ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
12 abstract class ilBlockGUI
13 {
17  abstract public function getBlockType() : string;
18 
24  abstract protected function isRepositoryObject() : bool;
25 
26  protected $data = array();
27  protected $colspan = 1;
28  protected $enablenuminfo = true;
29  protected $detail_min = 0;
30  protected $detail_max = 0;
31  protected $bigmode = false;
32  protected $footer_links = array();
33  protected $block_id = 0;
34  protected $header_commands = array();
35  protected $allow_moving = true;
36  protected $move = array("left" => false, "right" => false, "up" => false, "down" => false);
37  protected $enabledetailrow = true;
38  protected $header_links = array();
39  protected $footerinfo = false;
40  protected $footerinfo_icon = false;
41  protected $block_commands = array();
42  protected $max_count = false;
43  protected $close_command = false;
44  protected $image = false;
45  protected $property = false;
46  protected $nav_value = "";
47  protected $css_row = "";
48 
49  protected $dropdown;
50 
54  protected $tpl;
55 
59  protected $main_tpl;
60 
64  protected $user;
65 
69  protected $ctrl;
70 
74  protected $access;
75 
79  protected $lng;
80 
84  protected $obj_def;
85 
91  public function __construct()
92  {
93  global $DIC;
94 
95  $this->user = $DIC->user();
96  $this->ctrl = $DIC->ctrl();
97  $this->access = $DIC->access();
98  $this->lng = $DIC->language();
99  $this->main_tpl = $DIC["tpl"];
100  $this->obj_def = $DIC["objDefinition"];
101 
102  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
104  $this->main_tpl->addJavaScript("./Services/Block/js/ilblockcallback.js");
105 
106  $this->setLimit($this->user->getPref("hits_per_page"));
107  }
108 
109  public function addHeaderLink($a_href, $a_text, $status = true)
110  {
111  $this->header_links[] =
112  array('href' => $a_href, 'text' => $a_text, 'status' => (bool) $status);
113  }
114 
115  public function getHeaderLinks()
116  {
117  return $this->header_links;
118  }
119 
125  public function setData($a_data)
126  {
127  $this->data = $a_data;
128  }
129 
135  public function getData()
136  {
137  return $this->data;
138  }
139 
145  public function setBigMode($a_bigmode)
146  {
147  $this->bigmode = $a_bigmode;
148  }
149 
155  public function getBigMode()
156  {
157  return $this->bigmode;
158  }
159 
165  public function setBlockId($a_block_id = 0)
166  {
167  $this->block_id = $a_block_id;
168  }
169 
175  public function getBlockId()
176  {
177  return $this->block_id;
178  }
179 
186  public function setAvailableDetailLevels($a_max, $a_min = 0)
187  {
188  $this->detail_min = $a_min;
189  $this->detail_max = $a_max;
190  $this->handleDetailLevel();
191  }
192 
198  public function setCurrentDetailLevel($a_currentdetaillevel)
199  {
200  $this->currentdetaillevel = $a_currentdetaillevel;
201  }
202 
210  public function setGuiObject(&$a_gui_object)
211  {
212  $this->gui_object = $a_gui_object;
213  }
214 
220  public function getGuiObject()
221  {
222  return $this->gui_object;
223  }
224 
230  public function getCurrentDetailLevel()
231  {
232  return $this->currentdetaillevel;
233  }
234 
240  public function setTitle($a_title)
241  {
242  $this->title = $a_title;
243  }
244 
250  public function getTitle()
251  {
252  return $this->title;
253  }
254 
260  public function setImage($a_image)
261  {
262  $this->image = $a_image;
263  }
264 
270  public function getImage()
271  {
272  return $this->image;
273  }
274 
280  public function setOffset($a_offset)
281  {
282  $this->offset = $a_offset;
283  }
284 
290  public function getOffset()
291  {
292  return $this->offset;
293  }
294 
295  public function correctOffset()
296  {
297  if (!($this->offset < $this->max_count)) {
298  $this->setOffset(0);
299  }
300  }
301 
307  public function setLimit($a_limit)
308  {
309  $this->limit = $a_limit;
310  }
311 
317  public function getLimit()
318  {
319  return $this->limit;
320  }
321 
327  public function setEnableEdit($a_enableedit)
328  {
329  $this->enableedit = $a_enableedit;
330  }
331 
337  public function getEnableEdit()
338  {
339  return $this->enableedit;
340  }
341 
347  public function setRepositoryMode($a_repositorymode)
348  {
349  $this->repositorymode = $a_repositorymode;
350  }
351 
357  public function getRepositoryMode()
358  {
359  return $this->repositorymode;
360  }
361 
367  public function setFooterInfo($a_footerinfo, $a_hide_and_icon = false)
368  {
369  if ($a_hide_and_icon) {
370  $this->footerinfo_icon = $a_footerinfo;
371  } else {
372  $this->footerinfo = $a_footerinfo;
373  }
374  }
375 
381  public function getFooterInfo($a_hide_and_icon = false)
382  {
383  if ($a_hide_and_icon) {
384  return $this->footerinfo_icon;
385  } else {
386  return $this->footerinfo;
387  }
388  }
389 
395  public function setSubtitle($a_subtitle)
396  {
397  $this->subtitle = $a_subtitle;
398  }
399 
405  public function getSubtitle()
406  {
407  return $this->subtitle;
408  }
409 
415  public function setRefId($a_refid)
416  {
417  $this->refid = $a_refid;
418  }
419 
425  public function getRefId()
426  {
427  return $this->refid;
428  }
429 
435  public function setAdminCommands($a_admincommands)
436  {
437  $this->admincommands = $a_admincommands;
438  }
439 
445  public function getAdminCommands()
446  {
447  return $this->admincommands;
448  }
449 
455  public function setColSpan($a_colspan)
456  {
457  $this->colspan = $a_colspan;
458  }
459 
465  public function getColSpan()
466  {
467  return $this->colspan;
468  }
469 
475  public function setEnableDetailRow($a_enabledetailrow)
476  {
477  $this->enabledetailrow = $a_enabledetailrow;
478  }
479 
485  public function getEnableDetailRow()
486  {
487  return $this->enabledetailrow;
488  }
489 
490 
496  public function setEnableNumInfo($a_enablenuminfo)
497  {
498  $this->enablenuminfo = $a_enablenuminfo;
499  }
500 
506  public function getEnableNumInfo()
507  {
508  return $this->enablenuminfo;
509  }
510 
517  public function setProperties($a_properties)
518  {
519  $this->property = $a_properties;
520  }
521 
522  public function getProperty($a_property)
523  {
524  return $this->property[$a_property];
525  }
526 
527  public function setProperty($a_property, $a_value)
528  {
529  $this->property[$a_property] = $a_value;
530  }
531 
537  public function setRowTemplate($a_rowtemplatename, $a_rowtemplatedir = "")
538  {
539  $this->rowtemplatename = $a_rowtemplatename;
540  $this->rowtemplatedir = $a_rowtemplatedir;
541  }
542 
543  final public function getNavParameter()
544  {
545  return $this->getBlockType() . "_" . $this->getBlockId() . "_blnav";
546  }
547 
548  final public function getDetailParameter()
549  {
550  return $this->getBlockType() . "_" . $this->getBlockId() . "_bldet";
551  }
552 
553  final public function getConfigParameter()
554  {
555  return $this->getBlockType() . "_" . $this->getBlockId() . "_blconf";
556  }
557 
558  final public function getMoveParameter()
559  {
560  return $this->getBlockType() . "_" . $this->getBlockId() . "_blmove";
561  }
562 
568  public function getRowTemplateName()
569  {
570  return $this->rowtemplatename;
571  }
572 
578  public function getRowTemplateDir()
579  {
580  return $this->rowtemplatedir;
581  }
582 
589  public function addBlockCommand(
590  $a_href,
591  $a_text,
592  $a_target = "",
593  $a_img = "",
594  $a_right_aligned = false,
595  $a_checked = false,
596  $a_html = ""
597  ) {
598  return $this->block_commands[] =
599  array("href" => $a_href,
600  "text" => $a_text, "target" => $a_target, "img" => $a_img,
601  "right" => $a_right_aligned, "checked" => $a_checked, "html" => $a_html);
602  }
603 
609  public function getBlockCommands()
610  {
611  return $this->block_commands;
612  }
613 
620  public function addHeaderCommand($a_href, $a_text, $a_as_close = false)
621  {
622  if ($a_as_close) {
623  $this->close_command = $a_href;
624  } else {
625  $this->header_commands[] =
626  array("href" => $a_href,
627  "text" => $a_text);
628  }
629  }
630 
636  public function getHeaderCommands()
637  {
638  return $this->header_commands;
639  }
640 
644  public function addFooterLink(
645  $a_text,
646  $a_href = "",
647  $a_onclick = "",
648  $a_block_id = "",
649  $a_top = false,
650  $a_omit_separator = false,
651  $a_checked = false
652  ) {
653  $this->footer_links[] = array(
654  "text" => $a_text,
655  "href" => $a_href,
656  "onclick" => $a_onclick,
657  "block_id" => $a_block_id,
658  "top" => $a_top,
659  "omit_separator" => $a_omit_separator,
660  "checked" => $a_checked);
661  }
662 
666  public function getFooterLinks()
667  {
668  return $this->footer_links;
669  }
670 
674  public function clearFooterLinks()
675  {
676  $this->footer_links = array();
677  }
678 
682  public static function getScreenMode()
683  {
684  return IL_SCREEN_SIDE;
685  }
686 
690  public function handleDetailLevel()
691  {
694  // set/get detail level
695  if ($this->detail_max > $this->detail_min) {
696  include_once("Services/Block/classes/class.ilBlockSetting.php");
697  if (isset($_GET[$this->getDetailParameter()])) {
699  $this->getBlockType(),
700  $_GET[$this->getDetailParameter()],
701  $ilUser->getId(),
703  );
705  if ((int) $_GET[$this->getDetailParameter()] == 0) {
706  $ilCtrl->redirectByClass("ilcolumngui", "");
707  }
708  } else {
710  $this->getBlockType(),
711  $ilUser->getId(),
713  ));
714  }
715  }
716  }
717 
721  /*
722  function handleConfigStatus()
723  {
724  $this->config_mode = false;
725 
726  if ($_GET[$this->getConfigParameter()] == "toggle")
727  {
728  if ($_SESSION[$this->getConfigParameter()] == "on")
729  {
730  $_SESSION[$this->getConfigParameter()] = "off";
731  }
732  else
733  {
734  $_SESSION[$this->getConfigParameter()] = "on";
735  }
736  }
737  if ($_SESSION[$this->getConfigParameter()] == "on")
738  {
739  $this->config_mode = true;
740  }
741  }
742  */
743 
747  public function getHTML()
748  {
750  $lng = $this->lng;
751  $ilAccess = $this->access;
753  $objDefinition = $this->obj_def;
754 
755  if ($this->isRepositoryObject()) {
756  if (!$ilAccess->checkAccess("read", "", $this->getRefId())) {
757  return "";
758  }
759  }
760 
761  $this->tpl = new ilTemplate("tpl.block.html", true, true, "Services/Block");
762 
763  // $this->handleConfigStatus();
764 
765  $this->fillDataSection();
766 
767  if ($this->getRepositoryMode() && $this->isRepositoryObject()) {
768  // #10993
769  if ($this->getAdminCommands()) {
770  $this->tpl->setCurrentBlock("block_check");
771  $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
772  $this->tpl->parseCurrentBlock();
773  }
774 
775  if ($ilAccess->checkAccess("delete", "", $this->getRefId())) {
776  $this->addBlockCommand(
777  "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=delete" .
778  "&item_ref_id=" . $this->getRefId(),
779  $lng->txt("delete")
780  );
781 
782  // see ilObjectListGUI::insertCutCommand();
783  $this->addBlockCommand(
784  "ilias.php?baseClass=ilRepositoryGUI&ref_id=" . $_GET["ref_id"] . "&cmd=cut" .
785  "&item_ref_id=" . $this->getRefId(),
786  $lng->txt("move")
787  );
788  }
789 
790  // #14595 - see ilObjectListGUI::insertCopyCommand()
791  if ($ilAccess->checkAccess("copy", "", $this->getRefId())) {
792  $parent_type = ilObject::_lookupType($_GET["ref_id"], true);
793  $parent_gui = "ilObj" . $objDefinition->getClassName($parent_type) . "GUI";
794 
795  $ilCtrl->setParameterByClass("ilobjectcopygui", "source_id", $this->getRefId());
796  $copy_cmd = $ilCtrl->getLinkTargetByClass(
797  array("ilrepositorygui", $parent_gui, "ilobjectcopygui"),
798  "initTargetSelection"
799  );
800 
801  // see ilObjectListGUI::insertCopyCommand();
802  $this->addBlockCommand(
803  $copy_cmd,
804  $lng->txt("copy")
805  );
806  }
807  }
808 
809  // footer info
810  if ($this->getFooterInfo() != "") {
811  $this->tpl->setCurrentBlock("footer_information");
812  $this->tpl->setVariable("FOOTER_INFO", $this->getFooterInfo());
813  $this->tpl->setVariable("FICOLSPAN", $this->getColSpan());
814  $this->tpl->parseCurrentBlock();
815  }
816 
817  $this->dropdown = array();
818 
819  // commands
820  if (count($this->getBlockCommands()) > 0) {
821  $has_block_command = false;
822 
823  foreach ($this->getBlockCommands() as $command) {
824  if (!$command["img"] && !$command["html"]) {
825  $this->dropdown[] = $command;
826  continue;
827  }
828 
829  $has_block_command = true;
830 
831  if ($command["target"] != "") {
832  $this->tpl->setCurrentBlock("bc_target");
833  $this->tpl->setVariable("CMD_TARGET", $command["target"]);
834  $this->tpl->parseCurrentBlock();
835  }
836 
837  if ($command["img"] != "") {
838  $this->tpl->setCurrentBlock("bc_image");
839  $this->tpl->setVariable("SRC_BC", $command["img"]);
840  $this->tpl->setVariable("ALT_BC", $command["text"]);
841  $this->tpl->parseCurrentBlock();
842  $this->tpl->setCurrentBlock("block_command");
843  } elseif ($command["html"] != "") {
844  if ($command['href'] !== '') {
845  $this->tpl->setCurrentBlock("bc_html");
846  $this->tpl->setVariable("HTML", $command["html"]);
847  $this->tpl->parseCurrentBlock();
848  $this->tpl->setCurrentBlock("block_command");
849  } else {
850  $this->tpl->setCurrentBlock('bc_html_nohref');
851  $this->tpl->setVariable('HTML_NOHREF', $command['html']);
852  $this->tpl->parseCurrentBlock();
853  $this->tpl->setCurrentBlock("block_command");
854  }
855  } else {
856  $this->tpl->setCurrentBlock("block_command");
857  $this->tpl->setVariable("CMD_TEXT", $command["text"]);
858  $this->tpl->setVariable("BC_CLASS", 'class="il_ContainerItemCommand"');
859  }
860 
861  if ($command['href'] !== '') {
862  $this->tpl->setVariable("CMD_HREF", $command["href"]);
863  }
864  $this->tpl->parseCurrentBlock();
865  }
866 
867  if ($has_block_command) {
868  $this->tpl->setCurrentBlock("block_commands");
869  $this->tpl->setVariable("CCOLSPAN", $this->getColSpan());
870  $this->tpl->parseCurrentBlock();
871  }
872  }
873 
874  // fill previous next
875  $this->fillPreviousNext();
876 
877  // fill footer
878  $this->fillFooter();
879 
880  // fill row for setting details
881  $this->fillDetailRow();
882 
883  // header links
884  if (count($this->getHeaderLinks())) {
885  $counter = 0;
886  foreach ($this->getHeaderLinks() as $command) {
887  if ($counter > 0) {
888  $this->tpl->setCurrentBlock('head_delim');
889  $this->tpl->touchBlock('head_delim');
890  $this->tpl->parseCurrentBlock();
891  }
892  if ($command['status'] == true) {
893  $this->tpl->setCurrentBlock('head_link');
894  $this->tpl->setVariable('HHREF', $command['href']);
895  $this->tpl->setVariable('HLINK', $command['text']);
896  $this->tpl->parseCurrentBlock();
897  } else {
898  $this->tpl->setCurrentBlock('head_text');
899  $this->tpl->setVariable('HTEXT', $command['text']);
900  $this->tpl->parseCurrentBlock();
901  }
902 
903  $this->tpl->setCurrentBlock('head_item');
904  $this->tpl->parseCurrentBlock();
905 
906  ++$counter;
907  }
908 
909  $this->tpl->setCurrentBlock('header_links');
910  $this->tpl->parseCurrentBlock();
911  }
912 
913  // for screen readers we first output the title and the commands
914  // (e.g. close icon afterwards), otherwise we first output the
915  // header commands, since we want to have the close icon top right
916  // and not floated after the title
917  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization")) {
918  $this->fillHeaderTitleBlock();
919  $this->fillHeaderCommands();
920  } else {
921  $this->fillHeaderCommands();
922  $this->fillHeaderTitleBlock();
923  }
924 
925  $this->tpl->setVariable("COLSPAN", $this->getColSpan());
926  if ($this->getBigMode()) {
927  $this->tpl->touchBlock("hclassb");
928  } else {
929  $this->tpl->touchBlock("hclass");
930  }
931 
932  if ($ilCtrl->isAsynch()) {
933  // return without div wrapper
934  echo $this->tpl->getAsynch();
935  } else {
936  // return incl. wrapping div with id
937  return '<div id="' . "block_" . $this->getBlockType() . "_" . $this->block_id . '">' .
938  $this->tpl->get() . '</div>';
939  }
940  }
941 
945  public function fillHeaderCommands()
946  {
947  $lng = $this->lng;
949 
950 
951  // header commands
952  if (count($this->getHeaderCommands()) > 0 ||
953  ($this->detail_max > $this->detail_min && $this->detail_min == 0) ||
954  $this->close_command != "") {
955  foreach ($this->getHeaderCommands() as $command) {
956  $this->tpl->setCurrentBlock("header_command");
957  $this->tpl->setVariable("HREF_HCOMM", $command["href"]);
958  $this->tpl->setVariable("TXT_HCOMM", $command["text"]);
959  $this->tpl->parseCurrentBlock();
960  }
961 
962  // close button
963  if (($this->detail_max > $this->detail_min && $this->detail_min == 0 &&
964  !$this->getRepositoryMode())
965  ||
966  $this->close_command != "") {
967  $alt = $lng->txt("hide");
968  if ($this->close_command != "") {
970  } else {
971  $ilCtrl->setParameterByClass(
972  "ilcolumngui",
973  $this->getDetailParameter(),
974  "0"
975  );
976  $url = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
977  $ilCtrl->setParameterByClass(
978  "ilcolumngui",
979  $this->getDetailParameter(),
980  ""
981  );
982  }
983 
984  $this->dropdown[] = array("text" => $alt,
985  "image" => $img,
986  "href" => $url);
987  }
988 
989  $this->tpl->setCurrentBlock("header_commands");
990  $this->tpl->parseCurrentBlock();
991  }
992 
993  // adv selection gui
994  include_once "Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php";
996  $dropdown->setUseImages(true);
999  $dropdown->setId("block_dd_" . $this->getBlockType() . "_" . $this->block_id);
1000  foreach ($this->dropdown as $item) {
1001  if ($item["href"] || $item["onclick"]) {
1002  if ($item["checked"]) {
1003  $item["image"] = ilUtil::getImagePath("icon_checked.svg");
1004  }
1005  $dropdown->addItem(
1006  $item["text"],
1007  "",
1008  $item["href"],
1009  $item["image"],
1010  $item["text"],
1011  "",
1012  "",
1013  false,
1014  $item["onclick"]
1015  );
1016  }
1017  }
1018  $dropdown = $dropdown->getHTML();
1019  $this->tpl->setCurrentBlock("header_dropdown");
1020  $this->tpl->setVariable("ADV_DROPDOWN", $dropdown);
1021  $this->tpl->parseCurrentBlock();
1022 
1023  $this->tpl->setCurrentBlock("hitem");
1024  $this->tpl->parseCurrentBlock();
1025  }
1026 
1027 
1031  public function fillHeaderTitleBlock()
1032  {
1033  $lng = $this->lng;
1034 
1035  // image
1036  if ($this->getImage() != "") {
1037  $this->tpl->setCurrentBlock("block_img");
1038  $this->tpl->setVariable("IMG_BLOCK", $this->getImage());
1039  $this->tpl->setVariable(
1040  "IMID",
1041  "block_" . $this->getBlockType() . "_" . $this->block_id
1042  );
1043  $this->tpl->setVariable(
1044  "IMG_ALT",
1045  str_replace(array("'",'"'), "", strip_tags($lng->txt("icon") . " " . $this->getTitle()))
1046  );
1047  $this->tpl->parseCurrentBlock();
1048  }
1049 
1050  // header title
1051  $this->tpl->setCurrentBlock("header_title");
1052  $this->tpl->setVariable(
1053  "BTID",
1054  "block_" . $this->getBlockType() . "_" . $this->block_id
1055  );
1056  $this->tpl->setVariable(
1057  "BLOCK_TITLE",
1058  $this->getTitle()
1059  );
1060  $this->tpl->setVariable(
1061  "TXT_BLOCK",
1062  $lng->txt("block")
1063  );
1064  $this->tpl->parseCurrentBlock();
1065 
1066  $this->tpl->setCurrentBlock("hitem");
1067  $this->tpl->parseCurrentBlock();
1068  }
1069 
1070 
1074  public function setDataSection($a_content)
1075  {
1076  $this->tpl->setCurrentBlock("data_section");
1077  $this->tpl->setVariable("DATA", $a_content);
1078  $this->tpl->parseCurrentBlock();
1079  $this->tpl->setVariable("BLOCK_ROW", "");
1080  }
1081 
1086  public function fillDataSection()
1087  {
1088  $this->nav_value = (isset($_POST[$this->getNavParameter()]) && $_POST[$this->getNavParameter()] != "")
1089  ? $_POST[$this->getNavParameter()]
1090  : (isset($_GET[$this->getNavParameter()]) ? $_GET[$this->getNavParameter()] : $this->nav_value);
1091  $this->nav_value = ($this->nav_value == "" && isset($_SESSION[$this->getNavParameter()]))
1092  ? $_SESSION[$this->getNavParameter()]
1093  : $this->nav_value;
1094 
1096 
1097  $nav = explode(":", $this->nav_value);
1098  if (isset($nav[2])) {
1099  $this->setOffset($nav[2]);
1100  } else {
1101  $this->setOffset(0);
1102  }
1103 
1104  // data
1105  $this->tpl->addBlockFile(
1106  "BLOCK_ROW",
1107  "block_row",
1108  $this->getRowTemplateName(),
1109  $this->getRowTemplateDir()
1110  );
1111 
1112  $data = $this->getData();
1113  $this->max_count = count($data);
1114  $this->correctOffset();
1115  $data = array_slice($data, $this->getOffset(), $this->getLimit());
1116 
1117  $this->preloadData($data);
1118 
1119  foreach ($data as $record) {
1120  $this->tpl->setCurrentBlock("block_row");
1121  $this->fillRowColor();
1122  $this->fillRow($record);
1123  $this->tpl->setCurrentBlock("block_row");
1124  $this->tpl->parseCurrentBlock();
1125  }
1126  }
1127 
1128  public function fillRow($a_set)
1129  {
1130  foreach ($a_set as $key => $value) {
1131  $this->tpl->setVariable("VAL_" . strtoupper($key), $value);
1132  }
1133  }
1134 
1135  public function fillFooter()
1136  {
1137  }
1138 
1139  final protected function fillRowColor($a_placeholder = "CSS_ROW")
1140  {
1141  $this->css_row = ($this->css_row != "ilBlockRow1")
1142  ? "ilBlockRow1"
1143  : "ilBlockRow2";
1144  $this->tpl->setVariable($a_placeholder, $this->css_row);
1145  }
1146 
1150  public function fillPreviousNext()
1151  {
1152  $lng = $this->lng;
1153 
1154  // table pn numinfo
1155  $numinfo = "";
1156  if ($this->getEnableNumInfo() && $this->max_count > 0) {
1157  $start = $this->getOffset() + 1; // compute num info
1158  $end = $this->getOffset() + $this->getLimit();
1159 
1160  if ($end > $this->max_count or $this->getLimit() == 0) {
1162  }
1163 
1164  $numinfo = "(" . $start . "-" . $end . " " . strtolower($lng->txt("of")) . " " . $this->max_count . ")";
1165  }
1166 
1167  $this->setPreviousNextLinks();
1168  $this->fillFooterLinks(true, $numinfo);
1169  }
1170 
1178  public function setPreviousNextLinks()
1179  {
1180  $ilCtrl = $this->ctrl;
1181  $lng = $this->lng;
1182 
1183  // if more entries then entries per page -> show link bar
1184  if ($this->max_count > $this->getLimit() && ($this->getLimit() != 0)) {
1185  // previous link
1186  if ($this->getOffset() >= 1) {
1187  $prevoffset = $this->getOffset() - $this->getLimit();
1188 
1189  $ilCtrl->setParameterByClass(
1190  "ilcolumngui",
1191  $this->getNavParameter(),
1192  "::" . $prevoffset
1193  );
1194 
1195  // ajax link
1196  $ilCtrl->setParameterByClass(
1197  "ilcolumngui",
1198  "block_id",
1199  "block_" . $this->getBlockType() . "_" . $this->block_id
1200  );
1201  $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1202  $onclick = $ilCtrl->getLinkTargetByClass(
1203  "ilcolumngui",
1204  "updateBlock",
1205  "",
1206  true
1207  );
1208  $ilCtrl->setParameterByClass(
1209  "ilcolumngui",
1210  "block_id",
1211  ""
1212  );
1213 
1214  // normal link
1215  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1216  $text = $lng->txt("previous");
1217 
1218  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1219  }
1220 
1221  // calculate number of pages
1222  $pages = intval($this->max_count / $this->getLimit());
1223 
1224  // add a page if a rest remains
1225  if (($this->max_count % $this->getLimit())) {
1226  $pages++;
1227  }
1228 
1229  // show next link (if not last page)
1230  if (!(($this->getOffset() / $this->getLimit()) == ($pages - 1)) && ($pages != 1)) {
1231  $newoffset = $this->getOffset() + $this->getLimit();
1232 
1233  $ilCtrl->setParameterByClass(
1234  "ilcolumngui",
1235  $this->getNavParameter(),
1236  "::" . $newoffset
1237  );
1238 
1239  // ajax link
1240  $ilCtrl->setParameterByClass(
1241  "ilcolumngui",
1242  "block_id",
1243  "block_" . $this->getBlockType() . "_" . $this->block_id
1244  );
1245  //$this->tpl->setCurrentBlock("pnonclick");
1246  $block_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1247  $onclick = $ilCtrl->getLinkTargetByClass(
1248  "ilcolumngui",
1249  "updateBlock",
1250  "",
1251  true
1252  );
1253  //echo "-".$onclick."-";
1254  //$this->tpl->parseCurrentBlock();
1255  $ilCtrl->setParameterByClass(
1256  "ilcolumngui",
1257  "block_id",
1258  ""
1259  );
1260 
1261  // normal link
1262  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1263  $text = $lng->txt("next");
1264 
1265  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1266  }
1267  $ilCtrl->setParameterByClass(
1268  "ilcolumngui",
1269  $this->getNavParameter(),
1270  ""
1271  );
1272  return true;
1273  } else {
1274  return false;
1275  }
1276  }
1277 
1283  public function fillFooterLinks($a_top = false, $a_numinfo = "")
1284  {
1285  $first = true;
1286  $flinks = $this->getFooterLinks();
1287 
1288  $prefix = ($a_top) ? "top" : "foot";
1289 
1290  $has_link = false;
1291 
1292  $omit_separator = false;
1293  foreach ($flinks as $flink) {
1294  if ($flink["top"] != $a_top) {
1295  continue;
1296  }
1297 
1298  if (!$a_top) {
1299  if ($flink["onclick"]) {
1300  $flink["onclick"] = "ilBlockJSHandler('" . $flink["block_id"] .
1301  "','" . $flink["onclick"] . "')";
1302  }
1303  $this->dropdown[] = $flink;
1304  continue;
1305  }
1306 
1307  $has_link = true;
1308 
1309  if (!$first && !$omit_separator) {
1310  $this->tpl->touchBlock($prefix . "_delim");
1311  $this->tpl->touchBlock($prefix . "_item");
1312  }
1313 
1314  // ajax link
1315  if ($flink["onclick"] != "") {
1316  $this->tpl->setCurrentBlock($prefix . "_onclick");
1317  $this->tpl->setVariable(
1318  "OC_BLOCK_ID",
1319  $flink["block_id"]
1320  );
1321  $this->tpl->setVariable(
1322  "OC_HREF",
1323  $flink["onclick"]
1324  );
1325  $this->tpl->parseCurrentBlock();
1326  }
1327 
1328  // normal link
1329  if ($flink["href"] != "") {
1330  // normal link
1331  $this->tpl->setCurrentBlock($prefix . "_link");
1332  $this->tpl->setVariable(
1333  "FHREF",
1334  $flink["href"]
1335  );
1336  $this->tpl->setVariable("FLINK", $flink["text"]);
1337  $this->tpl->parseCurrentBlock();
1338  $this->tpl->touchBlock($prefix . "_item");
1339  } else {
1340  $this->tpl->setCurrentBlock($prefix . "_text");
1341  $this->tpl->setVariable("FTEXT", $flink["text"]);
1342  $this->tpl->parseCurrentBlock();
1343  $this->tpl->touchBlock($prefix . "_item");
1344  }
1345 
1346  $first = false;
1347  $omit_separator = $flink["omit_separator"];
1348  }
1349 
1350  if ($a_numinfo != "" && $has_link) {
1351  $this->tpl->setVariable("NUMINFO", $a_numinfo);
1352  $first = false;
1353  }
1354 
1355  /*
1356  if (!$first)
1357  {
1358  $this->tpl->setVariable("PCOLSPAN", $this->getColSpan());
1359  $this->tpl->setCurrentBlock($prefix."_row");
1360  $this->tpl->parseCurrentBlock();
1361  }
1362  */
1363  }
1364 
1368  public function fillDetailRow()
1369  {
1370  $ilCtrl = $this->ctrl;
1371  $lng = $this->lng;
1372 
1373  if ($this->enabledetailrow == false) {
1374  return;
1375  }
1376 
1377  $start = ($this->detail_min < 1)
1378  ? $start = 1
1379  : $this->detail_min;
1380 
1381  $end = ($this->detail_max < $this->detail_min)
1382  ? $this->detail_min
1383  : $this->detail_max;
1384 
1385  $settings = array();
1386  for ($i = $start; $i <= $end; $i++) {
1387  $settings[] = $i;
1388  }
1389 
1390  if ($end > $start) {
1391  foreach ($settings as $i) {
1392  if (($i > $start && $i > 1)) {
1393  //$this->tpl->touchBlock("det_delim");
1394  //$this->tpl->touchBlock("det_item");
1395  }
1396  // if ($i != $this->getCurrentDetailLevel())
1397  // {
1398  $ilCtrl->setParameterByClass(
1399  "ilcolumngui",
1400  $this->getDetailParameter(),
1401  $i
1402  );
1403 
1404  $onclick = $onclick_id = "";
1405 
1406  // ajax link
1407  if ($i > 0) {
1408  $ilCtrl->setParameterByClass(
1409  "ilcolumngui",
1410  "block_id",
1411  "block_" . $this->getBlockType() . "_" . $this->block_id
1412  );
1413  $onclick = $ilCtrl->getLinkTargetByClass(
1414  "ilcolumngui",
1415  "updateBlock",
1416  "",
1417  true
1418  );
1419  $onclick_id = "block_" . $this->getBlockType() . "_" . $this->block_id;
1420  $ilCtrl->setParameterByClass(
1421  "ilcolumngui",
1422  "block_id",
1423  ""
1424  );
1425  }
1426 
1427  // normal link
1428  //$icon = ilUtil::getImagePath("details".$i.".svg");
1429  $text = $lng->txt("details") . " " . $i;
1430  $url = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1431 
1432  if ($onclick) {
1433  $onclick = "ilBlockJSHandler('" . $onclick_id . "','" . $onclick . "')";
1434  }
1435 
1436  $checked = ($i == $this->getCurrentDetailLevel());
1437  $this->dropdown[] = array("text" => $text,
1438  "image" => $icon,
1439  "href" => $url,
1440  "onclick" => $onclick,
1441  "checked" => $checked);
1442  // }
1443  }
1444 
1445  // info + icon in detail row
1446  if ($this->getFooterInfo(true) != "") {
1447  $this->tpl->setCurrentBlock("det_info");
1448  $this->tpl->setVariable("INFO_TEXT", $this->getFooterInfo(true));
1449  $this->tpl->setVariable("ALT_DET_INFO", $lng->txt("info_short"));
1450  $this->tpl->setVariable("DI_BLOCK_ID", $this->getBlockType() . "_" . $this->getBlockId());
1451  $this->tpl->setVariable("IMG_DET_INFO", ilUtil::getImagePath("icon_info.svg"));
1452  $this->tpl->parseCurrentBlock();
1453  }
1454 
1455  /*
1456  $this->tpl->setCurrentBlock("detail_setting");
1457  $this->tpl->setVariable("TXT_DETAILS", $lng->txt("details"));
1458  $this->tpl->setVariable("DCOLSPAN", $this->getColSpan());
1459  $this->tpl->parseCurrentBlock();
1460  */
1461 
1462  $ilCtrl->setParameterByClass(
1463  "ilcolumngui",
1464  $this->getDetailParameter(),
1465  ""
1466  );
1467  }
1468  }
1469 
1474  protected function preloadData(array $data)
1475  {
1476  }
1477 }
getImage()
Get Image.
clearFooterLinks()
Clear footer links.
getEnableDetailRow()
Get EnableDetailRow.
getFooterLinks()
Get footer links.
setBigMode($a_bigmode)
Set Big Mode.
getRowTemplateDir()
Get Row Template Directory.
static _writeDetailLevel($a_type, $a_value, $a_user=0, $a_block_id=0)
Write detail level to database.
$_SESSION["AccountId"]
global $DIC
Definition: saml.php:7
setDataSection($a_content)
Call this from overwritten fillDataSection(), if standard row based data is not used.
$_GET["client_id"]
setFooterInfo($a_footerinfo, $a_hide_and_icon=false)
Set Footer Info.
static initConnection(ilTemplate $a_main_tpl=null)
Init YUI Connection module.
setProperty($a_property, $a_value)
getLimit()
Get Limit.
getHeaderCommands()
Get Header Block commands.
setProperties($a_properties)
This function is supposed to be used for block type specific properties, that should be inherited thr...
static _lookupDetailLevel($a_type, $a_user=0, $a_block_id=0)
Lookup detail level.
setRefId($a_refid)
Set Ref Id (only used if isRepositoryObject() is true).
fillFooterLinks($a_top=false, $a_numinfo="")
Fill footer links.
setEnableNumInfo($a_enablenuminfo)
Set Enable Item Number Info.
setAdminCommands($a_admincommands)
Set Administration Commmands.
getRepositoryMode()
Get RepositoryMode.
getGuiObject()
Get GuiObject.
user()
Definition: user.php:4
fillRowColor($a_placeholder="CSS_ROW")
fillHeaderTitleBlock()
Fill header title block (title and.
setEnableEdit($a_enableedit)
Set EnableEdit.
global $ilCtrl
Definition: ilias.php:18
$start
Definition: bench.php:8
fillDetailRow()
Fill Detail Setting Row.
setColSpan($a_colspan)
Set Columns Span.
getBlockCommands()
Get Block commands.
setImage($a_image)
Set Image.
setSubtitle($a_subtitle)
Set Subtitle.
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.
fillHeaderCommands()
Fill header commands block.
setTitle($a_title)
Set Title.
getFooterInfo($a_hide_and_icon=false)
Get Footer Info.
addHeaderCommand($a_href, $a_text, $a_as_close=false)
Add Header Block Command.
preloadData(array $data)
Can be overwritten in subclasses.
$a_content
Definition: workflow.php:93
static getScreenMode()
Get Screen Mode for current command.
setBlockId($a_block_id=0)
Set Block Id.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getEnableNumInfo()
Get Enable Item Number Info.
setData($a_data)
Set Data.
setPreviousNextLinks()
Get previous/next linkbar.
special template class to simplify handling of ITX/PEAR
setAvailableDetailLevels($a_max, $a_min=0)
Set Available Detail Levels.
$text
Definition: errorreport.php:18
getBigMode()
Get Big Mode.
setOffset($a_offset)
Set Offset.
addHeaderLink($a_href, $a_text, $status=true)
$ilUser
Definition: imgupload.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
__construct()
Constructor.
getHTML()
Handle config status.
getBlockId()
Get Block Id.
getOffset()
Get Offset.
getAdminCommands()
Get Administration Commmands.
addBlockCommand( $a_href, $a_text, $a_target="", $a_img="", $a_right_aligned=false, $a_checked=false, $a_html="")
Add Block Command.
User interface class for advanced drop-down selection lists.
getData()
Get Data.
setLimit($a_limit)
Set Limit.
getRefId()
Get Ref Id (only used if isRepositoryObject() is true).
getEnableEdit()
Get EnableEdit.
handleDetailLevel()
Handle read/write current detail level.
setRepositoryMode($a_repositorymode)
Set RepositoryMode.
$this data['403_header']
setCurrentDetailLevel($a_currentdetaillevel)
Set Current Detail Level.
fillPreviousNext()
Fill previous/next row.
getColSpan()
Get Columns Span.
getRowTemplateName()
Get Row Template Name.
$i
Definition: disco.tpl.php:19
isRepositoryObject()
Returns whether block has a corresponding repository object.
This class represents a block method of a block.
$url
getSubtitle()
Get Subtitle.
setGuiObject(&$a_gui_object)
Set GuiObject.
fillDataSection()
Standard implementation for row based data.
const IL_SCREEN_SIDE
setRowTemplate($a_rowtemplatename, $a_rowtemplatedir="")
Set Row Template Name.
setEnableDetailRow($a_enabledetailrow)
Set EnableDetailRow.
$key
Definition: croninfo.php:18
$_POST["username"]
getTitle()
Get Title.
getProperty($a_property)
getCurrentDetailLevel()
Get Current Detail Level.