Source for file load_templates.php

Documentation is available at load_templates.php

  1. <?php
  2.  
  3. /**
  4.  * Loads sub-templates contained in an external file
  5.  * <pre>
  6.  *  * file : the resource name of the file to load
  7.  * </pre>
  8.  * This software is provided 'as-is', without any express or implied warranty.
  9.  * In no event will the authors be held liable for any damages arising from the use of this software.
  10.  *
  11.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  12.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  13.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  14.  * @link       http://dwoo.org/
  15.  * @version    1.1.0
  16.  * @date       2009-07-18
  17.  * @package    Dwoo
  18.  */
  19. function Dwoo_Plugin_load_templates_compile(Dwoo_Compiler $compiler$file)
  20. {
  21.     $file substr($file1-1);
  22.  
  23.     if ($file === ''{
  24.         return;
  25.     }
  26.  
  27.     if (preg_match('#^([a-z]{2,}):(.*)$#i'$file$m)) {
  28.         // resource:identifier given, extract them
  29.         $resource $m[1];
  30.         $identifier $m[2];
  31.     else {
  32.         // get the current template's resource
  33.         $resource $compiler->getDwoo()->getTemplate()->getResourceName();
  34.         $identifier $file;
  35.     }
  36.  
  37.     $tpl $compiler->getDwoo()->templateFactory($resource$identifier);
  38.  
  39.     if ($tpl === null{
  40.         throw new Dwoo_Compilation_Exception($compiler'Load Templates : Resource "'.$resource.':'.$identifier.'" not found.');
  41.     elseif ($tpl === false{
  42.         throw new Dwoo_Compilation_Exception($compiler'Load Templates : Resource "'.$resource.'" does not support includes.');
  43.     }
  44.  
  45.     $cmp clone $compiler;
  46.     $cmp->compile($compiler->getDwoo()$tpl);
  47.     foreach ($cmp->getTemplatePlugins(as $template=>$args{
  48.         $compiler->addTemplatePlugin($template$args['params']$args['uuid']$args['body']);
  49.     }
  50.     foreach ($cmp->getUsedPlugins(as $plugin=>$type{
  51.         $compiler->addUsedPlugin($plugin$type);
  52.     }
  53.  
  54.     $out '\'\';// checking for modification in '.$resource.':'.$identifier."\r\n";
  55.     
  56.     $modCheck $tpl->getIsModifiedCode();
  57.     
  58.     if ($modCheck{
  59.         $out .= 'if (!('.$modCheck.')) { ob_end_clean(); return false; }';
  60.     else {
  61.         $out .= 'try {
  62.     $tpl = $this->templateFactory("'.$resource.'", "'.$identifier.'");
  63. } catch (Dwoo_Exception $e) {
  64.     $this->triggerError(\'Load Templates : Resource <em>'.$resource.'</em> was not added to Dwoo, can not extend <em>'.$identifier.'</em>\', E_USER_WARNING);
  65. }
  66. if ($tpl === null)
  67.     $this->triggerError(\'Load Templates : Resource "'.$resource.':'.$identifier.'" was not found.\', E_USER_WARNING);
  68. elseif ($tpl === false)
  69.     $this->triggerError(\'Load Templates : Resource "'.$resource.'" does not support extends.\', E_USER_WARNING);
  70. if ($tpl->getUid() != "'.$tpl->getUid().'") { ob_end_clean(); return false; }';
  71.     }
  72.     
  73.     return $out;
  74. }

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