コード例 #1
0
 function loadObjectList($key = '', $class = 'stdClass', $translate = true, $language = null)
 {
     //sbou
     //sbou TODO check r�cursive pb
     //$jfManager = FalangManager::getInstance();
     if (!$translate) {
         $this->_skipSetRefTables = true;
         $result = parent::loadObjectList($key, empty($class) ? 'stdClass' : $class);
         $this->_skipSetRefTables = false;
         return $result;
     }
     $result = parent::loadObjectList($key, empty($class) ? 'stdClass' : $class);
     //		if( isset($jfManager)) {
     //			$this->_setLanguage($language);
     //		}
     // TODO check the impact of this on frontend translation
     // It does stop Joomfish plugins from working on missing translations e.g. regional content so disable for now
     // Don't do it for now since translation caching is so effective
     /*
     $registry = JFactory::getConfig();
     $defaultLang = $registry->getValue("config.defaultlang");
     if ($defaultLang == $language){
     $translate = false;
     }
     */
     //sbou TODO this is not the right solution.
     //		if( isset($jfManager)) {
     if (true) {
         $doTranslate = false;
         $tables = $this->getRefTables();
         if ($tables == null) {
             return $result;
         }
         // an unstranslatable query to return result as is
         // if we don't have "fieldTablePairs" then we can't translate
         if (!array_key_exists("fieldTablePairs", $tables)) {
             return $result;
         }
         foreach ($tables["fieldTablePairs"] as $i => $table) {
             if ($this->translatedContentAvailable($table)) {
                 $doTranslate = true;
                 break;
             }
         }
         if ($doTranslate) {
             $pfunc = $this->_profile();
             //sbou TODO cache desactived
             //				if ($jfManager->getCfg("transcaching",1)){
             if (false) {
                 // cache the results
                 // TODO call based on config
                 //$cache = JFactory::getCache('jfquery');
                 $cache = $jfManager->getCache($language);
                 $this->orig_limit = $this->limit;
                 $this->orig_offset = $this->offset;
                 $result = $cache->get(array("FaLang", 'translateListCached'), array($result, $language, $this->getRefTables()));
                 $this->orig_limit = 0;
                 $this->orig_offset = 0;
             } else {
                 $this->orig_limit = $this->limit;
                 $this->orig_offset = $this->offset;
                 Falang::translateList($result, $language, $this->getRefTables());
                 $this->orig_limit = 0;
                 $this->orig_offset = 0;
             }
             $pfunc = $this->_profile($pfunc);
         }
     }
     return $result;
 }