本文整理汇总了PHP中modX::toJSON方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::toJSON方法的具体用法?PHP modX::toJSON怎么用?PHP modX::toJSON使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::toJSON方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importAttachments
/**
* Import all attachments for this post
* @param disPost $post
* @param array $prow
* @return array
*/
public function importAttachments(disPost $post, array $prow = array())
{
$ast = $this->pdo->query('
SELECT
*
FROM ' . $this->getFullTableName('attachments') . '
WHERE
`ID_MSG` = ' . $prow['ID_MSG'] . '
');
if (!$ast) {
return array();
}
$aIdx = 0;
while ($arow = $ast->fetch(PDO::FETCH_ASSOC)) {
$this->log('Adding attachment: ' . $arow['filename']);
/** @var disPostAttachment $attachment */
$attachment = $this->modx->newObject('disPostAttachment');
$attachment->fromArray(array('post' => $post->get('id'), 'board' => $post->get('board'), 'filename' => $arow['filename'], 'filesize' => $arow['size'], 'downloads' => $arow['downloads'], 'integrated_id' => $arow['ID_ATTACH'], 'integrated_data' => $this->modx->toJSON(array('filename' => $arow['filename'], 'file_hash' => $arow['file_hash'], 'width' => $arow['width'], 'height' => $arow['height'], 'attachmentType' => $arow['attachmentType'], 'ID_MEMBER' => $arow['ID_MEMBER'], 'ID_MESSAGE' => !empty($arow['ID_MESSAGE']) ? $arow['ID_MESSAGE'] : 0, 'ID_THUMB' => $arow['ID_THUMB']))));
if ($this->config['live']) {
$attachment->save();
}
$aIdx++;
}
$ast->closeCursor();
}
示例2: install
protected function install($packagesDir, $dir, $packagesBaseUrl, OutputInterface $output)
{
$configContent = $this->modx->fromJSON(file_get_contents($packagesDir . $dir . '/_build/config.json'));
$this->config = new Config($this->modx, $dir);
$this->config->parseConfig($configContent);
$this->packageCorePath = $packagesDir . $dir . "/core/components/" . $this->config->getLowCaseName() . "/";
$this->packageCorePath = str_replace('\\', '/', $this->packageCorePath);
$this->packageAssetsPath = $packagesDir . $dir . "/assets/components/" . $this->config->getLowCaseName() . "/";
$this->packageAssetsPath = str_replace('\\', '/', $this->packageAssetsPath);
$this->packageAssetsUrl = $packagesBaseUrl . $dir . '/assets/components/' . $this->config->getLowCaseName() . '/';
$this->createNamespace();
$this->createMenusAndActions();
$this->createSystemSettings($packagesDir, $packagesBaseUrl);
$this->createTables();
$this->clearCache();
/** @var \GitPackage $packageObject */
$packageObject = $this->modx->newObject('GitPackage');
$packageObject->set('version', $this->config->getVersion());
$packageObject->set('description', $this->config->getDescription());
$packageObject->set('author', $this->config->getAuthor());
$packageObject->set('name', $this->config->getName());
$packageObject->set('dir_name', $dir);
$packageObject->set('config', $this->modx->toJSON($configContent));
$packageObject->save();
}
示例3: toJSON
/**
* Converts PHP to JSON with JavaScript literals left in-tact.
*
* JSON does not allow JavaScript literals, but this function encodes certain identifiable
* literals and decodes them back into literals after modX::toJSON() formats the data.
*
* @access public
* @param mixed $data The PHP data to be converted.
* @return string The extended JSON-encoded string.
*/
public function toJSON($data)
{
if (is_array($data)) {
array_walk_recursive($data, array(&$this, '_encodeLiterals'));
}
return $this->_decodeLiterals($this->modx->toJSON($data));
}
示例4: loadJsCss
/**
* Loads javascript and styles for ajax pagination
*
*/
public function loadJsCss()
{
$assetsUrl = !empty($this->pdoTools->config['assetsUrl']) ? $this->pdoTools->config['assetsUrl'] : MODX_ASSETS_URL . 'components/pdotools/';
if ($css = trim($this->pdoTools->config['frontend_css'])) {
$this->modx->regClientCSS(str_replace('[[+assetsUrl]]', $assetsUrl, $css));
}
if ($js = trim($this->pdoTools->config['frontend_js'])) {
$this->modx->regClientScript(str_replace('[[+assetsUrl]]', $assetsUrl, $js));
}
$ajaxHistory = $this->pdoTools->config['ajaxHistory'] === '' ? !in_array($this->pdoTools->config['ajaxMode'], array('scroll', 'button')) : !empty($this->pdoTools->config['ajaxHistory']);
$limit = $this->pdoTools->config['limit'] > $this->pdoTools->config['maxLimit'] ? $this->pdoTools->config['maxLimit'] : $this->pdoTools->config['limit'];
$moreChunk = $this->modx->getOption('ajaxTplMore', $this->pdoTools->config, '@INLINE <button class="btn btn-default btn-more">[[%pdopage_more]]</button>');
$moreTpl = $this->pdoTools->getChunk($moreChunk, array('limit' => $limit));
$hash = sha1($this->modx->toJSON($this->pdoTools->config));
$_SESSION['pdoPage'][$hash] = $this->pdoTools->config;
$config = $this->modx->toJSON(array('wrapper' => $this->modx->getOption('ajaxElemWrapper', $this->pdoTools->config, '#pdopage'), 'rows' => $this->modx->getOption('ajaxElemRows', $this->pdoTools->config, '#pdopage .rows'), 'pagination' => $this->modx->getOption('ajaxElemPagination', $this->pdoTools->config, '#pdopage .pagination'), 'link' => $this->modx->getOption('ajaxElemLink', $this->pdoTools->config, '#pdopage .pagination a'), 'more' => $this->modx->getOption('ajaxElemMore', $this->pdoTools->config, '#pdopage .btn-more'), 'moreTpl' => $moreTpl, 'mode' => $this->pdoTools->config['ajaxMode'], 'history' => (int) $ajaxHistory, 'pageVarKey' => $this->pdoTools->config['pageVarKey'], 'pageLimit' => $limit, 'assetsUrl' => $assetsUrl, 'connectorUrl' => rtrim($assetsUrl, '/') . '/connector.php', 'pageId' => $this->modx->resource->id, 'hash' => $hash));
$this->modx->regClientStartupScript('<script type="text/javascript">pdoPage = {callbacks: {}, keys: {}, configs: {}};</script>', true);
$this->modx->regClientScript('<script type="text/javascript">pdoPage.initialize(' . $config . ');</script>', true);
}
示例5: render
/**
* Gets the challenge HTML (javascript and non-javascript version).
* This is called from the browser, and the resulting reCAPTCHA HTML widget
* is embedded within the HTML form it was called from.
*
* @param array $scriptProperties
* @return string - The HTML to be embedded in the user's form.
*/
public function render($scriptProperties = array())
{
if (empty($this->config[FormItReCaptcha::OPT_PUBLIC_KEY])) {
return $this->error($this->modx->lexicon('recaptcha.no_api_key'));
}
/* use ssl or not */
$server = !empty($this->config[FormItReCaptcha::OPT_USE_SSL]) ? FormItReCaptcha::API_SECURE_SERVER : FormItReCaptcha::API_SERVER;
$opt = $this->getOptions($scriptProperties);
$html = '<script type="text/javascript">var RecaptchaOptions = ' . $this->modx->toJSON($opt) . ';</script><script type="text/javascript" src="' . $server . 'challenge?k=' . $this->config[FormItReCaptcha::OPT_PUBLIC_KEY] . '"></script>
<noscript><div>
<object data="' . $server . 'noscript?k=' . $this->config[FormItReCaptcha::OPT_PUBLIC_KEY] . '" height="' . $opt['height'] . '" width="' . $opt['width'] . '" style="width: ' . $opt['width'] . 'px; height: ' . $opt['height'] . 'px;"></object>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/></div>
</noscript>';
$this->modx->setPlaceholder('formit.recaptcha_html', $html);
$this->modx->setPlaceholder($scriptProperties['placeholderPrefix'] . 'recaptcha_html', $html);
return $html;
}
示例6: setFieldsAsPlaceholders
/**
* Sets the fields to MODX placeholders
* @return void
*/
public function setFieldsAsPlaceholders()
{
$fields = $this->dictionary->toArray();
/* better handling of checkbox values when input name is an array[] */
$fs = array();
/** @var mixed $v */
foreach ($fields as $k => $v) {
if (is_array($v) && !isset($_FILES[$k])) {
foreach ($v as $sk => $sv) {
$fs[$k . '.' . $sk] = $this->convertMODXTags($sv);
}
$v = $this->modx->toJSON($v);
}
/* str_replace to prevent showing of placeholders */
$fs[$k] = $this->convertMODXTags($v);
}
$this->modx->setPlaceholders($fs, $this->config['placeholderPrefix']);
}
示例7: loadControllerFiles
/**
* @param modManagerController $controller
* @param array $opts
*/
public function loadControllerFiles(modManagerController $controller, array $opts = array())
{
$config = $this->config;
$config['connector_url'] = $this->config['connectorUrl'];
$config['fields_grid_domain'] = $this->getDomainGridFields();
if (!empty($opts['css'])) {
$controller->addCss($this->config['cssUrl'] . 'mgr/main.css');
$controller->addCss($this->config['cssUrl'] . 'mgr/bootstrap.buttons.css');
}
if (!empty($opts['config'])) {
$controller->addHtml("<script type='text/javascript'>subdomainsfolder.config={$this->modx->toJSON($config)}</script>");
}
if (!empty($opts['tools'])) {
$controller->addJavascript($this->config['jsUrl'] . 'mgr/subdomainsfolder.js');
$controller->addJavascript($this->config['jsUrl'] . 'mgr/misc/tools.js');
$controller->addJavascript($this->config['jsUrl'] . 'mgr/misc/combo.js');
}
if (!empty($opts['domain'])) {
$controller->addLastJavascript($this->config['jsUrl'] . 'mgr/domain/domain.window.js');
$controller->addLastJavascript($this->config['jsUrl'] . 'mgr/domain/domain.grid.js');
$controller->addLastJavascript($this->config['jsUrl'] . 'mgr/domain/domain.panel.js');
}
}
示例8: submit
/** @inheritdoc} */
public function submit($data = array())
{
$response = $this->ms2->invokeEvent('msOnSubmitOrder', array('data' => $data, 'order' => $this));
if (!$response['success']) {
return $this->error($response['message']);
}
if (!empty($response['data']['data'])) {
$this->set($response['data']['data']);
}
$response = $this->getDeliveryRequiresFields();
if ($this->ms2->config['json_response']) {
$response = $this->modx->fromJSON($response);
}
$requires = $response['data']['requires'];
$errors = array();
foreach ($requires as $v) {
if (!empty($v) && empty($this->order[$v])) {
$errors[] = $v;
}
}
if (!empty($errors)) {
return $this->error('ms2_order_err_requires', $errors);
}
$user_id = $this->ms2->getCustomerId();
$cart_status = $this->ms2->cart->status();
$delivery_cost = $this->getCost(false, true);
$createdon = date('Y-m-d H:i:s');
/* @var msOrder $order */
$order = $this->modx->newObject('msOrder');
$order->fromArray(array('user_id' => $user_id, 'createdon' => $createdon, 'num' => $this->getnum(), 'delivery' => $this->order['delivery'], 'payment' => $this->order['payment'], 'cart_cost' => $cart_status['total_cost'], 'weight' => $cart_status['total_weight'], 'delivery_cost' => $delivery_cost, 'cost' => $cart_status['total_cost'] + $delivery_cost, 'status' => 0, 'context' => $this->ms2->config['ctx']));
// Adding address
/* @var msOrderAddress $address */
$address = $this->modx->newObject('msOrderAddress');
$address->fromArray(array_merge($this->order, array('user_id' => $user_id, 'createdon' => $createdon)));
$order->addOne($address);
// Adding products
$cart = $this->ms2->cart->get();
$products = array();
foreach ($cart as $v) {
/* @var msOrderProduct $product */
$product = $this->modx->newObject('msOrderProduct');
$product->fromArray(array_merge($v, array('product_id' => $v['id'], 'cost' => $v['price'] * $v['count'])));
$products[] = $product;
}
$order->addMany($products);
$response = $this->ms2->invokeEvent('msOnBeforeCreateOrder', array('msOrder' => $order, 'order' => $this));
if (!$response['success']) {
return $this->error($response['message']);
}
if ($order->save()) {
$response = $this->ms2->invokeEvent('msOnCreateOrder', array('msOrder' => $order, 'order' => $this));
if (!$response['success']) {
return $this->error($response['message']);
}
$this->ms2->cart->clean();
$this->clean();
if (empty($_SESSION['minishop2']['orders'])) {
$_SESSION['minishop2']['orders'] = array();
}
$_SESSION['minishop2']['orders'][] = $order->get('id');
// Trying to set status "new"
$response = $this->ms2->changeOrderStatus($order->get('id'), 1);
if ($response !== true) {
return $this->error($response, array('msorder' => $order->get('id')));
} elseif ($payment = $this->modx->getObject('msPayment', array('id' => $order->get('payment'), 'active' => 1))) {
$response = $payment->send($order);
if ($this->config['json_response']) {
@session_write_close();
exit(is_array($response) ? $this->modx->toJSON($response) : $response);
} else {
if (!empty($response['data']['redirect'])) {
$this->modx->sendRedirect($response['data']['redirect']);
exit;
} elseif (!empty($response['data']['msorder'])) {
$this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id), array('msorder' => $response['data']['msorder']));
exit;
} else {
$this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id));
exit;
}
}
} else {
if ($this->ms2->config['json_response']) {
return $this->success('', array('msorder' => $order->get('id')));
} else {
$this->modx->sendRedirect($this->modx->makeUrl($this->modx->resource->id), array('msorder' => $response['data']['msorder']));
exit;
}
}
}
return $this->error();
}
示例9: define
if (!defined('MODX_CORE_PATH')) {
define('MODX_CORE_PATH', dirname(dirname(__FILE__)) . '/core/');
}
if (!(include_once MODX_CORE_PATH . 'model/modx/modx.class.php')) {
die;
}
$modx = new modX('', array(xPDO::OPT_CONN_INIT => array(xPDO::OPT_CONN_MUTABLE => true)));
/* initialize the proper context */
$ctx = isset($_REQUEST['ctx']) && !empty($_REQUEST['ctx']) ? $_REQUEST['ctx'] : 'mgr';
$modx->initialize($ctx);
if (defined('MODX_REQP') && MODX_REQP === false) {
} else {
if (!is_object($modx->context) || !$modx->context->checkPolicy('load')) {
header("Content-Type: application/json; charset=UTF-8");
header('HTTP/1.1 401 Not Authorized');
echo $modx->toJSON(array('success' => false, 'code' => 401));
@session_write_close();
die;
}
}
if ($ctx == 'mgr') {
$ml = $modx->getOption('manager_language', null, 'en');
if ($ml != 'en') {
$modx->lexicon->load($ml . ':core:default');
$modx->setOption('cultureKey', $ml);
}
}
/* handle the request */
$connectorRequestClass = $modx->getOption('modConnectorRequest.class', null, 'modConnectorRequest');
$modx->config['modRequest.class'] = $connectorRequestClass;
$modx->getRequest();
示例10: array
SELECT
*
FROM ' . $discuss->import->getFullTableName('attachments') . '
WHERE
`ID_MSG` != 0
');
if (!$ast) {
return array();
}
$aIdx = 0;
while ($arow = $ast->fetch(PDO::FETCH_ASSOC)) {
$post = $modx->getObject('disPost', array('integrated_id' => $arow['ID_MSG']));
if ($post) {
$discuss->import->log('Adding attachment: ' . $arow['filename']);
$attachment = $modx->newObject('disPostAttachment');
$attachment->fromArray(array('post' => $post->get('id'), 'board' => $post->get('board'), 'filename' => $arow['filename'], 'filesize' => $arow['size'], 'downloads' => $arow['downloads'], 'integrated_id' => $arow['ID_ATTACH'], 'integrated_data' => $modx->toJSON(array('filename' => $arow['filename'], 'file_hash' => $arow['file_hash'], 'width' => $arow['width'], 'height' => $arow['height'], 'attachmentType' => $arow['attachmentType'], 'ID_MEMBER' => $arow['ID_MEMBER'], 'ID_MSG' => $arow['ID_MSG'], 'ID_THUMB' => $arow['ID_THUMB']))));
$attachment->save();
$aIdx++;
}
}
$ast->closeCursor();
} else {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Failed to load Import class.');
}
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$modx->log(modX::LOG_LEVEL_INFO, "\nExecution time: {$totalTime}\n");
示例11: getProperties
/**
* Get the properties on this source
* @param boolean $parsed
* @return array
*/
public function getProperties($parsed = false)
{
$properties = $this->get('properties');
$defaultProperties = $this->getDefaultProperties();
if (!empty($properties) && is_array($properties)) {
foreach ($properties as &$property) {
$property['overridden'] = 0;
if (array_key_exists($property['name'], $defaultProperties)) {
if ($defaultProperties[$property['name']]['value'] != $property['value']) {
$property['overridden'] = 1;
}
} else {
$property['overridden'] = 2;
}
}
$properties = array_merge($defaultProperties, $properties);
} else {
$properties = $defaultProperties;
}
/** @var array $results Allow manipulation of media source properties via event */
$results = $this->xpdo->invokeEvent('OnMediaSourceGetProperties', array('properties' => $this->xpdo->toJSON($properties)));
if (!empty($results)) {
foreach ($results as $result) {
$result = is_array($result) ? $result : $this->xpdo->fromJSON($result);
$properties = array_merge($properties, $result);
}
}
if ($parsed) {
$properties = $this->parseProperties($properties);
}
return $this->prepareProperties($properties);
}
示例12: elseif
}
if (strpos($path, $core_path) === 0) {
$path = str_replace($core_path, '[[++core_path]]', $path);
} elseif (strpos($path, $assets_path) === 0) {
$path = str_replace($assets_path, '[[++assets_path]]', $path);
} elseif (strpos($path, $manager_path) === 0) {
$path = str_replace($manager_path, '[[++manager_path]]', $path);
} elseif (strpos($path, $base_path) === 0) {
$path = str_replace($base_path, '[[++base_path]]', $path);
}
$pkg['path'] = $path;
}
}
}
$modx->log(modX::LOG_LEVEL_INFO, "Setting extension packages to: " . print_r($extPackages, true));
$object->set('value', $modx->toJSON($extPackages));
$package->put($object, array_merge($attributes, array('resolve' => array(array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.extension_packages.php')))));
}
/* loop through the classes and package the objects */
foreach ($classes as $class) {
if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
set_time_limit(0);
}
$instances = 0;
$classCriteria = null;
$classAttributes = $attributes;
switch ($class) {
case 'modSession':
/* skip sessions */
continue 2;
case 'modSystemSetting':
示例13: loadManagerFiles
/**
* @param modManagerController $controller
* @param modResource $resource
*/
public function loadManagerFiles(modManagerController $controller, modResource $resource)
{
$modx23 = (int) $this->systemVersion();
$cssUrl = $this->config['cssUrl'] . 'mgr/';
$jsUrl = $this->config['jsUrl'] . 'mgr/';
$properties = $resource->getProperties('ms2gallery');
if (empty($properties['media_source'])) {
if (!($source_id = $resource->getTVValue('ms2Gallery'))) {
/** @var modContextSetting $setting */
$setting = $this->modx->getObject('modContextSetting', array('key' => 'ms2gallery_source_default', 'context_key' => $resource->get('context_key')));
$source_id = !empty($setting) ? $setting->get('value') : $this->modx->getOption('ms2gallery_source_default');
}
$resource->setProperties(array('media_source' => $source_id), 'ms2gallery');
$resource->save();
} else {
$source_id = $properties['media_source'];
}
if (empty($source_id)) {
$source_id = $this->modx->getOption('ms2gallery_source_default');
}
$resource->set('media_source', $source_id);
$controller->addLexiconTopic('ms2gallery:default');
$controller->addJavascript($jsUrl . 'ms2gallery.js');
$controller->addLastJavascript($jsUrl . 'misc/ms2.combo.js');
$controller->addLastJavascript($jsUrl . 'misc/ms2.utils.js');
$controller->addLastJavascript($jsUrl . 'misc/plupload/plupload.full.js');
$controller->addLastJavascript($jsUrl . 'misc/ext.ddview.js');
$controller->addLastJavascript($jsUrl . 'gallery.view.js');
$controller->addLastJavascript($jsUrl . 'gallery.window.js');
$controller->addLastJavascript($jsUrl . 'gallery.toolbar.js');
$controller->addLastJavascript($jsUrl . 'gallery.panel.js');
$controller->addCss($cssUrl . 'main.css');
if (!$modx23) {
$controller->addCss($cssUrl . 'font-awesome.min.css');
}
$source_config = array();
/** @var modMediaSource $source */
if ($source = $this->modx->getObject('modMediaSource', $source_id)) {
$tmp = $source->getProperties();
foreach ($tmp as $v) {
$source_config[$v['name']] = $v['value'];
}
}
$controller->addHtml('
<script type="text/javascript">
MODx.modx23 = ' . $modx23 . ';
ms2Gallery.config = ' . $this->modx->toJSON($this->config) . ';
ms2Gallery.config.media_source = ' . $this->modx->toJSON($source_config) . ';
</script>');
if ($this->modx->getOption('ms2gallery_new_tab_mode', null, true)) {
$controller->addLastJavascript($jsUrl . 'tab.js');
} else {
$insert = '
tabs.add({
xtype: "ms2gallery-page",
id: "ms2gallery-page",
title: _("ms2gallery"),
record: {
id: ' . $resource->get('id') . ',
source: ' . $source_id . ',
}
});
';
if ($this->modx->getCount('modPlugin', array('name' => 'AjaxManager', 'disabled' => false))) {
$controller->addHtml('
<script type="text/javascript">
Ext.onReady(function() {
window.setTimeout(function() {
var tabs = Ext.getCmp("modx-resource-tabs");
if (tabs) {
' . $insert . '
}
}, 10);
});
</script>');
} else {
$controller->addHtml('
<script type="text/javascript">
Ext.ComponentMgr.onAvailable("modx-resource-tabs", function() {
var tabs = this;
tabs.on("beforerender", function() {
' . $insert . '
});
});
</script>');
}
}
}
示例14: success
/**
* This method returns an success of the order
*
* @param string $message A lexicon key for success message
* @param array $data.Additional data, for example cart status
* @param array $placeholders Array with placeholders for lexicon entry
*
* @return array|string $response
*/
public function success($message = '', $data = array(), $placeholders = array())
{
$response = array('success' => true, 'message' => $this->modx->lexicon($message, $placeholders), 'data' => $data);
return $this->config['json_response'] ? $this->modx->toJSON($response) : $response;
}
示例15: process
//.........这里部分代码省略.........
if ($object) {
$extPackages = $object->get('value');
$extPackages = $modx->fromJSON($extPackages);
foreach ($extPackages as &$extPackage) {
if (!is_array($extPackage)) {
continue;
}
foreach ($extPackage as $pkgName => &$pkg) {
if (!empty($pkg['path']) && strpos($pkg['path'], '[[++') === false) {
if (substr($pkg['path'], 0, 1) !== '/' || strpos($pkg['path'], $base_path) !== 0 && strpos($pkg['path'], $core_path) !== 0) {
$path = realpath($pkg['path']);
if ($path === false) {
$path = $pkg['path'];
} else {
$path = rtrim($path, '/') . '/';
}
} else {
$path = $pkg['path'];
}
if (strpos($path, $core_path) === 0) {
$path = str_replace($core_path, '[[++core_path]]', $path);
} elseif (strpos($path, $assets_path) === 0) {
$path = str_replace($assets_path, '[[++assets_path]]', $path);
} elseif (strpos($path, $manager_path) === 0) {
$path = str_replace($manager_path, '[[++manager_path]]', $path);
} elseif (strpos($path, $base_path) === 0) {
$path = str_replace($base_path, '[[++base_path]]', $path);
}
$pkg['path'] = $path;
}
}
}
$modx->log(modX::LOG_LEVEL_INFO, "Setting extension packages to: " . print_r($extPackages, true));
$object->set('value', $modx->toJSON($extPackages));
$package->put($object, array_merge($attributes, array('resolve' => array(array('type' => 'php', 'source' => VAPOR_DIR . 'scripts/resolve.extension_packages.php')))));
}
}
/* loop through the classes and package the objects */
foreach ($classes as $class) {
if (!XPDO_CLI_MODE && !ini_get('safe_mode')) {
set_time_limit(0);
}
$instances = 0;
$classCriteria = null;
$classAttributes = $attributes;
switch ($class) {
case 'modSession':
/* skip sessions */
continue 2;
case 'modSystemSetting':
$classCriteria = array('key:!=' => 'extension_packages');
break;
case 'modWorkspace':
/** @var modWorkspace $object */
foreach ($modx->getIterator('modWorkspace', $classCriteria) as $object) {
if (strpos($object->path, $core_path) === 0) {
$object->set('path', str_replace($core_path, '{core_path}', $object->path));
} elseif (strpos($object->path, $assets_path) === 0) {
$object->set('path', str_replace($assets_path, '{assets_path}', $object->path));
} elseif (strpos($object->path, $manager_path) === 0) {
$object->set('path', str_replace($manager_path, '{manager_path}', $object->path));
} elseif (strpos($object->path, $base_path) === 0) {
$object->set('path', str_replace($base_path, '{base_path}', $object->path));
}
if ($package->put($object, $classAttributes)) {
$instances++;