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.  * This file is released under the LGPL
  18.  * "GNU Lesser General Public License"
  19.  * More information can be found here:
  20.  * {@link http://www.gnu.org/copyleft/lesser.html}
  21.  *
  22.  * @author     Jordi Boggiano <j.boggiano@seld.be>
  23.  * @copyright  Copyright (c) 2008, Jordi Boggiano
  24.  * @license    http://www.gnu.org/copyleft/lesser.html  GNU Lesser General Public License
  25.  * @link       http://dwoo.org/
  26.  * @version    0.9.1
  27.  * @date       2008-05-30
  28.  * @package    Dwoo
  29.  */
  30. function Dwoo_Plugin_include(Dwoo $dwoo$file$cache_time null$cache_id null$compile_id null$data '_root'$assign nullarray $rest array())
  31. {
  32.     if ($file === ''{
  33.         return;
  34.     }
  35.  
  36.     if (preg_match('#^([a-z]{2,}):(.*)$#i'$file$m)) {
  37.         // resource:identifier given, extract them
  38.         $resource $m[1];
  39.         $identifier $m[2];
  40.     else {
  41.         // get the current template's resource
  42.         $resource $dwoo->getTemplate()->getResourceName();
  43.         $identifier $file;
  44.     }
  45.  
  46.     try {
  47.         $include $dwoo->templateFactory($resource$identifier$cache_time$cache_id$compile_id);
  48.     catch (Dwoo_Security_Exception $e{
  49.         return $dwoo->triggerError('Include : Security restriction : '.$e->getMessage()E_USER_WARNING);
  50.     catch (Dwoo_Exception $e{
  51.         return $dwoo->triggerError('Include : '.$e->getMessage()E_USER_WARNING);
  52.     }
  53.  
  54.     if ($include === null{
  55.         return $dwoo->triggerError('Include : Resource "'.$resource.':'.$identifier.'" not found.'E_USER_WARNING);
  56.     elseif ($include === false{
  57.         return $dwoo->triggerError('Include : Resource "'.$resource.'" does not support includes.'E_USER_WARNING);
  58.     }
  59.  
  60.     if ($dwoo->isArray($data)) {
  61.         $vars $data;
  62.     elseif ($dwoo->isArray($cache_time)) {
  63.         $vars $cache_time;
  64.     else {
  65.         $vars $dwoo->readVar($data);
  66.     }
  67.  
  68.     if (count($rest)) {
  69.         $vars $rest $vars;
  70.     }
  71.  
  72.     $out $dwoo->get($include$vars);
  73.  
  74.     if ($assign !== null{
  75.         $dwoo->assignInScope($out$assign);
  76.     else {
  77.         return $out;
  78.     }
  79. }

Documentation generated on Sun, 07 Sep 2008 23:57:52 +0200 by phpDocumentor 1.4.0