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


PHP modX::getObject方法代码示例

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


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

示例1: getProfitResourceGroups

 /** @inheritdoc} */
 public function getProfitResourceGroups($id = 0)
 {
     $groups = array();
     $key = $this->MlmSystem->namespace;
     $options = array('cache_key' => $key . '/profit/group/' . __CLASS__ . '/resource/' . $id, 'cacheTime' => 0);
     if ($resource = $this->modx->getObject('modResource', array('id' => $id)) and !($groups = $this->MlmSystem->getCache($options))) {
         $ids = $this->modx->getParentIds($id, 10, array('context' => $resource->get('context_key')));
         $ids[] = $id;
         $ids = array_unique($ids);
         $q = $this->modx->newQuery('modResourceGroupResource', array('document:IN' => $ids));
         $q->leftJoin('MlmSystemProfitGroup', 'MlmSystemProfitGroup', 'MlmSystemProfitGroup.group = modResourceGroupResource.document_group');
         $q->where(array('MlmSystemProfitGroup.class' => 'modResourceGroup'));
         $q->select('document_group,profit');
         $q->sortby('profit');
         $q->groupby('MlmSystemProfitGroup.group');
         $tstart = microtime(true);
         if ($q->prepare() && $q->stmt->execute()) {
             $this->modx->queryTime += microtime(true) - $tstart;
             $this->modx->executedQueries++;
             while ($row = $q->stmt->fetch(PDO::FETCH_ASSOC)) {
                 $groups[$row['document_group']] = $row['profit'];
             }
         }
         $this->MlmSystem->setCache($groups, $options);
     }
     return $groups;
 }
开发者ID:vgrish,项目名称:mlmsystem,代码行数:28,代码来源:systemprofits.class.php

示例2: prepareTvValue

 /**
  * Prepare a JSON encoded object and return a valid JSON encoded Image+ object
  *
  * @param $json JSON value to prepare
  * @param array $opts
  * @param modTemplateVar $tv
  * @return string
  */
 public function prepareTvValue($json, $opts = array(), modTemplateVar $tv)
 {
     // Prepare value
     $decoded = json_decode($json);
     if (!$decoded) {
         // The variable does not contain an Image+ image object
         if ($json != '') {
             // Get Media Source
             /** @var modMediaSource $source */
             if ($tv) {
                 $source = $tv->getSource($this->modx->resource ? $this->modx->resource->get('context_key') : 'mgr');
             } else {
                 $source = $this->modx->getObject('modMediaSource', $this->modx->getOption('default_media_source'));
             }
             if (!($source && $source->getWorkingContext())) {
                 $this->modx->log(xPDO::LOG_LEVEL_ERROR, 'Invalid Media Source', '', 'Image+');
                 return '';
             }
             $source->setRequestProperties($_REQUEST);
             $source->initialize();
             // The variable contains a value and has to be converted to an Image+ image object
             $imgPath = $source->getBasePath() . $json;
             if (file_exists($imgPath)) {
                 $size = getimagesize($imgPath);
             } else {
                 $this->modx->log(xPDO::LOG_LEVEL_INFO, 'The template variabe value does not contain an existing image', '', 'Image+');
             }
             $json = json_encode(array('altTag' => '', 'crop' => array('height' => $size ? $size[1] : 0, 'width' => $size ? $size[0] : 0, 'x' => 0, 'y' => 0), 'sourceImg' => array('height' => $size ? $size[1] : 0, 'width' => $size ? $size[0] : 0, 'source' => $source->get('id'), 'src' => $json), 'targetHeight' => (int) $opts['targetHeight'], 'targetWidth' => (int) $opts['targetWidth']));
         }
     }
     return $json;
 }
开发者ID:hugopeek,项目名称:ImagePlus,代码行数:40,代码来源:imageplus.class.php

