Ejemplo n.º 1
3
 /**
  * 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/');
 }
 public function __construct($modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx = $modx;
     $this->MlmSystem = $this->modx->MlmSystem;
     if (!is_object($this->MlmSystem)) {
         $this->MlmSystem = $this->modx->getService('mlmsystem');
     }
 }
Ejemplo n.º 3
2
 /**
  * Get all names of template from provider
  * @return array|\Iterator
  */
 public function getList()
 {
     $c = $this->modx->newQuery('modTemplate');
     $c->select('templatename');
     if ($c->prepare() && $c->stmt->execute()) {
         return $c->stmt->fetchAll(PDO::FETCH_COLUMN);
     }
     return array();
 }
Ejemplo n.º 4
1
 /**
  * The Quip Constructor.
  *
  * This method is used to create a new Quip object.
  *
  * @param modX &$modx A reference to the modX object.
  * @param array $config A collection of properties that modify Quip
  * behaviour.
  * @return Quip A unique Quip instance.
  */
 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('xdbedit.core_path', null, $modx->getOption('core_path') . 'components/xdbedit/');
     $assetsPath = $this->modx->getOption('xdbedit.assets_path', null, $modx->getOption('assets_path') . 'components/xdbedit/');
     $assetsUrl = $this->modx->getOption('xdbedit.assets_url', null, $modx->getOption('assets_url') . 'components/xdbedit/');
     $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'controllersPath' => $corePath . 'controllers/', 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/', 'auto_create_tables' => true, 'baseUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $assetsUrl . 'connector.php', 'thread' => ''), $config);
     /* load debugging settings */
     if ($this->modx->getOption('debug', $this->config, false)) {
         error_reporting(E_ALL);
         ini_set('display_errors', true);
         $this->modx->setLogTarget('HTML');
         $this->modx->setLogLevel(modX::LOG_LEVEL_ERROR);
         $debugUser = $this->config['debugUser'] == '' ? $this->modx->user->get('username') : 'anonymous';
         $user = $this->modx->getObject('modUser', array('username' => $debugUser));
         if ($user == null) {
             $this->modx->user->set('id', $this->modx->getOption('debugUserId', $this->config, 1));
             $this->modx->user->set('username', $debugUser);
         } else {
             $this->modx->user = $user;
         }
     }
 }
Ejemplo n.º 5
0
 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;
 }
Ejemplo n.º 6
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     require_once dirname(__FILE__) . '/build.config.php';
     require_once dirname(__FILE__) . '/uthelpers.class.php';
     require_once MODX_CORE_PATH . 'model/modx/modx.class.php';
     $modx = new modX();
     $modx->initialize('mgr');
     $modx->getService('error', 'error.modError', '', '');
     $this->utHelpers = new UtHelpers();
     $this->mc = new MyComponentProject($modx);
     $this->mc->init(array(), 'unittest');
     $this->mc->createCategories();
     $this->mc->createBasics();
     $this->modx =& $this->mc->modx;
     if ($this->mc->props['categories']['UnitTest']['category'] != 'UnitTest') {
         die('wrong config');
     }
     if (strstr($this->mc->targetRoot, 'unittest')) {
         // $this->utHelpers->rrmdir($this->mc->targetRoot);
     } else {
         die('Wrong Target Root!');
     }
     $modx->setLogLevel(modX::LOG_LEVEL_INFO);
     $modx->setLogTarget('ECHO');
 }
