4 include_once(
"./Services/UICore/lib/html-it/IT.php");
5 include_once(
"./Services/UICore/lib/html-it/ITX.php");
75 string $in_module =
"",
76 string $vars =
"DEFAULT",
78 bool $a_use_cache =
true 80 $this->activeBlock =
"__global__";
81 $this->vars = array();
83 $this->il_use_cache = $a_use_cache;
84 $this->il_cur_key = $file .
"/" . $in_module;
88 $this->tplName = basename($fname);
89 $this->tplPath = dirname($fname);
92 if (!file_exists($fname)) {
93 throw new \LogicException(
"Template '$fname' was not found.");
114 if ($this->il_use_cache) {
116 if (isset(self::$il_cache[$this->il_cur_key]) && is_array(self::$il_cache[$this->il_cur_key])) {
120 $this->flagBlocktrouble = self::$il_cache[
$this->il_cur_key][
"flagBlocktrouble"];
131 $this->
template =
'';
133 if ($this->il_use_cache) {
145 $this->
template =
'';
157 return (isset($this->blockvariables[
"content"][$a_blockname]) ?
true :
false) | (isset($this->blockvariables[$a_blockname]) ? true :
false);
164 public function get($part =
"DEFAULT")
171 $ilPluginAdmin = $DIC[
"ilPluginAdmin"];
172 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
173 foreach ($pl_names as $pl) {
175 $gui_class = $ui_plugin->getUIClassInstance();
177 $resp = $gui_class->getHTML(
180 array(
"tpl_id" => $this->tplIdentifier,
"tpl_obj" => $this,
"html" => $html)
184 $html = $gui_class->modifyHTML($html,
$resp);
199 if ($part ==
"DEFAULT") {
215 $this->activeBlock = $part;
217 if ($part ==
"DEFAULT") {
218 return parent::setCurrentBlock();
220 return parent::setCurrentBlock($part);
237 parent::touchBlock($block);
250 if ($part !=
"DEFAULT") {
252 $this->activeBlock = $part;
255 if ($part !=
"DEFAULT") {
256 $this->activeBlock = $tmp;
261 $this->activeBlock =
"__global__";
263 if ($part ==
"DEFAULT") {
264 return parent::parseCurrentBlock();
266 return parent::parseCurrentBlock($part);
279 public function addBlockFile($var, $block, $tplname, $in_module =
false)
284 echo
"<br/>Template '" . $this->tplPath .
"/" . $tplname .
"'";
288 if (file_exists($tplfile) ==
false) {
289 echo
"<br/>Template '" . $tplfile .
"' doesn't exist! aborting...";
297 $ilPluginAdmin = $DIC[
"ilPluginAdmin"];
298 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
299 foreach ($pl_names as $pl) {
301 $gui_class = $ui_plugin->getUIClassInstance();
303 $resp = $gui_class->getHTML(
306 array(
"tpl_id" => $id,
"tpl_obj" => $this,
"html" =>
$template)
328 foreach ($this->vars as $key => $val) {
329 if (is_array($this->blockvariables[$this->activeBlock])) {
330 if (array_key_exists($key, $this->blockvariables[$this->activeBlock])) {
363 if (!$this->flagCacheTemplatefile ||
372 $ilPluginAdmin = $DIC[
"ilPluginAdmin"];
373 $pl_names = $ilPluginAdmin->getActivePluginsForSlot(
IL_COMP_SERVICE,
"UIComponent",
"uihk");
374 foreach ($pl_names as $pl) {
376 $gui_class = $ui_plugin->getUIClassInstance();
378 $resp = $gui_class->getHTML(
381 array(
"tpl_id" => $this->tplIdentifier,
"tpl_obj" => $this,
"html" =>
$template)
409 protected function getTemplatePath($a_tplname, $a_in_module =
false, $a_plugin =
false)
414 if (isset($DIC[
"ilCtrl"])) {
415 $ilCtrl = $DIC->ctrl();
420 if (strpos($a_tplname,
"/") ===
false) {
423 if ($a_in_module !=
"") {
424 $module_path = $a_in_module .
"/";
428 include_once
"Services/Style/System/classes/class.ilStyleDefinition.php";
432 $fname =
"./Customizing/global/skin/" .
434 . basename($a_tplname);
436 if ($fname ==
"" || !file_exists($fname)) {
437 $fname =
"./Customizing/global/skin/" .
442 if ($fname ==
"" || !file_exists($fname)) {
443 $fname =
"./" . $module_path .
"templates/default/" . basename($a_tplname);
445 } elseif (strpos($a_tplname,
"src/UI") === 0) {
446 if (class_exists(
"ilStyleDefinition")
450 $base_path =
"./Customizing/global/skin/";
451 $ui_path =
"/" . str_replace(
"src/UI/templates/default",
"UI", $a_tplname);
454 if (!file_exists($fname)) {
455 $fname = $base_path . $skin .
"/" . $ui_path;
459 if ($fname ==
"" || !file_exists($fname)) {
487 if (isset($DIC[
"ilCtrl"])) {
488 $ilCtrl = $DIC->ctrl();
494 if (!empty(
$_GET[
"baseClass"]) && $a_in_module ===
true) {
495 $a_in_module = $ilCtrl->getModuleDir();
498 if (strpos($a_tplname,
"/") ===
false) {
500 if ($a_in_module ===
true) {
503 $module_path = $a_in_module .
"/";
509 return $module_path . basename($a_tplname);
517 return (isset($this->blockvariables[
"content"][$a_variablename]) ?
true :
false);
getTemplatePath($a_tplname, $a_in_module=false, $a_plugin=false)
builds a full template path with template and module name
__construct(string $file, bool $flag1, bool $flag2, string $in_module="", string $vars="DEFAULT", bool $plugin=false, bool $a_use_cache=true)
constructor ilTemplate constructor.
addBlock($placeholder, $blockname, $template)
Adds a block to the template changing a variable placeholder to a block placeholder.
getUnmodified($part="DEFAULT")
getTemplateIdentifier($a_tplname, $a_in_module=false)
get a unique template identifier
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
free()
Clears all datafields of the object.
setVariable($variable, $value='')
Sets a variable value.
static getCurrentSkin()
get the current skin
touchBlock($block)
overwrites ITX::touchBlock.
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get Plugin Object.
addBlockFile($var, $block, $tplname, $in_module=false)
overwrites ITX::addBlockFile public
setCurrentBlock($part="DEFAULT")
Überladene Funktion, die sich hier lokal noch den aktuellen Block merkt.
parseCurrentBlock()
Parses the current block.
buildBlockvariablelist()
Build a list of all variables within of a block.
blockExists($a_blockname)
check if block exists in actual template private
__construct(Container $dic, ilPlugin $plugin)
setTemplate( $template, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Sets the template.
fillVars()
all template vars defined in $vars will be replaced automatically without setting and parsing them wi...
setOption($option, $value)
Sets the option for the template class.
static getCurrentStyle()
get the current style or sub style
variableExists($a_variablename)
findBlocks($string)
Recusively builds a list of all blocks within the template.
parseCurrentBlock($part="DEFAULT")
Überladene Funktion, die auf den aktuelle Block vorher noch ein replace ausführt public...
getFile($filename)
Reads a file from disk and returns its content.
buildFunctionlist()
Builds a functionlist from the template.