Esempio n. 1
0
 function getContents($order = "", $treeTitle = "", $where = "", $treeSeparator = "\\", $originalSQL = "", $ignoreSelfOnTitle = false, $callback = false)
 {
     # This is used on bi_adm::edit.php too
     $output = array();
     if ($this->options[CONS_MODULE_PARENT] != '') {
         if ($order == "" && $this->order != "") {
             $odb = array();
             $ord = explode(",", $this->order);
             foreach ($ord as $orditem) {
                 $orditem = trim($orditem);
                 if (strpos($orditem, "+") !== false) {
                     $orditem = str_replace("+", "", $orditem);
                     if ($orditem == $this->options[CONS_MODULE_PARENT]) {
                         continue;
                     }
                     // will add automaticaly
                     if (isset($this->fields[$orditem])) {
                         $odb[] = $this->name . "." . $orditem . " ASC";
                     } else {
                         $odb[] = $orditem . " ASC";
                     }
                 } else {
                     $orditem = str_replace("-", "", $orditem);
                     if ($orditem == $this->options[CONS_MODULE_PARENT]) {
                         continue;
                     }
                     // will add automaticaly
                     if (isset($this->fields[$orditem])) {
                         $odb[] = $this->name . "." . $orditem . " DESC";
                     } else {
                         $odb[] = $orditem . " DESC";
                     }
                 }
             }
             $order = implode(",", $odb);
         }
         if ($originalSQL == "") {
             // built SQL, will use where provided
             $sql = $this->get_base_sql($where, $this->name . "." . $this->options[CONS_MODULE_PARENT] . " ASC" . ($order != '' ? ',' . $order : ''));
         } else {
             // give a full SQL, will just add proper order and treetitle
             $sql = $originalSQL;
             if (!is_array($sql)) {
                 $sql = $this->parent->dbo->sqlarray_break($sql);
             }
             $sql['ORDER'] = explode(",", $this->name . "." . $this->options[CONS_MODULE_PARENT] . " ASC" . ($order != '' ? ',' . $order : ''));
         }
         if (!$this->parent->dbo->query($sql, $r, $n)) {
             $this->parent->errorControl->raise(146, $this->parent->dbo->log[count($this->parent->dbo->log) - 1], $this->name, 'on getContents');
         }
         $this->parent->templateParams['core'] =& $this->parent;
         $this->parent->templateParams['module'] =& $this;
         for ($c = 0; $c < $n; $c++) {
             $tmpData = $this->parent->dbo->fetch_assoc($r);
             if ($callback !== false) {
                 $tmpData = $callback($this->parent->template, $this->parent->templateParams, $tmpData);
             }
             $tmpData['#'] = $c;
             $tmpData = prepareDataToOutput($this->parent->template, $this->parent->templateParams, $tmpData);
             $output[] = $tmpData;
         }
         $treeObj = new ttree();
         $treeObj->arrayToTree($output, $treeSeparator, $this->options[CONS_MODULE_PARENT], $treeTitle == '' ? $this->title : $treeTitle, $ignoreSelfOnTitle);
         return $treeObj;
     } else {
         $sql = $this->get_base_sql('', $order);
         $this->parent->dbo->query($sql, $r, $n);
         for ($c = 0; $c < $n; $c++) {
             $tmpData = $this->parent->dbo->fetch_assoc($r);
             $params = array('module' => $this);
             $tmpData = prepareDataToOutput($this->parent->template, $params, $tmpData);
             $tmpData['#'] = $c;
             $output[] = $tmpData;
         }
     }
     return $output;
 }