ILIAS  Release_3_10_x_branch Revision 61812
 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;
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  // image
795  if ($this->getImage() != "")
796  {
797  $this->tpl->setCurrentBlock("block_img");
798  $this->tpl->setVariable("IMG_BLOCK", $this->getImage());
799  $this->tpl->parseCurrentBlock();
800  }
801 
802  // fill previous next
803  $this->fillPreviousNext();
804 
805  // fill footer
806  $this->fillFooter();
807 
808  // fill row for setting details
809  $this->fillDetailRow();
810 
811  // fill row for setting details
812  if ($this->allow_moving)
813  {
814  $this->fillMoveRow();
815  }
816 
817  // header commands
818  if (count($this->getHeaderCommands()) > 0 ||
819  ($this->detail_max > $this->detail_min && $this->detail_min == 0) ||
820  $this->close_command != "" || $this->allow_moving)
821  {
822 
823  foreach($this->getHeaderCommands() as $command)
824  {
825  $this->tpl->setCurrentBlock("header_command");
826  $this->tpl->setVariable("HREF_HCOMM", $command["href"]);
827  $this->tpl->setVariable("TXT_HCOMM", $command["text"]);
828  $this->tpl->parseCurrentBlock();
829  }
830 
831  // close button
832  if (($this->detail_max > $this->detail_min && $this->detail_min == 0 &&
833  !$this->getRepositoryMode())
834  ||
835  $this->close_command != "")
836  {
837  $this->tpl->setCurrentBlock("header_close");
838  $this->tpl->setVariable("ALT_CLOSE", $lng->txt("close"));
839  if ($this->getBigMode())
840  {
841  $this->tpl->setVariable("IMG_CLOSE", ilUtil::getImagePath("icon_close2.gif"));
842  }
843  else
844  {
845  $this->tpl->setVariable("IMG_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
846  }
847  if ($this->close_command != "")
848  {
849  $this->tpl->setVariable("HREF_CLOSE",
850  $this->close_command);
851  }
852  else
853  {
854  $ilCtrl->setParameterByClass("ilcolumngui",
855  $this->getDetailParameter(), "0");
856  $this->tpl->setVariable("HREF_CLOSE",
857  $ilCtrl->getLinkTargetByClass("ilcolumngui",
858  ""));
859  $ilCtrl->setParameterByClass("ilcolumngui",
860  $this->getDetailParameter(), "");
861  }
862  $this->tpl->parseCurrentBlock();
863  }
864 
865  // move button
866  /*
867  if ($this->allow_moving)
868  {
869  $ilCtrl->setParameterByClass("ilcolumngui",
870  $this->getConfigParameter(), "toggle");
871 
872  // ajax link
873  $ilCtrl->setParameterByClass("ilcolumngui",
874  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
875  $this->tpl->setCurrentBlock("oncclick");
876  $this->tpl->setVariable("OC_BLOCK_ID",
877  "block_".$this->getBlockType()."_".$this->block_id);
878  $this->tpl->setVariable("OC_HREF",
879  $ilCtrl->getLinkTargetByClass("ilcolumngui",
880  "updateBlock", "", true));
881  $this->tpl->parseCurrentBlock();
882  $ilCtrl->setParameterByClass("ilcolumngui",
883  "block_id", "");
884 
885  // normal link
886  $this->tpl->setCurrentBlock("header_config");
887  $this->tpl->setVariable("IMG_CONFIG", ilUtil::getImagePath("icon_move_s.gif"));
888  $this->tpl->setVariable("ALT_CONFIG", $lng->txt("move"));
889  $this->tpl->setVariable("HREF_CONFIG",
890  $ilCtrl->getLinkTargetByClass("ilcolumngui", ""));
891  $this->tpl->parseCurrentBlock();
892  $ilCtrl->setParameterByClass("ilcolumngui",
893  $this->getConfigParameter(), "");
894  }
895 */
896 
897  $this->tpl->setCurrentBlock("header_commands");
898  $this->tpl->parseCurrentBlock();
899  }
900 
901  // header links
902  if(count($this->getHeaderLinks()))
903  {
904  $counter = 0;
905  foreach($this->getHeaderLinks() as $command)
906  {
907  if($counter > 0)
908  {
909  $this->tpl->setCurrentBlock('head_delim');
910  $this->tpl->touchBlock('head_delim');
911  $this->tpl->parseCurrentBlock();
912  }
913  if($command['status'] == true)
914  {
915  $this->tpl->setCurrentBlock('head_link');
916  $this->tpl->setVariable('HHREF', $command['href']);
917  $this->tpl->setVariable('HLINK', $command['text']);
918  $this->tpl->parseCurrentBlock();
919  }
920  else
921  {
922  $this->tpl->setCurrentBlock('head_text');
923  $this->tpl->setVariable('HTEXT', $command['text']);
924  $this->tpl->parseCurrentBlock();
925  }
926 
927  $this->tpl->setCurrentBlock('head_item');
928  $this->tpl->parseCurrentBlock();
929 
930  ++$counter;
931  }
932 
933  $this->tpl->setCurrentBlock('header_links');
934  $this->tpl->parseCurrentBlock();
935  }
936 
937  // title
938  $this->tpl->setVariable("BLOCK_TITLE",
939  $this->getTitle());
940  $this->tpl->setVariable("COLSPAN", $this->getColSpan());
941  if ($this->getBigMode())
942  {
943  $this->tpl->touchBlock("hclassb");
944  }
945  else
946  {
947  $this->tpl->touchBlock("hclass");
948  }
949 
950  if ($ilCtrl->isAsynch())
951  {
952  // return without div wrapper
953  echo $this->tpl->getAsynch();
954  }
955  else
956  {
957  // return incl. wrapping div with id
958  return '<div id="'."block_".$this->getBlockType()."_".$this->block_id.'">'.
959  $this->tpl->get().'</div>';
960  }
961  }
962 
966  function setDataSection($a_content)
967  {
968  $this->tpl->setCurrentBlock("data_section");
969  $this->tpl->setVariable("DATA", $a_content);
970  $this->tpl->parseCurrentBlock();
971  }
972 
977  function fillDataSection()
978  {
979  $this->nav_value = ($_POST[$this->getNavParameter()] != "")
980  ? $_POST[$this->getNavParameter()]
981  : $_GET[$this->getNavParameter()];
982  $this->nav_value = ($this->nav_value == "")
983  ? $_SESSION[$this->getNavParameter()]
984  : $this->nav_value;
985 
986  $_SESSION[$this->getNavParameter()] = $this->nav_value;
987 
988  $nav = explode(":", $this->nav_value);
989  $this->setOffset($nav[2]);
990 
991  // data
992  $this->tpl->addBlockFile("BLOCK_ROW", "block_row", $this->getRowTemplateName(),
993  $this->getRowTemplateDir());
994 
995  $data = $this->getData();
996  $this->max_count = count($data);
997  $this->correctOffset();
998  $data = array_slice($data, $this->getOffset(), $this->getLimit());
999 
1000  foreach($data as $record)
1001  {
1002  $this->tpl->setCurrentBlock("block_row");
1003  $this->fillRowColor();
1004  $this->fillRow($record);
1005  $this->tpl->setCurrentBlock("block_row");
1006  $this->tpl->parseCurrentBlock();
1007  }
1008  }
1009 
1010  function fillRow($a_set)
1011  {
1012  foreach ($a_set as $key => $value)
1013  {
1014  $this->tpl->setVariable("VAL_".strtoupper($key), $value);
1015  }
1016  }
1017 
1018  function fillFooter()
1019  {
1020  }
1021 
1022  final protected function fillRowColor($a_placeholder = "CSS_ROW")
1023  {
1024  $this->css_row = ($this->css_row != "tblrow1")
1025  ? "tblrow1"
1026  : "tblrow2";
1027  $this->tpl->setVariable($a_placeholder, $this->css_row);
1028  }
1029 
1033  function fillPreviousNext()
1034  {
1035  global $lng, $ilCtrl;
1036 
1037  $pn = false;
1038 
1039  // table pn numinfo
1040  $numinfo = "";
1041  if ($this->getEnableNumInfo() && $this->max_count > 0)
1042  {
1043  $start = $this->getOffset() + 1; // compute num info
1044  $end = $this->getOffset() + $this->getLimit();
1045 
1046  if ($end > $this->max_count or $this->getLimit() == 0)
1047  {
1048  $end = $this->max_count;
1049  }
1050 
1051  $numinfo = "(".$start."-".$end." ".strtolower($lng->txt("of"))." ".$this->max_count.")";
1052  }
1053 
1054  $this->setPreviousNextLinks();
1055  $this->fillFooterLinks(true, $numinfo);
1056 
1057  }
1058 
1067  {
1068  global $ilCtrl, $lng;
1069 
1070  // if more entries then entries per page -> show link bar
1071  if ($this->max_count > $this->getLimit() && ($this->getLimit() != 0))
1072  {
1073  // previous link
1074  if ($this->getOffset() >= 1)
1075  {
1076  $prevoffset = $this->getOffset() - $this->getLimit();
1077 
1078  $ilCtrl->setParameterByClass("ilcolumngui",
1079  $this->getNavParameter(), "::".$prevoffset);
1080 
1081  // ajax link
1082  $ilCtrl->setParameterByClass("ilcolumngui",
1083  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1084  $block_id = "block_".$this->getBlockType()."_".$this->block_id;
1085  $onclick = $ilCtrl->getLinkTargetByClass("ilcolumngui",
1086  "updateBlock", "", true);
1087  $ilCtrl->setParameterByClass("ilcolumngui",
1088  "block_id", "");
1089 
1090  // normal link
1091  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1092  $text = $lng->txt("previous");
1093 
1094  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1095  }
1096 
1097  // calculate number of pages
1098  $pages = intval($this->max_count / $this->getLimit());
1099 
1100  // add a page if a rest remains
1101  if (($this->max_count % $this->getLimit()))
1102  $pages++;
1103 
1104  // show next link (if not last page)
1105  if (! ( ($this->getOffset() / $this->getLimit())==($pages-1) ) && ($pages!=1) )
1106  {
1107  $newoffset = $this->getOffset() + $this->getLimit();
1108 
1109  $ilCtrl->setParameterByClass("ilcolumngui",
1110  $this->getNavParameter(), "::".$newoffset);
1111 
1112  // ajax link
1113  $ilCtrl->setParameterByClass("ilcolumngui",
1114  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1115  //$this->tpl->setCurrentBlock("pnonclick");
1116  $block_id = "block_".$this->getBlockType()."_".$this->block_id;
1117  $onclick = $ilCtrl->getLinkTargetByClass("ilcolumngui",
1118  "updateBlock", "", true);
1119 //echo "-".$onclick."-";
1120  //$this->tpl->parseCurrentBlock();
1121  $ilCtrl->setParameterByClass("ilcolumngui",
1122  "block_id", "");
1123 
1124  // normal link
1125  $href = $ilCtrl->getLinkTargetByClass("ilcolumngui", "");
1126  $text = $lng->txt("next");
1127 
1128  $this->addFooterLink($text, $href, $onclick, $block_id, true);
1129  }
1130  $ilCtrl->setParameterByClass("ilcolumngui",
1131  $this->getNavParameter(), "");
1132  return true;
1133  }
1134  else
1135  {
1136  return false;
1137  }
1138  }
1139 
1145  function fillFooterLinks($a_top = false, $a_numinfo = "")
1146  {
1147  global $ilCtrl, $lng;
1148 
1149  $first = true;
1150  $flinks = $this->getFooterLinks();
1151 
1152  $prefix = ($a_top) ? "top" : "foot";
1153 
1154  $omit_separator = false;
1155  foreach($flinks as $flink)
1156  {
1157  if ($flink["top"] != $a_top)
1158  {
1159  continue;
1160  }
1161 
1162  if (!$first && !$omit_separator)
1163  {
1164  $this->tpl->touchBlock($prefix."_delim");
1165  $this->tpl->touchBlock($prefix."_item");
1166  }
1167 
1168  // ajax link
1169  if ($flink["onclick"] != "")
1170  {
1171  $this->tpl->setCurrentBlock($prefix."_onclick");
1172  $this->tpl->setVariable("OC_BLOCK_ID",
1173  $flink["block_id"]);
1174  $this->tpl->setVariable("OC_HREF",
1175  $flink["onclick"]);
1176  $this->tpl->parseCurrentBlock();
1177  }
1178 
1179  // normal link
1180  if ($flink["href"] != "")
1181  {
1182  // normal link
1183  $this->tpl->setCurrentBlock($prefix."_link");
1184  $this->tpl->setVariable("FHREF",
1185  $flink["href"]);
1186  $this->tpl->setVariable("FLINK", $flink["text"]);
1187  $this->tpl->parseCurrentBlock();
1188  $this->tpl->touchBlock($prefix."_item");
1189  }
1190  else
1191  {
1192  $this->tpl->setCurrentBlock($prefix."_text");
1193  $this->tpl->setVariable("FTEXT", $flink["text"]);
1194  $this->tpl->parseCurrentBlock();
1195  $this->tpl->touchBlock($prefix."_item");
1196  }
1197  $first = false;
1198  $omit_separator = $flink["omit_separator"];
1199  }
1200 
1201  if ($a_numinfo != "")
1202  {
1203  $this->tpl->setVariable("NUMINFO", $a_numinfo);
1204  $first = false;
1205  }
1206 
1207  if (!$first)
1208  {
1209  $this->tpl->setVariable("PCOLSPAN", $this->getColSpan());
1210  $this->tpl->setCurrentBlock($prefix."_row");
1211  $this->tpl->parseCurrentBlock();
1212  }
1213  }
1214 
1218  function fillDetailRow()
1219  {
1220  global $ilCtrl, $lng;
1221 
1222  if ($this->enabledetailrow == false)
1223  {
1224  return;
1225  }
1226 
1227  $start = ($this->detail_min < 1)
1228  ? $start = 1
1229  : $this->detail_min;
1230 
1231  $end = ($this->detail_max < $this->detail_min)
1232  ? $this->detail_min
1233  : $this->detail_max;
1234 
1235  $settings = array();
1236  for ($i = $start; $i <= $end; $i++)
1237  {
1238  $settings[] = $i;
1239  }
1240 
1241  if ($end > $start)
1242  {
1243  foreach ($settings as $i)
1244  {
1245  if (($i > $start && $i > 1))
1246  {
1247  //$this->tpl->touchBlock("det_delim");
1248  //$this->tpl->touchBlock("det_item");
1249  }
1250  if ($i != $this->getCurrentDetailLevel())
1251  {
1252  $ilCtrl->setParameterByClass("ilcolumngui",
1253  $this->getDetailParameter(), $i);
1254 
1255  // ajax link
1256  if ($i > 0)
1257  {
1258  $ilCtrl->setParameterByClass("ilcolumngui",
1259  "block_id", "block_".$this->getBlockType()."_".$this->block_id);
1260  $this->tpl->setCurrentBlock("onclick");
1261  $this->tpl->setVariable("OC_BLOCK_ID",
1262  "block_".$this->getBlockType()."_".$this->block_id);
1263  $this->tpl->setVariable("OC_HREF",
1264  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1265  "updateBlock", "", true));
1266  $this->tpl->parseCurrentBlock();
1267  $ilCtrl->setParameterByClass("ilcolumngui",
1268  "block_id", "");
1269  }
1270 
1271  // normal link
1272  $this->tpl->setCurrentBlock("det_link");
1273  //$this->tpl->setVariable("DLINK", $i);
1274  $this->tpl->setVariable("SRC_LINK",
1275  ilUtil::getImagePath("details".$i.".gif"));
1276  $this->tpl->setVariable("ALT_LINK",
1277  $lng->txt("details_".$i));
1278  $this->tpl->setVariable("DHREF",
1279  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1280  ""));
1281  $this->tpl->parseCurrentBlock();
1282  $this->tpl->touchBlock("det_item");
1283  }
1284  else
1285  {
1286  $this->tpl->setCurrentBlock("det_text");
1287  //$this->tpl->setVariable("DTEXT", $i);
1288  $this->tpl->setVariable("ALT_NO_LINK",
1289  $lng->txt("details_".$i));
1290  $this->tpl->setVariable("SRC_NO_LINK",
1291  ilUtil::getImagePath("details".$i."off.gif"));
1292  $this->tpl->parseCurrentBlock();
1293  $this->tpl->touchBlock("det_item");
1294  }
1295  }
1296 
1297  // info + icon in detail row
1298  if ($this->getFooterInfo(true) != "")
1299  {
1300  $this->tpl->setCurrentBlock("det_info");
1301  $this->tpl->setVariable("INFO_TEXT", $this->getFooterInfo(true));
1302  $this->tpl->setVariable("ALT_DET_INFO", $lng->txt("info_short"));
1303  $this->tpl->setVariable("DI_BLOCK_ID", $this->getBlockType()."_".$this->getBlockId());
1304  $this->tpl->setVariable("IMG_DET_INFO", ilUtil::getImagePath("icon_info_s.gif"));
1305  $this->tpl->parseCurrentBlock();
1306  }
1307 
1308  $this->tpl->setCurrentBlock("detail_setting");
1309  $this->tpl->setVariable("TXT_DETAILS", $lng->txt("details"));
1310  $this->tpl->setVariable("DCOLSPAN", $this->getColSpan());
1311  $this->tpl->parseCurrentBlock();
1312 
1313  $ilCtrl->setParameterByClass("ilcolumngui",
1314  $this->getDetailParameter(), "");
1315  }
1316  }
1317 
1321  function fillMoveRow()
1322  {
1323  global $ilCtrl, $lng;
1324 
1325  if ($this->config_mode)
1326  {
1327  if ($this->getAllowMove("left"))
1328  {
1329  $this->fillMoveLink("left", "icon_left_s.gif", $lng->txt("move_left"));
1330  }
1331  if ($this->getAllowMove("up"))
1332  {
1333  $this->fillMoveLink("up", "icon_up_s.gif", $lng->txt("move_up"));
1334  }
1335  if ($this->getAllowMove("down"))
1336  {
1337  $this->fillMoveLink("down", "icon_down_s.gif", $lng->txt("move_down"));
1338  }
1339  if ($this->getAllowMove("right"))
1340  {
1341  $this->fillMoveLink("right", "icon_right_s.gif", $lng->txt("move_right"));
1342  }
1343  $ilCtrl->setParameter($this, $this->getMoveParameter(), "");
1344 
1345  $this->tpl->setCurrentBlock("move");
1346  $this->tpl->parseCurrentBlock();
1347  }
1348  }
1349 
1350  function getAllowMove($a_direction)
1351  {
1352  return $this->move[$a_direction];
1353  }
1354 
1355  function setAllowMove($a_direction, $a_allow = true)
1356  {
1357  $this->move[$a_direction] = $a_allow;
1358 //var_dump($this->move);
1359  }
1360 
1361  function fillMoveLink($a_value, $a_img, $a_txt)
1362  {
1363  global $ilCtrl, $lng;
1364 
1365  $ilCtrl->setParameterByClass("ilcolumngui", "block_id",
1366  $this->getBlockType()."_".$this->getBlockId());
1367  $ilCtrl->setParameterByClass("ilcolumngui", "move_dir",
1368  $a_value);
1369  $this->tpl->setCurrentBlock("move_link");
1370  $this->tpl->setVariable("IMG_MOVE", ilUtil::getImagePath($a_img));
1371  $this->tpl->setVariable("ALT_MOVE", $a_txt);
1372  $this->tpl->setVariable("HREF_MOVE",
1373  $ilCtrl->getLinkTargetByClass("ilcolumngui",
1374  "moveBlock"));
1375  $this->tpl->parseCurrentBlock();
1376  }
1377 }