3declare(strict_types=1);
7require_once __DIR__ .
'/../lib/html-it/IT.php';
8require_once __DIR__ .
'/../lib/html-it/ITX.php';
58 string $in_module =
"",
61 bool $a_use_cache =
true
64 $this->il_use_cache = $a_use_cache;
65 $this->il_cur_key = $file .
"/" . $in_module;
68 if (!file_exists($fname)) {
72 $this->tplName = basename($fname);
73 $this->tplPath = dirname($fname);
83 protected function init(): void
89 if ($this->il_use_cache &&
90 isset(self::$il_cache[$this->il_cur_key]) &&
91 is_array(self::$il_cache[$this->il_cur_key])
106 if ($this->il_use_cache) {
118 $this->
template =
'';
126 isset($this->blockvariables[
"content"][$a_blockname]) ||
127 isset($this->blockvariables[$a_blockname]);
135 $component_factory =
$DIC[
"component.factory"];
136 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
137 $gui_class = $ui_plugin->getUIClassInstance();
138 $resp = $gui_class->getHTML(
142 "tpl_id" => $this->tplIdentifier,
149 $html = $gui_class->modifyHTML($html,
$resp);
179 $this->activeBlock = $part;
180 return parent::setCurrentBlock($part);
193 return parent::touchBlock($block);
207 return parent::parseCurrentBlock();
210 public function addBlockFile(
string $var,
string $block,
string $tplname,
string $in_module =
null): bool
215 echo
"<br/>Template '" . $this->tplPath .
"/" . $tplname .
"'";
219 if (file_exists($tplfile) ===
false) {
220 echo
"<br/>Template '" . $tplfile .
"' doesn't exist! aborting...";
226 $component_factory =
$DIC[
"component.factory"];
227 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
228 $gui_class = $ui_plugin->getUIClassInstance();
229 $resp = $gui_class->getHTML(
254 foreach ($this->vars as
$key => $val) {
255 if (is_array($this->blockvariables[$this->activeBlock]) &&
256 array_key_exists(
$key, $this->blockvariables[$this->activeBlock])
274 if (!$this->flagCacheTemplatefile ||
281 $component_factory =
$DIC[
"component.factory"];
282 foreach ($component_factory->getActivePluginsInSlot(
"uihk") as $ui_plugin) {
283 $gui_class = $ui_plugin->getUIClassInstance();
284 $resp = $gui_class->getHTML(
288 "tpl_id" => $this->tplIdentifier,
311 protected function getTemplatePath(
string $a_tplname,
string $a_in_module =
null): string
314 if (strpos($a_tplname,
"/") ===
false) {
317 if ($a_in_module !==
"") {
318 $module_path = $a_in_module .
"/";
325 $fname =
"./Customizing/global/skin/" .
327 . basename($a_tplname);
329 if ($fname ===
"" || !file_exists($fname)) {
330 $fname =
"./Customizing/global/skin/" .
335 if ($fname ===
"" || !file_exists($fname)) {
336 $fname =
"./" . $module_path .
"templates/default/" . basename($a_tplname);
338 } elseif (strpos($a_tplname,
"src/UI") === 0) {
339 if (class_exists(
"ilStyleDefinition")
343 $base_path =
"./Customizing/global/skin/";
344 $ui_path =
"/" . str_replace(
"src/UI/templates/default",
"UI", $a_tplname);
347 if (!file_exists($fname)) {
348 $fname = $base_path . $skin .
"/" . $ui_path;
352 if ($fname ==
"" || !file_exists($fname)) {
369 if (strpos($a_tplname,
"/") ===
false) {
370 if (
null !== $a_in_module) {
371 $module_path = $a_in_module .
"/";
376 return $module_path . basename($a_tplname);
384 return isset($this->blockvariables[
"content"][$a_variablename]);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Integrated Template Extension - ITX With this class you get the full power of the phplib template cla...
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.
free()
Clears all datafields of the object.
buildBlockvariablelist()
Build a list of all variables within of a block.
array $blockparents
Array of block parents.
bool $removeEmptyBlocks
Controls the handling of empty blocks, default is remove.
setOption(string $option, $value)
Sets the option for the template class.
array $blockinner
Array of inner blocks of a block.
string $template
Content of the template.
findBlocks(string $string)
Recusively builds a list of all blocks within the template.
array $blockdata
Array with the parsed content of a block.
getFile(string $filename)
Reads a file from disk and returns its content.
parseCurrentBlock()
Parses the current block.
setTemplate(string $template, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Sets the template.
array $blocklist
Array of all blocks and their content.
array $err
Contains the error objects.
array $blockvariables
Array of variables in a block.
setVariable($variable, $value='')
Sets a variable value.
bool $flagBlocktrouble
Internal flag indicating that a blockname was used multiple times.
bool $removeUnknownVariables
Controls the handling of unknown variables, default is remove.
static getCurrentSkin()
get the current skin use always this function instead of getting the account's skin the current skin ...
static getCurrentStyle()
get the current style or sub style use always this function instead of getting the account's style th...
special template class to simplify handling of ITX/PEAR
variableExists(string $a_variablename)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
init()
Clears all datafields of the object and rebuild the internal blocklist LoadTemplatefile() and setTemp...
addBlockFile(string $var, string $block, string $tplname, string $in_module=null)
__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.
string $activeBlock
Aktueller Block Der wird gemerkt bei der berladenen Funktion setCurrentBlock, damit beim ParseBlock v...
blockExists(string $a_blockname)
Checks wheter a block exists.
fillVars()
all template vars defined in $vars will be replaced automatically without setting and parsing them wi...
getTemplatePath(string $a_tplname, string $a_in_module=null)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
loadTemplatefile(string $filename, bool $removeUnknownVariables=true, bool $removeEmptyBlocks=true)
Reads a template file from the disk.
array $vars
variablen die immer in jedem block ersetzt werden sollen
getUnmodified(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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...
touchBlock(string $block)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
get(string $key, Refinery\Transformation $t)
Get passed parameter, if not data passed, get key from http request.