ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
5 require_once("libs/composer/vendor/autoload.php");
6 
7 // Do the require-dance for ilTemplate.
8 require_once("./Services/UICore/lib/html-it/IT.php");
9 require_once("./Services/UICore/lib/html-it/ITX.php");
10 require_once("./Services/UICore/classes/class.ilTemplate.php");
11 
13 {
14  // This makes PHP happy, baseclass needs that
15  protected $blockparents = null;
16 
17  public function __construct(
18  $file,
19  $flag1,
20  $flag2,
21  $in_module = false,
22  $vars = "DEFAULT",
23  $plugin = false,
24  $a_use_cache = true
25  ) {
26  parent::__construct($file, $flag1, $flag2, $in_module, $vars, $plugin, false);
27  }
28 
38  public function getFile($filename)
39  {
40  if ($filename[0] == '/' && substr($this->fileRoot, -1) == '/') {
41  $filename = substr($filename, 1);
42  }
43 
44  $filename = $this->fileRoot . $filename;
45 
46  require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
47  $this->real_filename = $filename;
48 
49  if (!($fh = @fopen($filename, 'r'))) {
50  $this->err[] = PEAR::raiseError(
52  ': "' . $filename . '"',
54  );
55  return "";
56  }
57 
58  $fsize = filesize($filename);
59  if ($fsize < 1) {
60  fclose($fh);
61  return '';
62  }
63 
64  $content = fread($fh, $fsize);
65  fclose($fh);
66 
67  return preg_replace_callback(
68  "#<!-- INCLUDE (.*) -->#im",
69  function ($hit) {
70  return $this->getFile($hit[1]);
71  },
72  $content
73  );
74  } // end func getFile
75 
89  public function loadTemplatefile(
90  $filename,
92  $removeEmptyBlocks = true
93  ) {
95  }
96 
97  // Small adjustment to fit \ILIAS\UI\Implementation\Template and call to
98  public function get(
99  $part = null,
100  $add_error_mess = false,
101  $handle_referer = false,
102  $add_ilias_footer = false,
103  $add_standard_elements = false,
104  $a_main_menu = true,
105  $a_tabs = true
106  ) {
107  if ($part === null) {
108  $part = "__global__";
109  }
110  if ($part == '__global__' && !$this->flagGlobalParsed) {
111  $this->parse('__global__');
112  }
113 
114  if (!isset($this->blocklist[$part])) {
116  '"' . $block . "'"));
117  }
118 
119  if (isset($this->blockdata[$part])) {
120  $ret = $this->blockdata[$part];
121  if ($this->clearCache) {
122  unset($this->blockdata[$part]);
123  }
124  if ($this->_options['preserve_data']) {
125  $ret = str_replace(
126  $this->openingDelimiter .
127  '%preserved%' . $this->closingDelimiter,
128  $this->openingDelimiter,
129  $ret
130  );
131  }
132  return $ret;
133  }
134 
135  return '';
136  }
137 }
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
Definition: IT.php:778
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
errorMessage($value, $blockname='')
Return a textual error message for a IT error code.
Definition: IT.php:991
Interface to templating as it is used in the UI framework.
Definition: Template.php:13
$removeUnknownVariables
Definition: IT.php:195
const IT_BLOCK_NOT_FOUND
Definition: IT.php:26
special template class to simplify handling of ITX/PEAR
getFile($filename)
Reads a file from disk and returns its content.
parse($block='__global__', $flag_recursion=false)
Parses the given block.
Definition: IT.php:485
$filename
Definition: buildRTE.php:89
$removeEmptyBlocks
Definition: IT.php:202
& 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&#39;s de...
Definition: PEAR.php:522
$ret
Definition: parser.php:6
__construct( $file, $flag1, $flag2, $in_module=false, $vars="DEFAULT", $plugin=false, $a_use_cache=true)
const IT_TPL_NOT_FOUND
Definition: IT.php:25