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

Source for file PHPFile.class.php

Documentation is available at PHPFile.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package filesystem
  9.  */
  10. if!defined"CLASSPATH" ) )
  11. {
  12.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  13.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  14.   exit();
  15. }
  16.  
  17. /**
  18.  *
  19.  */
  20. require_onceCLASSPATH."filesystem/Files.class.php" );
  21.  
  22. /**
  23.  * A class to create php-files who using this class-library.
  24.  *
  25.  * @package   filesystem
  26.  * @version   0.1.3
  27.  * @author    Daniel Plücken <daniel@debakel.net>
  28.  * @license   http://www.gnu.org/copyleft/lesser.html
  29.  *             GNU Lesser General Public License
  30.  * @copyright Copyright (c) 2003 Daniel Plücken <daniel@debakel.net>
  31.  *
  32.  *  This library is free software; you can redistribute it and/or
  33.  *  modify it under the terms of the GNU Lesser General Public
  34.  *  License as published by the Free Software Foundation; either
  35.  *  version 2.1 of the License.
  36.  *
  37.  *  This library is distributed in the hope that it will be useful,
  38.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  39.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  40.  *  GNU Lesser General Public License for more details.
  41.  *
  42.  *  You should have received a copy of the GNU Lesser General
  43.  *  Public License along with this library; if not, write to the
  44.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  45.  *  Boston, MA 02111-1307 USA
  46.  */
  47. class PHPFile extends Files
  48. {
  49.   /**
  50.    * @access public
  51.    * @var    string $pathtoclasses 
  52.    */
  53.   var $pathtoclasses;
  54.   /**
  55.    * @access public
  56.    * @var    array  $includes 
  57.    */
  58.   var $includes = array"html/HTMLDocument.inc.php" );
  59.   /**
  60.    * @access public
  61.    * @var    HTMLDocument 
  62.    */
  63.   var $htmldoc;
  64.  
  65.  
  66.  
  67.  
  68.    /**
  69.     * Constructor
  70.     *
  71.     * @version 1.0
  72.     * @since   0.1.0
  73.     * @author  Daniel Plücken <daniel@debakel.net>
  74.     * @access  public
  75.     * @param   string  $path_and_filename 
  76.     * @or
  77.     * @param   string  $path 
  78.     * @param   string  $filename 
  79.     */
  80.   function PHPFile()
  81.   {
  82.      $param func_get_args();
  83.      
  84.      $this->Files$param[0]$param[1);
  85.   }
  86.  
  87.  
  88.  
  89.  
  90.    /**
  91.     * Sets pathtoclasses, the variable of this object, that should contain the
  92.     * path to the class library relatively from the location of this file.
  93.     *
  94.     * @version 1.0
  95.     * @since   0.1.0
  96.     * @author  Daniel Plücken <daniel@debakel.net>
  97.     * @access  public
  98.     * @param   string  $string  the path to the class-library relativly from the
  99.     *                            location of this file.
  100.     */
  101.   function setPathToClasses$string )
  102.   $this->pathtoclasses = $string}
  103.  
  104.  
  105.  
  106.  
  107.   /**
  108.     * Sets htmldoc, the variable of this object, that should contain the
  109.     * object's reference of the html-document whose sourcecode will be
  110.     * written if this object will be printed.
  111.     *
  112.     * @version 1.0
  113.     * @since   0.1.0
  114.     * @author  Daniel Plücken <daniel@debakel.net>
  115.     * @access  public
  116.     * @param   HTMLDocument $doc_ref  The path to the class-library relativly
  117.     *                                  from the location of this file.
  118.     */
  119.   function setDocument&$doc_ref )
  120.   $this->htmldoc =$doc_ref}
  121.  
  122.  
  123.  
  124.  
  125.    /**
  126.     * Adds a sourcepath to the array "includes" of this object.
  127.     *
  128.     * @version 1.0
  129.     * @since   0.1.0
  130.     * @author  Daniel Plücken <daniel@debakel.net>
  131.     * @access  public
  132.     * @param   string  $string  The path to a script in the class-library.
  133.     */
  134.   function addInclude$string )
  135.   {
  136.      $doinc true;
  137.      for$i 0$i count$this->includes )$i++ )
  138.        if$this->includes[$i== $string )
  139.        {
  140.           $doinc false;
  141.           break;
  142.        }
  143.      
  144.      if$doinc )
  145.        $this->includes[$string;
  146.   }
  147.  
  148.  
  149.  
  150.  
  151.   /**
  152.     * Adds items to the object that is referenced in the object's variable
  153.     * "htmldoc".
  154.     *
  155.     * @version 1.0
  156.     * @since   0.1.0
  157.     * @author  Daniel Plücken <daniel@debakel.net>
  158.     * @access  public
  159.     * @param   HTMLDocument $item_ref 
  160.     * @return  string 
  161.     */
  162.   function addItem&$item_ref )
  163.   $this->htmldoc->addItem$item_ref )}
  164.  
  165.  
  166.  
  167.  
  168.    /**
  169.     * Returns the source of the generated php-file.
  170.     *
  171.     * @version 1.0
  172.     * @since   0.1.0
  173.     * @author  Daniel Plücken <daniel@debakel.net>
  174.     * @access  public
  175.     * @return  string 
  176.     */
  177.   function get()
  178.   {
  179.      $outputstr  "<?php\n";
  180.      $outputstr .= "\x24classpath = \""
  181.                   .!empty$this->pathtoclasses )
  182.                      ? $this->pathtoclasses
  183.                      : "./"
  184.                    )
  185.                   ."\";\n\n";
  186.      for$i 0$i count$this->includes )$i++ )
  187.        $outputstr .= "include( \x24classpath.\"".$this->includes[$i]."\" );\n";
  188.      
  189.      $outputstr .= "\n";
  190.      
  191.      $outputstr .= $this->htmldoc->getPHPSource();
  192.      
  193.      $outputstr .= "?>\n";
  194.      
  195.      return $outputstr;
  196.   }
  197. // END of class PHPFile
  198. ?>

Documentation generated on Thu, 05 Jun 2008 19:14:43 +0200 by phpDocumentor 1.4.1