示例3: process

 /**
  * Loads snippet for form processing
  *
  * @param $action
  * @param array $fields
  *
  * @return array|string
  */
 public function process($action, array $fields = array())
 {
     if (!isset($_SESSION['AjaxForm'][$action])) {
         return $this->error('af_err_action_nf');
     }
     unset($fields['af_action'], $_POST['af_action']);
     $scriptProperties = $_SESSION['AjaxForm'][$action];
     $scriptProperties['fields'] = $fields;
     $scriptProperties['AjaxForm'] = $this;
     $name = $scriptProperties['snippet'];
     $set = '';
     if (strpos($name, '@') !== false) {
         list($name, $set) = explode('@', $name);
     }
     /** @var modSnippet $snippet */
     if ($snippet = $this->modx->getObject('modSnippet', array('name' => $name))) {
         $properties = $snippet->getProperties();
         $property_set = !empty($set) ? $snippet->getPropertySet($set) : array();
         $scriptProperties = array_merge($properties, $property_set, $scriptProperties);
         $snippet->_cacheable = false;
         $snippet->_processed = false;
         $response = $snippet->process($scriptProperties);
         if (strtolower($snippet->name) == 'formit') {
             $response = $this->handleFormIt($scriptProperties);
         }
         return $response;
     } else {
         return $this->error('af_err_snippet_nf', array(), array('name' => $name));
     }
 }
开发者ID:vashot,项目名称:AjaxForm,代码行数:38,代码来源:ajaxform.class.php

示例4: getTask

 /**
  * Gets a task by its ID or namespace and reference
  *
  * @param string|int $namespaceOrId
  * @param string $reference
  * @return null|sTask
  */
 public function getTask($namespaceOrId, $reference = '')
 {
     if (is_numeric($namespaceOrId) && empty($reference)) {
         $condition = $namespaceOrId;
     } else {
         $condition = array('namespace' => $namespaceOrId, 'reference' => $reference);
     }
     $task = $this->modx->getObject('sTask', $condition);
     return $task;
 }
开发者ID:sebastian-marinescu,项目名称:Scheduler,代码行数:17,代码来源:scheduler.class.php

示例5: getLastModified

 /**
  * @param string $tpl
  *
  * @return int
  */
 public function getLastModified($tpl)
 {
     /** @var modChunk $chunk */
     if ($chunk = $this->modx->getObject('modTemplate', array('templatename' => $tpl))) {
         if ($chunk->isStatic() && ($file = $chunk->getSourceFile())) {
             return filemtime($file);
         }
     }
     return time();
 }
开发者ID:qhuy61,项目名称:pdoTools,代码行数:15,代码来源:ModTemplate.php

示例6: getLastModified

 /**
  * @param string $tpl
  *
  * @return int
  */
 public function getLastModified($tpl)
 {
     $c = is_numeric($tpl) && $tpl > 0 ? $tpl : array('name' => $tpl);
     /** @var modChunk $chunk */
     if ($chunk = $this->modx->getObject('modChunk', $c)) {
         if ($chunk->isStatic() && ($file = $chunk->getSourceFile())) {
             return filemtime($file);
         }
     }
     return time();
 }
开发者ID:WhisperingTree,项目名称:blog,代码行数:16,代码来源:ModChunk.php

示例7: get

 /**
  * Gets an element object of the specifed type
  * 
  * @todo Keep getting "Call to a member function getObject() on a non-object" 
  * 
  * @param modX $modx
  * @param string $type
  * @param integer | string $criteria (ID or name of the element) 
  * 
  * @return Element | boolean
  */
 public static function get(modX $modx, $type, $criteria)
 {
     if (is_int($criteria)) {
         $element = $modx->getObject($type, $criteria);
     } else {
         $element = $modx->getObject($type, array(Element::get_name_field($type) => $criteria));
     }
     if (isset($element)) {
         return new Element($element);
     }
     return false;
 }
开发者ID:roryg,项目名称:ElementHelper,代码行数:23,代码来源:element.class.php

示例8: postInstall

 public function postInstall()
 {
     /* fix settings_version */
     /** @var \modSystemSetting $object */
     $object = $this->xpdo->getObject('modSystemSetting', array('key' => 'settings_version'));
     if (!$object) {
         $object = $this->xpdo->newObject('modSystemSetting');
         $object->fromArray(array('key' => 'settings_version', 'area' => 'system', 'namespace' => 'core', 'xtype' => 'textfield'), '', true);
     }
     $object->set('value', $this->xpdo->version['full_version']);
     $object->save(false);
     /* fix session_cookie_domain */
     $object = $this->xpdo->getObject('modSystemSetting', array('key' => 'session_cookie_domain'));
     if (!$object) {
         $object = $this->xpdo->newObject('modSystemSetting');
         $object->fromArray(array('key' => 'session_cookie_domain', 'area' => 'session', 'namespace' => 'core', 'xtype' => 'textfield'), '', true);
     }
     $object->set('value', '');
     $object->save(false);
     /* fix session_cookie_path */
     $object = $this->xpdo->getObject('modSystemSetting', array('key' => 'session_cookie_path'));
     if (!$object) {
         $object = $this->xpdo->newObject('modSystemSetting');
         $object->fromArray(array('key' => 'session_cookie_path', 'area' => 'session', 'namespace' => 'core', 'xtype' => 'textfield'), '', true);
     }
     $object->set('value', $this->xpdo->getOption('base_url', null, MODX_BASE_URL));
     $object->save(false);
 }