Ejemplo n.º 7
0
 function getStats()
 {
     $output = '';
     $q_status = $this->modx->newQuery('msOrderStatus', array('active' => 1));
     $q_status->select('id,name,color');
     if ($q_status->prepare() && $q_status->stmt->execute()) {
         while ($row = $q_status->stmt->fetch(PDO::FETCH_ASSOC)) {
             //$output[$row['id']] = $row;
             $output['total_counts'][$row['id']] = array('name' => $row['name'], 'color' => $row['color'], 'count_orders' => $this->modx->getCount('msOrder', array('status' => $row['id'])));
         }
     }
     $q_stats_month = $this->modx->newQuery('msOrder');
     $q_stats_month->select('status,`createdon`, month(`createdon`) AS `order_month`, count(*) AS `order_count`, SUM(cart_cost) AS order_cost');
     $q_stats_month->groupby('month(`createdon`), status');
     $q_stats_month->sortby('createdon', ASC);
     if ($q_stats_month->prepare() && $q_stats_month->stmt->execute()) {
         $output['cart_cost'] = 0;
         $output['cart_count'] = 0;
         while ($row = $q_stats_month->stmt->fetch(PDO::FETCH_ASSOC)) {
             $date = date_parse($row['createdon']);
             $output['stats_month'][$date['year'] . '-' . $date['month']][$row['status']] = array('total_cost' => $row['order_cost'], 'count_orders' => $row['order_count'], 'status' => $row['status']);
             $output['cart_cost'] += $row['order_cost'];
             $output['cart_count'] += $row['order_count'];
         }
         $output['cart_cost'] = number_format($output['cart_cost'], 2, ',', ' ');
         $output['users_count'] = $this->modx->getCount('modUser', array('active' => 1, 'primary_group' => 0));
     }
     return $output;
 }
Ejemplo n.º 8
0
function _modProcessMenus(modX &$modx, &$output, $menus, &$childrenCt, $showDescriptions = true)
{
    foreach ($menus as $menu) {
        if (!empty($menu['permissions'])) {
            $permissions = array();
            $exploded = explode(',', $menu['permissions']);
            foreach ($exploded as $permission) {
                $permissions[trim($permission)] = true;
            }
            if (!empty($permissions) && !$modx->hasPermission($permissions)) {
                continue;
            }
        }
        $smTpl = '<li>' . "\n";
        $description = !empty($menu['description']) ? '<span class="description">' . $menu['description'] . '</span>' . "\n" : '';
        if (!empty($menu['handler'])) {
            $smTpl .= '<a href="javascript:;" onclick="' . str_replace('"', '\'', $menu['handler']) . '">' . $menu['text'] . ($showDescriptions ? $description : '') . '</a>' . "\n";
        } else {
            $url = '?a=' . $menu['action'] . $menu['params'];
            $smTpl .= '<a href="' . $url . '">' . $menu['text'] . ($showDescriptions ? $description : '') . '</a>' . "\n";
        }
        if (!empty($menu['children'])) {
            $smTpl .= '<ul class="modx-subsubnav">' . "\n";
            _modProcessMenus($modx, $smTpl, $menu['children'], $childrenCt, $showDescriptions);
            $smTpl .= '</ul>' . "\n";
        }
        $smTpl .= '</li>';
        $output .= $smTpl;
        $childrenCt++;
    }
}
Ejemplo n.º 9
0
 /**
  * Return the appropriate Resource controller class based on the class_key request parameter
  * 
  * @static
  * @param modX $modx A reference to the modX instance
  * @param string $className The controller class name that is attempting to be loaded
  * @param array $config An array of configuration options for the action
  * @return modManagerController The proper controller class
  */
 public static function getInstance(modX &$modx, $className, array $config = array())
 {
     $resourceClass = 'modDocument';
     $isDerivative = false;
     if (!empty($_REQUEST['class_key'])) {
         $isDerivative = true;
         $resourceClass = in_array($_REQUEST['class_key'], array('modDocument', 'modResource')) ? 'modResource' : $_REQUEST['class_key'];
     } else {
         if (!empty($_REQUEST['id'])) {
             /** @var modResource $resource */
             $resource = $modx->getObject('modResource', $_REQUEST['id']);
             if ($resource && !in_array($resource->get('class_key'), array('modDocument', 'modResource'))) {
                 $isDerivative = true;
                 $resourceClass = $resource->get('class_key');
             }
         }
     }
     if ($isDerivative) {
         $resourceClass = str_replace(array('../', '..', '/', '\\'), '', $resourceClass);
         $delegateView = $modx->call($resourceClass, 'getControllerPath', array(&$modx));
         $action = strtolower(str_replace(array('Resource', 'ManagerController'), '', $className));
         $className = str_replace('mod', '', $resourceClass) . ucfirst($action) . 'ManagerController';
         $controllerFile = $delegateView . $action . '.class.php';
         require_once $controllerFile;
     }
     $controller = new $className($modx, $config);
     $controller->resourceClass = $resourceClass;
     return $controller;
 }
 /**
  * Refresh Resource URI fields for children of the specified parent.
  *
  * @static
  * @param modX &$modx A reference to a valid modX instance.
  * @param int $parent The id of a Resource parent to start from (default is 0, the root)
  * @param array $options An array of various options for the method:
  *      - resetOverrides: if true, Resources with uri_override set to true will be included
  *      - contexts: an optional array of context keys to limit the refresh scope
  * @return void
  */
 public static function refreshURIs(modX &$modx, $parent = 0, array $options = array())
 {
     $resetOverrides = array_key_exists('resetOverrides', $options) ? (bool) $options['resetOverrides'] : false;
     $contexts = array_key_exists('contexts', $options) ? explode(',', $options['contexts']) : null;
     $criteria = $modx->newQuery('linguaSiteContent');
     $criteria->where(array('lang_id' => $options['lang_id'], 'parent' => $parent));
     if (!$resetOverrides) {
         $criteria->where(array('uri_override' => false));
     }
     if (!empty($contexts)) {
         $criteria->where(array('context_key:IN' => $contexts));
     }
     /** @var Resource $resource */
     $resources = $modx->getIterator('linguaSiteContent', $criteria);
     foreach ($resources as $resource) {
         $resource->set('refreshURIs', true);
         if ($resetOverrides) {
             $resource->set('uri_override', false);
         }
         if (!$resource->get('uri_override')) {
             $resource->set('uri', '');
         }
         $resource->save();
     }
 }
 /** @inheritdoc} */
 public function success($message = '', $data = array(), $placeholders = array())
 {
     if (!is_object($this->ms2)) {
         $this->ms2 = $this->modx->getService('minishop2');
     }
     return $this->ms2->success($message, $data, $placeholders);
 }
