HTML_Template_Flexy
[ class tree: HTML_Template_Flexy ] [ index: HTML_Template_Flexy ] [ all elements ]

Source for file Standard.php

Documentation is available at Standard.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Alan Knowles <alan@akbkhome.com>                            |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: Standard.php 334846 2014-09-12 04:50:56Z alan_k $
  20. //
  21. //  Base Compiler Class
  22. //  Standard 'Original Flavour' Flexy compiler
  23.  
  24. /*------------------------------------------------------------------------------------------
  25.                                         NOTICE: 
  26.                              THIS COMPILER IS DEPRECIATED 
  27.                                 USE THE FLEXY COMPILER 
  28.      
  29.                       The Flexy Compiler should be Compatible
  30.  
  31. ------------------------------------------------------------------------------------------*/
  32.  
  33. require_once 'HTML/Template/Flexy/Tokenizer.php';
  34. require_once 'HTML/Template/Flexy/Token.php';
  35.  
  36. // cache for po files..
  37. $GLOBALS['_html_template_flexy_compiler_standard']['PO'= array();
  38.  
  39.  
  40. class HTML_Template_Flexy_Compiler_Standard extends HTML_Template_Flexy_Compiler 
  41. {
  42.     
  43.     
  44.     var $flexy;
  45.     /**
  46.     * The compile method.
  47.     * 
  48.     * @params   object HTML_Template_Flexy
  49.     * @params   string|false string to compile of false to use a file.
  50.     * @return   string   filename of template
  51.     * @access   public
  52.     */
  53.     function compile($flexy,$string=false
  54.     {
  55.         // read the entire file into one variable
  56.         
  57.         // note this should be moved to new HTML_Template_Flexy_Token
  58.         // and that can then manage all the tokens in one place..
  59.         global $_HTML_TEMPLATE_FLEXY_COMPILER;
  60.         
  61.         $this->flexy $flexy;
  62.         
  63.         $gettextStrings &$_HTML_TEMPLATE_FLEXY_COMPILER['gettextStrings'];
  64.         $gettextStrings = array()// reset it.
  65.         
  66.         if (@$this->options['debug']{
  67.             echo "compiling template $flexy->currentTemplate<BR>";
  68.             
  69.         }
  70.          
  71.         // reset the elements.
  72.         $flexy->_elements = array();
  73.         
  74.         // replace this with a singleton??
  75.         
  76.         $GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions'$this->options;
  77.         $GLOBALS['_HTML_TEMPLATE_FLEXY']['elements'= array();
  78.         $GLOBALS['_HTML_TEMPLATE_FLEXY']['filename'$flexy->currentTemplate;
  79.         $GLOBALS['_HTML_TEMPLATE_FLEXY']['prefixOutput']  '';
  80.         $GLOBALS['_HTML_TEMPLATE_FLEXY']['compiledTemplate']  $flexy->compiledTemplate;
  81.         
  82.         if (is_array($this->options['Translation2'])) {
  83.             require_once 'Translation2.php';
  84.             $this->options['Translation2'= new Translation2(
  85.                 $this->options['Translation2']['driver'],
  86.                 @$this->options['Translation2']['options']
  87.             );
  88.         }
  89.         
  90.         
  91.         if ($this->is_a($this->options['Translation2'],'Translation2')) {
  92.             $this->options['Translation2']->setLang($this->options['locale']);
  93.             // fixme - needs to be more specific to which template to use..
  94.             foreach ($this->options['templateDir'as $tt{
  95.                 $n basename($flexy->currentTemplate);
  96.                 if (substr($flexy->currentTemplate,0,strlen($tt)) == $tt{
  97.                     $n substr($flexy->currentTemplate,strlen($tt)+1);
  98.                 }
  99.                 //echo $n;
  100.             }
  101.             $this->options['Translation2']->setPageID($n);
  102.         else {
  103.             setlocale(LC_ALL$this->options['locale']);
  104.         }
  105.         
  106.         
  107.         
  108.         
  109.         
  110.         
  111.         
  112.         $data $string;
  113.         $res = false;
  114.         if ($string === false{
  115.             $data file_get_contents($flexy->currentTemplate);
  116.         }
  117.          
  118.             // PRE PROCESS {_(.....)} translation markers.
  119.         $got_gettext_markup = false;
  120.         
  121.         
  122.         
  123.         if (strpos($data,'{_('!== false{
  124.             $matches = array();
  125.             $lmatches explode ('{_('$data);
  126.             array_shift($lmatches);
  127.             // shift the first..
  128.             foreach ($lmatches as $k{
  129.                 if (false === strpos($k,')_}')) {
  130.                     continue;
  131.                 }
  132.                 $x explode(')_}',$k);
  133.                 $matches[$x[0];
  134.             }
  135.         
  136.         
  137.            //echo '<PRE>';print_r($matches);
  138.             // we may need to do some house cleaning here...
  139.             $gettextStrings $matches;
  140.             $got_gettext_markup = true;
  141.             
  142.             
  143.             // replace them now..  
  144.             // ** leaving in the tag (which should be ignored by the parser..
  145.             // we then get rid of the tags during the toString method in this class.
  146.             foreach($matches as $v{
  147.                 $data str_replace('{_('.$v.')_}''{_('.$this->flexy->translateString($v).')_}',$data);
  148.             }
  149.             
  150.         }
  151.             
  152.         if (isset($_HTML_TEMPLATE_FLEXY_COMPILER['cache'][md5($data)])) {
  153.             $res $_HTML_TEMPLATE_FLEXY_COMPILER['cache'][md5($data)];
  154.         else {
  155.         
  156.              
  157.             $tokenizer = new HTML_Template_Flexy_Tokenizer($data);
  158.             $tokenizer->fileName = $flexy->currentTemplate;
  159.             
  160.             
  161.             //$tokenizer->debug=1;
  162.             $tokenizer->options['ignore_html'$this->options['nonHTML'];
  163.             $tokenizer->options['ignore_php']  !$this->options['allowPHP'];
  164.             
  165.             $res = HTML_Template_Flexy_Token::buildTokens($tokenizer);
  166.          
  167.             $_HTML_TEMPLATE_FLEXY_COMPILER['cache'][md5($data)$res;
  168.             
  169.         }
  170.         
  171.         if ($this->is_a($res,'PEAR_Error')) {
  172.             return $res;
  173.         }   
  174.         // turn tokens into Template..
  175.         
  176.         $data $res->compile($this);
  177.         
  178.         if ($this->is_a($data,'PEAR_Error')) {
  179.             return $data;
  180.         }
  181.         
  182.         $data $GLOBALS['_HTML_TEMPLATE_FLEXY']['prefixOutput'$data;
  183.         
  184.         if (   @$this->options['debug']{
  185.             echo "<B>Result: </B><PRE>".htmlspecialchars($data)."</PRE><BR>";
  186.             
  187.         }
  188.  
  189.         if ($this->options['nonHTML']{
  190.            $data =  str_replace("?>\n","?>\n\n",$data);
  191.         }
  192.         
  193.          
  194.         
  195.         
  196.         // at this point we are into writing stuff...
  197.         if ($this->options['compileToString']{
  198.             $flexy->elements =  $GLOBALS['_HTML_TEMPLATE_FLEXY']['elements'];
  199.             return $data;
  200.         }
  201.         
  202.         
  203.         
  204.         
  205.         // error checking?
  206.         $file  $flexy->compiledTemplate;
  207.         if (isset($flexy->options['output.block'])) {
  208.             list($file,$partexplode('#',$file  );
  209.         }
  210.         
  211.         if( ($cfp fopen$file 'w' )) ) {
  212.             if (@$this->options['debug']{
  213.                 echo "<B>Writing: </B>".htmlspecialchars($data)."<BR>";
  214.                 
  215.             }
  216.             fwrite($cfp,$data);
  217.             fclose($cfp);
  218.             
  219.             chmod($file,0775);
  220.             // make the timestamp of the two items match.
  221.             clearstatcache();
  222.             touch($filefilemtime($flexy->currentTemplate));
  223.             if ($file != $flexy->compiledTemplate{
  224.                 chmod($flexy->compiledTemplate,0775);
  225.                 // make the timestamp of the two items match.
  226.                 clearstatcache();
  227.                 touch($flexy->compiledTemplatefilemtime($flexy->currentTemplate));
  228.             }
  229.              
  230.             
  231.         else {
  232.             return HTML_Template_Flexy::staticRaiseError('HTML_Template_Flexy::failed to write to '.$flexy->compiledTemplate,
  233.         }
  234.         // gettext strings
  235.         if (file_exists($flexy->getTextStringsFile)) {
  236.             unlink($flexy->getTextStringsFile);
  237.         }
  238.         
  239.         if($gettextStrings && ($cfp fopen$flexy->getTextStringsFile'w') ) ) {
  240.             
  241.             fwrite($cfp,serialize(array_unique($gettextStrings)));
  242.             fclose($cfp);
  243.         }
  244.         
  245.         // elements
  246.         if (file_exists($flexy->elementsFile)) {
  247.             unlink($flexy->elementsFile);
  248.         }
  249.         
  250.         if$GLOBALS['_HTML_TEMPLATE_FLEXY']['elements'&&
  251.             ($cfp fopen$flexy->elementsFile'w') ) ) {
  252.             fwrite($cfp,serialize$GLOBALS['_HTML_TEMPLATE_FLEXY']['elements']));
  253.             fclose($cfp);
  254.             // now clear it.
  255.         
  256.         }
  257.         
  258.         return true;
  259.     }
  260.     
  261.     /**
  262.     * Flag indicating compiler is inside {_( .... )_} block, and should not
  263.     * add to the gettextstrings array.
  264.     *
  265.     * @var boolean 
  266.     * @access public
  267.     */
  268.     var $inGetTextBlock = false;
  269.     
  270.     /**
  271.     * This is the base toString Method, it relays into toString{TokenName}
  272.     *
  273.     * @param    object    HTML_Template_Flexy_Token_* 
  274.     * 
  275.     * @return   string     string to build a template
  276.     * @access   public
  277.     * @see      toString*
  278.     */
  279.   
  280.  
  281.     function toString($element
  282.     {
  283.         static $len = 26; // strlen('HTML_Template_Flexy_Token_');
  284.         if ($this->options['debug']{
  285.             $x $element;
  286.             unset($x->children);
  287.             echo htmlspecialchars(print_r($x,true))."<BR>\n";
  288.         }
  289.         if ($element->token == 'GetTextStart'{
  290.             $this->inGetTextBlock = true;
  291.             return '';
  292.         }
  293.         if ($element->token == 'GetTextEnd'{
  294.             $this->inGetTextBlock = false;
  295.             return '';
  296.         }
  297.         
  298.             
  299.         $class get_class($element);
  300.         if (strlen($class>= $len{
  301.             $type substr($class,$len);
  302.             return $this->{'toString'.$type}($element);
  303.         }
  304.         
  305.         $ret $element->value;
  306.         $add $element->compileChildren($this);
  307.         if ($this->is_a($add,'PEAR_Error')) {
  308.             return $add;
  309.         }
  310.         $ret .= $add;
  311.         
  312.         if ($element->close{
  313.             $add $element->close->compile($this);
  314.             if ($this->is_a($add,'PEAR_Error')) {
  315.                 return $add;
  316.             }
  317.             $ret .= $add;
  318.         }
  319.         
  320.         return $ret;
  321.     }
  322.  
  323.  
  324.     /**
  325.     *   HTML_Template_Flexy_Token_Else toString
  326.     *
  327.     * @param    object    HTML_Template_Flexy_Token_Else 
  328.     * 
  329.     * @return   string     string to build a template
  330.     * @access   public
  331.     * @see      toString*
  332.     */
  333.   
  334.  
  335.     function toStringElse($element
  336.      {
  337.         // pushpull states to make sure we are in an area.. - should really check to see 
  338.         // if the state it is pulling is a if...
  339.         if ($element->pullState(=== false{
  340.             return $this->appendHTML(
  341.                 "<font color=\"red\">Unmatched {else:} on line: {$element->line}</font>"
  342.                 );
  343.         }
  344.         $element->pushState();
  345.         return $this->appendPhp("} else {");
  346.     }
  347.     
  348.     /**
  349.     *   HTML_Template_Flexy_Token_End toString
  350.     *
  351.     * @param    object    HTML_Template_Flexy_Token_Else 
  352.     * 
  353.     * @return   string     string to build a template
  354.     * @access   public
  355.     * @see      toString*
  356.     */
  357.   
  358.     function toStringEnd($element
  359.     {
  360.         // pushpull states to make sure we are in an area.. - should really check to see 
  361.         // if the state it is pulling is a if...
  362.         if ($element->pullState(=== false{
  363.             return $this->appendHTML(
  364.                 "<font color=\"red\">Unmatched {end:} on line: {$element->line}</font>"
  365.                 );
  366.         }
  367.          
  368.         return $this->appendPhp("}");
  369.     }
  370.  
  371.     /**
  372.     *   HTML_Template_Flexy_Token_EndTag toString
  373.     *
  374.     * @param    object    HTML_Template_Flexy_Token_EndTag 
  375.     * 
  376.     * @return   string     string to build a template
  377.     * @access   public
  378.     * @see      toString*
  379.     */
  380.   
  381.  
  382.  
  383.     function toStringEndTag($element
  384.     {
  385.         return $this->toStringTag($element);
  386.     }
  387.         
  388.     
  389.     
  390.     /**
  391.     *   HTML_Template_Flexy_Token_Foreach toString
  392.     *
  393.     * @param    object    HTML_Template_Flexy_Token_Foreach 
  394.     * 
  395.     * @return   string     string to build a template
  396.     * @access   public
  397.     * @see      toString*
  398.     */
  399.   
  400.     
  401.     function toStringForeach($element
  402.     {
  403.     
  404.         $loopon $element->toVar($element->loopOn);
  405.         if ($this->is_a($loopon,'PEAR_Error')) {
  406.             return $loopon;
  407.         }
  408.         
  409.         $ret 'if ($this->options[\'strict\'] || ('.
  410.             'is_array('$loopon')  || ' .
  411.             'is_object(' $loopon  '))) ' .
  412.             'foreach(' $loopon  " ";
  413.             
  414.         $ret .= "as \${$element->key}";
  415.         
  416.         if ($element->value{
  417.             $ret .=  " => \${$element->value}";
  418.         }
  419.         $ret .= ") {";
  420.         
  421.         $element->pushState();
  422.         $element->pushVar($element->key);
  423.         $element->pushVar($element->value);
  424.         return $this->appendPhp($ret);
  425.     }
  426.     /**
  427.     *   HTML_Template_Flexy_Token_If toString
  428.     *
  429.     * @param    object    HTML_Template_Flexy_Token_If 
  430.     * 
  431.     * @return   string     string to build a template
  432.     * @access   public
  433.     * @see      toString*
  434.     */
  435.   
  436.     function toStringIf($element
  437.     {
  438.         
  439.         $var $element->toVar($element->condition);
  440.         if ($this->is_a($var,'PEAR_Error')) {
  441.             return $var;
  442.         }
  443.         
  444.         $ret "if (".$element->isNegative . $var .")  {";
  445.         $element->pushState();
  446.         return $this->appendPhp($ret);
  447.     }
  448.  
  449.    /**
  450.     *  get Modifier Wrapper
  451.     *
  452.     * converts :h, :u, :r , .....
  453.     * @param    object    HTML_Template_Flexy_Token_Method|Var
  454.     * 
  455.     * @return   array prefix,suffix
  456.     * @access   public
  457.     * @see      toString*
  458.     */
  459.  
  460.     function getModifierWrapper($element
  461.     {
  462.         $prefix 'echo ';
  463.         
  464.         $suffix '';
  465.         $modifier strlen(trim($element->modifier)) $element->modifier : ' ';
  466.         
  467.         switch ($modifier{0}{
  468.             case 'h':
  469.                 break;
  470.             case 'u':
  471.                 $prefix 'echo urlencode(';
  472.                 $suffix ')';
  473.                 break;
  474.             case 'r':
  475.                 $prefix 'echo \'<pre>\'; echo htmlspecialchars(print_r(';
  476.                 $suffix ',true)); echo \'</pre>\';';
  477.                 break;                
  478.             case 'n'
  479.                 // blank or value..
  480.                 $numberformat @$GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']['numberFormat'];
  481.                 $prefix 'echo number_format(';
  482.                 $suffix $GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']['numberFormat'')';
  483.                 break;
  484.             case 'b'// nl2br + htmlspecialchars
  485.                 $prefix 'echo nl2br(htmlspecialchars(';
  486.                 
  487.                 // add language ?
  488.                 $suffix '))';
  489.                 break;
  490.             case ' ':
  491.                 $prefix 'echo htmlspecialchars(';
  492.                 // add language ?
  493.                 $suffix ')';
  494.                 break;
  495.             default:
  496.                $prefix 'echo $this->plugin("'.trim($element->modifier.'",';
  497.                $suffix ')'
  498.             
  499.             
  500.         }
  501.         
  502.         return array($prefix,$suffix);
  503.     }
  504.  
  505.  
  506.  
  507.   /**
  508.     *   HTML_Template_Flexy_Token_Var toString
  509.     *
  510.     * @param    object    HTML_Template_Flexy_Token_Method 
  511.     * 
  512.     * @return   string     string to build a template
  513.     * @access   public
  514.     * @see      toString*
  515.     */
  516.   
  517.     function toStringVar($element
  518.     {
  519.         // ignore modifier at present!!
  520.         
  521.         $var $element->toVar($element->value);
  522.         if ($this->is_a($var,'PEAR_Error')) {
  523.             return $var;
  524.         }
  525.         list($prefix,$suffix$this->getModifierWrapper($element);
  526.         return $this->appendPhp$prefix $var $suffix .';');
  527.     }
  528.    /**
  529.     *   HTML_Template_Flexy_Token_Method toString
  530.     *
  531.     * @param    object    HTML_Template_Flexy_Token_Method 
  532.     * 
  533.     * @return   string     string to build a template
  534.     * @access   public
  535.     * @see      toString*
  536.     */
  537.   
  538.     function toStringMethod($element
  539.     {
  540.  
  541.               
  542.         // set up the modifier at present!!
  543.         list($prefix,$suffix$this->getModifierWrapper($element);
  544.         
  545.         // add the '!' to if
  546.         
  547.         if ($element->isConditional{
  548.             $prefix 'if ('.$element->isNegative;
  549.             $element->pushState();
  550.             $suffix ')';
  551.         }  
  552.         
  553.         
  554.         // check that method exists..
  555.         // if (method_exists($object,'method');
  556.         $bits explode('.',$element->method);
  557.         $method array_pop($bits);
  558.         
  559.         $object implode('.',$bits);
  560.         
  561.         $var $element->toVar($object);
  562.         if ($this->is_a($var,'PEAR_Error')) {
  563.             return $var;
  564.         }
  565.         
  566.         if (($object == 'GLOBALS'&& 
  567.             $GLOBALS['_HTML_TEMPLATE_FLEXY']['currentOptions']['globalfunctions']{
  568.             // we should check if they something weird like: GLOBALS.xxxx[sdf](....)
  569.             $var $method;
  570.         else {
  571.             $prefix 'if ($this->options[\'strict\'] || (isset('.$var.
  572.                 ') && method_exists('.$var .",'{$method}'))) " . $prefix;
  573.             $var $element->toVar($element->method);
  574.         }
  575.         
  576.  
  577.         if ($this->is_a($var,'PEAR_Error')) {
  578.             return $var;
  579.         }
  580.         
  581.         $ret  =  $prefix;
  582.         $ret .=  $var "(";
  583.         $s =0;
  584.          
  585.        
  586.          
  587.         foreach($element->args as $a{
  588.              
  589.             if ($s{
  590.                 $ret .= ",";
  591.             }
  592.             $s =1;
  593.             if ($a{0== '#'{
  594.                 $ret .= '"'addslashes(substr($a,1,-1)) '"';
  595.                 continue;
  596.             }
  597.             
  598.             $var $element->toVar($a);
  599.             if ($this->is_a($var,'PEAR_Error')) {
  600.                 return $var;
  601.             }
  602.             $ret .= $var;
  603.             
  604.         }
  605.         $ret .= ")" $suffix;
  606.         
  607.         if ($element->isConditional{
  608.             $ret .= ' { ';
  609.         else {
  610.             $ret .= ";";
  611.         }
  612.         
  613.         
  614.         
  615.         return $this->appendPhp($ret)
  616.         
  617.          
  618.  
  619.    }
  620.    /**
  621.     *   HTML_Template_Flexy_Token_Processing toString
  622.     *
  623.     * @param    object    HTML_Template_Flexy_Token_Processing 
  624.     * 
  625.     * @return   string     string to build a template
  626.     * @access   public
  627.     * @see      toString*
  628.     */
  629.  
  630.  
  631.     function toStringProcessing($element
  632.     {
  633.         // if it's XML then quote it..
  634.         if (strtoupper(substr($element->value,2,3)) == 'XML'
  635.             return $this->appendPhp("echo '" str_replace("'","\\"."'"$element->value"';");
  636.         }
  637.         // otherwise it's PHP code - so echo it..
  638.         return $element->value;
  639.     }
  640.     
  641.     /**
  642.     *   HTML_Template_Flexy_Token_Text toString
  643.     *
  644.     * @param    object    HTML_Template_Flexy_Token_Text 
  645.     * 
  646.     * @return   string     string to build a template
  647.     * @access   public
  648.     * @see      toString*
  649.     */
  650.  
  651.  
  652.  
  653.     function toStringText($element
  654.     {
  655.         
  656.         // first get rid of stuff thats not translated etc.
  657.         // empty strings => output.
  658.         // comments -> just output
  659.         // our special tags -> output..
  660.         
  661.         if (!strlen(trim($element->value) )) {
  662.             return $this->appendHtml($element->value);
  663.         }
  664.         // dont add comments to translation lists.
  665.          
  666.         if (substr($element->value,0,4== '<!--'{
  667.             return $this->appendHtml($element->value);
  668.         }
  669.         // ignore anything wrapped with {_( .... )_}
  670.         if ($this->inGetTextBlock{
  671.             return $this->appendHtml($element->value);
  672.         }
  673.         
  674.         // argTokens is built before the tag matching (it combined
  675.         // flexy tags into %s, into the string,
  676.         // and made a list of tokens in argTokens.
  677.         
  678.         if (!count($element->argTokens&& !$element->isWord()) {
  679.             return $this->appendHtml($element->value);
  680.         }
  681.         
  682.         // grab the white space at start and end (and keep it!
  683.         
  684.         $value ltrim($element->value);
  685.         $front substr($element->value,0,-strlen($value));
  686.         $value rtrim($element->value);
  687.         $rear  substr($element->value,strlen($value));
  688.         $value trim($element->value);
  689.         
  690.         
  691.         // convert to escaped chars.. (limited..)
  692.         //$value = strtr($value,$cleanArray);
  693.         
  694.         $this->addStringToGettext($value);
  695.         $value $this->flexy->translateString($value);
  696.         // its a simple word!
  697.         if (!count($element->argTokens)) {
  698.             return $this->appendHtml($front $value $rear);
  699.         }
  700.         
  701.         
  702.         // there are subtokens..
  703.         // print_r($element->argTokens );
  704.         $args = array();
  705.         // these should only be text or vars..
  706.         
  707.         foreach($element->argTokens as $i=>$token{
  708.             $args[$token->compile($this);
  709.         }
  710.         
  711.         // we break up the translated string, and put the compiled tags 
  712.         // in between the values here.
  713.         
  714.         $bits explode('%s',$value);
  715.         $ret  $front;
  716.         
  717.         foreach($bits as $i=>$v{
  718.             $ret .= $v @$args[$i];
  719.         }
  720.         
  721.         return  $ret $rear;
  722.         
  723.     }
  724.     /**
  725.     * addStringToGettext
  726.     *
  727.     * Adds a string to the gettext array.
  728.     * 
  729.     * @param   mixed        preferably.. string to store
  730.     *
  731.     * @return   none 
  732.     * @access   public
  733.     */
  734.     
  735.     function addStringToGettext($string
  736.     {
  737.     
  738.         
  739.         
  740.         
  741.         if (!is_string($string)) {
  742.             return;
  743.         }
  744.         
  745.         if (!preg_match('/[a-z]+/i'$string)) {
  746.             return;
  747.         }
  748.         $string trim($string);
  749.         
  750.         if (substr($string,0,4== '<!--'{
  751.             return;
  752.         }
  753.         
  754.         $GLOBALS['_HTML_TEMPLATE_FLEXY_COMPILER']['gettextStrings'][$string;
  755.     }
  756.     
  757.      
  758.      /**
  759.     *   HTML_Template_Flexy_Token_Tag toString
  760.     *
  761.     * @param    object    HTML_Template_Flexy_Token_Tag 
  762.     * 
  763.     * @return   string     string to build a template
  764.     * @access   public
  765.     * @see      toString*
  766.     */
  767.   
  768.     function toStringTag($element{
  769.         if (strpos($element->tag,':'=== false{
  770.             $namespace 'Tag';
  771.         else {
  772.             $bits =  explode(':',$element->tag);
  773.             $namespace $bits[0];
  774.         }
  775.         if ($namespace{0== '/'{
  776.             $namespace substr($namespace,1);
  777.         }
  778.         if (empty($this->tagHandlers[$namespace])) {
  779.             
  780.             require_once 'HTML/Template/Flexy/Compiler/Standard/Tag.php';
  781.             $this->tagHandlers[$namespace&HTML_Template_Flexy_Compiler_Standard_Tag::factory($namespace,$this);
  782.             if (!$this->tagHandlers[$namespace{
  783.                 return HTML_Template_Flexy::staticRaiseError('HTML_Template_Flexy::failed to create Namespace Handler '.$namespace 
  784.                     ' in file ' $GLOBALS['_HTML_TEMPLATE_FLEXY']['filename'],
  785.                     HTML_TEMPLATE_FLEXY_ERROR_SYNTAX ,HTML_TEMPLATE_FLEXY_ERROR_RETURN);
  786.             }
  787.                 
  788.         }
  789.         return $this->tagHandlers[$namespace]->toString($element);
  790.         
  791.         
  792.     }
  793.     
  794.  
  795. }

Documentation generated on Mon, 11 Mar 2019 15:59:58 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.