开发者ID:exside,项目名称:teleport,代码行数:28,代码来源:Transport.php

示例9: delete

 /**
  * Handle DELETE requests
  * @return array
  */
 public function delete()
 {
     $id = $this->getProperty($this->primaryKeyField, false);
     if (empty($id)) {
         return $this->failure($this->modx->lexicon('rest.err_field_ns', array('field' => $this->primaryKeyField)));
     }
     $c = $this->getPrimaryKeyCriteria($id);
     $this->object = $this->modx->getObject($this->classKey, $c);
     if (empty($this->object)) {
         return $this->failure($this->modx->lexicon('rest.err_obj_nf', array('class_key' => $this->classKey)));
     }
     if (!empty($this->deleteRequiredFields)) {
         if (!$this->checkRequiredFields($this->deleteRequiredFields)) {
             return $this->failure();
         }
     }
     $this->object->fromArray($this->getProperties());
     $beforeDelete = $this->beforeDelete();
     if ($beforeDelete !== true) {
         return $this->failure($beforeDelete === false ? $this->errorMessage : $beforeDelete);
     }
     if (!$this->object->{$this->deleteMethod}()) {
         $this->setObjectErrors();
         return $this->failure($this->modx->lexicon('rest.err_class_remove', array('class_key' => $this->classKey)));
     }
     $objectArray = $this->object->toArray();
     $this->afterDelete($objectArray);
     return $this->success('', $objectArray);
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:33,代码来源:modrestcontroller.class.php

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

示例11: validate

 /**
  * Validates a field based on a custom rule, if specified
  *
  * @access public
  * @param string $key The key of the field
  * @param mixed $value The value of the field
  * @param string $type Optional. The type of the validator to apply. Can
  * either be a method name of lgnValidator or a Snippet name.
  * @return boolean True if validation was successful. If not, will store
  * error messages to $this->errors.
  */
 public function validate($key, $value, $type = '')
 {
     $validated = false;
     $hasParams = strpos($type, '=');
     $param = null;
     if ($hasParams !== false) {
         $param = str_replace('`', '', substr($type, $hasParams + 1, strlen($type)));
         $type = substr($type, 0, $hasParams);
     }
     $invNames = array('validate', 'validateFields', '_addError', '__construct');
     if (method_exists($this, $type) && $type != 'validate') {
         /* built-in validator */
         $validated = $this->{$type}($key, $value, $param);
     } else {
         if ($snippet = $this->modx->getObject('modSnippet', array('name' => $type))) {
             /* custom snippet validator */
             $props = array_merge($this->login->config, array('key' => $key, 'value' => $value, 'param' => $param, 'type' => $type, 'validator' => &$this, 'errors' => &$this->errors));
             $validated = $snippet->process($props);
         } else {
             /* no validator found */
             $this->modx->log(modX::LOG_LEVEL_ERROR, '[Register] Could not find validator "' . $type . '" for field "' . $key . '".');
             $validated = true;
         }
     }
     if (is_array($validated) && !empty($validated)) {
         foreach ($validated as $key => $errMsg) {
             $this->_addError($key, $errMsg);
         }
         $validated = false;
     } elseif ($validated !== '1' && $validated !== 1 && $validated !== true) {
         $this->_addError($key, $validated);
         $validated = false;
     }
     return $validated;
 }
开发者ID:jrotering,项目名称:Login,代码行数:46,代码来源:lgnvalidator.class.php

示例12: find

 public function find(array $search = array(), array $args = array())
 {
     $results = array();
     $where = array_merge(array('query' => false, 'tag' => false, 'sorter' => false, 'start' => 0, 'limit' => 10, 'dateFormat' => '%b %d, %Y', 'supportsSeparator' => ', '), $search);
     $where['page'] = !empty($where['start']) ? round($where['start'] / $where['limit']) : 0;
     /** @var modRestResponse $response */
     $response = $this->request('package', 'GET', $where);
     if ($response->isError()) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $response->getError(), '', __METHOD__, __FILE__, __LINE__);
         return $results;
     }
     $xml = $response->toXml();
     /** @var SimpleXMLElement $package */
     foreach ($xml as $package) {
         $installed = $this->xpdo->getObject('transport.modTransportPackage', (string) $package->signature);
         $versionCompiled = rtrim((string) $package->version . '-' . (string) $package->release, '-');
         $releasedon = strftime($this->arg('dateFormat', $where), strtotime((string) $package->releasedon));
         $supports = '';
         foreach ($package->supports as $support) {
             $supports .= (string) $support . $this->arg('supportsSeparator', $where);
         }
         $results[] = array('id' => (string) $package->id, 'version' => (string) $package->version, 'release' => (string) $package->release, 'signature' => (string) $package->signature, 'author' => (string) $package->author, 'description' => (string) $package->description, 'instructions' => (string) $package->instructions, 'changelog' => (string) $package->changelog, 'createdon' => (string) $package->createdon, 'editedon' => (string) $package->editedon, 'name' => (string) $package->name, 'downloads' => number_format((int) $package->downloads, 0), 'releasedon' => $releasedon, 'screenshot' => (string) $package->screenshot, 'thumbnail' => !empty($package->thumbnail) ? (string) $package->thumbnail : (string) $package->screenshot, 'license' => (string) $package->license, 'minimum_supports' => (string) $package->minimum_supports, 'breaks_at' => (int) $package->breaks_at != 10000000 ? (string) $package->breaks_at : '', 'supports_db' => (string) $package->supports_db, 'location' => (string) $package->location, 'version-compiled' => $versionCompiled, 'downloaded' => !empty($installed) ? true : false, 'featured' => (bool) $package->featured, 'audited' => (bool) $package->audited, 'dlaction-icon' => $installed ? 'package-installed' : 'package-download', 'dlaction-text' => $installed ? $this->xpdo->lexicon('downloaded') : $this->xpdo->lexicon('download'));
     }
     return array((int) $xml['total'], $results);
 }
