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');
8 require_once(
'./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php');
68 global
$ilCtrl, $ilTabs, $ilAccess;
70 $this->tabs = $ilTabs;
71 $this->access = $ilAccess;
73 $this->parent_obj = $a_parent_obj;
77 $this->
setId(strtolower(get_class($this->active_record_list->getAR()) .
"_index"));
81 parent::__construct($a_parent_obj, $a_parent_cmd);
100 $this->initTableFilter();
104 $this->initTableColumns();
105 $this->initTableData();
117 $this->
fields->sortFields();
144 $this->actions->addAction($action);
149 $this->
setFormAction($this->ctrl->getFormAction($this->parent_obj));
170 return $this->
txt(
"add_item");
185 return $this->
txt(
"delete",
false);
196 $this->multi_item_actions->addAction($action);
202 $this->
addMultiItemSelectionButton(
"index_table_multi_action", $this->multi_item_actions->getActionsAsKeyTextArray(),
"multiAction", $this->
txt(
'execute',
false));
214 return $this->
getFields()->getSelectableColumns($this);
221 protected function initTableFilter() {
232 if ($field->getHasFilter()) {
267 protected function addFilterItemToForm(
ilFormPropertyGUI $item, $optional =
false) {
273 $this->filter_array[$item->
getPostVar()] = $item->getValue();
287 $this->
setRowTemplate(
'tpl.record_row.html',
'./Services/ActiveRecord/');
294 protected function initTableColumns() {
302 if ($field->getSortable()) {
303 $this->
addColumn($this->
txt($field->getTxt()), $field->getName());
332 protected function initTableData() {
333 $this->active_record_list->getArWhereCollection()->setStatements(NULL);
334 $this->active_record_list->getArJoinCollection()->setStatements(NULL);
335 $this->active_record_list->getArLimitCollection()->setStatements(NULL);
336 $this->active_record_list->getArOrderCollection()->setStatements(NULL);
338 $this->filterTableData();
341 $ar_data = $this->active_record_list->getArray();
344 foreach ($ar_data as $key => $item) {
346 foreach ($this->
getFields()->getFieldsForDisplay() as $field) {
350 if (array_key_exists($field->getName(), $item)) {
351 if (!$item[$field->getName()]) {
353 } elseif ($field->getIsCreatedByField()) {
355 } elseif ($field->getIsModifiedByField()) {
358 $data[$key][$field->getName()] = $this->
setArFieldData($field, $item, $item[$field->getName()]);
369 protected function filterTableData() {
376 $this->
addFilterWhere($filter, $filter->getPostVar(), $filter->getValue());
389 switch (get_class($filter)) {
390 case 'ilTextInputGUI':
394 case 'ilCombinationInputGUI':
395 if (is_object($value[
"from"]) || is_object($value[
"to"])) {
396 if (get_class($value[
"from"]) ==
"ilDateTime" || get_class($value[
"to"]) ==
"ilDateTime") {
401 if (get_class($value[
"from"]) ==
"ilDate" || get_class($value[
"to"]) ==
"ilDate") {
428 if ($value[
"from"] !=
"" OR $value[
"to"] !=
"") {
429 if ($value[
"from"] ==
"") {
432 if ($value[
"to"] ==
"") {
433 $value[
"to"] = PHP_INT_MAX;
435 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" >= " . $value[
"from"]
436 .
" AND " . $this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" <= " . $value[
"to"]);
447 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" like '%" . $value .
"%'");
457 if ($value[
"from"] != NULL OR $value[
"to"] != NULL) {
458 if ($value[
"from"] == NULL) {
461 if ($value[
"to"] == NULL) {
464 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" BETWEEN '" 476 if ($value[
"from"] != NULL OR $value[
"to"] != NULL) {
477 if ($value[
"from"] == NULL) {
480 if ($value[
"to"] == NULL) {
483 $this->active_record_list->where($this->active_record_list->getAR()->getConnectorContainerName() .
"." . $name .
" BETWEEN '" 501 $this->
setDefaultOrderField($this->active_record_list->getAR()->getArFieldList()->getPrimaryField()->getName());
505 $this->
setMaxCount($this->active_record_list->count());
532 return $user->getPublicName();
546 return $user->getPublicName();
595 return "CUSTOM-OVERRIDE: setCustomFieldData";
609 $this->addActionsToRow($a_set);
617 $this->ctrl->setParameterByClass(get_class($this->parent_obj),
'ar_id', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()
627 $this->tpl->setVariable(
'ID', self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
636 foreach ($a_set as $key => $value) {
650 $this->tpl->setCurrentBlock(
'entry');
651 $this->tpl->setVariable(
'ENTRY_CONTENT', $value);
652 $this->tpl->parseCurrentBlock(
'entry');
659 protected function addActionsToRow($a_set) {
662 $alist->setId(self::domid_encode($a_set[$this->
getFields()->getPrimaryField()->getName()]));
663 $alist->setListTitle($this->
txt(
'actions',
false));
670 if ($action->getAccess()) {
671 $access = $this->access->checkAccess($action->getAccess(),
'',
$_GET[
'ref_id']);
674 $alist->addItem($action->getTitle(), $action->getId(), $this->ctrl->getLinkTargetByClass($action->getTargetClass(), $action->getTargetCmd()));
678 $this->tpl->setVariable(
'ACTION', $alist->getHTML());
688 $index_table_tpl =
new ilTemplate(
"tpl.index_table.html",
true,
true,
"./Services/ActiveRecord/");
693 $index_table_tpl->setVariable(
"TABLE", parent::render());
695 return $index_table_tpl->get();
705 public function txt(
$txt, $plugin_txt =
true) {
706 return $this->parent_obj->txt(
$txt, $plugin_txt);
713 $this->initTableData();
718 parent::resetFilter();
720 $this->initTableData();
733 if (!empty($id_to_encode)) {
734 $encoded_id = preg_replace_callback(
'/([^a-zA-Z0-9])/',
function ($matches) {
735 return "__idstart_" . strtolower(dechex(ord($matches[0]))) .
"_idend__";
751 if (!empty($id_to_decode)) {
752 $decoded_id = preg_replace_callback(
'/__idstart_(.{2})_idend__/',
function ($matches) {
753 return chr(hexdec($matches[1]));
791 return $this->
getFields()->getField($field_name);
855 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)
addFilterItemByMetaType($id, $type=self::FILTER_TEXT, $a_optional=false, $caption=NULL)
Add filter by standard type.
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.
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)
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)
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
addFilterDateWhere(ilCombinationInputGUI $filter, $name, $value)
static formatDate(ilDateTime $date)
Format a date public.
__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.
Create styles array
The data for the language used.
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.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
initAfterParentConstructor()
setSelectAllCheckbox($a_select_all_checkbox)
Set the name of the checkbox that should be toggled with a select all button.
setMaxCount($a_max_count)
set max.
getFilterItems($a_optionals=false)
Get filter items.
getSelectableColumns()
Get selectable columns.
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.
addFilterNumericWhere(ilCombinationInputGUI $filter, $name, $value)
GUI-Class arIndexTableAction.
setFilterCommand($a_val, $a_caption=null)
Set filter command.