3 declare(strict_types=1);
21 require_once __DIR__ .
'/../lib/html-it/IT.php';
22 require_once __DIR__ .
'/../lib/html-it/ITX.php';
72 string $in_module =
"",
75 bool $a_use_cache =
true 78 $this->il_use_cache = $a_use_cache;
79 $this->il_cur_key = $file .
"/" . $in_module;
82 if (!file_exists($fname)) {
86 $this->tplName = basename($fname);
87 $this->tplPath = dirname($fname);
97 protected function init(): void
103 if ($this->il_use_cache &&
104 isset(self::$il_cache[$this->il_cur_key]) &&
105 is_array(self::$il_cache[$this->il_cur_key])
109 $this->flagBlocktrouble = self::$il_cache[
$this->il_cur_key][
"flagBlocktrouble"];
120 if ($this->il_use_cache) {
132 $this->
template =
'';
140 isset($this->blockvariables[
"content"][$a_blockname]) ||
141 isset($this->blockvariables[$a_blockname]);
149 $component_factory = $DIC[
"component.factory"];
150 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
151 $gui_class = $ui_plugin->getUIClassInstance();
152 $resp = $gui_class->getHTML(
156 "tpl_id" => $this->tplIdentifier,
163 $html = $gui_class->modifyHTML($html,
$resp);
177 $part = self::IT_DEFAULT_BLOCK;
190 $part = self::IT_DEFAULT_BLOCK;
193 $this->activeBlock = $part;
194 return parent::setCurrentBlock($part);
207 return parent::touchBlock($block);
219 $this->activeBlock = self::IT_DEFAULT_BLOCK;
221 return parent::parseCurrentBlock();
224 public function addBlockFile(
string $var,
string $block,
string $tplname,
string $in_module = null): bool
229 if (file_exists($tplfile) ===
false) {
230 echo
"<br/>Template '" . $tplfile .
"' doesn't exist! aborting...";
236 $component_factory = $DIC[
"component.factory"];
237 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
238 $gui_class = $ui_plugin->getUIClassInstance();
239 $resp = $gui_class->getHTML(
264 foreach ($this->vars as
$key => $val) {
265 if (is_array($this->blockvariables[$this->activeBlock]) &&
266 array_key_exists(
$key, $this->blockvariables[$this->activeBlock])
284 if (!$this->flagCacheTemplatefile ||
285 $this->lastTemplatefile !== $filename
291 $component_factory = $DIC[
"component.factory"];
292 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
293 $gui_class = $ui_plugin->getUIClassInstance();
294 $resp = $gui_class->getHTML(
298 "tpl_id" => $this->tplIdentifier,
321 protected function getTemplatePath(
string $a_tplname,
string $a_in_module = null): string
324 if (strpos($a_tplname,
"/") ===
false) {
327 if ($a_in_module !==
"") {
328 $module_path = $a_in_module .
"/";
335 $fname =
"./Customizing/global/skin/" .
337 . basename($a_tplname);
339 if ($fname ===
"" || !file_exists($fname)) {
340 $fname =
"./Customizing/global/skin/" .
345 if ($fname ===
"" || !file_exists($fname)) {
346 $fname =
"./" . $module_path .
"templates/default/" . basename($a_tplname);
348 } elseif (strpos($a_tplname,
"src/UI") === 0) {
349 if (class_exists(
"ilStyleDefinition")
353 $base_path =
"./Customizing/global/skin/";
354 $ui_path =
"/" . str_replace(
"src/UI/templates/default",
"UI", $a_tplname);
357 if (!file_exists($fname)) {
358 $fname = $base_path . $skin .
"/" . $ui_path;
362 if ($fname ==
"" || !file_exists($fname)) {
379 if (strpos($a_tplname,
"/") ===
false) {
380 if (null !== $a_in_module) {
381 $module_path = $a_in_module .
"/";
386 return $module_path . basename($a_tplname);
394 return isset($this->blockvariables[
"content"][$a_variablename]);
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
string $template
Content of the template.
array $blockparents
Array of block parents.
array $blockvariables
Array of variables in a block.
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
getUnmodified(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
bool $flagBlocktrouble
Internal flag indicating that a blockname was used multiple times.
getTemplatePath(string $a_tplname, string $a_in_module=null)
Integrated Template Extension - ITX With this class you get the full power of the phplib template cla...
string $activeBlock
Aktueller Block Der wird gemerkt bei der berladenen Funktion setCurrentBlock, damit beim ParseBlock v...
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
free()
Clears all datafields of the object.
setOption(string $option, $value)
Sets the option for the template class.
touchBlock(string $block)
setVariable($variable, $value='')
Sets a variable value.
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
getFile(string $filename)
Reads a file from disk and returns its content.
blockExists(string $a_blockname)
getTemplateIdentifier(string $a_tplname, string $a_in_module=null)
get a unique template identifier The identifier is common for default or customized skins but distinc...
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.
variableExists(string $a_variablename)
parseCurrentBlock()
Parses the current block.
buildBlockvariablelist()
Build a list of all variables within of a block.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
fillVars()
all template vars defined in $vars will be replaced automatically without setting and parsing them wi...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...
array $blockinner
Array of inner blocks of a block.
array $err
Contains the error objects.
array $blockdata
Array with the parsed content of a block.
__construct(string $file, bool $flag1, bool $flag2, string $in_module="", string $vars=ilGlobalTemplateInterface::DEFAULT_BLOCK, bool $plugin=false, bool $a_use_cache=true)
constructor ilTemplate constructor.
array $vars
variablen die immer in jedem block ersetzt werden sollen
array $blocklist
Array of all blocks and their content.
addBlock(string $placeholder, string $blockname, string $template)
Adds a block to the template changing a variable placeholder to a block placeholder.
buildFunctionlist()
Builds a functionlist from the template.
addBlockFile(string $var, string $block, string $tplname, string $in_module=null)