Source for file Load.class.php

Documentation is available at Load.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Load
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Load Interface
  22.  * 
  23.  * The Load Interface provides a way for the program to easily Load various files
  24.  * into memory.  It also includes a file hunter method, which is responsible for
  25.  * searching for the existence of a file and returning the full path to the file.
  26.  * 
  27.  * The Custom Path feature is used to indicate a custom directory to search through
  28.  * first.  This directory should model the structure of the Home directory, but
  29.  * contains the files to load first.  The custom directory should only hold files
  30.  * with modifications, not all orinigals.  This allows the programmer to make modifications
  31.  * to source code without actually replacing the orinigal source.  For example, if
  32.  * using the Gumbo Library, the custom directory will hold any changes the programmer
  33.  * makes to any of the class files.  In the event the Gumbo Library has a new release,
  34.  * the source can be updated without losing any modifications made by the programmer.  The
  35.  * programmer will be responsible for updating any modifications to the new version.
  36.  *
  37.  * @category Gumbo
  38.  * @package Load
  39.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  40.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  41.  * @author Michael Luster <mluster79@yahoo.com>
  42.  * @link http://sourceforge.net/projects/phpgumbo
  43.  * @desc Load Interface
  44.  * @version 0.0.1
  45.  */
  46.  
  47. interface Gumbo_Interface_Load {
  48.     
  49.     /** ACTION METHODS **/
  50.     /**
  51.      * Quick load of a file using a session key
  52.      * 
  53.      * The method will require the file name and a Load Setting key reference.
  54.      * If no key is defined, or the key doesn't exist, the default
  55.      * settings will be used.  The method is a quick wrapper to the Load_File method.
  56.      * 
  57.      * The return_path parameter, if set, will return the full file path.  This
  58.      * is useful for performing direct includes of various types of files.
  59.      * 
  60.      * @param string $name file name
  61.      * @param string $key settings reference
  62.      * @param bool $return_path returns the formatted path string
  63.      * @return mix 
  64.      */
  65.     public function load ($name$key=null$return_path=false);
  66.     
  67.     /**
  68.      * Loads a Class file into memory
  69.      * 
  70.      * The load class will load a class file into memory only once.  The arguments
  71.      * expect the same values as defined by the Gumbo_Interface_Load_Setting.
  72.      * 
  73.      * @param string $name class name
  74.      * @param string|array$dirs starting locations
  75.      * @param string $ext class file extension (default: 'php')
  76.      * @param bool $stretch stretch the class name as directories (default: false)
  77.      * @param string $separator class name separator (default: "_")
  78.      * @param string $path which path to search through (default: "include") [include|home|absolute]
  79.      * @param string $remove removes string pattern from the class name when performing a file search
  80.      * @return bool 
  81.      */
  82.     public function loadClass ($name$dirs=null$ext=null$stretch=false$separator=null$path="include"$remove=null);
  83.     
  84.     /**
  85.      * Loads a file into memory.  The arguments expect the same values as defined
  86.      * by Gumbo_Interface_Load_Setting.
  87.      * @param string $name class name
  88.      * @param string|array$dirs locations to search through
  89.      * @param string $ext file extension (default: 'php')
  90.      * @param bool $once loads the file only once (default: false)
  91.      * @param bool $use_include use include instead of require (default: false)
  92.      * @param bool $stretch stretches the directory path based on the file name (default: false)
  93.      * @param string $separator character separating the directory names inside the file name (default: "_")
  94.      * @param string $path start path to the file (default: include) [include|home|absolute]
  95.      * @param string $remove removes a string pattern from the file name when performing a file search
  96.      * @return bool 
  97.      */
  98.     public function loadFile ($name$dirs=null$ext=null$once=false$use_include=false$stretch=false$separator=null$path=null$remove=null);
  99.     
  100.     
  101.     
  102.     /** MUTATOR METHODS **/
  103.     /**
  104.      * Sets the Custom Class File location
  105.      * @precondition is_dir ($loc)
  106.      * @param string $loc 
  107.      */
  108.     public function setDirCustom ($loc);
  109.     
  110.     
  111.     
  112.     /** ACCESSOR METHODS **/
  113.     /**
  114.      * Returns the home directory
  115.      * @return string 
  116.      */
  117.     public function getDirHome ();
  118.     
  119.     /**
  120.      * Returns the Custom directory
  121.      * @return string 
  122.      */
  123.     public function getDirCustom ();
  124.     
  125.     
  126.     
  127.     /**
  128.      * Returns a formatted file path.  The parameters expect the same values as defined
  129.      * by Gumbo_Interface_Load_Setting.
  130.      * @param string $name file name
  131.      * @param string|array$dirs locations to search through (from path)
  132.      * @param string $ext file extension (if null, uses the string from the last dot *.ext)
  133.      * @param bool $stretch stretch the file name from the path directory
  134.      * @param string $separator stretch separator character (typically "." or "_")
  135.      * @param string $path path to start from (default: include) [include|home|absolute]
  136.      * @param string $remove removes string pattern from the file name before file search
  137.      * @return string 
  138.      */
  139.     public function getFullPath ($name$dirs=null$ext=null$stretch=false$separator=null$path="include"$remove=null);
  140.     
  141. }
  142.  
  143. ?>