| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- if (!defined('APP_PATH_LIB')) define('APP_PATH_LIB', dirname(__FILE__));
- class Lib {
- public static function loadClass($clsName) {
- return self::_loadClass($clsName, $required = true);
- }
- public static function tryLoadClass($clsName) {
- return self::_loadClass($clsName, $required = false);
- }
- /**
- * load Class.
- *
- * @example Core_Database_Mysql - check Core/Database/Mysql.php or Core_Database_Mysql.php file
- */
- public static function _loadClass($clsName, $required = true) {
- if (class_exists($clsName)) return true;
- $path = APP_PATH_LIB . '/' . implode('/', explode('_', $clsName)) . '.php';
- if (file_exists($path)) {
- require_once $path;
- } else {
- $path = APP_PATH_LIB . "/{$clsName}.php";
- if (file_exists($path)) {
- require_once $path;
- }
- }
- if (class_exists($clsName)) {
- return true;
- } else {
- if ($required) {
- die("Cant load class {$clsName}");
- }
- return false;
- }
- }
- public static function loadXslFunction($funcName) {
- return self::_loadXslFunction($funcName, $required = true);
- }
- public static function tryLoadXslFunction($funcName) {
- return self::_loadXslFunction($funcName, $required = false);
- }
- /**
- * load function.
- *
- * @example testFetchWfs -> SE/se-lib/xsl-functions/testFetchWfs.php // function testFetchWfs() {}
- * @example test_fetchWfs -> SE/se-lib/xsl-functions/test/fetchWfs.php // function test_fetchWfs() {}
- */
- public static function _loadXslFunction($funcName, $required = true) {
- DBG::log("_loadXslFunction({$funcName})...");
- if (function_exists($funcName)) return true;
- $path = APP_PATH_LIB . '/xsl-functions/' . implode('/', explode('_', $funcName)) . '.php';
- DBG::log("DBG _loadXslFunction: {$path}");
- if (file_exists($path)) {
- require_once $path;
- } else {
- $path = APP_PATH_LIB . "/xsl-functions/{$funcName}.php";
- DBG::log("DBG _loadXslFunction: {$path}");
- if (file_exists($path)) {
- require_once $path;
- }
- }
- if (function_exists($funcName)) {
- return true;
- } else {
- if ($required) {
- die("Cant load xsl function {$funcName}");
- }
- return false;
- }
- }
- }
|