Пример #1
0
 /**
  * Get cache handler.
  *
  * Note this cache will ignore the cache setting in Joomla configuration.
  *
  * @param   string  $handler  The cache handler name.
  * @param   string  $storage  The storage name.
  *
  * @return  \JCache|\JCacheController|\JCacheControllerClosure
  */
 public static function getCache($handler = 'closure', $storage = 'runtime')
 {
     static $included = false;
     if (!$included) {
         \JCacheStorage::addIncludePath(__DIR__);
         \JCacheController::addIncludePath(__DIR__);
         $included = true;
     }
     $handler = $handler ?: 'closure';
     $cache = \JFactory::getCache('windwalker', $handler, $storage);
     $cache->setCaching(true);
     return $cache;
 }
Пример #2
0
 /**
  * Returns a reference to a cache adapter object, always creating it
  *
  * @param   string   $type     The cache object type to instantiate; default is output.
  * @param   array    $options  Array of options
  *
  * @return  JCache             A JCache object
  *
  * @since   11.1
  */
 public static function getInstance($type = 'output', $options = array())
 {
     JCacheController::addIncludePath(JPATH_PLATFORM . '/joomla/cache/controller');
     $type = strtolower(preg_replace('/[^A-Z0-9_\\.-]/i', '', $type));
     $class = 'JCacheController' . ucfirst($type);
     if (!class_exists($class)) {
         // Search for the class file in the JCache include paths.
         jimport('joomla.filesystem.path');
         if ($path = JPath::find(JCacheController::addIncludePath(), strtolower($type) . '.php')) {
             require_once $path;
         } else {
             JError::raiseError(500, 'Unable to load Cache Controller: ' . $type);
         }
     }
     return new $class($options);
 }
Пример #3
0
 /**
  * Returns a reference to a cache adapter object, always creating it
  *
  * @param   string  $type     The cache object type to instantiate
  * @param   array   $options  The array of options
  *
  * @return  JCache  A JCache object
  *
  * @since   11.1
  */
 public static function getInstance($type = 'output', $options = array())
 {
     return JCacheController::getInstance($type, $options);
 }
Пример #4
0
 private function _getTranslations()
 {
     if (!isset($this->translations)) {
         $filter_state = $this->getState('filter.state') ? $this->getState('filter.state') : '.';
         $filter_tag = $this->getState('filter.tag') ? "^" . $this->getState('filter.tag') . "\$" : '.';
         $cache_controller = JCacheController::getInstance();
         $key = 'translation-' . ($this->getState('filter.client') ? $this->getState('filter.client') . '-' : '') . ($this->getState('filter.storage') ? $this->getState('filter.storage') . '-' : '') . ($this->getState('filter.tag') ? "^(" . $this->getState('translations.reference') . "|" . $this->getState('filter.tag') . ")\$" . '-' : '') . ($this->getState('filter.type') ? $this->getState('filter.type') . '-' : '') . ($this->getState('filter.search') ? $this->getState('filter.search') . '-' : '') . ($this->getState('filter.origin') ? $this->getState('filter.origin') . '-' : '');
         $key = substr($key, 0, strlen($key) - 1);
         $this->translations = $cache_controller->get($key, 'localise');
         if (!is_array($this->translations)) {
             $this->translations = array();
             $this->_scanLocalTranslationsFolders();
             $this->_scanGlobalTranslationsFolders();
             $this->_scanReference();
             $this->_scanOverride();
             $cache_controller->store($this->translations, $key, 'localise');
         }
         foreach ($this->translations as $key => $translation) {
             $model = JModelLegacy::getInstance('Translation', 'LocaliseModel', array('ignore_request' => true));
             $model->setState('translation.id', LocaliseHelper::getFileId($translation->path));
             $model->setState('translation.path', $translation->path);
             $model->setState('translation.refpath', $translation->refpath);
             $model->setState('translation.reference', $this->getState('translations.reference'));
             $model->setState('translation.client', $translation->client);
             $model->setState('translation.tag', $translation->tag);
             $model->setState('translation.filename', $translation->filename);
             $item = $model->getItem();
             $state = count($item->error) ? 'error' : $translation->state;
             if (preg_match("/{$filter_state}/", $state) && preg_match("/{$filter_tag}/", $translation->tag)) {
                 if (count($item->error)) {
                     $item->state = 'error';
                     $item->completed = -count($item->error) - 1000;
                 } elseif ($item->bom != 'UTF-8') {
                     if ($translation->state == 'notinreference') {
                         $item->completed = -500;
                     } else {
                         $item->completed = -400;
                     }
                 } elseif ($translation->state == 'notinreference') {
                     $item->completed = -600;
                 } elseif ($translation->type == 'override') {
                     $item->completed = 101;
                 } elseif ($translation->tag == $this->getState('translations.reference')) {
                     $item->completed = 102;
                 } elseif ($translation->state == 'unexisting') {
                     $item->completed = -($item->total / ($item->total + 1));
                 } elseif ($item->complete) {
                     $item->completed = 100;
                 }
                 $this->translations[$key]->setProperties($item->getProperties());
             } else {
                 unset($this->translations[$key]);
             }
         }
         JArrayHelper::sortObjects($this->translations, $this->getState('list.ordering', 'name'), $this->getState('list.direction') == 'asc' ? 1 : -1);
         $this->translations = array_values($this->translations);
     }
     return $this->translations;
 }