@@ 478-498 (lines=21) @@ | ||
475 | * |
|
476 | * @return bool |
|
477 | */ |
|
478 | public static function loadClass($class) |
|
479 | { |
|
480 | if (class_exists($class, false) || interface_exists($class, false)) { |
|
481 | return true; |
|
482 | } |
|
483 | ||
484 | $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; |
|
485 | if (!self::loadFile(\XoopsBaseConfig::get('lib-path') . DIRECTORY_SEPARATOR . $file)) { |
|
486 | return false; |
|
487 | } |
|
488 | ||
489 | if (!class_exists($class, false) && !interface_exists($class, false)) { |
|
490 | return false; |
|
491 | } |
|
492 | ||
493 | if (method_exists($class, '__autoload')) { |
|
494 | call_user_func(array($class, '__autoload')); |
|
495 | } |
|
496 | ||
497 | return true; |
|
498 | } |
|
499 | ||
500 | /** |
|
501 | * Use this method instead of XoopsLoad::fileExists for increasing performance |
@@ 59-80 (lines=22) @@ | ||
56 | * |
|
57 | * @return bool if class exists |
|
58 | */ |
|
59 | public static function loadClass($class) |
|
60 | { |
|
61 | if (class_exists($class, false) || interface_exists($class, false)) { |
|
62 | return true; |
|
63 | } |
|
64 | ||
65 | $file = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; |
|
66 | if (!self::loadFile(dirname(__DIR__) . DIRECTORY_SEPARATOR . $file)) { |
|
67 | return false; |
|
68 | } |
|
69 | ||
70 | if (!class_exists($class, false) && !interface_exists($class, false)) { |
|
71 | trigger_error( |
|
72 | "File \"$file\" does not exist or class \"$class\" was not found in the file", |
|
73 | E_USER_WARNING |
|
74 | ); |
|
75 | ||
76 | return false; |
|
77 | } |
|
78 | ||
79 | return true; |
|
80 | } |
|
81 | ||
82 | /** |
|
83 | * Ensure that filename does not contain exploits |