ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilTemplate.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
11 class ilTemplate extends ilTemplateX
12 {
22  var $vars;
23 
31 
32  var $js_files = array(0 => "Services/JavaScript/js/Basic.js"); // list of JS files that should be included
33  var $js_files_vp = array("Services/JavaScript/js/Basic.js" => true); // version parameter flag
34  var $js_files_batch = array("Services/JavaScript/js/Basic.js" => 1); // version parameter flag
35  var $css_files = array(); // list of css files that should be included
36  var $admin_panel_commands = array();
37 
38  private $addFooter; // creates an output of the ILIAS footer
39 
40  protected static $il_cache = array();
41  protected $message = "";
42 
43  protected $title_desc = "";
44  protected $upper_icon = "";
45  protected $tree_flat_link = "";
46  protected $mount_webfolder = "";
47  protected $stop_floating = "";
48  protected $page_form_action = "";
49  protected $page_actions = array();
50  protected $creation_selector = false;
51  protected $permanent_link = false;
52  protected $adv_layout = false;
53  protected $content_style_sheet = "";
54 
64  function ilTemplate($file,$flag1,$flag2,$in_module = false, $vars = "DEFAULT",
65  $plugin = false, $a_use_cache = false)
66  {
67  global $ilias;
68 //echo "<br>-".$file."-";
69  $this->activeBlock = "__global__";
70  $this->vars = array();
71  $this->addFooter = TRUE;
72 
73  $this->il_use_cache = $a_use_cache;
74  $this->il_cur_key = $file."/".$in_module;
75 
76  $fname = $this->getTemplatePath($file, $in_module, $plugin);
77 
78  $this->tplName = basename($fname);
79  $this->tplPath = dirname($fname);
80  // set default content-type to text/html
81  $this->contenttype = "text/html";
82  if (!file_exists($fname))
83  {
84  $ilias->raiseError("template ".$fname." was not found.", $ilias->error_obj->FATAL);
85  return false;
86  }
87 
88  //$this->IntegratedTemplateExtension(dirname($fname));
89  $this->callConstructor();
90  //$this->loadTemplatefile(basename($fname), $flag1, $flag2);
91  $this->loadTemplatefile($fname, $flag1, $flag2);
92  //add tplPath to replacevars
93  $this->vars["TPLPATH"] = $this->tplPath;
94 
95  // set Options
96  if (method_exists($this, "setOption"))
97  {
98  $this->setOption('use_preg', false);
99  }
100  $this->setBodyClass("std");
101 
102  return true;
103  }
104 
105  // overwrite their init function
106  function init()
107  {
108  $this->free();
109  $this->buildFunctionlist();
110 
111  $cache_hit = false;
112  if ($this->il_use_cache)
113  {
114  // cache hit
115  if (isset(self::$il_cache[$this->il_cur_key]) && is_array(self::$il_cache[$this->il_cur_key]))
116  {
117  $cache_hit = true;
118 //echo "cache hit";
119  $this->err = self::$il_cache[$this->il_cur_key]["err"];
120  $this->flagBlocktrouble = self::$il_cache[$this->il_cur_key]["flagBlocktrouble"];
121  $this->blocklist = self::$il_cache[$this->il_cur_key]["blocklist"];
122  $this->blockdata = self::$il_cache[$this->il_cur_key]["blockdata"];
123  $this->blockinner = self::$il_cache[$this->il_cur_key]["blockinner"];
124  $this->blockparents = self::$il_cache[$this->il_cur_key]["blockparents"];
125  $this->blockvariables = self::$il_cache[$this->il_cur_key]["blockvariables"];
126  }
127  }
128 
129  if (!$cache_hit)
130  {
131  $this->findBlocks($this->template);
132  $this->template = '';
133  $this->buildBlockvariablelist();
134  if ($this->il_use_cache)
135  {
136  self::$il_cache[$this->il_cur_key]["err"] = $this->err;
137  self::$il_cache[$this->il_cur_key]["flagBlocktrouble"] = $this->flagBlocktrouble;
138  self::$il_cache[$this->il_cur_key]["blocklist"] = $this->blocklist;
139  self::$il_cache[$this->il_cur_key]["blockdata"] = $this->blockdata;
140  self::$il_cache[$this->il_cur_key]["blockinner"] = $this->blockinner;
141  self::$il_cache[$this->il_cur_key]["blockparents"] = $this->blockparents;
142  self::$il_cache[$this->il_cur_key]["blockvariables"] = $this->blockvariables;
143  }
144  }
145 
146  // we don't need it any more
147  $this->template = '';
148 
149  } // end func init
150 
151  /*
152  * Sets whether the ILIAS footer should be shown or not
153  *
154  * @param boolean $value TRUE to show the ILIAS footer, FALSE to hide it
155  */
156  function setAddFooter($value)
157  {
158  $this->addFooter = $value;
159  }
160 
161  /*
162  * Returns whether the ILIAS footer should be shown or not
163  *
164  * @return boolean TRUE if the ILIAS footer will be shown, FALSE otherwise
165  */
166  function getAddFooter()
167  {
168  return $this->addFooter;
169  }
170 
171 
176  function getAsynch()
177  {
178  header("Content-type: " . $this->getContentType() . "; charset=UTF-8");
179  return $this->get();
180  }
181 
188  function get($part = "DEFAULT", $add_error_mess = false,
189  $handle_referer = false, $add_ilias_footer = false,
190  $add_standard_elements = false, $a_main_menu = true, $a_tabs = true)
191  {
192  if ($add_error_mess)
193  {
194  $this->fillMessage();
195  }
196 
197  if ($add_ilias_footer)
198  {
199  $this->addILIASFooter();
200  }
201 
202  // set standard parts (tabs and title icon)
203  if($add_standard_elements)
204  {
205  // to get also the js files for the main menu
206  $this->getMainMenu();
207 
208  // these fill blocks in tpl.main.html
209  $this->fillCssFiles();
210  $this->fillContentStyle();
211  $this->fillBodyClass();
212  $this->fillOnLoadCode();
213 
214  // these fill just plain placeholder variables in tpl.main.html
215  $this->setCurrentBlock("DEFAULT");
216  $this->fillNewContentStyle();
217  $this->fillContentLanguage();
218  $this->fillWindowTitle();
219 
220  // these fill blocks in tpl.adm_content.html
221  /* Change Sn */
222  if (!KIOSK_MODE) $this->fillHeader();
223  if (!KIOSK_MODE) $this->fillSideIcons();
224  if (!KIOSK_MODE) $this->fillScreenReaderFocus();
225  if (!KIOSK_MODE) $this->fillStopFloating();
226  if (!KIOSK_MODE) $this->fillPageFormAction();
227  if (!KIOSK_MODE) $this->fillLeftContent();
228  if (!KIOSK_MODE) $this->fillRightContent();
229  if (!KIOSK_MODE) $this->fillAdminPanel();
230  if (!KIOSK_MODE) $this->fillPermanentLink();
231  if (!KIOSK_MODE) $this->fillToolbar();
232 
233  // late loading of javascipr files, since operations above may add files
234  $this->fillJavaScriptFiles();
235 
236  // these fill just plain placeholder variables in tpl.adm_content.html
237  if ($this->blockExists("content"))
238  {
239  $this->setCurrentBlock("content");
240  if ($a_tabs)
241  {
242  if (!KIOSK_MODE) $this->fillTabs();
243  }
244  $this->fillMainContent();
245  if ($a_main_menu)
246  {
247  $this->fillMainMenu();
248  }
249  $this->parseCurrentBlock();
250  }
251  }
252 
253  if ($handle_referer)
254  {
255  $this->handleReferer();
256  }
257 
258  if ($part == "DEFAULT")
259  {
260  return parent::get();
261  }
262  else
263  {
264  return parent::get($part);
265  }
266 
267  }
268 
273  function setMessage($a_type, $a_txt, $a_keep = false)
274  {
275  if (!in_array($a_type, array("info", "success", "failure", "question")) || $a_txt == "")
276  {
277  return;
278  }
279  if ($a_type == "question")
280  {
281  $a_type = "mess_question";
282  }
283  if (!$a_keep)
284  {
285  $this->message[$a_type] = $a_txt;
286  }
287  else
288  {
289  $_SESSION[$a_type] = $a_txt;
290  }
291  }
292 
293  function fillMessage()
294  {
295  global $lng;
296 
297  $ms = array("info", "success", "failure", "question");
298  $out = "";
299 
300  foreach ($ms as $m)
301  {
302  $txt = "";
303  if ($m == "question")
304  {
305  $m = "mess_question";
306  }
307 
308  if (isset($_SESSION[$m]) && $_SESSION[$m] != "")
309  {
310  $txt = $_SESSION[$m];
311  }
312  else if (isset($this->message[$m]))
313  {
314  $txt = $this->message[$m];
315  }
316 
317  if ($m == "mess_question")
318  {
319  $m = "question";
320  }
321 
322  if ($txt != "")
323  {
324  $out.= $this->getMessageHTML($txt, $m);
325  }
326 
327  if ($m == "question")
328  {
329  $m = "mess_question";
330  }
331 
332  if (isset($_SESSION[$m]) && $_SESSION[$m])
333  {
334  //session_unregister($m);
335  unset($_SESSION[$m]); // backport 32335
336  }
337  }
338 
339  if ($out != "")
340  {
341  $this->setVariable("MESSAGE", $out);
342  }
343  }
344 
348  public function getMessageHTML($a_txt, $a_type = "info")
349  {
350  global $lng;
351 
352  $mtpl = new ilTemplate("tpl.message.html", true, true, "Services/Utilities");
353  $mtpl->setCurrentBlock($a_type."_message");
354  $mtpl->setVariable("TEXT", $a_txt);
355  $mtpl->setVariable("MESSAGE_HEADING", $lng->txt($a_type."_message"));
356  $mtpl->setVariable("ALT_IMAGE", $lng->txt("icon")." ".$lng->txt($a_type."_message"));
357  $mtpl->setVariable("SRC_IMAGE", ilUtil::getImagePath("mess_".$a_type.".gif"));
358  $mtpl->parseCurrentBlock();
359 
360  return $mtpl->get();
361  }
362 
369  function getContentType()
370  {
371  return $this->contenttype;
372  }
373 
384  function setContentType($a_content_type = "text/html")
385  {
386  $this->contenttype = $a_content_type;
387  }
388 
394  function show($part = "DEFAULT", $a_fill_tabs = true, $a_skip_main_menu = false)
395  {
396  global $ilias;
397  // include yahoo dom per default
398  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
400 
401 //echo "-".ilUtil::getP3PLocation()."-";
402  //header('P3P: policyref="'.ilUtil::getP3PLocation().
403  // '", CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
404  header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"');
405  header("Content-type: " . $this->getContentType() . "; charset=UTF-8");
406 
407  $this->fillMessage();
408 
409  // display ILIAS footer
410  if ($part !== false)
411  {
412  if (!KIOSK_MODE) $this->addILIASFooter(); //Change Sn
413  }
414 
415  // set standard parts (tabs and title icon)
416  $this->fillBodyClass();
417  if ($a_fill_tabs)
418  {
419  // to get also the js files for the main menu
420  if (!$a_skip_main_menu)
421  {
422  $this->getMainMenu();
423  }
424 
425  // these fill blocks in tpl.main.html
426  $this->fillCssFiles();
427  //$this->fillJavaScriptFiles();
428  $this->fillContentStyle();
429 
430  // these fill just plain placeholder variables in tpl.main.html
431  $this->setCurrentBlock("DEFAULT");
432  $this->fillNewContentStyle();
433  $this->fillContentLanguage();
434  $this->fillWindowTitle();
435  $this->fillOnLoadCode();
436 
437  // these fill blocks in tpl.adm_content.html
438  /* Change Sn */
439  if (!KIOSK_MODE) $this->fillHeader(); //Change Sn
440  if (!KIOSK_MODE) $this->fillSideIcons();
441  if (!KIOSK_MODE) $this->fillScreenReaderFocus();
442  if (!KIOSK_MODE) $this->fillStopFloating();
443  if (!KIOSK_MODE) $this->fillPageFormAction();
444  if (!KIOSK_MODE) $this->fillLeftContent();
445  if (!KIOSK_MODE) $this->fillRightContent();
446  if (!KIOSK_MODE) $this->fillAdminPanel();
447  if (!KIOSK_MODE) $this->fillPermanentLink();
448  if (!KIOSK_MODE) $this->fillToolbar();
449  /* Change Sn End */
450  // late loading of javascipr files, since operations above may add files
451  $this->fillJavaScriptFiles();
452 
453  // these fill just plain placeholder variables in tpl.adm_content.html
454  // these fill just plain placeholder variables in tpl.adm_content.html
455  if ($this->blockExists("content"))
456  {
457  $this->setCurrentBlock("content");
458  if (!KIOSK_MODE) $this->fillTabs(); //Change Sn
459  $this->fillMainContent();
460  $this->fillMainMenu();
461  $this->parseCurrentBlock();
462  }
463  }
464 
465  if ($part == "DEFAULT" or is_bool($part))
466  {
467  parent::show();
468  }
469  else
470  {
471  parent::show($part);
472  }
473  $this->handleReferer();
474  }
475 
476 
483  public function fillContentLanguage()
484  {
485  global $ilUser,$lng;
486 
487  if(is_object($ilUser))
488  {
489  if($ilUser->getLanguage())
490  {
491  $this->setVariable('META_CONTENT_LANGUAGE',$ilUser->getLanguage());
492  return true;
493  }
494  if(is_object($lng))
495  {
496  $this->setVariable('META_CONTENT_LANGUAGE',$lng->getDefaultLanguage());
497  return true;
498  }
499  }
500  $this->setVariable('META_CONTENT_LANGUAGE','en');
501  return true;
502  }
503 
504  function fillWindowTitle()
505  {
506  global $ilSetting;
507 
508  if ($this->header_page_title != "")
509  {
510  $a_title = ilUtil::stripScriptHTML($this->header_page_title);
511  $this->setVariable("PAGETITLE", "- ".$a_title);
512  }
513 
514  if ($ilSetting->get('short_inst_name') != "")
515  {
516  $this->setVariable("WINDOW_TITLE",
517  $ilSetting->get('short_inst_name'));
518  }
519  else
520  {
521  $this->setVariable("WINDOW_TITLE",
522  "ILIAS");
523  }
524  }
525 
526  function fillTabs()
527  {
528  global $ilias,$ilTabs;
529 
530  if ($this->blockExists("tabs_outer_start"))
531  {
532  $sthtml = $ilTabs->getSubTabHTML();
533  $thtml = $ilTabs->getHTML((trim($sthtml) == ""));
534 
535  $this->touchBlock("tabs_outer_start");
536  $this->touchBlock("tabs_outer_end");
537  $this->touchBlock("tabs_inner_start");
538  $this->touchBlock("tabs_inner_end");
539 
540  if ($thtml != "")
541  {
542  $this->setVariable("TABS",$thtml);
543  }
544  $this->setVariable("SUB_TABS", $sthtml);
545  }
546  }
547 
551  function enableAdvancedColumnLayout($a_left, $a_right)
552  {
553  $this->adv_layout = true;
554  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
556  }
557 
558  function fillToolbar()
559  {
560  global $ilToolbar;
561 
562  $this->setVariable("BUTTONS", $ilToolbar->getHTML());
563  }
564 
566  {
567  if ($this->page_form_action != "")
568  {
569  $this->setCurrentBlock("page_form_start");
570  $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action);
571  $this->parseCurrentBlock();
572  $this->touchBlock("page_form_end");
573  }
574  }
575 
576  function fillJavaScriptFiles($a_force = false)
577  {
578  global $ilias, $ilTabs, $ilSetting, $ilUser;
579 
580  if (is_object($ilSetting)) // maybe this one can be removed
581  {
582  $vers = "vers=".str_replace(array(".", " "), "-", $ilSetting->get("ilias_version"));
583  }
584  if ($this->blockExists("js_file"))
585  {
586  // three batches
587  for ($i=1; $i<=3; $i++)
588  {
589  reset($this->js_files);
590  foreach($this->js_files as $file)
591  {
592  if (is_file($file) || substr($file, 0, 4) == "http" || $a_force)
593  {
594  if ($this->js_files_batch[$file] == $i)
595  {
596  $this->setCurrentBlock("js_file");
597 
598  if ($this->js_files_vp[$file])
599  {
600  $this->setVariable("JS_FILE", ilUtil::appendUrlParameterString($file,$vers));
601  }
602  else
603  {
604  $this->setVariable("JS_FILE", $file);
605  }
606 
607  $this->parseCurrentBlock();
608  }
609  }
610  }
611  }
612  }
613  }
614 
615  function fillCssFiles($a_force = false)
616  {
617  if (!$this->blockExists("css_file"))
618  {
619  return;
620  }
621  foreach($this->css_files as $css)
622  {
623  $filename = $css["file"];
624  if (strpos($filename, "?") > 0) $filename = substr($filename, 0, strpos($filename, "?"));
625  if (is_file($filename) || $a_force)
626  {
627  $this->setCurrentBlock("css_file");
628  $this->setVariable("CSS_FILE", $css["file"]);
629  $this->setVariable("CSS_MEDIA", $css["media"]);
630  $this->parseCurrentBlock();
631  }
632  }
633  }
634 
638  function setContentStyleSheet($a_style)
639  {
640  $this->content_style_sheet = $a_style;
641  }
642 
646  function fillContentStyle()
647  {
648  if ($this->content_style_sheet != "")
649  {
650  $this->setCurrentBlock("ContentStyle");
651  $this->setVariable("LOCATION_CONTENT_STYLESHEET",
652  $this->content_style_sheet);
653  $this->parseCurrentBlock();
654  }
655  }
656 
660  private function fillNewContentStyle()
661  {
662  $this->setVariable("LOCATION_NEWCONTENT_STYLESHEET_TAG",
663  '<link rel="stylesheet" type="text/css" href="'.
665  .'" />');
666  }
667 
668  function getMainMenu()
669  {
670  global $ilMainMenu;
671 
672  $ilMainMenu->setLoginTargetPar($this->getLoginTargetPar());
673  $this->main_menu = $ilMainMenu->getHTML();
674  }
675 
676  function fillMainMenu()
677  {
678  global $tpl, $ilMainMenu, $ilCtrl, $ilSetting, $ilUser;
679  $tpl->setVariable("MAINMENU", $this->main_menu);
680  if($this->variableExists('MAINMENU'))
681  {
682  global $ilAuth, $lng, $tpl, $ilClientIniFile, $ilUser;
683 
684  if((int)$ilSetting->get('session_handling_type') == 0 &&
685  (int)$ilSetting->get('session_reminder_enabled') &&
686  $ilUser->getId() != ANONYMOUS_USER_ID &&
687  (int)$ilUser->getPref('session_reminder_enabled'))
688  {
689  $leadTime = (float)$ilUser->getPref('session_reminder_lead_time') * 60;
690  $expiresTime = $ilAuth->sessionValidThru();
691  $currentTime = time();
692  $expiresInXSeconds = $expiresTime - $currentTime;
693 
694  if($leadTime > $expiresInXSeconds) return;
695 
696  $tplSR = new ilTemplate('tpl.SessionReminder.js', true, true);
697 
698  $tplSR->setVariable('ILIAS_SESSION_COUNTDOWN', ($expiresInXSeconds - $leadTime) * 1000);
699  $tplSR->setVariable('ILIAS_SESSION_EXTENDER_URL', './ilias.php?baseClass=ilPersonalDesktopGUI');
700  $tplSR->setVariable('ILIAS_SESSION_CHECKER_URL',
701  './sessioncheck.php'.
702  '?lang='.$lng->getLangKey().
703  '&client_id='.CLIENT_ID.
704  '&session_id='.session_id().
705  '&lead_time='.$leadTime.
706  '&timezone='.urlencode($ilUser->getTimeZone()).
707  '&countDownTime='.($expiresInXSeconds - $leadTime));
708  $tplSR->setVariable('CONFIRM_TXT', $lng->txt('session_reminder_alert'));
709 
710  $tpl->setVariable('SESSION_REMINDER', $tplSR->get());
711  }
712  }
713  }
714 
718  function addILIASFooter()
719  {
720  global $ilAuth;
721 
722  if (!$this->getAddFooter()) return;
723  global $ilias, $ilClientIniFile, $ilCtrl, $ilDB, $ilSetting;
724 
725  $ftpl = new ilTemplate("tpl.footer.html", true, true);
726 
727  $ftpl->setVariable("ILIAS_VERSION", $ilias->getSetting("ilias_version"));
728 
729  // output translation link
730  if ($ilSetting->get("lang_ext_maintenance") == "1")
731  {
732  include_once("Services/Language/classes/class.ilObjLanguageAccess.php");
734  {
735  include_once("Services/Language/classes/class.ilObjLanguageExtGUI.php");
736  $ftpl->setVariable("TRANSLATION_LINK",
738  }
739  }
740 
741  if (DEVMODE)
742  {
743  // execution time
744  $t1 = explode(" ", $GLOBALS['ilGlobalStartTime']);
745  $t2 = explode(" ", microtime());
746  $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1];
747 
748  $mem_usage = "";
749  if(function_exists("memory_get_usage"))
750  {
751  $mem_usage.=
752  "<br /> Memory Usage: ".memory_get_usage()." Bytes";
753  }
754  if(function_exists("xdebug_peak_memory_usage"))
755  {
756  $mem_usage.=
757  "<br /> XDebug Peak Memory Usage: ".xdebug_peak_memory_usage()." Bytes";
758  }
759  $mem_usage.= "<br>".round($diff, 4)." Seconds";
760 
761  if ($mem_usage != "")
762  {
763  $ftpl->setVariable("MEMORY_USAGE", $mem_usage);
764  }
765 
766  if (is_object($ilAuth) && isset($_SESSION[$ilAuth->_sessionName]) &&
767  isset($_SESSION[$ilAuth->_sessionName]["timestamp"]))
768  {
769  $ftpl->setVariable("SESS_INFO", "<br />maxlifetime: ".
770  ini_get("session.gc_maxlifetime")." (".
771  (ini_get("session.gc_maxlifetime")/60)."), id: ".session_id()."<br />".
772  "timestamp: ".date("Y-m-d H:i:s", $_SESSION[$ilAuth->_sessionName]["timestamp"]).
773  ", idle: ".date("Y-m-d H:i:s", $_SESSION[$ilAuth->_sessionName]["idle"]).
774  "<br />expire: ".($exp = $ilClientIniFile->readVariable("session","expire")).
775  " (".($exp/60)."), session ends at: ".
776  date("Y-m-d H:i:s", $_SESSION[$ilAuth->_sessionName]["idle"] + $exp));
777  }
778 
779  if (version_compare(PHP_VERSION,'5','>='))
780  {
781  $ftpl->setVariable("VALIDATION_LINKS",
782  '<br /><a href="'.
783  ilUtil::appendUrlParameterString($_SERVER["REQUEST_URI"], "do_dev_validate=xhtml").
784  '">Validate</a> | <a href="'.
785  ilUtil::appendUrlParameterString($_SERVER["REQUEST_URI"], "do_dev_validate=accessibility").
786  '">Accessibility</a>');
787  }
788  if (!empty($_GET["do_dev_validate"]) && $ftpl->blockExists("xhtml_validation"))
789  {
790  require_once("Services/XHTMLValidator/classes/class.ilValidatorAdapter.php");
791  $template2 = ilPHP::cloneObject($this);
792 //echo "-".ilValidatorAdapter::validate($template2->get(), $_GET["do_dev_validate"])."-";
793  $ftpl->setCurrentBlock("xhtml_validation");
794  $ftpl->setVariable("VALIDATION",
795  ilValidatorAdapter::validate($template2->get("DEFAULT",
796  false, false, false, true), $_GET["do_dev_validate"]));
797  $ftpl->parseCurrentBlock();
798  }
799 
800  // controller history
801  if (is_object($ilCtrl) && $ftpl->blockExists("c_entry") &&
802  $ftpl->blockExists("call_history"))
803  {
804  $hist = $ilCtrl->getCallHistory();
805  foreach($hist as $entry)
806  {
807  $ftpl->setCurrentBlock("c_entry");
808  $ftpl->setVariable("C_ENTRY", $entry["class"]);
809  if (is_object($ilDB))
810  {
811  $file = $ilCtrl->lookupClassPath($entry["class"]);
812  $add = $entry["mode"]." - ".$entry["cmd"];
813  if ($file != "")
814  {
815  $add.= " - ".$file;
816  }
817  $ftpl->setVariable("C_FILE", $add);
818  }
819  $ftpl->parseCurrentBlock();
820  }
821  $ftpl->setCurrentBlock("call_history");
822  $ftpl->parseCurrentBlock();
823 
824  // debug hack
825  $debug = $ilCtrl->getDebug();
826  foreach($debug as $d)
827  {
828  $ftpl->setCurrentBlock("c_entry");
829  $ftpl->setVariable("C_ENTRY", $d);
830  $ftpl->parseCurrentBlock();
831  }
832  $ftpl->setCurrentBlock("call_history");
833  $ftpl->parseCurrentBlock();
834  }
835 
836  // included files
837  if (is_object($ilCtrl) && $ftpl->blockExists("i_entry") &&
838  $ftpl->blockExists("included_files"))
839  {
840  $fs = get_included_files();
841  $ifiles = array();
842  $total = 0;
843  foreach($fs as $f)
844  {
845  $ifiles[] = array("file" => $f, "size" => filesize($f));
846  $total += filesize($f);
847  }
848  $ifiles = ilUtil::sortArray($ifiles, "size", "desc", true);
849  foreach($ifiles as $f)
850  {
851  $ftpl->setCurrentBlock("i_entry");
852  $ftpl->setVariable("I_ENTRY", $f["file"]." (".$f["size"]." Bytes, ".round(100 / $total * $f["size"], 2)."%)");
853  $ftpl->parseCurrentBlock();
854  }
855  $ftpl->setCurrentBlock("i_entry");
856  $ftpl->setVariable("I_ENTRY", "Total (".$total." Bytes, 100%)");
857  $ftpl->parseCurrentBlock();
858  $ftpl->setCurrentBlock("included_files");
859  $ftpl->parseCurrentBlock();
860  }
861 
862  }
863 
864  // BEGIN Usability: Non-Delos Skins can display the elapsed time in the footer
865  // The corresponding $ilBench->start invocation is in inc.header.php
866  global $ilBench;
867  $ilBench->stop("Core", "ElapsedTimeUntilFooter");
868  $ftpl->setVariable("ELAPSED_TIME",
869  ", ".number_format($ilBench->getMeasuredTime("Core", "ElapsedTimeUntilFooter"),1).' seconds');
870  // END Usability: Non-Delos Skins can display the elapsed time in the footer
871 
872  $this->setVariable("FOOTER", $ftpl->get());
873  }
874 
875 
880  function handleReferer()
881  {
882  if ((substr(strrchr($_SERVER["PHP_SELF"],"/"),1) != "error.php")
883  && (substr(strrchr($_SERVER["PHP_SELF"],"/"),1) != "adm_menu.php"))
884  {
885  $_SESSION["post_vars"] = $_POST;
886 
887  // referer is modified if query string contains cmd=gateway and $_POST is not empty.
888  // this is a workaround to display formular again in case of error and if the referer points to another page
889  $url_parts = @parse_url($_SERVER["REQUEST_URI"]);
890  if(!$url_parts)
891  {
892  $protocol = (isset($_SERVER['HTTPS']) ? 'https' : 'http').'://';
893  $host = $_SERVER['HTTP_HOST'];
894  $path = $_SERVER['REQUEST_URI'];
895  $url_parts = @parse_url($protocol.$host.$path);
896  }
897 
898  if (isset($url_parts["query"]) && preg_match("/cmd=gateway/",$url_parts["query"]) && (isset($_POST["cmd"]["create"])))
899  {
900  foreach ($_POST as $key => $val)
901  {
902  if (is_array($val))
903  {
904  $val = key($val);
905  }
906 
907  $str .= "&".$key."=".$val;
908  }
909 
910  $_SESSION["referer"] = preg_replace("/cmd=gateway/",substr($str,1),$_SERVER["REQUEST_URI"]);
911  $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
912 
913  }
914  else if (isset($url_parts["query"]) && preg_match("/cmd=post/",$url_parts["query"]) && (isset($_POST["cmd"]["create"])))
915  {
916  foreach ($_POST as $key => $val)
917  {
918  if (is_array($val))
919  {
920  $val = key($val);
921  }
922 
923  $str .= "&".$key."=".$val;
924  }
925 
926  $_SESSION["referer"] = preg_replace("/cmd=post/",substr($str,1),$_SERVER["REQUEST_URI"]);
927  if (isset($_GET['ref_id']))
928  {
929  $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
930  }
931  else
932  {
933  $_SESSION['referer_ref_id'] = 0;
934  }
935  }
936  else
937  {
938  $_SESSION["referer"] = $_SERVER["REQUEST_URI"];
939  if (isset($_GET['ref_id']))
940  {
941  $_SESSION['referer_ref_id'] = (int) $_GET['ref_id'];
942  }
943  else
944  {
945  $_SESSION['referer_ref_id'] = 0;
946  }
947  }
948 
949  unset($_SESSION["error_post_vars"]);
950  }
951  }
952 
959  function blockExists($a_blockname)
960  {
961  // added second evaluation to the return statement because the first one only works for the content block (Helmut Schottmüller, 2007-09-14)
962  return (isset($this->blockvariables["content"][$a_blockname]) ? true : false) | (isset($this->blockvariables[$a_blockname]) ? true : false);
963  }
964 
965  private function variableExists($a_variablename)
966  {
967  return (isset($this->blockvariables["content"][$a_variablename]) ? true : false);
968  }
969 
976  function fillVars()
977  {
978  $count = 0;
979  reset($this->vars);
980 
981  while(list($key, $val) = each($this->vars))
982  {
983  if (is_array($this->blockvariables[$this->activeBlock]))
984  {
985  if (array_key_exists($key, $this->blockvariables[$this->activeBlock]))
986  {
987  $count++;
988 
989  $this->setVariable($key, $val);
990  }
991  }
992  }
993 
994  return $count;
995  }
996 
1003  function setCurrentBlock ($part = "DEFAULT")
1004  {
1005  $this->activeBlock = $part;
1006 
1007  if ($part == "DEFAULT")
1008  {
1009  return parent::setCurrentBlock();
1010  }
1011  else
1012  {
1013  return parent::setCurrentBlock($part);
1014  }
1015  }
1016 
1023  function touchBlock($block)
1024  {
1025  $this->setCurrentBlock($block);
1026  $count = $this->fillVars();
1027  $this->parseCurrentBlock();
1028 
1029  if ($count == 0)
1030  {
1031  parent::touchBlock($block);
1032  }
1033  }
1034 
1041  function parseCurrentBlock($part = "DEFAULT")
1042  {
1043  // Hier erst noch ein replace aufrufen
1044  if ($part != "DEFAULT")
1045  {
1046  $tmp = $this->activeBlock;
1047  $this->activeBlock = $part;
1048  }
1049 
1050  if ($part != "DEFAULT")
1051  {
1052  $this->activeBlock = $tmp;
1053  }
1054 
1055  $this->fillVars();
1056 
1057  $this->activeBlock = "__global__";
1058 
1059  if ($part == "DEFAULT")
1060  {
1061  return parent::parseCurrentBlock();
1062  }
1063  else
1064  {
1065  return parent::parseCurrentBlock($part);
1066  }
1067  }
1068 
1079  function replaceFromDatabase(&$DB,$block,$conv,$select="default")
1080  {
1081  $res = $DB->selectDbAll();
1082 
1083  while ($DB->getDbNextElement($res))
1084  {
1085  $this->setCurrentBlock($block);
1086  $result = array();
1087  reset($conv);
1088 
1089  while (list ($key,$val) = each ($conv))
1090  {
1091  $result[$val]=$DB->element->data[$key];
1092  }
1093 
1094  if (($select != "default")
1095  && ($DB->element->data[$select["id"]]==$select["value"]
1096  || (strtolower($select["text"]) == "checked"
1097  && strpos( ",,".$select["value"].",," , ",".$DB->element->data[$select["id"]]."," )!=false)))
1098  {
1099  $result[$select["field"]] = $select["text"];
1100  }
1101 
1102  $this->replace($result);
1103  $this->parseCurrentBlock($block);
1104  }
1105  }
1106 
1114  {
1115  if (!is_array($vars))
1116  {
1117  return;
1118  }
1119 
1120  reset($vars);
1121 
1122  while (list($i) = each($vars))
1123  {
1124  $vars[$i] = stripslashes($vars[$i]);
1125  $vars[$i] = htmlspecialchars($vars[$i]);
1126  }
1127 
1128  return($vars);
1129  }
1130 
1135  function replace()
1136  {
1137  reset($this->vars);
1138 
1139  while(list($key, $val) = each($this->vars))
1140  {
1141  $this->setVariable($key, $val);
1142  }
1143  }
1144 
1149  function replaceDefault()
1150  {
1151  $this->replace($this->vars);
1152  }
1153 
1161  function checkTopic($a_block, $a_topic)
1162  {
1163  return array_key_exists($a_topic, $this->blockvariables[$a_block]);
1164  }
1165 
1172  {
1173  return $this->checkTopic("__global__", "NAVIGATION");
1174  }
1175 
1181  function includeTree()
1182  {
1183  return $this->checkTopic("__global__", "TREE");
1184  }
1185 
1192  {
1193  return file_exists($this->tplPath."/".$filename);
1194  }
1195 
1196 
1206  function addBlockFile($var, $block, $tplname, $in_module = false)
1207  {
1208  if (DEBUG)
1209  {
1210  echo "<br/>Template '".$this->tplPath."/".$tplname."'";
1211  }
1212 
1213  $tplfile = $this->getTemplatePath($tplname, $in_module);
1214  if (file_exists($tplfile) == false)
1215  {
1216  echo "<br/>Template '".$tplfile."' doesn't exist! aborting...";
1217  return false;
1218  }
1219 
1220  return parent::addBlockFile($var, $block, $tplfile);
1221  }
1222 
1231  function getTemplatePath($a_tplname, $a_in_module = false, $a_plugin = false)
1232  {
1233  global $ilias, $ilCtrl;
1234 
1235  $fname = "";
1236 
1237  // if baseClass functionality is used (ilias.php):
1238  // get template directory from ilCtrl
1239  if (!empty($_GET["baseClass"]) && $a_in_module === true)
1240  {
1241  $a_in_module = $ilCtrl->getModuleDir();
1242  }
1243 
1244  if (strpos($a_tplname,"/") === false)
1245  {
1246  $module_path = "";
1247 
1248  //$fname = $ilias->tplPath;
1249  if ($a_in_module)
1250  {
1251  if ($a_in_module === true)
1252  {
1253  $module_path = ILIAS_MODULE."/";
1254  }
1255  else
1256  {
1257  $module_path = $a_in_module."/";
1258  }
1259  }
1260 
1261  if ($ilias->account->skin != "default")
1262  {
1263  $fname = "./Customizing/global/skin/".
1264  $ilias->account->skin."/".$module_path.basename($a_tplname);
1265  }
1266  if($fname == "" || !file_exists($fname))
1267  {
1268  $fname = "./".$module_path."templates/default/".basename($a_tplname);
1269  }
1270  }
1271  else
1272  {
1273  $fname = $a_tplname;
1274  }
1275 
1276  return $fname;
1277  }
1278 
1279  function setHeaderPageTitle($a_title)
1280  {
1281  $a_title = ilUtil::stripScriptHTML($a_title);
1282  $this->header_page_title = $a_title;
1283  }
1284 
1285  function setStyleSheetLocation($a_stylesheet)
1286  {
1287  $this->setVariable("LOCATION_STYLESHEET", $a_stylesheet);
1288  }
1289 
1290  function setNewContentStyleSheetLocation($a_stylesheet)
1291  {
1292  $this->setVariable("LOCATION_NEWCONTENT_STYLESHEET", $a_stylesheet);
1293  }
1294 
1296  {
1297  $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
1298  $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
1299  }
1300 
1304  function setTitle($a_title)
1305  {
1306  $this->title = ilUtil::stripScriptHTML($a_title);
1307  $this->header_page_title = $a_title;
1308  }
1309 
1313  private function fillHeader()
1314  {
1315  global $lng;
1316 
1317  if ($this->icon_path != "")
1318  {
1319  if ($this->icon_desc != "")
1320  {
1321  $this->setCurrentBlock("header_image_desc");
1322  $this->setVariable("IMAGE_DESC", $lng->txt("icon")." ".$this->icon_desc);
1323  $this->parseCurrentBlock();
1324  }
1325  $this->setCurrentBlock("header_image");
1326  if ($this->icon_desc != "")
1327  {
1328  $this->setVariable("IMAGE_ALT", $lng->txt("icon")." ".$this->icon_desc);
1329  }
1330  else
1331  {
1332  // empty alt tag for images that, e.g. are directly attached in heading
1333  // and would only repeat the heading text
1334  $this->setVariable("IMAGE_ALT", "");
1335  }
1336  $this->setVariable("IMG_HEADER", $this->icon_path);
1337  $this->parseCurrentBlock();
1338  $header = true;
1339  }
1340 
1341  if ($this->title != "")
1342  {
1343  $this->title = ilUtil::stripScriptHTML($this->title);
1344  $this->setVariable("HEADER", $this->title);
1345  $header = true;
1346  }
1347 
1348  if ($header)
1349  {
1350  $this->setCurrentBlock("header_image");
1351  $this->parseCurrentBlock();
1352  }
1353 
1354  if ($this->title_desc != "")
1355  {
1356  $this->setCurrentBlock("header_desc");
1357  $this->setVariable("H_DESCRIPTION", $this->title_desc);
1358  $this->parseCurrentBlock();
1359  }
1360  }
1361 
1365  function setTitleIcon($a_icon_path, $a_icon_desc = "")
1366  {
1367  $this->icon_desc = $a_icon_desc;
1368  $this->icon_path = $a_icon_path;
1369  }
1370 
1371  function setBodyClass($a_class = "")
1372  {
1373  $this->body_class = $a_class;
1374  }
1375 
1376  function fillBodyClass()
1377  {
1378  if ($this->body_class != "" && $this->blockExists("body_class"))
1379  {
1380  $this->setCurrentBlock("body_class");
1381  $this->setVariable("BODY_CLASS", $this->body_class);
1382  $this->parseCurrentBlock();
1383  }
1384  }
1385 
1386  function setPageFormAction($a_action)
1387  {
1388  $this->page_form_action = $a_action;
1389  }
1390 
1394  function setDescription($a_descr)
1395  {
1396  $this->title_desc = $a_descr;
1397 // $this->setVariable("H_DESCRIPTION", $a_descr);
1398  }
1399 
1404  {
1405  $this->stop_floating = true;
1406  }
1407 
1411  private function fillStopFloating()
1412  {
1413  if ($this->stop_floating)
1414  {
1415  $this->touchBlock("stop_floating");
1416  }
1417  }
1418 
1422  function setContent($a_html)
1423  {
1424  if ($a_html != "")
1425  {
1426  $this->main_content = $a_html;
1427  }
1428  }
1429 
1433  private function fillMainContent()
1434  {
1435  if (trim($this->main_content) != "")
1436  {
1437  $this->setVariable("ADM_CONTENT", $this->main_content);
1438  }
1439  if($this->adv_layout)
1440  {
1441  $this->touchBlock("adv_layout_init");
1442  $this->setVariable("COL_LAY_SKIN", " yui-skin-sam");
1443  }
1444  }
1445 
1449  function setRightContent($a_html)
1450  {
1451  $this->right_content = $a_html;
1452  }
1453 
1457  private function fillRightContent()
1458  {
1459  if (trim($this->right_content) != "")
1460  {
1461  $this->setCurrentBlock("right_column");
1462  $this->setVariable("RIGHT_CONTENT", $this->right_content);
1463  $this->parseCurrentBlock();
1464  $this->touchBlock("right_columnt");
1465  }
1466  }
1467 
1471  function setLeftContent($a_html)
1472  {
1473  $this->left_content = $a_html;
1474  }
1475 
1479  private function fillLeftContent()
1480  {
1481  if (trim($this->left_content) != "")
1482  {
1483  $this->setCurrentBlock("left_column");
1484  $this->setVariable("LEFT_CONTENT", $this->left_content);
1485  $this->parseCurrentBlock();
1486  $this->touchBlock("left_columnt");
1487  }
1488  }
1489 
1493  function setLocator()
1494  {
1495  if (KIOSK_MODE) return true; // Change Sn
1496  global $ilLocator, $lng;
1497  $this->setVariable("LOCATOR", $ilLocator->getHTML());
1498  }
1499 
1503  function setTabs($a_tabs_html)
1504  {
1505  if ($a_tabs_html != "" && $this->blockExists("tabs_outer_start"))
1506  {
1507  $this->touchBlock("tabs_outer_start");
1508  $this->touchBlock("tabs_outer_end");
1509  $this->touchBlock("tabs_inner_start");
1510  $this->touchBlock("tabs_inner_end");
1511  $this->setVariable("TABS", $a_tabs_html);
1512  }
1513  }
1514 
1518  function setSubTabs($a_tabs_html)
1519  {
1520  $this->setVariable("SUB_TABS", $a_tabs_html);
1521  }
1522 
1526  function setUpperIcon($a_link, $a_frame = "")
1527  {
1528  global $lng;
1529 
1530  $this->upper_icon = $a_link;
1531  $this->upper_icon_frame = $a_frame;
1532  }
1533 
1538  public function setLoginTargetPar($a_val)
1539  {
1540  $this->login_target_par = $a_val;
1541  }
1542 
1546  public function getLoginTargetPar()
1547  {
1548  return $this->login_target_par;
1549  }
1550 
1555  {
1556  global $ilUser;
1557 
1558  if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization"))
1559  {
1560  $this->touchBlock("sr_focus");
1561  }
1562  }
1563 
1567  function fillSideIcons()
1568  {
1569  global $lng, $ilSetting;
1570 
1571  if ($this->upper_icon == "" && $this->tree_flat_link == ""
1572  && $this->mount_webfolder == "")
1573  {
1574  return;
1575  }
1576 
1577  // upper icon
1578  if ($this->upper_icon != "")
1579  {
1580  if ($this->upper_icon_frame != "")
1581  {
1582  $this->setCurrentBlock("target_top");
1583  $this->setVariable("TARGET_TOP", $this->upper_icon_frame);
1584  $this->parseCurrentBlock();
1585  }
1586 
1587  $this->setCurrentBlock("alt_top");
1588  $this->setVariable("ALT_TOP", $lng->txt("up"));
1589  $this->parseCurrentBlock();
1590 
1591  $this->setCurrentBlock("top");
1592  $this->setVariable("LINK_TOP", $this->upper_icon);
1593  $this->setVariable("IMG_TOP",ilUtil::getImagePath("ic_top.gif"));
1594  $this->parseCurrentBlock();
1595  }
1596 
1597  // tree/flat icon
1598  if ($this->tree_flat_link != "")
1599  {
1600  $this->setCurrentBlock("tree_mode");
1601  $this->setVariable("LINK_MODE", $this->tree_flat_link);
1602  if ($ilSetting->get("tree_frame") == "right")
1603  {
1604  if ($this->tree_flat_mode == "tree")
1605  {
1606  $this->setVariable("IMG_TREE",ilUtil::getImagePath("ic_sidebar_left.gif"));
1607  $this->setVariable("RIGHT", "Right");
1608  }
1609  else
1610  {
1611  $this->setVariable("IMG_TREE",ilUtil::getImagePath("ic_sidebar_right.gif"));
1612  $this->setVariable("RIGHT", "Right");
1613  }
1614  }
1615  else
1616  {
1617  if ($this->tree_flat_mode == "tree")
1618  {
1619  $this->setVariable("IMG_TREE",ilUtil::getImagePath("ic_sidebar_right.gif"));
1620  }
1621  else
1622  {
1623  $this->setVariable("IMG_TREE",ilUtil::getImagePath("ic_sidebar_left.gif"));
1624  }
1625  }
1626  $this->setVariable("ALT_TREE",$lng->txt($this->tree_flat_mode."view"));
1627  $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent"));
1628  include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php");
1629  $this->setVariable("TREE_ACC_KEY",
1630  ilAccessKeyGUI::getAttribute(($this->tree_flat_mode == "tree")
1633  $this->parseCurrentBlock();
1634  }
1635 
1636  // mount webfolder
1637  if ($this->mount_webfolder != "")
1638  {
1639  require_once('Services/WebDAV/classes/class.ilDAVServer.php');
1640  $davServer = new ilDAVServer();
1641  $a_ref_id = $this->mount_webfolder;
1642  $a_link = $davServer->getMountURI($a_ref_id);
1643  $a_folder = $davServer->getFolderURI($a_ref_id);
1644 
1645  $this->setCurrentBlock("mount_webfolder");
1646  $this->setVariable("LINK_MOUNT_WEBFOLDER", $a_link);
1647  $this->setVariable("FOLDER_MOUNT_WEBFOLDER", $a_folder);
1648  $this->setVariable("IMG_MOUNT_WEBFOLDER",ilUtil::getImagePath("ic_mount_webfolder.gif"));
1649  $this->setVariable("ALT_MOUNT_WEBFOLDER",$lng->txt("mount_webfolder"));
1650  $this->setVariable("TARGET_MOUNT_WEBFOLDER", '_blank');
1651  $this->parseCurrentBlock();
1652  }
1653 
1654  $this->setCurrentBlock("tree_icons");
1655  $this->parseCurrentBlock();
1656  }
1657 
1658  // BEGIN WebDAV: Mount webfolder icon.
1662  function setMountWebfolderIcon($a_ref_id)
1663  {
1664  global $lng;
1665 
1666  $this->mount_webfolder = $a_ref_id;
1667  }
1668  // END WebDAV: Mount webfolder icon.
1669 
1675  function setTreeFlatIcon($a_link, $a_mode)
1676  {
1677  global $lng;
1678 
1679  $this->tree_flat_link = $a_link;
1680  $this->tree_flat_mode = $a_mode;
1681  }
1682 
1686  function addJavaScript($a_js_file, $a_add_version_parameter = true, $a_batch = 2)
1687  {
1688  // three batches currently
1689  if ($a_batch < 1 || $a_batch > 3)
1690  {
1691  $a_batch = 2;
1692  }
1693  if (!in_array($a_js_file, $this->js_files))
1694  {
1695  $this->js_files[] = $a_js_file;
1696  $this->js_files_vp[$a_js_file] = $a_add_version_parameter;
1697  $this->js_files_batch[$a_js_file] = $a_batch;
1698  }
1699  }
1700 
1704  function addOnLoadCode($a_code)
1705  {
1706  $this->on_load_code[] = $a_code;
1707  }
1708 
1712  function addCss($a_css_file, $media = "screen")
1713  {
1714  if (!array_key_exists($a_css_file . $media, $this->css_files))
1715  {
1716  $this->css_files[$a_css_file . $media] = array("file" => $a_css_file, "media" => $media);
1717  }
1718  }
1719 
1723  function setCreationSelector($a_form_action, $a_options,
1724  $a_command, $a_txt)
1725  {
1726  $this->setPageFormAction($a_form_action);
1727 
1728  $this->creation_selector =
1729  array("form_action" => $a_form_action,
1730  "options" => $a_options,
1731  "command" => $a_command,
1732  "txt" => $a_txt);
1733  }
1734 
1738  function setPageActions($a_page_actions_html)
1739  {
1740  $this->page_actions = $a_page_actions_html;
1741  }
1742 
1746  function setEditPageButton($a_link, $a_txt, $a_frame)
1747  {
1748  $this->edit_page_button =
1749  array("link" => $a_link, "txt" => $a_txt, "frame" => $a_frame);
1750  }
1751 
1755  function addAdminPanelCommand($a_cmd, $a_txt, $a_arrow = false)
1756  {
1757  $this->admin_panel_commands[] =
1758  array("cmd" => $a_cmd, "txt" => $a_txt);
1759  if ($a_arrow)
1760  {
1761  $this->admin_panel_arrow = true;
1762  }
1763  }
1764 
1770  function fillAdminPanel()
1771  {
1772  global $lng;
1773 
1774  $adm_view_cmp = $adm_cmds = $creation_selector = $adm_view = false;
1775 
1776  $toolb = new ilToolbarGUI();
1777 
1778  // admin panel commands
1779  if ((count($this->admin_panel_commands) > 0))
1780  {
1781  foreach($this->admin_panel_commands as $cmd)
1782  {
1783  $toolb->addFormButton($cmd["txt"], $cmd["cmd"]);
1784  }
1785 
1786  $adm_cmds = true;
1787  }
1788  if ($adm_cmds)
1789  {
1790  $this->setCurrentBlock("adm_view_components");
1791  if ($this->admin_panel_arrow)
1792  {
1793  $toolb->setLeadingImage(ilUtil::getImagePath("arrow_upright.gif"), $lng->txt("actions"));
1794  }
1795  $this->setVariable("ADM_PANEL1", $toolb->getHTML());
1796  $this->parseCurrentBlock();
1797  $adm_view_cmp = true;
1798  }
1799 
1800  // admin view button
1801  if ($this->page_actions != "")
1802  {
1803  $this->setVariable("PAGE_ACTIONS", $this->page_actions);
1804  $adm_view = true;
1805  }
1806 
1807  // creation selector
1808  if (is_array($this->creation_selector))
1809  {
1810  $this->setCurrentBlock("add_commands");
1811  if ($adm_cmds)
1812  {
1813  $this->setVariable("ADD_COM_WIDTH", 'width="1"');
1814  }
1815 
1816  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1817  $selection = new ilAdvancedSelectionListGUI();
1818  $selection->setFormSelectMode("new_type", "", false,
1819  "", "", "",
1820  "", $this->creation_selector["txt"], "", $this->creation_selector["command"]);
1821  $selection->setListTitle($lng->txt("cntr_add_new_item"));
1822  $selection->setId("item_creation");
1823  //$selection->setSelectionHeaderClass("MMInactive");
1824  $selection->setHeaderIcon(ilUtil::getImagePath("cmd_add_s.gif"));
1825  $selection->setItemLinkClass("xsmall");
1826  //$selection->setSelectionHeaderClass("submit");
1827  $selection->setUseImages(true);
1828  $selection->setOnClickMode(ilAdvancedSelectionListGUI::ON_ITEM_CLICK_FORM_SUBMIT,
1829  "main_page_form");
1830  foreach ($this->creation_selector["options"] as $item)
1831  {
1832  $selection->addItem($item["title"], $item["value"], "",
1833  $item["img"], $item["title"], "");
1834  }
1835  $this->setVariable("SELECT_OBJTYPE_REPOS",
1836  $selection->getHTML());
1837 
1838  $this->parseCurrentBlock();
1839  $creation_selector = true;
1840  }
1841 
1842  if ($adm_cmds)
1843  {
1844  $this->setCurrentBlock("adm_view_components2");
1845  if ($this->admin_panel_arrow)
1846  {
1847  $toolb->setLeadingImage(ilUtil::getImagePath("arrow_downright.gif"), $lng->txt("actions"));
1848  }
1849  $this->setVariable("ADM_PANEL2", $toolb->getHTML());
1850  $this->parseCurrentBlock();
1851  }
1852 
1853  }
1854 
1855  function setPermanentLink($a_type, $a_id, $a_append = "", $a_target = "")
1856  {
1857  $this->permanent_link = array(
1858  "type" => $a_type,
1859  "id" => $a_id,
1860  "append" => $a_append,
1861  "target" => $a_target);
1862  }
1863 
1868  {
1869  if (is_array($this->permanent_link))
1870  {
1871  include_once("./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php");
1872  $plinkgui = new ilPermanentLinkGUI(
1873  $this->permanent_link["type"],
1874  $this->permanent_link["id"],
1875  $this->permanent_link["append"],
1876  $this->permanent_link["target"]);
1877  $this->setVariable("PRMLINK", $plinkgui->getHTML());
1878  }
1879  }
1880 
1884  function fillOnLoadCode()
1885  {
1886  if (is_array($this->on_load_code))
1887  {
1888  $this->setCurrentBlock("on_load_code");
1889  foreach ($this->on_load_code as $code)
1890  {
1891  $this->setCurrentBlock("on_load_code_inner");
1892  $this->setVariable("OLCODE", $code);
1893  $this->parseCurrentBlock();
1894  }
1895  $this->setCurrentBlock("on_load_code");
1896  $this->parseCurrentBlock();
1897  }
1898  }
1899 
1900 }
1901 ?>