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


PHP modX::call方法代码示例

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


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

示例1: 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')) ? 'modDocument' : $_REQUEST['class_key'];
         if ($resourceClass == 'modResource') {
             $resourceClass = 'modDocument';
         }
     } else {
         if (!empty($_REQUEST['id']) && $_REQUEST['id'] != 'undefined' && strlen($_REQUEST['id']) === strlen((int) $_REQUEST['id'])) {
             /** @var modResource $resource */
             $resource = $modx->getObject('modResource', array('id' => $_REQUEST['id']));
             if ($resource && !in_array($resource->get('class_key'), array('modDocument', 'modResource'))) {
                 $isDerivative = true;
                 $resourceClass = $resource->get('class_key');
             } else {
                 if ($resource && $resource->get('class_key') == 'modResource') {
                     /* fix improper class key */
                     $resource->set('class_key', 'modDocument');
                     $resource->save();
                 }
             }
         }
     }
     if ($isDerivative) {
         $resourceClass = str_replace(array('../', '..', '/', '\\'), '', $resourceClass);
         if (!class_exists($resourceClass) && !$modx->loadClass($resourceClass)) {
             $resourceClass = 'modDocument';
         }
         $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';
         if (!file_exists($controllerFile)) {
             // We more than likely are using a custom manager theme without overridden controller, let's try with the default theme
             $theme = $modx->getOption('manager_theme', null, 'default');
             $modx->setOption('manager_theme', 'default');
             $delegateView = $modx->call($resourceClass, 'getControllerPath', array(&$modx));
             $controllerFile = $delegateView . $action . '.class.php';
             // Restore custom theme (so we don't process/use default theme assets)
             $modx->setOption('manager_theme', $theme);
         }
         require_once $controllerFile;
     }
     $controller = new $className($modx, $config);
     $controller->resourceClass = $resourceClass;
     return $controller;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:59,代码来源:resource.class.php

示例2: 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

示例3: 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')) ? 'modDocument' : $_REQUEST['class_key'];
         if ($resourceClass == 'modResource') {
             $resourceClass = 'modDocument';
         }
     } else {
         if (!empty($_REQUEST['id']) && $_REQUEST['id'] != 'undefined') {
             /** @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');
             } else {
                 if ($resource && $resource->get('class_key') == 'modResource') {
                     /* fix improper class key */
                     $resource->set('class_key', 'modDocument');
                     $resource->save();
                 }
             }
         }
     }
     if ($isDerivative) {
         $resourceClass = str_replace(array('../', '..', '/', '\\'), '', $resourceClass);
         if (!class_exists($resourceClass) && !$modx->loadClass($resourceClass)) {
             $resourceClass = 'modDocument';
         }
         $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';
         if (!file_exists($controllerFile)) {
             $modx->setOption('manager_theme', 'default');
             $delegateView = $modx->call($resourceClass, 'getControllerPath', array(&$modx));
             $controllerFile = $delegateView . $action . '.class.php';
         }
         require_once $controllerFile;
     }
     $controller = new $className($modx, $config);
     $controller->resourceClass = $resourceClass;
     return $controller;
 }
开发者ID:e-gob,项目名称:chilesinpapeleo-ayuda,代码行数:55,代码来源:resource.class.php

