2 require_once(
'./Services/Table/classes/class.ilTable2GUI.php');
3 require_once(
'./Services/ActiveRecord/class.ActiveRecordList.php');
4 require_once(
'./Services/ActiveRecord/Views/Index/class.arIndexTableField.php');
5 require_once(
'./Services/ActiveRecord/Views/Index/class.arIndexTableFields.php');
6 require_once(
'./Services/ActiveRecord/Views/Index/class.arIndexTableAction.php');
7 require_once(
'./Services/ActiveRecord/Views/Index/class.arIndexTableActions.php');
70 $ilTabs = $DIC[
'ilTabs'];
71 $ilAccess = $DIC[
'ilAccess'];
73 $this->tabs = $ilTabs;
74 $this->access = $ilAccess;
76 $this->parent_obj = $a_parent_obj;
80 $this->
setId(strtolower(get_class($this->active_record_list->getAR()) .
"_index"));
84 parent::__construct($a_parent_obj, $a_parent_cmd);
105 $this->initTableFilter();
109 $this->initTableColumns();
110 $this->initTableData();
124 $this->
fields->sortFields();
155 $this->actions->addAction($action);
161 $this->
setFormAction($this->ctrl->getFormAction($this->parent_obj));
185 return $this->
txt(
"add_item");
202 return $this->
txt(
"delete",
false);
214 $this->multi_item_actions->addAction($action);
221 $this->
addMultiItemSelectionButton(
"index_table_multi_action", $this->multi_item_actions->getActionsAsKeyTextArray(),
"multiAction", $this->
txt(
'execute',
false));
234 return $this->
getFields()->getSelectableColumns($this);
241 protected function initTableFilter()
253 if ($field->getHasFilter()) {
289 protected function addFilterItemToForm(
ilFormPropertyGUI $item, $optional =
false)
296 $this->filter_array[$item->
getPostVar()] = $item->getValue();
312 $this->
setRowTemplate(
'tpl.record_row.html',
'./Services/ActiveRecord/');
319 protected function initTableColumns()
328 if ($field->getSortable()) {
329 $this->
addColumn($this->
txt($field->getTxt()), $field->getName());
360 protected function initTableData()
362 $this->active_record_list->getArWhereCollection()->setStatements(null);
363 $this->active_record_list->getArJoinCollection()->setStatements(null);
364 $this->active_record_list->getArLimitCollection()->setStatements(null);
365 $this->active_record_list->getArOrderCollection()->setStatements(null);
367 $this->filterTableData();
370 $ar_data = $this->active_record_list->getArray();
373 foreach ($ar_data as
$key => $item) {
375 foreach ($this->
getFields()->getFieldsForDisplay() as $field) {
379 if (array_key_exists($field->getName(), $item)) {
380 if (!$item[$field->getName()]) {
382 } elseif ($field->getIsCreatedByField()) {
384 } elseif ($field->getIsModifiedByField()) {
398 protected function filterTableData()
406 $this->
addFilterWhere($filter, $filter->getPostVar(), $filter->getValue());
419 switch (get_class($filter)) {
420 case 'ilTextInputGUI':
424 case 'ilCombinationInputGUI':
425 if (is_object($value[
"from"]) || is_object($value[
"to"])) {
426 if (get_class($value[
"from"]) ==
"ilDateTime" || get_class($value[
"to"]) ==
"ilDateTime") {
431 if (get_class($value[
"from"]) ==
"ilDate" || get_class($value[
"to"]) ==
"ilDate") {
458 if ($value[
"from"] !=
"" or $value[
"to"] !=
"") {
459 if ($value[
"from"] ==
"") {
462 if ($value[
"to"] ==
"") {
463 $value[
"to"] = PHP_INT_MAX;
465 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." .
$name .
" >= " . $value[
"from"]
466 .
" AND " . $this->active_record_list->getAR()->getConnectorContainerName() .
"." .
$name .
" <= " . $value[
"to"]);
478 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." .
$name .
" like '%" . $value .
"%'");
489 if ($value[
"from"] != null
or $value[
"to"] != null) {
490 if ($value[
"from"] == null) {
493 if ($value[
"to"] == null) {
496 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." .
$name .
" BETWEEN '" 509 if ($value[
"from"] != null
or $value[
"to"] != null) {
510 if ($value[
"from"] == null) {
513 if ($value[
"to"] == null) {
516 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." .
$name .
" BETWEEN '" 537 $this->
setDefaultOrderField($this->active_record_list->getAR()->getArFieldList()->getPrimaryField()->getName());
541 $this->
setMaxCount($this->active_record_list->count());
570 return $user->getPublicName();
585 return $user->getPublicName();
637 return "CUSTOM-OVERRIDE: setCustomFieldData";
652 $this->addActionsToRow($a_set);
661 $this->ctrl->setParameterByClass(get_class($this->parent_obj),
'ar_id', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()
672 $this->tpl->setVariable(
'ID', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
682 foreach ($a_set as
$key => $value) {
697 $this->tpl->setCurrentBlock(
'entry');
698 $this->tpl->setVariable(
'ENTRY_CONTENT', $value);
699 $this->tpl->parseCurrentBlock(
'entry');
706 protected function addActionsToRow($a_set)
710 $alist->setId(self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
711 $alist->setListTitle($this->
txt(
'actions',
false));
718 if ($action->getAccess()) {
719 $access = $this->access->checkAccess($action->getAccess(),
'',
$_GET[
'ref_id']);
722 $alist->addItem($action->getTitle(), $action->getId(), $this->ctrl->getLinkTargetByClass($action->getTargetClass(), $action->getTargetCmd()));
726 $this->tpl->setVariable(
'ACTION', $alist->getHTML());
736 $index_table_tpl =
new ilTemplate(
"tpl.index_table.html",
true,
true,
"./Services/ActiveRecord/");
741 $index_table_tpl->setVariable(
"TABLE", parent::render());
743 return $index_table_tpl->get();
755 return $this->parent_obj->txt(
$txt, $plugin_txt);
763 $this->initTableData();
769 parent::resetFilter();
771 $this->initTableData();
785 if (!empty($id_to_encode)) {
786 $encoded_id = preg_replace_callback(
'/([^a-zA-Z0-9])/',
function ($matches) {
787 return "__idstart_" . strtolower(dechex(ord($matches[0]))) .
"_idend__";
804 if (!empty($id_to_decode)) {
805 $decoded_id = preg_replace_callback(
'/__idstart_(.{2})_idend__/',
function ($matches) {
806 return chr(hexdec($matches[1]));
848 return $this->
getFields()->getField($field_name);
920 return $this->actions->getActions();
addMultipleSelectionColumn()
GUI-Class arIndexTableGUI.
GUI-Class arIndexTableActions.
setExternalSorting($a_val)
Set external sorting.
getDefaultOrderField()
Get Default order field.
GUI-Class arIndexTableFields.
setDefaultOrderField($a_defaultorderfield)
Set Default order field.
setCustomFieldData(arIndexTableField $field, $item)
addAction(arIndexTableAction $action)
checkColumnVisibile(arIndexTableField $field)
parseEntry(arIndexTableField $field, $value)
addMutliItemAction(arIndexTableAction $action)
initBeforeParentConstructor()
setEmptyFieldData(arIndexTableField $field, $item)
addFilterField(arIndexTableField $field)
txt($txt, $plugin_txt=true)
setFields(arIndexTableFields $fields)
setFilterCols($a_val)
Set filter columns.
setExternalSegmentation($a_val)
Set external segmentation.
addFilterDateTimeWhere(ilCombinationInputGUI $filter, $name, $value)
resetOffset($a_in_determination=false)
Reset offset.
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=null)
Add filter by standard type.
addMultiItemActionCheckboxToRow($a_set)
addFilterItem($a_input_item, $a_optional=false)
Add filter item.
GUI-Class arIndexTableField.
static domid_decode($id_to_decode)
determineLimit()
Determine the limit.
getMultiItemActionsAsArray()
getOrderDirection()
Get order direction.
$fields
arIndexTableFields
setDateFieldData(arIndexTableField $field, $item, $value)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
initMultiItemActionsButton()
static domid_encode($id_to_encode)
setArModifiedByField(arIndexTableField $field, $item, $value)
setArCreatedByField(arIndexTableField $field, $item, $value)
setTableTitle($table_title)
setCtrlParametersForRow($a_set)
setResetCommand($a_val, $a_caption=null)
Set reset filter command.
setMultiItemActions($multi_item_actions)
addField(arIndexTableField $field)
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
addFilterDateWhere(ilCombinationInputGUI $filter, $name, $value)
__construct(arGUI $a_parent_obj, $a_parent_cmd, ActiveRecordList $active_record_list)
customizeFields()
To be overridden
addFilterWhere(ilFormPropertyGUI $filter, $name, $value)
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setArFieldData(arIndexTableField $field, $item, $value)
writeFilterToSession()
Write filter values to session.
isColumnSelected($a_col)
Is given column selected?
setOrderAndSegmentation()
addFilterTextWhere(ilTextInputGUI $filter, $name, $value)
addMultiItemSelectionButton($a_sel_var, $a_options, $a_cmd, $a_text, $a_default_selection='')
Add Selection List + Command button for selected items.
determineOffsetAndOrder($a_omit_offset=false)
Determine offset and order.
User interface class for advanced drop-down selection lists.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
initAfterParentConstructor()
setMaxCount($a_max_count)
set max.
getFilterItems($a_optionals=false)
Get filter items.
getSelectableColumns()
Get selectable columns.
addFilterNumericWhere(ilCombinationInputGUI $filter, $name, $value)
GUI-Class arIndexTableAction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.