Location: PHPKode > projects > SithTemplate > SithTemplate-1.1/docs/html/_std_lib_ex_8plugin_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: StdLibEx.plugin.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>StdLibEx.plugin.php</h1>  </div>
</div>
<div class="contents">
<a href="_std_lib_ex_8plugin_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="l00685"></a><a class="code" href="class_template_std_lib_ex_plugin.html">00685</a> <span class="keyword">class </span><a class="code" href="class_template_std_lib_ex_plugin.html" title="New StdLibEx plugin, which combines old CoreTags, CoreFilters and CoreHooks.">TemplateStdLibExPlugin</a> <span class="keyword">implements</span> <a class="code" href="interface_i_template_plugin.html" title="Interface required for all plugins.">ITemplatePlugin</a> {
<a name="l00686"></a>00686  <span class="comment">// Handlers registration</span>
<a name="l00687"></a>00687 
<a name="l00693"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a66045852315aba2315a0bdf20bec0ec6">00693</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a66045852315aba2315a0bdf20bec0ec6" title="Provided tags.">providedTags</a>() {
<a name="l00694"></a>00694   <span class="keywordflow">return</span> array(
<a name="l00695"></a>00695    <span class="comment">// Django</span>
<a name="l00696"></a>00696    <span class="stringliteral">&#39;autoescape&#39;</span>  =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTAutoEscape&#39;</span>,  <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00697"></a>00697    <span class="stringliteral">&#39;block&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTBlock&#39;</span>,       <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00698"></a>00698    <span class="stringliteral">&#39;cycle&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTCycle&#39;</span>,       <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00699"></a>00699    <span class="stringliteral">&#39;debug&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTDebug&#39;</span>,       <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00700"></a>00700    <span class="stringliteral">&#39;extends&#39;</span>     =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTExtends&#39;</span>,     <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00701"></a>00701    <span class="stringliteral">&#39;filter&#39;</span>      =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTFilter&#39;</span>,      <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00702"></a>00702    <span class="stringliteral">&#39;firstof&#39;</span>     =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTFirstOf&#39;</span>,     <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 2),
<a name="l00703"></a>00703    <span class="stringliteral">&#39;for&#39;</span>         =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTFor&#39;</span>,         <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 3),
<a name="l00704"></a>00704    <span class="stringliteral">&#39;empty&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTEmpty&#39;</span>,       <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0, <span class="stringliteral">&#39;parent&#39;</span> =&gt; <span class="stringliteral">&#39;for&#39;</span>),
<a name="l00705"></a>00705    <span class="stringliteral">&#39;ifchanged&#39;</span>   =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTIfChanged&#39;</span>,   <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0, <span class="stringliteral">&#39;parent&#39;</span> =&gt; <span class="stringliteral">&#39;for&#39;</span>),
<a name="l00706"></a>00706    <span class="stringliteral">&#39;if&#39;</span>          =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTIf&#39;</span>,          <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00707"></a>00707    <span class="stringliteral">&#39;else&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTElse&#39;</span>,        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0, <span class="stringliteral">&#39;parent&#39;</span> =&gt; <span class="stringliteral">&#39;if*&#39;</span>),
<a name="l00708"></a>00708    <span class="stringliteral">&#39;elseif&#39;</span>      =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTElseIf&#39;</span>,      <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1, <span class="stringliteral">&#39;parent&#39;</span> =&gt; <span class="stringliteral">&#39;if&#39;</span>),
<a name="l00709"></a>00709    <span class="stringliteral">&#39;ifequal&#39;</span>     =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTIfEqual&#39;</span>,     <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 2),
<a name="l00710"></a>00710    <span class="stringliteral">&#39;ifnotequal&#39;</span>  =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTIfNotEqual&#39;</span>,  <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 2),
<a name="l00711"></a>00711    <span class="stringliteral">&#39;include&#39;</span>     =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTInclude&#39;</span>,     <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00712"></a>00712    <span class="stringliteral">&#39;now&#39;</span>         =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTNow&#39;</span>,         <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00713"></a>00713    <span class="stringliteral">&#39;spaceless&#39;</span>   =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTSpaceless&#39;</span>,   <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00714"></a>00714    <span class="stringliteral">&#39;templatetag&#39;</span> =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTTemplateTag&#39;</span>, <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00715"></a>00715    <span class="stringliteral">&#39;widthratio&#39;</span>  =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTWidthRatio&#39;</span>,  <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 3),
<a name="l00716"></a>00716    <span class="stringliteral">&#39;with&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTWith&#39;</span>,        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;block&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 3),
<a name="l00717"></a>00717    <span class="comment">// SithTemplate extensions</span>
<a name="l00718"></a>00718    <span class="stringliteral">&#39;putblock&#39;</span>    =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTPutBlock&#39;</span>,    <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00719"></a>00719    <span class="stringliteral">&#39;call&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTCall&#39;</span>,        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00720"></a>00720    <span class="stringliteral">&#39;meta&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleTMeta&#39;</span>,        <span class="stringliteral">&#39;type&#39;</span> =&gt; <span class="stringliteral">&#39;inline&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 2),
<a name="l00721"></a>00721   );
<a name="l00722"></a>00722  }
<a name="l00728"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a4021981fc7a307081f2f48425ba07661">00728</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a4021981fc7a307081f2f48425ba07661" title="Provided filters.">providedFilters</a>() {
<a name="l00729"></a>00729   <span class="keywordflow">return</span> array(
<a name="l00730"></a>00730    <span class="comment">// Django</span>
<a name="l00731"></a>00731    <span class="stringliteral">&#39;add&#39;</span>             =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFAdd&#39;</span>,            <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00732"></a>00732    <span class="stringliteral">&#39;addslashes&#39;</span>      =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFAddSlashes&#39;</span>,     <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00733"></a>00733    <span class="stringliteral">&#39;capfirst&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFCapFirst&#39;</span>,       <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00734"></a>00734    <span class="stringliteral">&#39;cut&#39;</span>             =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFCut&#39;</span>,            <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00735"></a>00735    <span class="stringliteral">&#39;date&#39;</span>            =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFDate&#39;</span>,           <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00736"></a>00736    <span class="stringliteral">&#39;default&#39;</span>         =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFDefault&#39;</span>,        <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00737"></a>00737    <span class="stringliteral">&#39;default_if_none&#39;</span> =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFDefaultIfNone&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00738"></a>00738    <span class="stringliteral">&#39;divisibleby&#39;</span>     =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFDivisibleBy&#39;</span>,    <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00739"></a>00739    <span class="stringliteral">&#39;escape&#39;</span>          =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFEscape&#39;</span>,         <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00740"></a>00740    <span class="stringliteral">&#39;filesizeformat&#39;</span>  =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFFileSizeFormat&#39;</span>, <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00741"></a>00741    <span class="stringliteral">&#39;fix_ampersands&#39;</span>  =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFFixAmpersands&#39;</span>,  <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00742"></a>00742    <span class="stringliteral">&#39;join&#39;</span>            =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFJoin&#39;</span>,           <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00743"></a>00743    <span class="stringliteral">&#39;length&#39;</span>          =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLength&#39;</span>,         <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00744"></a>00744    <span class="stringliteral">&#39;length_is&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLengthIs&#39;</span>,       <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00745"></a>00745    <span class="stringliteral">&#39;linebreaks&#39;</span>      =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLineBreaks&#39;</span>,     <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00746"></a>00746    <span class="stringliteral">&#39;linebreaksbr&#39;</span>    =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLineBreaksBR&#39;</span>,   <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00747"></a>00747    <span class="stringliteral">&#39;ljust&#39;</span>           =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLJust&#39;</span>,          <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00748"></a>00748    <span class="stringliteral">&#39;lower&#39;</span>           =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFLower&#39;</span>,          <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00749"></a>00749    <span class="stringliteral">&#39;make_list&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFMakeList&#39;</span>,       <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00750"></a>00750    <span class="stringliteral">&#39;pluralize&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFPluralize&#39;</span>,      <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00751"></a>00751    <span class="stringliteral">&#39;random&#39;</span>          =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFRandom&#39;</span>,         <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00752"></a>00752    <span class="stringliteral">&#39;removetags&#39;</span>      =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFRemoveTags&#39;</span>,     <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00753"></a>00753    <span class="stringliteral">&#39;rjust&#39;</span>           =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFRJust&#39;</span>,          <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00754"></a>00754    <span class="stringliteral">&#39;slugify&#39;</span>         =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFSlugify&#39;</span>,        <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00755"></a>00755    <span class="stringliteral">&#39;title&#39;</span>           =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFTitle&#39;</span>,          <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00756"></a>00756    <span class="stringliteral">&#39;upper&#39;</span>           =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFUpper&#39;</span>,          <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00757"></a>00757    <span class="stringliteral">&#39;urlencode&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFURLEncode&#39;</span>,      <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00758"></a>00758    <span class="stringliteral">&#39;urldecode&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFURLDecode&#39;</span>,      <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00759"></a>00759    <span class="stringliteral">&#39;wordcount&#39;</span>       =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFWordCount&#39;</span>,      <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 0),
<a name="l00760"></a>00760    <span class="stringliteral">&#39;wordwrap&#39;</span>        =&gt; array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleFWordWrap&#39;</span>,       <span class="stringliteral">&#39;minArgs&#39;</span> =&gt; 1),
<a name="l00761"></a>00761   );
<a name="l00762"></a>00762  }
<a name="l00768"></a><a class="code" href="class_template_std_lib_ex_plugin.html#aaac777855bafb5e899a91483d4f28e85">00768</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#aaac777855bafb5e899a91483d4f28e85" title="Provided hooks.">providedHooks</a>() {
<a name="l00769"></a>00769   <span class="keywordflow">return</span> array(
<a name="l00770"></a>00770    <span class="stringliteral">&#39;parseVariableExpression:postCodeGen&#39;</span> =&gt; array(
<a name="l00771"></a>00771     array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleHInternalVariable&#39;</span>),
<a name="l00772"></a>00772     array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleHForLoopVariable&#39;</span>),
<a name="l00773"></a>00773     array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleHBlockVariable&#39;</span>),
<a name="l00774"></a>00774    ),
<a name="l00775"></a>00775    <span class="stringliteral">&#39;parseFilterChain:entry&#39;</span> =&gt; array(
<a name="l00776"></a>00776     array(<span class="stringliteral">&#39;handler&#39;</span> =&gt; <span class="stringliteral">&#39;handleHAutoEscape&#39;</span>),
<a name="l00777"></a>00777    )
<a name="l00778"></a>00778   );
<a name="l00779"></a>00779  }
<a name="l00786"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a52cc2adc22b09c2c66ea60b61804cf37">00786</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a52cc2adc22b09c2c66ea60b61804cf37" title="Provided handlers.">providedHandlers</a>() {
<a name="l00787"></a>00787   <span class="keywordflow">return</span> array(
<a name="l00788"></a>00788    <span class="stringliteral">&#39;tags&#39;</span>    =&gt; $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#a66045852315aba2315a0bdf20bec0ec6" title="Provided tags.">providedTags</a>(),
<a name="l00789"></a>00789    <span class="stringliteral">&#39;filters&#39;</span> =&gt; $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#a4021981fc7a307081f2f48425ba07661" title="Provided filters.">providedFilters</a>(),
<a name="l00790"></a>00790    <span class="stringliteral">&#39;hooks&#39;</span>   =&gt; $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#aaac777855bafb5e899a91483d4f28e85" title="Provided hooks.">providedHooks</a>(),
<a name="l00791"></a>00791   );
<a name="l00792"></a>00792  }
<a name="l00793"></a>00793  
<a name="l00794"></a>00794  <span class="comment">//</span>
<a name="l00795"></a>00795  <span class="comment">// Std tags</span>
<a name="l00796"></a>00796  <span class="comment">//</span>
<a name="l00797"></a>00797  
<a name="l00799"></a><a class="code" href="class_template_std_lib_ex_plugin.html#af411fa8ae0b7ac509f6bfd601cd81945">00799</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#af411fa8ae0b7ac509f6bfd601cd81945" title="{% autoescape %} tag.">handleTAutoEscape</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00800"></a>00800   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00801"></a>00801    (!in_array($args[0], array(<span class="stringliteral">&#39;on&#39;</span>, <span class="stringliteral">&#39;off&#39;</span>))),
<a name="l00802"></a>00802    $node,
<a name="l00803"></a>00803    <span class="stringliteral">&#39;First argument of &quot;autoescape&quot; must be either &quot;on&quot; or &quot;off&quot;&#39;</span>,
<a name="l00804"></a>00804    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l00805"></a>00805   );
<a name="l00806"></a>00806   
<a name="l00807"></a>00807   $oldAutoEscape = $compiler-&gt;settings[<span class="stringliteral">&#39;autoEscape&#39;</span>];
<a name="l00808"></a>00808   $compiler-&gt;settings[<span class="stringliteral">&#39;autoEscape&#39;</span>] = ($args[0] == <span class="stringliteral">&#39;on&#39;</span> ? <span class="keyword">true</span> : <span class="keyword">false</span>);
<a name="l00809"></a>00809   $code = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($node-&gt;nodeChildren);
<a name="l00810"></a>00810   $compiler-&gt;settings[<span class="stringliteral">&#39;autoEscape&#39;</span>] = $oldAutoEscape;
<a name="l00811"></a>00811   
<a name="l00812"></a>00812   <span class="keywordflow">return</span> $code;
<a name="l00813"></a>00813  }
<a name="l00814"></a>00814  
<a name="l00816"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ad749d211fd3665f23b1a3e0eab6f05ab">00816</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#ad749d211fd3665f23b1a3e0eab6f05ab" title="{% block %} tag.">handleTBlock</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00817"></a>00817   $blockName = <span class="stringliteral">&#39;block:&#39;</span>.$args[0];
<a name="l00818"></a>00818   $funcName  = <span class="charliteral">&#39;_&#39;</span>.TemplateUtils::sanitize($blockName);
<a name="l00819"></a>00819   
<a name="l00820"></a>00820   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00821"></a>00821    (isset($compiler-&gt;blocks[$blockName])),
<a name="l00822"></a>00822    $node,
<a name="l00823"></a>00823    <span class="stringliteral">&#39;Redefined block &quot;&#39;</span>.$args[0].<span class="charliteral">&#39;&quot;&#39;</span>,
<a name="l00824"></a>00824    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l00825"></a>00825   );
<a name="l00826"></a>00826   
<a name="l00827"></a>00827   <span class="keywordflow">if</span> (!isset($compiler-&gt;varInBlock)) {
<a name="l00828"></a>00828    $compiler-&gt;varInBlock = array();
<a name="l00829"></a>00829   }
<a name="l00830"></a>00830   
<a name="l00831"></a>00831   $compiler-&gt;varInBlock[] = $blockName;
<a name="l00832"></a>00832   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a616eb81be4f686387ecd3f778eca26a5" title="Creates code block from raw node.">createBlock</a>($blockName, $node);
<a name="l00833"></a>00833   array_pop($compiler-&gt;varInBlock);
<a name="l00834"></a>00834 
<a name="l00835"></a>00835   <span class="keywordflow">if</span> (in_array(<span class="stringliteral">&#39;store&#39;</span>, $args)) {
<a name="l00836"></a>00836    <span class="keywordflow">return</span> <span class="stringliteral">&#39;&#39;</span>;
<a name="l00837"></a>00837   } <span class="keywordflow">else</span> {
<a name="l00838"></a>00838    <span class="keywordflow">return</span> <span class="stringliteral">&#39;$b.=$this-&gt;&#39;</span>.$funcName.<span class="stringliteral">&#39;($e);&#39;</span>;
<a name="l00839"></a>00839   }
<a name="l00840"></a>00840  }
<a name="l00841"></a>00841  
<a name="l00843"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a8bbcc3162e9c6eac36c284418fa4c854">00843</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a8bbcc3162e9c6eac36c284418fa4c854" title="{% cycle %} tag.">handleTCycle</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00844"></a>00844   $inLoop = (isset($compiler-&gt;varInLoop) &amp;&amp; $compiler-&gt;varInLoop);
<a name="l00845"></a>00845   
<a name="l00846"></a>00846   <span class="keywordflow">if</span> ($inLoop) {
<a name="l00847"></a>00847    $cycleBlockName = <span class="stringliteral">&#39;cycle:&#39;</span>.end($compiler-&gt;varInLoop);
<a name="l00848"></a>00848    $cycleMustExist = <span class="keyword">false</span>;
<a name="l00849"></a>00849    $cycleArgs      = &amp;$args;
<a name="l00850"></a>00850   } <span class="keywordflow">else</span> {
<a name="l00851"></a>00851    $argCount = count($args);
<a name="l00852"></a>00852 
<a name="l00853"></a>00853    <span class="keywordflow">if</span> ($argCount == 1) {
<a name="l00854"></a>00854     $cycleBlockName = <span class="stringliteral">&#39;cycle:&#39;</span>.$args[0];
<a name="l00855"></a>00855     $cycleMustExist = <span class="keyword">true</span>;
<a name="l00856"></a>00856    } <span class="keywordflow">else</span> {
<a name="l00857"></a>00857     $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00858"></a>00858      ($argCount &lt; 4 || $args[$argCount - 2] != <span class="stringliteral">&#39;as&#39;</span>),
<a name="l00859"></a>00859      $node,
<a name="l00860"></a>00860      <span class="stringliteral">&#39;Insufficient &quot;cycle&quot; arguments - correct signature is {% cycle value value [value [value [...]]] as name %}&#39;</span>,
<a name="l00861"></a>00861      <a class="code" href="class_template_error.html#ac502ffee5019e6d870c25083af550454" title="An invalid syntax error.">TemplateError::E_INVALID_SYNTAX</a>
<a name="l00862"></a>00862     );
<a name="l00863"></a>00863     
<a name="l00864"></a>00864     $cycleBlockName = <span class="stringliteral">&#39;cycle:&#39;</span>.$args[$argCount - 1];
<a name="l00865"></a>00865     $cycleMustExist = <span class="keyword">false</span>;
<a name="l00866"></a>00866     $cycleArgs      = array_slice($args, 0, -2);
<a name="l00867"></a>00867    }
<a name="l00868"></a>00868   }
<a name="l00869"></a>00869   
<a name="l00870"></a>00870   $cycleExists = isset($compiler-&gt;blocks[$cycleBlockName]);
<a name="l00871"></a>00871   
<a name="l00872"></a>00872   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00873"></a>00873    ($cycleMustExist ? !$cycleExists : $cycleExists),
<a name="l00874"></a>00874    $node,
<a name="l00875"></a>00875    <span class="stringliteral">&#39;Cycle &quot;&#39;</span>.mb_substr($cycleBlockName, 6).<span class="stringliteral">&#39;&quot; &#39;</span>.
<a name="l00876"></a>00876    ($cycleMustExist ? <span class="stringliteral">&#39;does not exist&#39;</span> : <span class="stringliteral">&#39;already exists&#39;</span>),
<a name="l00877"></a>00877    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l00878"></a>00878   );
<a name="l00879"></a>00879   
<a name="l00880"></a>00880   <span class="keywordflow">if</span> (!$cycleExists) {
<a name="l00881"></a>00881    <span class="comment">// $v - array of cycled values</span>
<a name="l00882"></a>00882    <span class="comment">// $i - current internal cycle index</span>
<a name="l00883"></a>00883    <span class="comment">//      (array index is calculated by $i % count($v))</span>
<a name="l00884"></a>00884    <span class="keywordflow">if</span> (!$cycleArgs) <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">TemplateUtils::panic</a>(__FILE__, __LINE__);
<a name="l00885"></a>00885    
<a name="l00886"></a>00886    $allCheck = <span class="stringliteral">&#39;&#39;</span>;
<a name="l00887"></a>00887    
<a name="l00888"></a>00888    <span class="keywordflow">foreach</span> ($cycleArgs as &amp;$arg) {
<a name="l00889"></a>00889     <span class="keywordflow">if</span> (mb_substr($arg, 0, 1) == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l00890"></a>00890      $arg = <span class="charliteral">&#39;\&#39;&#39;</span>.TemplateUtils::escape(mb_substr($arg, 1, -1)).<span class="charliteral">&#39;\&#39;&#39;</span>;
<a name="l00891"></a>00891     } <span class="keywordflow">else</span> {
<a name="l00892"></a>00892      list($arg, $check)  = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $arg);
<a name="l00893"></a>00893      $allCheck          .= $check;
<a name="l00894"></a>00894     }
<a name="l00895"></a>00895    }
<a name="l00896"></a>00896    
<a name="l00897"></a>00897    $compiler-&gt;blocks[$cycleBlockName] =
<a name="l00898"></a>00898     <span class="stringliteral">&#39;static $v=0,$i=0;if(!$v){&#39;</span>.$allCheck.<span class="stringliteral">&#39;$v=array(&#39;</span>.implode(<span class="charliteral">&#39;,&#39;</span>, $cycleArgs).<span class="stringliteral">&#39;);}&#39;</span>.
<a name="l00899"></a>00899     <span class="stringliteral">&#39;return $v[($i++)%&#39;</span>.count($cycleArgs).<span class="stringliteral">&#39;];&#39;</span>;
<a name="l00900"></a>00900   }
<a name="l00901"></a>00901   
<a name="l00902"></a>00902   <span class="keywordflow">return</span> <span class="stringliteral">&#39;$b.=$this-&gt;_&#39;</span>.TemplateUtils::sanitize($cycleBlockName).<span class="stringliteral">&#39;($e);&#39;</span>;
<a name="l00903"></a>00903  }
<a name="l00904"></a>00904  
<a name="l00906"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ad4760c7c841c09f4f87f2ed19c5b6593">00906</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#ad4760c7c841c09f4f87f2ed19c5b6593" title="{% debug %} tag.">handleTDebug</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00907"></a>00907   <span class="keywordflow">return</span> <span class="stringliteral">&#39;var_dump($this-&gt;ctx);&#39;</span>;
<a name="l00908"></a>00908  }
<a name="l00909"></a>00909  
<a name="l00911"></a><a class="code" href="class_template_std_lib_ex_plugin.html#aeb855968ea0d26771a70c12bd194aef0">00911</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#aeb855968ea0d26771a70c12bd194aef0" title="{% extends %} tag.">handleTExtends</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00912"></a>00912   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00913"></a>00913    (isset($compiler-&gt;metadata[<span class="stringliteral">&#39;parentTemplate&#39;</span>]) &amp;&amp; !empty($compiler-&gt;metadata[<span class="stringliteral">&#39;parentTemplate&#39;</span>])),
<a name="l00914"></a>00914    $node,
<a name="l00915"></a>00915    <span class="stringliteral">&#39;This template already has a parent specified&#39;</span>,
<a name="l00916"></a>00916    <a class="code" href="class_template_error.html#ac502ffee5019e6d870c25083af550454" title="An invalid syntax error.">TemplateError::E_INVALID_SYNTAX</a>
<a name="l00917"></a>00917   );
<a name="l00918"></a>00918   
<a name="l00919"></a>00919   $dsn = mb_substr($args[0], 1, -1);
<a name="l00920"></a>00920   
<a name="l00921"></a>00921   <a class="code" href="class_template_utils.html#a9c4b3a502dd4eb798f4d47deb972ed7c" title="Checks whether I/O restriction is in effect.">TemplateUtils::checkIORestriction</a>(
<a name="l00922"></a>00922    $compiler, <span class="stringliteral">&#39;restrictExtendIO&#39;</span>, $dsn, $compiler-&gt;metadata[<span class="stringliteral">&#39;usedIO&#39;</span>], $node
<a name="l00923"></a>00923   );
<a name="l00924"></a>00924   
<a name="l00925"></a>00925   $compiler-&gt;metadata[<span class="stringliteral">&#39;parentTemplate&#39;</span>] = $dsn;
<a name="l00926"></a>00926   <span class="comment">// no block-level code generated</span>
<a name="l00927"></a>00927   <span class="keywordflow">return</span> <span class="stringliteral">&#39;&#39;</span>;
<a name="l00928"></a>00928  }
<a name="l00929"></a>00929  
<a name="l00931"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a37127ea490c836e5452fc0941441ab41">00931</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a37127ea490c836e5452fc0941441ab41" title="{% filter %} tag.">handleTFilter</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00932"></a>00932   $filters   = &amp;$args[0];
<a name="l00933"></a>00933   $blockName = <span class="stringliteral">&#39;block:filter:&#39;</span>.md5($filters);
<a name="l00934"></a>00934   $call      = <span class="stringliteral">&#39;$this-&gt;_&#39;</span>.TemplateUtils::sanitize($blockName).<span class="stringliteral">&#39;($e)&#39;</span>;
<a name="l00935"></a>00935   
<a name="l00936"></a>00936   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a616eb81be4f686387ecd3f778eca26a5" title="Creates code block from raw node.">createBlock</a>($blockName, $node);
<a name="l00937"></a>00937   
<a name="l00938"></a>00938   $code = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0e954efa4b344518798797fe3bc6dd14" title="Handles filter chains.">parseFilterChain</a>($node, $filters, $call);
<a name="l00939"></a>00939   <span class="keywordflow">return</span> <span class="stringliteral">&#39;$b.=&#39;</span>.$code.<span class="charliteral">&#39;;&#39;</span>;
<a name="l00940"></a>00940  }
<a name="l00941"></a>00941  
<a name="l00943"></a><a class="code" href="class_template_std_lib_ex_plugin.html#af3277e43eeba6f1b9df2ec33b3e5754f">00943</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#af3277e43eeba6f1b9df2ec33b3e5754f" title="{% firstof %} tag.">handleTFirstOf</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00944"></a>00944   $allCode  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l00945"></a>00945   $lastArg  = &amp;$args[count($args) - 1];
<a name="l00946"></a>00946   $fallback = null;
<a name="l00947"></a>00947   
<a name="l00948"></a>00948   <span class="keywordflow">foreach</span> ($args as &amp;$arg) {
<a name="l00949"></a>00949    <span class="keywordflow">if</span> (mb_substr($arg, 0, 1) == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l00950"></a>00950     $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00951"></a>00951      ($arg !== $lastArg),
<a name="l00952"></a>00952      $node,
<a name="l00953"></a>00953      <span class="stringliteral">&#39;Fallback value for &quot;firstof&quot; tag must be given as the last one&#39;</span>,
<a name="l00954"></a>00954      <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l00955"></a>00955     );
<a name="l00956"></a>00956     
<a name="l00957"></a>00957     $fallback = <span class="charliteral">&#39;\&#39;&#39;</span>.TemplateUtils::escape(mb_substr($arg, 1, -1)).<span class="charliteral">&#39;\&#39;&#39;</span>;
<a name="l00958"></a>00958    } <span class="keywordflow">else</span> {
<a name="l00959"></a>00959     list($code,) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $arg);
<a name="l00960"></a>00960     
<a name="l00961"></a>00961     $allCode   = <span class="stringliteral">&#39;elseif(isset(&#39;</span>.$code.<span class="stringliteral">&#39;)&amp;&amp;@&#39;</span>.$code.<span class="stringliteral">&#39;){$b.=&#39;</span>.$code.<span class="stringliteral">&#39;;}&#39;</span>;
<a name="l00962"></a>00962    }
<a name="l00963"></a>00963   }
<a name="l00964"></a>00964   
<a name="l00965"></a>00965   $allCode = mb_substr($allCode, 4);
<a name="l00966"></a>00966   
<a name="l00967"></a>00967   <span class="keywordflow">if</span> ($fallback) {
<a name="l00968"></a>00968    $allCode .= <span class="stringliteral">&#39;else{$b.=&#39;</span>.$fallback.<span class="stringliteral">&#39;;}&#39;</span>;
<a name="l00969"></a>00969   }
<a name="l00970"></a>00970   
<a name="l00971"></a>00971   <span class="keywordflow">return</span> $allCode;
<a name="l00972"></a>00972  }
<a name="l00973"></a>00973  
<a name="l00975"></a><a class="code" href="class_template_std_lib_ex_plugin.html#addfd378f9906cf919024ad3ae46bbddf">00975</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#addfd378f9906cf919024ad3ae46bbddf" title="{% for %} tag.">handleTFor</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l00976"></a>00976   <span class="keywordflow">if</span> (count($args) == 3) {
<a name="l00977"></a>00977    <span class="comment">// {% for value in iterable %}</span>
<a name="l00978"></a>00978    $valueVariable    = &amp;$args[0];
<a name="l00979"></a>00979    $keyVariable      = null;
<a name="l00980"></a>00980    $inConstant       = &amp;$args[1];
<a name="l00981"></a>00981    $iterableVariable = &amp;$args[2];
<a name="l00982"></a>00982   } elseif (count($args) == 4) {
<a name="l00983"></a>00983    <span class="comment">// {% for value in iterable %}</span>
<a name="l00984"></a>00984    $valueVariable    = &amp;$args[1];
<a name="l00985"></a>00985    $keyVariable      = &amp;$args[0];
<a name="l00986"></a>00986    
<a name="l00987"></a>00987    $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l00988"></a>00988     (mb_substr($keyVariable, -1, 1) != <span class="charliteral">&#39;,&#39;</span>),
<a name="l00989"></a>00989     $node,
<a name="l00990"></a>00990     <span class="stringliteral">&#39;Key variable definition invalid - it should end with a comma&#39;</span>,
<a name="l00991"></a>00991     <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l00992"></a>00992    );
<a name="l00993"></a>00993    
<a name="l00994"></a>00994    $keyVariable      = mb_substr($keyVariable, 0, -1);
<a name="l00995"></a>00995    
<a name="l00996"></a>00996    $inConstant       = &amp;$args[2];
<a name="l00997"></a>00997    $iterableVariable = &amp;$args[3];
<a name="l00998"></a>00998   } <span class="keywordflow">else</span> {
<a name="l00999"></a>00999    $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8f7f10bdd17ee4be906b39cff3f0d13d" title="Raises an error, appending &amp;quot;(in template &amp;lt;file&amp;gt; somewhere around line &amp;lt;line&amp;gt;)&amp;quot; ...">raise</a>(
<a name="l01000"></a>01000     $node,
<a name="l01001"></a>01001     <span class="stringliteral">&#39;Invalid argument count - either 3 or 4 are required&#39;</span>,
<a name="l01002"></a>01002     <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01003"></a>01003    );
<a name="l01004"></a>01004   }
<a name="l01005"></a>01005   
<a name="l01006"></a>01006   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01007"></a>01007    ($inConstant != <span class="stringliteral">&#39;in&#39;</span>),
<a name="l01008"></a>01008    $node,
<a name="l01009"></a>01009    <span class="stringliteral">&#39;Invalid argument given - expected &quot;in&quot;, found &quot;&#39;</span>.$inConstant.<span class="charliteral">&#39;&quot;&#39;</span>,
<a name="l01010"></a>01010    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01011"></a>01011   );
<a name="l01012"></a>01012   
<a name="l01013"></a>01013   <span class="comment">// to avoid loop&#39;s block name collisions, and long function names at the same time</span>
<a name="l01014"></a>01014   $loopBlockName = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0cee437cbd376a2ad926de8b745e120c" title="Generates prefixed block name that is guaranteed to be unique in current template.">generateUniqueBlock</a>($keyVariable.$valueVariable.$iterableVariable, <span class="stringliteral">&#39;loop:&#39;</span>);
<a name="l01015"></a>01015   
<a name="l01016"></a>01016   list($iterable, $filters)   = <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">TemplateUtils::split</a>(<span class="charliteral">&#39;|&#39;</span>, $iterableVariable);
<a name="l01017"></a>01017   list($iterable, $iterCheck) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $iterable);
<a name="l01018"></a>01018   
<a name="l01019"></a>01019   <span class="keywordflow">if</span> (!isset($compiler-&gt;varInLoop)) {
<a name="l01020"></a>01020    $compiler-&gt;varInLoop = array();
<a name="l01021"></a>01021   }
<a name="l01022"></a>01022   
<a name="l01023"></a>01023   $loopCall = sprintf(
<a name="l01024"></a>01024    <span class="stringliteral">&#39;$b.=$this-&gt;_&#39;</span>.<a class="code" href="class_template_utils.html#aeadcc7d717f5752474ab611bd45cfd7b" title="Sanitize string, for use as function name.">TemplateUtils::sanitize</a>($loopBlockName).<span class="stringliteral">&#39;($e%s);&#39;</span>,
<a name="l01025"></a>01025    ($compiler-&gt;varInLoop ? <span class="stringliteral">&#39;,$f&#39;</span> : <span class="stringliteral">&#39;&#39;</span>)
<a name="l01026"></a>01026   );
<a name="l01027"></a>01027   
<a name="l01028"></a>01028   <span class="comment">// body of the loop</span>
<a name="l01029"></a>01029   list($loopBodyNodes, $emptyNodes) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a9ce1b5f9a87d8fdbadfad18bb440efff" title="Used to find and isolate alternative branch of given node, starting with given inline tag...">findAlternativeBranch</a>($node, <span class="stringliteral">&#39;empty&#39;</span>);
<a name="l01030"></a>01030   
<a name="l01031"></a>01031   $compiler-&gt;varInLoop[] = $loopBlockName;
<a name="l01032"></a>01032   $loopBody = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($loopBodyNodes);
<a name="l01033"></a>01033   array_pop($compiler-&gt;varInLoop);
<a name="l01034"></a>01034   
<a name="l01035"></a>01035   <span class="comment">// and loop itself</span>
<a name="l01036"></a>01036   <span class="comment">//</span>
<a name="l01037"></a>01037   <span class="comment">// $k              = value of the key</span>
<a name="l01038"></a>01038   <span class="comment">// $v              = value of the value</span>
<a name="l01039"></a>01039   <span class="comment">// $kn             = name of context variable holding key</span>
<a name="l01040"></a>01040   <span class="comment">// $vn             = name of context variable holding value</span>
<a name="l01041"></a>01041   <span class="comment">// $ic             = item count in iterable</span>
<a name="l01042"></a>01042   <span class="comment">// $iv             = iterable</span>
<a name="l01043"></a>01043   <span class="comment">// $f              = name of the forloop variable</span>
<a name="l01044"></a>01044   <span class="comment">// $this-&gt;ctx[$kn] = reference to $k</span>
<a name="l01045"></a>01045   <span class="comment">// $this-&gt;ctx[$vn] = reference to $v</span>
<a name="l01046"></a>01046   <span class="comment">// $cf             = reference to $this-&gt;ctx[$f]</span>
<a name="l01047"></a>01047   
<a name="l01048"></a>01048   <span class="comment">// sanity check</span>
<a name="l01049"></a>01049   $loopCheckCode =
<a name="l01050"></a>01050    <span class="stringliteral">&#39;if(!is_array($iv)&amp;&amp;!(is_object($iv)&amp;&amp;&#39;</span>.
<a name="l01051"></a>01051    <span class="stringliteral">&#39;TemplateUtils::doesImplement($iv,\&#39;Traversable\&#39;)&amp;&amp;&#39;</span>.
<a name="l01052"></a>01052    <span class="stringliteral">&#39;TemplateUtils::doesImplement($iv,\&#39;Countable\&#39;))){&#39;</span>.
<a name="l01053"></a>01053    <span class="stringliteral">&#39;$this-&gt;invalidVar(\&#39;&#39;</span>.TemplateUtils::escape($iterableVariable).<span class="charliteral">&#39;\&#39;</span>,\<span class="stringliteral">&#39;iterable expected\&#39;);}&#39;</span>;
<a name="l01054"></a>01054   
<a name="l01055"></a>01055   $loopCode =
<a name="l01056"></a>01056    $iterCheck.
<a name="l01057"></a>01057    <span class="stringliteral">&#39;$iv=&#39;</span>.$compiler-&gt;parseFilterChain($node, $filters, <span class="charliteral">&#39;@&#39;</span>.$iterable).<span class="charliteral">&#39;;&#39;</span>.
<a name="l01058"></a>01058    <span class="stringliteral">&#39;$f=\&#39;forloop:&#39;</span>.TemplateUtils::escape($loopBlockName).<span class="charliteral">&#39;\&#39;</span>;<span class="stringliteral">&#39;.</span>
<a name="l01059"></a>01059 <span class="stringliteral">   $loopCheckCode;</span>
<a name="l01060"></a>01060 <span class="stringliteral">  </span>
<a name="l01061"></a>01061 <span class="stringliteral">  if ($keyVariable) {</span>
<a name="l01062"></a>01062 <span class="stringliteral">   $loopCode .= TemplateUtils::strip(&#39;</span>
<a name="l01063"></a>01063     $k  = null;
<a name="l01064"></a>01064     $kn = \<span class="stringliteral">&#39;&#39;</span>.TemplateUtils::escape($keyVariable).<span class="charliteral">&#39;\&#39;</span>;
<a name="l01065"></a>01065     $this-&gt;ctx[$kn] = &amp;$k;
<a name="l01066"></a>01066    <span class="stringliteral">&#39;);</span>
<a name="l01067"></a>01067 <span class="stringliteral">  }</span>
<a name="l01068"></a>01068 <span class="stringliteral">  </span>
<a name="l01069"></a>01069 <span class="stringliteral">  $loopCode .= sprintf(TemplateUtils::strip(&#39;</span>
<a name="l01070"></a>01070    $v  = null;
<a name="l01071"></a>01071    $vn = \<span class="stringliteral">&#39;&#39;</span>.TemplateUtils::escape($valueVariable).<span class="charliteral">&#39;\&#39;</span>;
<a name="l01072"></a>01072    $this-&gt;ctx[$vn] = &amp;$v;
<a name="l01073"></a>01073    $ic = count($iv);
<a name="l01074"></a>01074    
<a name="l01075"></a>01075    $this-&gt;ctx[$f] = array(
<a name="l01076"></a>01076     \<span class="stringliteral">&#39;counter\&#39;     =&gt; 1,</span>
<a name="l01077"></a>01077 <span class="stringliteral">    \&#39;counter0\&#39;    =&gt; 0,</span>
<a name="l01078"></a>01078 <span class="stringliteral">    \&#39;revcounter\&#39;  =&gt; $ic,</span>
<a name="l01079"></a>01079 <span class="stringliteral">    \&#39;revcounter0\&#39; =&gt; $ic - 1,</span>
<a name="l01080"></a>01080 <span class="stringliteral">    \&#39;first\&#39;       =&gt; true,</span>
<a name="l01081"></a>01081 <span class="stringliteral">    \&#39;last\&#39;        =&gt; ($ic - 1) == 0</span>
<a name="l01082"></a>01082 <span class="stringliteral">   );</span>
<a name="l01083"></a>01083 <span class="stringliteral">   </span>
<a name="l01084"></a>01084 <span class="stringliteral">   $cf = &amp;$this-&gt;ctx[$f];</span>
<a name="l01085"></a>01085 <span class="stringliteral">   </span>
<a name="l01086"></a>01086 <span class="stringliteral">   if (func_num_args() == 2) {</span>
<a name="l01087"></a>01087 <span class="stringliteral">    $cf[\&#39;parentloop\&#39;] = &amp;$this-&gt;ctx[func_get_arg(1)];</span>
<a name="l01088"></a>01088 <span class="stringliteral">   }</span>
<a name="l01089"></a>01089 <span class="stringliteral">   </span>
<a name="l01090"></a>01090 <span class="stringliteral">   %s</span>
<a name="l01091"></a>01091 <span class="stringliteral">   </span>
<a name="l01092"></a>01092 <span class="stringliteral">   %s {</span>
<a name="l01093"></a>01093 <span class="stringliteral">    %s</span>
<a name="l01094"></a>01094 <span class="stringliteral">    ++$cf[\&#39;counter\&#39;];</span>
<a name="l01095"></a>01095 <span class="stringliteral">    ++$cf[\&#39;counter0\&#39;];</span>
<a name="l01096"></a>01096 <span class="stringliteral">    --$cf[\&#39;revcounter\&#39;];</span>
<a name="l01097"></a>01097 <span class="stringliteral">    --$cf[\&#39;revcounter0\&#39;];</span>
<a name="l01098"></a>01098 <span class="stringliteral">    $cf[\&#39;first\&#39;] = false;</span>
<a name="l01099"></a>01099 <span class="stringliteral">    $cf[\&#39;last\&#39;]  = ($cf[\&#39;revcounter0\&#39;] == 0);</span>
<a name="l01100"></a>01100 <span class="stringliteral">   }</span>
<a name="l01101"></a>01101 <span class="stringliteral">   &#39;</span>),
<a name="l01102"></a>01102    ($emptyNodes ? <span class="stringliteral">&#39;if($ic==0){$b=\&#39;\&#39;;&#39;</span>.$compiler-&gt;handleChildren($emptyNodes).<span class="stringliteral">&#39;return $b;}&#39;</span> : <span class="stringliteral">&#39;&#39;</span>),
<a name="l01103"></a>01103    <span class="stringliteral">&#39;foreach($iv as &#39;</span>.($keyVariable ? <span class="stringliteral">&#39;$k=&gt;&#39;</span> : <span class="stringliteral">&#39;&#39;</span>).<span class="stringliteral">&#39;$v)&#39;</span>, $loopBody
<a name="l01104"></a>01104   );
<a name="l01105"></a>01105   
<a name="l01106"></a>01106   $compiler-&gt;blocks[$loopBlockName] = <span class="stringliteral">&#39;$b=\&#39;\&#39;;&#39;</span>.$loopCode.<span class="stringliteral">&#39;return $b;&#39;</span>;
<a name="l01107"></a>01107   
<a name="l01108"></a>01108   <span class="keywordflow">return</span> $loopCall;
<a name="l01109"></a>01109  }
<a name="l01110"></a>01110  
<a name="l01112"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a63486d133e23e5c40b3dde2bcbbe3e67">01112</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a63486d133e23e5c40b3dde2bcbbe3e67" title="{% empty %} tag.">handleTEmpty</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01113"></a>01113   <span class="comment">// handled by {% for %}, does not generate any code</span>
<a name="l01114"></a>01114   <span class="comment">// in fact, this handler should never be called</span>
<a name="l01115"></a>01115   <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">TemplateUtils::panic</a>(__FILE__, __LINE__);
<a name="l01116"></a>01116   <span class="keywordflow">return</span> <span class="stringliteral">&#39;&#39;</span>;
<a name="l01117"></a>01117  }
<a name="l01118"></a>01118  
<a name="l01120"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ae89fc81f4757c3d6177de0d5189fd6d5">01120</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#ae89fc81f4757c3d6177de0d5189fd6d5" title="{% ifchanged %} tag.">handleTIfChanged</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01121"></a>01121   list($ifNodes, $elseNodes) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a9ce1b5f9a87d8fdbadfad18bb440efff" title="Used to find and isolate alternative branch of given node, starting with given inline tag...">findAlternativeBranch</a>($node, <span class="stringliteral">&#39;else&#39;</span>);
<a name="l01122"></a>01122   $ifBlockName = <span class="stringliteral">&#39;ifchanged:&#39;</span>.end($compiler-&gt;varInLoop);
<a name="l01123"></a>01123   
<a name="l01124"></a>01124   $ifBlockBody = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($ifNodes);
<a name="l01125"></a>01125   
<a name="l01126"></a>01126   $ifChangedCode  = <span class="stringliteral">&#39;$__lv=$this-&gt;_%s($e%s);&#39;</span>;
<a name="l01127"></a>01127   $ifChangedCode .= <span class="stringliteral">&#39;if($__lv!==false){$b.=$__lv;}&#39;</span>;
<a name="l01128"></a>01128   $ifChangedCode .= ($elseNodes ? <span class="stringliteral">&#39;else{&#39;</span>.$compiler-&gt;handleChildren($elseNodes).<span class="charliteral">&#39;}&#39;</span> : <span class="stringliteral">&#39;&#39;</span>).<span class="stringliteral">&#39;unset($__lv);&#39;</span>;
<a name="l01129"></a>01129   
<a name="l01130"></a>01130   <span class="keywordflow">if</span> (count($args) == 0) {
<a name="l01131"></a>01131    <span class="comment">// we compare rendered result of this block</span>
<a name="l01132"></a>01132    <span class="comment">//</span>
<a name="l01133"></a>01133    <span class="comment">// $lb is contents of the block after last call</span>
<a name="l01134"></a>01134 
<a name="l01135"></a>01135    $ifBlockArgs  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l01136"></a>01136    $ifBlockCode  = <span class="stringliteral">&#39;static $lb=\&#39;\&#39;;$b=\&#39;\&#39;;&#39;</span>.$ifBlockBody;
<a name="l01137"></a>01137    $ifBlockCode .= <span class="stringliteral">&#39;if($b!=$lb){$lb=$b;return $b;}else{return false;}&#39;</span>;
<a name="l01138"></a>01138   } <span class="keywordflow">else</span> {
<a name="l01139"></a>01139    <span class="comment">// we compare values of given variables</span>
<a name="l01140"></a>01140    <span class="comment">// this variant of {% ifchanged %} might be repeated, so</span>
<a name="l01141"></a>01141    <span class="comment">// unique block name is required</span>
<a name="l01142"></a>01142    <span class="comment">//</span>
<a name="l01143"></a>01143    <span class="comment">// $vs is array of already captured variables</span>
<a name="l01144"></a>01144    
<a name="l01145"></a>01145    $ifBlockName = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0cee437cbd376a2ad926de8b745e120c" title="Generates prefixed block name that is guaranteed to be unique in current template.">generateUniqueBlock</a>(implode(<span class="charliteral">&#39;;&#39;</span>, $args), $ifBlockName.<span class="charliteral">&#39;:&#39;</span>);
<a name="l01146"></a>01146    $ifBlockCode = <span class="stringliteral">&#39;static $vs=array(&#39;</span>.implode(<span class="charliteral">&#39;,&#39;</span>, array_fill(0, count($args), <span class="stringliteral">&#39;null&#39;</span>)).<span class="stringliteral">&#39;);if(&#39;</span>;
<a name="l01147"></a>01147    
<a name="l01148"></a>01148    <span class="keywordflow">foreach</span> ($args as $idx =&gt; &amp;$arg) {
<a name="l01149"></a>01149     list($arg, $check) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $arg);
<a name="l01150"></a>01150     $ifChangedCode     = $check.$ifChangedCode;
<a name="l01151"></a>01151     
<a name="l01152"></a>01152     $ifBlockCode .= <span class="stringliteral">&#39;($vs[&#39;</span>.$idx.<span class="stringliteral">&#39;]!=func_get_arg(&#39;</span>.($idx + 1).<span class="stringliteral">&#39;))&amp;&amp;&#39;</span>;
<a name="l01153"></a>01153    }
<a name="l01154"></a>01154    
<a name="l01155"></a>01155    $ifBlockCode  = mb_substr($ifBlockCode, 0, -2).<span class="stringliteral">&#39;){&#39;</span>;
<a name="l01156"></a>01156    $ifBlockCode .= <span class="stringliteral">&#39;$nvs=func_get_args();$vs=array_slice($nvs,1);unset($nvs);&#39;</span>;
<a name="l01157"></a>01157    $ifBlockCode .= <span class="stringliteral">&#39;$b=\&#39;\&#39;;&#39;</span>.$ifBlockBody.<span class="stringliteral">&#39;return $b;}else{return false;}&#39;</span>;
<a name="l01158"></a>01158    $ifBlockArgs  = <span class="charliteral">&#39;,&#39;</span>.implode(<span class="charliteral">&#39;,&#39;</span>, $args);
<a name="l01159"></a>01159   }
<a name="l01160"></a>01160 
<a name="l01161"></a>01161   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01162"></a>01162    (isset($compiler-&gt;blocks[$ifBlockName])),
<a name="l01163"></a>01163    $node,
<a name="l01164"></a>01164    <span class="stringliteral">&#39;Repeated &quot;ifchanged&quot; block within same loop&#39;</span>,
<a name="l01165"></a>01165    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01166"></a>01166   );
<a name="l01167"></a>01167   
<a name="l01168"></a>01168 
<a name="l01169"></a>01169   $compiler-&gt;blocks[$ifBlockName] = $ifBlockCode;
<a name="l01170"></a>01170   
<a name="l01171"></a>01171   <span class="keywordflow">return</span> sprintf($ifChangedCode, <a class="code" href="class_template_utils.html#aeadcc7d717f5752474ab611bd45cfd7b" title="Sanitize string, for use as function name.">TemplateUtils::sanitize</a>($ifBlockName), $ifBlockArgs);
<a name="l01172"></a>01172  }
<a name="l01173"></a>01173  
<a name="l01175"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a103477d31f461d7862f7f50239be75c1">01175</a>  <span class="keyword">private</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a103477d31f461d7862f7f50239be75c1">parseIfExpressionNonEmpty</a>($x) { <span class="keywordflow">return</span> trim($x) != <span class="stringliteral">&#39;&#39;</span>; }
<a name="l01176"></a>01176  
<a name="l01178"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a107851f550d866d79bb8f1766266810e">01178</a>  <span class="keyword">private</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a107851f550d866d79bb8f1766266810e">parseIfExpressionCheckParens</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, $level, $final = <span class="keyword">false</span>) {
<a name="l01179"></a>01179   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01180"></a>01180    (($final &amp;&amp; ($level &gt; 0)) || $level &lt; 0),
<a name="l01181"></a>01181    $node,
<a name="l01182"></a>01182    <span class="stringliteral">&#39;Unbalanced parenthesis - too much &#39;</span>.($final ? <span class="stringliteral">&#39;opening&#39;</span> : <span class="stringliteral">&#39;closing&#39;</span>).<span class="stringliteral">&#39; parens (&#39;</span>.
<a name="l01183"></a>01183    strval(($final ? $level : -$level)).<span class="charliteral">&#39;)&#39;</span>,
<a name="l01184"></a>01184    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01185"></a>01185   );
<a name="l01186"></a>01186  }
<a name="l01187"></a>01187  
<a name="l01192"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a30241ff53a46ba258499171666ed07ae">01192</a>  <span class="keyword">private</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a30241ff53a46ba258499171666ed07ae">parseIfExpression</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, $expression) {
<a name="l01193"></a>01193   $tokens = array_filter(
<a name="l01194"></a>01194    preg_split(
<a name="l01195"></a>01195     <span class="stringliteral">&#39;/(\&quot;.+?\&quot;)|([()])|([^\s()]+)/u&#39;</span>, $expression, -1,
<a name="l01196"></a>01196     PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
<a name="l01197"></a>01197    ),
<a name="l01198"></a>01198    array($this, <span class="stringliteral">&#39;parseIfExpressionNonEmpty&#39;</span>)
<a name="l01199"></a>01199   );
<a name="l01200"></a>01200   
<a name="l01201"></a>01201   $code  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l01202"></a>01202   $level = 0;
<a name="l01203"></a>01203   
<a name="l01204"></a>01204   <span class="comment">// syntax checking</span>
<a name="l01205"></a>01205   $_operators    = array(<span class="stringliteral">&#39;eq&#39;</span>,<span class="stringliteral">&#39;neq&#39;</span>,<span class="stringliteral">&#39;lt&#39;</span>,<span class="stringliteral">&#39;lte&#39;</span>,<span class="stringliteral">&#39;gt&#39;</span>,<span class="stringliteral">&#39;gte&#39;</span>,<span class="stringliteral">&#39;and&#39;</span>,<span class="stringliteral">&#39;or&#39;</span>,<span class="stringliteral">&#39;id&#39;</span>,<span class="stringliteral">&#39;nid&#39;</span>);
<a name="l01206"></a>01206   $_parentheses  = array(<span class="charliteral">&#39;(&#39;</span>,<span class="charliteral">&#39;)&#39;</span>);
<a name="l01207"></a>01207   $_allowedCheck = array_merge($_parentheses, $_operators, array(<span class="stringliteral">&#39;not&#39;</span>));
<a name="l01208"></a>01208   $nextAllowed   = array_merge($_parentheses, array(<span class="stringliteral">&#39;variable&#39;</span>, <span class="stringliteral">&#39;not&#39;</span>));
<a name="l01209"></a>01209   
<a name="l01210"></a>01210   <span class="comment">// process tokens</span>
<a name="l01211"></a>01211   <span class="keywordflow">foreach</span> ($tokens as &amp;$token) {
<a name="l01212"></a>01212    $check = (
<a name="l01213"></a>01213     (in_array($token, $_allowedCheck) &amp;&amp; !in_array($token, $nextAllowed)) ||
<a name="l01214"></a>01214     (!in_array($token, $_allowedCheck) &amp;&amp; !in_array(<span class="stringliteral">&#39;variable&#39;</span>, $nextAllowed))
<a name="l01215"></a>01215    );
<a name="l01216"></a>01216    
<a name="l01217"></a>01217    $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01218"></a>01218     $check,
<a name="l01219"></a>01219     $node,
<a name="l01220"></a>01220     <span class="stringliteral">&#39;Unexpected &quot;&#39;</span>.$token.<span class="stringliteral">&#39;&quot;, expected one of: &#39;</span>.implode(<span class="stringliteral">&#39;, &#39;</span>, $nextAllowed),
<a name="l01221"></a>01221     <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01222"></a>01222    );
<a name="l01223"></a>01223    
<a name="l01224"></a>01224    <span class="keywordflow">if</span> (in_array($token, $_parentheses)) {
<a name="l01225"></a>01225 
<a name="l01226"></a>01226     <span class="comment">// encountered parenthesis</span>
<a name="l01227"></a>01227     <span class="keywordflow">if</span> ($token == <span class="charliteral">&#39;(&#39;</span>) { <span class="comment">// open sub-expr</span>
<a name="l01228"></a>01228 
<a name="l01229"></a>01229      ++$level;
<a name="l01230"></a>01230      $code .= <span class="charliteral">&#39;(&#39;</span>;
<a name="l01231"></a>01231      $nextAllowed = array(<span class="stringliteral">&#39;variable&#39;</span>, <span class="stringliteral">&#39;not&#39;</span>, <span class="charliteral">&#39;(&#39;</span>);
<a name="l01232"></a>01232 
<a name="l01233"></a>01233     } <span class="keywordflow">else</span> { <span class="comment">// close sub-expr</span>
<a name="l01234"></a>01234 
<a name="l01235"></a>01235      $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#a107851f550d866d79bb8f1766266810e">parseIfExpressionCheckParens</a>($compiler, $node, --$level);
<a name="l01236"></a>01236      $code .= <span class="charliteral">&#39;)&#39;</span>;
<a name="l01237"></a>01237      $nextAllowed = array_merge($_operators, array(<span class="charliteral">&#39;)&#39;</span>));
<a name="l01238"></a>01238 
<a name="l01239"></a>01239     }
<a name="l01240"></a>01240 
<a name="l01241"></a>01241    } elseif (in_array($token, $_operators)) {
<a name="l01242"></a>01242 
<a name="l01243"></a>01243     <span class="comment">// encountered operator (except &quot;not&quot;)</span>
<a name="l01244"></a>01244     <span class="keywordflow">switch</span> ($token) {
<a name="l01245"></a>01245      <span class="keywordflow">case</span> <span class="stringliteral">&#39;eq&#39;</span>:  $code .= <span class="stringliteral">&#39;==&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// equals</span>
<a name="l01246"></a>01246      <span class="keywordflow">case</span> <span class="stringliteral">&#39;neq&#39;</span>: $code .= <span class="stringliteral">&#39;!=&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// not equals</span>
<a name="l01247"></a>01247      <span class="keywordflow">case</span> <span class="stringliteral">&#39;lt&#39;</span>:  $code .= <span class="charliteral">&#39;&lt;&#39;</span>;   <span class="keywordflow">break</span>; <span class="comment">// less than</span>
<a name="l01248"></a>01248      <span class="keywordflow">case</span> <span class="stringliteral">&#39;lte&#39;</span>: $code .= <span class="stringliteral">&#39;&lt;=&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// less than or equals</span>
<a name="l01249"></a>01249      <span class="keywordflow">case</span> <span class="stringliteral">&#39;gt&#39;</span>:  $code .= <span class="charliteral">&#39;&gt;&#39;</span>;   <span class="keywordflow">break</span>; <span class="comment">// greater than</span>
<a name="l01250"></a>01250      <span class="keywordflow">case</span> <span class="stringliteral">&#39;gte&#39;</span>: $code .= <span class="stringliteral">&#39;&gt;=&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// greater than or equals</span>
<a name="l01251"></a>01251      <span class="keywordflow">case</span> <span class="stringliteral">&#39;and&#39;</span>: $code .= <span class="stringliteral">&#39;&amp;&amp;&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// logical and</span>
<a name="l01252"></a>01252      <span class="keywordflow">case</span> <span class="stringliteral">&#39;or&#39;</span>:  $code .= <span class="stringliteral">&#39;||&#39;</span>;  <span class="keywordflow">break</span>; <span class="comment">// logical or</span>
<a name="l01253"></a>01253      <span class="keywordflow">case</span> <span class="stringliteral">&#39;id&#39;</span>:  $code .= <span class="stringliteral">&#39;===&#39;</span>; <span class="keywordflow">break</span>; <span class="comment">// is identical</span>
<a name="l01254"></a>01254      <span class="keywordflow">case</span> <span class="stringliteral">&#39;nid&#39;</span>: $code .= <span class="stringliteral">&#39;!==&#39;</span>; <span class="keywordflow">break</span>; <span class="comment">// is not identical</span>
<a name="l01255"></a>01255     }
<a name="l01256"></a>01256     
<a name="l01257"></a>01257     $nextAllowed = array(<span class="stringliteral">&#39;variable&#39;</span>, <span class="stringliteral">&#39;not&#39;</span>, <span class="charliteral">&#39;(&#39;</span>);
<a name="l01258"></a>01258 
<a name="l01259"></a>01259    } elseif ($token == <span class="stringliteral">&#39;not&#39;</span>) {
<a name="l01260"></a>01260 
<a name="l01261"></a>01261     <span class="comment">// encountered &quot;not&quot;</span>
<a name="l01262"></a>01262     $code .= <span class="charliteral">&#39;!&#39;</span>;
<a name="l01263"></a>01263     $nextAllowed = array_merge($_operators, array(<span class="stringliteral">&#39;variable&#39;</span>, <span class="charliteral">&#39;(&#39;</span>));
<a name="l01264"></a>01264 
<a name="l01265"></a>01265    } <span class="keywordflow">else</span> {
<a name="l01266"></a>01266 
<a name="l01267"></a>01267     <span class="comment">// encountered variable or literal value</span>
<a name="l01268"></a>01268     <span class="keywordflow">if</span> (mb_substr($token, 0, 1) == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l01269"></a>01269 
<a name="l01270"></a>01270      <span class="comment">// literal string</span>
<a name="l01271"></a>01271      $code .= <span class="charliteral">&#39;\&#39;&#39;</span>.mb_substr($token, 1, -1).<span class="charliteral">&#39;\&#39;&#39;</span>;
<a name="l01272"></a>01272 
<a name="l01273"></a>01273     } elseif (preg_match(<span class="stringliteral">&#39;/^[0-9]+(.[0-9]+)?$/&#39;</span>, $token)) {
<a name="l01274"></a>01274 
<a name="l01275"></a>01275      <span class="comment">// integer/float</span>
<a name="l01276"></a>01276      $code .= $token;
<a name="l01277"></a>01277 
<a name="l01278"></a>01278     } <span class="keywordflow">else</span> {
<a name="l01279"></a>01279 
<a name="l01280"></a>01280      <span class="comment">// variable</span>
<a name="l01281"></a>01281      list($variable, $filters) = <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">TemplateUtils::split</a>(<span class="charliteral">&#39;|&#39;</span>, $token);
<a name="l01282"></a>01282      list($variable,)          = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $variable);
<a name="l01283"></a>01283      $variable                 = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0e954efa4b344518798797fe3bc6dd14" title="Handles filter chains.">parseFilterChain</a>($node, $filters, <span class="charliteral">&#39;@&#39;</span>.$variable);
<a name="l01284"></a>01284      
<a name="l01285"></a>01285      $code .= $variable;
<a name="l01286"></a>01286 
<a name="l01287"></a>01287     }
<a name="l01288"></a>01288 
<a name="l01289"></a>01289     $nextAllowed = array_merge($_operators, array(<span class="charliteral">&#39;)&#39;</span>));
<a name="l01290"></a>01290 
<a name="l01291"></a>01291    }
<a name="l01292"></a>01292   }
<a name="l01293"></a>01293   
<a name="l01294"></a>01294   $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#a107851f550d866d79bb8f1766266810e">parseIfExpressionCheckParens</a>($compiler, $node, $level, <span class="keyword">true</span>);
<a name="l01295"></a>01295 
<a name="l01296"></a>01296   <span class="keywordflow">return</span> $code;
<a name="l01297"></a>01297  }
<a name="l01298"></a>01298  
<a name="l01300"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a057b22904c107667f092f0229e81c1ea">01300</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a057b22904c107667f092f0229e81c1ea" title="{% if %} tag.">handleTIf</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01301"></a>01301   <span class="keywordflow">return</span>
<a name="l01302"></a>01302    <span class="stringliteral">&#39;if(&#39;</span>.$this-&gt;parseIfExpression($compiler, $node, implode(<span class="charliteral">&#39; &#39;</span>, $args)).<span class="stringliteral">&#39;){&#39;</span>.
<a name="l01303"></a>01303    $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($node-&gt;nodeChildren).
<a name="l01304"></a>01304    <span class="charliteral">&#39;}&#39;</span>;
<a name="l01305"></a>01305  }
<a name="l01306"></a>01306  
<a name="l01308"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a96b52b2c79ff7c7989669edaf081c8d2">01308</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a96b52b2c79ff7c7989669edaf081c8d2" title="{% else %} tag.">handleTElse</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01309"></a>01309   <span class="comment">// if it&#39;s {% ifchanged %} ... {% else %} ... {% endif %}</span>
<a name="l01310"></a>01310   <span class="comment">// then it should work like {% empty %}, and this handler should not be called</span>
<a name="l01311"></a>01311   <span class="keywordflow">if</span> ($node-&gt;nodeParent-&gt;nodeContent[0] == <span class="stringliteral">&#39;ifchanged&#39;</span>) <a class="code" href="class_template_utils.html#a9756a1cc5232e00302a0b52c3a1e8e10" title="Panics.">TemplateUtils::panic</a>(__FILE__, __LINE__);
<a name="l01312"></a>01312   <span class="keywordflow">return</span> <span class="stringliteral">&#39;}else{&#39;</span>;
<a name="l01313"></a>01313  }
<a name="l01314"></a>01314  
<a name="l01316"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a1a9e1da3b6fe94a91df5bd07887b6686">01316</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a1a9e1da3b6fe94a91df5bd07887b6686" title="{% elseif %} tag.">handleTElseIf</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01317"></a>01317   <span class="keywordflow">return</span> <span class="stringliteral">&#39;}elseif(&#39;</span>.$this-&gt;parseIfExpression($compiler, $node, implode(<span class="charliteral">&#39; &#39;</span>, $args)).<span class="stringliteral">&#39;){&#39;</span>;
<a name="l01318"></a>01318  }
<a name="l01319"></a>01319  
<a name="l01321"></a><a class="code" href="class_template_std_lib_ex_plugin.html#af395e0a8476316ced46da05d0cfcadda">01321</a>  <span class="keyword">private</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#af395e0a8476316ced46da05d0cfcadda">commonIfEqual</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, array $variables, $operator) {
<a name="l01322"></a>01322   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01323"></a>01323    (count($variables) != 2),
<a name="l01324"></a>01324    $node,
<a name="l01325"></a>01325    <span class="stringliteral">&#39;Invalid argument count - both &quot;ifequal&quot; and &quot;ifnotequal&quot; require 2 exactly&#39;</span>,
<a name="l01326"></a>01326    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01327"></a>01327   );
<a name="l01328"></a>01328   
<a name="l01329"></a>01329   <span class="keywordflow">foreach</span> ($variables as &amp;$variable) {
<a name="l01330"></a>01330    list($variable, $filters) = <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">TemplateUtils::split</a>(<span class="charliteral">&#39;|&#39;</span>, $variable);
<a name="l01331"></a>01331    list($code, $check)       = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $variable);
<a name="l01332"></a>01332    $variable                 = array($compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0e954efa4b344518798797fe3bc6dd14" title="Handles filter chains.">parseFilterChain</a>($node, $filters, <span class="charliteral">&#39;@&#39;</span>.$code), $check);
<a name="l01333"></a>01333   }
<a name="l01334"></a>01334   
<a name="l01335"></a>01335   $check  = $variables[0][1].$variables[1][1];
<a name="l01336"></a>01336   $code   = <span class="stringliteral">&#39;if(&#39;</span>.$variables[0][0].$operator.$variables[1][0].<span class="stringliteral">&#39;){&#39;</span>;
<a name="l01337"></a>01337   $code  .= $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($node-&gt;nodeChildren).<span class="charliteral">&#39;}&#39;</span>;
<a name="l01338"></a>01338   <span class="keywordflow">return</span> $check.$code;
<a name="l01339"></a>01339  }
<a name="l01340"></a>01340  
<a name="l01342"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a2dea793d7a967ada5b15199e1a4752db">01342</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a2dea793d7a967ada5b15199e1a4752db" title="{% ifequal %} tag.">handleTIfEqual</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01343"></a>01343   <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#af395e0a8476316ced46da05d0cfcadda">commonIfEqual</a>($compiler, $node, $args, <span class="stringliteral">&#39;==&#39;</span>);
<a name="l01344"></a>01344  }
<a name="l01345"></a>01345  
<a name="l01347"></a><a class="code" href="class_template_std_lib_ex_plugin.html#adeed39913c34e69ddc5bdc6b01640f28">01347</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#adeed39913c34e69ddc5bdc6b01640f28" title="{% ifnotequal %} tag.">handleTIfNotEqual</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01348"></a>01348   <span class="keywordflow">return</span> $this-&gt;<a class="code" href="class_template_std_lib_ex_plugin.html#af395e0a8476316ced46da05d0cfcadda">commonIfEqual</a>($compiler, $node, $args, <span class="stringliteral">&#39;!=&#39;</span>);
<a name="l01349"></a>01349  }
<a name="l01350"></a>01350  
<a name="l01352"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ae95c19fce3f1344cd390c5b59ffe015d">01352</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#ae95c19fce3f1344cd390c5b59ffe015d" title="{% include %} tag.">handleTInclude</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01353"></a>01353   $code  = <span class="stringliteral">&#39;$__io=%s;TemplateUtils::checkIORestriction($e,\&#39;restrictIncludeIO\&#39;,$__io,%s);&#39;</span>;
<a name="l01354"></a>01354   $code .= <span class="stringliteral">&#39;$b.=$e-&gt;cachedGet($__io)-&gt;render($this-&gt;ctx,$e);unset($__io);&#39;</span>;
<a name="l01355"></a>01355   
<a name="l01356"></a>01356   <span class="keywordflow">if</span> (mb_substr($args[0], 0, 1) == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l01357"></a>01357    $varCode  = <span class="charliteral">&#39;\&#39;&#39;</span>.TemplateUtils::escape(mb_substr($args[0], 1, -1)).<span class="charliteral">&#39;\&#39;&#39;</span>;
<a name="l01358"></a>01358    $varCheck = <span class="stringliteral">&#39;&#39;</span>;
<a name="l01359"></a>01359   } <span class="keywordflow">else</span> {
<a name="l01360"></a>01360    list($varCode, $varCheck) = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $args[0]);
<a name="l01361"></a>01361   }
<a name="l01362"></a>01362   
<a name="l01363"></a>01363   $code = $varCheck.sprintf($code, $varCode, <span class="charliteral">&#39;\&#39;&#39;</span>.<a class="code" href="class_template_utils.html#aa3553ef2c1e54e0e99ad38a7fe931efa" title="Escape string to use in template class.">TemplateUtils::escape</a>($compiler-&gt;metadata[<span class="stringliteral">&#39;usedIO&#39;</span>]).<span class="charliteral">&#39;\&#39;&#39;</span>);
<a name="l01364"></a>01364   
<a name="l01365"></a>01365   <span class="keywordflow">return</span> $code;
<a name="l01366"></a>01366  }
<a name="l01367"></a>01367  
<a name="l01369"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a081a1e7799bf2224bc47427e046d236a">01369</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a081a1e7799bf2224bc47427e046d236a" title="{% now %} tag.">handleTNow</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01370"></a>01370   <span class="keywordflow">if</span> (mb_substr($args[0], 0, 1) == <span class="charliteral">&#39;&quot;&#39;</span>) {
<a name="l01371"></a>01371    $format = <span class="charliteral">&#39;\&#39;&#39;</span>.TemplateUtils::escape(mb_substr($args[0], 1, -1)).<span class="charliteral">&#39;\&#39;&#39;</span>;
<a name="l01372"></a>01372    $check  = <span class="stringliteral">&#39;&#39;</span>;
<a name="l01373"></a>01373   } <span class="keywordflow">else</span> {
<a name="l01374"></a>01374    list($variable, $filters) = <a class="code" href="class_template_utils.html#ad8600ee16ab4bcfc0575696c8e2520d2" title="Split string into two.">TemplateUtils::split</a>(<span class="charliteral">&#39;|&#39;</span>, $args[0]);
<a name="l01375"></a>01375    list($variable, $check)   = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a8efc4fef1f377e69631fe3de4c2033e3" title="Parses variable expression, and creates runtime PHP access code.">parseVariableExpression</a>($node, $variable);
<a name="l01376"></a>01376    $format                   = $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a0e954efa4b344518798797fe3bc6dd14" title="Handles filter chains.">parseFilterChain</a>($node, $filters, <span class="charliteral">&#39;@&#39;</span>.$variable);
<a name="l01377"></a>01377   }
<a name="l01378"></a>01378   
<a name="l01379"></a>01379   <span class="keywordflow">return</span> $check.sprintf(<span class="stringliteral">&#39;$b.=date(%s);&#39;</span>, $format);
<a name="l01380"></a>01380  }
<a name="l01381"></a>01381  
<a name="l01383"></a><a class="code" href="class_template_std_lib_ex_plugin.html#acd849b68b6a11b6695f18ebf1961b7f6">01383</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#acd849b68b6a11b6695f18ebf1961b7f6" title="{% spaceless %} tag.">handleTSpaceless</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01384"></a>01384   <span class="keywordflow">foreach</span> ($node-&gt;nodeChildren as &amp;$childNode) {
<a name="l01385"></a>01385    <span class="keywordflow">if</span> ($childNode-&gt;nodeID == <span class="stringliteral">&#39;text&#39;</span>) {
<a name="l01386"></a>01386     $childNode-&gt;nodeContent = preg_replace(<span class="stringliteral">&#39;/&gt;\s+&lt;/s&#39;</span>, <span class="stringliteral">&#39;&gt;&lt;&#39;</span>, $childNode-&gt;nodeContent);
<a name="l01387"></a>01387    }
<a name="l01388"></a>01388   }
<a name="l01389"></a>01389   
<a name="l01390"></a>01390   <span class="keywordflow">return</span> $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#a91899408f7ddf3173a8932bb8277aad7" title="Generates code from given node&amp;#39;s children.">handleChildren</a>($node-&gt;nodeChildren);
<a name="l01391"></a>01391  }
<a name="l01392"></a>01392  
<a name="l01394"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a2752cc72521032378ee80a2d750f958c">01394</a>  <span class="keyword">public</span> function <a class="code" href="class_template_std_lib_ex_plugin.html#a2752cc72521032378ee80a2d750f958c" title="{% templatetag %} tag.">handleTTemplateTag</a>(<a class="code" href="class_template_compiler_ex.html" title="Primary compiler driver.">TemplateCompilerEx</a> $compiler, <a class="code" href="class_template_node_ex.html" title="Class-container for AST nodes.">TemplateNodeEx</a> $node, &amp;$tag, array &amp;$args) {
<a name="l01395"></a>01395   <span class="keyword">static</span> $openTag       = array(<span class="stringliteral">&#39;openblock&#39;</span>, <span class="stringliteral">&#39;ob&#39;</span>, <span class="stringliteral">&#39;opentag&#39;</span>, <span class="stringliteral">&#39;ot&#39;</span>);
<a name="l01396"></a>01396   <span class="keyword">static</span> $openVariable  = array(<span class="stringliteral">&#39;openvariable&#39;</span>, <span class="stringliteral">&#39;openvar&#39;</span>, <span class="stringliteral">&#39;ov&#39;</span>);
<a name="l01397"></a>01397   <span class="keyword">static</span> $openComment   = array(<span class="stringliteral">&#39;opencomment&#39;</span>, <span class="stringliteral">&#39;oc&#39;</span>);
<a name="l01398"></a>01398   <span class="keyword">static</span> $closeTag      = array(<span class="stringliteral">&#39;closeblock&#39;</span>, <span class="stringliteral">&#39;cb&#39;</span>, <span class="stringliteral">&#39;closetag&#39;</span>, <span class="stringliteral">&#39;ct&#39;</span>);
<a name="l01399"></a>01399   <span class="keyword">static</span> $closeVariable = array(<span class="stringliteral">&#39;closevariable&#39;</span>, <span class="stringliteral">&#39;closevar&#39;</span>, <span class="stringliteral">&#39;cv&#39;</span>);
<a name="l01400"></a>01400   <span class="keyword">static</span> $closeComment  = array(<span class="stringliteral">&#39;closecomment&#39;</span>, <span class="stringliteral">&#39;cc&#39;</span>);
<a name="l01401"></a>01401   <span class="keyword">static</span> $map           = null;
<a name="l01402"></a>01402   
<a name="l01403"></a>01403   <span class="keywordflow">if</span> (!$map) {
<a name="l01404"></a>01404    $map = array_merge(
<a name="l01405"></a>01405     <span class="comment">// replaced array_fill_keys with array_combine/array_fill combination</span>
<a name="l01406"></a>01406     <span class="comment">// for compatibility with PHP 5.1</span>
<a name="l01407"></a>01407     <span class="comment">// http://pl.php.net/manual/pl/function.array-fill-keys.php#83962</span>
<a name="l01408"></a>01408     array_combine($openTag,       array_fill(0, count($openTag),       <span class="stringliteral">&#39;{%&#39;</span>)),
<a name="l01409"></a>01409     array_combine($openVariable,  array_fill(0, count($openVariable),  <span class="stringliteral">&#39;{{&#39;</span>)),
<a name="l01410"></a>01410     array_combine($openComment,   array_fill(0, count($openComment),   <span class="stringliteral">&#39;{#&#39;</span>)),
<a name="l01411"></a>01411     array_combine($closeTag,      array_fill(0, count($closeTag),      <span class="stringliteral">&#39;%}&#39;</span>)),
<a name="l01412"></a>01412     array_combine($closeVariable, array_fill(0, count($closeVariable), <span class="stringliteral">&#39;}}&#39;</span>)),
<a name="l01413"></a>01413     array_combine($closeComment,  array_fill(0, count($closeComment),  <span class="stringliteral">&#39;#}&#39;</span>)),
<a name="l01414"></a>01414     array(<span class="stringliteral">&#39;openbrace&#39;</span> =&gt; <span class="charliteral">&#39;{&#39;</span>, <span class="stringliteral">&#39;closebrace&#39;</span> =&gt; <span class="charliteral">&#39;}&#39;</span>) <span class="comment">// added in 1.1a2</span>
<a name="l01415"></a>01415    );
<a name="l01416"></a>01416   }
<a name="l01417"></a>01417   
<a name="l01418"></a>01418   $tag = &amp;$args[0];
<a name="l01419"></a>01419   
<a name="l01420"></a>01420   $compiler-&gt;<a class="code" href="class_template_compiler_ex.html#af8bc3411f0f8bcfbd153a8d56f0ae2e7" title="Shorthand for conditional call to TemplateCompilerEx::raise.">raiseIf</a>(
<a name="l01421"></a>01421    (!isset($map[$tag])),
<a name="l01422"></a>01422    $node,
<a name="l01423"></a>01423    <span class="stringliteral">&#39;Invalid &quot;templatetag&quot; argument - expected one of: &#39;</span>.implode(<span class="stringliteral">&#39;, &#39;</span>, array_keys($map)),
<a name="l01424"></a>01424    <a class="code" href="class_template_error.html#aa33bae77cab676e7fcf3daf9ac6d3fd0" title="An invalid argument error.">TemplateError::E_INVALID_ARGUMENT</a>
<a name="l01425"></a>01425   );
<a name="l01426"></a>01426   
<a name="l01427"></a>01427   <span class="keywordflow">return</span> <span class="stringliteral">&#39;$b.=\&#39;&#39;</span>.$map[$tag].<span class="charliteral">&#39;\&#39;</span>;<span class="stringliteral">&#39;;</span>
<a name="l01428"></a>01428 <span class="stringliteral"> }</span>
<a name="l01429"></a>01429 <span class="stringliteral"> </span>
<a name="l01431"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a8bd354521870fe4e4708fe0ba870c90f">01431</a> <span class="stringliteral"> public function handleTWidthRatio(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$tag, array &amp;$args) {</span>
<a name="l01432"></a>01432 <span class="stringliteral">  $allCheck  = &#39;</span><span class="stringliteral">&#39;;</span>
<a name="l01433"></a>01433 <span class="stringliteral">  $widthCode = &#39;</span>$b.=strval(round((<span class="stringliteral">&#39;;</span>
<a name="l01434"></a>01434 <span class="stringliteral">  </span>
<a name="l01435"></a>01435 <span class="stringliteral">  for ($i = 0; $i &lt; 2; ++$i) {</span>
<a name="l01436"></a>01436 <span class="stringliteral">   if (preg_match(&#39;</span>/^[0-9]+(\.[0-9]+)?$/<span class="stringliteral">&#39;, $args[$i])) {</span>
<a name="l01437"></a>01437 <span class="stringliteral">    $widthCode .= $args[$i];</span>
<a name="l01438"></a>01438 <span class="stringliteral">   } else {</span>
<a name="l01439"></a>01439 <span class="stringliteral">    list($variable, $filters) = TemplateUtils::split(&#39;</span>|<span class="stringliteral">&#39;, $args[$i]);</span>
<a name="l01440"></a>01440 <span class="stringliteral">    list($variable, $check)   = $compiler-&gt;parseVariableExpression($node, $variable);</span>
<a name="l01441"></a>01441 <span class="stringliteral">    $allCheck  .= $check;</span>
<a name="l01442"></a>01442 <span class="stringliteral">    $widthCode .= $compiler-&gt;parseFilterChain($node, $filters, &#39;</span>@<span class="stringliteral">&#39;.$variable);</span>
<a name="l01443"></a>01443 <span class="stringliteral">   }</span>
<a name="l01444"></a>01444 <span class="stringliteral">   $widthCode .= &#39;</span>/<span class="stringliteral">&#39;;</span>
<a name="l01445"></a>01445 <span class="stringliteral">  }</span>
<a name="l01446"></a>01446 <span class="stringliteral">  </span>
<a name="l01447"></a>01447 <span class="stringliteral">  $compiler-&gt;raiseIf(</span>
<a name="l01448"></a>01448 <span class="stringliteral">   (!preg_match(&#39;</span>/^[0-9]+$/<span class="stringliteral">&#39;, $args[2])),</span>
<a name="l01449"></a>01449 <span class="stringliteral">   $node,</span>
<a name="l01450"></a>01450 <span class="stringliteral">   &#39;</span>Last argument of <span class="stringliteral">&quot;widthratio&quot;</span> must be integer constant<span class="stringliteral">&#39;,</span>
<a name="l01451"></a>01451 <span class="stringliteral">   TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01452"></a>01452 <span class="stringliteral">  );</span>
<a name="l01453"></a>01453 <span class="stringliteral">  </span>
<a name="l01454"></a>01454 <span class="stringliteral">  return mb_substr($widthCode, 0, -1).&#39;</span>)*<span class="stringliteral">&#39;.$args[2].&#39;</span>));<span class="stringliteral">&#39;;</span>
<a name="l01455"></a>01455 <span class="stringliteral"> }</span>
<a name="l01456"></a>01456 <span class="stringliteral"> </span>
<a name="l01458"></a><a class="code" href="class_template_std_lib_ex_plugin.html#aa365412e7382b58938fd5f4163e36409">01458</a> <span class="stringliteral"> public function handleTWith(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$tag, array &amp;$args) {</span>
<a name="l01459"></a>01459 <span class="stringliteral">  $withBlockName = $compiler-&gt;generateUniqueBlock($args[0].$args[2], &#39;</span>with:<span class="stringliteral">&#39;);</span>
<a name="l01460"></a>01460 <span class="stringliteral">  </span>
<a name="l01461"></a>01461 <span class="stringliteral">  $compiler-&gt;raiseIf(</span>
<a name="l01462"></a>01462 <span class="stringliteral">   ($args[1] != &#39;</span>as<span class="stringliteral">&#39;),</span>
<a name="l01463"></a>01463 <span class="stringliteral">   $node,</span>
<a name="l01464"></a>01464 <span class="stringliteral">   &#39;</span>Second <span class="stringliteral">&quot;with&quot;</span> parameter must be literal <span class="stringliteral">&quot;as&quot;</span><span class="stringliteral">&#39;,</span>
<a name="l01465"></a>01465 <span class="stringliteral">   TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01466"></a>01466 <span class="stringliteral">  );</span>
<a name="l01467"></a>01467 <span class="stringliteral">  </span>
<a name="l01468"></a>01468 <span class="stringliteral">  $compiler-&gt;blocks[$withBlockName] = &#39;</span>$b=\<span class="charliteral">&#39;\&#39;</span>;<span class="stringliteral">&#39;;</span>
<a name="l01469"></a>01469 <span class="stringliteral">  list($variable, $filters) = TemplateUtils::split(&#39;</span>|<span class="stringliteral">&#39;, $args[0]);</span>
<a name="l01470"></a>01470 <span class="stringliteral">  list($variable, $check)   = $compiler-&gt;parseVariableExpression($node, $variable);</span>
<a name="l01471"></a>01471 <span class="stringliteral">  $variable                 = $compiler-&gt;parseFilterChain($node, $filters, &#39;</span>@<span class="stringliteral">&#39;.$variable);</span>
<a name="l01472"></a>01472 <span class="stringliteral">  </span>
<a name="l01473"></a>01473 <span class="stringliteral">  $compiler-&gt;blocks[$withBlockName] .= $check.&#39;</span>$this-&gt;ctx[\<span class="stringliteral">&#39;&#39;</span>.$args[2].<span class="charliteral">&#39;\&#39;</span>]=<span class="stringliteral">&#39;;</span>
<a name="l01474"></a>01474 <span class="stringliteral">  $compiler-&gt;blocks[$withBlockName] .= $variable.&#39;</span>;<span class="stringliteral">&#39;.$compiler-&gt;handleChildren($node-&gt;nodeChildren);</span>
<a name="l01475"></a>01475 <span class="stringliteral">  $compiler-&gt;blocks[$withBlockName] .= &#39;</span>unset($this-&gt;ctx[\<span class="stringliteral">&#39;&#39;</span>.$args[2].<span class="charliteral">&#39;\&#39;</span>]);<span class="keywordflow">return</span> $b;<span class="stringliteral">&#39;;</span>
<a name="l01476"></a>01476 <span class="stringliteral">  </span>
<a name="l01477"></a>01477 <span class="stringliteral">  return &#39;</span>$b.=$this-&gt;_<span class="stringliteral">&#39;.TemplateUtils::sanitize($withBlockName).&#39;</span>($e);<span class="stringliteral">&#39;;</span>
<a name="l01478"></a>01478 <span class="stringliteral"> }</span>
<a name="l01479"></a>01479 <span class="stringliteral"> </span>
<a name="l01481"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ac352b9ea9b79e876606586c79e7bbb5c">01481</a> <span class="stringliteral"> public function handleTPutBlock(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$tag, array &amp;$args) {</span>
<a name="l01482"></a>01482 <span class="stringliteral">  $blockName = &#39;</span>block:<span class="stringliteral">&#39;.$args[0];</span>
<a name="l01483"></a>01483 <span class="stringliteral">  $blockCall = &#39;</span>$b.=$this-&gt;_<span class="stringliteral">&#39;.TemplateUtils::sanitize($blockName).&#39;</span>($e);<span class="stringliteral">&#39;;</span>
<a name="l01484"></a>01484 <span class="stringliteral">  </span>
<a name="l01485"></a>01485 <span class="stringliteral">  if (isset($args[1]) &amp;&amp; $args[1] == &#39;</span>strict<span class="stringliteral">&#39;) {</span>
<a name="l01486"></a>01486 <span class="stringliteral">   $compiler-&gt;raiseIf(</span>
<a name="l01487"></a>01487 <span class="stringliteral">    (!isset($compiler-&gt;blocks[$blockName])),</span>
<a name="l01488"></a>01488 <span class="stringliteral">    $node,</span>
<a name="l01489"></a>01489 <span class="stringliteral">    &#39;</span>Block <span class="stringliteral">&quot;&#39;.$args[0].&#39;&quot;</span> does not exist (strict mode used in <span class="stringliteral">&quot;putblock&quot;</span>)<span class="stringliteral">&#39;,</span>
<a name="l01490"></a>01490 <span class="stringliteral">    TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01491"></a>01491 <span class="stringliteral">   );</span>
<a name="l01492"></a>01492 <span class="stringliteral">   </span>
<a name="l01493"></a>01493 <span class="stringliteral">   return $blockCall;</span>
<a name="l01494"></a>01494 <span class="stringliteral">  } else {</span>
<a name="l01495"></a>01495 <span class="stringliteral">   $code  = &#39;</span><span class="keywordflow">if</span>(is_callable(array($this,\<span class="charliteral">&#39;_&#39;</span>.<a class="code" href="class_template_utils.html#aeadcc7d717f5752474ab611bd45cfd7b" title="Sanitize string, for use as function name.">TemplateUtils::sanitize</a>($blockName).<span class="charliteral">&#39;\&#39;</span>))){<span class="stringliteral">&#39;;</span>
<a name="l01496"></a>01496 <span class="stringliteral">   $code .= $blockCall;</span>
<a name="l01497"></a>01497 <span class="stringliteral">   $code .= &#39;</span>}<span class="stringliteral">&#39;;</span>
<a name="l01498"></a>01498 <span class="stringliteral">   </span>
<a name="l01499"></a>01499 <span class="stringliteral">   return $code;</span>
<a name="l01500"></a>01500 <span class="stringliteral">  }</span>
<a name="l01501"></a>01501 <span class="stringliteral"> }</span>
<a name="l01502"></a>01502 <span class="stringliteral"> </span>
<a name="l01504"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a1d6e4220f3f0f14332878345d03d8a4e">01504</a> <span class="stringliteral"> public function handleTCall(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$tag, array &amp;$args) {</span>
<a name="l01505"></a>01505 <span class="stringliteral">  $argCount = count($args);</span>
<a name="l01506"></a>01506 <span class="stringliteral">  </span>
<a name="l01507"></a>01507 <span class="stringliteral">  if ($argCount &gt;= 3 &amp;&amp; $args[$argCount - 2] == &#39;</span>as<span class="stringliteral">&#39;) {</span>
<a name="l01508"></a>01508 <span class="stringliteral">   // {% call &lt;function&gt; [&lt;arg&gt; [&lt;arg&gt; [...]]] as &lt;variable&gt; %}</span>
<a name="l01509"></a>01509 <span class="stringliteral">   $destCode  = &#39;</span>$this-&gt;ctx[\<span class="stringliteral">&#39;&#39;</span>.TemplateUtils::escape($args[$argCount - 1]).<span class="charliteral">&#39;\&#39;</span>]=<span class="stringliteral">&#39;;</span>
<a name="l01510"></a>01510 <span class="stringliteral">   $argCount -= 2;</span>
<a name="l01511"></a>01511 <span class="stringliteral">   $args      = array_slice($args, 0, -2);</span>
<a name="l01512"></a>01512 <span class="stringliteral">  } else {</span>
<a name="l01513"></a>01513 <span class="stringliteral">   // {% call &lt;function&gt; [&lt;arg&gt; [&lt;arg&gt; [...]]] %}</span>
<a name="l01514"></a>01514 <span class="stringliteral">   $destCode  = &#39;</span>$b.=<span class="stringliteral">&#39;;</span>
<a name="l01515"></a>01515 <span class="stringliteral">  }</span>
<a name="l01516"></a>01516 <span class="stringliteral">  </span>
<a name="l01517"></a>01517 <span class="stringliteral">  $checkCode = &#39;</span><span class="stringliteral">&#39;;</span>
<a name="l01518"></a>01518 <span class="stringliteral">  $function  = $args[0];</span>
<a name="l01519"></a>01519 <span class="stringliteral">  </span>
<a name="l01520"></a>01520 <span class="stringliteral">  foreach ($args as &amp;$arg) {</span>
<a name="l01521"></a>01521 <span class="stringliteral">   if (mb_substr($arg, 0, 1) == &#39;</span><span class="stringliteral">&quot;&#39;) {</span>
<a name="l01522"></a>01522 <span class="stringliteral">    $arg = &#39;\&#39;&#39;.TemplateUtils::escape(mb_substr($arg, 1, -1)).&#39;\&#39;&#39;;</span>
<a name="l01523"></a>01523 <span class="stringliteral">   } else {</span>
<a name="l01524"></a>01524 <span class="stringliteral">    list($arg, $filters) = TemplateUtils::split(&#39;|&#39;, $arg);</span>
<a name="l01525"></a>01525 <span class="stringliteral">    list($arg, $check)   = $compiler-&gt;parseVariableExpression($node, $arg);</span>
<a name="l01526"></a>01526 <span class="stringliteral">    $arg                 = $compiler-&gt;parseFilterChain($node, $filters, &#39;@&#39;.$arg);</span>
<a name="l01527"></a>01527 <span class="stringliteral">    $checkCode          .= $check;</span>
<a name="l01528"></a>01528 <span class="stringliteral">   }</span>
<a name="l01529"></a>01529 <span class="stringliteral">  }</span>
<a name="l01530"></a>01530 <span class="stringliteral">  </span>
<a name="l01531"></a>01531 <span class="stringliteral">  return</span>
<a name="l01532"></a>01532 <span class="stringliteral">   $checkCode.</span>
<a name="l01533"></a>01533 <span class="stringliteral">   &#39;$_fn=&#39;.$args[0].&#39;;&#39;.</span>
<a name="l01534"></a>01534 <span class="stringliteral">   &#39;TemplateUtils::checkIfAllowed($e,\&#39;function\&#39;,$_fn);&#39;.</span>
<a name="l01535"></a>01535 <span class="stringliteral">   &#39;if(!is_callable($_fn)){$this-&gt;invalidVar(\&#39;&#39;.TemplateUtils::escape($function).&#39;\&#39;,&#39;.</span>
<a name="l01536"></a>01536 <span class="stringliteral">   &#39;\&#39;callable expected\&#39;);}&#39;.</span>
<a name="l01537"></a>01537 <span class="stringliteral">   $destCode.&#39;call_user_func($_fn&#39;.</span>
<a name="l01538"></a>01538 <span class="stringliteral">   (count($args) &gt; 1 ? &#39;,&#39;.implode(&#39;,&#39;, array_slice($args, 1)) : &#39;&#39;).</span>
<a name="l01539"></a>01539 <span class="stringliteral">   &#39;);&#39;;</span>
<a name="l01540"></a>01540 <span class="stringliteral"> }</span>
<a name="l01541"></a>01541 <span class="stringliteral"> </span>
<a name="l01543"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a146220b1e89e45b22d9cd93e00de4fa4">01543</a> <span class="stringliteral"> public function handleTMeta(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$tag, array &amp;$args) {</span>
<a name="l01544"></a>01544 <span class="stringliteral">  $args[0] = &#39;user:&#39;.$args[0];</span>
<a name="l01545"></a>01545 <span class="stringliteral">  $args[1] = mb_substr($args[1], 1, -1);</span>
<a name="l01546"></a>01546 <span class="stringliteral">  </span>
<a name="l01547"></a>01547 <span class="stringliteral">  $compiler-&gt;metadata[$args[0]] = $args[1];</span>
<a name="l01548"></a>01548 <span class="stringliteral">  </span>
<a name="l01549"></a>01549 <span class="stringliteral">  return &#39;&#39;;</span>
<a name="l01550"></a>01550 <span class="stringliteral"> }</span>
<a name="l01551"></a>01551 <span class="stringliteral"> </span>
<a name="l01552"></a>01552 <span class="stringliteral"> //</span>
<a name="l01553"></a>01553 <span class="stringliteral"> // Std filters</span>
<a name="l01554"></a>01554 <span class="stringliteral"> //</span>
<a name="l01555"></a>01555 <span class="stringliteral"> </span>
<a name="l01557"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a04dfeca3f6f2926224c40f9f8ef521a2">01557</a> <span class="stringliteral"> public function handleFAdd(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01558"></a>01558 <span class="stringliteral">  list($argType, $argValue) = $args[0];</span>
<a name="l01559"></a>01559 <span class="stringliteral">  $operator                 = ($argType == &#39;string&#39; ? &#39;.&#39; : &#39;+&#39;);</span>
<a name="l01560"></a>01560 <span class="stringliteral">  </span>
<a name="l01561"></a>01561 <span class="stringliteral">  return &#39;(%s&#39;.$operator.$argValue.&#39;)&#39;;</span>
<a name="l01562"></a>01562 <span class="stringliteral"> }</span>
<a name="l01563"></a>01563 <span class="stringliteral"> </span>
<a name="l01565"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a2c3417761a4d650aad6f87ba402de9a3">01565</a> <span class="stringliteral"> public function handleFAddSlashes(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01566"></a>01566 <span class="stringliteral">  return &#39;addslashes(%s)&#39;;</span>
<a name="l01567"></a>01567 <span class="stringliteral"> }</span>
<a name="l01568"></a>01568 <span class="stringliteral"> </span>
<a name="l01570"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a1db6b35bd8981f7d69dfff7635b15ed1">01570</a> <span class="stringliteral"> public function handleFCapFirst(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01571"></a>01571 <span class="stringliteral">  return &#39;(mb_strtoupper(mb_substr(($__v=%s),0,1)).mb_substr($__v,1))&#39;;</span>
<a name="l01572"></a>01572 <span class="stringliteral"> }</span>
<a name="l01573"></a>01573 <span class="stringliteral"> </span>
<a name="l01575"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a4cdb027933d232f10570218aea855129">01575</a> <span class="stringliteral"> public function handleFCut(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01576"></a>01576 <span class="stringliteral">  list($cutType, $cutValue) = $args[0];</span>
<a name="l01577"></a>01577 <span class="stringliteral">  if ($cutType == &#39;variable&#39;) {</span>
<a name="l01578"></a>01578 <span class="stringliteral">   $cut = &#39;preg_quote(&#39;.$cutValue.&#39;,\&#39;~\&#39;)&#39;;</span>
<a name="l01579"></a>01579 <span class="stringliteral">  } elseif ($cutType == &#39;string&#39;) {</span>
<a name="l01580"></a>01580 <span class="stringliteral">   $cut = preg_quote($cutValue, &#39;~&#39;);</span>
<a name="l01581"></a>01581 <span class="stringliteral">  }</span>
<a name="l01582"></a>01582 <span class="stringliteral">  </span>
<a name="l01583"></a>01583 <span class="stringliteral">  return &#39;preg_replace(\&#39;~\&#39;.&#39;.$cut.&#39;.\&#39;~u\&#39;,\&#39;\&#39;,%s)&#39;;</span>
<a name="l01584"></a>01584 <span class="stringliteral"> }</span>
<a name="l01585"></a>01585 <span class="stringliteral"> </span>
<a name="l01587"></a><a class="code" href="class_template_std_lib_ex_plugin.html#aea23f7f3c1acd4dda7718b3a884fe5d9">01587</a> <span class="stringliteral"> public function handleFDate(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01588"></a>01588 <span class="stringliteral">  return &#39;date(&#39;.$args[0][1].&#39;,%s)&#39;;</span>
<a name="l01589"></a>01589 <span class="stringliteral"> }</span>
<a name="l01590"></a>01590 <span class="stringliteral"> </span>
<a name="l01592"></a><a class="code" href="class_template_std_lib_ex_plugin.html#adc18b02116717d0269633eaab38ac951">01592</a> <span class="stringliteral"> public function handleFDefault(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01593"></a>01593 <span class="stringliteral">  return &#39;(($__v=%s)?$__v:&#39;.$args[0][1].&#39;)&#39;;</span>
<a name="l01594"></a>01594 <span class="stringliteral"> }</span>
<a name="l01595"></a>01595 <span class="stringliteral"> </span>
<a name="l01597"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a17879600c66994ce817e409047e65777">01597</a> <span class="stringliteral"> public function handleFDefaultIfNone(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01598"></a>01598 <span class="stringliteral">  return &#39;(($__v=%s)!==null?$__v:&#39;.$args[0][1].&#39;)&#39;;</span>
<a name="l01599"></a>01599 <span class="stringliteral"> }</span>
<a name="l01600"></a>01600 <span class="stringliteral"> </span>
<a name="l01602"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a83d4e2ea9054493fcb69604833b9b7b2">01602</a> <span class="stringliteral"> public function handleFDivisibleBy(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01603"></a>01603 <span class="stringliteral">  list($argType, $argValue) = $args[0];</span>
<a name="l01604"></a>01604 <span class="stringliteral">  </span>
<a name="l01605"></a>01605 <span class="stringliteral">  if ($argType == &#39;string&#39;) {</span>
<a name="l01606"></a>01606 <span class="stringliteral">   $compiler-&gt;raise(</span>
<a name="l01607"></a>01607 <span class="stringliteral">    $node,</span>
<a name="l01608"></a>01608 <span class="stringliteral">    &#39;Filter &quot;</span>divisibleby<span class="stringliteral">&quot; does not support string argument&#39;,</span>
<a name="l01609"></a>01609 <span class="stringliteral">    TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01610"></a>01610 <span class="stringliteral">   );</span>
<a name="l01611"></a>01611 <span class="stringliteral">  } elseif ($argType == &#39;number&#39; &amp;&amp; $argValue == 0) {</span>
<a name="l01612"></a>01612 <span class="stringliteral">   $compiler-&gt;raise(</span>
<a name="l01613"></a>01613 <span class="stringliteral">    $node,</span>
<a name="l01614"></a>01614 <span class="stringliteral">    &#39;Filter &quot;</span>divisibleby<span class="stringliteral">&quot; does not support &quot;</span>0<span class="stringliteral">&quot; numeric argument&#39;,</span>
<a name="l01615"></a>01615 <span class="stringliteral">    TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01616"></a>01616 <span class="stringliteral">   );</span>
<a name="l01617"></a>01617 <span class="stringliteral">  }</span>
<a name="l01618"></a>01618 <span class="stringliteral">  </span>
<a name="l01619"></a>01619 <span class="stringliteral">  return &#39;((%s%%((int)&#39;.$args[0][1].&#39;))==0)&#39;;</span>
<a name="l01620"></a>01620 <span class="stringliteral"> }</span>
<a name="l01621"></a>01621 <span class="stringliteral"> </span>
<a name="l01623"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a99788233877d9dfafcd89e4649507a17">01623</a> <span class="stringliteral"> public function handleFEscape(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01624"></a>01624 <span class="stringliteral">  return &#39;htmlspecialchars(%s)&#39;;</span>
<a name="l01625"></a>01625 <span class="stringliteral"> }</span>
<a name="l01626"></a>01626 <span class="stringliteral"> </span>
<a name="l01628"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a4fcf177b3b7ed365ff72b9f2757f6703">01628</a> <span class="stringliteral"> public function handleFFileSizeFormat(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01629"></a>01629 <span class="stringliteral">  if (!isset($compiler-&gt;blocks[&#39;filter:filesizeformat&#39;])) {</span>
<a name="l01630"></a>01630 <span class="stringliteral">   $_b  = (string)(1024);</span>
<a name="l01631"></a>01631 <span class="stringliteral">   $_kB = (string)(1024*1024);</span>
<a name="l01632"></a>01632 <span class="stringliteral">   $_MB = (string)(1024*1024*1024);</span>
<a name="l01633"></a>01633 <span class="stringliteral">   </span>
<a name="l01634"></a>01634 <span class="stringliteral">   $compiler-&gt;blocks[&#39;filter:filesizeformat&#39;] =</span>
<a name="l01635"></a>01635 <span class="stringliteral">    &#39;$v=func_get_arg(1);if($v&lt;&#39;.$_b.&#39;){return $v.\&#39; b\&#39;;}&#39;.</span>
<a name="l01636"></a>01636 <span class="stringliteral">    &#39;elseif($v&lt;&#39;.$_kB.&#39;){return round($v/&#39;.$_b.&#39;,2).\&#39; kB\&#39;;}&#39;.</span>
<a name="l01637"></a>01637 <span class="stringliteral">    &#39;elseif($v&lt;&#39;.$_MB.&#39;){return round($v/&#39;.$_kB.&#39;,2).\&#39; MB\&#39;;}&#39;.</span>
<a name="l01638"></a>01638 <span class="stringliteral">    &#39;else{return round($v/&#39;.$_MB.&#39;,2).\&#39; GB\&#39;;}&#39;;</span>
<a name="l01639"></a>01639 <span class="stringliteral">  }</span>
<a name="l01640"></a>01640 <span class="stringliteral">  </span>
<a name="l01641"></a>01641 <span class="stringliteral">  return &#39;$this-&gt;_filter_filesizeformat($e,%s)&#39;;</span>
<a name="l01642"></a>01642 <span class="stringliteral"> }</span>
<a name="l01643"></a>01643 <span class="stringliteral"> </span>
<a name="l01645"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a4ec1b696aeb5c368280153a403dd8bf6">01645</a> <span class="stringliteral"> public function handleFFixAmpersands(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01646"></a>01646 <span class="stringliteral">  return &#39;str_replace(\&#39;&amp;\&#39;,\&#39;&amp;amp;\&#39;,%s)&#39;;</span>
<a name="l01647"></a>01647 <span class="stringliteral"> }</span>
<a name="l01648"></a>01648 <span class="stringliteral"> </span>
<a name="l01650"></a><a class="code" href="class_template_std_lib_ex_plugin.html#af77314a94f8244ce292ceb6267869c77">01650</a> <span class="stringliteral"> public function handleFJoin(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01651"></a>01651 <span class="stringliteral">  return &#39;implode(&#39;.$args[0][1].&#39;,%s)&#39;;</span>
<a name="l01652"></a>01652 <span class="stringliteral"> }</span>
<a name="l01653"></a>01653 <span class="stringliteral"> </span>
<a name="l01655"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a4235e1610133818b1fcd6ef7bf94ca74">01655</a> <span class="stringliteral"> public function handleFLength(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01656"></a>01656 <span class="stringliteral">  return &#39;(is_string(($__v=%s))?mb_strlen($__v):count($__v))&#39;;</span>
<a name="l01657"></a>01657 <span class="stringliteral"> }</span>
<a name="l01658"></a>01658 <span class="stringliteral"> </span>
<a name="l01660"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ae54d0e23d33b652e9b798ae5ca75a1ab">01660</a> <span class="stringliteral"> public function handleFLengthIs(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01661"></a>01661 <span class="stringliteral">  return &#39;(&#39;.$this-&gt;handleFLength($compiler, $node, $filter, $args).&#39;==&#39;.$args[0][1].&#39;)&#39;;</span>
<a name="l01662"></a>01662 <span class="stringliteral"> }</span>
<a name="l01663"></a>01663 <span class="stringliteral"> </span>
<a name="l01665"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a55163169395c04f6c97c639f78bd78b8">01665</a> <span class="stringliteral"> public function handleFLineBreaks(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01666"></a>01666 <span class="stringliteral">  if (!isset($compiler-&gt;blocks[&#39;filter:linebreaks&#39;])) {</span>
<a name="l01667"></a>01667 <span class="stringliteral">   // FIXME: handle \r linebreaks?</span>
<a name="l01668"></a>01668 <span class="stringliteral">   $compiler-&gt;blocks[&#39;filter:linebreaks&#39;] =</span>
<a name="l01669"></a>01669 <span class="stringliteral">    &#39;$v=func_get_arg(1);$v=str_replace(&quot;</span>\r\n<span class="stringliteral">&quot;,&quot;</span>\n<span class="stringliteral">&quot;,$v);$ps=preg_split(&quot;</span>/\n{2,}/<span class="stringliteral">&quot;,$v);&#39;.</span>
<a name="l01670"></a>01670 <span class="stringliteral">    &#39;foreach($ps as &amp;$p){$p=\&#39;&lt;p&gt;\&#39;.str_replace(&quot;</span>\n<span class="stringliteral">&quot;,\&#39;&lt;br /&gt;\&#39;,trim($p)).\&#39;&lt;/p&gt;\&#39;;}&#39;.</span>
<a name="l01671"></a>01671 <span class="stringliteral">    &#39;return implode(&quot;</span>\n\n<span class="stringliteral">&quot;,$ps);&#39;;</span>
<a name="l01672"></a>01672 <span class="stringliteral">  }</span>
<a name="l01673"></a>01673 <span class="stringliteral">  </span>
<a name="l01674"></a>01674 <span class="stringliteral">  return &#39;$this-&gt;_filter_linebreaks($e,%s)&#39;;</span>
<a name="l01675"></a>01675 <span class="stringliteral"> }</span>
<a name="l01676"></a>01676 <span class="stringliteral"> </span>
<a name="l01678"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a857a7c510e68a8f8b6f17814fdfa5ce6">01678</a> <span class="stringliteral"> public function handleFLineBreaksBR(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01679"></a>01679 <span class="stringliteral">  return &#39;nl2br(%s)&#39;;</span>
<a name="l01680"></a>01680 <span class="stringliteral"> }</span>
<a name="l01681"></a>01681 <span class="stringliteral"> </span>
<a name="l01683"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a6800b8f92f9fe828e31fffc74bb41adc">01683</a> <span class="stringliteral"> private function commonFJust($sign, TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, &amp;$width) {</span>
<a name="l01684"></a>01684 <span class="stringliteral">  $compiler-&gt;raiseIf(</span>
<a name="l01685"></a>01685 <span class="stringliteral">   ($width[0] == &#39;string&#39;),</span>
<a name="l01686"></a>01686 <span class="stringliteral">   $node,</span>
<a name="l01687"></a>01687 <span class="stringliteral">   &#39;Filter &quot;</span><span class="stringliteral">&#39;.$filter.&#39;</span><span class="stringliteral">&quot; does not support string argument &#39;,</span>
<a name="l01688"></a>01688 <span class="stringliteral">   TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01689"></a>01689 <span class="stringliteral">  );</span>
<a name="l01690"></a>01690 <span class="stringliteral">  </span>
<a name="l01691"></a>01691 <span class="stringliteral">  switch ($width[0]) {</span>
<a name="l01692"></a>01692 <span class="stringliteral">   case &#39;number&#39;:   $width = $width[1]; break;</span>
<a name="l01693"></a>01693 <span class="stringliteral">   case &#39;variable&#39;: $width = &#39;\&#39;.(int)&#39;.$width[1].&#39;.\&#39;&#39;; break;</span>
<a name="l01694"></a>01694 <span class="stringliteral">  }</span>
<a name="l01695"></a>01695 <span class="stringliteral">  </span>
<a name="l01696"></a>01696 <span class="stringliteral">  return &#39;sprintf(\&#39;%%&#39;.$sign.$width.&#39;s\&#39;,%s)&#39;;</span>
<a name="l01697"></a>01697 <span class="stringliteral"> }</span>
<a name="l01698"></a>01698 <span class="stringliteral"> </span>
<a name="l01700"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a6e489eef13eeed577b5f2b098ebb2b62">01700</a> <span class="stringliteral"> public function handleFLJust(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01701"></a>01701 <span class="stringliteral">  return $this-&gt;commonFJust(&#39;-&#39;, $compiler, $node, $filter, $args[0]);</span>
<a name="l01702"></a>01702 <span class="stringliteral"> }</span>
<a name="l01703"></a>01703 <span class="stringliteral"> </span>
<a name="l01705"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a61ce3b203cd9a6580e068480288628a5">01705</a> <span class="stringliteral"> public function handleFLower(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01706"></a>01706 <span class="stringliteral">  return &#39;mb_strtolower(%s)&#39;;</span>
<a name="l01707"></a>01707 <span class="stringliteral"> }</span>
<a name="l01708"></a>01708 <span class="stringliteral"> </span>
<a name="l01710"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a7930c1355e33e470902abdd4a4df34bc">01710</a> <span class="stringliteral"> public function handleFMakeList(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01711"></a>01711 <span class="stringliteral">  return &#39;str_split(%s)&#39;;</span>
<a name="l01712"></a>01712 <span class="stringliteral"> }</span>
<a name="l01713"></a>01713 <span class="stringliteral"> </span>
<a name="l01715"></a><a class="code" href="class_template_std_lib_ex_plugin.html#af4488bfe8e4ce4699780a668008f9495">01715</a> <span class="stringliteral"> public function handleFPluralize(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01716"></a>01716 <span class="stringliteral">  $singularSuffix = &#39;&#39;;</span>
<a name="l01717"></a>01717 <span class="stringliteral">  $pluralSuffix   = &#39;s&#39;;</span>
<a name="l01718"></a>01718 <span class="stringliteral">  </span>
<a name="l01719"></a>01719 <span class="stringliteral">  if (isset($args[0])) {</span>
<a name="l01720"></a>01720 <span class="stringliteral">   $compiler-&gt;raiseIf(</span>
<a name="l01721"></a>01721 <span class="stringliteral">    ($args[0][0] != &#39;string&#39;),</span>
<a name="l01722"></a>01722 <span class="stringliteral">    $node,</span>
<a name="l01723"></a>01723 <span class="stringliteral">    &#39;Filter &quot;</span>pluralize<span class="stringliteral">&quot; does not support variable/numeric suffix argument&#39;,</span>
<a name="l01724"></a>01724 <span class="stringliteral">    TemplateError::E_INVALID_ARGUMENT</span>
<a name="l01725"></a>01725 <span class="stringliteral">   );</span>
<a name="l01726"></a>01726 <span class="stringliteral">   </span>
<a name="l01727"></a>01727 <span class="stringliteral">   $suffixes = TemplateUtils::split(&#39;,&#39;, mb_substr($args[0][1], 1, -1));</span>
<a name="l01728"></a>01728 <span class="stringliteral">   if ($suffixes[1] == &#39;&#39;) {</span>
<a name="l01729"></a>01729 <span class="stringliteral">    $pluralSuffix = $suffixes[0];</span>
<a name="l01730"></a>01730 <span class="stringliteral">   } else {</span>
<a name="l01731"></a>01731 <span class="stringliteral">    list($singularSuffix, $pluralSuffix) = $suffixes;</span>
<a name="l01732"></a>01732 <span class="stringliteral">   }</span>
<a name="l01733"></a>01733 <span class="stringliteral">   </span>
<a name="l01734"></a>01734 <span class="stringliteral">   $singularSuffix = TemplateUtils::escape($singularSuffix);</span>
<a name="l01735"></a>01735 <span class="stringliteral">   $pluralSuffix   = TemplateUtils::escape($pluralSuffix);</span>
<a name="l01736"></a>01736 <span class="stringliteral">  }</span>
<a name="l01737"></a>01737 <span class="stringliteral">  </span>
<a name="l01738"></a>01738 <span class="stringliteral">  return &#39;((%s)&gt;1?\&#39;&#39;.$pluralSuffix.&#39;\&#39;:\&#39;&#39;.$singularSuffix.&#39;\&#39;)&#39;;</span>
<a name="l01739"></a>01739 <span class="stringliteral"> }</span>
<a name="l01740"></a>01740 <span class="stringliteral"> </span>
<a name="l01742"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a36a9b7e72ee9cb918507a1e5d4688635">01742</a> <span class="stringliteral"> public function handleFRandom(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01743"></a>01743 <span class="stringliteral">  if (!isset($compiler-&gt;blocks[&#39;filter:random&#39;])) {</span>
<a name="l01744"></a>01744 <span class="stringliteral">   $compiler-&gt;blocks[&#39;filter:random&#39;] = &#39;$v=func_get_arg(1);return $v[array_rand($v)];&#39;;</span>
<a name="l01745"></a>01745 <span class="stringliteral">  }</span>
<a name="l01746"></a>01746 <span class="stringliteral">  </span>
<a name="l01747"></a>01747 <span class="stringliteral">  return &#39;$this-&gt;_filter_random($e,%s)&#39;;</span>
<a name="l01748"></a>01748 <span class="stringliteral"> }</span>
<a name="l01749"></a>01749 <span class="stringliteral"> </span>
<a name="l01751"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a6daaa60e3ac5b0b162fd4b6d87bf166f">01751</a> <span class="stringliteral"> public function handleFRemoveTags(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01752"></a>01752 <span class="stringliteral">  return &#39;strip_tags(%s)&#39;;</span>
<a name="l01753"></a>01753 <span class="stringliteral"> }</span>
<a name="l01754"></a>01754 <span class="stringliteral"> </span>
<a name="l01756"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a9de945e595484d8113a9007349dd7f3f">01756</a> <span class="stringliteral"> public function handleFRJust(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01757"></a>01757 <span class="stringliteral">  return $this-&gt;commonFJust(&#39;&#39;, $compiler, $node, $filter, $args[0]);</span>
<a name="l01758"></a>01758 <span class="stringliteral"> }</span>
<a name="l01759"></a>01759 <span class="stringliteral"> </span>
<a name="l01761"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a0d48b246b1364e9e254ac15eedd54c6a">01761</a> <span class="stringliteral"> public function handleFSlugify(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01762"></a>01762 <span class="stringliteral">  if (!isset($compiler-&gt;blocks[&#39;filter:slugify&#39;])) {</span>
<a name="l01763"></a>01763 <span class="stringliteral">   $compiler-&gt;blocks[&#39;filter:slugify&#39;] =</span>
<a name="l01764"></a>01764 <span class="stringliteral">    &#39;$v=func_get_arg(1);$v=mb_strtolower($v);$v=strip_tags($v);&#39;.</span>
<a name="l01765"></a>01765 <span class="stringliteral">    &#39;$v=preg_replace(\&#39;~\s+|\_~\&#39;, \&#39;-\&#39;,$v);&#39;.</span>
<a name="l01766"></a>01766 <span class="stringliteral">    &#39;$v=preg_replace(\&#39;~\-+~\&#39;,\&#39;-\&#39;,$v);&#39;.</span>
<a name="l01767"></a>01767 <span class="stringliteral">    &#39;$v=preg_replace(\&#39;~(^\-+)|(\-+$)|[^a-z0-9\-]~ui\&#39;,\&#39;\&#39;,$v);&#39;.</span>
<a name="l01768"></a>01768 <span class="stringliteral">    &#39;return $v;&#39;;</span>
<a name="l01769"></a>01769 <span class="stringliteral">  }</span>
<a name="l01770"></a>01770 <span class="stringliteral">  </span>
<a name="l01771"></a>01771 <span class="stringliteral">  return &#39;$this-&gt;_filter_slugify($e,%s)&#39;;</span>
<a name="l01772"></a>01772 <span class="stringliteral"> }</span>
<a name="l01773"></a>01773 <span class="stringliteral"> </span>
<a name="l01775"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a9ff32267b4f2d8c6514613dd1098b2f5">01775</a> <span class="stringliteral"> public function handleFTitle(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01776"></a>01776 <span class="stringliteral">  return &#39;mb_convert_case(%s,MB_CASE_TITLE)&#39;;</span>
<a name="l01777"></a>01777 <span class="stringliteral"> }</span>
<a name="l01778"></a>01778 <span class="stringliteral"> </span>
<a name="l01780"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a80304dd93e9851a5e4df1ac2e707f1c4">01780</a> <span class="stringliteral"> public function handleFUpper(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01781"></a>01781 <span class="stringliteral">  return &#39;mb_strtoupper(%s)&#39;;</span>
<a name="l01782"></a>01782 <span class="stringliteral"> }</span>
<a name="l01783"></a>01783 <span class="stringliteral"> </span>
<a name="l01785"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ad2e1c142943971e67f69b1b2a30955a0">01785</a> <span class="stringliteral"> public function handleFURLEncode(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01786"></a>01786 <span class="stringliteral">  return &#39;urlencode(%s)&#39;;</span>
<a name="l01787"></a>01787 <span class="stringliteral"> }</span>
<a name="l01788"></a>01788 <span class="stringliteral"> </span>
<a name="l01790"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a41c99c4a190b3367e86f4eb3972e931a">01790</a> <span class="stringliteral"> public function handleFURLDecode(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01791"></a>01791 <span class="stringliteral">  return &#39;urldecode(%s)&#39;;</span>
<a name="l01792"></a>01792 <span class="stringliteral"> }</span>
<a name="l01793"></a>01793 <span class="stringliteral"> </span>
<a name="l01795"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ac2d7656a90dc0ef03ab4793ced7b6093">01795</a> <span class="stringliteral"> public function handleFWordCount(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01796"></a>01796 <span class="stringliteral">  return &#39;str_word_count(%s)&#39;;</span>
<a name="l01797"></a>01797 <span class="stringliteral"> }</span>
<a name="l01798"></a>01798 <span class="stringliteral"> </span>
<a name="l01800"></a><a class="code" href="class_template_std_lib_ex_plugin.html#ab4d26badb06469f07931b8ca47b16232">01800</a> <span class="stringliteral"> public function handleFWordWrap(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$filter, array &amp;$args) {</span>
<a name="l01801"></a>01801 <span class="stringliteral">  return &#39;wordwrap(%s,&#39;.$args[0][1].&#39;,&quot;</span>\n<span class="stringliteral">&quot;,true)&#39;;</span>
<a name="l01802"></a>01802 <span class="stringliteral"> }</span>
<a name="l01803"></a>01803 <span class="stringliteral"> </span>
<a name="l01804"></a>01804 <span class="stringliteral"> //</span>
<a name="l01805"></a>01805 <span class="stringliteral"> // Std hooks</span>
<a name="l01806"></a>01806 <span class="stringliteral"> //</span>
<a name="l01807"></a>01807 <span class="stringliteral"> </span>
<a name="l01812"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a5058b286680f5e6a0b45742dc6259a20">01812</a> <span class="stringliteral"> public function handleHAutoEscape(TemplateCompilerEx $compiler, array &amp;$filterChain) {</span>
<a name="l01813"></a>01813 <span class="stringliteral">  $safe = false;</span>
<a name="l01814"></a>01814 <span class="stringliteral">  </span>
<a name="l01815"></a>01815 <span class="stringliteral">  if (in_array(&#39;safe&#39;, $filterChain)) {</span>
<a name="l01816"></a>01816 <span class="stringliteral">   // we always remove pseudofilter &quot;</span>safe<span class="stringliteral">&quot; - even if autoescaping is disabled</span>
<a name="l01817"></a>01817 <span class="stringliteral">   // otherwise syntax error may occur</span>
<a name="l01818"></a>01818 <span class="stringliteral">   $filterChain = array_values(array_diff($filterChain, array(&#39;safe&#39;)));</span>
<a name="l01819"></a>01819 <span class="stringliteral">   $safe        = true;</span>
<a name="l01820"></a>01820 <span class="stringliteral">  }</span>
<a name="l01821"></a>01821 <span class="stringliteral">  </span>
<a name="l01822"></a>01822 <span class="stringliteral">  if (!$compiler-&gt;settings[&#39;autoEscape&#39;]) return false;</span>
<a name="l01823"></a>01823 <span class="stringliteral">  </span>
<a name="l01824"></a>01824 <span class="stringliteral">  // check whether we&#39;re called from within handleVariable</span>
<a name="l01825"></a>01825 <span class="stringliteral">  // backtrace index is hardcoded, and should always be the same</span>
<a name="l01826"></a>01826 <span class="stringliteral">  // (handleVariable -&gt; parseFilterChain -&gt; runHooks -&gt; call_user_func_array -&gt; handleHAutoEscape)</span>
<a name="l01827"></a>01827 <span class="stringliteral">  //  ^ 4               ^ 3                 ^ 2         ^ 1                     ^ 0</span>
<a name="l01828"></a>01828 <span class="stringliteral">  // if you ever run into a problem with this, report it, and loop-based checking</span>
<a name="l01829"></a>01829 <span class="stringliteral">  // will be used instead</span>
<a name="l01830"></a>01830 <span class="stringliteral">  $trace = debug_backtrace();</span>
<a name="l01831"></a>01831 <span class="stringliteral">  if (!isset($trace[4]) || $trace[4][&#39;function&#39;] != &#39;handleVariable&#39;) return false;</span>
<a name="l01832"></a>01832 <span class="stringliteral">  </span>
<a name="l01833"></a>01833 <span class="stringliteral">  if (!$safe) {</span>
<a name="l01834"></a>01834 <span class="stringliteral">   $filterChain[] = &#39;escape&#39;;</span>
<a name="l01835"></a>01835 <span class="stringliteral">  }</span>
<a name="l01836"></a>01836 <span class="stringliteral">  </span>
<a name="l01837"></a>01837 <span class="stringliteral">  return false;</span>
<a name="l01838"></a>01838 <span class="stringliteral"> }</span>
<a name="l01839"></a>01839 <span class="stringliteral"></span>
<a name="l01844"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a334757e3b257e35b8d9d5eb0046e9f4e">01844</a> <span class="stringliteral"> public function handleHInternalVariable(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$variableCode, &amp;$variableCheck) {</span>
<a name="l01845"></a>01845 <span class="stringliteral">  static $subVariables = null;</span>
<a name="l01846"></a>01846 <span class="stringliteral">  static $internalProlog = &#39;/^\$this-&gt;ctx\[\&#39;internal\&#39;\]/u&#39;;</span>
<a name="l01847"></a>01847 <span class="stringliteral">  </span>
<a name="l01848"></a>01848 <span class="stringliteral">  if (!$subVariables) {</span>
<a name="l01849"></a>01849 <span class="stringliteral">   $subVariables = array(</span>
<a name="l01850"></a>01850 <span class="stringliteral">    // variable =&gt; array(code regex, replacement code, setting to allow/disallow)</span>
<a name="l01851"></a>01851 <span class="stringliteral">    &#39;request&#39; =&gt; array(</span>
<a name="l01852"></a>01852 <span class="stringliteral">     &#39;^\[\&#39;request\&#39;\]\[\&#39;(POST|GET|COOKIE|SERVER|REQUEST|SESSION|ENV)\&#39;\]&#39;,</span>
<a name="l01853"></a>01853 <span class="stringliteral">     &#39;\\$_${1}&#39;, &#39;allowInternalRequest&#39;</span>
<a name="l01854"></a>01854 <span class="stringliteral">    ),</span>
<a name="l01855"></a>01855 <span class="stringliteral">    &#39;version&#39; =&gt; array(&#39;^\[\&#39;version\&#39;\]$&#39;, &#39;\&#39;&#39;.SITHTEMPLATE_VERSION.&#39;\&#39;&#39;, null),</span>
<a name="l01856"></a>01856 <span class="stringliteral">    &#39;const&#39;   =&gt; array(</span>
<a name="l01857"></a>01857 <span class="stringliteral">     &#39;^\[\&#39;const\&#39;\]\[\&#39;(.*?)\&#39;\]$&#39;, &#39;constant(\&#39;${1}\&#39;)&#39;, &#39;allowInternalConstants&#39;</span>
<a name="l01858"></a>01858 <span class="stringliteral">    ),</span>
<a name="l01859"></a>01859 <span class="stringliteral">   );</span>
<a name="l01860"></a>01860 <span class="stringliteral">  }</span>
<a name="l01861"></a>01861 <span class="stringliteral">  </span>
<a name="l01862"></a>01862 <span class="stringliteral">  if (preg_match($internalProlog, $variableCode)) {</span>
<a name="l01863"></a>01863 <span class="stringliteral">   $variableCode  = preg_replace($internalProlog, &#39;&#39;, $variableCode);</span>
<a name="l01864"></a>01864 <span class="stringliteral">   $variableCheck = &#39;&#39;;</span>
<a name="l01865"></a>01865 <span class="stringliteral">   </span>
<a name="l01866"></a>01866 <span class="stringliteral">   $match = false;</span>
<a name="l01867"></a>01867 <span class="stringliteral">   foreach ($subVariables as $pattern) {</span>
<a name="l01868"></a>01868 <span class="stringliteral">    if (preg_match(&#39;/&#39;.$pattern[0].&#39;/u&#39;, $variableCode)) {</span>
<a name="l01869"></a>01869 <span class="stringliteral">     $compiler-&gt;raiseIf(</span>
<a name="l01870"></a>01870 <span class="stringliteral">      (!is_null($pattern[2]) &amp;&amp; !$compiler-&gt;settings[$pattern[2]]),</span>
<a name="l01871"></a>01871 <span class="stringliteral">      $node,</span>
<a name="l01872"></a>01872 <span class="stringliteral">      &#39;&quot;</span><span class="keyword">internal</span><span class="stringliteral">&quot; restricted by &quot;</span><span class="stringliteral">&#39;.$pattern[2].&#39;</span><span class="stringliteral">&quot; setting&#39;,</span>
<a name="l01873"></a>01873 <span class="stringliteral">      TemplateError::E_SECURITY_VIOLATION</span>
<a name="l01874"></a>01874 <span class="stringliteral">     );</span>
<a name="l01875"></a>01875 <span class="stringliteral">     </span>
<a name="l01876"></a>01876 <span class="stringliteral">     $variableCode = preg_replace(&#39;/&#39;.$pattern[0].&#39;/u&#39;, $pattern[1], $variableCode);</span>
<a name="l01877"></a>01877 <span class="stringliteral">     $match = true;</span>
<a name="l01878"></a>01878 <span class="stringliteral">     break;</span>
<a name="l01879"></a>01879 <span class="stringliteral">    }</span>
<a name="l01880"></a>01880 <span class="stringliteral">   }</span>
<a name="l01881"></a>01881 <span class="stringliteral">   </span>
<a name="l01882"></a>01882 <span class="stringliteral">   $compiler-&gt;raiseIf(</span>
<a name="l01883"></a>01883 <span class="stringliteral">    (!$match),</span>
<a name="l01884"></a>01884 <span class="stringliteral">    $node,</span>
<a name="l01885"></a>01885 <span class="stringliteral">    &#39;Invalid &quot;</span><span class="keyword">internal</span><span class="stringliteral">&quot; variable syntax - no matching subvariable found, tried: &#39;.</span>
<a name="l01886"></a>01886 <span class="stringliteral">    implode(&#39;, &#39;, array_keys($subVariables)),</span>
<a name="l01887"></a>01887 <span class="stringliteral">    TemplateError::E_INVALID_SYNTAX</span>
<a name="l01888"></a>01888 <span class="stringliteral">   );</span>
<a name="l01889"></a>01889 <span class="stringliteral">  }</span>
<a name="l01890"></a>01890 <span class="stringliteral"> }</span>
<a name="l01891"></a>01891 <span class="stringliteral"> </span>
<a name="l01896"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a7678a66924344afb3712d7f155cd8490">01896</a> <span class="stringliteral"> public function handleHForLoopVariable(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$variableCode, &amp;$variableCheck) {</span>
<a name="l01897"></a>01897 <span class="stringliteral">  if (isset($compiler-&gt;varInLoop) &amp;&amp; $compiler-&gt;varInLoop &amp;&amp; mb_strpos($variableCode, &#39;[\&#39;forloop\&#39;]&#39;) !== false) {</span>
<a name="l01898"></a>01898 <span class="stringliteral">   $variableCode  = str_replace(&#39;[\&#39;forloop\&#39;]&#39;, &#39;[$f]&#39;, $variableCode);</span>
<a name="l01899"></a>01899 <span class="stringliteral">   $variableCheck = &#39;&#39;;</span>
<a name="l01900"></a>01900 <span class="stringliteral">  }</span>
<a name="l01901"></a>01901 <span class="stringliteral">  </span>
<a name="l01902"></a>01902 <span class="stringliteral">  return false;</span>
<a name="l01903"></a>01903 <span class="stringliteral"> }</span>
<a name="l01904"></a>01904 <span class="stringliteral"></span>
<a name="l01909"></a><a class="code" href="class_template_std_lib_ex_plugin.html#a42c731d5b29bfe5e857fbe569ae72814">01909</a> <span class="stringliteral"> public function handleHBlockVariable(TemplateCompilerEx $compiler, TemplateNodeEx $node, &amp;$variableCode, &amp;$variableCheck) {</span>
<a name="l01910"></a>01910 <span class="stringliteral">  if (isset($compiler-&gt;varInBlock) &amp;&amp; $compiler-&gt;varInBlock &amp;&amp; mb_strpos($variableCode, &#39;[\&#39;block\&#39;][\&#39;super\&#39;]&#39;) !== false) {</span>
<a name="l01911"></a>01911 <span class="stringliteral">   $compiler-&gt;raiseIf(</span>
<a name="l01912"></a>01912 <span class="stringliteral">    (!isset($compiler-&gt;metadata[&#39;parentTemplate&#39;])),</span>
<a name="l01913"></a>01913 <span class="stringliteral">    $node,</span>
<a name="l01914"></a>01914 <span class="stringliteral">    &#39;Invalid use of &quot;</span>block.super<span class="stringliteral">&quot; - no parent template&#39;,</span>
<a name="l01915"></a>01915 <span class="stringliteral">    TemplateError::E_INVALID_SYNTAX</span>
<a name="l01916"></a>01916 <span class="stringliteral">   );</span>
<a name="l01917"></a>01917 <span class="stringliteral">   </span>
<a name="l01918"></a>01918 <span class="stringliteral">   $variableCode  = &#39;parent::_&#39;.TemplateUtils::sanitize(end($compiler-&gt;varInBlock)).&#39;($e)&#39;;</span>
<a name="l01919"></a>01919 <span class="stringliteral">   $variableCheck = &#39;&#39;;</span>
<a name="l01920"></a>01920 <span class="stringliteral">  }</span>
<a name="l01921"></a>01921 <span class="stringliteral">  </span>
<a name="l01922"></a>01922 <span class="stringliteral">  return false;</span>
<a name="l01923"></a>01923 <span class="stringliteral"> }</span>
<a name="l01924"></a>01924 <span class="stringliteral">}</span>
</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