Exemplo n.º 1
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);
 }
Exemplo n.º 2
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;
 }