开发者ID:modxcustomize,项目名称:Clickatell,代码行数:25,代码来源:modtransportprovider.class.php

示例13: getStatistics

 /**
  * Get the statistics for the bottom area of the forums
  * @return void
  */
 protected function getStatistics()
 {
     $this->setPlaceholder('totalPosts', number_format((int) $this->getPostCount()));
     $this->setPlaceholder('totalTopics', number_format((int) $this->getThreadCount()));
     $this->setPlaceholder('totalMembers', number_format((int) $this->modx->getCount('disUser')));
     /* active in last 40 */
     if ($this->modx->getOption('discuss.show_whos_online', null, true)) {
         $this->setPlaceholder('activeUsers', $this->discuss->hooks->load('user/active_in_last'));
     } else {
         $this->setPlaceholder('activeUsers', '');
     }
     /* total active */
     $this->setPlaceholder('totalMembersActive', number_format((int) $this->modx->getCount('disSession', array('user:!=' => 0))));
     $this->setPlaceholder('totalVisitorsActive', number_format((int) $this->modx->getCount('disSession', array('user' => 0))));
     /**
      * forum activity
      * @var disForumActivity $activity
      */
     $activity = $this->modx->getObject('disForumActivity', array('day' => date('Y-m-d')));
     if (!$activity) {
         $activity = $this->modx->newObject('disForumActivity');
         $activity->set('day', date('Y-m-d'));
         $activity->save();
     }
     $this->setPlaceholders($activity->toArray('activity.'));
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:30,代码来源:discusscontroller.class.php

示例14: getChunk

 /**
  * Gets a Chunk and caches it; also falls back to file-based templates
  * for easier debugging.
  *
  * Will always use the file-based chunk if $debug is set to true.
  *
  * @access public
  * @param string $name The name of the Chunk
  * @param array $properties The properties for the Chunk
  * @return string The processed content of the Chunk
  */
 public function getChunk($name, $properties = array())
 {
     $chunk = null;
     if (substr($name, 0, 6) == "@CODE:") {
         $content = substr($name, 6);
         $chunk = $this->modx->newObject('modChunk');
         $chunk->setContent($content);
     } elseif (!isset($this->chunks[$name])) {
         if (!$this->config['debug']) {
             $chunk = $this->modx->getObject('modChunk', array('name' => $name), true);
         }
         if (empty($chunk)) {
             $chunk = $this->_getTplChunk($name);
             if ($chunk == false) {
                 return false;
             }
         }
         $this->chunks[$name] = $chunk->getContent();
     } else {
         $o = $this->chunks[$name];
         $chunk = $this->modx->newObject('modChunk');
         $chunk->setContent($o);
     }
     $chunk->setCacheable(false);
     return $chunk->process($properties);
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:37,代码来源:formit.class.php

示例15: move

 /**
  * Move a thread to a new board
  *
  * @param int $boardId
  * @return boolean True if successful
  */
 public function move($boardId)
 {
     $oldBoard = $this->getOne('Board');
     $newBoard = is_object($boardId) && $boardId instanceof disBoard ? $boardId : $this->xpdo->getObject('disBoard', $boardId);
     if (!$oldBoard || !$newBoard) {
         return false;
     }
     $this->addOne($newBoard);
     if ($this->save()) {
         /* readjust all posts */
         $posts = $this->getMany('Posts');
         foreach ($posts as $post) {
             $post->set('board', $newBoard->get('id'));
             $post->save();
         }
         /* adjust old board topics/reply counts */
         $oldBoard->set('num_topics', $oldBoard->get('num_topics') - 1);
         $replies = $oldBoard->get('num_replies') - $this->get('replies');
         $oldBoard->set('num_replies', $replies);
         $total_posts = $oldBoard->get('total_posts') - $this->get('replies') - 1;
         $oldBoard->set('total_posts', $total_posts);
         /* recalculate latest post */
         $oldBoardLastPost = $this->xpdo->getObject('disPost', array('id' => $oldBoard->get('last_post')));
         if ($oldBoardLastPost && $oldBoardLastPost->get('id') == $this->get('post_last')) {
             $newLastPost = $oldBoard->get2ndLatestPost();
             if ($newLastPost) {
                 $oldBoard->set('last_post', $newLastPost->get('id'));
                 $oldBoard->addOne($newLastPost, 'LastPost');
             }
         }
         $oldBoard->save();
         /* adjust new board topics/reply counts */
         $newBoard->set('num_topics', $oldBoard->get('num_topics') - 1);
         $replies = $newBoard->get('num_replies') + $this->get('replies');
         $newBoard->set('num_replies', $replies);
         $total_posts = $newBoard->get('total_posts') + $this->get('replies') + 1;
         $newBoard->set('total_posts', $total_posts);
         /* recalculate latest post */
         $newBoardLastPost = $this->xpdo->getObject('disPost', array('id' => $newBoard->get('last_post')));
         $thisThreadPost = $this->getOne('LastPost');
         if ($newBoardLastPost && $thisThreadPost && $newBoardLastPost->get('createdon') < $thisThreadPost->get('createdon')) {
             $newBoard->set('last_post', $thisThreadPost->get('id'));
             $newBoard->addOne($thisThreadPost, 'LastPost');
         }
         $newBoard->save();
         /* Update ThreadRead board field */
         $this->xpdo->exec('UPDATE ' . $this->xpdo->getTableName('disThreadRead') . '
             SET ' . $this->xpdo->escape('board') . ' = ' . $newBoard->get('id') . '
             WHERE ' . $this->xpdo->escape('thread') . ' = ' . $this->get('id') . '
         ');
         /* clear caches */
         if (!defined('DISCUSS_IMPORT_MODE')) {
             $this->xpdo->getCacheManager();
             $this->xpdo->cacheManager->delete('discuss/thread/' . $this->get('id'));
             $this->xpdo->cacheManager->delete('discuss/board/' . $newBoard->get('id'));
             $this->xpdo->cacheManager->delete('discuss/board/' . $oldBoard->get('id'));
         }
     }
     return true;
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:66,代码来源:disthread.class.php


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