/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('msprofile_core_path', $config, $this->modx->getOption('core_path') . 'components/msprofile/'); $assetsUrl = $this->modx->getOption('msprofile_assets_url', $config, $this->modx->getOption('assets_url') . 'components/msprofile/'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $connectorUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'templatesPath' => $corePath . 'elements/templates/', 'chunkSuffix' => '.chunk.tpl', 'snippetsPath' => $corePath . 'elements/snippets/', 'processorsPath' => $corePath . 'processors/'), $config); $this->modx->addPackage('msprofile', $this->config['modelPath']); $this->modx->lexicon->load('msprofile:default'); $this->ms2 = $modx->getService('miniShop2'); $this->ms2->initialize($this->modx->context->key); }
/** * Initialize the importer and load the Quip package */ public function initialize() { @set_time_limit(0); @ini_set('memory_limit', '1024M'); $quipPath = $this->modx->getOption('quip.core_path', null, $this->modx->getOption('core_path') . 'components/quip/'); $this->modx->addPackage('quip', $quipPath . 'model/'); }
/** * Constructs the object * * @param modX &$modx A reference to the modX object * @param array $config An array of configuration options */ public function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $basePath = $this->modx->getOption('quickstartbuttons.core_path', $config, $this->modx->getOption('core_path') . 'components/quickstartbuttons/'); $assetsPath = $this->modx->getOption('quickstartbuttons.assets_path', $config, $this->modx->getOption('assets_path') . 'components/quickstartbuttons/'); $assetsUrl = $this->modx->getOption('quickstartbuttons.assets_url', $config, $this->modx->getOption('assets_url') . 'components/quickstartbuttons/'); $this->config = array_merge(array('basePath' => $basePath, 'corePath' => $basePath, 'lexiconPath' => $basePath . 'lexicon/', 'modelPath' => $basePath . 'model/', 'controllersPath' => $basePath . 'controllers/', 'processorsPath' => $basePath . 'processors/', 'templatesPath' => $basePath . 'templates/', 'elementsPath' => $basePath . 'elements/', 'chunksPath' => $basePath . 'elements/chunks/', 'hooksPath' => $basePath . 'hooks/', 'assetsPath' => $assetsPath, 'ordersPath' => $assetsPath . 'orders/', 'assetsUrl' => $assetsUrl, 'connectorUrl' => $assetsUrl . 'connector.php', 'jsUrl' => $assetsUrl . 'js/', 'cssUrl' => $assetsUrl . 'css/', 'imgsUrl' => $assetsUrl . 'images/'), $config); $this->modx->addPackage('quickstartbuttons', $this->config['modelPath']); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('urlhistory.core_path', $config, $this->modx->getOption('core_path') . 'components/urlhistory/'); $assetsUrl = $this->modx->getOption('urlhistory.assets_url', $config, $this->modx->getOption('assets_url') . 'components/urlhistory/'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $connectorUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'chunkSuffix' => '.chunk.tpl', 'snippetsPath' => $corePath . 'elements/snippets/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/'), $config); $this->modx->addPackage('urlhistory', $this->config['modelPath']); $this->modx->lexicon->load('urlhistory:default'); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $this->namespace = $this->getOption('namespace', $config, 'a11y'); $corePath = $this->getOption('core_path', $config, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/a11y/'); $assetsUrl = $this->getOption('assets_url', $config, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/a11y/'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assets_url' => $assetsUrl, 'core_path' => $corePath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $connectorUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/'), $config); $this->modx->addPackage('a11y', $this->config['modelPath']); $this->modx->lexicon->load('a11y:default'); $this->modx->lexicon->load('a11y:dashboard'); }
/** * @param \modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('clientconfig.core_path', $config, $this->modx->getOption('core_path') . 'components/clientconfig/'); $assetsUrl = $this->modx->getOption('clientconfig.assets_url', $config, $this->modx->getOption('assets_url') . 'components/clientconfig/'); $assetsPath = $this->modx->getOption('clientconfig.assets_path', $config, $this->modx->getOption('assets_path') . 'components/clientconfig/'); $this->config = array_merge(array('basePath' => $corePath, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'elementsPath' => $corePath . 'elements/', 'templatesPath' => $corePath . 'templates/', 'assetsPath' => $assetsPath, 'jsUrl' => $assetsUrl . 'js/', 'cssUrl' => $assetsUrl . 'css/', 'assetsUrl' => $assetsUrl, 'connectorUrl' => $assetsUrl . 'connector.php', 'verticalTabs' => (bool) $this->modx->getOption('clientconfig.vertical_tabs', null, false)), $config); $modelPath = $this->config['modelPath']; $this->modx->addPackage('clientconfig', $modelPath); $this->modx->lexicon->load('clientconfig:default'); $this->debug = (bool) $this->modx->getOption('clientconfig.debug', null, false); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $this->namespace = $this->getOption('namespace', $config, 'collections'); $corePath = $this->getOption('core_path', $config, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/collections/'); $assetsUrl = $this->getOption('assets_url', $config, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/collections/'); $connectorUrl = $assetsUrl . 'connector.php'; $taggerCorePath = $modx->getOption('tagger.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/tagger/'); if (file_exists($taggerCorePath . 'model/tagger/tagger.class.php')) { /** @var Tagger $tagger */ $tagger = $modx->getService('tagger', 'Tagger', $taggerCorePath . 'model/tagger/', array('core_path' => $taggerCorePath)); } else { $tagger = null; } $quipCorePath = $modx->getOption('quip.core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/quip/'); if (file_exists($quipCorePath . 'model/quip/quip.class.php')) { /** @var Quip $quip */ $quip = $modx->getService('quip', 'Quip', $quipCorePath . 'model/quip/', array('core_path' => $quipCorePath)); } else { $quip = null; } $this->config = array_merge(array('assets_url' => $assetsUrl, 'core_path' => $corePath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $connectorUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'chunkSuffix' => '.chunk.tpl', 'snippetsPath' => $corePath . 'elements/snippets/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/', 'taggerInstalled' => $tagger instanceof Tagger, 'quipInstalled' => $quip instanceof Quip), $config); $this->modx->addPackage('collections', $this->config['modelPath']); $this->modx->lexicon->load('collections:default'); $this->modx->lexicon->load('collections:selections'); }
/** * @param \modX $modx * @param array $config */ public function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $basePath = $this->modx->getOption('scheduler.core_path', $config, $this->modx->getOption('core_path') . 'components/scheduler/'); $assetsUrl = $this->modx->getOption('scheduler.assets_url', $config, $this->modx->getOption('assets_url') . 'components/scheduler/'); $assetsPath = $this->modx->getOption('scheduler.assets_path', $config, $this->modx->getOption('assets_path') . 'components/scheduler/'); $managerUrl = $this->modx->getOption('manager_url', $config, $this->modx->getOption('base_url') . 'manager/'); $this->config = array_merge(array('basePath' => $basePath, 'corePath' => $basePath, 'modelPath' => $basePath . 'model/', 'processorsPath' => $basePath . 'processors/', 'elementsPath' => $basePath . 'elements/', 'templatesPath' => $basePath . 'templates/', 'assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'jsUrl' => $assetsUrl . 'js/', 'cssUrl' => $assetsUrl . 'css/', 'connectorUrl' => $assetsUrl . 'connector.php', 'managerUrl' => $managerUrl, 'hideLogo' => $this->modx->getOption('scheduler.hideLogo', null, false)), $config); $this->modx->addPackage('scheduler', $this->config['modelPath']); $this->modx->loadClass('sTask', $this->config['modelPath'] . 'scheduler/'); $this->modx->loadClass('sTaskRun', $this->config['modelPath'] . 'scheduler/'); }
/** * Loads specified list of packages models */ public function loadModels() { if (empty($this->config['loadModels'])) { return; } $time = microtime(true); $models = array(); if (strpos(ltrim($this->config['loadModels']), '{') === 0) { $tmp = $this->modx->fromJSON($this->config['loadModels']); foreach ($tmp as $k => $v) { $v = trim(strtolower($v)); $models[$k] = strpos($v, MODX_CORE_PATH) === false ? MODX_CORE_PATH . ltrim($v, '/') : $v; } } else { $tmp = array_map('trim', explode(',', $this->config['loadModels'])); foreach ($tmp as $v) { $models[$v] = MODX_CORE_PATH . 'components/' . strtolower($v) . '/model/'; } } if (!empty($models)) { foreach ($models as $k => $v) { $t = '/' . str_replace(MODX_BASE_PATH, '', $v); if ($this->modx->addPackage(strtolower($k), $v)) { $this->addTime('Loaded model "' . $k . '" from "' . $t . '"', microtime(true) - $time); } else { $this->addTime('Could not load model "' . $k . '" from "' . $t . '"', microtime(true) - $time); } $time = microtime(true); } } $this->config['loadModels'] = ''; }
/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('ms2gallery.core_path', $config, $this->modx->getOption('core_path') . 'components/ms2gallery/'); $assetsUrl = $this->modx->getOption('ms2gallery.assets_url', $config, $this->modx->getOption('assets_url') . 'components/ms2gallery/'); $actionUrl = $this->modx->getOption('ms2gallery.action_url', $config, $assetsUrl . 'action.php'); $connectorUrl = $assetsUrl . 'connector.php'; $pageSize = $this->modx->getOption('ms2gallery_page_size', null, 20); $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'customPath' => $corePath . 'custom/', 'connector_url' => $connectorUrl, 'actionUrl' => $actionUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'ctx' => 'web', 'json_response' => false, 'templatesPath' => $corePath . 'elements/templates/', 'pageSize' => $pageSize), $config); $this->modx->addPackage('ms2gallery', $this->config['modelPath']); $this->modx->lexicon->load('ms2gallery:default'); }
public static function add(phpThumbOn $ThumbOn, modX $modx) { $from = $ThumbOn->getOption('input'); $to = $ThumbOn->getOption('_cacheFileName'); $options = $ThumbOn->getOption('_options', array('f' => $ThumbOn::DEFAULT_EXT)); $noImage = $ThumbOn->getOption('noimage'); $modx->addPackage("phpthumbon", $ThumbOn->getOption('modelPath')); switch ($ThumbOn->getOption('queue')) { case 2: //Отправляем в очередь и сжимаем картику noimage $path = $ThumbOn->getOption('assetsPath', MODX_BASE_PATH . '/assets/') . "/components/phpthumbon/cache/"; $tmp = md5(serialize($options)) . "." . $options['f']; $ThumbOn->makeDir($path); if (file_exists($path . $tmp)) { copy($path . $tmp, $to); } else { if ($to = $ThumbOn->loadResizer($noImage, $to)) { copy($to, $path . $tmp); } } $modx->newObject("ThumbImages", array('image' => $from, 'cache_image' => $to, 'config' => $options, 'isend' => $from == $noImage))->save(); break; case 1: default: //Отправляем в очередь и сразу отдаем картинку noimage if (!file_exists($to)) { copy($noImage, $to); } $modx->newObject("ThumbImages", array('image' => $from, 'cache_image' => $to, 'config' => $options, 'isend' => 0))->save(); break; } return $to; }
public function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('msearch2.core_path', $config, $this->modx->getOption('core_path') . 'components/msearch2/'); $assetsUrl = $this->modx->getOption('msearch2.assets_url', $config, $this->modx->getOption('assets_url') . 'components/msearch2/'); $actionUrl = $this->modx->getOption('msearch2.action_url', $config, $assetsUrl . 'action.php'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'customPath' => $corePath . 'custom/', 'connectorUrl' => $connectorUrl, 'actionUrl' => $actionUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'templatesPath' => $corePath . 'elements/templates/', 'processorsPath' => $corePath . 'processors/', 'cacheTime' => 1800, 'languages' => array('ru_RU' => array('storage' => 'file'), 'en_EN' => array('storage' => 'file')), 'min_word_length' => $this->modx->getOption('mse2_index_min_words_length', null, 3, true), 'exact_match_bonus' => $this->modx->getOption('mse2_search_exact_match_bonus', null, 5, true), 'all_words_bonus' => $this->modx->getOption('mse2_search_all_words_bonus', null, 5, true), 'introCutBefore' => 50, 'introCutAfter' => 250, 'filter_delimeter' => '|', 'method_delimeter' => ':', 'values_delimeter' => ',', 'split_words' => $this->modx->getOption('mse2_search_split_words', null, '#\\s#', true), 'split_all' => '#\\s|[,.:;!?"\'(){}\\/\\#]#', 'suggestionsRadio' => array()), $config); if (!is_array($this->config['languages'])) { $this->config['languages'] = $modx->fromJSON($this->config['languages']); } if (!is_array($this->config['suggestionsRadio'])) { $this->config['suggestionsRadio'] = array_map('trim', explode(',', $this->config['suggestionsRadio'])); } $this->modx->addPackage('msearch2', $this->config['modelPath']); $this->modx->lexicon->load('msearch2:default'); }
public function __construct(modX &$modx, array $config = array(), pdoTools &$pdoTools = null) { $this->modx =& $modx; $corePath = $this->modx->getOption('msearch2.core_path', $config, $this->modx->getOption('core_path') . 'components/msearch2/'); $assetsPath = $this->modx->getOption('msearch2.assets_path', $config, $this->modx->getOption('assets_path') . 'components/msearch2/'); $assetsUrl = $this->modx->getOption('msearch2.assets_url', $config, $this->modx->getOption('assets_url') . 'components/msearch2/'); $actionUrl = $this->modx->getOption('msearch2.action_url', $config, $assetsUrl . 'action.php'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'jsPath' => $assetsPath . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'customPath' => $corePath . 'custom/', 'dictsPath' => $corePath . 'phpmorphy/dicts/', 'connectorUrl' => $connectorUrl, 'actionUrl' => $actionUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'templatesPath' => $corePath . 'elements/templates/', 'processorsPath' => $corePath . 'processors/', 'cacheTime' => 1800, 'min_word_length' => $this->modx->getOption('mse2_index_min_words_length', null, 3, true), 'exact_match_bonus' => $this->modx->getOption('mse2_search_exact_match_bonus', null, 5, true), 'like_match_bonus' => $this->modx->getOption('mse2_search_like_match_bonus', null, 3, true), 'all_words_bonus' => $this->modx->getOption('mse2_search_all_words_bonus', null, 5, true), 'introCutBefore' => 50, 'introCutAfter' => 250, 'filter_delimeter' => '|', 'method_delimeter' => ':', 'values_delimeter' => ',', 'split_words' => $this->modx->getOption('mse2_search_split_words', null, '#\\s#', true), 'split_all' => $this->modx->getOption('mse2_index_split_words', null, '#\\s|[,.:;!?"\'(){}\\/\\#]#', true), 'index_all' => $this->modx->getOption('mse2_index_all', null, false), 'suggestionsRadio' => array(), 'autocomplete' => 0, 'queryVar' => 'query', 'minQuery' => 3, 'onlyIndex' => false, 'config_file' => $assetsPath . 'js/web/config.js'), $config); if (!is_array($this->config['suggestionsRadio'])) { $this->config['suggestionsRadio'] = array_map('trim', explode(',', $this->config['suggestionsRadio'])); } $this->modx->addPackage('msearch2', $this->config['modelPath']); $this->modx->lexicon->load('msearch2:default'); if (!empty($pdoTools) && $pdoTools instanceof pdoTools) { $this->pdoTools = $pdoTools; } $this->getWorkFields(); }
/** * The main constructor for Alpacka. This doesn't hardcode the instance to the modX class as that might change in * the future, and we don't want to manually update all derivative service classes when that happens. * * Your derivative constructor should look something like this: * * ```` php * public function __construct($instance, array $config = array()) * { * parent::__construct($instance, $config); * $this->setVersion(1, 3, 0, 'dev1'); * } * ```` * * Of course you can add additional logic in there as you please. * * @param \modX $instance * @param array $config */ public function __construct($instance, array $config = array()) { $this->modx = $instance; $this->config = array_merge($this->loadSettingsFromNamespace(), $config); // Automatically load the xPDO package if specified, as well as the default lexicon topic. if ($this->loadPackage && $this->namespace !== 'alpacka') { $this->modx->addPackage($this->namespace, $this->config['model_path']); } if ($this->loadLexicon && $this->namespace !== 'alpacka') { $this->modx->lexicon->load($this->namespace . ':default'); } }
/** * Add an element to the list * * @param integer $docId * @return bool|integer */ private function add($docId) { $found = 0; $newElement = array(); $newElement['rememberId'] = $docId; if (!$this->getOption('packagename')) { // no packagename -> resource $resource = $this->modx->getObject('modResource', array('id' => $docId)); $tvs = array(); $templateVars =& $resource->getMany('TemplateVars'); foreach ($templateVars as $templateVar) { $tvs[$this->getOption('tvPrefix') . $templateVar->get('name')] = $templateVar->renderOutput($resource->get('id')); } $row = array_merge($resource->toArray(), $tvs); } else { $packagepath = $this->modx->getOption('core_path') . 'components/' . $this->getOption('packagename') . '/'; $modelpath = $packagepath . 'model/'; $this->modx->addPackage($this->getOption('packagename'), $modelpath); $resource = $this->modx->getObject($this->getOption('classname'), array($this->getOption('keyname') => $docId)); if ($resource) { $joinvalues = array(); $joinoption = $this->getOption('joins'); if ($joinoption) { foreach ($joinoption as $join) { $values = $resource->getOne($join); $joinvalues[$join] = $values->toArray(); } } $row = array_merge($joinvalues, $resource->toArray()); } else { $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not retreive an object with key "' . $this->getOption('keyname') . '" and value "' . $docId . '"', '', 'RememberThis'); return false; } } $newElement['identifier'] = $row[$this->getOption('keyname')]; $newElement['itemtitle'] = $this->modx->getChunk($this->getOption('itemTitleTpl'), $row); foreach ($_SESSION['rememberThis'] as &$element) { if (!count(array_diff_assoc($element['element'], $newElement))) { $found = 1; } } if (!$found) { $_SESSION['rememberThis'][] = array('element' => $newElement); if ($this->getOption('useCookie')) { $this->setCookie(); } return key($_SESSION['rememberThis']); } else { return false; } }
protected function createTables() { if ($this->config->getDatabase() != null) { $modelPath = $this->packageCorePath . 'model/'; $this->modx->addPackage($this->config->getLowCaseName(), $modelPath, $this->config->getDatabase()->getPrefix()); foreach ($this->config->getDatabase()->getSimpleObjects() as $simpleObject) { $this->modx->loadClass($simpleObject); } $manager = $this->modx->getManager(); foreach ($this->config->getDatabase()->getTables() as $table) { $manager->createObjectContainer($table); } } }
/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; if (empty($config) && !empty($_SESSION['UploadifyConfig'])) { $this->config = $_SESSION['UploadifyConfig']; } else { $corePath = $this->modx->getOption('uploadify.core_path', $config, $this->modx->getOption('core_path') . 'components/uploadify/'); $assetsPath = $this->modx->getOption('uploadify.assets_path', $config, $this->modx->getOption('assets_path') . 'components/uploadify/'); $assetsUrl = $this->modx->getOption('uploadify.assets_url', $config, $this->modx->getOption('assets_url') . 'components/uploadify/'); //$connectorUrl = $assetsUrl.'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'assetsPath' => $assetsPath, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'actionUrl' => $assetsUrl . 'action.php', 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'maxFilesize' => 1048576, 'fileExtensions' => 'jpg,jpeg,png', 'imageExtensions' => 'jpg,jpeg,png', 'imageMaxWidth' => 1280, 'imageMaxHeight' => 720, 'imageQuality' => 99, 'thumbWidth' => 320, 'thumbHeight' => 240, 'thumbZC' => 'T', 'thumbBG' => 'ffffff', 'thumbFormat' => 'jpg', 'thumbQuality' => 90, 'source' => $this->modx->getOption('uf_source_default', null, 1, true), 'listThumbSize' => '320x240,640x480', 'listThumbZC' => '0,C', 'listThumbBG' => 'ffffff,000000', 'fromRetina' => isset($_SESSION['UploadifyConfig']['fromRetina']) ? $_SESSION['UploadifyConfig']['fromRetina'] : false, 'tplForm' => 'tpl.Uploadify.form', 'tplImage' => 'tpl.Uploadify.image', 'tplFile' => 'tpl.Uploadify.file', 'tplAuth' => 'tpl.Uploadify.auth', 'tplOption' => 'tpl.Uploadify.option', 'authSnippet' => null, 'host' => null), $config); $tmp = array('fileExtensions', 'imageExtensions', 'listThumbSize', 'listThumbZC', 'listThumbBG'); foreach ($tmp as $v) { $this->config[$v] = array_map('trim', explode(',', $this->config[$v])); } } $tmp = array('ThumbSize', 'ThumbZC', 'ThumbBG'); foreach ($tmp as $v) { $this->config['option' . $v] = isset($_SESSION['UploadifyConfig']['option' . $v]) && in_array($_SESSION['UploadifyConfig']['option' . $v], $this->config['list' . $v]) ? $_SESSION['UploadifyConfig']['option' . $v] : $this->config['list' . $v][0]; } if (!empty($this->config['optionThumbSize'])) { $tmp = array_map('trim', explode('x', $this->config['optionThumbSize'])); if (!empty($tmp[0]) && !empty($tmp[1])) { $this->config['thumbWidth'] = $tmp[0]; $this->config['thumbHeight'] = $tmp[1]; } } if (isset($this->config['optionThumbZC']) && $this->config['optionThumbZC'] != '') { $this->config['thumbZC'] = $this->config['optionThumbZC']; } if (isset($this->config['optionThumbBG']) && $this->config['optionThumbBG'] != '') { $this->config['thumbBG'] = $this->config['optionThumbBG']; } $_SESSION['UploadifyConfig'] = $this->config; $this->modx->addPackage('uploadify', $this->config['modelPath']); $this->modx->lexicon->load('uploadify:default'); }
/** * FormIt constructor * * @param modX &$modx A reference to the modX instance. * @param array $config An array of configuration options. Optional. */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; /* allows you to set paths in different environments * this allows for easier SVN management of files */ $corePath = $this->modx->getOption('formit.core_path', null, MODX_CORE_PATH . 'components/formit/'); $assetsPath = $this->modx->getOption('formit.assets_path', null, MODX_ASSETS_PATH . 'components/formit/'); $assetsUrl = $this->modx->getOption('formit.assets_url', null, MODX_ASSETS_URL . 'components/formit/'); $connectorUrl = $assetsUrl . 'connector.php'; /* loads some default paths for easier management */ $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/', 'controllersPath' => $corePath . 'controllers/', 'includesPath' => $corePath . 'includes/', 'testsPath' => $corePath . 'test/', 'templatesPath' => $corePath . 'templates/', 'assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $connectorUrl, 'debug' => $this->modx->getOption('formit.debug', null, false), 'use_multibyte' => (bool) $this->modx->getOption('use_multibyte', null, false), 'encoding' => $this->modx->getOption('modx_charset', null, 'UTF-8')), $config); if ($this->modx->getOption('formit.debug', $this->config, true)) { $this->startDebugTimer(); } $this->modx->addPackage('formit', $this->config['modelPath']); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $basePath = $this->modx->getOption('LTP.core_path', $config, $this->modx->getOption('core_path') . 'components/likeThisPage/'); $assetsUrl = $this->modx->getOption('LTP.assets_url', $config, $this->modx->getOption('assets_url') . 'components/likeThisPage/'); $this->config = array_merge(array('basePath' => $basePath, 'corePath' => $basePath, 'modelPath' => $basePath . 'model/', 'processorsPath' => $basePath . 'processors/', 'templatesPath' => $basePath . 'templates/', 'chunksPath' => $basePath . 'elements/chunks/', 'jsUrl' => $assetsUrl . 'js/', 'cssUrl' => $assetsUrl . 'css/', 'assetsUrl' => $assetsUrl, 'connectorUrl' => $assetsUrl . 'connector.php'), $config); $this->alan = 'GOD'; $this->cookieName = 'modx-likeThisPage-uuid'; $this->keyLength = 32; $this->jsFile = $this->config['assetsUrl'] . 'js/likeThisPage.functions.js'; $this->ObjectName = 'LikeThisPage'; $this->uuID = $this->getUniqueUserID(); $this->javascript = "LTP.ajax_url = '" . $this->config['assetsUrl'] . "likeThisPage.ajax.php';" . "\n"; $this->javascript .= "LTP.resID = " . $this->getCurrentResourceID() . ";" . "\n"; $this->javascript .= "if(document.getElementById('LTP_likeThisPageButton')!= null){document.getElementById('LTP_likeThisPageButton').onclick=function(){return LTP.likeThisPage();}};" . "\n"; // Add xPDO package $modx->addPackage('likeThisPage', $basePath . 'model/'); }
public function __construct(modX &$modx, $scriptProperties = array()) { $this->modx =& $modx; $modx->addPackage('msrevaluation', MODX_BASE_PATH . 'core/components/msrevaluation/model/'); $this->config = $scriptProperties; $this->config['assets_path'] = $modx->getOption('assets_path') . 'components/msrevaluation/'; $this->config['core_path'] = $modx->getOption('core_path') . 'components/msrevaluation/'; $this->config['assets_url'] = $modx->getOption('assets_url') . 'components/msrevaluation/'; $this->config['core_url'] = $modx->getOption('base_url') . 'core/components/msrevaluation/'; $this->config['connectorUrl'] = $this->config['assets_url'] . 'connector.php'; $protectedResources = array_merge(explode(',', $modx->getOption('protected_parents')), explode(',', $modx->getOption('protect_from_revaluation'))); $this->config['protected'] = array(); foreach ($protectedResources as $parent) { if (!($parent = (int) trim($parent))) { continue; } $childs = $modx->getChildIds($parent, 5, array('context' => 'web')); $this->config['protected'] = array_merge($this->config['protected'], $childs, array($parent)); } return true; }
/** * Loads specified list of packages models */ public function loadModels() { if (empty($this->config['loadModels'])) { return; } $time = microtime(true); $models = array(); if (strpos(ltrim($this->config['loadModels']), '{') === 0) { $tmp = $this->modx->fromJSON($this->config['loadModels']); foreach ($tmp as $k => $v) { if (!is_array($v)) { $v = array('path' => trim(strtolower($v))); } $v = array_merge(array('path' => MODX_CORE_PATH . 'components/' . strtolower($k) . '/model/', 'prefix' => null), $v); if (strpos($v['path'], MODX_CORE_PATH) === false) { $v['path'] = MODX_CORE_PATH . ltrim($v['path'], '/'); } $models[$k] = $v; } } else { $tmp = array_map('trim', explode(',', $this->config['loadModels'])); foreach ($tmp as $v) { $parts = explode(':', $v, 2); $models[$parts[0]] = array('path' => MODX_CORE_PATH . 'components/' . strtolower($parts[0]) . '/model/', 'prefix' => count($parts) > 1 ? $parts[1] : null); } } if (!empty($models)) { foreach ($models as $k => $v) { $t = '/' . str_replace(MODX_BASE_PATH, '', $v['path']); if ($this->modx->addPackage(strtolower($k), $v['path'], $v['prefix'])) { $this->addTime('Loaded model "' . $k . '" from "' . $t . '"', microtime(true) - $time); } else { $this->addTime('Could not load model "' . $k . '" from "' . $t . '"', microtime(true) - $time); } $time = microtime(true); } } $this->config['loadModels'] = ''; }
<?php require_once dirname(__FILE__) . '/build.config.php'; include_once MODX_CORE_PATH . 'model/modx/modx.class.php'; $modx = new modX(); $modx->initialize('mgr'); $modx->loadClass('transport.modPackageBuilder', '', false, true); $modx->setLogLevel(modX::LOG_LEVEL_INFO); $modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML'); $sources = array('model' => $modx->getOption('piwigomodx.core_path') . 'model/', 'schema_file' => $modx->getOption('piwigomodx.core_path') . 'model/schema/piwigomodx.mysql.schema.xml'); $manager = $modx->getManager(); $generator = $manager->getGenerator(); if (!is_dir($sources['model'])) { $modx->log(modX::LOG_LEVEL_ERROR, 'Model directory not found!'); die; } if (!file_exists($sources['schema_file'])) { $modx->log(modX::LOG_LEVEL_ERROR, 'Schema file not found!'); die; } $generator->parseSchema($sources['schema_file'], $sources['model']); $modx->addPackage('piwigomodx', $sources['model']); // add package to make all models available $manager->createObjectContainer('PiwigoModx'); // created the database table $modx->log(modX::LOG_LEVEL_INFO, 'Done!');
require $sources['build'] . '/includes/functions.php'; $modx = new modX(); $modx->initialize('mgr'); $modx->getService('error', 'error.modError'); $modx->setLogLevel(modX::LOG_LEVEL_ERROR); $modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML'); $modx->loadClass('transport.modPackageBuilder', '', false, true); /** @var xPDOManager $manager */ $manager = $modx->getManager(); /** @var xPDOGenerator $generator */ $generator = $manager->getGenerator(); // Remove old model rrmdir($sources['model'] . PKG_NAME_LOWER . '/mysql'); // Generate a new one $generator->parseSchema($sources['xml'], $sources['model']); $modx->addPackage(PKG_NAME_LOWER, $sources['model']); $modx->log(modX::LOG_LEVEL_INFO, 'Model generated.'); add_plugins_call($sources['model'] . PKG_NAME_LOWER, array('msProductData', 'msCustomerProfile')); print "\nDone\n"; /********************************************************/ function add_plugins_call($dir, $classes = array()) { foreach ($classes as $name) { $file = $dir . '/mysql/' . strtolower($name) . '.map.inc.php'; if (file_exists($file)) { file_put_contents($file, str_replace(' ', '', "\n" . ' if (!class_exists(\'ms2Plugins\') || !is_object($this->ms2Plugins)) { require_once (dirname(dirname(__FILE__)) . \'/plugins.class.php\'); $this->ms2Plugins = new ms2Plugins($this, array()); } $xpdo_meta_map[\'' . $name . '\'] = $this->ms2Plugins->loadMap(\'' . $name . '\', $xpdo_meta_map[\'' . $name . '\']);'), FILE_APPEND);
require_once dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php'; require_once MODX_CORE_PATH . 'config/' . MODX_CONFIG_KEY . '.inc.php'; require_once MODX_CORE_PATH . 'model/modx/modx.class.php'; $modx = new modX(); $modx->initialize('web'); $snippet = $modx->getObject('modSnippet', array('name' => 'YandexMoney')); $config = $snippet->getProperties(); $config['payStatusOut'] = $modx->getOption('yandexmoney.payStatusOut', null, 5); if (!defined('YANDEXMONEY_PATH')) { define('YANDEXMONEY_PATH', MODX_CORE_PATH . "components/yandexmoney/"); } if ($_GET['fail'] == 1) { if ($res = $modx->getObject('modResource', $config['fail_page_id'])) { $modx->sendRedirect($modx->makeUrl($config['fail_page_id'], '', '', 'full')); } exit; } elseif ($_GET['success'] == 1) { if ($res = $modx->getObject('modResource', $config['success_page_id'])) { $modx->sendRedirect($modx->makeUrl($config['success_page_id'], '', '', 'full')); } exit; } require_once YANDEXMONEY_PATH . 'model/yandexmoney.class.php'; $ym = new Yandexmoney($modx, $config); $order_id = $ym->ProcessResult(); if ($order_id) { $modx->addPackage('shopkeeper3', MODX_CORE_PATH . "components/shopkeeper3/model/"); $order = $modx->getObject('shk_order', array('id' => $order_id)); $order->set('status', $config['payStatusOut']); $order->save(); }
/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->getOption('core_path', $config, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/subdomainsfolder/'); $assetsPath = $this->getOption('assets_path', $config, $this->modx->getOption('assets_path', null, MODX_ASSETS_PATH) . 'components/subdomainsfolder/'); $assetsUrl = $this->getOption('assets_url', $config, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/subdomainsfolder/'); $this->config = array_merge(array('namespace' => $this->namespace, 'assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $assetsUrl . 'connector.php', 'actionUrl' => $assetsUrl . 'action.php', 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'templatesPath' => $corePath . 'elements/templates/', 'snippetsPath' => $corePath . 'elements/snippets/', 'processorsPath' => $corePath . 'processors/', 'handlersPath' => $corePath . 'handlers/'), $config); $this->modx->addPackage('subdomainsfolder', $this->config['modelPath']); $this->modx->lexicon->load('subdomainsfolder:default'); $this->namespace = $this->getOption('namespace', $config, 'subdomainsfolder'); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->modx->getOption('storelocator.core_path', null, $modx->getOption('core_path') . 'components/storelocator/'); $assetsPath = $this->modx->getOption('storelocator.assets_path', null, $modx->getOption('assets_path') . 'components/storelocator/'); $assetsUrl = $this->modx->getOption('storelocator.assets_url', null, $modx->getOption('assets_url') . 'components/storelocator/'); $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'controllersPath' => $corePath . 'controllers/', 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/', 'baseUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $assetsUrl . 'connector.php'), $config); $this->modx->addPackage('storelocator', $this->config['modelPath']); if ($this->modx->lexicon) { $this->modx->lexicon->load('storelocator:default'); } }
function __construct(modX &$modx, array $options = array()) { $this->modx =& $modx; $this->namespace = $this->getOption('namespace', $options, 'gitpackagemanagement'); $corePath = $this->getOption('core_path', $options, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/gitpackagemanagement/'); $assetsPath = $this->getOption('assets_path', $options, $this->modx->getOption('assets_path', null, MODX_ASSETS_PATH) . 'components/gitpackagemanagement/'); $assetsUrl = $this->getOption('assets_url', $options, $this->modx->getOption('assets_url', null, MODX_ASSETS_URL) . 'components/gitpackagemanagement/'); $connectorUrl = $assetsUrl . 'connector.php'; $this->options = array_merge(array('assetsPath' => $assetsPath, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $connectorUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/', 'widgetsPath' => $corePath . 'elements/widgets/', 'processorsPath' => $corePath . 'processors/', 'templatesPath' => $corePath . 'templates/'), $options); $this->modx->addPackage('gitpackagemanagement', $this->getOption('modelPath')); $this->modx->lexicon->load('gitpackagemanagement:default'); }
/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $this->ms2Gallery = $this->modx->getService('ms2Gallery', 'ms2Gallery', MODX_CORE_PATH . 'components/ms2gallery/model/ms2gallery/'); $corePath = $this->modx->getOption('ms2galleryForm.core_path', $config, $this->modx->getOption('core_path') . 'components/ms2galleryform/'); $assetsUrl = $this->modx->getOption('ms2galleryForm.assets_url', $config, $this->modx->getOption('assets_url') . 'components/ms2galleryform/'); $actionUrl = $this->modx->getOption('ms2galleryForm.action_url', $config, $assetsUrl . 'action.php'); $connectorUrl = $assetsUrl . 'connector.php'; $this->config = array_merge(array('assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connector_url' => $connectorUrl, 'actionUrl' => $actionUrl, 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'ctx' => 'web', 'json_response' => false), $config); $this->modx->addPackage('ms2galleryForm', $this->config['modelPath']); $this->modx->lexicon->load('ms2galleryform:default'); $this->authenticated = $this->modx->user->isAuthenticated($this->modx->context->get('key')); }
/** * @param modX $modx * @param array $config */ function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; $corePath = $this->getOption('core_path', $config, $this->modx->getOption('core_path') . 'components/moddevtools/'); $assetsUrl = $this->getOption('assets_url', $config, $this->modx->getOption('assets_url') . 'components/moddevtools/'); $debug = $this->getOption('debug', $config, false); // Load some default paths for easier management $this->config = array_merge(array('namespace' => $this->namespace, 'version' => $this->version, 'assetsUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'imagesUrl' => $assetsUrl . 'images/', 'connectorUrl' => $assetsUrl . 'connector.php', 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'chunksPath' => $corePath . 'elements/chunks/', 'templatesPath' => $corePath . 'elements/templates/', 'chunkSuffix' => '.chunk.tpl', 'snippetsPath' => $corePath . 'elements/snippets/', 'processorsPath' => $corePath . 'processors/'), $config); // set default options $this->config = array_merge($this->config, array('debug' => $debug, 'accessRegenerate' => $this->modx->user->get('sudo') || $this->modx->hasPermission('system_perform_maintenance_tasks'), 'viewChunk' => $this->modx->user->get('sudo') || $this->modx->hasPermission('view_chunk'), 'saveChunk' => $this->modx->user->get('sudo') || $this->modx->hasPermission('save_chunk'), 'viewTemplate' => $this->modx->user->get('sudo') || $this->modx->hasPermission('view_template'), 'saveTemplate' => $this->modx->user->get('sudo') || $this->modx->hasPermission('save_template'), 'viewSnippet' => $this->modx->user->get('sudo') || $this->modx->hasPermission('view_snippet'), 'editSnippet' => $this->modx->user->get('sudo') || $this->modx->hasPermission('edit_snippet'), 'saveSnippet' => $this->modx->user->get('sudo') || $this->modx->hasPermission('save_snippet'), 'viewResource' => $this->modx->user->get('sudo') || $this->modx->hasPermission('view_document'), 'saveResource' => $this->modx->user->get('sudo') || $this->modx->hasPermission('save_document'), 'extractLines' => 6, 'extractEllips' => '...', 'extractSeparator' => '<br>', 'extractQuantity' => 1, 'pcreModifier' => 'u')); $this->modx->addPackage('moddevtools', $this->config['modelPath']); $this->modx->lexicon->load('moddevtools:default'); }
function __construct(modX &$modx, array $config = array()) { $this->modx =& $modx; /* allows you to set paths in different environments * this allows for easier SVN management of files */ $corePath = $this->modx->getOption('formsave.core_path', null, $modx->getOption('core_path') . 'components/formsave/'); $assetsPath = $this->modx->getOption('formsave.assets_path', null, $modx->getOption('assets_path') . 'components/formsave/'); $assetsUrl = $this->modx->getOption('formsave.assets_url', null, $modx->getOption('assets_url') . 'components/formsave/'); $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'controllersPath' => $corePath . 'controllers/', 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/', 'baseUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $assetsUrl . 'connector.php', 'thread' => '', 'tplformsaveAddComment' => '', 'tplformsaveComment' => '', 'tplformsaveCommentOptions' => '', 'tplformsaveComments' => '', 'tplformsaveLoginToComment' => '', 'tplformsaveReport' => ''), $config); $this->modx->addPackage('formsave', $this->config['modelPath']); if ($this->modx->lexicon) { $this->modx->lexicon->load('formsave:default'); } }