Ejemplo n.º 12
0
 /**
  * FenomX constructor.
  *
  * @param pdoTools $pdoTools
  */
 public function __construct(pdoTools $pdoTools)
 {
     if (!class_exists('modChunkProvider')) {
         require dirname(dirname(__FILE__)) . '/fenom/Providers/ModChunk.php';
         require dirname(dirname(__FILE__)) . '/fenom/Providers/ModTemplate.php';
         require dirname(dirname(__FILE__)) . '/fenom/Providers/ModFile.php';
     }
     $provider = new modChunkProvider($pdoTools);
     parent::__construct($provider);
     $this->setCompileDir(rtrim($pdoTools->config['cachePath'], '/') . '/file');
     $this->addProvider('template', new modTemplateProvider($pdoTools));
     $this->addProvider('file', new modFileProvider($pdoTools));
     $default_options = array('disable_cache' => !$pdoTools->config['useFenomCache'], 'force_compile' => !$pdoTools->config['useFenomCache'], 'force_include' => !$pdoTools->config['useFenomCache'], 'auto_reload' => $pdoTools->config['useFenomCache']);
     if ($options = $pdoTools->modx->fromJSON($pdoTools->modx->getOption('pdotools_fenom_options'))) {
         $options = array_merge($default_options, $options);
     } else {
         $options = $default_options;
     }
     if (!$pdoTools->config['useFenomPHP']) {
         $this->removeAccessor('php');
         $options['disable_native_funcs'] = true;
     }
     $this->setOptions($options);
     $this->pdoTools = $pdoTools;
     $this->modx = $pdoTools->modx;
     $this->_addDefaultModifiers();
     $this->modx->invokeEvent('pdoToolsOnFenomInit', array('fenom' => $this, 'config' => $pdoTools->config));
 }
Ejemplo n.º 13
0
 public function __construct(modX $modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx = $modx;
     $fqn = $modx->getOption('twiggy_class', null, 'twiggy.twiggy', true);
     $path = $modx->getOption('twiggy_class_path', null, MODX_CORE_PATH . 'components/twiggy/model/', true);
     $this->twiggy = $modx->getService($fqn, '', $path, $this->scriptProperties);
 }
 public static function getInstance(modX &$modx, $className, $properties = array())
 {
     $object = $modx->getObject('modResource', $properties['id']);
     $classKey = !empty($properties['class_key']) ? $properties['class_key'] : ($object ? $object->get('class_key') : 'modDocument');
     $className = 'msProductDisableCacheUpdateProcessor';
     $processor = new $className($modx, $properties);
     return $processor;
 }
