home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Web Server / PHP.EXE / pear / PHPDoc / accessor / PhpdocAccessor.php next >
Encoding:
PHP Script  |  2001-02-18  |  2.2 KB  |  79 lines

  1. <?php
  2. /**
  3. * Provides an API to access PHPDoc XML files.
  4. * It's up to you eigther to use this class to access 
  5. * the phpdoc xml files or to write your own parser.
  6. *
  7. * @version  $Id: PhpdocAccessor.php,v 1.2 2001/02/18 15:03:05 uw Exp $
  8. */
  9. class PhpdocAccessor extends PhpdocObject {
  10.  
  11.     /**
  12.     * Instance of PhpdocXMLReader
  13.     * @var  object  PhpdocXMLReader $xmlreader
  14.     */    
  15.     var $xmlreader;
  16.     
  17.     /**
  18.     * Result of the PhpdocXMLReader
  19.     * @var    array    $xml
  20.     */
  21.     var $xml = array();
  22.     
  23.     /**
  24.     * Free xml resources on calling a getXY() function?
  25.     * 
  26.     * One of the design goals was to minimize the memory consumption of PHPdoc.
  27.     * So PHPdoc tries to save data as soon as possible to the disk, reuse objects
  28.     * and free resources of an object when they are no longer needed. The default 
  29.     * value of true will cause the object to free the memory used by the 
  30.     * xml data as soon as possible.
  31.     * 
  32.     * @var  boolean
  33.     */    
  34.     var $freeOnGet = true;
  35.  
  36.     /**
  37.     * Reformatted PhpdocXMLReader result array
  38.     * @var  array
  39.     */
  40.     var $data = array();
  41.     
  42.     /**
  43.     * Loads the specified xml file. 
  44.     *
  45.     * @param    string  Name of the xml file
  46.     * @return   boolean False if the given xml file was not 
  47.     *                   found or is empty otherwise true.
  48.     * @access   public
  49.     * @see      init()
  50.     */
  51.     function loadXMLFile($filename) {
  52.     
  53.         $this->xmlreader = new PhpdocXMLReader;
  54.         
  55.         $this->xml = $this->xmlreader->parse($filename);
  56.         $this->xml = $this->xml["phpdoc"];
  57.         $ok = (!is_array($this->xml) || 0 == count($this->xml)) ? false : true;
  58.         
  59.         $this->init();
  60.         
  61.         return $ok;        
  62.     } // end func loadXMLFile
  63.         
  64.     /**
  65.     * Reformats the xml result array from the PhpdocXMLReader.
  66.     * 
  67.     * Every derived class must override this function to call the functions
  68.     * it needs to reorganize the data from the PhpdocXMLReader in a 
  69.     * way that it needs. 
  70.     *
  71.     * @abstract
  72.     * @see    $xml, $data
  73.     */
  74.     function init() {
  75.     } // end func init
  76.  
  77. } // end class PhpdocAccessor
  78. ?>