示例4: loadAttributes

 /**
  * Loads the principal attributes that define a modUser security profile.
  *
  * {@inheritdoc}
  */
 public function loadAttributes($target, $context = '', $reload = false)
 {
     $context = !empty($context) ? $context : $this->xpdo->context->get('key');
     $id = $this->get('id') ? (string) $this->get('id') : '0';
     if ($this->get('id') && !$reload) {
         $staleContexts = $this->get('session_stale');
         $staleContexts = !empty($staleContexts) ? $staleContexts : array();
         $stale = array_search($context, $staleContexts);
         if ($stale !== false) {
             $reload = true;
             $staleContexts = array_diff($staleContexts, array($context));
             $this->set('session_stale', $staleContexts);
             $this->save();
         }
     }
     if ($this->_attributes === null || $reload) {
         $this->_attributes = array();
         if (isset($_SESSION["modx.user.{$id}.attributes"])) {
             if ($reload) {
                 unset($_SESSION["modx.user.{$id}.attributes"]);
             } else {
                 $this->_attributes = $_SESSION["modx.user.{$id}.attributes"];
             }
         }
     }
     if (!isset($this->_attributes[$context])) {
         $this->_attributes[$context] = array();
     }
     $target = (array) $target;
     foreach ($target as $t) {
         if (!isset($this->_attributes[$context][$t])) {
             $this->_attributes[$context][$t] = $this->xpdo->call($t, 'loadAttributes', array(&$this->xpdo, $context, $this->get('id')));
             if (!isset($this->_attributes[$context][$t]) || !is_array($this->_attributes[$context][$t])) {
                 $this->_attributes[$context][$t] = array();
             }
         }
     }
     $_SESSION["modx.user.{$id}.attributes"] = $this->_attributes;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:44,代码来源:moduser.class.php

示例5: elseif

         } 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++;
         } else {
             $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey()));
         }
     }
     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
     continue 2;
 case 'transport.modTransportPackage':
     $modx->loadClass($class);
     $response = $modx->call('modTransportPackage', 'listPackages', array(&$modx, $workspace->get('id')));
     if (isset($response['collection'])) {
         foreach ($response['collection'] as $object) {
             $packagesDir = MODX_CORE_PATH . 'packages/';
             if ($object->getOne('Workspace')) {
                 $packagesDir = $object->Workspace->get('path') . 'packages/';
             }
             $pkgSource = $object->get('source');
             $folderPos = strrpos($pkgSource, '/');
             $sourceDir = $folderPos > 1 ? substr($pkgSource, 0, $folderPos + 1) : '';
             $source = realpath($packagesDir . $pkgSource);
             $target = 'MODX_CORE_PATH . "packages/' . $sourceDir . '"';
             $classAttributes = array_merge($attributes, array('resolve' => array(array('type' => 'file', 'source' => $source, 'target' => "return {$target};"))));
             if ($package->put($object, $classAttributes)) {
                 $instances++;
             } else {
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:31,代码来源:vapor.php

示例6: getGroupsList

 /**
  * Gets a sortable, limitable collection (and total count) of Resource Groups for the Resource.
  *
  * @param array $sort An array of sort columns in column => direction format.
  * @param int $limit A limit of records to retrieve in the collection.
  * @param int $offset A record offset for a limited collection.
  * @return array An array containing the collection and total.
  */
 public function getGroupsList(array $sort = array('id' => 'ASC'), $limit = 0, $offset = 0)
 {
     return $this->xpdo->call('modResource', 'listGroups', array(&$this, $sort, $limit, $offset));
 }
开发者ID:DeFi-ManriquezLuis,项目名称:MTLTransfer,代码行数:12,代码来源:modresource.class.php

示例7: countUnansweredQuestions

 /**
  * Get the number of unanswered questions.
  * @return int
  */
 public function countUnansweredQuestions()
 {
     $response = $this->xpdo->call('disThread', 'fetchUnansweredQuestions', array(&$this->xpdo, "{$this->xpdo->escape('disThread')}.{$this->xpdo->escape('post_last_on')}", 'DESC', 10, 0, false, true));
     return number_format($response['total']);
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:9,代码来源:disuser.class.php

示例8: process


//.........这里部分代码省略.........
             }
             $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++;
                         } else {
                             $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 case 'transport.modTransportPackage':
                     $modx->loadClass($class);
                     $response = $modx->call('modTransportPackage', 'listPackages', array(&$modx, $workspace->get('id')));
                     if (isset($response['collection'])) {
                         foreach ($response['collection'] as $object) {
                             $packagesDir = MODX_CORE_PATH . 'packages/';
                             if ($object->getOne('Workspace')) {
                                 $packagesDir = $object->Workspace->get('path') . 'packages/';
                             }
                             $pkgSource = $object->get('source');
                             $folderPos = strrpos($pkgSource, '/');
                             $sourceDir = $folderPos > 1 ? substr($pkgSource, 0, $folderPos + 1) : '';
                             $source = realpath($packagesDir . $pkgSource);
                             $target = 'MODX_CORE_PATH . "packages/' . $sourceDir . '"';
                             $classAttributes = array_merge($attributes, array('resolve' => array(array('type' => 'file', 'source' => $source, 'target' => "return {$target};"))));
                             if ($package->put($object, $classAttributes)) {
                                 $instances++;
                             } else {
                                 $modx->log(modX::LOG_LEVEL_WARN, "Could not package {$class} instance with pk: " . print_r($object->getPrimaryKey(), true));
                             }
                         }
                     }
                     $modx->log(modX::LOG_LEVEL_INFO, "Packaged {$instances} of {$class}");
                     continue 2;
                 case 'sources.modMediaSource':
                     foreach ($modx->getIterator('sources.modMediaSource') as $object) {
                         $classAttributes = $attributes;
                         /** @var modMediaSource $object */
                         if ($object->get('is_stream') && $object->initialize()) {
                             $sourceBases = $object->getBases('');
                             $source = $object->getBasePath();
                             if (!$sourceBases['pathIsRelative'] && strpos($source, '://') === false) {
                                 $sourceBasePath = $source;
                                 if (strpos($source, $base_path) === 0) {
                                     $sourceBasePath = str_replace($base_path, '', $sourceBasePath);
开发者ID:Tramp1357,项目名称:atlasorg,代码行数:67,代码来源:create.class.php


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