Ejemplo n.º 15
0
 /**
  * Constructs the BannerY object
  *
  * @param modX &$modx A reference to the modX object
  * @param array $config An array of configuration options
  */
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $basePath = $this->modx->getOption('bannery.core_path', $config, $this->modx->getOption('core_path') . 'components/bannery/');
     $assetsUrl = $this->modx->getOption('bannery.assets_url', $config, $this->modx->getOption('assets_url') . 'components/bannery/');
     $this->config = array_merge(array('baseUrl' => $modx->getOption('base_url'), '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', 'managerUrl' => $this->modx->getOption('manager_url'), 'media_source' => $this->modx->getOption('bannery_media_source', null, $this->modx->getOption('default_media_source'), true)), $config);
     $this->modx->addPackage('bannery', $this->config['modelPath']);
 }
 public static function getInstance(modX &$modx, $className, $properties = array())
 {
     $classKey = !empty($properties['class_key']) ? $properties['class_key'] : 'modDocument';
     $object = $modx->newObject($classKey);
     $className = 'msCategoryDisableCacheCreateProcessor';
     $processor = new $className($modx, $properties);
     return $processor;
 }
Ejemplo n.º 17
0
 public static function getInstance(modX &$modx, $className, $properties = array())
 {
     if (isset($properties['data'])) {
         $data = (array) $modx->fromJSON($properties['data']);
         $properties = array_merge($properties, $data);
         unset($properties['data'], $data);
     }
     return parent::getInstance($modx, $className, $properties);
 }
Ejemplo n.º 18
0
 /**
  * Sets the cache path for this Smarty instance
  *
  * @access public
  * @param string $path The path to set. Defaults to '', which in turn
  * defaults to $this->modx->cachePath.
  */
 public function setCachePath($path = '')
 {
     $path = $this->modx->getOption(xPDO::OPT_CACHE_PATH) . $path;
     if (!is_dir($path)) {
         $this->modx->getCacheManager();
         $this->modx->cacheManager->writeTree($path);
     }
     $this->compile_dir = $path;
 }
Ejemplo n.º 19
0
 /**
  * @param int $resource
  *
  * @return string
  */
 public function formatResourceUrl($resource = 0)
 {
     $url = '';
     $args = array();
     if (!empty($resource)) {
         $url = $this->modx->makeUrl($resource, '', $args, 'full', array('xhtml_urls' => false));
     }
     return $url;
 }
Ejemplo n.º 20
0
 public function __construct(modX &$modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx =& $modx;
     if (!is_object($this->ecc)) {
         $corePath = $modx->getOption('ecc_core_path', null, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/ecc/');
         $this->ecc = $modx->getService('ecc', 'ecc', $corePath . 'model/ecc/', array('core_path' => $corePath));
     }
 }
Ejemplo n.º 21
0
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $this->modx->getOption('schedule.core_path', $config, $this->modx->getOption('core_path') . 'components/schedule/');
     $assetsUrl = $this->modx->getOption('schedule.assets_url', $config, $this->modx->getOption('assets_url') . 'components/schedule/');
     $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/', 'parents' => $modx->getOption('schedule.parents', '', 0), 'resources' => $modx->getOption('schedule.resources', '', 0), 'render_data_tpl' => $modx->getOption('schedule.render_data_tpl', '', 'tpl.Schedule.data.row')), $config);
     $this->modx->addPackage('schedule', $this->config['modelPath']);
     $this->modx->lexicon->load('schedule:default');
 }
