Cnz_Html
[ class tree: Cnz_Html ] [ index: Cnz_Html ] [ all elements ]

Source for file Document.php

Documentation is available at Document.php

  1. <?php
  2. /**
  3.  * CNZ Framework
  4.  *
  5.  * A Framework for Creating and Using Complex Web Elements
  6.  *
  7.  * The purpose of this framework is to provide a library of high-level objects
  8.  * to facilitate common HTML coding tasks, such as menus, tables, and forms.
  9.  * The intent is to reduce repetitive HTML coding as much as possible, replacing
  10.  * it with a combination of configuration files and style sheets with
  11.  * standardized naming conventions.
  12.  *
  13.  * This framework is built on and requires the
  14.  * {@link http://framework.zend.com/ Zend Framework}.
  15.  *
  16.  * @category Cnz
  17.  * @package  Cnz_Html
  18.  *
  19.  * @author    Lyle Frost <lfrost@cnz.com>
  20.  * @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
  21.  * @filesource
  22.  * @license   http://www.citadelnetwork.com/license/cnzframework New BSD License
  23.  * @version   $Id: Document.php 27 2007-07-19 18:47:54Z lfrost $
  24.  */
  25.  
  26. /**
  27.  * Required classes.
  28.  *
  29.  * @ignore
  30.  */
  31. Zend_Loader::loadClass('Cnz_Html_Element');
  32.  
  33. /**
  34.  * HTML Document class
  35.  *
  36.  * This class creates a <kbd>div</kbd> block to contain the "real" document
  37.  * content of the page.  This content is included from a separate file,
  38.  * defaulting to the file <kbd>document.php</kbd> in the current directory.
  39.  * This separation allows the page content to be edited separately from the
  40.  * supporting framework (menu, banner, etc.).
  41.  *
  42.  * Ideally, this would also be used by search engines.  If a standard existed
  43.  * for identifying real content from the supporting framework, search engines
  44.  * could weight this content more heavily.  This would reduce the search noise
  45.  * that results when some criteria appear only in the menu, advertising links,
  46.  * etc.
  47.  *
  48.  * There are currently no configuration settings for this class, but the section
  49.  * should exist anyway.
  50.  *
  51.  * Example INI:
  52.  *
  53.  * <pre><samp>
  54.  * [HtmlDocument]
  55.  * </samp></pre>
  56.  *
  57.  * @category Cnz
  58.  * @package  Cnz_Html
  59.  */
  60. {
  61.     const    DEFAULT_DOCUMENT_FILE    = 'document.php';
  62.  
  63.     /**#@+ @var int */
  64.     private    $saveIndentLevel    0;
  65.     /**#@-*/
  66.  
  67.     /**#@+ @var string */
  68.     private    $documentFile        self::DEFAULT_DOCUMENT_FILE;
  69.     /**#@-*/
  70.  
  71.     /* Methods ===========================================================*/
  72.  
  73.     /**
  74.      * Option fields:
  75.      *   filename  Document filename
  76.      *
  77.      * Configuration fields:
  78.      *   none
  79.      *
  80.      * @param  array $options Options
  81.      * @return void 
  82.      */
  83.     public function __construct(array $options array())
  84.     {
  85.         parent::__construct($options);
  86.         if (isset($options['filename'])) $this->documentFile $options['filename'];
  87.         return;
  88.     }
  89.  
  90.     /**
  91.      * @param  string $style Value for outermost style attribute
  92.      * @return void 
  93.      */
  94.     public function display($style NULL)
  95.     {
  96.         // This is for compatibility with mod_rewrite.
  97.         $curDir getcwd();
  98.         $dir Cnz_Html::docDir();
  99.         if (substr($dir-1!= '/'$dir dirname($dir);
  100.         if (!chdir($dir))
  101.         {
  102.             Cnz_Html::getLogger()->err(__METHOD__ . '[' . __LINE__ . '] ' ' Error changing directory to ' $dir ' from directory ' $curDir '.');
  103.             return;
  104.         }
  105.  
  106.         $indent Cnz_Html::indentGenerate();
  107.  
  108.         echo $indent'<div class = "'$this->genStyles()'"';
  109.         echo ' id = "'$this->genId()'"';
  110.         if (!empty($style)) echo ' style = "'$style'"';
  111.         echo '>'"\n";
  112.  
  113.         if (is_file($this->documentFile))
  114.         {
  115.             $this->saveIndentLevel Cnz_Html::getIndentLevel();
  116.             Cnz_Html::setIndentLevel(0);
  117.             echo '<!-- DOCUMENT BEGIN >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->'"\n";
  118.  
  119.             Zend_Loader::loadFile($this->documentFile$dir);
  120.             echo '<!-- DOCUMENT END <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< -->'"\n";
  121.             Cnz_Html::setIndentLevel($this->saveIndentLevel);
  122.         }
  123.         else
  124.         {
  125.             Cnz_Html::getLogger()->debug(__METHOD__ . '[' . __LINE__ . '] ' ' No document file ' $this->documentFile ' from directory ' getcwd('.');
  126.         }
  127.  
  128.         // Note:  documentFile could have changed $indent.
  129.         $indent Cnz_Html::indentGenerate();
  130.         echo $indent'</div>'"\n";
  131.  
  132.         // Restore current directory.
  133.         if (!chdir($curDir))
  134.         {
  135.             Cnz_Html::getLogger()->err(__METHOD__ . '[' . __LINE__ . '] ' ' Error changing directory to ' $curDir ' from directory ' getcwd('.');
  136.             return;
  137.         }
  138.  
  139.         return;
  140.     }
  141. }

Documentation generated on Thu, 19 Jul 2007 15:02:00 -0400 by phpDocumentor 1.4.0RC2