当前位置: 首页>>代码示例>>PHP>>正文


PHP modX类代码示例

本文整理汇总了PHP中modX的典型用法代码示例。如果您正苦于以下问题:PHP modX类的具体用法?PHP modX怎么用?PHP modX使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了modX类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * 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;
         }
     }
 }
开发者ID:Bruno17,项目名称:xdbedit,代码行数:36,代码来源:xdbedit.class.php

示例2: add

 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;
 }
开发者ID:gvozdb,项目名称:phpthumbon,代码行数:33,代码来源:QueueThumb.class.php

示例3: setUp

 /**
  * 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');
 }
开发者ID:mooror,项目名称:MyComponent,代码行数:29,代码来源:exporttest.php

示例4: _modProcessMenus

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++;
    }
}
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:31,代码来源:header.php

示例5: getInstance

 /**
  * 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;
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:38,代码来源:resource.class.php

示例6: refreshURIs

 /**
  * 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();
     }
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:36,代码来源:linguasitecontent.class.php

示例7: __construct

 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);
 }
开发者ID:vgrish,项目名称:twiggy,代码行数:8,代码来源:twiggyplugin.class.php

示例8: getInstance

 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;
 }
开发者ID:svyatoslavteterin,项目名称:belton.by,代码行数:8,代码来源:updatemsproduct.class.php

示例9: __construct

 /**
  * 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']);
 }
开发者ID:suasti,项目名称:BannerY,代码行数:14,代码来源:bannery.class.php

示例10: getInstance

 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;
 }
开发者ID:svyatoslavteterin,项目名称:belton.by,代码行数:8,代码来源:createmscategory.class.php

示例11: getInstance

 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);
 }
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:9,代码来源:updatefromgrid.class.php

示例12: __construct

 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));
     }
 }
开发者ID:BazMaster,项目名称:ecc,代码行数:9,代码来源:eccsystemplugin.class.php

示例13: initialize

 /**
  * 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/');
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:10,代码来源:articlesimport.class.php

示例14: __construct

 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');
     }
 }
开发者ID:vgrish,项目名称:mlmsystem,代码行数:9,代码来源:mlmsystemeventplugin.class.php

示例15: getList

 /**
  * 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();
 }
开发者ID:qhuy61,项目名称:pdoTools,代码行数:13,代码来源:ModTemplate.php


注:本文中的modX类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。