Source for file pre.smarty_compat.php

Documentation is available at pre.smarty_compat.php

  1. <?php
  2.  
  3. /**
  4.  * Performs some template conversions to allow smarty templates to be used by
  5.  * the Dwoo compiler.
  6.  *
  7.  * This software is provided 'as-is', without any express or implied warranty.
  8.  * In no event will the authors be held liable for any damages arising from the use of this software.
  9.  *
  10.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  11.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  12.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  13.  * @link       http://dwoo.org/
  14.  * @version    1.0.0
  15.  * @date       2008-10-23
  16.  * @package    Dwoo
  17.  */
  18. {
  19.     public function process($input)
  20.     {
  21.         list($l$r$this->compiler->getDelimiters();
  22.  
  23.         $rl preg_quote($l,'/');
  24.         $rr preg_quote($r,'/');
  25.         $sectionParam '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*';
  26.         $input preg_replace_callback('/'.$rl.'\s*section '.str_repeat($sectionParam6).'\s*'.$rr.'(.+?)(?:'.$rl.'\s*sectionelse\s*'.$rr.'(.+?))?'.$rl.'\s*\/section\s*'.$rr.'/is'array($this'convertSection')$input);
  27.         $input str_replace('$smarty.section.''$smarty.for.'$input);
  28.  
  29.         $smarty array
  30.         (
  31.             '/'.$rl.'\s*ldelim\s*'.$rr.'/',
  32.             '/'.$rl.'\s*rdelim\s*'.$rr.'/',
  33.             '/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/',
  34.             '/'.$rl.'\s*\$smarty\.rdelim\s*'.$rr.'/',
  35.             '/\$smarty\./',
  36.             '/'.$rl.'\s*php\s*'.$rr.'/',
  37.             '/'.$rl.'\s*\/php\s*'.$rr.'/',
  38.             '/\|(@?)strip(\||'.$rr.')/',
  39.             '/'.$rl.'\s*sectionelse\s*'.$rr.'/',
  40.         );
  41.  
  42.         $dwoo array
  43.         (
  44.             '\\'.$l,
  45.             $r,
  46.             '\\'.$l,
  47.             $r,
  48.             '$dwoo.',
  49.             '<?php ',
  50.             ' ?>',
  51.             '|$1whitespace$2',
  52.             $l.'else'.$r,
  53.         );
  54.  
  55.         if (preg_match('{\|@([a-z][a-z0-9_]*)}i'$input$matches)) {
  56.             trigger_error('The Smarty Compatibility Module has detected that you use |@'.$matches[1].' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator'E_USER_NOTICE);
  57.         }
  58.  
  59.         return preg_replace($smarty$dwoo$input);
  60.     }
  61.  
  62.     protected function convertSection(array $matches)
  63.     {
  64.         $params array();
  65.         $index 1;
  66.         while (!empty($matches[$index]&& $index 13{
  67.             $params[$matches[$index]] $matches[$index+1];
  68.             $index += 2;
  69.         }
  70.         return str_replace('['.trim($params['name']'"\'').']''[$'.trim($params['name']'"\'').']'$matches[0]);
  71.     }
  72. }

Documentation generated on Sun, 07 Feb 2010 17:53:54 +0000 by phpDocumentor 1.4.0