/usr/share/php/Nette/Latte/Template.php is in php-nette 2.3.8-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | <?php
/**
* This file is part of the Latte (https://latte.nette.org)
* Copyright (c) 2008 David Grudl (https://davidgrudl.com)
*/
namespace Latte;
/**
* Template.
* @internal
*/
class Template extends Object
{
/** @var Engine */
private $engine;
/** @var string */
private $name;
/** @var array */
protected $params = array();
public function __construct(array $params, Engine $engine, $name)
{
$this->setParameters($params);
$this->engine = $engine;
$this->name = $name;
}
/**
* @return Engine
*/
public function getEngine()
{
return $this->engine;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Initializes block, global & local storage in template.
* @return [\stdClass, \stdClass, \stdClass]
* @internal
*/
public function initialize($templateId, $contentType)
{
Runtime\Filters::$xhtml = (bool) preg_match('#xml|xhtml#', $contentType);
// local storage
$this->params['_l'] = new \stdClass;
// block storage
if (isset($this->params['_b'])) {
$block = $this->params['_b'];
unset($this->params['_b']);
} else {
$block = new \stdClass;
}
$block->templates[$templateId] = $this;
// global storage
if (!isset($this->params['_g'])) {
$this->params['_g'] = new \stdClass;
}
return array($block, $this->params['_g'], $this->params['_l']);
}
/**
* Renders template.
* @return void
* @internal
*/
public function renderChildTemplate($name, array $params = array())
{
$name = $this->engine->getLoader()->getChildName($name, $this->name);
$this->engine->render($name, $params);
}
/**
* Call a template run-time filter. Do not call directly.
* @param string filter name
* @param array arguments
* @return mixed
*/
public function __call($name, $args)
{
return $this->engine->invokeFilter($name, $args);
}
/********************* template parameters ****************d*g**/
/**
* Sets all parameters.
* @param array
* @return self
*/
public function setParameters(array $params)
{
$this->params = $params;
$this->params['template'] = $this;
return $this;
}
/**
* Returns array of all parameters.
* @return array
*/
public function getParameters()
{
return $this->params;
}
/**
* Sets a template parameter. Do not call directly.
* @return void
*/
public function __set($name, $value)
{
$this->params[$name] = $value;
}
/**
* Returns a template parameter. Do not call directly.
* @return mixed value
*/
public function &__get($name)
{
if (!array_key_exists($name, $this->params)) {
trigger_error("The variable '$name' does not exist in template.", E_USER_NOTICE);
}
return $this->params[$name];
}
/**
* Determines whether parameter is defined. Do not call directly.
* @return bool
*/
public function __isset($name)
{
return isset($this->params[$name]);
}
/**
* Removes a template parameter. Do not call directly.
* @param string name
* @return void
*/
public function __unset($name)
{
unset($this->params[$name]);
}
}
|