public function loadObjectList($key = '', $class = "stdClass", $translate = true, $language = null, $asObject = true, $onlytransFields = true)
 {
     $this->translate = $translate;
     if ($this->skipjf || $translate === false) {
         return parent::loadObjectList($key, $class);
     }
     $pfunc = $this->profile();
     // we can't call the query twice!
     if (!($cur = $this->query())) {
         return null;
     }
     $fields = array();
     if (!$this->doTranslate($fields)) {
         $array = array();
         while ($row = mysqli_fetch_object($cur, $class)) {
             if ($key) {
                 $array[$row->{$key}] = $row;
             } else {
                 $array[] = $row;
             }
         }
         mysqli_free_result($cur);
         return $array;
     }
     $jfdata = array();
     if ($key != "") {
         while ($row = mysqli_fetch_array($cur, MYSQLI_BOTH)) {
             $jfdata[$row[$key]] = $row;
         }
     } else {
         while ($row = mysqli_fetch_array($cur, MYSQLI_BOTH)) {
             $jfdata[] = $row;
         }
     }
     if (count($jfdata) == 0) {
         return $jfdata;
     }
     // Before joomfish manager is created since we can't translate so skip this anaylsis
     $jfManager = JoomFishManager::getInstance();
     if (!$jfManager) {
         return $jfdata;
     }
     if (isset($jfManager)) {
         $this->setLanguage($language);
     }
     if ($jfManager->getCfg("transcaching", 1)) {
         $this->orig_limit = $this->get("limit");
         $this->orig_offset = $this->get("offset");
         // cache the results
         // special Joomfish database cache
         // $cache = $jfManager->getCache($language);
         // $jfdata = $cache->get(array("JoomFish", 'translateListArrayCached'), array($jfdata, $language, $fields));
         $cache = JFactory::getCache('com_joomfish', 'callback');
         $jfdata = $cache->get("JoomFish::translateListArrayCached", array(&$jfdata, $language, $fields, $onlytransFields));
         $this->orig_limit = 0;
         $this->orig_offset = 0;
     } else {
         $this->orig_limit = $this->get("limit");
         $this->orig_offset = $this->get("offset");
         JoomFish::translateListArray($jfdata, $language, $fields, $onlytransFields);
         $this->orig_limit = 0;
         $this->orig_offset = 0;
     }
     mysqli_free_result($cur);
     if ($asObject) {
         $array = array();
         foreach ($jfdata as $row) {
             $obj = new stdClass();
             $fieldcount = 0;
             foreach ($fields as $field) {
                 $fieldname = $field->name;
                 $obj->{$fieldname} = $row[$fieldcount];
                 $fieldcount++;
             }
             if ($key) {
                 $array[$obj->{$key}] = $obj;
             } else {
                 $array[] = $obj;
             }
         }
         $pfunc = $this->profile($pfunc);
         return $array;
     }
     $pfunc = $this->profile($pfunc);
     return $jfdata;
 }
Esempio n. 2
0
 /**
  * Translates a list based on cached values
  * @param array $rows
  * @param JFLanguage $language
  * @param array $tableArray
  */
 public static function translateListArrayCached(&$rows, $language, $tableArray, $onlytransFields = true)
 {
     JoomFish::translateListArray($rows, $language, $tableArray, $onlytransFields);
     return $rows;
 }