00001 <?php
00025 global $cld;
00026 $cld = array('pix', 'js', 'css', 'vbs', 'ldr');
00027 global ${Z_IN_CRYPT_VAR_NAME};
00033 class zLoader extends zCore{
00034 var $class;
00035 var $loaded_mods = array();
00036
00037 function zLoader(){
00038 $this->__construct();
00039 }
00045 function __construct(){
00046 parent::__construct();
00047 if(!defined('MOD_INTERNAL')){define("MOD_INTERNAL", "module-abstract");}
00048 if(!defined('MOD_EXPLICIT')){define("MOD_EXPLICIT", "module");}
00049 if(!defined('PLUG_INTERNAL')){define("PLUG_INTERNAL", "plugin-abstract");}
00050 if(!defined('PLUG_EXPLICIT')){define("PLUG_EXPLICIT", "plugin");}
00051 if(!defined('Z_CLS_LOAD_CNS')){define('Z_CLS_LOAD_CNS', 1);}
00052 if(!defined('Z_MODULE_FILE_NAME')){define('Z_MODULE_FILE_NAME', 'class.ini.php');}
00053 $this->class = parse_ini_file(ZIGSETTINGS.DRS.'class.ini.php', true);
00054 }
00064 function ld($path, $str, $indx){
00065
00066 $trg = ZIGROOT.DRS.$path.DRS.@$this->class[$indx][$str];
00067 if(!@in_array($str, array_keys($this->class[$indx]))){
00068 perror("Sorry the ".$indx." `".$str."` is not Installed/listed/Found according to ".Z_MODULE_FILE_NAME);
00069 }else{
00070 if(file_exists($trg) && is_readable($trg)){
00071 if(!@isset($this->loaded_mods[$indx][$str])){
00072 $this->loaded_mods[$indx][$str] = $path;
00073 include_once($trg);
00074 }
00075 }else{
00076 is_file($trg) ? $sts = "Not readable [ Permission : ".fileperms($trg)." ]" : $sts = "Not Present";
00077 perror("<code>zigmoyd.loader</code><br />Sorry the ".$path." `".$str."` is Not accessible<br /> as the file `".$trg."` is ".$sts);
00078 }
00079 }
00080 }
00092 function module($str, $mode = MOD_EXPLICIT){
00093 if($mode == MOD_EXPLICIT){$key = MOD_KEY_NAME_EXPLICIT;}elseif($mode == MOD_INTERNAL){
00094 $key = MOD_KEY_NAME_INTERNAL;}else{perror("Unknown Mode `".$mode."` Specified");}
00095 $this->ld($key, $str, $mode);
00096 }
00107 function modules(){
00108 $lst_args = func_get_args();
00109 foreach($lst_args as $key => $val){
00110 if(!is_array($val)){$this->module($val);}
00111 else{foreach($val as $k => $v){$this->module($v);}}
00112 }
00113 }
00124 function plugin($str, $mode = PLUG_EXPLICIT){
00125 if($mode == PLUG_EXPLICIT){$key = PLUG_KEY_NAME_EXPLICIT;}elseif($mode == PLUG_INTERNAL){
00126 $key = PLUG_KEY_NAME_INTERNAL;}else{perror("Unknown Mode `".$mode."` Specified");}
00127 $this->ld($key, $str, $mode);
00128 }
00139 function plugins(){
00140 $lst_args = func_get_args();
00141 foreach($lst_args as $var){
00142 $this->plugin($val);
00143 }
00144 }
00150 function lib($libName){
00151 if(!file_exists(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.Z_DIR_LOCAL_LIB.DRS.$libName.'.lib.php')){
00152 perror("<code>zigmoyd.loader.lib</code><br />Failed to load Lib $libName as file $libName.lib.php doesn't exist");
00153 return false;
00154 }
00155 if(!is_readable(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.Z_DIR_LOCAL_LIB.DRS.$libName.'.lib.php')){
00156 perror("<code>zigmoyd.loader.lib</code><br />Failed to load Lib $libName as file $libName.lib.php is not readable");
00157 return false;
00158 }
00159 include_once(ZIGROOT.DRS.Z_DIR_PROJECTS.DRS.Z_PROJECT_DIR.DRS.Z_DIR_LOCAL_LIB.DRS.$libName.'.lib.php');
00160 return true;
00161 }
00167 function listModules(){
00168 return array_keys($this->class['module']);
00169 }
00175 function listPlugins(){
00176 return array_keys($this->class['plugin']);
00177 }
00178 }
00180 ?>