Location: PHPKode > projects > SithTemplate > SithTemplate-1.1/docs/html/_environment_8php_source.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>SithTemplate: Environment.php Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.2 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<h1>Environment.php</h1>  </div>
</div>
<div class="contents">
<a href="_environment_8php.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?php
<a name="l00198"></a><a class="code" href="class_template_environ.html">00198</a> <span class="keyword">class </span><a class="code" href="class_template_environ.html" title="Template environment - library&amp;#39;s end-user API.">TemplateEnviron</a> {
<a name="l00202"></a><a class="code" href="class_template_environ.html#a5b9029c41ea8dec7765f56b762a349d5">00202</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a5b9029c41ea8dec7765f56b762a349d5" title="One of recompilation modes - always recompile.">RECOMPILE_ALWAYS</a>     = 1;
<a name="l00206"></a><a class="code" href="class_template_environ.html#a78aacb9bf4a8ffd591bfb89e12f2637d">00206</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a78aacb9bf4a8ffd591bfb89e12f2637d" title="One of recompilation modes - recompile only when necessary (default).">RECOMPILE_IF_CHANGED</a> = 0;
<a name="l00210"></a><a class="code" href="class_template_environ.html#a9d912ae01fa388c0e04af9085327eda1">00210</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a9d912ae01fa388c0e04af9085327eda1" title="One of recompilation modes - never recompile (a.k.a.">RECOMPILE_NEVER</a>      = -1;
<a name="l00211"></a>00211  
<a name="l00215"></a><a class="code" href="class_template_environ.html#a5029fb8f59f467ed9b8cbc0586fcea9c">00215</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a5029fb8f59f467ed9b8cbc0586fcea9c" title="One of security modes - do not test against the lists.">SECURITY_DISABLE</a>     = 0;
<a name="l00219"></a><a class="code" href="class_template_environ.html#a6e3c4bc113cd6efc66cff819431ea0db">00219</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a6e3c4bc113cd6efc66cff819431ea0db" title="One of security modes - first allow all, then check &amp;#39;disallowed&amp;#39; list.">SECURITY_ALLOW_ALL</a>   = 1;
<a name="l00223"></a><a class="code" href="class_template_environ.html#a5dfd0bca9d3d50d7efcf2360d237d2c8">00223</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a5dfd0bca9d3d50d7efcf2360d237d2c8" title="One of security modes - first check &amp;#39;allowed&amp;#39; list, then &amp;#39;disallowed&amp;#39;.">SECURITY_ALLOW_DENY</a>  = 2;
<a name="l00227"></a><a class="code" href="class_template_environ.html#ab9c3628bda2698c4f4fd3bbd7d06b7f8">00227</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#ab9c3628bda2698c4f4fd3bbd7d06b7f8" title="One of security modes - first check &amp;#39;disallowed&amp;#39; list, then &amp;#39;allowed&amp;#39;.">SECURITY_DENY_ALLOW</a>  = 3;
<a name="l00231"></a><a class="code" href="class_template_environ.html#ae3f379fc7bd67ba77f1ad1ad998db3eb">00231</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#ae3f379fc7bd67ba77f1ad1ad998db3eb" title="One of security modes - first disallow all, then check &amp;#39;allowed&amp;#39; list.">SECURITY_DENY_ALL</a>    = 4;
<a name="l00232"></a>00232  
<a name="l00238"></a><a class="code" href="class_template_environ.html#ae42a4d9c0cd3c832af7121f75f11806a">00238</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#ae42a4d9c0cd3c832af7121f75f11806a" title="May be used instead of allowed or disallowed list, as a wildcard matching everything.">SECURITY_MATCH_EVERYTHING</a> = <span class="keyword">true</span>;
<a name="l00239"></a>00239  
<a name="l00244"></a><a class="code" href="class_template_environ.html#a0c4ef7d9a5ced3764fb32398fa6217af">00244</a>  <span class="keyword">const</span> <a class="code" href="class_template_environ.html#a0c4ef7d9a5ced3764fb32398fa6217af" title="May be used as loadPlugins setting to always load all available plugins on all search paths...">LOAD_ALL_PLUGINS</a> = <span class="keyword">true</span>;
<a name="l00245"></a>00245  
<a name="l00363"></a><a class="code" href="class_template_environ.html#a1a6916c9094781e70523b3ed7ba20b68">00363</a>  <span class="keyword">public</span> <a class="code" href="class_template_environ.html#a1a6916c9094781e70523b3ed7ba20b68" title="Default environment settings.">$settings</a> = array(
<a name="l00364"></a>00364   <span class="comment">// [Prefixes]</span>
<a name="l00365"></a>00365   <span class="stringliteral">&#39;inputPrefix&#39;</span>            =&gt; <span class="stringliteral">&#39;./templates/&#39;</span>,
<a name="l00366"></a>00366   <span class="stringliteral">&#39;outputPrefix&#39;</span>           =&gt; <span class="stringliteral">&#39;./templates_c/&#39;</span>,
<a name="l00367"></a>00367   
<a name="l00368"></a>00368   <span class="comment">// [Plugins]</span>
<a name="l00369"></a>00369   <span class="stringliteral">&#39;loadPlugins&#39;</span>            =&gt; self::LOAD_ALL_PLUGINS,
<a name="l00370"></a>00370   <span class="stringliteral">&#39;pluginsPaths&#39;</span>           =&gt; array(),
<a name="l00371"></a>00371   <span class="stringliteral">&#39;useDefaultPluginsPath&#39;</span>  =&gt; <span class="keyword">true</span>,
<a name="l00372"></a>00372   
<a name="l00373"></a>00373   <span class="comment">// [Compilation]</span>
<a name="l00374"></a>00374   <span class="stringliteral">&#39;recompilationMode&#39;</span>      =&gt; self::RECOMPILE_IF_CHANGED,
<a name="l00375"></a>00375   <span class="stringliteral">&#39;defaultIODriver&#39;</span>        =&gt; <span class="stringliteral">&#39;file&#39;</span>,
<a name="l00376"></a>00376   
<a name="l00377"></a>00377   <span class="comment">// [Security]</span>
<a name="l00378"></a>00378   <span class="stringliteral">&#39;autoEscape&#39;</span>             =&gt; <span class="keyword">false</span>,
<a name="l00379"></a>00379   <span class="stringliteral">&#39;allowInternalRequest&#39;</span>   =&gt; <span class="keyword">true</span>,
<a name="l00380"></a>00380   <span class="stringliteral">&#39;allowInternalConstants&#39;</span> =&gt; <span class="keyword">true</span>,
<a name="l00381"></a>00381   <span class="stringliteral">&#39;restrictIncludeIO&#39;</span>      =&gt; <span class="keyword">false</span>,
<a name="l00382"></a>00382   <span class="stringliteral">&#39;restrictExtendIO&#39;</span>       =&gt; <span class="keyword">false</span>,
<a name="l00383"></a>00383   
<a name="l00384"></a>00384   <span class="comment">// [Security Lists]</span>
<a name="l00385"></a>00385   <span class="stringliteral">&#39;securityEvalMode&#39;</span>       =&gt; self::SECURITY_DISABLE,
<a name="l00386"></a>00386   <span class="stringliteral">&#39;allowedPlugins&#39;</span>         =&gt; self::SECURITY_MATCH_EVERYTHING,
<a name="l00387"></a>00387   <span class="stringliteral">&#39;disallowedPlugins&#39;</span>      =&gt; array(),
<a name="l00388"></a>00388   <span class="stringliteral">&#39;allowedTags&#39;</span>            =&gt; self::SECURITY_MATCH_EVERYTHING,
<a name="l00389"></a>00389   <span class="stringliteral">&#39;disallowedTags&#39;</span>         =&gt; array(),
<a name="l00390"></a>00390   <span class="stringliteral">&#39;allowedFilters&#39;</span>         =&gt; self::SECURITY_MATCH_EVERYTHING,
<a name="l00391"></a>00391   <span class="stringliteral">&#39;disallowedFilters&#39;</span>      =&gt; array(),
<a name="l00392"></a>00392   <span class="stringliteral">&#39;allowedFunctions&#39;</span>       =&gt; self::SECURITY_MATCH_EVERYTHING,
<a name="l00393"></a>00393   <span class="stringliteral">&#39;disallowedFunctions&#39;</span>    =&gt; array(),
<a name="l00394"></a>00394  );
<a name="l00395"></a>00395  
<a name="l00399"></a><a class="code" href="class_template_environ.html#a5938e33eabf69f562786fd45c6488d1b">00399</a>  <span class="keyword">public</span> <a class="code" href="class_template_environ.html#a5938e33eabf69f562786fd45c6488d1b" title="Internal template objects cache.">$templateCache</a> = array();
<a name="l00400"></a>00400  
<a name="l00404"></a><a class="code" href="class_template_environ.html#a87e53363d52c31747335d98c93eab978">00404</a>  <span class="keyword">public</span> <a class="code" href="class_template_environ.html#a87e53363d52c31747335d98c93eab978" title="Compiler instance.">$compiler</a> = null;
<a name="l00405"></a>00405  
<a name="l00412"></a><a class="code" href="class_template_environ.html#a873058cdbe887d87f8a1b4d235e7a35a">00412</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#a873058cdbe887d87f8a1b4d235e7a35a" title="Constructor.">__construct</a>(array <a class="code" href="class_template_environ.html#a1a6916c9094781e70523b3ed7ba20b68" title="Default environment settings.">$settings</a> = array()) {
<a name="l00413"></a>00413   $this-&gt;settings = array_merge($this-&gt;settings, <a class="code" href="class_template_environ.html#a1a6916c9094781e70523b3ed7ba20b68" title="Default environment settings.">$settings</a>);
<a name="l00414"></a>00414   <span class="keywordflow">if</span> ($this-&gt;settings[<span class="stringliteral">&#39;useDefaultPluginsPath&#39;</span>]) {
<a name="l00415"></a>00415    $this-&gt;settings[<span class="stringliteral">&#39;pluginsPaths&#39;</span>][] = SITHTEMPLATE_DIR.<span class="stringliteral">&#39;plugins/&#39;</span>;
<a name="l00416"></a>00416   }
<a name="l00417"></a>00417  }
<a name="l00418"></a>00418  
<a name="l00426"></a><a class="code" href="class_template_environ.html#a9b30f6017bfdf15e9c0234d52ecf5a8d">00426</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_environ.html#a9b30f6017bfdf15e9c0234d52ecf5a8d" title="Named constructor.">createFromINI</a>($settingsINI) {
<a name="l00427"></a>00427   <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_template_environ.html" title="Template environment - library&amp;#39;s end-user API.">TemplateEnviron</a>(parse_ini_file($settingsINI));
<a name="l00428"></a>00428  }
<a name="l00429"></a>00429  
<a name="l00438"></a><a class="code" href="class_template_environ.html#a77902cf744027639a5d6a87acd054cbc">00438</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#a77902cf744027639a5d6a87acd054cbc" title="Compile given template.">compile</a>(<a class="code" href="interface_i_template_i_o_driver.html" title="Interface required for all I/O drivers.">ITemplateIODriver</a> $io, $template) {
<a name="l00439"></a>00439   <span class="keywordflow">if</span> (!$this-&gt;compiler) {
<a name="l00440"></a>00440    $this-&gt;compiler           = <span class="keyword">new</span> <a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a>;
<a name="l00441"></a>00441    $this-&gt;compiler-&gt;settings = &amp;$this-&gt;settings;
<a name="l00442"></a>00442   }
<a name="l00443"></a>00443   
<a name="l00444"></a>00444   $this-&gt;compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a13570ae4a6d834431eeb3c84a5051ac3" title="Compiles given template into output package.">compile</a>($io, $template);
<a name="l00445"></a>00445  }
<a name="l00446"></a>00446  
<a name="l00458"></a><a class="code" href="class_template_environ.html#ad0960ce6c608f4f3b7fbba321cec3a9e">00458</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#ad0960ce6c608f4f3b7fbba321cec3a9e" title="Includes template&amp;#39;s code into global namespace via I/O driver given in DSN.">include_</a>($template, $mode = null, $returnMeta = <span class="keyword">false</span>) {
<a name="l00459"></a>00459   <span class="keywordflow">if</span> (!$mode) $mode = $this-&gt;settings[<span class="stringliteral">&#39;recompilationMode&#39;</span>];
<a name="l00460"></a>00460   list($io, $template) = <a class="code" href="class_template_utils.html#a3c4884dc20fe80e13a23f36f09663220" title="Splits I/O DSN, and creates correct driver object.">TemplateUtils::parseIODSN</a>($this-&gt;settings, $template);
<a name="l00461"></a>00461 
<a name="l00462"></a>00462   <span class="keywordflow">if</span> (!$io-&gt;upToDate($this-&gt;settings, $template, $mode)) {
<a name="l00463"></a>00463    $this-&gt;<a class="code" href="class_template_environ.html#a77902cf744027639a5d6a87acd054cbc" title="Compile given template.">compile</a>($io, $template);
<a name="l00464"></a>00464   }
<a name="l00465"></a>00465   
<a name="l00466"></a>00466   $metadata = $io-&gt;loadMetadata($this-&gt;settings, $template);
<a name="l00467"></a>00467   <span class="keywordflow">if</span> ($returnMeta) <span class="keywordflow">return</span> $metadata;
<a name="l00468"></a>00468   
<a name="l00469"></a>00469   <span class="keywordflow">if</span> (is_array($metadata) &amp;&amp; isset($metadata[<span class="stringliteral">&#39;parentTemplate&#39;</span>])) {
<a name="l00470"></a>00470    $this-&gt;<a class="code" href="class_template_environ.html#ad0960ce6c608f4f3b7fbba321cec3a9e" title="Includes template&amp;#39;s code into global namespace via I/O driver given in DSN.">include_</a>($metadata[<span class="stringliteral">&#39;parentTemplate&#39;</span>], $mode);
<a name="l00471"></a>00471   }
<a name="l00472"></a>00472   
<a name="l00473"></a>00473   <span class="keywordflow">return</span> $io-&gt;includeCode($this-&gt;settings, $template);
<a name="l00474"></a>00474  }
<a name="l00475"></a>00475  
<a name="l00487"></a><a class="code" href="class_template_environ.html#a83a8ca46797584a7a175198532b220e7">00487</a>  <span class="keyword">public</span> function <span class="keyword">get</span>($template, $mode = null) {
<a name="l00488"></a>00488   $className = $this-&gt;<a class="code" href="class_template_environ.html#ad0960ce6c608f4f3b7fbba321cec3a9e" title="Includes template&amp;#39;s code into global namespace via I/O driver given in DSN.">include_</a>($template, $mode);
<a name="l00489"></a>00489   <span class="keywordflow">return</span> <span class="keyword">new</span> $className;
<a name="l00490"></a>00490  }
<a name="l00491"></a>00491  
<a name="l00501"></a><a class="code" href="class_template_environ.html#a132df401c128e10eafa3a5e923622964">00501</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#a132df401c128e10eafa3a5e923622964" title="Returns user-defined template metadata.">getMeta</a>($template, $mode = null) {
<a name="l00502"></a>00502   $metadata = $this-&gt;<a class="code" href="class_template_environ.html#ad0960ce6c608f4f3b7fbba321cec3a9e" title="Includes template&amp;#39;s code into global namespace via I/O driver given in DSN.">include_</a>($template, $mode, <span class="keyword">true</span>);
<a name="l00503"></a>00503   $userMeta = array();
<a name="l00504"></a>00504   
<a name="l00505"></a>00505   <span class="keywordflow">foreach</span> ($metadata as $var =&gt; &amp;$value) {
<a name="l00506"></a>00506    <span class="keywordflow">if</span> (mb_substr($var, 0, 5) == <span class="stringliteral">&#39;user:&#39;</span>) {
<a name="l00507"></a>00507     $userMeta[mb_substr($var, 5)] = $value;
<a name="l00508"></a>00508    }
<a name="l00509"></a>00509   }
<a name="l00510"></a>00510   
<a name="l00511"></a>00511   <span class="keywordflow">return</span> $userMeta;
<a name="l00512"></a>00512  }
<a name="l00513"></a>00513  
<a name="l00522"></a><a class="code" href="class_template_environ.html#a5387aedb93a098eb199e94fdab8bc92f">00522</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#a5387aedb93a098eb199e94fdab8bc92f" title="Cached version of TemplateEnviron::get.">cachedGet</a>($template, $mode = null) {
<a name="l00523"></a>00523   <span class="keywordflow">if</span> (!isset($this-&gt;templateCache[$template])) {
<a name="l00524"></a>00524    $this-&gt;templateCache[$template] = $this-&gt;<span class="keyword">get</span>($template, $mode);
<a name="l00525"></a>00525   }
<a name="l00526"></a>00526   <span class="keywordflow">return</span> $this-&gt;templateCache[$template];
<a name="l00527"></a>00527  }
<a name="l00528"></a>00528  
<a name="l00538"></a><a class="code" href="class_template_environ.html#a564c04dff7b3d6d026ae07adf64dc8b2">00538</a>  <span class="keyword">public</span> function <a class="code" href="class_template_environ.html#a564c04dff7b3d6d026ae07adf64dc8b2" title="Render the template directly.">render</a>($template, array $context, $mode = null) {
<a name="l00539"></a>00539   <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_template_environ.html#a5387aedb93a098eb199e94fdab8bc92f" title="Cached version of TemplateEnviron::get.">cachedGet</a>($template, $mode)-&gt;render($context, $this);
<a name="l00540"></a>00540  }
<a name="l00541"></a>00541 }
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Fri Jan 14 2011 20:08:37 for SithTemplate by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
Return current item: SithTemplate