Ejemplo n.º 22
-1
 /**
  * The Babel Constructor.
  *
  * This method is used to create a new Babel object.
  *
  * @param modX &$modx A reference to the modX object.
  * @param array $config A collection of properties that modify Babel
  * behaviour.
  * @return Babel A unique Babel instance.
  */
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $this->modx->getOption('babel.core_path', null, $modx->getOption('core_path') . 'components/babel/');
     $assetsUrl = $this->modx->getOption('babel.assets_url', null, $modx->getOption('assets_url') . 'components/babel/');
     $contextKeysOption = $this->modx->getOption('babel.contextKeys', $config, '');
     $contextKeyToGroup = $this->decodeContextKeySetting($contextKeysOption);
     $syncTvsOption = $this->modx->getOption('babel.syncTvs', $config, '');
     $syncTvs = array();
     if (!empty($syncTvsOption)) {
         $syncTvs = explode(',', $syncTvsOption);
         $syncTvs = array_map('intval', $syncTvs);
     }
     $babelTvName = $this->modx->getOption('babel.babelTvName', $config, 'babelLanguageLinks');
     $this->config = array_merge(array('corePath' => $corePath, 'chunksPath' => $corePath . 'elements/chunks/', 'chunkSuffix' => '.chunk.tpl', 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'contextKeyToGroup' => $contextKeyToGroup, 'syncTvs' => $syncTvs, 'babelTvName' => $babelTvName), $config);
     /* load babel lexicon */
     if ($this->modx->lexicon) {
         $this->modx->lexicon->load('babel:default');
     }
     /* load babel TV */
     $this->babelTv = $modx->getObject('modTemplateVar', array('name' => $babelTvName));
     if (!$this->babelTv) {
         $this->modx->log(modX::LOG_LEVEL_WARN, 'Could not load babel TV: ' . $babelTvName . ' will try to create it...');
         $fields = array('name' => $babelTvName, 'type' => 'hidden', 'default_text' => '', 'caption' => $this->modx->lexicon('babel.tv_caption'), 'description' => $this->modx->lexicon('babel.tv_description'));
         $this->babelTv = $modx->newObject('modTemplateVar', $fields);
         if ($this->babelTv->save()) {
             $this->modx->log(modX::LOG_LEVEL_INFO, 'Created babel TV: ' . $babelTvName);
         } else {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'Could not create babel TV: ' . $babelTvName);
         }
     }
 }
Ejemplo n.º 23
-1
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $modx->getOption('taglister.core_path', null, $modx->getOption('core_path') . 'components/taglister/');
     $assetsUrl = $modx->getOption('taglister.assets_url', null, $modx->getOption('assets_url') . 'components/taglister/');
     $this->config = array_merge(array('corePath' => $corePath, 'chunksPath' => $corePath . 'elements/chunks/', 'snippetsPath' => $corePath . 'elements/snippets/'), $config);
 }
