93 protected string $id =
"";
124 ?
object $a_parent_obj,
125 string $a_parent_cmd =
"",
126 string $a_template_context =
""
129 $this->main_tpl =
$DIC->ui()->mainTemplate();
131 $this->
lng = $DIC->language();
132 $this->
ctrl = $DIC->ctrl();
135 if (isset(
$DIC[
"http"])) {
136 $this->table_request = new \ILIAS\Table\TableGUIRequest(
143 $this->unique_id = md5(uniqid(
'',
true));
144 $this->parent_obj = $a_parent_obj;
145 $this->parent_cmd = $a_parent_cmd;
146 $this->buttons = array();
147 $this->header_commands = array();
148 $this->multi = array();
149 $this->hidden_inputs = array();
151 $this->tpl =
new ilTemplate(
"tpl.table2.html",
true,
true,
"Services/Table");
155 if (!$a_template_context) {
156 $a_template_context = $this->
getId();
161 if (isset($this->table_request)) {
162 $this->export_mode = $this->table_request->getExportMode($this->prefix);
165 if ($this->table_request->getTemplate($this->prefix) !=
"") {
166 $this->
restoreTemplate($this->table_request->getTemplate($this->prefix));
175 $this->raw_post_data = [];
176 if (isset(
$DIC[
"http"])) {
177 $this->raw_post_data =
$DIC->http()->request()->getParsedBody();
183 if (is_null($this->table_request)) {
186 $this->requested_nav_par = $this->table_request->getNavPar($this->
getNavParameter());
187 $this->requested_nav_par1 = $this->table_request->getNavPar($this->
getNavParameter(), 1);
188 $this->requested_nav_par2 = $this->table_request->getNavPar($this->
getNavParameter(), 2);
189 $this->requested_tmpl_create = $this->table_request->getTemplCreate();
190 $this->requested_tmpl_delete = $this->table_request->getTemplDelete();
195 $this->open_form_tag = $a_val;
205 $this->close_form_tag = $a_val;
218 if (isset(
$DIC[
"ilUser"])) {
222 if ($this->limit_determined) {
227 if (isset($this->table_request) && !is_null($this->table_request->getRows($this->prefix))) {
228 $this->
storeProperty(
"rows", $this->table_request->getRows($this->prefix));
229 $limit = $this->table_request->getRows($this->prefix) ?? 0;
247 $this->limit_determined =
true;
261 if ($this->columns_determined) {
268 if ($old_sel !=
"") {
269 $sel_fields = unserialize($old_sel);
272 if (!is_array($sel_fields)) {
274 $sel_fields = array();
277 $this->selected_columns = array();
282 if (isset($this->table_request)) {
283 $fs = $this->table_request->getFS($this->
getId());
284 $fsh = $this->table_request->getFSH($this->
getId());
288 $this->selected_column[$k] =
false;
290 $new_column = (!isset($sel_fields[$k]));
294 if (in_array($k, $fs)) {
295 $this->selected_column[$k] =
true;
297 } elseif ($stored && !$new_column) {
298 $this->selected_column[$k] = $sel_fields[$k];
303 if (isset(
$c[
"default"]) &&
$c[
"default"]) {
304 $this->selected_column[$k] =
true;
310 if (isset($this->table_request)) {
311 $ff = $this->table_request->getFF($this->
getId());
313 if (count($ff) > 0) {
315 if (in_array($k, $ff)) {
316 $this->selected_column[$k] =
true;
321 if ($old_sel != serialize($this->selected_column) && $set) {
322 $this->
storeProperty(
"selfields", serialize($this->selected_column));
325 $this->columns_determined =
true;
330 return $this->selected_column[$col] ??
false;
336 foreach ($this->selected_column as $k => $v) {
344 public function executeCommand(): bool
350 switch ($next_class) {
351 case 'ilformpropertydispatchgui':
356 $this->table_request->getPostVar()
358 $form_prop_dispatch->setItem($item);
359 return (
bool) $ilCtrl->forwardCommand($form_prop_dispatch);
364 public function resetOffset(
bool $a_in_determination =
false): void
366 if (!$this->nav_determined && !$a_in_determination) {
390 $this->top_anchor = $a_val;
400 $this->noentriestext = $a_text;
410 $this->datatable = $a_val;
420 $this->enabled[
"title"] = $a_enabletitle;
425 return $this->enabled[
"title"];
430 $this->enabled[
"header"] = $a_enableheader;
435 return $this->enabled[
"header"];
440 $this->num_info = $a_val;
451 string $a_icon_alt =
""
453 parent::
setTitle($a_title, $a_icon, $a_icon_alt);
458 $this->description = $a_val;
463 return $this->description;
468 $this->order_field = $a_order_field;
473 return $this->order_field;
476 final public function setData(array $a_data): void
478 $this->row_data = $a_data;
483 return $this->row_data;
488 return count($this->row_data) > 0;
493 $this->prefix = $a_prefix;
494 $this->getRequestedValues();
499 return $this->prefix;
504 bool $a_optional =
false
506 $a_input_item->setParentTable($this);
508 $this->filters[] = $a_input_item;
510 $this->optional_filters[] = $a_input_item;
514 if ($this->restore_filter) {
515 if (array_key_exists($a_input_item->getFieldId(), $this->restore_filter_values ?? [])) {
516 $this->setFilterValue($a_input_item, $this->restore_filter_values[$a_input_item->getFieldId()]);
518 $this->setFilterValue($a_input_item,
null);
529 int $type = self::FILTER_TEXT,
530 bool $a_optional =
false,
542 case self::FILTER_CHECKBOX:
546 case self::FILTER_SELECT:
550 case self::FILTER_DATE:
554 case self::FILTER_TEXT:
556 $item->setMaxLength(64);
561 case self::FILTER_LANGUAGE:
562 $lng->loadLanguageModule(
"meta");
564 $options = array(
"" =>
$lng->txt(
"trac_all"));
565 foreach (
$lng->getInstalledLanguages() as $lang_key) {
566 $options[$lang_key] =
$lng->txt(
"meta_l_" . $lang_key);
568 $item->setOptions($options);
571 case self::FILTER_NUMBER_RANGE:
574 $combi_item->setSize(5);
575 $item->addCombinationItem(
"from", $combi_item,
$lng->txt(
"from"));
577 $combi_item->setSize(5);
578 $item->addCombinationItem(
"to", $combi_item,
$lng->txt(
"to"));
584 case self::FILTER_DATE_RANGE:
587 $item->addCombinationItem(
"from", $combi_item,
$lng->txt(
"from"));
589 $item->addCombinationItem(
"to", $combi_item,
$lng->txt(
"to"));
593 case self::FILTER_DATETIME_RANGE:
596 $combi_item->setShowTime(
true);
597 $item->addCombinationItem(
"from", $combi_item,
$lng->txt(
"from"));
599 $combi_item->setShowTime(
true);
600 $item->addCombinationItem(
"to", $combi_item,
$lng->txt(
"to"));
604 case self::FILTER_DURATION_RANGE:
605 $lng->loadLanguageModule(
"form");
608 $combi_item->setShowMonths(
false);
609 $combi_item->setShowDays(
true);
610 $combi_item->setShowSeconds(
true);
611 $item->addCombinationItem(
"from", $combi_item,
$lng->txt(
"from"));
613 $combi_item->setShowMonths(
false);
614 $combi_item->setShowDays(
true);
615 $combi_item->setShowSeconds(
true);
616 $item->addCombinationItem(
"to", $combi_item,
$lng->txt(
"to"));
624 $this->addFilterItem($item, $a_optional);
625 $item->readFromSession();
632 return $this->filters;
634 return $this->optional_filters;
639 foreach ($this->getFilterItems() as $item) {
640 if ($item->getPostVar() == $a_post_var) {
644 foreach ($this->getFilterItems(
true) as $item) {
645 if ($item->getPostVar() == $a_post_var) {
654 $this->filter_cols = $a_val;
659 return $this->filter_cols;
664 $this->disable_filter_hiding = $a_val;
669 return $this->disable_filter_hiding;
677 return (
bool) $this->selected_filter[$a_col];
683 foreach ($this->selected_filter as $k => $v) {
693 if ($this->filters_determined) {
697 $old_sel = $this->loadProperty(
"selfilters");
700 if ($old_sel !=
"") {
702 unserialize($old_sel);
705 if (!is_array($sel_filters)) {
707 $sel_filters = array();
710 $this->selected_filter = array();
712 foreach ($this->getFilterItems(
true) as $item) {
713 $k = $item->getPostVar();
715 $this->selected_filter[$k] =
false;
717 if ($this->table_request->getFSF($this->getId())) {
719 if (in_array($k, $this->table_request->getFF($this->getId()))) {
720 $this->selected_filter[$k] =
true;
722 $item->setValue(
null);
723 $item->writeToSession();
726 $this->selected_filter[$k] = $sel_filters[$k] ??
"";
730 if ($old_sel != serialize($this->selected_filter) && $set) {
731 $this->storeProperty(
"selfilters", serialize($this->selected_filter));
734 $this->filters_determined =
true;
741 $this->custom_prev_next =
true;
742 $this->custom_prev = $a_prev_link;
743 $this->custom_next = $a_next_link;
747 string $a_form_action,
748 bool $a_multipart =
false
750 $this->form_action = $a_form_action;
751 $this->form_multipart = $a_multipart;
756 return $this->form_action;
761 $this->formname = $a_name;
766 return $this->formname;
769 public function setId(
string $a_val): void
772 if ($this->getPrefix() ==
"") {
773 $this->setPrefix($a_val);
775 if (strlen($this->
id) > 30) {
776 throw new ilException(
"Table ID to long (max. 30 char): " . $this->
id);
787 $this->display_as_block = $a_val;
792 return $this->display_as_block;
796 string $a_select_all_checkbox,
797 bool $a_select_all_on_top =
false
799 $this->select_all_checkbox = $a_select_all_checkbox;
800 $this->select_all_on_top = $a_select_all_on_top;
805 $this->ext_sort = $a_val;
810 return $this->ext_sort;
815 string $a_caption =
""
817 $this->filter_cmd = $a_val;
818 $this->filter_cmd_txt = $a_caption;
823 return $this->filter_cmd;
828 string $a_caption =
""
830 $this->reset_cmd = $a_val;
831 $this->reset_cmd_txt = $a_caption;
836 return $this->reset_cmd;
841 $this->ext_seg = $a_val;
846 return $this->ext_seg;
854 final public function setRowTemplate(
string $a_template,
string $a_template_dir =
""): void
856 $this->row_template = $a_template;
857 $this->row_template_dir = $a_template_dir;
862 $this->defaultorderfield = $a_defaultorderfield;
867 return $this->defaultorderfield;
873 $this->defaultorderdirection = $a_defaultorderdirection;
878 return $this->defaultorderdirection;
883 $this->default_filter_visibility = $a_status;
888 return $this->default_filter_visibility;
893 $this->buttons = array();
899 string $a_onclick =
'',
903 $this->buttons[] = array(
"cmd" => $a_cmd,
"text" => $a_text,
'onclick' => $a_onclick,
904 "id" => $a_id,
"class" => $a_class);
909 $this->buttons[] = $a_button;
925 string $a_default_selection =
''
927 $this->mi_sel_buttons[] = array(
"sel_var" => $a_sel_var,
"options" => $a_options,
"selected" => $a_default_selection,
"cmd" => $a_cmd,
"text" => $a_text);
928 $this->addHiddenInput(
"cmd_sv[" . $a_cmd .
"]", $a_sel_var);
933 $this->close_command = $a_link;
938 $this->multi[] = array(
"cmd" => $a_cmd,
"text" => $a_text);
943 $this->hidden_inputs[] = array(
"name" => $a_name,
"value" => $a_value);
949 string $a_target =
"",
952 $this->header_commands[] = array(
"href" => $a_href,
"text" => $a_text,
953 "target" => $a_target,
"img" => $a_img);
958 $this->top_commands = $a_val;
963 return $this->top_commands;
968 string $a_sort_field =
"",
969 string $a_width =
"",
970 bool $a_is_checkbox_action_column =
false,
971 string $a_class =
"",
972 string $a_tooltip =
"",
973 bool $a_tooltip_with_html =
false
975 $this->column[] = array(
977 "sort_field" => $a_sort_field,
979 "is_checkbox_action_column" => $a_is_checkbox_action_column,
981 "tooltip" => $a_tooltip,
982 "tooltip_html" => $a_tooltip_with_html
984 if ($a_sort_field !=
"") {
985 $this->sortable_fields[] = $a_sort_field;
987 $this->column_count = count($this->column);
993 return $this->prefix .
"_table_nav";
1002 $ilCtrl = $this->ctrl;
1006 $old = $this->requested_nav_par ??
'';
1009 $ilCtrl->setParameter(
1011 $this->getNavParameter(),
1012 urlencode(
$key) .
":" . $order_dir .
":" . $this->offset
1014 $this->tpl->setVariable(
1016 $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd) . $hash
1020 $ilCtrl->setParameter(
1022 $this->getNavParameter(),
1031 $allcolumnswithwidth =
true;
1032 foreach ($this->column as $idx => $column) {
1033 if (!strlen($column[
"width"])) {
1034 $allcolumnswithwidth =
false;
1035 } elseif ($column[
"width"] ==
"1") {
1037 $this->column[$idx][
"width"] =
"1%";
1040 if ($allcolumnswithwidth) {
1041 foreach ($this->column as $column) {
1042 $this->tpl->setCurrentBlock(
"tbl_colgroup_column");
1043 $width = (is_numeric($column[
"width"]))
1044 ? $column[
"width"] .
"px"
1046 $this->tpl->setVariable(
"COLGROUP_COLUMN_WIDTH",
" style=\"width:" . $width .
"\"");
1047 $this->tpl->parseCurrentBlock();
1051 foreach ($this->column as $column) {
1054 if ($column[
"tooltip"] !=
"") {
1056 "thc_" . $this->
getId() .
"_" . $ccnt,
1061 !$column[
"tooltip_html"]
1065 if ($column[
'is_checkbox_action_column'] && $this->select_all_on_top) {
1066 $this->tpl->setCurrentBlock(
'tbl_header_top_select_all');
1067 $this->tpl->setVariable(
"HEAD_SELECT_ALL_TXT_SELECT_ALL",
$lng->txt(
"select_all"));
1068 $this->tpl->setVariable(
"HEAD_SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1069 $this->tpl->setVariable(
"HEAD_SELECT_ALL_FORM_NAME", $this->getFormName());
1070 $this->tpl->setVariable(
"HEAD_CHECKBOXNAME",
"chb_select_all_" . $this->unique_id .
'_top');
1071 $this->tpl->parseCurrentBlock();
1075 if ($column[
'is_checkbox_action_column'] && !$this->select_all_on_top) {
1076 $this->tpl->setCurrentBlock(
'tbl_header_top_select_column');
1077 if ($column[
"width"] !=
"") {
1078 $width = (is_numeric($column[
"width"]))
1079 ? $column[
"width"] .
"px"
1081 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" style=\"width:" . $width .
"\"");
1083 $this->tpl->parseCurrentBlock();
1088 !$this->enabled[
"sort"] ||
1089 (($column[
"sort_field"] ==
"") &&
1090 !($column[
"is_checkbox_action_column"] && $this->select_all_on_top))
1092 $this->tpl->setCurrentBlock(
"tbl_header_no_link");
1093 if ($column[
"width"] !=
"") {
1094 $width = (is_numeric($column[
"width"]))
1095 ? $column[
"width"] .
"px"
1097 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH_NO_LINK",
" style=\"width:" . $width .
"\"");
1099 if ($column[
"class"] !=
"") {
1100 $this->tpl->setVariable(
"TBL_COLUMN_CLASS_NO_LINK",
" class=\"" . $column[
"class"] .
"\"");
1102 if (!$column[
"is_checkbox_action_column"]) {
1103 $this->tpl->setVariable(
1104 "TBL_HEADER_CELL_NO_LINK",
1108 $this->tpl->setVariable(
1109 "TBL_HEADER_CELL_NO_LINK",
1113 $this->tpl->setVariable(
"HEAD_CELL_NL_ID",
"thc_" . $this->
getId() .
"_" . $ccnt);
1114 if ($column[
"class"] !=
"") {
1115 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1117 $this->tpl->parseCurrentBlock();
1118 $this->tpl->touchBlock(
"tbl_header_th");
1121 if (($column[
"sort_field"] == $this->order_field) && ($this->order_direction !=
"")) {
1122 $this->tpl->setCurrentBlock(
"tbl_order_image");
1123 if ($this->order_direction ===
"asc") {
1124 $this->tpl->setVariable(
"ORDER_CLASS",
"glyphicon glyphicon-arrow-up");
1125 $this->tpl->setVariable(
"ORDER_TXT", $this->
lng->txt(
"sorting_asc"));
1127 $this->tpl->setVariable(
"ORDER_CLASS",
"glyphicon glyphicon-arrow-down");
1128 $this->tpl->setVariable(
"ORDER_TXT", $this->
lng->txt(
"sorting_desc"));
1130 $this->tpl->setVariable(
"IMG_ORDER_ALT", $this->
lng->txt(
"change_sort_direction"));
1131 $this->tpl->parseCurrentBlock();
1134 $this->tpl->setCurrentBlock(
"tbl_header_cell");
1135 $this->tpl->setVariable(
"TBL_HEADER_CELL", $column[
"text"]);
1136 $this->tpl->setVariable(
"HEAD_CELL_ID",
"thc_" . $this->
getId() .
"_" . $ccnt);
1139 if ($column[
"width"] !=
"") {
1140 $width = (is_numeric($column[
"width"]))
1141 ? $column[
"width"] .
"px"
1143 $this->tpl->setVariable(
"TBL_COLUMN_WIDTH",
" style=\"width:" . $width .
"\"");
1145 if ($column[
"class"] !=
"") {
1146 $this->tpl->setVariable(
"TBL_COLUMN_CLASS",
" class=\"" . $column[
"class"] .
"\"");
1149 $lng_sort_column = $this->
lng->txt(
"sort_by_this_column");
1150 $this->tpl->setVariable(
"TBL_ORDER_ALT", $lng_sort_column);
1154 if ($column[
"sort_field"] == $this->order_field) {
1155 $order_dir = $this->sort_order;
1157 if ($order_dir ===
"asc") {
1158 $lng_change_sort = $this->
lng->txt(
"sort_ascending_long");
1160 $lng_change_sort = $this->
lng->txt(
"sort_descending_long");
1162 $this->tpl->setVariable(
"TBL_ORDER_ALT", $lng_change_sort);
1165 if ($column[
"class"] !=
"") {
1166 $this->tpl->setVariable(
"TBL_HEADER_CLASS",
" " . $column[
"class"]);
1168 $this->setOrderLink($column[
"sort_field"], $order_dir);
1169 $this->tpl->parseCurrentBlock();
1170 $this->tpl->touchBlock(
"tbl_header_th");
1173 $this->tpl->setCurrentBlock(
"tbl_header");
1174 $this->tpl->parseCurrentBlock();
1189 if (isset(
$DIC[
"ilUser"])) {
1193 if ($this->nav_determined) {
1197 if ($this->requested_nav_par1 !=
"") {
1198 if ($this->requested_nav_par1 != ($this->requested_nav_par ??
"")) {
1199 $this->nav_value = $this->requested_nav_par1;
1201 $this->requested_nav_par2 !=
"" &&
1202 $this->requested_nav_par2 != $this->requested_nav_par
1204 $this->nav_value = $this->requested_nav_par2;
1206 } elseif ($this->requested_nav_par !=
"") {
1207 $this->nav_value = $this->requested_nav_par;
1211 $order = $this->loadProperty(
"order");
1212 if (in_array($order, $this->sortable_fields)) {
1213 $direction = $this->loadProperty(
"direction");
1215 $direction = $this->getDefaultOrderDirection();
1221 $this->loadProperty(
"offset");
1223 $nav = explode(
":", $this->nav_value);
1226 $req_order_field = $nav[0] ??
"";
1227 $req_order_dir = $nav[1] ??
"";
1228 $req_offset = (
int) ($nav[2] ?? 0);
1229 $this->setOrderField(($req_order_field !=
"") ? $req_order_field : $this->getDefaultOrderField());
1230 $this->setOrderDirection(($req_order_dir !=
"") ? $req_order_dir : $this->getDefaultOrderDirection());
1232 if (!$a_omit_offset) {
1234 if (!$this->getExternalSegmentation() && $this->limit_determined && $this->limit == 9999) {
1235 $this->resetOffset(
true);
1236 } elseif (!$this->getExternalSegmentation() && $req_offset >= $this->max_count) {
1237 $this->resetOffset(
true);
1239 $this->setOffset($req_offset);
1243 if (!$a_omit_offset) {
1244 $this->nav_determined =
true;
1250 if ($this->getOrderField() !=
"") {
1251 $this->storeProperty(
"order", $this->getOrderField());
1253 if ($this->getOrderDirection() !=
"") {
1254 $this->storeProperty(
"direction", $this->getOrderDirection());
1256 if ($this->getOffset() >= 0) {
1257 $this->storeProperty(
"offset", (
string) $this->getOffset());
1270 if (isset(
$DIC[
"ilUser"])) {
1275 $ilCtrl = $this->ctrl;
1278 if ($this->getExportMode() > 0) {
1279 $this->exportData($this->getExportMode(),
true);
1282 $this->prepareOutput();
1284 if (is_object($ilCtrl) && is_object($this->getParentObject()) && $this->
getId() ==
"") {
1285 $ilCtrl->saveParameter($this->getParentObject(), $this->getNavParameter());
1288 if (!$this->getPrintMode()) {
1290 if ($this->form_action !=
"" && $this->getOpenFormTag()) {
1293 if ($this->form_multipart) {
1294 $this->tpl->touchBlock(
"form_multipart_bl");
1297 if ($this->getPreventDoubleSubmission()) {
1298 $this->tpl->touchBlock(
"pdfs");
1301 $this->tpl->setCurrentBlock(
"tbl_form_header");
1302 $this->tpl->setVariable(
"FORMACTION", $this->getFormAction() . $hash);
1303 $this->tpl->setVariable(
"FORMNAME", $this->getFormName());
1304 $this->tpl->parseCurrentBlock();
1307 if ($this->form_action !=
"" && $this->getCloseFormTag()) {
1308 $this->tpl->touchBlock(
"tbl_form_footer");
1312 if (!$this->enabled[
'content']) {
1313 return $this->render();
1316 if (!$this->getExternalSegmentation()) {
1317 $this->setMaxCount(count($this->row_data));
1320 $this->determineOffsetAndOrder();
1322 $this->setFooter(
"tblfooter", $this->
lng->txt(
"previous"), $this->lng->txt(
"next"));
1324 $data = $this->getData();
1325 if ($this->dataExists()) {
1327 if (!$this->getExternalSorting() && $this->enabled[
"sort"]) {
1330 $this->getOrderField(),
1331 $this->getOrderDirection(),
1332 $this->numericOrdering($this->getOrderField())
1337 if (!$this->getExternalSegmentation()) {
1338 $data = array_slice(
$data, $this->getOffset(), $this->getLimit());
1343 if ($this->dataExists()) {
1344 if ($this->getPrintMode()) {
1348 $this->tpl->addBlockFile(
1351 $this->row_template,
1352 $this->row_template_dir
1355 foreach (
$data as $set) {
1356 $this->tpl->setCurrentBlock(
"tbl_content");
1357 $this->css_row = ($this->css_row !==
"tblrow1")
1360 $this->tpl->setVariable(
"CSS_ROW", $this->css_row);
1362 $this->fillRow($set);
1363 $this->tpl->setCurrentBlock(
"tbl_content");
1364 $this->tpl->parseCurrentBlock();
1368 $no_items_text = (trim($this->getNoEntriesText()) !=
'')
1369 ? $this->getNoEntriesText()
1370 :
$lng->txt(
"no_items");
1372 $this->css_row = ($this->css_row !==
"tblrow1")
1376 $this->tpl->setCurrentBlock(
"tbl_no_entries");
1377 $this->tpl->setVariable(
'TBL_NO_ENTRY_CSS_ROW', $this->css_row);
1378 $this->tpl->setVariable(
'TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count);
1379 $this->tpl->setVariable(
'TBL_NO_ENTRY_TEXT', trim($no_items_text));
1380 $this->tpl->parseCurrentBlock();
1384 if (!$this->getPrintMode()) {
1385 $this->fillFooter();
1387 $this->fillHiddenRow();
1389 $this->fillActionRow();
1391 $this->storeNavParameter();
1394 return $this->render();
1409 $this->tpl->setVariable(
"CSS_TABLE", $this->getStyle(
"table"));
1410 if ($this->
getId() !=
"") {
1411 $this->tpl->setVariable(
"ID",
'id="' . $this->
getId() .
'"');
1415 if ($this->getDescription() !=
"") {
1416 $this->tpl->setCurrentBlock(
"tbl_header_description");
1417 $this->tpl->setVariable(
"TBL_DESCRIPTION", $this->getDescription());
1418 $this->tpl->parseCurrentBlock();
1421 if (!$this->getPrintMode()) {
1422 $this->renderFilter();
1425 if ($this->getDisplayAsBlock()) {
1426 $this->tpl->touchBlock(
"outer_start_1");
1427 $this->tpl->touchBlock(
"outer_end_1");
1429 $this->tpl->touchBlock(
"outer_start_2");
1430 $this->tpl->touchBlock(
"outer_end_2");
1434 if ($this->enabled[
"title"] && ($this->title !=
""
1435 || $this->icon !=
"" || count($this->header_commands) > 0 ||
1436 $this->headerHTML !=
"" || $this->close_command !=
"")) {
1437 if ($this->enabled[
"icon"]) {
1438 $this->tpl->setCurrentBlock(
"tbl_header_title_icon");
1440 $this->tpl->setVariable(
"TBL_TITLE_IMG_ALT", $this->icon_alt);
1441 $this->tpl->parseCurrentBlock();
1444 if (!$this->getPrintMode()) {
1445 foreach ($this->header_commands as $command) {
1446 if ($command[
"img"] !=
"") {
1447 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1448 if ($command[
"target"] !=
"") {
1449 $this->tpl->setVariable(
1451 'target="' . $command[
"target"] .
'"'
1454 $this->tpl->setVariable(
"ALT_IMG_LINK", $command[
"text"]);
1455 $this->tpl->setVariable(
"HREF_IMG_LINK", $command[
"href"]);
1456 $this->tpl->setVariable(
1461 $this->tpl->setCurrentBlock(
"head_cmd");
1462 $this->tpl->setVariable(
"TXT_HEAD_CMD", $command[
"text"]);
1463 $this->tpl->setVariable(
"HREF_HEAD_CMD", $command[
"href"]);
1465 $this->tpl->parseCurrentBlock();
1469 if (isset($this->headerHTML)) {
1470 $this->tpl->setCurrentBlock(
"tbl_header_html");
1471 $this->tpl->setVariable(
"HEADER_HTML", $this->headerHTML);
1472 $this->tpl->parseCurrentBlock();
1476 if ($this->close_command !=
"") {
1477 $this->tpl->setCurrentBlock(
"tbl_header_img_link");
1478 $this->tpl->setVariable(
"ALT_IMG_LINK",
$lng->txt(
"close"));
1479 $this->tpl->setVariable(
"HREF_IMG_LINK", $this->close_command);
1480 $this->tpl->parseCurrentBlock();
1483 $this->tpl->setCurrentBlock(
"tbl_header_title");
1484 $this->tpl->setVariable(
"TBL_TITLE", $this->title);
1485 if ($this->getDisplayAsBlock()) {
1486 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
1488 $this->tpl->parseCurrentBlock();
1492 if ($this->enabled[
"header"]) {
1493 $this->fillHeader();
1496 $this->tpl->touchBlock(
"tbl_table_end");
1498 return $this->tpl->get();
1509 $main_tpl =
$DIC[
"tpl"];
1511 $filter = $this->getFilterItems();
1512 $opt_filter = $this->getFilterItems(
true);
1514 $main_tpl->addJavascript(
"./Services/Table/js/ServiceTable.js");
1516 if (count($filter) == 0 && count($opt_filter) == 0) {
1525 if (count($filter) > 0) {
1526 foreach ($filter as $item) {
1527 if ($ccnt >= $this->getFilterCols()) {
1528 $this->tpl->setCurrentBlock(
"filter_row");
1529 $this->tpl->parseCurrentBlock();
1532 $this->tpl->setCurrentBlock(
"filter_item");
1533 $this->tpl->setVariable(
1537 $this->tpl->setVariable(
1539 $item->getTableFilterLabelFor()
1541 $this->tpl->setVariable(
1543 $item->getTableFilterHTML()
1545 $this->tpl->parseCurrentBlock();
1551 if (count($opt_filter) > 0) {
1552 $this->determineSelectedFilters();
1554 foreach ($opt_filter as $item) {
1555 if ($this->isFilterSelected($item->getPostVar())) {
1556 if ($ccnt >= $this->getFilterCols()) {
1557 $this->tpl->setCurrentBlock(
"filter_row");
1558 $this->tpl->parseCurrentBlock();
1561 $this->tpl->setCurrentBlock(
"filter_item");
1562 $this->tpl->setVariable(
1566 $this->tpl->setVariable(
1570 $this->tpl->setVariable(
1572 $item->getTableFilterHTML()
1574 $this->tpl->parseCurrentBlock();
1581 foreach ($opt_filter as $item) {
1582 $k = $item->getPostVar();
1583 $items[$k] = array(
"txt" => $item->getTitle(),
1584 "selected" => $this->isFilterSelected($k));
1588 $cb_over->setLinkTitle(
$lng->txt(
"optional_filters"));
1589 $cb_over->setItems($items);
1591 $cb_over->setFormCmd($this->getParentCmd());
1592 $cb_over->setFieldVar(
"tblff" . $this->
getId());
1593 $cb_over->setHiddenVar(
"tblfsf" . $this->
getId());
1595 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
1596 $this->tpl->setCurrentBlock(
"filter_select");
1599 $this->tpl->setVariable(
"HIDDEN_CMD_APPLY", $this->filter_cmd);
1601 $this->tpl->setVariable(
"FILTER_SELECTOR", $cb_over->getHTML(
false));
1602 $this->tpl->parseCurrentBlock();
1606 if ($ccnt > 0 || count($opt_filter) > 0) {
1607 $this->tpl->setVariable(
"TXT_FILTER",
$lng->txt(
"filter"));
1610 if ($ccnt < $this->getFilterCols()) {
1611 for (
$i = $ccnt;
$i <= $this->getFilterCols();
$i++) {
1612 $this->tpl->touchBlock(
"filter_empty_cell");
1615 $this->tpl->setCurrentBlock(
"filter_row");
1616 $this->tpl->parseCurrentBlock();
1618 $this->tpl->setCurrentBlock(
"filter_buttons");
1619 $this->tpl->setVariable(
"CMD_APPLY", $this->filter_cmd);
1620 $this->tpl->setVariable(
"TXT_APPLY", $this->filter_cmd_txt
1621 ?:
$lng->txt(
"apply_filter"));
1622 $this->tpl->setVariable(
"CMD_RESET", $this->reset_cmd);
1623 $this->tpl->setVariable(
"TXT_RESET", $this->reset_cmd_txt
1624 ?:
$lng->txt(
"reset_filter"));
1625 } elseif (count($opt_filter) > 0) {
1626 $this->tpl->setCurrentBlock(
"optional_filter_hint");
1627 $this->tpl->setVariable(
'TXT_OPT_HINT',
$lng->txt(
'optional_filter_hint'));
1628 $this->tpl->parseCurrentBlock();
1631 $this->tpl->setCurrentBlock(
"filter_section");
1632 $this->tpl->setVariable(
"FIL_ID", $this->
getId());
1633 $this->tpl->parseCurrentBlock();
1636 if (!$this->isFilterVisible() && !$this->getDisableFilterHiding()) {
1638 $this->main_tpl->addOnLoadCode(
"
1639 ilTableHideFilter['atfil_$id'] = true;
1640 ilTableHideFilter['tfil_$id'] = true;
1641 ilTableHideFilter['dtfil_$id'] = true;
1648 $this->main_tpl->addOnLoadCode(
"ilInitTableFilters()");
1657 $prop = $this->loadProperty(
'filter');
1658 if ($prop ===
'0' || $prop ===
'1') {
1659 return (
bool) $prop;
1661 return $this->getDefaultFilterVisibility();
1671 foreach ($a_gui->getFilterElements(false) as $item) {
1672 if ($item === $a_element) {
1681 $advmd_record_gui =
null;
1682 if (method_exists($this,
"getAdvMDRecordGUI")) {
1683 $advmd_record_gui = $this->getAdvMDRecordGUI();
1686 foreach ($this->getFilterItems() as $item) {
1687 if ($advmd_record_gui &&
1688 $this->isAdvMDFilter($advmd_record_gui, $item)) {
1692 if ($item->checkInput()) {
1693 $item->setValueByArray($this->raw_post_data);
1694 $item->writeToSession();
1697 foreach ($this->getFilterItems(
true) as $item) {
1698 if ($advmd_record_gui &&
1699 $this->isAdvMDFilter($advmd_record_gui, $item)) {
1703 if ($item->checkInput()) {
1704 $item->setValueByArray($this->raw_post_data);
1705 $item->writeToSession();
1709 if ($advmd_record_gui) {
1710 $advmd_record_gui->importFilter();
1714 $this->requested_tmpl_create =
"";
1715 $this->requested_tmpl_delete =
"";
1720 $filter = $this->getFilterItems();
1721 $opt_filter = $this->getFilterItems(
true);
1723 foreach ($filter as $item) {
1724 if ($item->checkInput()) {
1726 $item->setValueByArray([]);
1727 $item->clearFromSession();
1730 foreach ($opt_filter as $item) {
1731 if ($item->checkInput()) {
1733 $item->setValueByArray([]);
1734 $item->clearFromSession();
1739 $this->requested_tmpl_create =
"";
1740 $this->requested_tmpl_delete =
"";
1750 foreach ($a_set as
$key => $value) {
1751 $this->tpl->setVariable(
"VAL_" . strtoupper(
$key), $value);
1760 if (isset(
$DIC[
"ilUser"])) {
1765 $ilCtrl = $this->ctrl;
1770 $column_selector =
'';
1773 if ((strlen($this->getFormName())) && (strlen($this->getSelectAllCheckbox())) && $this->dataExists()) {
1774 $this->tpl->setCurrentBlock(
"select_all_checkbox");
1775 $this->tpl->setVariable(
"SELECT_ALL_TXT_SELECT_ALL",
$lng->txt(
"select_all"));
1776 $this->tpl->setVariable(
"SELECT_ALL_CHECKBOX_NAME", $this->getSelectAllCheckbox());
1777 $this->tpl->setVariable(
"SELECT_ALL_FORM_NAME", $this->getFormName());
1778 $this->tpl->setVariable(
"CHECKBOXNAME",
"chb_select_all_" . $this->unique_id);
1779 $this->tpl->parseCurrentBlock();
1783 if ($this->enabled[
"numinfo"] && $this->enabled[
"footer"]) {
1784 $start = $this->offset + 1;
1785 if (!$this->dataExists()) {
1788 $end = $this->offset + $this->limit;
1790 if ($end > $this->max_count or $this->limit == 0) {
1791 $end = $this->max_count;
1794 if ($this->max_count > 0) {
1795 if ($this->lang_support) {
1796 $numinfo =
"(" . $start .
" - " . $end .
" " . strtolower($this->
lng->txt(
"of")) .
" " . $this->max_count .
")";
1798 $numinfo =
"(" . $start .
" - " . $end .
" of " . $this->max_count .
")";
1801 if ($this->max_count > 0) {
1802 if ($this->getEnableNumInfo()) {
1803 $this->tpl->setCurrentBlock(
"tbl_footer_numinfo");
1804 $this->tpl->setVariable(
"NUMINFO", $numinfo);
1805 $this->tpl->parseCurrentBlock();
1812 if ($this->enabled[
"linkbar"] && $this->enabled[
"footer"] && $this->limit != 0
1813 && $this->max_count > 0) {
1814 $linkbar = $this->getLinkbar(
"1");
1815 $this->tpl->setCurrentBlock(
"tbl_footer_linkbar");
1816 $this->tpl->setVariable(
"LINKBAR", $linkbar);
1817 $this->tpl->parseCurrentBlock();
1823 if (is_array($this->getSelectableColumns()) && count($this->getSelectableColumns()) > 0) {
1825 foreach ($this->getSelectableColumns() as $k =>
$c) {
1826 $items[$k] = array(
"txt" =>
$c[
"txt"],
1827 "selected" => $this->isColumnSelected($k));
1830 $cb_over->setLinkTitle(
$lng->txt(
"columns"));
1831 $cb_over->setItems($items);
1834 $cb_over->setFormCmd($this->getParentCmd());
1835 $cb_over->setFieldVar(
"tblfs" . $this->
getId());
1836 $cb_over->setHiddenVar(
"tblfsh" . $this->
getId());
1837 $cb_over->setSelectionHeaderClass(
"ilTableMenuItem");
1838 $column_selector = $cb_over->getHTML();
1842 if ($this->getShowTemplates() && is_object(
$ilUser)) {
1844 if ($this->requested_tmpl_create !=
"") {
1845 if ($this->saveTemplate($this->requested_tmpl_create)) {
1846 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"tbl_template_created"));
1848 } elseif ($this->requested_tmpl_delete !=
"") {
1849 if ($this->deleteTemplate($this->requested_tmpl_delete)) {
1850 $this->main_tpl->setOnScreenMessage(
'success',
$lng->txt(
"tbl_template_deleted"));
1854 $create_id =
"template_create_overlay_" . $this->
getId();
1855 $delete_id =
"template_delete_overlay_" . $this->
getId();
1856 $list_id =
"template_stg_" . $this->
getId();
1859 $templates = $storage->getNames($this->getContext(),
$ilUser->getId());
1862 if (count($templates) > 0) {
1864 $overlay->setTrigger($list_id .
"_delete");
1865 $overlay->setAnchor(
"ilAdvSelListAnchorElement_" . $list_id);
1866 $overlay->setAutoHide(
false);
1869 $lng->loadLanguageModule(
"form");
1870 $this->tpl->setCurrentBlock(
"template_editor_delete_item");
1871 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION_VALUE",
"");
1872 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION",
"- " .
$lng->txt(
"form_please_select") .
" -");
1873 $this->tpl->parseCurrentBlock();
1874 foreach ($templates as
$name) {
1875 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION_VALUE",
$name);
1876 $this->tpl->setVariable(
"TEMPLATE_DELETE_OPTION",
$name);
1877 $this->tpl->parseCurrentBlock();
1880 $this->tpl->setCurrentBlock(
"template_editor_delete");
1881 $this->tpl->setVariable(
"TEMPLATE_DELETE_ID", $delete_id);
1882 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE",
$lng->txt(
"tbl_template_delete"));
1883 $this->tpl->setVariable(
"TXT_TEMPLATE_DELETE_SUBMIT",
$lng->txt(
"delete"));
1884 $this->tpl->setVariable(
"TEMPLATE_DELETE_CMD", $this->parent_cmd);
1885 $this->tpl->parseCurrentBlock();
1891 $overlay->setTrigger($list_id .
"_create");
1892 $overlay->setAnchor(
"ilAdvSelListAnchorElement_" . $list_id);
1893 $overlay->setAutoHide(
false);
1896 $this->tpl->setCurrentBlock(
"template_editor");
1897 $this->tpl->setVariable(
"TEMPLATE_CREATE_ID", $create_id);
1898 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE",
$lng->txt(
"tbl_template_create"));
1899 $this->tpl->setVariable(
"TXT_TEMPLATE_CREATE_SUBMIT",
$lng->txt(
"save"));
1900 $this->tpl->setVariable(
"TEMPLATE_CREATE_CMD", $this->parent_cmd);
1901 $this->tpl->parseCurrentBlock();
1905 $alist->setId($list_id);
1906 $alist->addItem(
$lng->txt(
"tbl_template_create"),
"create",
"#");
1907 if (count($templates) > 0) {
1908 $alist->addItem(
$lng->txt(
"tbl_template_delete"),
"delete",
"#");
1909 foreach ($templates as
$name) {
1910 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_tpl", urlencode(
$name));
1911 $alist->addItem(
$name,
$name, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
1912 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_tpl",
"");
1915 $alist->setListTitle(
$lng->txt(
"tbl_templates"));
1917 $this->tpl->setVariable(
"TEMPLATE_SELECTOR",
" " . $alist->getHTML());
1921 $this->tpl->setCurrentBlock(
"tbl_footer");
1922 $this->tpl->setVariable(
"COLUMN_COUNT", $this->getColumnCount());
1923 if ($this->getDisplayAsBlock()) {
1924 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
1926 $this->tpl->parseCurrentBlock();
1929 if ($numinfo !=
"" || $linkbar !=
"" || $column_selector !=
"" ||
1930 count($this->filters) > 0 || count($this->optional_filters) > 0) {
1931 if (is_object(
$ilUser) && (count($this->filters) || count($this->optional_filters))) {
1932 $this->tpl->setCurrentBlock(
"filter_activation");
1933 $this->tpl->setVariable(
"TXT_ACTIVATE_FILTER",
$lng->txt(
"show_filter"));
1934 $this->tpl->setVariable(
"FILA_ID", $this->
getId());
1935 if ($this->
getId() !=
"") {
1936 $this->tpl->setVariable(
"SAVE_URLA",
"./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1937 $this->
getId() .
"&cmd=showFilter&user_id=" .
$ilUser->getId());
1939 $this->tpl->parseCurrentBlock();
1942 if (!$this->getDisableFilterHiding()) {
1943 $this->tpl->setCurrentBlock(
"filter_deactivation");
1944 $this->tpl->setVariable(
"TXT_HIDE",
$lng->txt(
"hide_filter"));
1945 if ($this->
getId() !=
"") {
1946 $this->tpl->setVariable(
"SAVE_URL",
"./ilias.php?baseClass=ilTablePropertiesStorageGUI&table_id=" .
1947 $this->
getId() .
"&cmd=hideFilter&user_id=" .
$ilUser->getId());
1948 $this->tpl->setVariable(
"FILD_ID", $this->
getId());
1950 $this->tpl->parseCurrentBlock();
1954 if ($numinfo !=
"" && $this->getEnableNumInfo()) {
1955 $this->tpl->setCurrentBlock(
"top_numinfo");
1956 $this->tpl->setVariable(
"NUMINFO", $numinfo);
1957 $this->tpl->parseCurrentBlock();
1959 if ($linkbar !=
"" && !$this->getDisplayAsBlock()) {
1960 $linkbar = $this->getLinkbar(
"2");
1961 $this->tpl->setCurrentBlock(
"top_linkbar");
1962 $this->tpl->setVariable(
"LINKBAR", $linkbar);
1963 $this->tpl->parseCurrentBlock();
1967 $this->tpl->setVariable(
"COLUMN_SELECTOR", $column_selector);
1970 if ($this->getShowRowsSelector() &&
1973 !$this->rows_selector_off) {
1976 $alist->setId(
"sellst_rows_" . $this->
getId());
1977 $hpp = (
$ilUser->getPref(
"hits_per_page") != 9999)
1978 ?
$ilUser->getPref(
"hits_per_page")
1979 :
$lng->txt(
"no_limit");
1981 $options = array(0 =>
$lng->txt(
"default") .
" (" . $hpp .
")",5 => 5, 10 => 10, 15 => 15, 20 => 20,
1982 30 => 30, 40 => 40, 50 => 50,
1983 100 => 100, 200 => 200, 400 => 400, 800 => 800);
1984 foreach ($options as $k => $v) {
1985 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_trows", $k);
1986 $alist->addItem($v, $k, $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd));
1987 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_trows",
"");
1989 $alist->setListTitle($this->getRowSelectorLabel() ?:
$lng->txt(
"rows"));
1990 $this->tpl->setVariable(
"ROW_SELECTOR", $alist->getHTML());
1994 if (count($this->export_formats) > 0 && $this->dataExists()) {
1997 $alist->setId(
"sellst_xpt");
1998 foreach ($this->export_formats as
$format => $caption_lng_id) {
1999 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_xpt",
$format);
2000 $url = $ilCtrl->getLinkTarget($this->parent_obj, $this->parent_cmd);
2001 $ilCtrl->setParameter($this->parent_obj, $this->prefix .
"_xpt",
"");
2004 $alist->setListTitle(
$lng->txt(
"export"));
2005 $this->tpl->setVariable(
"EXPORT_SELECTOR",
" " . $alist->getHTML());
2008 $this->tpl->setCurrentBlock(
"top_navigation");
2009 $this->tpl->setVariable(
"COLUMN_COUNT", $this->getColumnCount());
2010 if ($this->getDisplayAsBlock()) {
2011 $this->tpl->setVariable(
"BLK_CLASS",
"Block");
2013 $this->tpl->parseCurrentBlock();
2024 $ilCtrl = $this->ctrl;
2029 $link = $ilCtrl->getLinkTargetByClass(get_class($this->parent_obj), $this->parent_cmd) .
2030 "&" . $this->getNavParameter() .
"=" .
2031 $this->getOrderField() .
":" . $this->getOrderDirection() .
":";
2034 $layout_prev =
$lng->txt(
"previous");
2035 $layout_next =
$lng->txt(
"next");
2038 if ($this->max_count > $this->getLimit() || $this->custom_prev_next) {
2039 $sep =
"<span> | </span>";
2042 $pages = intval($this->max_count / $this->getLimit());
2045 if (($this->max_count % $this->getLimit())) {
2050 $offset_arr = array();
2051 for (
$i = 1 ;
$i <= $pages ;
$i++) {
2052 $newoffset = $this->getLimit() * (
$i - 1);
2054 $nav_value = $this->getOrderField() .
":" . $this->getOrderDirection() .
":" . $newoffset;
2055 $offset_arr[$nav_value] =
$i;
2058 $sep =
"<span> </span>";
2061 if ($this->custom_prev_next && $this->custom_prev !=
"") {
2062 $LinkBar .=
"<a href=\"" . $this->custom_prev . $hash .
"\">" . $layout_prev .
"</a>";
2063 } elseif ($this->getOffset() >= 1 && !$this->custom_prev_next) {
2064 $prevoffset = $this->getOffset() - $this->getLimit();
2065 $LinkBar .=
"<a href=\"" . $link . $prevoffset . $hash .
"\">" . $layout_prev .
"</a>";
2067 $LinkBar .=
'<span class="ilTableFootLight">' . $layout_prev .
"</span>";
2071 if ($a_num ==
"1") {
2072 $LinkBar .=
'<input type="hidden" name="' . $this->getNavParameter() .
2073 '" value="' . $this->getOrderField() .
":" . $this->getOrderDirection() .
":" . $this->getOffset() .
'" />';
2076 $sep =
"<span> | </span>";
2080 if ($this->custom_prev_next && $this->custom_next !=
"") {
2081 $LinkBar .=
"<a href=\"" . $this->custom_next . $hash .
"\">" . $layout_next .
"</a>";
2082 } elseif (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1) &&
2083 !$this->custom_prev_next) {
2084 $newoffset = $this->getOffset() + $this->getLimit();
2085 $LinkBar .=
"<a href=\"" . $link . $newoffset . $hash .
"\">" . $layout_next .
"</a>";
2087 $LinkBar .=
'<span class="ilTableFootLight">' . $layout_next .
"</span>";
2090 $sep =
"<span> </span>";
2092 if (count($offset_arr) && !$this->getDisplayAsBlock() && !$this->custom_prev_next) {
2096 '<label for="tab_page_sel_' . $a_num .
'">' .
$lng->txt(
"page") .
'</label> ' .
2099 $this->getNavParameter() . $a_num,
2105 array(
"id" =>
"tab_page_sel_" . $a_num,
2106 "onchange" =>
"ilTablePageSelection(this, 'cmd[" . $this->parent_cmd .
"]')")
2118 $hidden_row =
false;
2119 if (count($this->hidden_inputs)) {
2120 foreach ($this->hidden_inputs as $hidden_input) {
2121 $this->tpl->setCurrentBlock(
"tbl_hidden_field");
2122 $this->tpl->setVariable(
"FIELD_NAME", $hidden_input[
"name"]);
2123 $this->tpl->setVariable(
"FIELD_VALUE", $hidden_input[
"value"]);
2124 $this->tpl->parseCurrentBlock();
2127 $this->tpl->setCurrentBlock(
"tbl_hidden_row");
2128 $this->tpl->parseCurrentBlock();
2137 $action_row =
false;
2143 if (count($this->sel_buttons) > 0) {
2144 foreach ($this->sel_buttons as $button) {
2145 $this->tpl->setCurrentBlock(
"sel_button");
2146 $this->tpl->setVariable(
2149 $button[
"selected"],
2156 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2157 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2158 $this->tpl->parseCurrentBlock();
2160 if ($this->getTopCommands()) {
2161 $this->tpl->setCurrentBlock(
"sel_top_button");
2162 $this->tpl->setVariable(
2165 $button[
"selected"],
2172 $this->tpl->setVariable(
"SBTN_NAME", $button[
"cmd"]);
2173 $this->tpl->setVariable(
"SBTN_VALUE", $button[
"text"]);
2174 $this->tpl->parseCurrentBlock();
2180 $this->sel_buttons[] = array(
"options" => [],
"cmd" =>
'',
"text" =>
'');
2183 if (count($this->buttons) > 0) {
2184 foreach ($this->buttons as $button) {
2185 if (!is_array($button)) {
2187 $this->tpl->setVariable(
'BUTTON_OBJ', $button->render());
2190 $button = clone $button;
2192 $this->tpl->setVariable(
'BUTTON_TOP_OBJ', $button->render());
2197 if (strlen($button[
'onclick'])) {
2198 $this->tpl->setCurrentBlock(
'cmdonclick');
2199 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2200 $this->tpl->parseCurrentBlock();
2202 $this->tpl->setCurrentBlock(
"plain_button");
2203 if ($button[
"id"] !=
"") {
2204 $this->tpl->setVariable(
"PBID",
' id="' . $button[
"id"] .
'" ');
2206 if ($button[
"class"] !=
"") {
2207 $this->tpl->setVariable(
"PBBT_CLASS",
' ' . $button[
"class"]);
2209 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2210 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2211 $this->tpl->parseCurrentBlock();
2213 if ($this->getTopCommands()) {
2214 if (strlen($button[
'onclick'])) {
2215 $this->tpl->setCurrentBlock(
'top_cmdonclick');
2216 $this->tpl->setVariable(
'CMD_ONCLICK', $button[
'onclick']);
2217 $this->tpl->parseCurrentBlock();
2219 $this->tpl->setCurrentBlock(
"plain_top_button");
2220 $this->tpl->setVariable(
"PBTN_NAME", $button[
"cmd"]);
2221 $this->tpl->setVariable(
"PBTN_VALUE", $button[
"text"]);
2222 if ($button[
"class"] !=
"") {
2223 $this->tpl->setVariable(
"PBBT_CLASS",
' ' . $button[
"class"]);
2225 $this->tpl->parseCurrentBlock();
2234 if (count($this->mi_sel_buttons)) {
2235 foreach ($this->mi_sel_buttons as $button) {
2236 $this->tpl->setCurrentBlock(
"mi_sel_button");
2237 $this->tpl->setVariable(
2240 $button[
"selected"],
2247 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2248 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2249 $this->tpl->parseCurrentBlock();
2251 if ($this->getTopCommands()) {
2252 $this->tpl->setCurrentBlock(
"mi_top_sel_button");
2253 $this->tpl->setVariable(
2256 $button[
"selected"],
2257 $button[
"sel_var"] .
"_2",
2263 $this->tpl->setVariable(
"MI_BTN_NAME", $button[
"cmd"]);
2264 $this->tpl->setVariable(
"MI_BTN_VALUE", $button[
"text"]);
2265 $this->tpl->parseCurrentBlock();
2273 if (count($this->multi) > 1 && $this->dataExists()) {
2274 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2275 $this->tpl->setCurrentBlock(
"tbl_cmd_select_all");
2276 $this->tpl->setVariable(
"TXT_SELECT_CMD_ALL",
$lng->txt(
"all_objects"));
2277 $this->tpl->parseCurrentBlock();
2280 $this->tpl->setCurrentBlock(
"tbl_cmd_select");
2282 foreach ($this->multi as $mc) {
2283 $sel[$mc[
"cmd"]] = $mc[
"text"];
2285 $this->tpl->setVariable(
2289 $this->tpl->setVariable(
"TXT_EXECUTE",
$lng->txt(
"execute"));
2290 $this->tpl->parseCurrentBlock();
2294 if ($this->getTopCommands()) {
2295 if ($this->enable_command_for_all && $this->max_count <= self::getAllCommandLimit()) {
2296 $this->tpl->setCurrentBlock(
"tbl_top_cmd_select_all");
2297 $this->tpl->setVariable(
"TXT_SELECT_CMD_ALL",
$lng->txt(
"all_objects"));
2298 $this->tpl->parseCurrentBlock();
2301 $this->tpl->setCurrentBlock(
"tbl_top_cmd_select");
2303 foreach ($this->multi as $mc) {
2304 $sel[$mc[
"cmd"]] = $mc[
"text"];
2306 $this->tpl->setVariable(
2310 $this->tpl->setVariable(
"TXT_EXECUTE",
$lng->txt(
"execute"));
2311 $this->tpl->parseCurrentBlock();
2313 } elseif (count($this->multi) == 1 && $this->dataExists()) {
2314 $this->tpl->setCurrentBlock(
"tbl_single_cmd");
2315 foreach ($this->multi as $mc) {
2319 $this->tpl->setVariable(
"TXT_SINGLE_CMD",
$txt);
2320 $this->tpl->setVariable(
"SINGLE_CMD", $cmd);
2321 $this->tpl->parseCurrentBlock();
2325 if ($this->getTopCommands()) {
2326 $this->tpl->setCurrentBlock(
"tbl_top_single_cmd");
2327 foreach ($this->multi as $mc) {
2331 $this->tpl->setVariable(
"TXT_SINGLE_CMD",
$txt);
2332 $this->tpl->setVariable(
"SINGLE_CMD", $cmd);
2333 $this->tpl->parseCurrentBlock();
2338 $this->tpl->setCurrentBlock(
"tbl_action_img_arrow");
2340 $this->tpl->setVariable(
"ALT_ARROW",
$lng->txt(
"action"));
2341 $this->tpl->parseCurrentBlock();
2343 if ($this->getTopCommands()) {
2344 $this->tpl->setCurrentBlock(
"tbl_top_action_img_arrow");
2346 $this->tpl->setVariable(
"ALT_ARROW",
$lng->txt(
"action"));
2347 $this->tpl->parseCurrentBlock();
2352 $this->tpl->setCurrentBlock(
"tbl_action_row");
2353 $this->tpl->parseCurrentBlock();
2354 if ($this->getTopCommands()) {
2355 $this->tpl->setCurrentBlock(
"tbl_top_action_row");
2356 $this->tpl->parseCurrentBlock();
2363 $this->headerHTML = $html;
2371 if (isset(
$DIC[
"ilUser"])) {
2378 $tab_prop->storeProperty($this->
getId(),
$ilUser->getId(), $type, $value);
2387 if (isset(
$DIC[
"ilUser"])) {
2394 return $tab_prop->getProperty($this->
getId(),
$ilUser->getId(), $type);
2404 $this->determineOffsetAndOrder();
2405 $this->determineLimit();
2406 $this->determineSelectedColumns();
2407 $this->determineSelectedFilters();
2412 $result[
"order"] = $this->getOrderField();
2413 $result[
"direction"] = $this->getOrderDirection();
2414 $result[
"offset"] = $this->getOffset();
2415 $result[
"rows"] = $this->getLimit();
2416 $result[
"selfilters"] = $this->getSelectedFilters();
2420 $result[
"selfields"] = $this->selected_column;
2423 if ($this->filters) {
2424 foreach ($this->filters as $item) {
2425 $result[
"filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2428 if ($this->optional_filters && $result[
"selfilters"]) {
2429 foreach ($this->optional_filters as $item) {
2430 if (in_array($item->getFieldId(), $result[
"selfilters"])) {
2431 $result[
"filter_values"][$item->getFieldId()] = $this->getFilterValue($item);
2445 if (method_exists($a_item,
"getChecked")) {
2446 return (
string) $a_item->getChecked();
2447 } elseif (method_exists($a_item,
"getValue")) {
2448 return $a_item->getValue() ?:
"";
2449 } elseif (method_exists($a_item,
"getDate")) {
2461 if (method_exists($a_item,
"setChecked")) {
2462 $a_item->setChecked((
bool) $a_value);
2463 } elseif (method_exists($a_item,
"setValue")) {
2464 $a_item->setValue($a_value);
2465 } elseif (method_exists($a_item,
"setDate")) {
2468 $a_item->writeToSession();
2474 $this->context =
$id;
2488 $this->show_rows_selector = $a_value;
2493 return $this->show_rows_selector;
2498 $this->show_templates = $a_value;
2503 return $this->show_templates;
2520 $data = $storage->load($this->getContext(),
$ilUser->getId(), $a_name);
2521 if (is_array(
$data)) {
2522 foreach (
$data as $property => $value) {
2523 $this->storeProperty($property, $value);
2527 $data[
"filter_values"] = unserialize(
$data[
"filter_values"]);
2528 if (
$data[
"filter_values"]) {
2529 $this->restore_filter_values =
$data[
"filter_values"];
2532 $this->restore_filter =
true;
2553 $state = $this->getCurrentState();
2554 $state[
"filter_values"] = serialize($state[
"filter_values"] ??
null);
2555 $state[
"selfields"] = serialize($state[
"selfields"] ??
null);
2556 $state[
"selfilters"] = serialize($state[
"selfilters"] ??
null);
2558 $storage->store($this->getContext(),
$ilUser->getId(), $a_name, $state);
2574 $storage->delete($this->getContext(),
$ilUser->getId(), $a_name);
2582 if ($this->getExportMode() || $this->getPrintMode()) {
2585 return parent::getLimit();
2590 if ($this->getExportMode() || $this->getPrintMode()) {
2593 return parent::getOffset();
2601 $this->export_formats = array();
2604 $valid = array(self::EXPORT_EXCEL =>
"tbl_export_excel",
2605 self::EXPORT_CSV =>
"tbl_export_csv");
2616 $this->print_mode = $a_value;
2621 return $this->print_mode;
2626 return $this->export_mode;
2634 if ($this->dataExists()) {
2636 if (!$this->getExternalSorting() && $this->enabled[
"sort"]) {
2637 $this->determineOffsetAndOrder(
true);
2641 $this->getOrderField(),
2642 $this->getOrderDirection(),
2643 $this->numericOrdering($this->getOrderField())
2649 case self::EXPORT_EXCEL:
2651 $excel->addSheet($this->title
2652 ?: $this->
lng->txt(
"export"));
2656 $this->fillMetaExcel($excel, $row);
2660 $this->fillHeaderExcel($excel, $row);
2665 foreach ($this->row_data as $set) {
2666 $this->fillRowExcel($excel, $row, $set);
2678 case self::EXPORT_CSV:
2680 $csv->setSeparator(
";");
2683 $this->fillMetaCSV($csv);
2684 $this->fillHeaderCSV($csv);
2685 foreach ($this->row_data as $set) {
2686 $this->fillRowCSV($csv, $set);
2692 header(
"Content-type: text/comma-separated-values");
2693 header(
"Content-Disposition: attachment; filename=\"" .
$filename .
"\"");
2694 header(
"Expires: 0");
2695 header(
"Cache-Control: must-revalidate, post-check=0,pre-check=0");
2696 header(
"Pragma: public");
2697 echo $csv->getCSVString();
2699 file_put_contents(
$filename, $csv->getCSVString());
2729 foreach ($this->column as $column) {
2730 $title = strip_tags($column[
"text"]);
2732 $a_excel->
setCell($a_row, $col++, $title);
2748 foreach ($a_set as $value) {
2749 if (is_array($value)) {
2750 $value = implode(
', ', $value);
2752 $a_excel->
setCell($a_row, $col++, $value);
2772 foreach ($this->column as $column) {
2773 $title = strip_tags($column[
"text"]);
2789 foreach ($a_set as
$key => $value) {
2790 if (is_array($value)) {
2791 $value = implode(
', ', $value);
2800 $this->enable_command_for_all = $a_value;
2807 $ilClientIniFile =
$DIC[
"ilClientIniFile"];
2809 $limit = $ilClientIniFile->readVariable(
"system",
"TABLE_ACTION_ALL_LIMIT");
2811 $limit = self::ACTION_ALL_LIMIT;
2819 $this->row_selector_label = $row_selector_label;
2824 return $this->row_selector_label;
2829 $this->prevent_double_submission = $a_val;
2834 return $this->prevent_double_submission;
2837 public function setLimit(
int $a_limit = 0,
int $a_default_limit = 0): void
2839 parent::setLimit($a_limit, $a_default_limit);
2842 if ($a_limit == 9999 &&
2843 $this->limit_determined) {
2844 $this->rows_selector_off =
true;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
getNextClass($a_gui_class=null)
@inheritDoc
static setUseRelativeDates(bool $a_status)
set use relative dates
setBold(string $a_coords)
Set cell(s) to bold.
getColumnCoord(int $a_col)
Get column "name" from number.
setCell(int $a_row, int $a_col, $a_value, ?string $a_datatype=null)
Set cell value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
loadLanguageModule(string $a_module)
Load language module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $defaultorderdirection
restoreTemplate(string $a_name)
Restore state from template.
setTopAnchor(string $a_val)
isFilterSelected(string $a_col)
Is given filter selected?
isColumnSelected(string $col)
array $restore_filter_values
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
setOrderLink(string $key, string $order_dir)
bool $enable_command_for_all
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setFilterCommand(string $a_val, string $a_caption="")
getFormName()
get the name of the parent form
prepareOutput()
Anything that must be done before HTML is generated.
setOrderField(string $a_order_field)
setPreventDoubleSubmission(bool $a_val)
getDefaultFilterVisibility()
getFilterItemByPostVar(string $a_post_var)
determineSelectedColumns()
loadProperty(string $type)
bool $disable_filter_hiding
setEnableAllCommand(bool $a_value)
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
bool $prevent_double_submission
string $requested_nav_par1
fillRowCSV(ilCSVWriter $a_csv, array $a_set)
CSV Version of Fill Row.
setIsDataTable(bool $a_val)
setRowSelectorLabel(string $row_selector_label)
determineOffsetAndOrder(bool $a_omit_offset=false)
setCustomPreviousNext(string $a_prev_link, string $a_next_link)
setOpenFormTag(bool $a_val)
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
string $row_selector_label
setEnableNumInfo(bool $a_val)
setExportFormats(array $formats)
Set available export formats.
setExternalSegmentation(bool $a_val)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
addFilterItem(ilTableFilterItem $a_input_item, bool $a_optional=false)
setEnableTitle(bool $a_enabletitle)
setFormName(string $a_name="")
getLinkbar(string $a_num)
setDescription(string $a_val)
addHiddenInput(string $a_name, string $a_value)
addMultiCommand(string $a_cmd, string $a_text)
setShowTemplates(bool $a_value)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setFormAction(string $a_form_action, bool $a_multipart=false)
saveTemplate(string $a_name)
Save current state as template.
resetOffset(bool $a_in_determination=false)
setHeaderHTML(string $html)
string $defaultorderfield
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
ILIAS Table TableGUIRequest $table_request
fillHeaderCSV(ilCSVWriter $a_csv)
CSV Version of Fill Header.
setEnableHeader(bool $a_enableheader)
deleteTemplate(string $a_name)
string $requested_tmpl_delete
getDefaultOrderDirection()
renderFilter()
Render Filter section.
fillRowExcel(ilExcel $a_excel, int &$a_row, array $a_set)
Excel Version of Fill Row.
isFilterVisible()
Check if filter is visible: manually shown (session, db) or default value set.
addCommandButtonInstance(ilButtonBase $a_button)
setDefaultOrderField(string $a_defaultorderfield)
ilGlobalTemplateInterface $main_tpl
setPrintMode(bool $a_value=false)
setDisplayAsBlock(bool $a_val)
fillRow(array $a_set)
Standard Version of Fill Row.
getCurrentState()
get current settings for order, limit, columns and filter
getSelectableColumns()
Get selectable columns.
addHeaderCommand(string $a_href, string $a_text, string $a_target="", string $a_img="")
static getAllCommandLimit()
getExternalSegmentation()
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
string $requested_nav_par
setDisableFilterHiding(bool $a_val=true)
numericOrdering(string $a_field)
Should this field be sorted numeric?
setNoEntriesText(string $a_text)
fillMetaExcel(ilExcel $a_excel, int &$a_row)
Add meta information to excel export.
setTopCommands(bool $a_val)
getFilterItems(bool $a_optionals=false)
setFilterValue(ilTableFilterItem $a_item, $a_value)
setExternalSorting(bool $a_val)
isAdvMDFilter(ilAdvancedMDRecordGUI $a_gui, ilTableFilterItem $a_element)
Check if filter element is based on adv md.
array $selectable_columns
const FILTER_DURATION_RANGE
string $requested_nav_par2
addMultiItemSelectionButton(string $a_sel_var, array $a_options, string $a_cmd, string $a_text, string $a_default_selection='')
string $requested_tmpl_create
setCloseCommand(string $a_link)
getFilterValue(ilTableFilterItem $a_item)
Get current filter value.
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
bool $default_filter_visibility
setDefaultOrderDirection(string $a_defaultorderdirection)
setFilterCols(int $a_val)
setResetCommand(string $a_val, string $a_caption="")
storeProperty(string $type, string $value)
setDefaultFilterVisiblity(bool $a_status)
setData(array $a_data)
Set table data.
const FILTER_NUMBER_RANGE
exportData(int $format, bool $send=false)
Export and optionally send current table data.
fillMetaCSV(ilCSVWriter $a_csv)
Add meta information to csv export.
fillHeaderExcel(ilExcel $a_excel, int &$a_row)
Excel Version of Fill Header.
setCloseFormTag(bool $a_val)
getPreventDoubleSubmission()
const FILTER_DATETIME_RANGE
determineSelectedFilters()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setOffset(int $a_offset)
set dataset offset
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
static img(string $a_src, ?string $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc