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