Source for file include.php

Documentation is available at include.php

  1. <?php
  2.  
  3. /**
  4.  * Inserts another template into the current one
  5.  * <pre>
  6.  *  * file : the resource name of the template
  7.  *  * cache_time : cache length in seconds
  8.  *  * cache_id : cache identifier for the included template
  9.  *  * compile_id : compilation identifier for the included template
  10.  *  * data : data to feed into the included template, it can be any array and will default to $_root (the current data)
  11.  *  * assign : if set, the output of the included template will be saved in this variable instead of being output
  12.  *  * rest : any additional parameter/value provided will be added to the data array
  13.  * </pre>
  14.  * This software is provided 'as-is', without any express or implied warranty.
  15.  * In no event will the authors be held liable for any damages arising from the use of this software.
  16.  *
  17.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  18.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  19.  * @license    http://dwoo.org/LICENSE   Modified BSD License
  20.  * @link       http://dwoo.org/
  21.  * @version    1.1.0
  22.  * @date       2009-07-18
  23.  * @package    Dwoo
  24.  */
  25. function Dwoo_Plugin_include(Dwoo $dwoo$file$cache_time null$cache_id null$compile_id null$data '_root'$assign nullarray $rest array())
  26. {
  27.     if ($file === ''{
  28.         return;
  29.     }
  30.  
  31.     if (preg_match('#^([a-z]{2,}):(.*)$#i'$file$m)) {
  32.         // resource:identifier given, extract them
  33.         $resource $m[1];
  34.         $identifier $m[2];
  35.     else {
  36.         // get the current template's resource
  37.         $resource $dwoo->getTemplate()->getResourceName();
  38.         $identifier $file;
  39.     }
  40.  
  41.     try {
  42.         if (!is_numeric($cache_time)) {
  43.             $cache_time null;
  44.         }
  45.         $include $dwoo->templateFactory($resource$identifier$cache_time$cache_id$compile_id);
  46.     catch (Dwoo_Security_Exception $e{
  47.         return $dwoo->triggerError('Include : Security restriction : '.$e->getMessage()E_USER_WARNING);
  48.     catch (Dwoo_Exception $e{
  49.         return $dwoo->triggerError('Include : '.$e->getMessage()E_USER_WARNING);
  50.     }
  51.  
  52.     if ($include === null{
  53.         return $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.'E_USER_WARNING);
  54.     elseif ($include === false{
  55.         return $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.'E_USER_WARNING);
  56.     }
  57.  
  58.     if ($dwoo->isArray($data)) {
  59.         $vars $data;
  60.     elseif ($dwoo->isArray($cache_time)) {
  61.         $vars $cache_time;
  62.     else {
  63.         $vars $dwoo->readVar($data);
  64.     }
  65.  
  66.     if (count($rest)) {
  67.         $vars $rest $vars;
  68.     }
  69.  
  70.     $out $dwoo->get($include$vars);
  71.  
  72.     if ($assign !== null{
  73.         $dwoo->assignInScope($out$assign);
  74.     else {
  75.         return $out;
  76.     }
  77. }

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