Exemplo n.º 1
0
 protected function initTableData()
 {
     $this->active_record_list->getArWhereCollection()->setStatements(NULL);
     $this->active_record_list->getArJoinCollection()->setStatements(NULL);
     $this->active_record_list->getArLimitCollection()->setStatements(NULL);
     $this->active_record_list->getArOrderCollection()->setStatements(NULL);
     $this->filterTableData();
     $this->beforeGetData();
     $this->setOrderAndSegmentation();
     $ar_data = $this->active_record_list->getArray();
     $data = array();
     foreach ($ar_data as $key => $item) {
         $data[$key] = array();
         foreach ($this->getFields()->getFieldsForDisplay() as $field) {
             /**
              * @var arIndexTableField $field
              */
             if (array_key_exists($field->getName(), $item)) {
                 if (!$item[$field->getName()]) {
                     $data[$key][$field->getName()] = $this->setEmptyFieldData($field, $item);
                 } elseif ($field->getIsCreatedByField()) {
                     $data[$key][$field->getName()] = $this->setArCreatedByField($field, $item, $item[$field->getName()]);
                 } elseif ($field->getIsModifiedByField()) {
                     $data[$key][$field->getName()] = $this->setArModifiedByField($field, $item, $item[$field->getName()]);
                 } else {
                     $data[$key][$field->getName()] = $this->setArFieldData($field, $item, $item[$field->getName()]);
                 }
             } else {
                 $data[$key][$field->getName()] = $this->setCustomFieldData($field, $item);
             }
         }
     }
     $this->setData($data);
 }
Exemplo n.º 2
0
 /**
  * @param ActiveRecordList $arl
  *
  * @return mixed|string
  */
 protected function buildQuery(ActiveRecordList $arl)
 {
     // SELECTS
     $q = $arl->getArSelectCollection()->asSQLStatement();
     // Concats
     $q .= $arl->getArConcatCollection()->asSQLStatement();
     $q .= ' FROM ' . $arl->getAR()->getConnectorContainerName();
     // JOINS
     $q .= $arl->getArJoinCollection()->asSQLStatement();
     // WHERE
     $q .= $arl->getArWhereCollection()->asSQLStatement();
     // ORDER
     $q .= $arl->getArOrderCollection()->asSQLStatement();
     // LIMIT
     $q .= $arl->getArLimitCollection()->asSQLStatement();
     //TODO: using template in the model.
     if ($arl->getDebug()) {
         global $tpl;
         if ($tpl instanceof ilTemplate) {
             ilUtil::sendInfo($q);
         } else {
             var_dump($q);
             // FSX
         }
     }
     $arl->setLastQuery($q);
     return $q;
 }
Exemplo n.º 3
0
 /**
  * @param ActiveRecordList $arl
  *
  * @internal param $q
  *
  * @return array
  */
 public function readSet(ActiveRecordList $arl)
 {
     $session = self::getSessionForActiveRecord($arl->getAR());
     foreach ($session as $i => $s) {
         $session[$i] = (array) $s;
     }
     foreach ($arl->getArWhereCollection()->getWheres() as $w) {
         $fieldname = $w->getFieldname();
         $v = $w->getValue();
         $operator = $w->getOperator();
         foreach ($session as $i => $s) {
             $session[$i] = (array) $s;
             switch ($operator) {
                 case '=':
                     if ($s[$fieldname] != $v) {
                         unset($session[$i]);
                     }
                     break;
             }
         }
     }
     return $session;
 }