ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilBlockGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
4
12abstract class ilBlockGUI
13{
14 abstract public static function getBlockType(); // return block type, e.g. "feed"
15 abstract public static function isRepositoryObject(); // returns whether block has a
16 // corresponding repository object
17
18 protected $data = array();
19 protected $colspan = 1;
20 protected $enablenuminfo = true;
21 protected $detail_min = 0;
22 protected $detail_max = 0;
23 protected $bigmode = false;
24 protected $footer_links = array();
25 protected $block_id = 0;
26 protected $header_commands = array();
27 protected $allow_moving = true;
28 protected $move = array("left" => false, "right" => false, "up" => false, "down" => false);
29 protected $enabledetailrow = true;
30 protected $header_links = array();
31 protected $footerinfo = false;
32 protected $footerinfo_icon = false;
33 protected $block_commands = array();
34 protected $max_count = false;
35 protected $close_command = false;
36 protected $image = false;
37 protected $property = false;
38 protected $nav_value = "";
39 protected $css_row = "";
40
41 protected $dropdown;
42
46 protected $tpl;
47
51 protected $main_tpl;
52
56 protected $user;
57
61 protected $ctrl;
62
66 protected $access;
67
71 protected $lng;
72
76 protected $obj_def;
77
83 public function __construct()
84 {
85 global $DIC;
86
87 $this->user = $DIC->user();
88 $this->ctrl = $DIC->ctrl();
89 $this->access = $DIC->access();
90 $this->lng = $DIC->language();
91 $this->main_tpl = $DIC["tpl"];
92 $this->obj_def = $DIC["objDefinition"];
93
94 include_once("./Services/YUI/classes/class.ilYuiUtil.php");
96 $this->main_tpl->addJavaScript("./Services/Block/js/ilblockcallback.js");
97
98 $this->setLimit($this->user->getPref("hits_per_page"));
99 }
100
101 public function addHeaderLink($a_href, $a_text, $status = true)
102 {
103 $this->header_links[] =
104 array('href' => $a_href, 'text' => $a_text, 'status' => (bool) $status);
105 }
106
107 public function getHeaderLinks()
108 {
109 return $this->header_links;
110 }
111
117 public function setData($a_data)
118 {
119 $this->data = $a_data;
120 }
121
127 public function getData()
128 {
129 return $this->data;
130 }
131
137 public function setBigMode($a_bigmode)
138 {
139 $this->bigmode = $a_bigmode;
140 }
141
147 public function getBigMode()
148 {
149 return $this->bigmode;
150 }
151
157 public function setBlockId($a_block_id = 0)
158 {
159 $this->block_id = $a_block_id;
160 }
161
167 public function getBlockId()
168 {
169 return $this->block_id;
170 }
171
178 public function setAvailableDetailLevels($a_max, $a_min = 0)
179 {
180 $this->detail_min = $a_min;
181 $this->detail_max = $a_max;
182 $this->handleDetailLevel();
183 }
184
190 public function setCurrentDetailLevel($a_currentdetaillevel)
191 {
192 $this->currentdetaillevel = $a_currentdetaillevel;
193 }
194
202 public function setGuiObject(&$a_gui_object)
203 {
204 $this->gui_object = $a_gui_object;
205 }
206
212 public function getGuiObject()
213 {
214 return $this->gui_object;
215 }
216
222 public function getCurrentDetailLevel()
223 {
224 return $this->currentdetaillevel;
225 }
226
232 public function setTitle($a_title)
233 {
234 $this->title = $a_title;
235 }
236
242 public function getTitle()
243 {
244 return $this->title;
245 }
246
252 public function setImage($a_image)
253 {
254 $this->image = $a_image;
255 }
256
262 public function getImage()
263 {
264 return $this->image;
265 }
266
272 public function setOffset($a_offset)
273 {
274 $this->offset = $a_offset;
275 }
276
282 public function getOffset()
283 {
284 return $this->offset;
285 }
286
287 public function correctOffset()
288 {
289 if (!($this->offset < $this->max_count)) {
290 $this->setOffset(0);
291 }
292 }
293
299 public function setLimit($a_limit)
300 {
301 $this->limit = $a_limit;
302 }
303
309 public function getLimit()
310 {
311 return $this->limit;
312 }
313
319 public function setEnableEdit($a_enableedit)
320 {
321 $this->enableedit = $a_enableedit;
322 }
323
329 public function getEnableEdit()
330 {
331 return $this->enableedit;
332 }
333
339 public function setRepositoryMode($a_repositorymode)
340 {
341 $this->repositorymode = $a_repositorymode;
342 }
343
349 public function getRepositoryMode()
350 {
351 return $this->repositorymode;
352 }
353
359 public function setFooterInfo($a_footerinfo, $a_hide_and_icon = false)
360 {
361 if ($a_hide_and_icon) {
362 $this->footerinfo_icon = $a_footerinfo;
363 } else {
364 $this->footerinfo = $a_footerinfo;
365 }
366 }
367
373 public function getFooterInfo($a_hide_and_icon = false)
374 {
375 if ($a_hide_and_icon) {
377 } else {
378 return $this->footerinfo;
379 }
380 }
381
387 public function setSubtitle($a_subtitle)
388 {
389 $this->subtitle = $a_subtitle;
390 }
391
397 public function getSubtitle()
398 {
399 return $this->subtitle;
400 }
401
407 public function setRefId($a_refid)
408 {
409 $this->refid = $a_refid;
410 }
411
417 public function getRefId()
418 {
419 return $this->refid;
420 }
421
427 public function setAdminCommands($a_admincommands)
428 {
429 $this->admincommands = $a_admincommands;
430 }
431
437 public function getAdminCommands()
438 {
439 return $this->admincommands;
440 }
441
447 public function setColSpan($a_colspan)
448 {
449 $this->colspan = $a_colspan;
450 }
451
457 public function getColSpan()
458 {
459 return $this->colspan;
460 }
461
467 public function setEnableDetailRow($a_enabledetailrow)
468 {
469 $this->enabledetailrow = $a_enabledetailrow;
470 }
471
477 public function getEnableDetailRow()
478 {
480 }
481
482
488 public function setEnableNumInfo($a_enablenuminfo)
489 {
490 $this->enablenuminfo = $a_enablenuminfo;
491 }
492
498 public function getEnableNumInfo()
499 {
501 }
502
509 public function setProperties($a_properties)
510 {
511 $this->property = $a_properties;
512 }
513
514 public function getProperty($a_property)
515 {
516 return $this->property[$a_property];
517 }
518
519 public function setProperty($a_property, $a_value)
520 {
521 $this->property[$a_property] = $a_value;
522 }
523
529 public function setRowTemplate($a_rowtemplatename, $a_rowtemplatedir = "")
530 {
531 $this->rowtemplatename = $a_rowtemplatename;
532 $this->rowtemplatedir = $a_rowtemplatedir;
533 }
534
535 final public function getNavParameter()
536 {
537 return $this->getBlockType() . "_" . $this->getBlockId() . "_blnav";
538 }
539
540 final public function getDetailParameter()
541 {
542 return $this->getBlockType() . "_" . $this->getBlockId() . "_bldet";
543 }
544
545 final public function getConfigParameter()
546 {
547 return $this->getBlockType() . "_" . $this->getBlockId() . "_blconf";
548 }
549
550 final public function getMoveParameter()
551 {
552 return $this->getBlockType() . "_" . $this->getBlockId() . "_blmove";
553 }
554
560 public function getRowTemplateName()
561 {
562 return $this->rowtemplatename;
563 }
564
570 public function getRowTemplateDir()
571 {
572 return $this->rowtemplatedir;
573 }
574
581 public function addBlockCommand(
582 $a_href,
583 $a_text,
584 $a_target = "",
585 $a_img = "",
586 $a_right_aligned = false,
587 $a_checked = false,
588 $a_html = ""
589 ) {
590 return $this->block_commands[] =
591 array("href" => $a_href,
592 "text" => $a_text, "target" => $a_target, "img" => $a_img,
593 "right" => $a_right_aligned, "checked" => $a_checked, "html" => $a_html);
594 }
595
601 public function getBlockCommands()
602 {
604 }
605
612 public function addHeaderCommand($a_href, $a_text, $a_as_close = false)
613 {
614 if ($a_as_close) {
615 $this->close_command = $a_href;
616 } else {
617 $this->header_commands[] =
618 array("href" => $a_href,
619 "text" => $a_text);
620 }
621 }
622
628 public function getHeaderCommands()
629 {
631 }
632
636 public function addFooterLink(
637 $a_text,
638 $a_href = "",
639 $a_onclick = "",
640 $a_block_id = "",
641 $a_top = false,
642 $a_omit_separator = false,
643 $a_checked = false
644 ) {
645 $this->footer_links[] = array(
646 "text" => $a_text,
647 "href" => $a_href,
648 "onclick" => $a_onclick,
649 "block_id" => $a_block_id,
650 "top" => $a_top,
651 "omit_separator" => $a_omit_separator,
652 "checked" => $a_checked);
653 }
654
658 public function getFooterLinks()
659 {
660 return $this->footer_links;
661 }
662
666 public function clearFooterLinks()
667 {
668 $this->footer_links = array();
669 }
670
674 public static function getScreenMode()
675 {
676 return IL_SCREEN_SIDE;
677 }
678
682 public function handleDetailLevel()
683 {
686 // set/get detail level
687 if ($this->detail_max > $this->detail_min) {
688 include_once("Services/Block/classes/class.ilBlockSetting.php");
689 if (isset($_GET[$this->getDetailParameter()])) {
691 $this->getBlockType(),
692 $_GET[$this->getDetailParameter()],
693 $ilUser->getId(),
694 $this->block_id
695 );
697 if ((int) $_GET[$this->getDetailParameter()] == 0) {
698 $ilCtrl->redirectByClass("ilcolumngui", "");
699 }
700 } else {
702 $this->getBlockType(),
703 $ilUser->getId(),
704 $this->block_id
705 ));
706 }
707 }
708 }
709
713 /*
714 function handleConfigStatus()
715 {
716 $this->config_mode = false;
717
718 if ($_GET[$this->getConfigParameter()] == "toggle")
719 {
720 if ($_SESSION[$this->getConfigParameter()] == "on")
721 {
722 $_SESSION[$this->getConfigParameter()] = "off";
723 }
724 else
725 {
726 $_SESSION[$this->getConfigParameter()] = "on";
727 }
728 }
729 if ($_SESSION[$this->getConfigParameter()] == "on")
730 {
731 $this->config_mode = true;
732 }
733 }
734 */
735
739 public function getHTML()
740 {
743 $ilAccess = $this->access;
745 $objDefinition = $this->obj_def;
746
747 if ($this->isRepositoryObject()) {
748 if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
749 return "";
750 }
751 }
752
753 $this->tpl = new ilTemplate("tpl.block.html", true, true, "Services/Block");
754
755 // $this->handleConfigStatus();
756
757 $this->fillDataSection();
758
759 if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
760 // #10993
761 if ($this->getAdminCommands()) {
762 $this->tpl->setCurrentBlock("block_check");
763 $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
764 $this->tpl->parseCurrentBlock();
765 }
766
767 if ($ilAccess->checkAccess("delete", "", $this->getRefId())) {
768 $this->addBlockCommand(
769 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=delete" .
770 "&item_ref_id=" . $this->getRefId(),
771 $lng->txt("delete")
772 );
773
774 // see ilObjectListGUI::insertCutCommand();
775 $this->addBlockCommand(
776 "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=cut" .
777 "&item_ref_id=" . $this->getRefId(),
778 $lng->txt("move")
779 );
780 }
781
782 // #14595 - see ilObjectListGUI::insertCopyCommand()
783 if ($ilAccess->checkAccess("copy", "", $this->getRefId())) {
784 $parent_type = ilObject::_lookupType($_GET["ref_id"], true);
785 $parent_gui = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
786
787 $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
788 $copy_cmd = $ilCtrl->getLinkTargetByClass(
789 array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
790 "initTargetSelection"
791 );
792
793 // see ilObjectListGUI::insertCopyCommand();
794 $this->addBlockCommand(
795 $copy_cmd,
796 $lng->txt("copy")
797 );
798 }
799 }
800
801 // footer info
802 if ($this->getFooterInfo() != "") {
803 $this->tpl->setCurrentBlock("footer_information");
804 $this->tpl->setVariable("FOOTER_INFO", $this->getFooterInfo());
805 $this->tpl->setVariable("FICOLSPAN", $this->getColSpan());
806 $this->tpl->parseCurrentBlock();
807 }
808
809 $this->dropdown = array();
810
811 // commands
812 if (count($this->getBlockCommands()) > 0) {
813 $has_block_command = false;
814
815 foreach ($this->getBlockCommands() as $command) {
816 if (!$command["img"] && !$command["html"]) {
817 $this->dropdown[] = $command;
818 continue;
819 }
820
821 $has_block_command = true;
822
823 if ($command["target"] != "") {
824 $this->tpl->setCurrentBlock("bc_target");
825 $this->tpl->setVariable("CMD_TARGET", $command["target"]);
826 $this->tpl->parseCurrentBlock();
827 }
828
829 if ($command["img"] != "") {
830 $this->tpl->setCurrentBlock("bc_image");
831 $this->tpl->setVariable("SRC_BC", $command["img"]);
832 $this->tpl->setVariable("ALT_BC", $command["text"]);
833 $this->tpl->parseCurrentBlock();
834 $this->tpl->setCurrentBlock("block_command");
835 } elseif ($command["html"] != "") {
836 $this->tpl->setCurrentBlock("bc_html");
837 $this->tpl->setVariable("HTML", $command["html"]);
838 $this->tpl->parseCurrentBlock();
839 $this->tpl->setCurrentBlock("block_command");
840 } else {
841 $this->tpl->setCurrentBlock("block_command");
842 $this->tpl->setVariable("CMD_TEXT", $command["text"]);
843 $this->tpl->setVariable("BC_CLASS", 'class="il_ContainerItemCommand"');
844 }
845
846 $this->tpl->setVariable("CMD_HREF", $command["href"]);
847 $this->tpl->parseCurrentBlock();
848 }
849
850 if ($has_block_command) {
851 $this->tpl->setCurrentBlock("block_commands");
852 $this->tpl->setVariable("CCOLSPAN", $this->getColSpan());
853 $this->tpl->parseCurrentBlock();
854 }
855 }
856
857 // fill previous next
858 $this->fillPreviousNext();
859
860 // fill footer
861 $this->fillFooter();
862
863 // fill row for setting details
864 $this->fillDetailRow();
865
866 // header links
867 if (count($this->getHeaderLinks())) {
868 $counter = 0;
869 foreach ($this->getHeaderLinks() as $command) {
870 if ($counter > 0) {
871 $this->tpl->setCurrentBlock('head_delim');
872 $this->tpl->touchBlock('head_delim');
873 $this->tpl->parseCurrentBlock();
874 }
875 if ($command['status'] == true) {
876 $this->tpl->setCurrentBlock('head_link');
877 $this->tpl->setVariable('HHREF', $command['href']);
878 $this->tpl->setVariable('HLINK', $command['text']);
879 $this->tpl->parseCurrentBlock();
880 } else {
881 $this->tpl->setCurrentBlock('head_text');
882 $this->tpl->setVariable('HTEXT', $command['text']);
883 $this->tpl->parseCurrentBlock();
884 }
885
886 $this->tpl->setCurrentBlock('head_item');
887 $this->tpl->parseCurrentBlock();
888
889 ++$counter;
890 }
891
892 $this->tpl->setCurrentBlock('header_links');
893 $this->tpl->parseCurrentBlock();
894 }
895
896 // for screen readers we first output the title and the commands
897 // (e.g. close icon afterwards), otherwise we first output the
898 // header commands, since we want to have the close icon top right
899 // and not floated after the title
900 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
901 $this->fillHeaderTitleBlock();
902 $this->fillHeaderCommands();
903 } else {
904 $this->fillHeaderCommands();
905 $this->fillHeaderTitleBlock();
906 }
907
908 $this->tpl->setVariable("COLSPAN", $this->getColSpan());
909 if ($this->getBigMode()) {
910 $this->tpl->touchBlock("hclassb");
911 } else {
912 $this->tpl->touchBlock("hclass");
913 }
914
915 if ($ilCtrl->isAsynch()) {
916 // return without div wrapper
917 echo $this->tpl->getAsynch();
918 } else {
919 // return incl. wrapping div with id
920 return '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
921 $this->tpl->get() . '</div>';
922 }
923 }
924
928 public function fillHeaderCommands()
929 {
932
933
934 // header commands
935 if (count($this->getHeaderCommands()) > 0 ||
936 ($this->detail_max > $this->detail_min && $this->detail_min == 0) ||
937 $this->close_command != "") {
938 foreach ($this->getHeaderCommands() as $command) {
939 $this->tpl->setCurrentBlock("header_command");
940 $this->tpl->setVariable("HREF_HCOMM", $command["href"]);
941 $this->tpl->setVariable("TXT_HCOMM", $command["text"]);
942 $this->tpl->parseCurrentBlock();
943 }
944
945 // close button
946 if (($this->detail_max > $this->detail_min && $this->detail_min == 0 &&
947 !$this->getRepositoryMode())
948 ||
949 $this->close_command != "") {
950 $alt = $lng->txt("hide");
951 if ($this->close_command != "") {
953 } else {
954 $ilCtrl->setParameterByClass(
955 "ilcolumngui",
956 $this->getDetailParameter(),
957 "0"
958 );
959 $url = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
960 $ilCtrl->setParameterByClass(
961 "ilcolumngui",
962 $this->getDetailParameter(),
963 ""
964 );
965 }
966
967 $this->dropdown[] = array("text" => $alt,
968 "image" => $img,
969 "href" => $url);
970 }
971
972 $this->tpl->setCurrentBlock("header_commands");
973 $this->tpl->parseCurrentBlock();
974 }
975
976 // adv selection gui
977 include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
979 $dropdown->setUseImages(true);
982 $dropdown->setId("block_dd_" . $this->getBlockType() . "_" . $this->block_id);
983 foreach ($this->dropdown as $item) {
984 if ($item["href"] || $item["onclick"]) {
985 if ($item["checked"]) {
986 $item["image"] = ilUtil::getImagePath("icon_checked.svg");
987 }
988 $dropdown->addItem(
989 $item["text"],
990 "",
991 $item["href"],
992 $item["image"],
993 $item["text"],
994 "",
995 "",
996 false,
997 $item["onclick"]
998 );
999 }
1000 }
1001 $dropdown = $dropdown->getHTML();
1002 $this->tpl->setCurrentBlock("header_dropdown");
1003 $this->tpl->setVariable("ADV_DROPDOWN", $dropdown);
1004 $this->tpl->parseCurrentBlock();
1005
1006 $this->tpl->setCurrentBlock("hitem");
1007 $this->tpl->parseCurrentBlock();
1008 }
1009
1010
1014 public function fillHeaderTitleBlock()
1015 {
1016 $lng = $this->lng;
1017
1018 // image
1019 if ($this->getImage() != "") {
1020 $this->tpl->setCurrentBlock("block_img");
1021 $this->tpl->setVariable("IMG_BLOCK", $this->getImage());
1022 $this->tpl->setVariable(
1023 "IMID",
1024 "block_" . $this->getBlockType() . "_" . $this->block_id
1025 );
1026 $this->tpl->setVariable(
1027 "IMG_ALT",
1028 str_replace(array("'",'"'), "", strip_tags($lng->txt("icon") . " " . $this->getTitle()))
1029 );
1030 $this->tpl->parseCurrentBlock();
1031 }
1032
1033 // header title
1034 $this->tpl->setCurrentBlock("header_title");
1035 $this->tpl->setVariable(
1036 "BTID",
1037 "block_" . $this->getBlockType() . "_" . $this->block_id
1038 );
1039 $this->tpl->setVariable(
1040 "BLOCK_TITLE",
1041 $this->getTitle()
1042 );
1043 $this->tpl->setVariable(
1044 "TXT_BLOCK",
1045 $lng->txt("block")
1046 );
1047 $this->tpl->parseCurrentBlock();
1048
1049 $this->tpl->setCurrentBlock("hitem");
1050 $this->tpl->parseCurrentBlock();
1051 }
1052
1053
1058 {
1059 $this->tpl->setCurrentBlock("data_section");
1060 $this->tpl->setVariable("DATA", $a_content);
1061 $this->tpl->parseCurrentBlock();
1062 $this->tpl->setVariable("BLOCK_ROW", "");
1063 }
1064
1069 public function fillDataSection()
1070 {
1071 $this->nav_value = (isset($_POST[$this->getNavParameter()]) && $_POST[$this->getNavParameter()] != "")
1072 ? $_POST[$this->getNavParameter()]
1073 : (isset($_GET[$this->getNavParameter()]) ? $_GET[$this->getNavParameter()] : $this->nav_value);
1074 $this->nav_value = ($this->nav_value == "" && isset($_SESSION[$this->getNavParameter()]))
1075 ? $_SESSION[$this->getNavParameter()]
1077
1079
1080 $nav = explode(":", $this->nav_value);
1081 if (isset($nav[2])) {
1082 $this->setOffset($nav[2]);
1083 } else {
1084 $this->setOffset(0);
1085 }
1086
1087 // data
1088 $this->tpl->addBlockFile(
1089 "BLOCK_ROW",
1090 "block_row",
1091 $this->getRowTemplateName(),
1092 $this->getRowTemplateDir()
1093 );
1094
1095 $data = $this->getData();
1096 $this->max_count = count($data);
1097 $this->correctOffset();
1098 $data = array_slice($data, $this->getOffset(), $this->getLimit());
1099
1100 $this->preloadData($data);
1101
1102 foreach ($data as $record) {
1103 $this->tpl->setCurrentBlock("block_row");
1104 $this->fillRowColor();
1105 $this->fillRow($record);
1106 $this->tpl->setCurrentBlock("block_row");
1107 $this->tpl->parseCurrentBlock();
1108 }
1109 }
1110
1111 public function fillRow($a_set)
1112 {
1113 foreach ($a_set as $key => $value) {
1114 $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
1115 }
1116 }
1117
1118 public function fillFooter()
1119 {
1120 }
1121
1122 final protected function fillRowColor($a_placeholder = "CSS_ROW")
1123 {
1124 $this->css_row = ($this->css_row != "ilBlockRow1")
1125 ? "ilBlockRow1"
1126 : "ilBlockRow2";
1127 $this->tpl->setVariable($a_placeholder, $this->css_row);
1128 }
1129
1133 public function fillPreviousNext()
1134 {
1135 $lng = $this->lng;
1136
1137 // table pn numinfo
1138 $numinfo = "";
1139 if ($this->getEnableNumInfo() && $this->max_count > 0) {
1140 $start = $this->getOffset() + 1; // compute num info
1141 $end = $this->getOffset() + $this->getLimit();
1142
1143 if ($end > $this->max_count or $this->getLimit() == 0) {
1145 }
1146
1147 $numinfo = "(" . $start . "-" . $end . " " . strtolower($lng->txt("of")) . " " . $this->max_count . ")";
1148 }
1149
1150 $this->setPreviousNextLinks();
1151 $this->fillFooterLinks(true, $numinfo);
1152 }
1153
1161 public function setPreviousNextLinks()
1162 {
1164 $lng = $this->lng;
1165
1166 // if more entries then entries per page -> show link bar
1167 if ($this->max_count > $this->getLimit() && ($this->getLimit() != 0)) {
1168 // previous link
1169 if ($this->getOffset() >= 1) {
1170 $prevoffset = $this->getOffset() - $this->getLimit();
1171
1172 $ilCtrl->setParameterByClass(
1173 "ilcolumngui",
1174 $this->getNavParameter(),
1175 "::" . $prevoffset
1176 );
1177
1178 // ajax link
1179 $ilCtrl->setParameterByClass(
1180 "ilcolumngui",
1181 "block_id",
1182 "block_" . $this->getBlockType() . "_" . $this->block_id
1183 );
1184 $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1185 $onclick = $ilCtrl->getLinkTargetByClass(
1186 "ilcolumngui",
1187 "updateBlock",
1188 "",
1189 true
1190 );
1191 $ilCtrl->setParameterByClass(
1192 "ilcolumngui",
1193 "block_id",
1194 ""
1195 );
1196
1197 // normal link
1198 $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1199 $text = $lng->txt("previous");
1200
1201 $this->addFooterLink($text, $href, $onclick, $block_id, true);
1202 }
1203
1204 // calculate number of pages
1205 $pages = intval($this->max_count / $this->getLimit());
1206
1207 // add a page if a rest remains
1208 if (($this->max_count % $this->getLimit())) {
1209 $pages++;
1210 }
1211
1212 // show next link (if not last page)
1213 if (!(($this->getOffset() / $this->getLimit())==($pages-1)) && ($pages!=1)) {
1214 $newoffset = $this->getOffset() + $this->getLimit();
1215
1216 $ilCtrl->setParameterByClass(
1217 "ilcolumngui",
1218 $this->getNavParameter(),
1219 "::" . $newoffset
1220 );
1221
1222 // ajax link
1223 $ilCtrl->setParameterByClass(
1224 "ilcolumngui",
1225 "block_id",
1226 "block_" . $this->getBlockType() . "_" . $this->block_id
1227 );
1228 //$this->tpl->setCurrentBlock("pnonclick");
1229 $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1230 $onclick = $ilCtrl->getLinkTargetByClass(
1231 "ilcolumngui",
1232 "updateBlock",
1233 "",
1234 true
1235 );
1236 //echo "-".$onclick."-";
1237 //$this->tpl->parseCurrentBlock();
1238 $ilCtrl->setParameterByClass(
1239 "ilcolumngui",
1240 "block_id",
1241 ""
1242 );
1243
1244 // normal link
1245 $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1246 $text = $lng->txt("next");
1247
1248 $this->addFooterLink($text, $href, $onclick, $block_id, true);
1249 }
1250 $ilCtrl->setParameterByClass(
1251 "ilcolumngui",
1252 $this->getNavParameter(),
1253 ""
1254 );
1255 return true;
1256 } else {
1257 return false;
1258 }
1259 }
1260
1266 public function fillFooterLinks($a_top = false, $a_numinfo = "")
1267 {
1268 $first = true;
1269 $flinks = $this->getFooterLinks();
1270
1271 $prefix = ($a_top) ? "top" : "foot";
1272
1273 $has_link = false;
1274
1275 $omit_separator = false;
1276 foreach ($flinks as $flink) {
1277 if ($flink["top"] != $a_top) {
1278 continue;
1279 }
1280
1281 if (!$a_top) {
1282 if ($flink["onclick"]) {
1283 $flink["onclick"] = "ilBlockJSHandler('" . $flink["block_id"] .
1284 "','" . $flink["onclick"] . "')";
1285 }
1286 $this->dropdown[] = $flink;
1287 continue;
1288 }
1289
1290 $has_link = true;
1291
1292 if (!$first && !$omit_separator) {
1293 $this->tpl->touchBlock($prefix . "_delim");
1294 $this->tpl->touchBlock($prefix . "_item");
1295 }
1296
1297 // ajax link
1298 if ($flink["onclick"] != "") {
1299 $this->tpl->setCurrentBlock($prefix . "_onclick");
1300 $this->tpl->setVariable(
1301 "OC_BLOCK_ID",
1302 $flink["block_id"]
1303 );
1304 $this->tpl->setVariable(
1305 "OC_HREF",
1306 $flink["onclick"]
1307 );
1308 $this->tpl->parseCurrentBlock();
1309 }
1310
1311 // normal link
1312 if ($flink["href"] != "") {
1313 // normal link
1314 $this->tpl->setCurrentBlock($prefix . "_link");
1315 $this->tpl->setVariable(
1316 "FHREF",
1317 $flink["href"]
1318 );
1319 $this->tpl->setVariable("FLINK", $flink["text"]);
1320 $this->tpl->parseCurrentBlock();
1321 $this->tpl->touchBlock($prefix . "_item");
1322 } else {
1323 $this->tpl->setCurrentBlock($prefix . "_text");
1324 $this->tpl->setVariable("FTEXT", $flink["text"]);
1325 $this->tpl->parseCurrentBlock();
1326 $this->tpl->touchBlock($prefix . "_item");
1327 }
1328
1329 $first = false;
1330 $omit_separator = $flink["omit_separator"];
1331 }
1332
1333 if ($a_numinfo != "" && $has_link) {
1334 $this->tpl->setVariable("NUMINFO", $a_numinfo);
1335 $first = false;
1336 }
1337
1338 /*
1339 if (!$first)
1340 {
1341 $this->tpl->setVariable("PCOLSPAN", $this->getColSpan());
1342 $this->tpl->setCurrentBlock($prefix."_row");
1343 $this->tpl->parseCurrentBlock();
1344 }
1345 */
1346 }
1347
1351 public function fillDetailRow()
1352 {
1354 $lng = $this->lng;
1355
1356 if ($this->enabledetailrow == false) {
1357 return;
1358 }
1359
1360 $start = ($this->detail_min < 1)
1361 ? $start = 1
1362 : $this->detail_min;
1363
1364 $end = ($this->detail_max < $this->detail_min)
1365 ? $this->detail_min
1366 : $this->detail_max;
1367
1368 $settings = array();
1369 for ($i = $start; $i <= $end; $i++) {
1370 $settings[] = $i;
1371 }
1372
1373 if ($end > $start) {
1374 foreach ($settings as $i) {
1375 if (($i > $start && $i > 1)) {
1376 //$this->tpl->touchBlock("det_delim");
1377 //$this->tpl->touchBlock("det_item");
1378 }
1379 // if ($i != $this->getCurrentDetailLevel())
1380 // {
1381 $ilCtrl->setParameterByClass(
1382 "ilcolumngui",
1383 $this->getDetailParameter(),
1384 $i
1385 );
1386
1387 $onclick = $onclick_id = "";
1388
1389 // ajax link
1390 if ($i > 0) {
1391 $ilCtrl->setParameterByClass(
1392 "ilcolumngui",
1393 "block_id",
1394 "block_" . $this->getBlockType() . "_" . $this->block_id
1395 );
1396 $onclick = $ilCtrl->getLinkTargetByClass(
1397 "ilcolumngui",
1398 "updateBlock",
1399 "",
1400 true
1401 );
1402 $onclick_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1403 $ilCtrl->setParameterByClass(
1404 "ilcolumngui",
1405 "block_id",
1406 ""
1407 );
1408 }
1409
1410 // normal link
1411 //$icon = ilUtil::getImagePath("details".$i.".svg");
1412 $text = $lng->txt("details") . " " . $i;
1413 $url = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1414
1415 if ($onclick) {
1416 $onclick = "ilBlockJSHandler('" . $onclick_id . "','" . $onclick . "')";
1417 }
1418
1419 $checked = ($i == $this->getCurrentDetailLevel());
1420 $this->dropdown[] = array("text" => $text,
1421 "image" => $icon,
1422 "href" => $url,
1423 "onclick" => $onclick,
1424 "checked" => $checked);
1425 // }
1426 }
1427
1428 // info + icon in detail row
1429 if ($this->getFooterInfo(true) != "") {
1430 $this->tpl->setCurrentBlock("det_info");
1431 $this->tpl->setVariable("INFO_TEXT", $this->getFooterInfo(true));
1432 $this->tpl->setVariable("ALT_DET_INFO", $lng->txt("info_short"));
1433 $this->tpl->setVariable("DI_BLOCK_ID", $this->getBlockType() . "_" . $this->getBlockId());
1434 $this->tpl->setVariable("IMG_DET_INFO", ilUtil::getImagePath("icon_info.svg"));
1435 $this->tpl->parseCurrentBlock();
1436 }
1437
1438 /*
1439 $this->tpl->setCurrentBlock("detail_setting");
1440 $this->tpl->setVariable("TXT_DETAILS", $lng->txt("details"));
1441 $this->tpl->setVariable("DCOLSPAN", $this->getColSpan());
1442 $this->tpl->parseCurrentBlock();
1443 */
1444
1445 $ilCtrl->setParameterByClass(
1446 "ilcolumngui",
1447 $this->getDetailParameter(),
1448 ""
1449 );
1450 }
1451 }
1452
1457 protected function preloadData(array $data)
1458 {
1459 }
1460}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_SCREEN_SIDE
User interface class for advanced drop-down selection lists.
This class represents a block method of a block.
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setLimit($a_limit)
Set Limit.
getBlockCommands()
Get Block commands.
setImage($a_image)
Set Image.
fillHeaderCommands()
Fill header commands block.
getOffset()
Get Offset.
setFooterInfo($a_footerinfo, $a_hide_and_icon=false)
Set Footer Info.
getCurrentDetailLevel()
Get Current Detail Level.
getEnableDetailRow()
Get EnableDetailRow.
getBlockId()
Get Block Id.
getImage()
Get Image.
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
addFooterLink( $a_text, $a_href="", $a_onclick="", $a_block_id="", $a_top=false, $a_omit_separator=false, $a_checked=false)
Add a footer text/link.
setSubtitle($a_subtitle)
Set Subtitle.
static isRepositoryObject()
setData($a_data)
Set Data.
setRefId($a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
fillDetailRow()
Fill Detail Setting Row.
getRepositoryMode()
Get RepositoryMode.
__construct()
Constructor.
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
getAdminCommands()
Get Administration Commmands.
getHeaderCommands()
Get Header Block commands.
addHeaderCommand($a_href, $a_text, $a_as_close=false)
Add Header Block Command.
getTitle()
Get Title.
preloadData(array $data)
Can be overwritten in subclasses.
fillHeaderTitleBlock()
Fill header title block (title and.
fillDataSection()
Standard implementation for row based data.
static getScreenMode()
Get Screen Mode for current command.
getBigMode()
Get Big Mode.
setOffset($a_offset)
Set Offset.
setBigMode($a_bigmode)
Set Big Mode.
getProperty($a_property)
getRowTemplateDir()
Get Row Template Directory.
getGuiObject()
Get GuiObject.
fillRowColor($a_placeholder="CSS_ROW")
getFooterLinks()
Get footer links.
getFooterInfo($a_hide_and_icon=false)
Get Footer Info.
addHeaderLink($a_href, $a_text, $status=true)
getRowTemplateName()
Get Row Template Name.
getEnableEdit()
Get EnableEdit.
setEnableEdit($a_enableedit)
Set EnableEdit.
setColSpan($a_colspan)
Set Columns Span.
setTitle($a_title)
Set Title.
setAdminCommands($a_admincommands)
Set Administration Commmands.
setBlockId($a_block_id=0)
Set Block Id.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
addBlockCommand( $a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
getColSpan()
Get Columns Span.
handleDetailLevel()
Handle read/write current detail level.
getEnableNumInfo()
Get Enable Item Number Info.
setCurrentDetailLevel($a_currentdetaillevel)
Set Current Detail Level.
getLimit()
Get Limit.
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
fillPreviousNext()
Fill previous/next row.
setGuiObject(&$a_gui_object)
Set GuiObject.
clearFooterLinks()
Clear footer links.
setProperties($a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
getData()
Get Data.
static getBlockType()
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
getHTML()
Handle config status.
setPreviousNextLinks()
Get previous/next linkbar.
setProperty($a_property, $a_value)
getSubtitle()
Get Subtitle.
static _writeDetailLevel($a_type, $a_value, $a_user=0, $a_block_id=0)
Write detail level to database.
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
static _lookupType($a_id, $a_reference=false)
lookup object type
special template class to simplify handling of ITX/PEAR
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
$counter
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
global $ilCtrl
Definition: ilias.php:18
$end
Definition: saml1-acs.php:18
$url
global $DIC
Definition: saml.php:7
$this data['403_header']
$ilUser
Definition: imgupload.php:18
$a_content
Definition: workflow.php:93
$text
Definition: errorreport.php:18