ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilIndependentTemplate.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
5require_once("libs/composer/vendor/autoload.php");
6
7// Do the require-dance for ilTemplate.
8require_once("./Services/UICore/lib/html-it/IT.php");
9require_once("./Services/UICore/lib/html-it/ITX.php");
10require_once("./Services/UICore/classes/class.ilTemplate.php");
11
22 public function getFile($filename)
23 {
24 if ($filename{0} == '/' && substr($this->fileRoot, -1) == '/') {
25 $filename = substr($filename, 1);
26 }
27
28 $filename = $this->fileRoot . $filename;
29
30 require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
31 $this->real_filename = $filename;
32
33 if (!($fh = @fopen($filename, 'r'))) {
34 $this->err[] = PEAR::raiseError(
36 ': "' .$filename .'"',
38 );
39 return "";
40 }
41
42 $fsize = filesize($filename);
43 if ($fsize < 1) {
44 fclose($fh);
45 return '';
46 }
47
48 $content = fread($fh, $fsize);
49 fclose($fh);
50
51 return preg_replace_callback(
52 "#<!-- INCLUDE (.*) -->#im",
53 function ($hit) {
54 return $this->getFile($hit[1]);
55 },
56 $content
57 );
58 } // end func getFile
59
73 public function loadTemplatefile( $filename,
75 $removeEmptyBlocks = true )
76 {
78 }
79
80 // Small adjustment to fit \ILIAS\UI\Implementation\Template and call to
81 public function get($block = null) {
82 if ($block === null) {
83 $block = "__global__";
84 }
85 if ($block == '__global__' && !$this->flagGlobalParsed) {
86 $this->parse('__global__');
87 }
88
89 if (!isset($this->blocklist[$block])) {
91 '"' . $block . "'"));
92 }
93
94 if (isset($this->blockdata[$block])) {
95 $ret = $this->blockdata[$block];
96 if ($this->clearCache) {
97 unset($this->blockdata[$block]);
98 }
99 if ($this->_options['preserve_data']) {
100 $ret = str_replace(
101 $this->openingDelimiter .
102 '%preserved%' . $this->closingDelimiter,
103 $this->openingDelimiter,
104 $ret
105 );
106 }
107 return $ret;
108 }
109
110 return '';
111 }
112}
const IT_TPL_NOT_FOUND
Definition: IT.php:25
const IT_BLOCK_NOT_FOUND
Definition: IT.php:26
An exception for terminatinating execution or to throw for unit testing.
$removeEmptyBlocks
Definition: IT.php:202
$removeUnknownVariables
Definition: IT.php:195
errorMessage($value, $blockname='')
Return a textual error message for a IT error code.
Definition: IT.php:981
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
Definition: IT.php:776
parse($block='__global__', $flag_recursion=false)
Parses the given block.
Definition: IT.php:485
& raiseError($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
This method is a wrapper that returns an instance of the configured error class with this object's de...
Definition: PEAR.php:522
getFile($filename)
Reads a file from disk and returns its content.
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
special template class to simplify handling of ITX/PEAR
Interface to templating as it is used in the UI framework.
Definition: Template.php:13
$ret
Definition: parser.php:6