ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
13{
14 public function __construct(
15 $file,
16 $flag1,
17 $flag2,
18 $in_module = false,
19 $vars = "DEFAULT",
20 $plugin = false,
21 $a_use_cache = true
22 ) {
23 parent::__construct($file, $flag1, $flag2, $in_module, $vars, $plugin, false);
24 }
25
35 public function getFile($filename)
36 {
37 if ($filename{0} == '/' && substr($this->fileRoot, -1) == '/') {
38 $filename = substr($filename, 1);
39 }
40
41 $filename = $this->fileRoot . $filename;
42
43 require_once('./Services/GlobalCache/classes/class.ilGlobalCache.php');
44 $this->real_filename = $filename;
45
46 if (!($fh = @fopen($filename, 'r'))) {
47 $this->err[] = PEAR::raiseError(
49 ': "' . $filename . '"',
51 );
52 return "";
53 }
54
55 $fsize = filesize($filename);
56 if ($fsize < 1) {
57 fclose($fh);
58 return '';
59 }
60
61 $content = fread($fh, $fsize);
62 fclose($fh);
63
64 return preg_replace_callback(
65 "#<!-- INCLUDE (.*) -->#im",
66 function ($hit) {
67 return $this->getFile($hit[1]);
68 },
69 $content
70 );
71 } // end func getFile
72
86 public function loadTemplatefile(
90 ) {
92 }
93
94 // Small adjustment to fit \ILIAS\UI\Implementation\Template and call to
95 public function get($block = null)
96 {
97 if ($block === null) {
98 $block = "__global__";
99 }
100 if ($block == '__global__' && !$this->flagGlobalParsed) {
101 $this->parse('__global__');
102 }
103
104 if (!isset($this->blocklist[$block])) {
106 '"' . $block . "'"));
107 }
108
109 if (isset($this->blockdata[$block])) {
110 $ret = $this->blockdata[$block];
111 if ($this->clearCache) {
112 unset($this->blockdata[$block]);
113 }
114 if ($this->_options['preserve_data']) {
115 $ret = str_replace(
116 $this->openingDelimiter .
117 '%preserved%' . $this->closingDelimiter,
118 $this->openingDelimiter,
119 $ret
120 );
121 }
122 return $ret;
123 }
124
125 return '';
126 }
127}
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:991
loadTemplatefile( $filename, $removeUnknownVariables=true, $removeEmptyBlocks=true)
Reads a template file from the disk.
Definition: IT.php:778
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.
__construct( $file, $flag1, $flag2, $in_module=false, $vars="DEFAULT", $plugin=false, $a_use_cache=true)
constructor
special template class to simplify handling of ITX/PEAR
Interface to templating as it is used in the UI framework.
Definition: Template.php:14
$ret
Definition: parser.php:6
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file