Revision 2010
Added by darkviper almost 11 years ago
WbAutoloader.php | ||
---|---|---|
16 | 16 |
*/ |
17 | 17 |
static public function doRegister(array $aDirectories) |
18 | 18 |
{ |
19 |
if(!sizeof(self::$_aSearchpatterns)) { |
|
20 |
if(sizeof($aDirectories > 0)) { |
|
19 |
if(!sizeof(self::$_aSearchpatterns)) |
|
20 |
{ |
|
21 |
if(sizeof($aDirectories > 0)) |
|
22 |
{ |
|
21 | 23 |
self::$_aSearchpatterns[] = '/(^.[^_].*$)/i'; |
22 |
self::$_aReplacements[] = basename(dirname(__FILE__)).'_$1'; |
|
23 |
foreach($aDirectories as $value => $shortKey) { |
|
24 |
self::$_aReplacements[] = basename(dirname(__FILE__)).'_\1'; |
|
25 |
foreach($aDirectories as $value => $shortKey) |
|
26 |
{ |
|
24 | 27 |
self::$_aSearchpatterns[] = '/^'.$shortKey.'_/i'; |
25 | 28 |
self::$_aReplacements[] = $value.'_'; |
26 | 29 |
} |
... | ... | |
34 | 37 |
*/ |
35 | 38 |
static public function CoreAutoloader($sClassName) |
36 | 39 |
{ |
37 |
if($sClassName == 'database'){ |
|
38 |
$sFileName = dirname(__FILE__).'/class.database.php'; |
|
39 |
if(is_file($sFileName)) { include($sFileName); } |
|
40 |
}else { |
|
41 |
$sClassName = preg_replace(self::$_aSearchpatterns, self::$_aReplacements, $sClassName); |
|
42 |
$sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php'; |
|
43 |
if(is_file($sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php')) { |
|
44 |
include($sFileName); |
|
40 |
$sClassName = preg_replace(self::$_aSearchpatterns, self::$_aReplacements, $sClassName); |
|
41 |
$sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php'; |
|
42 |
if (!is_file($sFileName = dirname(dirname(__FILE__)).'/'.str_replace('_', '/', $sClassName).'.php')) { |
|
43 |
// alternatively search for file with prefix 'class.' |
|
44 |
if (!is_file(($sFileName = dirname($sFileName).'/class.'.basename($sFileName)))) { |
|
45 |
return false; |
|
45 | 46 |
} |
46 | 47 |
} |
48 |
include($sFileName); |
|
47 | 49 |
} |
48 | 50 |
} // end class Autoloader |
Also available in: Unified diff
! WbAutoloader added possibility to load classes with additional file prefix 'class.'