2 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/class.srModelObjectTableGUI.php');
3 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/class.ActiveRecordList.php');
4 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/Views/Index/class.arIndexTableField.php');
5 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/Views/Index/class.arIndexTableFields.php');
6 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/Views/Index/class.arIndexTableAction.php');
7 require_once(
'./Customizing/global/plugins/Libraries/ActiveRecord/Views/Index/class.arIndexTableActions.php');
66 global
$ilCtrl, $ilTabs, $ilAccess;
68 $this->tabs = $ilTabs;
69 $this->access = $ilAccess;
71 $this->parent_obj = $a_parent_obj;
75 $this->
setId(strtolower(get_class($this->active_record_list->getAR()) .
"_index"));
98 $this->initTableFilter();
102 $this->initTableColumns();
103 $this->initTableData();
115 $this->
fields->sortFields();
142 $this->actions->addAction($action);
147 $this->
setFormAction($this->ctrl->getFormAction($this->parent_obj));
168 return $this->
txt(
"add_item");
183 return $this->
txt(
"delete",
false);
194 $this->multi_item_actions->addAction($action);
200 $this->
addMultiItemSelectionButton(
"index_table_multi_action", $this->multi_item_actions->getActionsAsKeyTextArray(),
"multiAction", $this->
txt(
'execute',
false));
212 return $this->
getFields()->getSelectableColumns($this);
219 protected function initTableFilter() {
230 if ($field->getHasFilter()) {
265 protected function addFilterItemToForm(
ilFormPropertyGUI $item, $optional =
false) {
271 $this->filter_array[$item->
getPostVar()] = $item->getValue();
285 $this->
setRowTemplate(
'tpl.record_row.html',
'./Customizing/global/plugins/Libraries/ActiveRecord/');
292 protected function initTableColumns() {
300 if ($field->getSortable()) {
301 $this->
addColumn($this->
txt($field->getTxt()), $field->getName());
330 protected function initTableData() {
331 $this->active_record_list->getArWhereCollection()->setStatements(NULL);
332 $this->active_record_list->getArJoinCollection()->setStatements(NULL);
333 $this->active_record_list->getArLimitCollection()->setStatements(NULL);
334 $this->active_record_list->getArOrderCollection()->setStatements(NULL);
336 $this->filterTableData();
339 $ar_data = $this->active_record_list->getArray();
342 foreach ($ar_data as $key => $item) {
343 $data[$key] = array();
344 foreach ($this->
getFields()->getFieldsForDisplay() as $field) {
348 if (array_key_exists($field->getName(), $item)) {
349 if (!$item[$field->getName()]) {
351 } elseif ($field->getIsCreatedByField()) {
353 } elseif ($field->getIsModifiedByField()) {
356 $data[$key][$field->getName()] = $this->
setArFieldData($field, $item, $item[$field->getName()]);
367 protected function filterTableData() {
374 $this->
addFilterWhere($filter, $filter->getPostVar(), $filter->getValue());
387 switch (get_class($filter)) {
388 case 'ilTextInputGUI':
392 case 'ilCombinationInputGUI':
393 if (is_object($value[
"from"]) || is_object($value[
"to"])) {
394 if (get_class($value[
"from"]) ==
"ilDateTime" || get_class($value[
"to"]) ==
"ilDateTime") {
399 if (get_class($value[
"from"]) ==
"ilDate" || get_class($value[
"to"]) ==
"ilDate") {
426 if ($value[
"from"] !=
"" OR $value[
"to"] !=
"") {
427 if ($value[
"from"] ==
"") {
430 if ($value[
"to"] ==
"") {
431 $value[
"to"] = PHP_INT_MAX;
433 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" >= " . $value[
"from"]
434 .
" AND " . $this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" <= " . $value[
"to"]);
445 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" like '%" . $value .
"%'");
455 if ($value[
"from"] != NULL OR $value[
"to"] != NULL) {
456 if ($value[
"from"] == NULL) {
459 if ($value[
"to"] == NULL) {
462 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" BETWEEN '"
474 if ($value[
"from"] != NULL OR $value[
"to"] != NULL) {
475 if ($value[
"from"] == NULL) {
478 if ($value[
"to"] == NULL) {
481 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" BETWEEN '"
499 $this->
setDefaultOrderField($this->active_record_list->getAR()->getArFieldList()->getPrimaryField()->getName());
503 $this->
setMaxCount($this->active_record_list->count());
530 return $user->getPublicName();
544 return $user->getPublicName();
593 return "CUSTOM-OVERRIDE: setCustomFieldData";
607 $this->addActionsToRow($a_set);
615 $this->ctrl->setParameterByClass(get_class($this->parent_obj),
'ar_id', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()
625 $this->tpl->setVariable(
'ID', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
634 foreach ($a_set as $key => $value) {
648 $this->tpl->setCurrentBlock(
'entry');
649 $this->tpl->setVariable(
'ENTRY_CONTENT', $value);
650 $this->tpl->parseCurrentBlock(
'entry');
657 protected function addActionsToRow($a_set) {
660 $alist->setId(self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
661 $alist->setListTitle($this->
txt(
'actions',
false));
668 if ($action->getAccess()) {
669 $access = $this->access->checkAccess($action->getAccess(),
'',
$_GET[
'ref_id']);
672 $alist->addItem($action->getTitle(), $action->getId(), $this->ctrl->getLinkTargetByClass($action->getTargetClass(), $action->getTargetCmd()));
676 $this->tpl->setVariable(
'ACTION', $alist->getHTML());
686 $index_table_tpl =
new ilTemplate(
"tpl.index_table.html",
true,
true,
"./Customizing/global/plugins/Libraries/ActiveRecord/");
691 $index_table_tpl->setVariable(
"TABLE", parent::render());
693 return $index_table_tpl->get();
703 public function txt(
$txt, $plugin_txt =
true) {
704 return $this->parent_obj->txt(
$txt, $plugin_txt);
711 $this->initTableData();
718 $this->initTableData();
731 if (!empty($id_to_encode)) {
732 $encoded_id = preg_replace_callback(
'/([^a-zA-Z0-9])/',
function ($matches) {
733 return "__idstart_" . strtolower(dechex(ord($matches[0]))) .
"_idend__";
749 if (!empty($id_to_decode)) {
750 $decoded_id = preg_replace_callback(
'/__idstart_(.{2})_idend__/',
function ($matches) {
751 return chr(hexdec($matches[1]));
789 return $this->
getFields()->getField($field_name);
853 return $this->actions->getActions();