[ Index ]

PHP Cross Reference of Web Application Component Toolkit

title

Body

[close]

/framework/template/tags/core/ -> include.tag.php (source)

   1  <?php
   2  //--------------------------------------------------------------------------------
   3  // Copyright 2003 Procata, Inc.
   4  // Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html)
   5  //--------------------------------------------------------------------------------
   6  /**
   7  * @package WACT_TAG
   8  * @version $Id: include.tag.php,v 1.18 2004/11/18 04:22:47 jeffmoore Exp $
   9  */
  10  
  11  /**
  12  * Register the tag
  13  */
  14  $taginfo =& new TagInfo('core:INCLUDE', 'CoreIncludeTag');
  15  $taginfo->setEndTag(ENDTAG_FORBIDDEN);
  16  $taginfo->setCompilerAttributes(array('file', 'literal'));
  17  TagDictionary::registerTag($taginfo, __FILE__);
  18  
  19  /**
  20  * Include another template into the current template
  21  * @see http://wact.sourceforge.net/index.php/CoreIncludeTag
  22  * @access protected
  23  * @package WACT_TAG
  24  */
  25  class CoreIncludeTag extends CompilerDirectiveTag {
  26  
  27      /**
  28      * @return int PARSER_FORBID_PARSING
  29      * @access protected
  30      */
  31      function preParse() {
  32          $file = $this->getAttribute('file'); 
  33          if (empty($file)) {
  34              RaiseError('compiler', 'MISSINGREQUIREATTRIBUTE', array(
  35                  'tag' => $this->tag,
  36                  'attribute' => 'file',
  37                  'file' => $this->SourceFile,
  38                  'line' => $this->StartingLineNo));
  39          }
  40      
  41          $sourcefile = ResolveTemplateSourceFileName($file, TMPL_INCLUDE, $this->SourceFile);
  42          if (empty($sourcefile)) {
  43              RaiseError('compiler', 'MISSINGFILE', array(
  44                  'tag' => $this->tag,
  45                  'srcfile' => $file,
  46                  'file' => $this->SourceFile,
  47                  'line' => $this->StartingLineNo));
  48          }
  49  
  50          if ($this->getBoolAttribute('literal')) {
  51              $LiteralComponent =& new TextNode(readTemplateFile($sourcefile));
  52              $this->addChild($LiteralComponent);
  53          } else {
  54              $sfp =& new SourceFileParser($sourcefile);
  55              $sfp->parse($this);
  56          }
  57          return PARSER_FORBID_PARSING;
  58      }
  59  }
  60  ?>


Generated: Sun Nov 28 19:36:09 2004 Cross-referenced by PHPXref 0.5