1<?php 2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */ 3 4include_once("./Services/UICore/lib/html-it/IT.php"); 5include_once("./Services/UICore/lib/html-it/ITX.php"); 6 7/** 8* special template class to simplify handling of ITX/PEAR 9* @author Stefan Kesseler <skesseler@databay.de> 10* @author Sascha Hofmann <shofmann@databay.de> 11* @version $Id$ 12*/ 13class ilTemplate extends HTML_Template_ITX 14{ 15 /** 16 * @var ilTemplate 17 */ 18 protected $tpl; 19 20 const MESSAGE_TYPE_FAILURE = 'failure'; 21 const MESSAGE_TYPE_INFO = "info"; 22 const MESSAGE_TYPE_SUCCESS = "success"; 23 const MESSAGE_TYPE_QUESTION = "question"; 24 /** 25 * @var array available Types for Messages 26 */ 27 protected static $message_types = array( 28 self::MESSAGE_TYPE_FAILURE, 29 self::MESSAGE_TYPE_INFO, 30 self::MESSAGE_TYPE_SUCCESS, 31 self::MESSAGE_TYPE_QUESTION, 32 ); 33 34 /** 35 * Content-type for template output 36 * @var string 37 */ 38 public $contenttype; 39 /** 40 * variablen die immer in jedem block ersetzt werden sollen 41 * @var array 42 */ 43 public $vars; 44 45 /** 46 * Aktueller Block 47 * Der wird gemerkt bei der berladenen Funktion setCurrentBlock, damit beim ParseBlock 48 * vorher ein replace auf alle Variablen gemacht werden kann, die mit dem BLockname anfangen. 49 * @var string 50 */ 51 public $activeBlock; 52 53 public $js_files = array(0 => "./Services/JavaScript/js/Basic.js"); // list of JS files that should be included 54 public $js_files_vp = array("./Services/JavaScript/js/Basic.js" => true); // version parameter flag 55 public $js_files_batch = array("./Services/JavaScript/js/Basic.js" => 1); // version parameter flag 56 public $css_files = array(); // list of css files that should be included 57 public $inline_css = array(); 58 public $admin_panel_commands = array(); 59 60 private $addFooter; // creates an output of the ILIAS footer 61 62 protected static $il_cache = array(); 63 protected $message = array(); 64 65 protected $title_desc = ""; 66 protected $title_url = ""; 67 protected $upper_icon = ""; 68 protected $tree_flat_link = ""; 69 protected $mount_webfolder = ""; 70 protected $stop_floating = ""; 71 protected $page_form_action = ""; 72 protected $page_actions = array(); 73 protected $permanent_link = false; 74 protected $content_style_sheet = ""; 75 protected $main_content = ""; 76 77 protected $title_alerts = array(); 78 protected $header_action; 79 protected $lightbox = array(); 80 protected $standard_template_loaded = false; 81 82 protected $translation_linked = false; // fix #9992: remember if a translation link is added 83 84 /** 85 * constructor 86 * @param string $file templatefile (mit oder ohne pfad) 87 * @param boolean $flag1 remove unknown variables 88 * @param boolean $flag2 remove empty blocks 89 * @param boolean $in_module should be set to true, if template file is in module subdirectory 90 * @param array $vars variables to replace 91 * @access public 92 */ 93 public function __construct( 94 $file, 95 $flag1, 96 $flag2, 97 $in_module = false, 98 $vars = "DEFAULT", 99 $plugin = false, 100 $a_use_cache = true 101 ) { 102 global $DIC; 103 104 //echo "<br>-".$file."-"; 105 106 $this->activeBlock = "__global__"; 107 $this->vars = array(); 108 $this->addFooter = true; 109 110 $this->il_use_cache = $a_use_cache; 111 $this->il_cur_key = $file . "/" . $in_module; 112 113 $fname = $this->getTemplatePath($file, $in_module, $plugin); 114 115 $this->tplName = basename($fname); 116 $this->tplPath = dirname($fname); 117 $this->tplIdentifier = $this->getTemplateIdentifier($file, $in_module); 118 119 // set default content-type to text/html 120 $this->contenttype = "text/html"; 121 if (!file_exists($fname)) { 122 if (isset($DIC["ilErr"])) { 123 $ilErr = $DIC["ilErr"]; 124 $ilErr->raiseError("template " . $fname . " was not found.", $ilErr->FATAL); 125 } 126 return false; 127 } 128 129 //$this->IntegratedTemplateExtension(dirname($fname)); 130 parent::__construct(); 131 //$this->loadTemplatefile(basename($fname), $flag1, $flag2); 132 $this->loadTemplatefile($fname, $flag1, $flag2); 133 //add tplPath to replacevars 134 $this->vars["TPLPATH"] = $this->tplPath; 135 136 // set Options 137 if (method_exists($this, "setOption")) { 138 $this->setOption('use_preg', false); 139 } 140 $this->setBodyClass("std"); 141 142 return true; 143 } 144 145 /** 146 * @param string $file 147 * @param string $vers 148 */ 149 protected function fillJavascriptFile($file, $vers) 150 { 151 $this->setCurrentBlock("js_file"); 152 if ($this->js_files_vp[$file]) { 153 $this->setVariable("JS_FILE", ilUtil::appendUrlParameterString($file, $vers)); 154 } else { 155 $this->setVariable("JS_FILE", $file); 156 } 157 $this->parseCurrentBlock(); 158 } 159 160 // overwrite their init function 161 public function init() 162 { 163 $this->free(); 164 $this->buildFunctionlist(); 165 166 $cache_hit = false; 167 if ($this->il_use_cache) { 168 // cache hit 169 if (isset(self::$il_cache[$this->il_cur_key]) && is_array(self::$il_cache[$this->il_cur_key])) { 170 $cache_hit = true; 171 //echo "cache hit"; 172 $this->err = self::$il_cache[$this->il_cur_key]["err"]; 173 $this->flagBlocktrouble = self::$il_cache[$this->il_cur_key]["flagBlocktrouble"]; 174 $this->blocklist = self::$il_cache[$this->il_cur_key]["blocklist"]; 175 $this->blockdata = self::$il_cache[$this->il_cur_key]["blockdata"]; 176 $this->blockinner = self::$il_cache[$this->il_cur_key]["blockinner"]; 177 $this->blockparents = self::$il_cache[$this->il_cur_key]["blockparents"]; 178 $this->blockvariables = self::$il_cache[$this->il_cur_key]["blockvariables"]; 179 } 180 } 181 182 if (!$cache_hit) { 183 $this->findBlocks($this->template); 184 $this->template = ''; 185 $this->buildBlockvariablelist(); 186 if ($this->il_use_cache) { 187 self::$il_cache[$this->il_cur_key]["err"] = $this->err; 188 self::$il_cache[$this->il_cur_key]["flagBlocktrouble"] = $this->flagBlocktrouble; 189 self::$il_cache[$this->il_cur_key]["blocklist"] = $this->blocklist; 190 self::$il_cache[$this->il_cur_key]["blockdata"] = $this->blockdata; 191 self::$il_cache[$this->il_cur_key]["blockinner"] = $this->blockinner; 192 self::$il_cache[$this->il_cur_key]["blockparents"] = $this->blockparents; 193 self::$il_cache[$this->il_cur_key]["blockvariables"] = $this->blockvariables; 194 } 195 } 196 197 // we don't need it any more 198 $this->template = ''; 199 } // end func init 200 201 /* 202 * Sets wheather the ILIAS footer should be shown or not 203 * 204 * @param boolean $value TRUE to show the ILIAS footer, FALSE to hide it 205 */ 206 public function setAddFooter($value) 207 { 208 $this->addFooter = $value; 209 } 210 211 /* 212 * Returns wheather the ILIAS footer should be shown or not 213 * 214 * @return boolean TRUE if the ILIAS footer will be shown, FALSE otherwise 215 */ 216 public function getAddFooter() 217 { 218 return $this->addFooter; 219 } 220 221 222 /** 223 * Use this for final get before sending asynchronous output (ajax) 224 * per echo to output. 225 */ 226 public function getAsynch() 227 { 228 header("Content-type: " . $this->getContentType() . "; charset=UTF-8"); 229 return $this->get(); 230 } 231 232 /** 233 * ??? 234 * @access public 235 * @param string 236 * @return string 237 */ 238 public function get( 239 $part = "DEFAULT", 240 $add_error_mess = false, 241 $handle_referer = false, 242 $add_ilias_footer = false, 243 $add_standard_elements = false, 244 $a_main_menu = true, 245 $a_tabs = true 246 ) { 247 global $DIC; 248 249 if ($add_error_mess) { 250 $this->fillMessage(); 251 } 252 253 if ($add_ilias_footer) { 254 $this->addILIASFooter(); 255 } 256 257 // set standard parts (tabs and title icon) 258 if ($add_standard_elements) { 259 if ($this->blockExists("content") && $a_tabs) { 260 // determine default screen id 261 $this->getTabsHTML(); 262 } 263 264 // to get also the js files for the main menu 265 $this->getMainMenu(); 266 $this->initHelp(); 267 268 // these fill blocks in tpl.main.html 269 $this->fillCssFiles(); 270 $this->fillInlineCss(); 271 $this->fillContentStyle(); 272 $this->fillBodyClass(); 273 274 // these fill just plain placeholder variables in tpl.main.html 275 $this->setCurrentBlock("DEFAULT"); 276 $this->fillNewContentStyle(); 277 $this->fillContentLanguage(); 278 $this->fillWindowTitle(); 279 280 // these fill blocks in tpl.adm_content.html 281 $this->fillHeader(); 282 $this->fillSideIcons(); 283 $this->fillScreenReaderFocus(); 284 $this->fillStopFloating(); 285 $this->fillLeftContent(); 286 $this->fillLeftNav(); 287 $this->fillRightContent(); 288 $this->fillAdminPanel(); 289 $this->fillToolbar(); 290 $this->fillPermanentLink(); 291 292 $this->setCenterColumnClass(); 293 294 // late loading of javascipr files, since operations above may add files 295 $this->fillJavaScriptFiles(); 296 $this->fillOnLoadCode(); 297 298 // these fill just plain placeholder variables in tpl.adm_content.html 299 if ($this->blockExists("content")) { 300 $this->setCurrentBlock("content"); 301 if ($a_tabs) { 302 $this->fillTabs(); 303 } 304 $this->fillMainContent(); 305 if ($a_main_menu) { 306 $this->fillMainMenu(); 307 } 308 $this->fillLightbox(); 309 $this->parseCurrentBlock(); 310 } 311 } 312 313 if ($handle_referer) { 314 $this->handleReferer(); 315 } 316 317 if ($part == "DEFAULT") { 318 $html = parent::get(); 319 } else { 320 $html = parent::get($part); 321 } 322 323 // include the template output hook 324 $ilPluginAdmin = $DIC["ilPluginAdmin"]; 325 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk"); 326 foreach ($pl_names as $pl) { 327 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl); 328 $gui_class = $ui_plugin->getUIClassInstance(); 329 330 $resp = $gui_class->getHTML( 331 "", 332 "template_get", 333 array("tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html) 334 ); 335 336 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) { 337 $html = $gui_class->modifyHTML($html, $resp); 338 } 339 } 340 341 // fix #9992: save language usages as late as possible 342 if ($this->translation_linked) { 343 ilObjLanguageAccess::_saveUsages(); 344 } 345 346 return $html; 347 } 348 349 350 /** 351 * Set message. Please use ilUtil::sendInfo(), ilUtil::sendSuccess() 352 * and ilUtil::sendFailure() 353 * 354 * @param string $a_type \ilTemplate::MESSAGE_TYPE_SUCCESS, 355 * \ilTemplate::MESSAGE_TYPE_FAILURE,, 356 * \ilTemplate::MESSAGE_TYPE_QUESTION, 357 * \ilTemplate::MESSAGE_TYPE_INFO 358 * @param string $a_txt The message to be sent 359 * @param bool $a_keep Keep this message over one redirect 360 */ 361 public function setMessage($a_type, $a_txt, $a_keep = false) 362 { 363 if (!in_array($a_type, self::$message_types) || $a_txt == "") { 364 return; 365 } 366 if ($a_type == self::MESSAGE_TYPE_QUESTION) { 367 $a_type = "mess_question"; 368 } 369 if (!$a_keep) { 370 $this->message[$a_type] = $a_txt; 371 } else { 372 $_SESSION[$a_type] = $a_txt; 373 } 374 } 375 376 public function hasMessage($a_type) 377 { 378 return (isset($this->message[$a_type]) && strlen($this->message[$a_type])); 379 } 380 381 public function fillMessage() 382 { 383 global $DIC; 384 385 $ms = array( self::MESSAGE_TYPE_INFO, 386 self::MESSAGE_TYPE_SUCCESS, self::MESSAGE_TYPE_FAILURE, 387 self::MESSAGE_TYPE_QUESTION 388 ); 389 $out = ""; 390 391 foreach ($ms as $m) { 392 if ($m == self::MESSAGE_TYPE_QUESTION) { 393 $m = "mess_question"; 394 } 395 $txt = $this->getMessageTextForType($m); 396 397 if ($m == "mess_question") { 398 $m = self::MESSAGE_TYPE_QUESTION; 399 } 400 401 if ($txt != "") { 402 // this is a workaround that allows to send rendered message boxes directly 403 // should be removed if we have a decent place for messages in a new ks layout 404 if (strpos($txt, 'role="alert"') > 0) { 405 $out .= $txt; 406 } else { 407 $out .= $this->getMessageHTML($txt, $m); 408 } 409 } 410 411 if ($m == self::MESSAGE_TYPE_QUESTION) { 412 $m = "mess_question"; 413 } 414 415 $request = $DIC->http()->request(); 416 $accept_header = $request->getHeaderLine('Accept'); 417 if (isset($_SESSION[$m]) && $_SESSION[$m] && ($accept_header !== 'application/json')) { 418 unset($_SESSION[$m]); 419 } 420 } 421 422 if ($out != "") { 423 $this->setVariable("MESSAGE", $out); 424 } 425 } 426 427 /** 428 * Get HTML for a system message 429 */ 430 public function getMessageHTML($a_txt, $a_type = "info") 431 { 432 global $DIC; 433 434 $lng = $DIC->language(); 435 $mtpl = new ilTemplate("tpl.message.html", true, true, "Services/Utilities"); 436 $mtpl->setCurrentBlock($a_type . "_message"); 437 $mtpl->setVariable("TEXT", $a_txt); 438 $mtpl->setVariable("MESSAGE_HEADING", $lng->txt($a_type . "_message")); 439 $mtpl->parseCurrentBlock(); 440 441 return $mtpl->get(); 442 } 443 444 /** 445 * Get the content type for the template output 446 * 447 * @return string Content type 448 * @access public 449 */ 450 public function getContentType() 451 { 452 return $this->contenttype; 453 } 454 455 /** 456 * Set the content type for the template output 457 * 458 * Set the content type for the template output 459 * Usually this is text/html. For MathML output the 460 * content type should be set to text/xml 461 * 462 * @param string $a_content_type Content type 463 * @access public 464 */ 465 public function setContentType($a_content_type = "text/html") 466 { 467 $this->contenttype = $a_content_type; 468 } 469 470 471 /** 472 * @param string $part 473 * @param bool $a_fill_tabs fill template variable {TABS} with content of ilTabs 474 * @param bool $a_skip_main_menu 475 */ 476 public function show($part = "DEFAULT", $a_fill_tabs = true, $a_skip_main_menu = false) 477 { 478 global $DIC; 479 480 $http = $DIC->http(); 481 switch ($http->request()->getHeaderLine('Accept')) { 482 case 'application/json': 483 $string = json_encode([ 484 self::MESSAGE_TYPE_SUCCESS => is_null($this->message[self::MESSAGE_TYPE_FAILURE]), 485 'message' => '', 486 ]); 487 $stream = \ILIAS\Filesystem\Stream\Streams::ofString($string); 488 $http->saveResponse($http->response()->withBody($stream)); 489 $http->sendResponse(); 490 exit; 491 default: 492 // include yahoo dom per default 493 include_once("./Services/YUI/classes/class.ilYuiUtil.php"); 494 ilYuiUtil::initDom(); 495 496 header('P3P: CP="CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa OUR BUS IND UNI COM NAV INT CNT STA PRE"'); 497 header("Content-type: " . $this->getContentType() . "; charset=UTF-8"); 498 499 $this->fillMessage(); 500 501 // display ILIAS footer 502 if ($part !== false) { 503 $this->addILIASFooter(); 504 } 505 506 // set standard parts (tabs and title icon) 507 $this->fillBodyClass(); 508 509 // see #22992 510 $this->fillContentLanguage(); 511 512 if ($a_fill_tabs) { 513 if ($this->blockExists("content")) { 514 // determine default screen id 515 $this->getTabsHTML(); 516 } 517 518 // to get also the js files for the main menu 519 if (!$a_skip_main_menu) { 520 $this->getMainMenu(); 521 $this->initHelp(); 522 } 523 524 if ($this->blockExists("content") && $this->variableExists('MAINMENU')) { 525 $tpl = $DIC["tpl"]; 526 527 include_once 'Services/Authentication/classes/class.ilSessionReminderGUI.php'; 528 $session_reminder_gui = new ilSessionReminderGUI(ilSessionReminder::createInstanceWithCurrentUserSession()); 529 $tpl->setVariable('SESSION_REMINDER', $session_reminder_gui->getHtml()); 530 } 531 532 // these fill blocks in tpl.main.html 533 $this->fillCssFiles(); 534 $this->fillInlineCss(); 535 //$this->fillJavaScriptFiles(); 536 $this->fillContentStyle(); 537 538 // these fill just plain placeholder variables in tpl.main.html 539 $this->setCurrentBlock("DEFAULT"); 540 $this->fillNewContentStyle(); 541 $this->fillWindowTitle(); 542 543 // these fill blocks in tpl.adm_content.html 544 $this->fillHeader(); 545 $this->fillSideIcons(); 546 $this->fillScreenReaderFocus(); 547 $this->fillStopFloating(); 548 $this->fillLeftContent(); 549 $this->fillLeftNav(); 550 $this->fillRightContent(); 551 $this->fillAdminPanel(); 552 $this->fillToolbar(); 553 $this->fillPermanentLink(); 554 555 $this->setCenterColumnClass(); 556 557 // late loading of javascipr files, since operations above may add files 558 $this->fillJavaScriptFiles(); 559 $this->fillOnLoadCode(); 560 561 // these fill just plain placeholder variables in tpl.adm_content.html 562 if ($this->blockExists("content")) { 563 $this->setCurrentBlock("content"); 564 $this->fillTabs(); 565 $this->fillMainContent(); 566 $this->fillMainMenu(); 567 $this->fillLightbox(); 568 $this->parseCurrentBlock(); 569 } 570 } 571 572 if ($part == "DEFAULT" or is_bool($part)) { 573 $html = parent::get(); 574 } else { 575 $html = parent::get($part); 576 } 577 578 // include the template output hook 579 $ilPluginAdmin = $DIC["ilPluginAdmin"]; 580 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk"); 581 foreach ($pl_names as $pl) { 582 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl); 583 $gui_class = $ui_plugin->getUIClassInstance(); 584 585 $resp = $gui_class->getHTML( 586 "", 587 "template_show", 588 array("tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $html) 589 ); 590 591 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) { 592 $html = $gui_class->modifyHTML($html, $resp); 593 } 594 } 595 596 // fix #9992: save language usages as late as possible 597 if ($this->translation_linked) { 598 ilObjLanguageAccess::_saveUsages(); 599 } 600 601 print $html; 602 603 $this->handleReferer(); 604 break; 605 } 606 } 607 608 609 /** 610 * Add current user language to meta tags 611 * 612 * @access public 613 * 614 */ 615 public function fillContentLanguage() 616 { 617 global $DIC; 618 619 $lng = $DIC->language(); 620 $ilUser = $DIC->user(); 621 622 $contentLanguage = 'en'; 623 $rtl = array('ar','fa','ur','he');//, 'de'); //make a list of rtl languages 624 /* rtl-review: add "de" for testing with ltr lang shown in rtl 625 * and set unicode-bidi to bidi-override for mirror effect */ 626 $textdir = 'ltr'; 627 if (is_object($ilUser)) { 628 if ($ilUser->getLanguage()) { 629 $contentLanguage = $ilUser->getLanguage(); 630 } elseif (is_object($lng)) { 631 $contentLanguage = $lng->getDefaultLanguage(); 632 } 633 if ($ilUser->getId() == ANONYMOUS_USER_ID && is_object($lng)) { 634 $contentLanguage = $lng->getLangKey(); 635 } 636 } 637 $this->setVariable('META_CONTENT_LANGUAGE', $contentLanguage); 638 if (in_array($contentLanguage, $rtl)) { 639 $textdir = 'rtl'; 640 } 641 $this->setVariable('LANGUAGE_DIRECTION', $textdir); 642 return true; 643 } 644 645 public function fillWindowTitle() 646 { 647 global $DIC; 648 649 $ilSetting = $DIC->settings(); 650 651 if ($this->header_page_title != "") { 652 $a_title = ilUtil::stripScriptHTML($this->header_page_title); 653 $this->setVariable("PAGETITLE", "- " . $a_title); 654 } 655 656 if ($ilSetting->get('short_inst_name') != "") { 657 $this->setVariable( 658 "WINDOW_TITLE", 659 $ilSetting->get('short_inst_name') 660 ); 661 } else { 662 $this->setVariable( 663 "WINDOW_TITLE", 664 "ILIAS" 665 ); 666 } 667 } 668 669 /** 670 * Get tabs HTML 671 * 672 * @param 673 * @return 674 */ 675 public function getTabsHTML() 676 { 677 global $DIC; 678 679 $ilTabs = $DIC["ilTabs"]; 680 681 if ($this->blockExists("tabs_outer_start")) { 682 $this->sthtml = $ilTabs->getSubTabHTML(); 683 $this->thtml = $ilTabs->getHTML((trim($this->sthtml) == "")); 684 } 685 } 686 687 688 public function fillTabs() 689 { 690 if ($this->blockExists("tabs_outer_start")) { 691 $this->touchBlock("tabs_outer_start"); 692 $this->touchBlock("tabs_outer_end"); 693 $this->touchBlock("tabs_inner_start"); 694 $this->touchBlock("tabs_inner_end"); 695 696 if ($this->thtml != "") { 697 $this->setVariable("TABS", $this->thtml); 698 } 699 $this->setVariable("SUB_TABS", $this->sthtml); 700 } 701 } 702 703 public function fillToolbar() 704 { 705 global $DIC; 706 707 $ilToolbar = $DIC["ilToolbar"]; 708 ; 709 710 $thtml = $ilToolbar->getHTML(); 711 if ($thtml != "") { 712 $this->setCurrentBlock("toolbar_buttons"); 713 $this->setVariable("BUTTONS", $thtml); 714 $this->parseCurrentBlock(); 715 } 716 } 717 718 public function fillPageFormAction() 719 { 720 if ($this->page_form_action != "") { 721 $this->setCurrentBlock("page_form_start"); 722 $this->setVariable("PAGE_FORM_ACTION", $this->page_form_action); 723 $this->parseCurrentBlock(); 724 $this->touchBlock("page_form_end"); 725 } 726 } 727 728 public function fillJavaScriptFiles($a_force = false) 729 { 730 global $DIC; 731 732 $ilSetting = $DIC->settings(); 733 734 if (is_object($ilSetting)) { // maybe this one can be removed 735 $vers = "vers=" . str_replace(array(".", " "), "-", $ilSetting->get("ilias_version")); 736 737 if (DEVMODE) { 738 $vers .= '-' . time(); 739 } 740 } 741 if ($this->blockExists("js_file")) { 742 // three batches 743 for ($i = 0; $i <= 3; $i++) { 744 reset($this->js_files); 745 foreach ($this->js_files as $file) { 746 if ($this->js_files_batch[$file] == $i) { 747 if (is_file($file) || substr($file, 0, 4) == "http" || substr($file, 0, 2) == "//" || $a_force) { 748 $this->fillJavascriptFile($file, $vers); 749 } elseif (substr($file, 0, 2) == './') { // #13962 750 $url_parts = parse_url($file); 751 if (is_file($url_parts['path'])) { 752 $this->fillJavascriptFile($file, $vers); 753 } 754 } 755 } 756 } 757 } 758 } 759 } 760 761 /** 762 * Fill in the css file tags 763 * 764 * @param boolean $a_force 765 */ 766 public function fillCssFiles($a_force = false) 767 { 768 if (!$this->blockExists("css_file")) { 769 return; 770 } 771 foreach ($this->css_files as $css) { 772 $filename = $css["file"]; 773 if (strpos($filename, "?") > 0) { 774 $filename = substr($filename, 0, strpos($filename, "?")); 775 } 776 if (is_file($filename) || $a_force) { 777 $this->setCurrentBlock("css_file"); 778 $this->setVariable("CSS_FILE", $css["file"]); 779 $this->setVariable("CSS_MEDIA", $css["media"]); 780 $this->parseCurrentBlock(); 781 } 782 } 783 } 784 785 /** 786 * Fill in the inline css 787 * 788 * @param boolean $a_force 789 */ 790 public function fillInlineCss() 791 { 792 if (!$this->blockExists("css_inline")) { 793 return; 794 } 795 foreach ($this->inline_css as $css) { 796 $this->setCurrentBlock("css_inline"); 797 $this->setVariable("CSS_INLINE", $css["css"]); 798 //$this->setVariable("CSS_MEDIA", $css["media"]); 799 $this->parseCurrentBlock(); 800 } 801 } 802 803 /** 804 * Set content style (used for page content editor) 805 */ 806 public function setContentStyleSheet($a_style) 807 { 808 $this->content_style_sheet = $a_style; 809 } 810 811 /** 812 * Fill Content Style 813 */ 814 public function fillContentStyle() 815 { 816 if ($this->content_style_sheet != "") { 817 $this->setCurrentBlock("ContentStyle"); 818 $this->setVariable( 819 "LOCATION_CONTENT_STYLESHEET", 820 $this->content_style_sheet 821 ); 822 $this->parseCurrentBlock(); 823 } 824 } 825 826 /** 827 * Fill Content Style 828 */ 829 private function fillNewContentStyle() 830 { 831 $this->setVariable( 832 "LOCATION_NEWCONTENT_STYLESHEET_TAG", 833 '<link rel="stylesheet" type="text/css" href="' . 834 ilUtil::getNewContentStyleSheetLocation() 835 . '" />' 836 ); 837 } 838 839 public function getMainMenu() 840 { 841 global $DIC; 842 843 $ilMainMenu = $DIC["ilMainMenu"]; 844 845 if ($this->variableExists('MAINMENU')) { 846 $ilMainMenu->setLoginTargetPar($this->getLoginTargetPar()); 847 $this->main_menu = $ilMainMenu->getHTML(); 848 $this->main_menu_spacer = $ilMainMenu->getSpacerClass(); 849 } 850 } 851 852 public function fillMainMenu() 853 { 854 global $DIC; 855 $tpl = $DIC["tpl"]; 856 if ($this->variableExists('MAINMENU')) { 857 $tpl->setVariable("MAINMENU", $this->main_menu); 858 $tpl->setVariable("MAINMENU_SPACER", $this->main_menu_spacer); 859 } 860 } 861 862 /** 863 * Init help 864 */ 865 public function initHelp() 866 { 867 include_once("./Services/Help/classes/class.ilHelpGUI.php"); 868 ilHelpGUI::initHelp($this); 869 } 870 871 872 /** 873 * add ILIAS footer 874 */ 875 public function addILIASFooter() 876 { 877 global $DIC; 878 879 $ilSetting = $DIC->settings(); 880 881 $lng = $DIC->language(); 882 883 $ilCtrl = $DIC->ctrl(); 884 $ilDB = $DIC->database(); 885 886 if (!$this->getAddFooter()) { 887 return; 888 } 889 890 $ftpl = new ilTemplate("tpl.footer.html", true, true, "Services/UICore"); 891 892 $php = ""; 893 if (DEVMODE) { 894 $php = ", PHP " . phpversion(); 895 } 896 $ftpl->setVariable("ILIAS_VERSION", $ilSetting->get("ilias_version") . $php); 897 898 $link_items = array(); 899 900 // imprint 901 include_once "Services/Imprint/classes/class.ilImprint.php"; 902 if ($_REQUEST["baseClass"] != "ilImprintGUI" && ilImprint::isActive()) { 903 include_once "Services/Link/classes/class.ilLink.php"; 904 $link_items[ilLink::_getStaticLink(0, "impr")] = array($lng->txt("imprint"), true); 905 } 906 907 // system support contacts 908 include_once("./Modules/SystemFolder/classes/class.ilSystemSupportContactsGUI.php"); 909 if (($l = ilSystemSupportContactsGUI::getFooterLink()) != "") { 910 $link_items[$l] = array(ilSystemSupportContactsGUI::getFooterText(), false); 911 } 912 913 if (DEVMODE) { 914 if (function_exists("tidy_parse_string")) { 915 $link_items[ilUtil::appendUrlParameterString($_SERVER["REQUEST_URI"], "do_dev_validate=xhtml")] = array("Validate", true); 916 $link_items[ilUtil::appendUrlParameterString($_SERVER["REQUEST_URI"], "do_dev_validate=accessibility")] = array("Accessibility", true); 917 } 918 } 919 920 // output translation link 921 include_once("Services/Language/classes/class.ilObjLanguageAccess.php"); 922 if (ilObjLanguageAccess::_checkTranslate() and !ilObjLanguageAccess::_isPageTranslation()) { 923 // fix #9992: remember linked translation instead of saving language usages here 924 $this->translation_linked = true; 925 $link_items[ilObjLanguageAccess::_getTranslationLink()] = array($lng->txt('translation'), true); 926 } 927 928 $cnt = 0; 929 foreach ($link_items as $url => $caption) { 930 $cnt++; 931 if ($caption[1]) { 932 $ftpl->touchBlock("blank"); 933 } 934 if ($cnt < sizeof($link_items)) { 935 $ftpl->touchBlock("item_separator"); 936 } 937 938 $ftpl->setCurrentBlock("items"); 939 $ftpl->setVariable("URL_ITEM", ilUtil::secureUrl($url)); 940 $ftpl->setVariable("TXT_ITEM", $caption[0]); 941 $ftpl->parseCurrentBlock(); 942 } 943 944 if (DEVMODE) { 945 // execution time 946 $t1 = explode(" ", $GLOBALS['ilGlobalStartTime']); 947 $t2 = explode(" ", microtime()); 948 $diff = $t2[0] - $t1[0] + $t2[1] - $t1[1]; 949 950 $mem_usage = array(); 951 if (function_exists("memory_get_usage")) { 952 $mem_usage[] = 953 "Memory Usage: " . memory_get_usage() . " Bytes"; 954 } 955 if (function_exists("xdebug_peak_memory_usage")) { 956 $mem_usage[] = 957 "XDebug Peak Memory Usage: " . xdebug_peak_memory_usage() . " Bytes"; 958 } 959 $mem_usage[] = round($diff, 4) . " Seconds"; 960 961 if (sizeof($mem_usage)) { 962 $ftpl->setVariable("MEMORY_USAGE", "<br>" . implode(" | ", $mem_usage)); 963 } 964 965 if (!empty($_GET["do_dev_validate"]) && $ftpl->blockExists("xhtml_validation")) { 966 require_once("Services/XHTMLValidator/classes/class.ilValidatorAdapter.php"); 967 $template2 = clone($this); 968 //echo "-".ilValidatorAdapter::validate($template2->get(), $_GET["do_dev_validate"])."-"; 969 $ftpl->setCurrentBlock("xhtml_validation"); 970 $ftpl->setVariable( 971 "VALIDATION", 972 ilValidatorAdapter::validate($template2->get( 973 "DEFAULT", 974 false, 975 false, 976 false, 977 true 978 ), $_GET["do_dev_validate"]) 979 ); 980 $ftpl->parseCurrentBlock(); 981 } 982 983 // controller history 984 if (is_object($ilCtrl) && $ftpl->blockExists("c_entry") && 985 $ftpl->blockExists("call_history")) { 986 $hist = $ilCtrl->getCallHistory(); 987 foreach ($hist as $entry) { 988 $ftpl->setCurrentBlock("c_entry"); 989 $ftpl->setVariable("C_ENTRY", $entry["class"]); 990 if (is_object($ilDB)) { 991 $file = $ilCtrl->lookupClassPath($entry["class"]); 992 $add = $entry["mode"] . " - " . $entry["cmd"]; 993 if ($file != "") { 994 $add .= " - " . $file; 995 } 996 $ftpl->setVariable("C_FILE", $add); 997 } 998 $ftpl->parseCurrentBlock(); 999 } 1000 $ftpl->setCurrentBlock("call_history"); 1001 $ftpl->parseCurrentBlock(); 1002 1003 $ftpl->setCurrentBlock("call_history"); 1004 $ftpl->parseCurrentBlock(); 1005 } 1006 1007 // included files 1008 if (is_object($ilCtrl) && $ftpl->blockExists("i_entry") && 1009 $ftpl->blockExists("included_files")) { 1010 $fs = get_included_files(); 1011 $ifiles = array(); 1012 $total = 0; 1013 foreach ($fs as $f) { 1014 $ifiles[] = array("file" => $f, "size" => filesize($f)); 1015 $total += filesize($f); 1016 } 1017 $ifiles = ilUtil::sortArray($ifiles, "size", "desc", true); 1018 foreach ($ifiles as $f) { 1019 $ftpl->setCurrentBlock("i_entry"); 1020 $ftpl->setVariable("I_ENTRY", $f["file"] . " (" . $f["size"] . " Bytes, " . round(100 / $total * $f["size"], 2) . "%)"); 1021 $ftpl->parseCurrentBlock(); 1022 } 1023 $ftpl->setCurrentBlock("i_entry"); 1024 $ftpl->setVariable("I_ENTRY", "Total (" . $total . " Bytes, 100%)"); 1025 $ftpl->parseCurrentBlock(); 1026 $ftpl->setCurrentBlock("included_files"); 1027 $ftpl->parseCurrentBlock(); 1028 } 1029 } 1030 1031 // BEGIN Usability: Non-Delos Skins can display the elapsed time in the footer 1032 // The corresponding $ilBench->start invocation is in inc.header.php 1033 $ilBench = $DIC["ilBench"]; 1034 $ilBench->stop("Core", "ElapsedTimeUntilFooter"); 1035 $ftpl->setVariable( 1036 "ELAPSED_TIME", 1037 ", " . number_format($ilBench->getMeasuredTime("Core", "ElapsedTimeUntilFooter"), 1) . ' seconds' 1038 ); 1039 // END Usability: Non-Delos Skins can display the elapsed time in the footer 1040 1041 $this->setVariable("FOOTER", $ftpl->get()); 1042 } 1043 1044 1045 /** 1046 * TODO: this is nice, but shouldn't be done here 1047 * (-> maybe at the end of ilias.php!?, alex) 1048 */ 1049 public function handleReferer() 1050 { 1051 if (((substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "error.php") 1052 && (substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "adm_menu.php") 1053 && (substr(strrchr($_SERVER["PHP_SELF"], "/"), 1) != "chat.php"))) { 1054 $_SESSION["post_vars"] = $_POST; 1055 1056 // referer is modified if query string contains cmd=gateway and $_POST is not empty. 1057 // this is a workaround to display formular again in case of error and if the referer points to another page 1058 $url_parts = @parse_url($_SERVER["REQUEST_URI"]); 1059 if (!$url_parts) { 1060 $protocol = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'; 1061 $host = $_SERVER['HTTP_HOST']; 1062 $path = $_SERVER['REQUEST_URI']; 1063 $url_parts = @parse_url($protocol . $host . $path); 1064 } 1065 1066 if (isset($url_parts["query"]) && preg_match("/cmd=gateway/", $url_parts["query"]) && (isset($_POST["cmd"]["create"]))) { 1067 foreach ($_POST as $key => $val) { 1068 if (is_array($val)) { 1069 $val = key($val); 1070 } 1071 1072 $str .= "&" . $key . "=" . $val; 1073 } 1074 1075 $_SESSION["referer"] = preg_replace("/cmd=gateway/", substr($str, 1), $_SERVER["REQUEST_URI"]); 1076 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id']; 1077 } elseif (isset($url_parts["query"]) && preg_match("/cmd=post/", $url_parts["query"]) && (isset($_POST["cmd"]["create"]))) { 1078 foreach ($_POST as $key => $val) { 1079 if (is_array($val)) { 1080 $val = key($val); 1081 } 1082 1083 $str .= "&" . $key . "=" . $val; 1084 } 1085 1086 $_SESSION["referer"] = preg_replace("/cmd=post/", substr($str, 1), $_SERVER["REQUEST_URI"]); 1087 if (isset($_GET['ref_id'])) { 1088 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id']; 1089 } else { 1090 $_SESSION['referer_ref_id'] = 0; 1091 } 1092 } else { 1093 $_SESSION["referer"] = $_SERVER["REQUEST_URI"]; 1094 if (isset($_GET['ref_id'])) { 1095 $_SESSION['referer_ref_id'] = (int) $_GET['ref_id']; 1096 } else { 1097 $_SESSION['referer_ref_id'] = 0; 1098 } 1099 } 1100 1101 unset($_SESSION["error_post_vars"]); 1102 } 1103 } 1104 1105 /** 1106 * check if block exists in actual template 1107 * @access private 1108 * @param string blockname 1109 * @return boolean 1110 */ 1111 public function blockExists($a_blockname) 1112 { 1113 // added second evaluation to the return statement because the first one only works for the content block (Helmut Schottmüller, 2007-09-14) 1114 return (isset($this->blockvariables["content"][$a_blockname]) ? true : false) | (isset($this->blockvariables[$a_blockname]) ? true : false); 1115 } 1116 1117 private function variableExists($a_variablename) 1118 { 1119 return (isset($this->blockvariables["content"][$a_variablename]) ? true : false); 1120 } 1121 1122 /** 1123 * all template vars defined in $vars will be replaced automatically 1124 * without setting and parsing them with setVariable & parseCurrentBlock 1125 * @access private 1126 * @return integer 1127 */ 1128 public function fillVars() 1129 { 1130 $count = 0; 1131 reset($this->vars); 1132 1133 foreach ($this->vars as $key => $val) { 1134 if (is_array($this->blockvariables[$this->activeBlock])) { 1135 if (array_key_exists($key, $this->blockvariables[$this->activeBlock])) { 1136 $count++; 1137 1138 $this->setVariable($key, $val); 1139 } 1140 } 1141 } 1142 1143 return $count; 1144 } 1145 1146 /** 1147 * Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt. 1148 * @access public 1149 * @param string 1150 * @return ??? 1151 */ 1152 public function setCurrentBlock($part = "DEFAULT") 1153 { 1154 $this->activeBlock = $part; 1155 1156 if ($part == "DEFAULT") { 1157 return parent::setCurrentBlock(); 1158 } else { 1159 return parent::setCurrentBlock($part); 1160 } 1161 } 1162 1163 /** 1164 * overwrites ITX::touchBlock. 1165 * @access public 1166 * @param string 1167 * @return ??? 1168 */ 1169 public function touchBlock($block) 1170 { 1171 $this->setCurrentBlock($block); 1172 $count = $this->fillVars(); 1173 $this->parseCurrentBlock(); 1174 1175 if ($count == 0) { 1176 parent::touchBlock($block); 1177 } 1178 } 1179 1180 /** 1181 * Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt 1182 * @access public 1183 * @param string 1184 * @return string 1185 */ 1186 public function parseCurrentBlock($part = "DEFAULT") 1187 { 1188 // Hier erst noch ein replace aufrufen 1189 if ($part != "DEFAULT") { 1190 $tmp = $this->activeBlock; 1191 $this->activeBlock = $part; 1192 } 1193 1194 if ($part != "DEFAULT") { 1195 $this->activeBlock = $tmp; 1196 } 1197 1198 $this->fillVars(); 1199 1200 $this->activeBlock = "__global__"; 1201 1202 if ($part == "DEFAULT") { 1203 return parent::parseCurrentBlock(); 1204 } else { 1205 return parent::parseCurrentBlock($part); 1206 } 1207 } 1208 1209 /** 1210 * ??? 1211 * TODO: Adjust var names to ilias. This method wasn't used so far 1212 * and isn't translated yet 1213 * @access public 1214 * @param string 1215 * @param string 1216 * @param string 1217 * @param string 1218 */ 1219 public function replaceFromDatabase(&$DB, $block, $conv, $select = "default") 1220 { 1221 $res = $DB->selectDbAll(); 1222 1223 while ($DB->getDbNextElement($res)) { 1224 $this->setCurrentBlock($block); 1225 $result = array(); 1226 reset($conv); 1227 1228 while (list($key, $val) = each($conv)) { 1229 $result[$val] = $DB->element->data[$key]; 1230 } 1231 1232 if (($select != "default") 1233 && ($DB->element->data[$select["id"]] == $select["value"] 1234 || (strtolower($select["text"]) == "checked" 1235 && strpos(",," . $select["value"] . ",,", "," . $DB->element->data[$select["id"]] . ",") != false))) { 1236 $result[$select["field"]] = $select["text"]; 1237 } 1238 1239 $this->replace($result); 1240 $this->parseCurrentBlock($block); 1241 } 1242 } 1243 1244 /** 1245 * Wird angewendet, wenn die Daten in ein Formular replaced werden sollen, 1246 * Dann wird erst noch ein htmlspecialchars drumherum gemacht. 1247 * @access public 1248 * @param string 1249 */ 1250 public function prepareForFormular($vars) 1251 { 1252 if (!is_array($vars)) { 1253 return; 1254 } 1255 1256 reset($vars); 1257 1258 while (list($i) = each($vars)) { 1259 $vars[$i] = stripslashes($vars[$i]); 1260 $vars[$i] = htmlspecialchars($vars[$i]); 1261 } 1262 1263 return($vars); 1264 } 1265 1266 /** 1267 * ??? 1268 * @access public 1269 */ 1270 public function replace() 1271 { 1272 reset($this->vars); 1273 1274 while (list($key, $val) = each($this->vars)) { 1275 $this->setVariable($key, $val); 1276 } 1277 } 1278 1279 /** 1280 * ??? 1281 * @access public 1282 */ 1283 public function replaceDefault() 1284 { 1285 $this->replace($this->vars); 1286 } 1287 1288 /** 1289 * checks for a topic in the template 1290 * @access private 1291 * @param string 1292 * @param string 1293 * @return boolean 1294 */ 1295 public function checkTopic($a_block, $a_topic) 1296 { 1297 return array_key_exists($a_topic, $this->blockvariables[$a_block]); 1298 } 1299 1300 /** 1301 * check if there is a NAVIGATION-topic 1302 * @access public 1303 * @return boolean 1304 */ 1305 public function includeNavigation() 1306 { 1307 return $this->checkTopic("__global__", "NAVIGATION"); 1308 } 1309 1310 /** 1311 * check if there is a TREE-topic 1312 * @access public 1313 * @return boolean 1314 */ 1315 public function includeTree() 1316 { 1317 return $this->checkTopic("__global__", "TREE"); 1318 } 1319 1320 /** 1321 * check if a file exists 1322 * @access public 1323 * @return boolean 1324 */ 1325 public function fileExists($filename) 1326 { 1327 return file_exists($this->tplPath . "/" . $filename); 1328 } 1329 1330 1331 /** 1332 * overwrites ITX::addBlockFile 1333 * @access public 1334 * @param string 1335 * @param string 1336 * @param string $tplname template name 1337 * @param boolean $in_module should be set to true, if template file is in module subdirectory 1338 * @return boolean/string 1339 */ 1340 public function addBlockFile($var, $block, $tplname, $in_module = false) 1341 { 1342 global $DIC; 1343 1344 if (DEBUG) { 1345 echo "<br/>Template '" . $this->tplPath . "/" . $tplname . "'"; 1346 } 1347 1348 $tplfile = $this->getTemplatePath($tplname, $in_module); 1349 if (file_exists($tplfile) == false) { 1350 echo "<br/>Template '" . $tplfile . "' doesn't exist! aborting..."; 1351 return false; 1352 } 1353 1354 $id = $this->getTemplateIdentifier($tplname, $in_module); 1355 $template = $this->getFile($tplfile); 1356 1357 // include the template input hook 1358 $ilPluginAdmin = $DIC["ilPluginAdmin"]; 1359 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk"); 1360 foreach ($pl_names as $pl) { 1361 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl); 1362 $gui_class = $ui_plugin->getUIClassInstance(); 1363 1364 $resp = $gui_class->getHTML( 1365 "", 1366 "template_add", 1367 array("tpl_id" => $id, "tpl_obj" => $this, "html" => $template) 1368 ); 1369 1370 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) { 1371 $template = $gui_class->modifyHTML($template, $resp); 1372 } 1373 } 1374 1375 return $this->addBlock($var, $block, $template); 1376 } 1377 1378 1379 /** 1380 * Reads a template file from the disk. 1381 * 1382 * overwrites IT:loadTemplateFile to include the template input hook 1383 * 1384 * @param string name of the template file 1385 * @param bool how to handle unknown variables. 1386 * @param bool how to handle empty blocks. 1387 * @access public 1388 * @return boolean false on failure, otherwise true 1389 * @see $template, setTemplate(), $removeUnknownVariables, 1390 * $removeEmptyBlocks 1391 */ 1392 public function loadTemplatefile( 1393 $filename, 1394 $removeUnknownVariables = true, 1395 $removeEmptyBlocks = true 1396 ) { 1397 global $DIC; 1398 1399 // copied from IT:loadTemplateFile 1400 $template = ''; 1401 if (!$this->flagCacheTemplatefile || 1402 $this->lastTemplatefile != $filename 1403 ) { 1404 $template = $this->getFile($filename); 1405 } 1406 $this->lastTemplatefile = $filename; 1407 // copied. 1408 1409 // new code to include the template input hook: 1410 $ilPluginAdmin = $DIC["ilPluginAdmin"]; 1411 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk"); 1412 foreach ($pl_names as $pl) { 1413 $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl); 1414 $gui_class = $ui_plugin->getUIClassInstance(); 1415 1416 $resp = $gui_class->getHTML( 1417 "", 1418 "template_load", 1419 array("tpl_id" => $this->tplIdentifier, "tpl_obj" => $this, "html" => $template) 1420 ); 1421 1422 if ($resp["mode"] != ilUIHookPluginGUI::KEEP) { 1423 $template = $gui_class->modifyHTML($template, $resp); 1424 } 1425 } 1426 // new. 1427 1428 // copied from IT:loadTemplateFile 1429 return $template != '' ? 1430 $this->setTemplate( 1431 $template, 1432 $removeUnknownVariables, 1433 $removeEmptyBlocks 1434 ) : false; 1435 // copied. 1436 } 1437 1438 1439 /** 1440 * builds a full template path with template and module name 1441 * 1442 * @param string $a_tplname template name 1443 * @param boolean $in_module should be set to true, if template file is in module subdirectory 1444 * 1445 * @return string full template path 1446 */ 1447 public function getTemplatePath($a_tplname, $a_in_module = false, $a_plugin = false) 1448 { 1449 global $DIC; 1450 1451 $ilCtrl = null; 1452 if (isset($DIC["ilCtrl"])) { 1453 $ilCtrl = $DIC->ctrl(); 1454 } 1455 1456 $fname = ""; 1457 1458 // if baseClass functionality is used (ilias.php): 1459 // get template directory from ilCtrl 1460 if (!empty($_GET["baseClass"]) && $a_in_module === true) { 1461 $a_in_module = $ilCtrl->getModuleDir(); 1462 } 1463 1464 if (strpos($a_tplname, "/") === false) { 1465 $module_path = ""; 1466 1467 if ($a_in_module) { 1468 if ($a_in_module === true) { 1469 $module_path = ILIAS_MODULE . "/"; 1470 } else { 1471 $module_path = $a_in_module . "/"; 1472 } 1473 } 1474 1475 // use ilStyleDefinition instead of account to get the current skin 1476 include_once "Services/Style/System/classes/class.ilStyleDefinition.php"; 1477 if (ilStyleDefinition::getCurrentSkin() != "default") { 1478 $style = ilStyleDefinition::getCurrentStyle(); 1479 1480 $fname = "./Customizing/global/skin/" . 1481 ilStyleDefinition::getCurrentSkin() . "/" . $style . "/" . $module_path 1482 . basename($a_tplname); 1483 1484 if ($fname == "" || !file_exists($fname)) { 1485 $fname = "./Customizing/global/skin/" . 1486 ilStyleDefinition::getCurrentSkin() . "/" . $module_path . basename($a_tplname); 1487 } 1488 } 1489 1490 if ($fname == "" || !file_exists($fname)) { 1491 $fname = "./" . $module_path . "templates/default/" . basename($a_tplname); 1492 } 1493 } elseif (strpos($a_tplname, "src/UI") === 0) { 1494 if (class_exists("ilStyleDefinition") // for testing 1495 && ilStyleDefinition::getCurrentSkin() != "default") { 1496 $fname = "./Customizing/global/skin/" . ilStyleDefinition::getCurrentSkin() . "/" . str_replace("src/UI/templates/default", "UI", $a_tplname); 1497 } 1498 if ($fname == "" || !file_exists($fname)) { 1499 $fname = $a_tplname; 1500 } 1501 } else { 1502 $fname = $a_tplname; 1503 } 1504 1505 return $fname; 1506 } 1507 1508 /** 1509 * get a unique template identifier 1510 * 1511 * The identifier is common for default or customized skins 1512 * but distincts templates of different services with the same name. 1513 * 1514 * This is used by the UI plugin hook for template input/output 1515 * 1516 * @param string $a_tplname template name 1517 * @param string $in_module Component, e.g. "Modules/Forum" 1518 * boolean $in_module or true, if component should be determined by ilCtrl 1519 * 1520 * @return string template identifier, e.g. "tpl.confirm.html" 1521 */ 1522 public function getTemplateIdentifier($a_tplname, $a_in_module = false) 1523 { 1524 global $DIC; 1525 1526 $ilCtrl = null; 1527 if (isset($DIC["ilCtrl"])) { 1528 $ilCtrl = $DIC->ctrl(); 1529 } 1530 1531 1532 // if baseClass functionality is used (ilias.php): 1533 // get template directory from ilCtrl 1534 if (!empty($_GET["baseClass"]) && $a_in_module === true) { 1535 $a_in_module = $ilCtrl->getModuleDir(); 1536 } 1537 1538 if (strpos($a_tplname, "/") === false) { 1539 if ($a_in_module) { 1540 if ($a_in_module === true) { 1541 $module_path = ILIAS_MODULE . "/"; 1542 } else { 1543 $module_path = $a_in_module . "/"; 1544 } 1545 } else { 1546 $module_path = ""; 1547 } 1548 1549 return $module_path . basename($a_tplname); 1550 } else { 1551 return $a_tplname; 1552 } 1553 } 1554 1555 public function setHeaderPageTitle($a_title) 1556 { 1557 $a_title = ilUtil::stripScriptHTML($a_title); 1558 $this->header_page_title = $a_title; 1559 } 1560 1561 public function setStyleSheetLocation($a_stylesheet) 1562 { 1563 $this->setVariable("LOCATION_STYLESHEET", $a_stylesheet); 1564 } 1565 1566 public function setNewContentStyleSheetLocation($a_stylesheet) 1567 { 1568 $this->setVariable("LOCATION_NEWCONTENT_STYLESHEET", $a_stylesheet); 1569 } 1570 1571 public function getStandardTemplate() 1572 { 1573 if ($this->standard_template_loaded) { 1574 return; 1575 } 1576 1577 // always load jQuery 1578 include_once("./Services/jQuery/classes/class.iljQueryUtil.php"); 1579 iljQueryUtil::initjQuery(); 1580 iljQueryUtil::initjQueryUI(); 1581 1582 // always load ui framework 1583 include_once("./Services/UICore/classes/class.ilUIFramework.php"); 1584 ilUIFramework::init(); 1585 1586 // always load Basic js 1587 // $this->addJavaScript("./Services/JavaScript/js/Basic.js", 1588 // true, 1); 1589 1590 $this->addBlockFile("CONTENT", "content", "tpl.adm_content.html"); 1591 $this->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html"); 1592 1593 $this->standard_template_loaded = true; 1594 } 1595 1596 /** 1597 * sets title in standard template 1598 */ 1599 public function setTitle($a_title) 1600 { 1601 $this->title = ilUtil::stripScriptHTML($a_title); 1602 $this->header_page_title = $a_title; 1603 } 1604 1605 /** 1606 * sets title url in standard template 1607 */ 1608 public function setTitleUrl($a_url) 1609 { 1610 $this->title_url = $a_url; 1611 } 1612 1613 /** 1614 * Set title color 1615 * 1616 * @param string $a_val color 1617 */ 1618 public function setTitleColor($a_val) 1619 { 1620 $this->title_color = $a_val; 1621 } 1622 1623 /** 1624 * Get title color 1625 * 1626 * @return string color 1627 */ 1628 public function getTitleColor() 1629 { 1630 return $this->title_color; 1631 } 1632 1633 /** 1634 * Set alert properties 1635 * @param array $a_props 1636 * @return void 1637 */ 1638 public function setAlertProperties(array $a_props) 1639 { 1640 $this->title_alerts = $a_props; 1641 } 1642 1643 /** 1644 * Clear header 1645 */ 1646 public function clearHeader() 1647 { 1648 $this->setTitle(""); 1649 $this->setTitleIcon(""); 1650 $this->setDescription(""); 1651 $this->setAlertProperties(array()); 1652 } 1653 1654 1655 /** 1656 * Fill header 1657 */ 1658 private function fillHeader() 1659 { 1660 global $DIC; 1661 1662 $lng = $DIC->language(); 1663 1664 $icon = false; 1665 if ($this->icon_path != "") { 1666 $icon = true; 1667 $this->setCurrentBlock("header_image"); 1668 if ($this->icon_desc != "") { 1669 $this->setVariable("IMAGE_DESC", $lng->txt("icon") . " " . $this->icon_desc); 1670 $this->setVariable("IMAGE_ALT", $lng->txt("icon") . " " . $this->icon_desc); 1671 } 1672 1673 $this->setVariable("IMG_HEADER", $this->icon_path); 1674 $this->parseCurrentBlock(); 1675 $header = true; 1676 } 1677 1678 if ($this->title != "") { 1679 $this->title = ilUtil::stripScriptHTML($this->title); 1680 $this->setVariable("HEADER", $this->title); 1681 if ($this->title_url != "") { 1682 $this->setVariable("HEADER_URL", ' href="' . $this->title_url . '"'); 1683 } 1684 if ($this->getTitleColor() != "") { 1685 $this->setVariable("HEADER_COLOR", " style=\"color: #" . $this->getTitleColor() . "\""); 1686 } 1687 1688 if ($icon) { 1689 //$this->setVariable("HICONCL", "ilHeaderHasIcon"); 1690 } 1691 $header = true; 1692 } 1693 1694 if ($header) { 1695 $this->setCurrentBlock("header_image"); 1696 $this->parseCurrentBlock(); 1697 } 1698 1699 if ($this->title_desc != "") { 1700 $this->setCurrentBlock("header_desc"); 1701 $this->setVariable("H_DESCRIPTION", $this->title_desc); 1702 $this->parseCurrentBlock(); 1703 } 1704 1705 $header = $this->getHeaderActionMenu(); 1706 if ($header) { 1707 $this->setCurrentBlock("head_action_inner"); 1708 $this->setVariable("HEAD_ACTION", $header); 1709 $this->parseCurrentBlock(); 1710 $this->setCurrentBlock("head_action"); 1711 $this->parseCurrentBlock(); 1712 } 1713 1714 if (count((array) $this->title_alerts)) { 1715 foreach ($this->title_alerts as $alert) { 1716 $this->setCurrentBlock('header_alert'); 1717 if (!($alert['propertyNameVisible'] === false)) { 1718 $this->setVariable('H_PROP', $alert['property'] . ':'); 1719 } 1720 $this->setVariable('H_VALUE', $alert['value']); 1721 $this->parseCurrentBlock(); 1722 } 1723 } 1724 1725 // add file upload drop zone in header 1726 if ($this->enable_fileupload != null) { 1727 $ref_id = $this->enable_fileupload; 1728 $upload_id = "dropzone_" . $ref_id; 1729 1730 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php"); 1731 $upload = new ilFileUploadGUI($upload_id, $ref_id, true); 1732 1733 $this->setVariable("FILEUPLOAD_DROPZONE_ID", " id=\"$upload_id\""); 1734 1735 $this->setCurrentBlock("header_fileupload"); 1736 $this->setVariable("HEADER_FILEUPLOAD_SCRIPT", $upload->getHTML()); 1737 $this->parseCurrentBlock(); 1738 } 1739 } 1740 1741 /** 1742 * set title icon 1743 */ 1744 public function setTitleIcon($a_icon_path, $a_icon_desc = "") 1745 { 1746 $this->icon_desc = $a_icon_desc; 1747 $this->icon_path = $a_icon_path; 1748 } 1749 1750 public function setBodyClass($a_class = "") 1751 { 1752 $this->body_class = $a_class; 1753 } 1754 1755 public function fillBodyClass() 1756 { 1757 if ($this->body_class != "" && $this->blockExists("body_class")) { 1758 $this->setCurrentBlock("body_class"); 1759 $this->setVariable("BODY_CLASS", $this->body_class); 1760 $this->parseCurrentBlock(); 1761 } 1762 } 1763 1764 public function setPageFormAction($a_action) 1765 { 1766 $this->page_form_action = $a_action; 1767 } 1768 1769 /** 1770 * sets title in standard template 1771 */ 1772 public function setDescription($a_descr) 1773 { 1774 $this->title_desc = $a_descr; 1775 // $this->setVariable("H_DESCRIPTION", $a_descr); 1776 } 1777 1778 /** 1779 * set stop floating (if no tabs are used) 1780 */ 1781 public function stopTitleFloating() 1782 { 1783 $this->stop_floating = true; 1784 } 1785 1786 /** 1787 * stop floating 1788 */ 1789 private function fillStopFloating() 1790 { 1791 if ($this->stop_floating) { 1792 $this->touchBlock("stop_floating"); 1793 } 1794 } 1795 1796 /** 1797 * Set header action menu 1798 * 1799 * @param string $a_gui $a_header 1800 */ 1801 public function setHeaderActionMenu($a_header) 1802 { 1803 $this->header_action = $a_header; 1804 } 1805 1806 /** 1807 * Get header action menu 1808 * 1809 * @return int ref id 1810 */ 1811 public function getHeaderActionMenu() 1812 { 1813 return $this->header_action; 1814 } 1815 1816 /** 1817 * sets content for standard template 1818 */ 1819 public function setContent($a_html) 1820 { 1821 if ($a_html != "") { 1822 $this->main_content = $a_html; 1823 } 1824 } 1825 1826 /** 1827 * Fill main content 1828 */ 1829 public function fillMainContent() 1830 { 1831 if (trim($this->main_content) != "") { 1832 $this->setVariable("ADM_CONTENT", $this->main_content); 1833 } 1834 } 1835 1836 /** 1837 * sets content of right column 1838 */ 1839 public function setRightContent($a_html) 1840 { 1841 $this->right_content = $a_html; 1842 } 1843 1844 /** 1845 * Fill right content 1846 */ 1847 private function fillRightContent() 1848 { 1849 if (trim($this->right_content) != "") { 1850 $this->setCurrentBlock("right_column"); 1851 $this->setVariable("RIGHT_CONTENT", $this->right_content); 1852 $this->parseCurrentBlock(); 1853 } 1854 } 1855 1856 private function setCenterColumnClass() 1857 { 1858 if (!$this->blockExists("center_col_width")) { 1859 return; 1860 } 1861 $center_column_class = ""; 1862 if (trim($this->right_content) != "" && trim($this->left_content) != "") { 1863 $center_column_class = "two_side_col"; 1864 } elseif (trim($this->right_content) != "" || trim($this->left_content) != "") { 1865 $center_column_class = "one_side_col"; 1866 } 1867 1868 switch ($center_column_class) { 1869 case "one_side_col": $center_column_class = "col-sm-9"; break; 1870 case "two_side_col": $center_column_class = "col-sm-6"; break; 1871 default: $center_column_class = "col-sm-12"; break; 1872 } 1873 if (trim($this->left_content) != "") { 1874 $center_column_class .= " col-sm-push-3"; 1875 } 1876 1877 $this->setCurrentBlock("center_col_width"); 1878 $this->setVariable("CENTER_COL", $center_column_class); 1879 $this->parseCurrentBlock(); 1880 } 1881 1882 /** 1883 * sets content of left column 1884 */ 1885 public function setLeftContent($a_html) 1886 { 1887 $this->left_content = $a_html; 1888 } 1889 1890 /** 1891 * Fill left content 1892 */ 1893 private function fillLeftContent() 1894 { 1895 if (trim($this->left_content) != "") { 1896 $this->setCurrentBlock("left_column"); 1897 $this->setVariable("LEFT_CONTENT", $this->left_content); 1898 $left_col_class = (trim($this->right_content) == "") 1899 ? "col-sm-3 col-sm-pull-9" 1900 : "col-sm-3 col-sm-pull-6"; 1901 $this->setVariable("LEFT_COL_CLASS", $left_col_class); 1902 $this->parseCurrentBlock(); 1903 } 1904 } 1905 1906 /** 1907 * Sets content of left navigation column 1908 */ 1909 public function setLeftNavContent($a_content) 1910 { 1911 $this->left_nav_content = $a_content; 1912 } 1913 1914 /** 1915 * Fill left navigation frame 1916 */ 1917 public function fillLeftNav() 1918 { 1919 if (trim($this->left_nav_content) != "") { 1920 $this->setCurrentBlock("left_nav"); 1921 $this->setVariable("LEFT_NAV_CONTENT", $this->left_nav_content); 1922 $this->parseCurrentBlock(); 1923 $this->touchBlock("left_nav_space"); 1924 } 1925 } 1926 1927 /** 1928 * Insert locator. 1929 */ 1930 public function setLocator() 1931 { 1932 global $DIC; 1933 1934 $ilMainMenu = $DIC["ilMainMenu"]; 1935 $ilLocator = $DIC["ilLocator"]; 1936 1937 $ilPluginAdmin = $DIC["ilPluginAdmin"]; 1938 1939 // blog/portfolio 1940 if ($ilMainMenu->getMode() == ilMainMenuGUI::MODE_TOPBAR_REDUCED || 1941 $ilMainMenu->getMode() == ilMainMenuGUI::MODE_TOPBAR_ONLY) { 1942 $this->setVariable("LOCATOR", ""); 1943 return; 1944 } 1945 1946 $html = ""; 1947 if (is_object($ilPluginAdmin)) { 1948 include_once("./Services/UIComponent/classes/class.ilUIHookProcessor.php"); 1949 $uip = new ilUIHookProcessor( 1950 "Services/Locator", 1951 "main_locator", 1952 array("locator_gui" => $ilLocator) 1953 ); 1954 if (!$uip->replaced()) { 1955 $html = $ilLocator->getHTML(); 1956 } 1957 $html = $uip->getHTML($html); 1958 } else { 1959 $html = $ilLocator->getHTML(); 1960 } 1961 1962 $this->setVariable("LOCATOR", $html); 1963 } 1964 1965 /** 1966 * sets tabs in standard template 1967 */ 1968 public function setTabs($a_tabs_html) 1969 { 1970 if ($a_tabs_html != "" && $this->blockExists("tabs_outer_start")) { 1971 $this->touchBlock("tabs_outer_start"); 1972 $this->touchBlock("tabs_outer_end"); 1973 $this->touchBlock("tabs_inner_start"); 1974 $this->touchBlock("tabs_inner_end"); 1975 $this->setVariable("TABS", $a_tabs_html); 1976 } 1977 } 1978 1979 /** 1980 * sets subtabs in standard template 1981 */ 1982 public function setSubTabs($a_tabs_html) 1983 { 1984 $this->setVariable("SUB_TABS", $a_tabs_html); 1985 } 1986 1987 /** 1988 * sets icon to upper level 1989 */ 1990 public function setUpperIcon($a_link, $a_frame = "") 1991 { 1992 $this->upper_icon = $a_link; 1993 $this->upper_icon_frame = $a_frame; 1994 } 1995 1996 /** 1997 * Set target parameter for login (public sector). 1998 * This is used by the main menu 1999 */ 2000 public function setLoginTargetPar($a_val) 2001 { 2002 $this->login_target_par = $a_val; 2003 } 2004 2005 /** 2006 * Get target parameter for login 2007 */ 2008 public function getLoginTargetPar() 2009 { 2010 return $this->login_target_par; 2011 } 2012 2013 /** 2014 * Accessibility focus for screen readers 2015 */ 2016 public function fillScreenReaderFocus() 2017 { 2018 global $DIC; 2019 2020 $ilUser = $DIC->user(); 2021 2022 if (is_object($ilUser) && $ilUser->getPref("screen_reader_optimization") && $this->blockExists("sr_focus")) { 2023 $this->touchBlock("sr_focus"); 2024 } 2025 } 2026 2027 /** 2028 * Fill side icons (upper icon, tree icon, webfolder icon) 2029 */ 2030 public function fillSideIcons() 2031 { 2032 global $DIC; 2033 2034 $ilSetting = $DIC->settings(); 2035 2036 $lng = $DIC->language(); 2037 2038 if ($this->upper_icon == "" && $this->tree_flat_link == "" 2039 && $this->mount_webfolder == "") { 2040 return; 2041 } 2042 2043 // upper icon 2044 // deprecated 2045 if ($this->upper_icon != "") { 2046 /*if ($this->upper_icon_frame != "") 2047 { 2048 $this->setCurrentBlock("target_top"); 2049 $this->setVariable("TARGET_TOP", $this->upper_icon_frame); 2050 $this->parseCurrentBlock(); 2051 } 2052 2053 $this->setCurrentBlock("alt_top"); 2054 $this->setVariable("ALT_TOP", $lng->txt("up")); 2055 $this->parseCurrentBlock(); 2056 2057 $this->setCurrentBlock("top"); 2058 $this->setVariable("LINK_TOP", $this->upper_icon); 2059 $this->parseCurrentBlock();*/ 2060 } 2061 2062 // tree/flat icon 2063 if ($this->tree_flat_link != "") { 2064 if ($this->left_nav_content != "") { 2065 $this->touchBlock("tree_lns"); 2066 } 2067 2068 $this->setCurrentBlock("tree_mode"); 2069 $this->setVariable("LINK_MODE", $this->tree_flat_link); 2070 if ($ilSetting->get("tree_frame") == "right") { 2071 if ($this->tree_flat_mode == "tree") { 2072 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg")); 2073 $this->setVariable("RIGHT", "Right"); 2074 } else { 2075 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg")); 2076 $this->setVariable("RIGHT", "Right"); 2077 } 2078 } else { 2079 if ($this->tree_flat_mode == "tree") { 2080 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg")); 2081 } else { 2082 $this->setVariable("IMG_TREE", ilUtil::getImagePath("icon_sidebar_on.svg")); 2083 } 2084 } 2085 $this->setVariable("ALT_TREE", $lng->txt($this->tree_flat_mode . "view")); 2086 $this->setVariable("TARGET_TREE", ilFrameTargetInfo::_getFrame("MainContent")); 2087 include_once("./Services/Accessibility/classes/class.ilAccessKeyGUI.php"); 2088 $this->setVariable( 2089 "TREE_ACC_KEY", 2090 ilAccessKeyGUI::getAttribute(($this->tree_flat_mode == "tree") 2091 ? ilAccessKey::TREE_ON 2092 : ilAccessKey::TREE_OFF) 2093 ); 2094 $this->parseCurrentBlock(); 2095 } 2096 2097 // mount webfolder 2098 if ($this->mount_webfolder != "") { 2099 require_once('Services/WebDAV/classes/class.ilWebDAVUtil.php'); 2100 $dav_util = ilWebDAVUtil::getInstance(); 2101 $a_ref_id = $this->mount_webfolder; 2102 $a_link = $dav_util->getMountURI($a_ref_id); 2103 $a_folder = $dav_util->getFolderURI($a_ref_id); 2104 2105 $this->setCurrentBlock("mount_webfolder"); 2106 $this->setVariable("LINK_MOUNT_WEBFOLDER", $a_link); 2107 $this->setVariable("FOLDER_MOUNT_WEBFOLDER", $a_folder); 2108 $this->setVariable("IMG_MOUNT_WEBFOLDER", ilUtil::getImagePath("ic_mount_webfolder.png")); 2109 $this->setVariable("ALT_MOUNT_WEBFOLDER", $lng->txt("mount_webfolder")); 2110 $this->setVariable("TARGET_MOUNT_WEBFOLDER", '_blank'); 2111 $this->parseCurrentBlock(); 2112 } 2113 2114 $this->setCurrentBlock("tree_icons"); 2115 $this->parseCurrentBlock(); 2116 } 2117 2118 // BEGIN WebDAV: Mount webfolder icon. 2119 /** 2120 * shows icon for mounting a webfolder 2121 */ 2122 public function setMountWebfolderIcon($a_ref_id) 2123 { 2124 $this->mount_webfolder = $a_ref_id; 2125 } 2126 // END WebDAV: Mount webfolder icon. 2127 2128 /** 2129 * set tree/flat icon 2130 * @param string link target 2131 * @param strong mode ("tree" | "flat") 2132 */ 2133 public function setTreeFlatIcon($a_link, $a_mode) 2134 { 2135 $this->tree_flat_link = $a_link; 2136 $this->tree_flat_mode = $a_mode; 2137 } 2138 2139 /** 2140 * Add a javascript file that should be included in the header. 2141 */ 2142 public function addJavaScript($a_js_file, $a_add_version_parameter = true, $a_batch = 2) 2143 { 2144 // three batches currently 2145 if ($a_batch < 1 || $a_batch > 3) { 2146 $a_batch = 2; 2147 } 2148 2149 // ensure jquery files being loaded first 2150 if (is_int(strpos($a_js_file, "Services/jQuery")) || 2151 is_int(strpos($a_js_file, "/jquery.js")) || 2152 is_int(strpos($a_js_file, "/jquery-min.js"))) { 2153 $a_batch = 0; 2154 } 2155 2156 if (!in_array($a_js_file, $this->js_files)) { 2157 $this->js_files[] = $a_js_file; 2158 $this->js_files_vp[$a_js_file] = $a_add_version_parameter; 2159 $this->js_files_batch[$a_js_file] = $a_batch; 2160 } 2161 } 2162 2163 /** 2164 * Reset javascript files 2165 */ 2166 public function resetJavascript() 2167 { 2168 $this->js_files = array(); 2169 $this->js_files_vp = array(); 2170 $this->js_files_batch = array(); 2171 } 2172 2173 /** 2174 * Reset css files 2175 * 2176 * @param 2177 * @return 2178 */ 2179 public function resetCss() 2180 { 2181 $this->css_files = array(); 2182 } 2183 2184 2185 /** 2186 * Add on load code 2187 */ 2188 public function addOnLoadCode($a_code, $a_batch = 2) 2189 { 2190 // three batches currently 2191 if ($a_batch < 1 || $a_batch > 3) { 2192 $a_batch = 2; 2193 } 2194 $this->on_load_code[$a_batch][] = $a_code; 2195 } 2196 2197 /** 2198 * Add a css file that should be included in the header. 2199 */ 2200 public function addCss($a_css_file, $media = "screen") 2201 { 2202 if (!array_key_exists($a_css_file . $media, $this->css_files)) { 2203 $this->css_files[$a_css_file . $media] = array("file" => $a_css_file, "media" => $media); 2204 } 2205 } 2206 2207 /** 2208 * Add a css file that should be included in the header. 2209 */ 2210 public function addInlineCss($a_css, $media = "screen") 2211 { 2212 $this->inline_css[] = array("css" => $a_css, "media" => $media); 2213 } 2214 2215 /** 2216 * Add lightbox html 2217 */ 2218 public function addLightbox($a_html, $a_id) 2219 { 2220 $this->lightbox[$a_id] = $a_html; 2221 } 2222 2223 /** 2224 * Fill lightbox content 2225 * 2226 * @param 2227 * @return 2228 */ 2229 public function fillLightbox() 2230 { 2231 $html = ""; 2232 2233 foreach ($this->lightbox as $lb) { 2234 $html .= $lb; 2235 } 2236 $this->setVariable("LIGHTBOX", $html); 2237 } 2238 2239 /** 2240 * Show admin view button 2241 */ 2242 public function setPageActions($a_page_actions_html) 2243 { 2244 $this->page_actions = $a_page_actions_html; 2245 } 2246 2247 /** 2248 * Show admin view button 2249 */ 2250 public function setEditPageButton($a_link, $a_txt, $a_frame) 2251 { 2252 $this->edit_page_button = 2253 array("link" => $a_link, "txt" => $a_txt, "frame" => $a_frame); 2254 } 2255 2256 /** 2257 * Add a command to the admin panel 2258 * @deprecated use addAdminPanelToolbar 2259 */ 2260 public function addAdminPanelCommand($a_cmd, $a_txt, $a_arrow = false) 2261 { 2262 $this->admin_panel_commands[] = 2263 array("cmd" => $a_cmd, "txt" => $a_txt); 2264 if ($a_arrow) { 2265 $this->admin_panel_arrow = true; 2266 } 2267 $this->admin_panel_top_only = false; 2268 } 2269 2270 /** 2271 * Add admin panel commands as toolbar 2272 * @param ilToolbarGUI $toolb 2273 * @param bool $a_top_only 2274 */ 2275 public function addAdminPanelToolbar(ilToolbarGUI $toolb, $a_bottom_panel = true, $a_arrow = false) 2276 { 2277 $this->admin_panel_commands_toolbar = $toolb; 2278 $this->admin_panel_arrow = $a_arrow; 2279 $this->admin_panel_bottom = $a_bottom_panel; 2280 } 2281 2282 /** 2283 * Put admin panel into template: 2284 * - creation selector 2285 * - admin view on/off button 2286 */ 2287 public function fillAdminPanel() 2288 { 2289 global $DIC; 2290 2291 $lng = $DIC->language(); 2292 2293 $adm_view_cmp = $adm_cmds = $adm_view = false; 2294 2295 $toolb = new ilToolbarGUI(); 2296 2297 // admin panel commands 2298 if ((count($this->admin_panel_commands) > 0)) { 2299 foreach ($this->admin_panel_commands as $cmd) { 2300 $toolb->addFormButton($cmd["txt"], $cmd["cmd"]); 2301 } 2302 $adm_cmds = true; 2303 } elseif ($this->admin_panel_commands_toolbar instanceof ilToolbarGUI) { 2304 $toolb = $this->admin_panel_commands_toolbar; 2305 $adm_cmds = true; 2306 } 2307 // Add arrow if desired 2308 if ($this->admin_panel_arrow) { 2309 $toolb->setLeadingImage(ilUtil::getImagePath("arrow_upright.svg"), $lng->txt("actions")); 2310 } 2311 2312 if ($adm_cmds) { 2313 $this->fillPageFormAction(); 2314 2315 $this->setCurrentBlock("adm_view_components"); 2316 $this->setVariable("ADM_PANEL1", $toolb->getHTML()); 2317 $this->parseCurrentBlock(); 2318 $adm_view_cmp = true; 2319 } 2320 2321 // admin view button 2322 if ($this->page_actions != "") { 2323 $this->setVariable("PAGE_ACTIONS", $this->page_actions); 2324 $adm_view = true; 2325 } 2326 2327 // creation selector 2328 // see: ilObjectAddNewItemGUI 2329 // placeholder "SELECT_OBJTYPE_REPOS" still needed! 2330 2331 if ($adm_cmds and $this->admin_panel_bottom) { 2332 $this->setCurrentBlock("adm_view_components2"); 2333 if ($this->admin_panel_arrow) { 2334 $toolb->setLeadingImage(ilUtil::getImagePath("arrow_downright.svg"), $lng->txt("actions")); 2335 } 2336 $this->setVariable("ADM_PANEL2", $toolb->getHTML()); 2337 2338 $this->parseCurrentBlock(); 2339 } 2340 } 2341 2342 public function setPermanentLink($a_type, $a_id, $a_append = "", $a_target = "", $a_title = "") 2343 { 2344 $this->permanent_link = array( 2345 "type" => $a_type, 2346 "id" => $a_id, 2347 "append" => $a_append, 2348 "target" => $a_target, 2349 "title" => $a_title); 2350 } 2351 2352 /** 2353 * Fill in permanent link 2354 */ 2355 public function fillPermanentLink() 2356 { 2357 if (is_array($this->permanent_link)) { 2358 include_once("./Services/PermanentLink/classes/class.ilPermanentLinkGUI.php"); 2359 $plinkgui = new ilPermanentLinkGUI( 2360 $this->permanent_link["type"], 2361 $this->permanent_link["id"], 2362 $this->permanent_link["append"], 2363 $this->permanent_link["target"] 2364 ); 2365 if ($this->permanent_link["title"] != "") { 2366 $plinkgui->setTitle($this->permanent_link["title"]); 2367 } 2368 $this->setVariable("PRMLINK", $plinkgui->getHTML()); 2369 } 2370 } 2371 2372 /** 2373 * Fill add on load code 2374 */ 2375 public function fillOnLoadCode() 2376 { 2377 for ($i = 1; $i <= 3; $i++) { 2378 if (is_array($this->on_load_code[$i])) { 2379 $this->setCurrentBlock("on_load_code"); 2380 foreach ($this->on_load_code[$i] as $code) { 2381 $this->setCurrentBlock("on_load_code_inner"); 2382 $this->setVariable("OLCODE", $code); 2383 $this->parseCurrentBlock(); 2384 } 2385 $this->setCurrentBlock("on_load_code"); 2386 $this->parseCurrentBlock(); 2387 } 2388 } 2389 } 2390 2391 /** 2392 * Get js onload code for ajax calls 2393 * 2394 * @return string 2395 */ 2396 public function getOnLoadCodeForAsynch() 2397 { 2398 $js = ""; 2399 for ($i = 1; $i <= 3; $i++) { 2400 if (is_array($this->on_load_code[$i])) { 2401 foreach ($this->on_load_code[$i] as $code) { 2402 $js .= $code . "\n"; 2403 } 2404 } 2405 } 2406 if ($js) { 2407 return '<script type="text/javascript">' . "\n" . 2408 $js . 2409 '</script>' . "\n"; 2410 } 2411 } 2412 2413 public function setBackgroundColor($a_bg_color) 2414 { 2415 // :TODO: currently inactive, JF should discuss this 2416 return; 2417 2418 if ($a_bg_color != "") { 2419 $this->setVariable("FRAME_BG_COLOR", " style=\"background-color: #" . $a_bg_color . "\""); 2420 } 2421 } 2422 2423 /** 2424 * Set banner 2425 * 2426 * @param string $a_img banner full path (background image) 2427 * @param int $a_width banner width 2428 * @param int $a_height banner height 2429 * @param bool $a_export 2430 */ 2431 public function setBanner($a_img, $a_width = 1370, $a_height = 100, $a_export = false) 2432 { 2433 if ($a_img) { 2434 if (!$a_export) { 2435 $a_img = ILIAS_HTTP_PATH . "/" . $a_img; 2436 } 2437 2438 $this->setCurrentBlock("banner_bl"); 2439 $this->setVariable("BANNER_WIDTH", $a_width); // currently not needed 2440 $this->setVariable("BANNER_HEIGHT", $a_height); 2441 $this->setVariable("BANNER_URL", $a_img); 2442 $this->parseCurrentBlock(); 2443 } 2444 } 2445 2446 /** 2447 * Add current object (repository/workspace) as target for login url 2448 * 2449 * @return string 2450 */ 2451 public static function buildLoginTarget() 2452 { 2453 global $DIC; 2454 2455 $tree = $DIC->repositoryTree(); 2456 $ilUser = $DIC->user(); 2457 2458 $target_str = ""; 2459 2460 // repository 2461 if ($_GET["ref_id"] != "") { 2462 if ($tree->isInTree($_GET["ref_id"]) && $_GET["ref_id"] != $tree->getRootId()) { 2463 $obj_id = ilObject::_lookupObjId($_GET["ref_id"]); 2464 $type = ilObject::_lookupType($obj_id); 2465 $target_str = $type . "_" . $_GET["ref_id"]; 2466 } 2467 } 2468 // personal workspace 2469 elseif ($_GET["wsp_id"] != "" && $_GET["wsp_id"] > 0) { 2470 include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; 2471 $tree = new ilWorkspaceTree($ilUser->getId()); 2472 $obj_id = $tree->lookupObjectId((int) $_GET["wsp_id"]); 2473 if ($obj_id) { 2474 $type = ilObject::_lookupType($obj_id); 2475 $target_str = $type . "_" . (int) $_GET["wsp_id"] . "_wsp"; 2476 } 2477 } 2478 // portfolio 2479 elseif ($_GET["prt_id"] != "") { 2480 $target_str = "prtf_" . (int) $_GET["prt_id"]; 2481 } 2482 2483 return $target_str; 2484 } 2485 2486 /** 2487 * Set variable 2488 */ 2489 /* function setVariable($a, $b = "") 2490 { 2491 parent::setVariable($a, $b); return; 2492 if ($a == "HEADER") mk(); 2493 parent::setVariable($a, $b); 2494 }*/ 2495 2496 /** 2497 * Reset all header properties: title, icon, description, alerts, action menu 2498 */ 2499 public function resetHeaderBlock($a_reset_header_action = true) 2500 { 2501 $this->setTitle(null); 2502 $this->setTitleIcon(null); 2503 $this->setDescription(null); 2504 $this->setAlertProperties(array()); 2505 $this->enableDragDropFileUpload(null); 2506 2507 // see setFullscreenHeader() 2508 if ($a_reset_header_action) { 2509 $this->setHeaderActionMenu(null); 2510 } 2511 } 2512 2513 /** 2514 * Enables the file upload into this object by dropping a file. 2515 */ 2516 public function enableDragDropFileUpload($a_ref_id) 2517 { 2518 $this->enable_fileupload = $a_ref_id; 2519 } 2520 2521 2522 /** 2523 * @param $m 2524 * 2525 * @return mixed|string 2526 */ 2527 private function getMessageTextForType($m) 2528 { 2529 $txt = ""; 2530 if (isset($_SESSION[$m]) && $_SESSION[$m] != "") { 2531 $txt = $_SESSION[$m]; 2532 } else { 2533 if (isset($this->message[$m])) { 2534 $txt = $this->message[$m]; 2535 } 2536 } 2537 2538 return $txt; 2539 } 2540} 2541