• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List

E:/E/GEAMP/www/openbiz/openbiz/others/Zend/Loader.php

00001 <?php
00030 class Zend_Loader
00031 {
00052     public static function loadClass($class, $dirs = null)
00053     {
00054         if (class_exists($class, false) || interface_exists($class, false)) {
00055             return;
00056         }
00057 
00058         if ((null !== $dirs) && !is_string($dirs) && !is_array($dirs)) {
00059             require_once 'Zend/Exception.php';
00060             throw new Zend_Exception('Directory argument must be a string or an array');
00061         }
00062 
00063         // autodiscover the path from the class name
00064         $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php';
00065         if (!empty($dirs)) {
00066             // use the autodiscovered path
00067             $dirPath = dirname($file);
00068             if (is_string($dirs)) {
00069                 $dirs = explode(PATH_SEPARATOR, $dirs);
00070             }
00071             foreach ($dirs as $key => $dir) {
00072                 if ($dir == '.') {
00073                     $dirs[$key] = $dirPath;
00074                 } else {
00075                     $dir = rtrim($dir, '\\/');
00076                     $dirs[$key] = $dir . DIRECTORY_SEPARATOR . $dirPath;
00077                 }
00078             }
00079             $file = basename($file);
00080             self::loadFile($file, $dirs, true);
00081         } else {
00082             self::loadFile($file);
00083         }
00084 
00085         if (!class_exists($class, false) && !interface_exists($class, false)) {
00086             require_once 'Zend/Exception.php';
00087             throw new Zend_Exception("File \"$file\" does not exist or class \"$class\" was not found in the file");
00088         }
00089     }
00090 
00114     public static function loadFile($filename, $dirs = null, $once = false)
00115     {
00116         self::_securityCheck($filename);
00117 
00121         $incPath = false;
00122         if (!empty($dirs) && (is_array($dirs) || is_string($dirs))) {
00123             if (is_array($dirs)) {
00124                 $dirs = implode(PATH_SEPARATOR, $dirs);
00125             }
00126             $incPath = get_include_path();
00127             set_include_path($dirs . PATH_SEPARATOR . $incPath);
00128         }
00129 
00133         if ($once) {
00134             include_once $filename;
00135         } else {
00136             include $filename;
00137         }
00138 
00142         if ($incPath) {
00143             set_include_path($incPath);
00144         }
00145 
00146         return true;
00147     }
00148 
00162     public static function isReadable($filename)
00163     {
00164         if (!$fh = @fopen($filename, 'r', true)) {
00165             return false;
00166         }
00167         @fclose($fh);
00168         return true;
00169     }
00170 
00183     public static function autoload($class)
00184     {
00185         trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
00186         try {
00187             @self::loadClass($class);
00188             return $class;
00189         } catch (Exception $e) {
00190             return false;
00191         }
00192     }
00193 
00204     public static function registerAutoload($class = 'Zend_Loader', $enabled = true)
00205     {
00206         trigger_error(__CLASS__ . '::' . __METHOD__ . ' is deprecated as of 1.8.0 and will be removed with 2.0.0; use Zend_Loader_Autoloader instead', E_USER_NOTICE);
00207         require_once 'Zend/Loader/Autoloader.php';
00208         $autoloader = Zend_Loader_Autoloader::getInstance();
00209         $autoloader->setFallbackAutoloader(true);
00210 
00211         if ('Zend_Loader' != $class) {
00212             self::loadClass($class);
00213             $methods = get_class_methods($class);
00214             if (!in_array('autoload', (array) $methods)) {
00215                 require_once 'Zend/Exception.php';
00216                 throw new Zend_Exception("The class \"$class\" does not have an autoload() method");
00217             }
00218 
00219             $callback = array($class, 'autoload');
00220 
00221             if ($enabled) {
00222                 $autoloader->pushAutoloader($callback);
00223             } else {
00224                 $autoloader->removeAutoloader($callback);
00225             }
00226         }
00227     }
00228 
00236     protected static function _securityCheck($filename)
00237     {
00241         if (preg_match('/[^a-z0-9\\/\\\\_.:-]/i', $filename)) {
00242             require_once 'Zend/Exception.php';
00243             throw new Zend_Exception('Security check: Illegal character in filename');
00244         }
00245     }
00246 
00261     protected static function _includeFile($filespec, $once = false)
00262     {
00263         if ($once) {
00264             return include_once $filespec;
00265         } else {
00266             return include $filespec ;
00267         }
00268     }
00269 }

Generated on Thu Apr 19 2012 17:01:17 for openbiz by  doxygen 1.7.2