예제 #1
0
 /**
  * Custom logic code here for setting placeholders, etc
  * @param array $scriptProperties
  * @return mixed
  */
 public function process(array $scriptProperties = array())
 {
     $placeholders = array();
     $this->resource = $this->modx->getObject('modResource', $scriptProperties['id']);
     if ($this->resource == null) {
         return $this->failure(sprintf($this->modx->lexicon('resource_with_id_not_found'), $scriptProperties['id']));
     }
     if (!$this->resource->checkPolicy('view')) {
         return $this->failure($this->modx->lexicon('access_denied'));
     }
     $this->resource->getOne('CreatedBy');
     $this->resource->getOne('EditedBy');
     $this->resource->getOne('Template');
     $server_offset_time = intval($this->modx->getOption('server_offset_time', null, 0));
     $this->resource->set('createdon_adjusted', strftime('%c', $this->resource->get('createdon') + $server_offset_time));
     $this->resource->set('editedon_adjusted', strftime('%c', $this->resource->get('editedon') + $server_offset_time));
     $this->resource->_contextKey = $this->resource->get('context_key');
     $buffer = $this->modx->cacheManager->get($this->resource->getCacheKey(), array(xPDO::OPT_CACHE_KEY => $this->modx->getOption('cache_resource_key', null, 'resource'), xPDO::OPT_CACHE_HANDLER => $this->modx->getOption('cache_resource_handler', null, $this->modx->getOption(xPDO::OPT_CACHE_HANDLER)), xPDO::OPT_CACHE_FORMAT => (int) $this->modx->getOption('cache_resource_format', null, $this->modx->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP))));
     if ($buffer) {
         $placeholders['buffer'] = htmlspecialchars($buffer['resource']['_content']);
     }
     /* assign resource to smarty */
     $placeholders['resource'] = $this->resource;
     /* make preview url */
     $this->getPreviewUrl();
     $placeholders['_ctx'] = $this->resource->get('context_key');
     return $placeholders;
 }
예제 #2
0
 public function getCacheSource()
 {
     $this->resource->_contextKey = $this->resource->get('context_key');
     $buffer = $this->modx->cacheManager->get($this->resource->getCacheKey(), array(xPDO::OPT_CACHE_KEY => $this->modx->getOption('cache_resource_key', null, 'resource'), xPDO::OPT_CACHE_HANDLER => $this->modx->getOption('cache_resource_handler', null, $this->modx->getOption(xPDO::OPT_CACHE_HANDLER)), xPDO::OPT_CACHE_FORMAT => (int) $this->modx->getOption('cache_resource_format', null, $this->modx->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP))));
     if ($buffer) {
         $buffer = htmlspecialchars($buffer['resource']['_content']);
     }
     return !empty($buffer) ? $buffer : $this->modx->lexicon('resource_notcached');
 }
예제 #3
0
 /**
  * @param modResource $resource
  */
 public function clearResourceCache(&$resource)
 {
     //        $resource->clearCache();
     $resource->_contextKey = $resource->context_key;
     /** @var modCacheManager $cache */
     $cache = $this->modx->cacheManager->getCacheProvider($this->modx->getOption('cache_resource_key', null, 'resource'));
     $key = $resource->getCacheKey();
     $cache->delete($key, array('deleteTop' => true));
     $cache->delete($key);
     $this->modx->_clearResourceCache = true;
     $this->modx->cacheManager = new atCacheManager($this->modx);
 }