Location: PHPKode > projects > SithTemplate > SithTemplate-1.1/docs/html/_utils_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: Utils.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>Utils.php</h1>  </div>
</div>
<div class="contents">
<a href="_utils_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="l00012"></a><a class="code" href="class_template_utils.html">00012</a> <span class="keyword">class </span><a class="code" href="class_template_utils.html" title="Namespace-acting all-static class.">TemplateUtils</a> {
<a name="l00019"></a><a class="code" href="class_template_utils.html#aa3553ef2c1e54e0e99ad38a7fe931efa">00019</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#aa3553ef2c1e54e0e99ad38a7fe931efa" title="Escape string to use in template class.">escape</a>($str) {
<a name="l00020"></a>00020   $str = str_replace(<span class="charliteral">&#39;\&#39;&#39;</span>, <span class="stringliteral">&#39;\\\&#39;&#39;</span>, $str);
<a name="l00021"></a>00021   $str = str_replace(
<a name="l00022"></a>00022    array(<span class="stringliteral">&quot;\n&quot;</span>, <span class="stringliteral">&quot;\r&quot;</span>, <span class="stringliteral">&quot;\t&quot;</span>),
<a name="l00023"></a>00023    array(<span class="charliteral">&#39;\&#39;</span>.<span class="stringliteral">&quot;\\n&quot;</span>.\<span class="stringliteral">&#39;&#39;</span>, <span class="charliteral">&#39;\&#39;</span>.<span class="stringliteral">&quot;\\r&quot;</span>.\<span class="stringliteral">&#39;&#39;</span>,<span class="charliteral">&#39;\&#39;</span>.<span class="stringliteral">&quot;\\t&quot;</span>.\<span class="stringliteral">&#39;&#39;</span>),
<a name="l00024"></a>00024    $str
<a name="l00025"></a>00025   );
<a name="l00026"></a>00026   <span class="keywordflow">return</span> $str;
<a name="l00027"></a>00027  }
<a name="l00028"></a>00028  
<a name="l00035"></a><a class="code" href="class_template_utils.html#aeadcc7d717f5752474ab611bd45cfd7b">00035</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#aeadcc7d717f5752474ab611bd45cfd7b" title="Sanitize string, for use as function name.">sanitize</a>($str) {
<a name="l00036"></a>00036   <span class="keywordflow">return</span> preg_replace(<span class="stringliteral">&#39;/([^a-z0-9\_])/ui&#39;</span>, <span class="charliteral">&#39;_&#39;</span>, $str);
<a name="l00037"></a>00037  }
<a name="l00038"></a>00038  
<a name="l00045"></a><a class="code" href="class_template_utils.html#a486a01915d89b3a87095461329a3a7e6">00045</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a486a01915d89b3a87095461329a3a7e6" title="Strip newlines and spaces from string.">strip</a>($str) {
<a name="l00046"></a>00046   <span class="keywordflow">return</span> str_replace(array(<span class="stringliteral">&quot;\n&quot;</span>, <span class="charliteral">&#39; &#39;</span>), <span class="stringliteral">&#39;&#39;</span>, $str);
<a name="l00047"></a>00047  }
<a name="l00048"></a>00048  
<a name="l00057"></a><a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2">00057</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">split</a>($separator, $str, $reverse = <span class="keyword">false</span>) {
<a name="l00058"></a>00058   $reverse = ($reverse ? <span class="stringliteral">&#39;mb_strrpos&#39;</span> : <span class="stringliteral">&#39;mb_strpos&#39;</span>);
<a name="l00059"></a>00059   $offset = mb_strlen($separator);
<a name="l00060"></a>00060   $separator = $reverse($str, $separator);
<a name="l00061"></a>00061   <span class="keywordflow">if</span> ($separator === <span class="keyword">false</span>) {
<a name="l00062"></a>00062    <span class="keywordflow">return</span> array($str, <span class="stringliteral">&#39;&#39;</span>);
<a name="l00063"></a>00063   }
<a name="l00064"></a>00064   <span class="keywordflow">return</span> array(
<a name="l00065"></a>00065    mb_substr($str, 0, $separator),
<a name="l00066"></a>00066    mb_substr($str, $separator+$offset)
<a name="l00067"></a>00067   );
<a name="l00068"></a>00068  }
<a name="l00069"></a>00069  
<a name="l00079"></a><a class="code" href="class_template_utils.html#a28bd46df8e8547dd387e2047733d8f87">00079</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a28bd46df8e8547dd387e2047733d8f87" title="Properly splits given expression using given delimiter.">splitEscaped</a>($delimiter, $expression) {
<a name="l00080"></a>00080   $splitChunks   = array();
<a name="l00081"></a>00081   $currentChunk  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l00082"></a>00082   $insideString  = <span class="keyword">false</span>;
<a name="l00083"></a>00083   $expressionLen = mb_strlen($expression);
<a name="l00084"></a>00084 
<a name="l00085"></a>00085   <span class="keywordflow">if</span> (mb_strlen($delimiter) &gt; 1) {
<a name="l00086"></a>00086    <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00087"></a>00087   }
<a name="l00088"></a>00088 
<a name="l00089"></a>00089   <span class="keywordflow">for</span> ($currentIdx = 0; $currentIdx &lt; $expressionLen; ++$currentIdx) {
<a name="l00090"></a>00090    $currentChar = mb_substr($expression, $currentIdx, 1);
<a name="l00091"></a>00091    $nextChar    = mb_substr($expression, $currentIdx + 1, 1);
<a name="l00092"></a>00092 
<a name="l00093"></a>00093    <span class="keywordflow">if</span> ($currentChar == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l00094"></a>00094     $currentChunk .= $currentChar;
<a name="l00095"></a>00095     $insideString  = !$insideString;
<a name="l00096"></a>00096    } elseif ($insideString &amp;&amp; $currentChar == <span class="charliteral">&#39;\\&#39;</span> &amp;&amp; $nextChar == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l00097"></a>00097     <span class="comment">// escaped &quot;</span>
<a name="l00098"></a>00098     $currentChunk .= $nextChar;
<a name="l00099"></a>00099     ++$currentIdx;
<a name="l00100"></a>00100    } elseif (!$insideString &amp;&amp; $currentChar == $delimiter) {
<a name="l00101"></a>00101     <span class="comment">// delimiter</span>
<a name="l00102"></a>00102     $splitChunks[] = $currentChunk;
<a name="l00103"></a>00103     $currentChunk  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l00104"></a>00104    } <span class="keywordflow">else</span> {
<a name="l00105"></a>00105     $currentChunk .= $currentChar;
<a name="l00106"></a>00106    }
<a name="l00107"></a>00107   }
<a name="l00108"></a>00108   
<a name="l00109"></a>00109   $splitChunks[] = $currentChunk;
<a name="l00110"></a>00110   
<a name="l00111"></a>00111   <span class="comment">// array_values used for keys to be reset</span>
<a name="l00112"></a>00112   <span class="keywordflow">return</span> array_values(array_filter($splitChunks, array(<span class="stringliteral">&#39;TemplateUtils&#39;</span>, <span class="stringliteral">&#39;filterEmpty&#39;</span>)));
<a name="l00113"></a>00113  }
<a name="l00114"></a>00114  
<a name="l00118"></a><a class="code" href="class_template_utils.html#a9a1d840a603201d1c3a1cb962b6e4c04">00118</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a9a1d840a603201d1c3a1cb962b6e4c04">filterEmpty</a>($x) { <span class="keywordflow">return</span> $x !== <span class="stringliteral">&#39;&#39;</span>; }
<a name="l00119"></a>00119  
<a name="l00127"></a><a class="code" href="class_template_utils.html#a1282a8a4e4a86cd2af8aef16f73434da">00127</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a1282a8a4e4a86cd2af8aef16f73434da" title="Check whether class implements given interface.">doesImplement</a>($classOrObject, $interface) {
<a name="l00128"></a>00128   <span class="keywordflow">return</span> in_array($interface, class_implements($classOrObject));
<a name="l00129"></a>00129  }
<a name="l00130"></a>00130  
<a name="l00138"></a><a class="code" href="class_template_utils.html#ae8b229fe2fe444ee11efdbb97bf7cfef">00138</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#ae8b229fe2fe444ee11efdbb97bf7cfef" title="Splits I/O DSN into driver name and template name.">splitIODSN</a>(array &amp;$settings, $dsn) {
<a name="l00139"></a>00139   <span class="keywordflow">if</span> (mb_strpos($dsn, <span class="stringliteral">&#39;://&#39;</span>) !== <span class="keyword">false</span>) {
<a name="l00140"></a>00140    <span class="keywordflow">return</span> <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">self::split</a>(<span class="stringliteral">&#39;://&#39;</span>, $dsn);
<a name="l00141"></a>00141   } <span class="keywordflow">else</span> {
<a name="l00142"></a>00142    <span class="keywordflow">return</span> array($settings[<span class="stringliteral">&#39;defaultIODriver&#39;</span>], $dsn);
<a name="l00143"></a>00143   }
<a name="l00144"></a>00144  }
<a name="l00145"></a>00145  
<a name="l00153"></a><a class="code" href="class_template_utils.html#a3c4884dc20fe80e13a23f36f09663220">00153</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a3c4884dc20fe80e13a23f36f09663220" title="Splits I/O DSN, and creates correct driver object.">parseIODSN</a>(array &amp;$settings, $dsn) {
<a name="l00154"></a>00154   list($driver, $template) = <a class="code" href="class_template_utils.html#ae8b229fe2fe444ee11efdbb97bf7cfef" title="Splits I/O DSN into driver name and template name.">self::splitIODSN</a>($settings, $dsn);
<a name="l00155"></a>00155   <span class="keywordflow">return</span> array(<a class="code" href="class_template_i_o.html#ad9206870c5ac71fe07b4118279e59c24" title="Returns (creates if necessary) an I/O driver instance.">TemplateIO::get</a>($driver), $template);
<a name="l00156"></a>00156  }
<a name="l00157"></a>00157  
<a name="l00165"></a><a class="code" href="class_template_utils.html#a15d98177df949189c4b094a7f6521329">00165</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a15d98177df949189c4b094a7f6521329" title="Returns class name for given template or DSN.">className</a>($template) {
<a name="l00166"></a>00166   <span class="keywordflow">if</span> (mb_strpos($template, <span class="stringliteral">&#39;://&#39;</span>) !== <span class="keyword">false</span>) <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00167"></a>00167   <span class="keywordflow">return</span> <span class="stringliteral">&#39;Template_&#39;</span>.self::sanitize($template);
<a name="l00168"></a>00168  }
<a name="l00169"></a>00169  
<a name="l00176"></a><a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10">00176</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">panic</a>($file, $line) {
<a name="l00177"></a>00177   <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="class_template_error.html" title="Main and currently the only exception type thrown by SithTemplate internals.">TemplateError</a>(
<a name="l00178"></a>00178    <span class="stringliteral">&#39;!!! PANIC !!! Internal SithTemplate error at &#39;</span>.$file.<span class="stringliteral">&#39; on line &#39;</span>.$line,
<a name="l00179"></a>00179    <a class="code" href="class_template_error.html#afca9160f440f7efed878786e633487db" title="A core panic.">TemplateError::E_INTERNAL_CORE_FAILURE</a>
<a name="l00180"></a>00180   );
<a name="l00181"></a>00181  }
<a name="l00182"></a>00182  
<a name="l00191"></a><a class="code" href="class_template_utils.html#a9ded2c07232134c25d3cf9300822e7d8">00191</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a9ded2c07232134c25d3cf9300822e7d8" title="Checks whether element is allowed.">checkIfAllowed</a>($obj, $type, $name, $node = null) {
<a name="l00192"></a>00192   <span class="keywordflow">if</span> (!in_array($type, array(<span class="stringliteral">&#39;plugin&#39;</span>, <span class="stringliteral">&#39;tag&#39;</span>, <span class="stringliteral">&#39;filter&#39;</span>, <span class="stringliteral">&#39;function&#39;</span>))) {
<a name="l00193"></a>00193    <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00194"></a>00194   }
<a name="l00195"></a>00195   
<a name="l00196"></a>00196   $isCompiler = ($obj instanceof <a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a>);
<a name="l00197"></a>00197   $isEnviron  = ($obj instanceof <a class="code" href="class_template_environ.html" title="Template environment - library&amp;#39;s end-user API.">TemplateEnviron</a>);
<a name="l00198"></a>00198   
<a name="l00199"></a>00199   <span class="keywordflow">if</span> (!$isCompiler &amp;&amp; !$isEnviron) {
<a name="l00200"></a>00200    <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00201"></a>00201   }
<a name="l00202"></a>00202   
<a name="l00203"></a>00203   $settings       = &amp;$obj-&gt;settings;
<a name="l00204"></a>00204   $mode           = &amp;$settings[<span class="stringliteral">&#39;securityEvalMode&#39;</span>];
<a name="l00205"></a>00205   $whitelist      = array(<span class="stringliteral">&#39;allowed&#39;</span>.ucwords($type).<span class="charliteral">&#39;s&#39;</span>, <span class="keyword">true</span>);
<a name="l00206"></a>00206   $blacklist      = array(<span class="stringliteral">&#39;dis&#39;</span>.$whitelist[0],          <span class="keyword">false</span>);
<a name="l00207"></a>00207   $allowed        = null;
<a name="l00208"></a>00208   $defaultAllowed = null;
<a name="l00209"></a>00209   
<a name="l00210"></a>00210   <span class="keywordflow">switch</span> ($mode) {
<a name="l00211"></a>00211    <span class="keywordflow">case</span> <a class="code" href="class_template_environ.html#a5029fb8f59f467ed9b8cbc0586fcea9c" title="One of security modes - do not test against the lists.">TemplateEnviron::SECURITY_DISABLE</a>: <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00212"></a>00212    <span class="keywordflow">case</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.">TemplateEnviron::SECURITY_ALLOW_ALL</a>:
<a name="l00213"></a>00213     $lists          = array($blacklist);
<a name="l00214"></a>00214     $allowed        = <span class="keyword">true</span>;
<a name="l00215"></a>00215    <span class="keywordflow">break</span>;
<a name="l00216"></a>00216    <span class="keywordflow">case</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;.">TemplateEnviron::SECURITY_ALLOW_DENY</a>:
<a name="l00217"></a>00217     $lists          = array($whitelist, $blacklist);
<a name="l00218"></a>00218     $defaultAllowed = <span class="keyword">true</span>;
<a name="l00219"></a>00219    <span class="keywordflow">break</span>;
<a name="l00220"></a>00220    <span class="keywordflow">case</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;.">TemplateEnviron::SECURITY_DENY_ALLOW</a>:
<a name="l00221"></a>00221     $lists          = array($blacklist, $whitelist);
<a name="l00222"></a>00222     $defaultAllowed = <span class="keyword">false</span>;
<a name="l00223"></a>00223    <span class="keywordflow">break</span>;
<a name="l00224"></a>00224    <span class="keywordflow">case</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.">TemplateEnviron::SECURITY_DENY_ALL</a>:
<a name="l00225"></a>00225     $lists          = array($whitelist);
<a name="l00226"></a>00226     $allowed        = <span class="keyword">false</span>;
<a name="l00227"></a>00227    <span class="keywordflow">break</span>;
<a name="l00228"></a>00228    <span class="keywordflow">default</span>: <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00229"></a>00229   }
<a name="l00230"></a>00230   
<a name="l00231"></a>00231   <span class="keywordflow">foreach</span> ($lists as $list) {
<a name="l00232"></a>00232    list($listName, $isWhitelist) = $list;
<a name="l00233"></a>00233    $list                         = &amp;$settings[$listName];
<a name="l00234"></a>00234    
<a name="l00235"></a>00235    <span class="keywordflow">if</span> (is_bool($list) || (is_array($list) &amp;&amp; in_array($name, $list))) {
<a name="l00236"></a>00236     $allowed = $isWhitelist;
<a name="l00237"></a>00237     <span class="keywordflow">continue</span>;
<a name="l00238"></a>00238    }
<a name="l00239"></a>00239   }
<a name="l00240"></a>00240   
<a name="l00241"></a>00241   <span class="keywordflow">if</span> (is_null($allowed)) {
<a name="l00242"></a>00242    trigger_error(
<a name="l00243"></a>00243     <span class="stringliteral">&#39;Warning: security eval mode is &#39;</span>.($defaultAllowed ? <span class="stringliteral">&#39;ALLOW_DENY&#39;</span> : <span class="stringliteral">&#39;DENY_ALLOW&#39;</span>).
<a name="l00244"></a>00244     <span class="stringliteral">&#39; and element &quot;&#39;</span>.$name.<span class="stringliteral">&#39;&quot; appeared on neither &quot;&#39;</span>.$whitelist[0].<span class="stringliteral">&#39;&quot; nor &quot;&#39;</span>.
<a name="l00245"></a>00245     $blacklist[0].<span class="stringliteral">&#39;&quot; list. Defaulting to &quot;&#39;</span>.(!$defaultAllowed ? <span class="stringliteral">&#39;dis&#39;</span> : <span class="stringliteral">&#39;&#39;</span>).<span class="stringliteral">&#39;allow&quot;.&#39;</span>,
<a name="l00246"></a>00246     E_USER_WARNING
<a name="l00247"></a>00247    );
<a name="l00248"></a>00248    $allowed = $defaultAllowed;
<a name="l00249"></a>00249   }
<a name="l00250"></a>00250   
<a name="l00251"></a>00251   <span class="keywordflow">if</span> ($allowed) <span class="keywordflow">return</span>;
<a name="l00252"></a>00252   
<a name="l00253"></a>00253   $message = <span class="stringliteral">&#39;Element &quot;&#39;</span>.$name.<span class="stringliteral">&#39;&quot; of type &quot;&#39;</span>.$type.<span class="stringliteral">&#39;&quot; is not allowed by current security settings&#39;</span>;
<a name="l00254"></a>00254   $code    = <a class="code" href="class_template_error.html#a86ebd61fe642f0e30d96c5086ebebe0c" title="A security violation.">TemplateError::E_SECURITY_VIOLATION</a>;
<a name="l00255"></a>00255   
<a name="l00256"></a>00256   <span class="keywordflow">if</span> ($isCompiler &amp;&amp; ($node instanceof <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a>)) {
<a name="l00257"></a>00257    $obj-&gt;raise($node, $message, $code);
<a name="l00258"></a>00258   } <span class="keywordflow">else</span> {
<a name="l00259"></a>00259    <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="class_template_error.html" title="Main and currently the only exception type thrown by SithTemplate internals.">TemplateError</a>($message, $code);
<a name="l00260"></a>00260   }
<a name="l00261"></a>00261  }
<a name="l00262"></a>00262  
<a name="l00274"></a><a class="code" href="class_template_utils.html#a9c4b3a502dd4eb798f4d47deb972ed7c">00274</a>  <span class="keyword">public</span> <span class="keyword">static</span> function <a class="code" href="class_template_utils.html#a9c4b3a502dd4eb798f4d47deb972ed7c" title="Checks whether I/O restriction is in effect.">checkIORestriction</a>($obj, $setting, $dsn, $expectedDriver, $node = null) {
<a name="l00275"></a>00275   <span class="keywordflow">if</span> (!in_array($setting, array(<span class="stringliteral">&#39;restrictIncludeIO&#39;</span>, <span class="stringliteral">&#39;restrictExtendIO&#39;</span>))) {
<a name="l00276"></a>00276    <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00277"></a>00277   }
<a name="l00278"></a>00278 
<a name="l00279"></a>00279   $isCompiler = ($obj instanceof <a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a>);
<a name="l00280"></a>00280   $isEnviron  = ($obj instanceof <a class="code" href="class_template_environ.html" title="Template environment - library&amp;#39;s end-user API.">TemplateEnviron</a>);
<a name="l00281"></a>00281   
<a name="l00282"></a>00282   <span class="keywordflow">if</span> (!$isCompiler &amp;&amp; !$isEnviron) {
<a name="l00283"></a>00283    <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">self::panic</a>(__FILE__, __LINE__);
<a name="l00284"></a>00284   }
<a name="l00285"></a>00285   
<a name="l00286"></a>00286   $settings = &amp;$obj-&gt;settings;
<a name="l00287"></a>00287   list($driver,) = <a class="code" href="class_template_utils.html#ae8b229fe2fe444ee11efdbb97bf7cfef" title="Splits I/O DSN into driver name and template name.">self::splitIODSN</a>($settings, $dsn);
<a name="l00288"></a>00288   
<a name="l00289"></a>00289   <span class="keywordflow">if</span> (!$settings[$setting] || $driver == $expectedDriver) <span class="keywordflow">return</span>;
<a name="l00290"></a>00290   
<a name="l00291"></a>00291   $message = sprintf(
<a name="l00292"></a>00292    <span class="stringliteral">&#39;I/O restriction in effect - you can only use &quot;%s&quot; I/O driver, &quot;%s&quot; used&#39;</span>,
<a name="l00293"></a>00293    $expectedDriver, $driver
<a name="l00294"></a>00294   );
<a name="l00295"></a>00295   $code    = <a class="code" href="class_template_error.html#a86ebd61fe642f0e30d96c5086ebebe0c" title="A security violation.">TemplateError::E_SECURITY_VIOLATION</a>;
<a name="l00296"></a>00296   
<a name="l00297"></a>00297   <span class="keywordflow">if</span> ($isCompiler &amp;&amp; ($node instanceof <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a>)) {
<a name="l00298"></a>00298    $obj-&gt;raise($node, $message, $code);
<a name="l00299"></a>00299   } <span class="keywordflow">else</span> {
<a name="l00300"></a>00300    <span class="keywordflow">throw</span> <span class="keyword">new</span> <a class="code" href="class_template_error.html" title="Main and currently the only exception type thrown by SithTemplate internals.">TemplateError</a>($message, $code);
<a name="l00301"></a>00301   }
<a name="l00302"></a>00302  }
<a name="l00303"></a>00303 }
</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