Ejemplo n.º 24
-1
 /**
  * Creates an instance of the Login class.
  *
  * @param modX &$modx A reference to the modX instance.
  * @param array $config An array of configuration parameters.
  * @return Login
  */
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $modx->getOption('login.core_path', $config, $modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/login/');
     $this->config = array_merge(array('chunksPath' => $corePath . 'chunks/', 'controllersPath' => $corePath . 'controllers/', 'corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'testsPath' => $corePath . 'test/'), $config);
     $this->modx->lexicon->load('login:default');
 }
Ejemplo n.º 25
-1
 public function __construct($modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx =& $modx;
     $corePath = $this->modx->getOption('pdfresource.core_path', null, $this->modx->getOption('core_path') . 'components/pdfresource/');
     $this->pdfresource = $this->modx->getService('pdfresource', 'PDFResource', $corePath . 'model/pdfresource/', array('core_path' => $corePath));
 }
Ejemplo n.º 26
-1
 public final function __construct(modX &$modx, array $options = array())
 {
     require_once $modx->getOption('core_path') . 'components/modfire/firephp.class.php';
     $enabled = $modx->getOption('modfire.enabled');
     $this->setEnabled($enabled);
     $this->setOptions($options);
 }
Ejemplo n.º 27
-1
 /**
  * Default constructor for PackMan
  *
  * @constructor
  * @param modX &$modx A reference to a modX instance.
  * @param array $config (optional) Configuration properties.
  * @return packman
  */
 function __construct(modX &$modx, array $config = array())
 {
     $this->modx =& $modx;
     $corePath = $modx->getOption('packman.core_path', null, $modx->getOption('core_path') . 'components/packman/');
     $assetsUrl = $modx->getOption('packman.assets_url', null, $modx->getOption('assets_url') . 'components/packman/');
     $this->config = array_merge(array('corePath' => $corePath, 'modelPath' => $corePath . 'model/', 'processorsPath' => $corePath . 'processors/', 'controllersPath' => $corePath . 'controllers/', 'includesPath' => $corePath . 'includes/', 'baseUrl' => $assetsUrl, 'cssUrl' => $assetsUrl . 'css/', 'jsUrl' => $assetsUrl . 'js/', 'connectorUrl' => $assetsUrl . 'connector.php'), $config);
     $this->modx->addPackage('packman', $this->config['modelPath']);
     $this->modx->lexicon->load('packman:default');
 }
Ejemplo n.º 28
-1
 public function __construct($modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx = $modx;
     $this->el = $this->modx->el;
     if (!is_object($this->el)) {
         $this->el = $this->modx->getService('el');
     }
 }
Ejemplo n.º 29
-1
 /**
  * Plugin to run the page parser and display the number of comments on the resource.
  * @return boolean
  */
 public function mtcount()
 {
     // get a reference to the output
     $output =& $this->modx->resource->_output;
     // Choosing a pattern all of our values ​​from the resource
     if (preg_match_all("/{%mt(.*?)%}/", $output, $mt_list)) {
         $r = array();
         $c = array();
         $lisrArray = $mt_list[1];
         array_walk($lisrArray, 'trim');
         // Divide into two arrays, one for the id of the resource, the other by conversation name
         foreach ($lisrArray as $key => $value) {
             if ($value[0] == 'r') {
                 $r[$key] = substr($value, 2);
             } else {
                 $c[$key] = substr($value, 2);
             }
         }
         // If the array is not empty, choose the number of comments on the resource id (column rid)
         if ($r && is_array($r)) {
             array_walk($r, 'intval');
             $rr = $this->modx->newQuery('modxTalksConversation', array('rid:IN' => $r));
             if ($rr->prepare() && $rr->stmt->execute()) {
                 $results = $rr->stmt->fetchAll(PDO::FETCH_ASSOC);
                 foreach ($results as $resultr) {
                     $objMt = json_decode($resultr['modxTalksConversation_properties']);
                     if (in_array('r_' . $resultr['modxTalksConversation_rid'], $lisrArray)) {
                         $mt_list[1][array_search('r_' . $resultr['modxTalksConversation_rid'], $lisrArray)] = isset($objMt->comments->total) ? $objMt->comments->total : 0;
                     }
                 }
             }
         }
         foreach ($r as $n) {
             $k = array_search('r_' . $n, $mt_list[1], true);
             if ($k !== false) {
                 $mt_list[1][$k] = 0;
             }
         }
         // If the array is not empty, choose the number of comments on the conversation name (column conversation)
         if ($c && is_array($c)) {
             $rr = $this->modx->newQuery('modxTalksConversation', array('conversation:IN' => $c));
             if ($rr->prepare() && $rr->stmt->execute()) {
                 $results = $rr->stmt->fetchAll(PDO::FETCH_ASSOC);
                 foreach ($results as $resultr) {
                     $objMt = json_decode($resultr['modxTalksConversation_properties']);
                     if (in_array('c_' . $resultr['modxTalksConversation_conversation'], $lisrArray)) {
                         $mt_list[1][array_search('c_' . $resultr['modxTalksConversation_conversation'], $lisrArray)] = $objMt->comments->total;
                     }
                 }
             }
         }
         // Replace all your templates in the resource to the correct values
         $output = str_replace($mt_list[0], $mt_list[1], $output);
     }
     return true;
 }
Ejemplo n.º 30
-1
 public function __construct($modx, &$scriptProperties)
 {
     $this->scriptProperties =& $scriptProperties;
     $this->modx = $modx;
     $this->gl = $this->modx->gl;
     if (!is_object($this->gl) or !$this->gl instanceof gl) {
         $corePath = $this->modx->getOption('gl_core_path', null, $this->modx->getOption('core_path', null, MODX_CORE_PATH) . 'components/gl/');
         $this->gl = $this->modx->getService('gl', 'gl', $corePath . 'model/gl/', $this->scriptProperties);
     }
 }