ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilBlockGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
12 abstract class ilBlockGUI
13 {
14  abstract static function getBlockType(); // return block type, e.g. "feed"
15  abstract 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 
46  function ilBlockGUI()
47  {
48  global $ilUser, $tpl, $ilCtrl;
49 
50  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
52  $tpl->addJavaScript("./Services/Block/js/ilblockcallback.js");
53 
54  $this->setLimit($ilUser->getPref("hits_per_page"));
55  }
56 
57  public function addHeaderLink($a_href, $a_text, $status = true)
58  {
59  $this->header_links[] =
60  array('href' => $a_href, 'text' => $a_text, 'status' => (bool)$status);
61  }
62 
63  public function getHeaderLinks()
64  {
65  return $this->header_links;
66  }
67 
73  function setData($a_data)
74  {
75  $this->data = $a_data;
76  }
77 
83  function getData()
84  {
85  return $this->data;
86  }
87 
93  function setBigMode($a_bigmode)
94  {
95  $this->bigmode = $a_bigmode;
96  }
97 
103  function getBigMode()
104  {
105  return $this->bigmode;
106  }
107 
113  function setBlockId($a_block_id = 0)
114  {
115  $this->block_id = $a_block_id;
116  }
117 
123  function getBlockId()
124  {
125  return $this->block_id;
126  }
127 
134  function setAvailableDetailLevels($a_max, $a_min = 0)
135  {
136  $this->detail_min = $a_min;
137  $this->detail_max = $a_max;
138  $this->handleDetailLevel();
139  }
140 
146  function setCurrentDetailLevel($a_currentdetaillevel)
147  {
148  $this->currentdetaillevel = $a_currentdetaillevel;
149  }
150 
158  public function setGuiObject(&$a_gui_object)
159  {
160  $this->gui_object = $a_gui_object;
161  }
162 
168  public function getGuiObject()
169  {
170  return $this->gui_object;
171  }
172 
179  {
180  return $this->currentdetaillevel;
181  }
182 
188  function setTitle($a_title)
189  {
190  $this->title = $a_title;
191  }
192 
198  function getTitle()
199  {
200  return $this->title;
201  }
202 
208  function setImage($a_image)
209  {
210  $this->image = $a_image;
211  }
212 
218  function getImage()
219  {
220  return $this->image;
221  }
222 
228  function setOffset($a_offset)
229  {
230  $this->offset = $a_offset;
231  }
232 
238  function getOffset()
239  {
240  return $this->offset;
241  }
242 
243  function correctOffset()
244  {
245  if (!($this->offset < $this->max_count))
246  {
247  $this->setOffset(0);
248  }
249  }
250 
256  function setLimit($a_limit)
257  {
258  $this->limit = $a_limit;
259  }
260 
266  function getLimit()
267  {
268  return $this->limit;
269  }
270 
276  function setEnableEdit($a_enableedit)
277  {
278  $this->enableedit = $a_enableedit;
279  }
280 
286  function getEnableEdit()
287  {
288  return $this->enableedit;
289  }
290 
296  function setRepositoryMode($a_repositorymode)
297  {
298  $this->repositorymode = $a_repositorymode;
299  }
300 
306  function getRepositoryMode()
307  {
308  return $this->repositorymode;
309  }
310 
316  function setFooterInfo($a_footerinfo, $a_hide_and_icon = false)
317  {
318  if ($a_hide_and_icon)
319  {
320  $this->footerinfo_icon = $a_footerinfo;
321  }
322  else
323  {
324  $this->footerinfo = $a_footerinfo;
325  }
326  }
327 
333  function getFooterInfo($a_hide_and_icon = false)
334  {
335  if ($a_hide_and_icon)
336  {
337  return $this->footerinfo_icon;
338  }
339  else
340  {
341  return $this->footerinfo;
342  }
343  }
344 
350  function setSubtitle($a_subtitle)
351  {
352  $this->subtitle = $a_subtitle;
353  }
354 
360  function getSubtitle()
361  {
362  return $this->subtitle;
363  }
364 
370  function setRefId($a_refid)
371  {
372  $this->refid = $a_refid;
373  }
374 
380  function getRefId()
381  {
382  return $this->refid;
383  }
384 
390  function setAdminCommands($a_admincommands)
391  {
392  $this->admincommands = $a_admincommands;
393  }
394 
400  function getAdminCommands()
401  {
402  return $this->admincommands;
403  }
404 
410  function setColSpan($a_colspan)
411  {
412  $this->colspan = $a_colspan;
413  }
414 
420  function getColSpan()
421  {
422  return $this->colspan;
423  }
424 
430  function setEnableDetailRow($a_enabledetailrow)
431  {
432  $this->enabledetailrow = $a_enabledetailrow;
433  }
434 
441  {
442  return $this->enabledetailrow;
443  }
444 
445 
451  function setEnableNumInfo($a_enablenuminfo)
452  {
453  $this->enablenuminfo = $a_enablenuminfo;
454  }
455 
461  function getEnableNumInfo()
462  {
463  return $this->enablenuminfo;
464  }
465 
472  function setProperties($a_properties)
473  {
474  $this->property = $a_properties;
475  }
476 
477  function getProperty($a_property)
478  {
479  return $this->property[$a_property];
480  }
481 
482  function setProperty($a_property, $a_value)
483  {
484  $this->property[$a_property] = $a_value;
485  }
486 
492  function setRowTemplate($a_rowtemplatename, $a_rowtemplatedir = "")
493  {
494  $this->rowtemplatename = $a_rowtemplatename;
495  $this->rowtemplatedir = $a_rowtemplatedir;
496  }
497 
498  final public function getNavParameter()
499  {
500  return $this->getBlockType()."_".$this->getBlockId()."_blnav";
501  }
502 
503  final public function getDetailParameter()
504  {
505  return $this->getBlockType()."_".$this->getBlockId()."_bldet";
506  }
507 
508  final public function getConfigParameter()
509  {
510  return $this->getBlockType()."_".$this->getBlockId()."_blconf";
511  }
512 
513  final public function getMoveParameter()
514  {
515  return $this->getBlockType()."_".$this->getBlockId()."_blmove";
516  }
517 
524  {
525  return $this->rowtemplatename;
526  }
527 
533  function getRowTemplateDir()
534  {
535  return $this->rowtemplatedir;
536  }
537 
544  function addBlockCommand($a_href, $a_text, $a_target = "", $a_img = "", $a_right_aligned = false)
545  {
546  return $this->block_commands[] =
547  array("href" => $a_href,
548  "text" => $a_text, "target" => $a_target, "img" => $a_img,
549  "right" => $a_right_aligned);
550  }
551 
557  function getBlockCommands()
558  {
559  return $this->block_commands;
560  }
561 
568  function addHeaderCommand($a_href, $a_text, $a_as_close = false)
569  {
570  if ($a_as_close)
571  {
572  $this->close_command = $a_href;
573  }
574  else
575  {
576  $this->header_commands[] =
577  array("href" => $a_href,
578  "text" => $a_text);
579  }
580  }
581 
587  function getHeaderCommands()
588  {
589  return $this->header_commands;
590  }
591 
595  function addFooterLink($a_text, $a_href = "", $a_onclick = "", $a_block_id = "",
596  $a_top = false, $a_omit_separator = false)
597  {
598  $this->footer_links[] = array(
599  "text" => $a_text,
600  "href" => $a_href,
601  "onclick" => $a_onclick,
602  "block_id" => $a_block_id,
603  "top" => $a_top,
604  "omit_separator" => $a_omit_separator);
605  }
606 
610  function getFooterLinks()
611  {
612  return $this->footer_links;
613  }
614 
618  function clearFooterLinks()
619  {
620  $this->footer_links = array();
621  }
622 
626  static function getScreenMode()
627  {
628  return IL_SCREEN_SIDE;
629  }
630 
634  function handleDetailLevel()
635  {
636  global $ilUser, $ilCtrl;
637 
638  // set/get detail level
639  if ($this->detail_max > $this->detail_min)
640  {
641  include_once("Services/Block/classes/class.ilBlockSetting.php");
642  if (isset($_GET[$this->getDetailParameter()]))
643  {
645  $ilUser->getId(), $this->block_id);
647  if ((int) $_GET[$this->getDetailParameter()] == 0)
648  {
649  $ilCtrl->redirectByClass("ilcolumngui", "");
650  }
651  }
652  else
653  {
655  $ilUser->getId(), $this->block_id));
656  }
657  }
658  }
659 
663 /*
664  function handleConfigStatus()
665  {
666  $this->config_mode = false;
667 
668  if ($_GET[$this->getConfigParameter()] == "toggle")
669  {
670  if ($_SESSION[$this->getConfigParameter()] == "on")
671  {
672  $_SESSION[$this->getConfigParameter()] = "off";
673  }
674  else
675  {
676  $_SESSION[$this->getConfigParameter()] = "on";
677  }
678  }
679  if ($_SESSION[$this->getConfigParameter()] == "on")
680  {
681  $this->config_mode = true;
682  }
683  }
684 */
685 
691  function setConfigMode($a_configmode)
692  {
693  $this->config_mode = $a_configmode;
694  }
695 
701  function getConfigMode()
702  {
703  return $this->config_mode;
704  }
705 
709  function getHTML()
710  {
711  global $ilCtrl, $lng, $ilAccess, $ilUser;
712 
713  if ($this->isRepositoryObject())
714  {
715  if (!$ilAccess->checkAccess("visible", "", $this->getRefId()))
716  {
717  return "";
718  }
719  }
720 
721  $this->tpl = new ilTemplate("tpl.block.html", true, true, "Services/Block");
722 
723 // $this->handleConfigStatus();
724 
725  $this->fillDataSection();
726 
727  if ($this->getRepositoryMode() && $this->isRepositoryObject()
728  && $this->getAdminCommands())
729  {
730  $this->tpl->setCurrentBlock("block_check");
731  $this->tpl->setVariable("BL_REF_ID", $this->getRefId());
732  $this->tpl->parseCurrentBlock();
733 
734  if ($ilAccess->checkAccess("delete", "", $this->getRefId()))
735  {
736  $this->addBlockCommand(
737  "repository.php?ref_id=".$_GET["ref_id"]."&cmd=delete".
738  "&item_ref_id=".$this->getRefId(),
739  $lng->txt("delete"));
740  }
741  }
742 
743  // footer info
744  if ($this->getFooterInfo() != "")
745  {
746  $this->tpl->setCurrentBlock("footer_information");
747  $this->tpl->setVariable("FOOTER_INFO", $this->getFooterInfo());
748  $this->tpl->setVariable("FICOLSPAN", $this->getColSpan());
749  $this->tpl->parseCurrentBlock();
750  }
751 
752  // commands
753  if (count($this->getBlockCommands()) > 0)
754  {
755 
756  foreach($this->getBlockCommands() as $command)
757  {
758  if ($command["target"] != "")
759  {
760  $this->tpl->setCurrentBlock("bc_target");
761  $this->tpl->setVariable("CMD_TARGET", $command["target"]);
762  $this->tpl->parseCurrentBlock();
763  }
764 
765  if ($command["img"] != "")
766  {
767  $this->tpl->setCurrentBlock("bc_image");
768  $this->tpl->setVariable("SRC_BC", $command["img"]);
769  $this->tpl->setVariable("ALT_BC", $command["text"]);
770  $this->tpl->parseCurrentBlock();
771  $this->tpl->setCurrentBlock("block_command");
772  }
773  else
774  {
775  $this->tpl->setCurrentBlock("block_command");
776  $this->tpl->setVariable("CMD_TEXT", $command["text"]);
777  $this->tpl->setVariable("BC_CLASS", 'class="il_ContainerItemCommand"');
778  }
779 
780  $this->tpl->setVariable("CMD_HREF", $command["href"]);
781  $this->tpl->parseCurrentBlock();
782  }
783  $this->tpl->setCurrentBlock("block_commands");
784  $this->tpl->setVariable("CCOLSPAN", $this->getColSpan());
785  $this->tpl->parseCurrentBlock();
786  }
787 
788  // fill previous next
789  $this->fillPreviousNext();
790 
791  // fill footer
792  $this->fillFooter();
793 
794  // fill row for setting details
795  $this->fillDetailRow();
796 
797  // fill row for setting details
798  if ($this->allow_moving)
799  {
800  $this->fillMoveRow();
801  }
802 
803  // header links
804  if(count($this->getHeaderLinks()))
805  {
806  $counter = 0;
807  foreach($this->getHeaderLinks() as $command)
808  {
809  if($counter > 0)
810  {
811  $this->tpl->setCurrentBlock('head_delim');
812  $this->tpl->touchBlock('head_delim');
813  $this->tpl->parseCurrentBlock();
814  }
815  if($command['status'] == true)
816  {
817  $this->tpl->setCurrentBlock('head_link');
818  $this->tpl->setVariable('HHREF', $command['href']);
819  $this->tpl->setVariable('HLINK', $command['text']);
820  $this->tpl->parseCurrentBlock();
821  }
822  else
823  {
824  $this->tpl->setCurrentBlock('head_text');
825  $this->tpl->setVariable('HTEXT', $command['text']);
826  $this->tpl->parseCurrentBlock();
827  }
828 
829  $this->tpl->setCurrentBlock('head_item');
830  $this->tpl->parseCurrentBlock();
831 
832  ++$counter;
833  }
834 
835  $this->tpl->setCurrentBlock('header_links');
836  $this->tpl->parseCurrentBlock();
837  }
838 
839  // for screen readers we first output the title and the commands
840  // (e.g. close icon afterwards), otherwise we first output the
841  // header commands, since we want to have the close icon top right
842  // and not floated after the title
843  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization"))
844  {
845  $this->fillHeaderTitleBlock();
846  $this->fillHeaderCommands();
847  }
848  else
849  {
850  $this->fillHeaderCommands();
851  $this->fillHeaderTitleBlock();
852  }
853 
854  $this->tpl->setVariable("COLSPAN", $this->getColSpan());
855  if ($this->getBigMode())
856  {
857  $this->tpl->touchBlock("hclassb");
858  }
859  else
860  {
861  $this->tpl->touchBlock("hclass");
862  }
863 
864  if ($ilCtrl->isAsynch())
865  {
866  // return without div wrapper
867  echo $this->tpl->getAsynch();
868  }
869  else
870  {
871  // return incl. wrapping div with id
872  return '<div id="'."block_".$this->getBlockType()."_".$this->block_id.'">'.
873  $this->tpl->get().'</div>';
874  }
875  }
876 
881  {
882  global $lng, $ilCtrl;
883 
884  // header commands
885  if (count($this->getHeaderCommands()) > 0 ||
886  ($this->detail_max > $this->detail_min && $this->detail_min == 0) ||
887  $this->close_command != "" || $this->allow_moving)
888  {
889 
890  foreach($this->getHeaderCommands() as $command)
891  {
892  $this->tpl->setCurrentBlock("header_command");
893  $this->tpl->setVariable("HREF_HCOMM", $command["href"]);
894  $this->tpl->setVariable("TXT_HCOMM", $command["text"]);
895  $this->tpl->parseCurrentBlock();
896  }
897 
898  // close button
899  if (($this->detail_max > $this->detail_min && $this->detail_min == 0 &&
900  !$this->getRepositoryMode())
901  ||
902  $this->close_command != "")
903  {
904  $this->tpl->setCurrentBlock("header_close");
905  $this->tpl->setVariable("ALT_CLOSE",
906  strip_tags(str_replace(array("'",'"'), "", $this->getTitle())).
907  " (".$lng->txt("block")."): ".$lng->txt("close")
908  );
909  if ($this->getBigMode())
910  {
911  $this->tpl->setVariable("IMG_CLOSE", ilUtil::getImagePath("icon_close2.gif"));
912  }
913  else
914  {
915  $this->tpl->setVariable("IMG_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
916  }
917  if ($this->close_command != "")
918  {
919  $this->tpl->setVariable("HREF_CLOSE",
920  $this->close_command);
921  }
922  else
923  {
924  $ilCtrl->setParameterByClass("ilcolumngui",
925  $this->getDetailParameter(), "0");
926  $this->tpl->setVariable("HREF_CLOSE",
927  $ilCtrl->getLinkTargetByClass("ilcolumngui",
928  ""));
929  $ilCtrl->setParameterByClass("ilcolumngui",
930  $this->getDetailParameter(), "");
931  }
932  $this->tpl->parseCurrentBlock();
933  }
934 
935  $this->tpl->setCurrentBlock("header_commands");
936  $this->tpl->parseCurrentBlock();
937  }
938 
939  $this->tpl->setCurrentBlock("hitem");
940  $this->tpl->parseCurrentBlock();
941  }
942 
943 
948  {
949  global $lng;
950 
951  // image
952  if ($this->getImage() != "")
953  {
954  $this->tpl->setCurrentBlock("block_img");
955  $this->tpl->setVariable("IMG_BLOCK", $this->getImage());
956  $this->tpl->setVariable("IMID",
957  "block_".$this->getBlockType()."_".$this->block_id);
958  $this->tpl->setVariable("IMG_ALT",
959  str_replace(array("'",'"'), "", strip_tags($lng->txt("icon")." ".$this->getTitle())));
960  $this->tpl->parseCurrentBlock();
961  }
962 
963  // header title
964  $this->tpl->setCurrentBlock("header_title");
965  $this->tpl->setVariable("BTID",
966  "block_".$this->getBlockType()."_".$this->block_id);
967  $this->tpl->setVariable("BLOCK_TITLE",
968  $this->getTitle());
969  $this->tpl->setVariable("TXT_BLOCK",
970  $lng->txt("block"));
971  $this->tpl->parseCurrentBlock();
972 
973  $this->tpl->setCurrentBlock("hitem");
974  $this->tpl->parseCurrentBlock();
975  }
976 
977 
981  function setDataSection($a_content)
982  {
983  $this->tpl->setCurrentBlock("data_section");
984  $this->tpl->setVariable("DATA", $a_content);
985  $this->tpl->parseCurrentBlock();
986  }
987 
992  function fillDataSection()
993  {
994  $this->nav_value = (isset($_POST[$this->getNavParameter()]) && $_POST[$this->getNavParameter()] != "")
995  ? $_POST[$this->getNavParameter()]
996  : (isset($_GET[$this->getNavParameter()]) ? $_GET[$this->getNavParameter()] : $this->nav_value);
997  $this->nav_value = ($this->nav_value == "" && isset($_SESSION[$this->getNavParameter()]))
998  ? $_SESSION[$this->getNavParameter()]
1000 
1002 
1003  $nav = explode(":", $this->nav_value);
1004  if (isset($nav[2]))
1005  {
1006  $this->setOffset($nav[2]);
1007  }
1008  else
1009  {
1010  $this->setOffset(0);
1011  }
1012 
1013  // data
1014  $this->tpl->addBlockFile("BLOCK_ROW", "block_row", $this->getRowTemplateName(),
1015  $this->getRowTemplateDir());
1016 
1017  $data = $this->getData();
1018  $this->max_count = count($data);
1019  $this->correctOffset();
1020  $data = array_slice($data, $this->getOffset(), $this->getLimit());
1021 
1022  foreach($data as $record)
1023  {
1024  $this->tpl->setCurrentBlock("block_row");
1025  $this->fillRowColor();
1026  $this->fillRow($record);
1027  $this->tpl->setCurrentBlock("block_row");
1028  $this->tpl->parseCurrentBlock();
1029  }
1030  }
1031 
1032  function fillRow($a_set)
1033  {
1034  foreach ($a_set as $key => $value)
1035  {
1036  $this->tpl->setVariable("VAL_".strtoupper($key), $value);
1037  }
1038  }
1039 
1040  function fillFooter()
1041  {
1042  }
1043 
1044  final protected function fillRowColor($a_placeholder = "CSS_ROW")
1045  {
1046  $this->css_row = ($this->css_row != "ilBlockRow1")
1047  ? "ilBlockRow1"
1048  : "ilBlockRow2";
1049  $this->tpl->setVariable($a_placeholder, $this->css_row);
1050  }
1051 
1055  function fillPreviousNext()
1056  {
1057  global $lng, $ilCtrl;
1058 
1059  $pn = false;
1060 
1061  // table pn numinfo
1062  $numinfo = "";
1063  if ($this->getEnableNumInfo() && $this->max_count > 0)
1064  {
1065  $start = $this->getOffset() + 1; // compute num info
1066  $end = $this->getOffset() + $this->getLimit();
1067 
1068  if ($end > $this->max_count or $this->getLimit() == 0)
1069  {
1070  $end = $this->max_count;
1071  }
1072 
1073  $numinfo = "(".$start."-".$end." ".strtolower($lng->txt("of"))." ".$this->max_count.")";
1074  }
1075 
1076  $this->setPreviousNextLinks();
1077  $this->fillFooterLinks(true, $numinfo);
1078 
1079  }
1080 
1089  {
1090  global $ilCtrl, $lng;
1091 
1092  // if more entries then entries per page -> show link bar
1093  if ($this->max_count > $this->getLimit() && ($this->getLimit() != 0))
1094  {
1095  // previous link
1096  if ($this->getOffset() >= 1)
1097  {
1098  $prevoffset = $this->getOffset() - $this->getLimit();
1099 
1100  $ilCtrl->setParameterByClass("ilcolumngui",
1101  $this->getNavParameter(), "::".$prevoffset);
1102 
1103  // ajax link
1104  $ilCtrl->setParameterByClass("ilcolumngui",
1105  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1106  $block_id = "block_".$this->getBlockType()."_".$this->block_id;
1107  $onclick = $ilCtrl->getLinkTargetByClass("ilcolumngui",
1108  "updateBlock", "", true);
1109  $ilCtrl->setParameterByClass("ilcolumngui",
1110  "block_id", "");
1111 
1112  // normal link
1113  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1114  $text = $lng->txt("previous");
1115 
1116  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1117  }
1118 
1119  // calculate number of pages
1120  $pages = intval($this->max_count / $this->getLimit());
1121 
1122  // add a page if a rest remains
1123  if (($this->max_count % $this->getLimit()))
1124  $pages++;
1125 
1126  // show next link (if not last page)
1127  if (! ( ($this->getOffset() / $this->getLimit())==($pages-1) ) && ($pages!=1) )
1128  {
1129  $newoffset = $this->getOffset() + $this->getLimit();
1130 
1131  $ilCtrl->setParameterByClass("ilcolumngui",
1132  $this->getNavParameter(), "::".$newoffset);
1133 
1134  // ajax link
1135  $ilCtrl->setParameterByClass("ilcolumngui",
1136  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1137  //$this->tpl->setCurrentBlock("pnonclick");
1138  $block_id = "block_".$this->getBlockType()."_".$this->block_id;
1139  $onclick = $ilCtrl->getLinkTargetByClass("ilcolumngui",
1140  "updateBlock", "", true);
1141 //echo "-".$onclick."-";
1142  //$this->tpl->parseCurrentBlock();
1143  $ilCtrl->setParameterByClass("ilcolumngui",
1144  "block_id", "");
1145 
1146  // normal link
1147  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1148  $text = $lng->txt("next");
1149 
1150  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1151  }
1152  $ilCtrl->setParameterByClass("ilcolumngui",
1153  $this->getNavParameter(), "");
1154  return true;
1155  }
1156  else
1157  {
1158  return false;
1159  }
1160  }
1161 
1167  function fillFooterLinks($a_top = false, $a_numinfo = "")
1168  {
1169  global $ilCtrl, $lng;
1170 
1171  $first = true;
1172  $flinks = $this->getFooterLinks();
1173 
1174  $prefix = ($a_top) ? "top" : "foot";
1175 
1176  $omit_separator = false;
1177  foreach($flinks as $flink)
1178  {
1179  if ($flink["top"] != $a_top)
1180  {
1181  continue;
1182  }
1183 
1184  if (!$first && !$omit_separator)
1185  {
1186  $this->tpl->touchBlock($prefix."_delim");
1187  $this->tpl->touchBlock($prefix."_item");
1188  }
1189 
1190  // ajax link
1191  if ($flink["onclick"] != "")
1192  {
1193  $this->tpl->setCurrentBlock($prefix."_onclick");
1194  $this->tpl->setVariable("OC_BLOCK_ID",
1195  $flink["block_id"]);
1196  $this->tpl->setVariable("OC_HREF",
1197  $flink["onclick"]);
1198  $this->tpl->parseCurrentBlock();
1199  }
1200 
1201  // normal link
1202  if ($flink["href"] != "")
1203  {
1204  // normal link
1205  $this->tpl->setCurrentBlock($prefix."_link");
1206  $this->tpl->setVariable("FHREF",
1207  $flink["href"]);
1208  $this->tpl->setVariable("FLINK", $flink["text"]);
1209  $this->tpl->parseCurrentBlock();
1210  $this->tpl->touchBlock($prefix."_item");
1211  }
1212  else
1213  {
1214  $this->tpl->setCurrentBlock($prefix."_text");
1215  $this->tpl->setVariable("FTEXT", $flink["text"]);
1216  $this->tpl->parseCurrentBlock();
1217  $this->tpl->touchBlock($prefix."_item");
1218  }
1219  $first = false;
1220  $omit_separator = $flink["omit_separator"];
1221  }
1222 
1223  if ($a_numinfo != "")
1224  {
1225  $this->tpl->setVariable("NUMINFO", $a_numinfo);
1226  $first = false;
1227  }
1228 
1229  if (!$first)
1230  {
1231  $this->tpl->setVariable("PCOLSPAN", $this->getColSpan());
1232  $this->tpl->setCurrentBlock($prefix."_row");
1233  $this->tpl->parseCurrentBlock();
1234  }
1235  }
1236 
1240  function fillDetailRow()
1241  {
1242  global $ilCtrl, $lng;
1243 
1244  if ($this->enabledetailrow == false)
1245  {
1246  return;
1247  }
1248 
1249  $start = ($this->detail_min < 1)
1250  ? $start = 1
1251  : $this->detail_min;
1252 
1253  $end = ($this->detail_max < $this->detail_min)
1254  ? $this->detail_min
1255  : $this->detail_max;
1256 
1257  $settings = array();
1258  for ($i = $start; $i <= $end; $i++)
1259  {
1260  $settings[] = $i;
1261  }
1262 
1263  if ($end > $start)
1264  {
1265  foreach ($settings as $i)
1266  {
1267  if (($i > $start && $i > 1))
1268  {
1269  //$this->tpl->touchBlock("det_delim");
1270  //$this->tpl->touchBlock("det_item");
1271  }
1272  if ($i != $this->getCurrentDetailLevel())
1273  {
1274  $ilCtrl->setParameterByClass("ilcolumngui",
1275  $this->getDetailParameter(), $i);
1276 
1277  // ajax link
1278  if ($i > 0)
1279  {
1280  $ilCtrl->setParameterByClass("ilcolumngui",
1281  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1282  $this->tpl->setCurrentBlock("onclick");
1283  $this->tpl->setVariable("OC_BLOCK_ID",
1284  "block_".$this->getBlockType()."_".$this->block_id);
1285  $this->tpl->setVariable("OC_HREF",
1286  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1287  "updateBlock", "", true));
1288  $this->tpl->parseCurrentBlock();
1289  $ilCtrl->setParameterByClass("ilcolumngui",
1290  "block_id", "");
1291  }
1292 
1293  // normal link
1294  $this->tpl->setCurrentBlock("det_link");
1295  //$this->tpl->setVariable("DLINK", $i);
1296  $this->tpl->setVariable("SRC_LINK",
1297  ilUtil::getImagePath("details".$i.".gif"));
1298  $this->tpl->setVariable("ALT_LINK",
1299  strip_tags(str_replace(array("'",'"'), "", $this->getTitle())).
1300  " (".$lng->txt("block")."): ".$lng->txt("details")." ".$i
1301  );
1302  $this->tpl->setVariable("DHREF",
1303  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1304  ""));
1305  $this->tpl->parseCurrentBlock();
1306  $this->tpl->touchBlock("det_item");
1307  }
1308  else
1309  {
1310  $this->tpl->setCurrentBlock("det_text");
1311  //$this->tpl->setVariable("DTEXT", $i);
1312  $this->tpl->setVariable("ALT_NO_LINK",
1313  strip_tags(str_replace(array("'",'"'), "", $this->getTitle())).
1314  " (".$lng->txt("block")."): ".$lng->txt("details")." ".$i.
1315  " (".$lng->txt("selected").")");
1316  $this->tpl->setVariable("SRC_NO_LINK",
1317  ilUtil::getImagePath("details".$i."off.gif"));
1318  $this->tpl->parseCurrentBlock();
1319  $this->tpl->touchBlock("det_item");
1320  }
1321  }
1322 
1323  // info + icon in detail row
1324  if ($this->getFooterInfo(true) != "")
1325  {
1326  $this->tpl->setCurrentBlock("det_info");
1327  $this->tpl->setVariable("INFO_TEXT", $this->getFooterInfo(true));
1328  $this->tpl->setVariable("ALT_DET_INFO", $lng->txt("info_short"));
1329  $this->tpl->setVariable("DI_BLOCK_ID", $this->getBlockType()."_".$this->getBlockId());
1330  $this->tpl->setVariable("IMG_DET_INFO", ilUtil::getImagePath("icon_info_s.gif"));
1331  $this->tpl->parseCurrentBlock();
1332  }
1333 
1334  $this->tpl->setCurrentBlock("detail_setting");
1335  $this->tpl->setVariable("TXT_DETAILS", $lng->txt("details"));
1336  $this->tpl->setVariable("DCOLSPAN", $this->getColSpan());
1337  $this->tpl->parseCurrentBlock();
1338 
1339  $ilCtrl->setParameterByClass("ilcolumngui",
1340  $this->getDetailParameter(), "");
1341  }
1342  }
1343 
1347  function fillMoveRow()
1348  {
1349  global $ilCtrl, $lng;
1350 
1351  if ($this->config_mode)
1352  {
1353  if ($this->getAllowMove("left"))
1354  {
1355  $this->fillMoveLink("left", "icon_left_s.gif", $lng->txt("move_left"));
1356  }
1357  if ($this->getAllowMove("up"))
1358  {
1359  $this->fillMoveLink("up", "icon_up_s.gif", $lng->txt("move_up"));
1360  }
1361  if ($this->getAllowMove("down"))
1362  {
1363  $this->fillMoveLink("down", "icon_down_s.gif", $lng->txt("move_down"));
1364  }
1365  if ($this->getAllowMove("right"))
1366  {
1367  $this->fillMoveLink("right", "icon_right_s.gif", $lng->txt("move_right"));
1368  }
1369  $ilCtrl->setParameter($this, $this->getMoveParameter(), "");
1370 
1371  $this->tpl->setCurrentBlock("move");
1372  $this->tpl->parseCurrentBlock();
1373  }
1374  }
1375 
1376  function getAllowMove($a_direction)
1377  {
1378  return $this->move[$a_direction];
1379  }
1380 
1381  function setAllowMove($a_direction, $a_allow = true)
1382  {
1383  $this->move[$a_direction] = $a_allow;
1384 //var_dump($this->move);
1385  }
1386 
1387  function fillMoveLink($a_value, $a_img, $a_txt)
1388  {
1389  global $ilCtrl, $lng;
1390 
1391  $ilCtrl->setParameterByClass("ilcolumngui", "block_id",
1392  $this->getBlockType()."_".$this->getBlockId());
1393  $ilCtrl->setParameterByClass("ilcolumngui", "move_dir",
1394  $a_value);
1395  $this->tpl->setCurrentBlock("move_link");
1396  $this->tpl->setVariable("IMG_MOVE", ilUtil::getImagePath($a_img));
1397  $this->tpl->setVariable("ALT_MOVE", $a_txt);
1398  $this->tpl->setVariable("HREF_MOVE",
1399  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1400  "moveBlock"));
1401  $this->tpl->parseCurrentBlock();
1402  }
1403 }