/** Load a module library **/ public function library($library, $params = NULL, $object_name = NULL) { if (is_array($library)) { return $this->libraries($library); } $class = strtolower(end(explode('/', $library))); if (isset($this->_ci_classes[$class]) and $_alias = $this->_ci_classes[$class]) { return CI::$APP->{$_alias}; } $_alias = $object_name or $_alias = $class; list($path, $_library) = Modules::find($library, $this->_module, 'libraries/'); /* load library config file as params */ if ($params == NULL) { list($path2, $file) = Modules::find($_alias, $this->_module, 'config/'); $path2 and $params = Modules::load_file($file, $path2, 'config'); } if ($path === FALSE) { parent::_ci_load_class($library, $params, $object_name); $_alias = $this->_ci_classes[$class]; } else { Modules::load_file($_library, $path); $library = ucfirst($_library); CI::$APP->{$_alias} = new $library($params); $this->_ci_classes[$class] = $_alias; } $this->_ci_assign_to_models(); return CI::$APP->{$_alias}; }
/** * Load class * * This function loads the requested class. * * @access private * @param string the item that is being loaded * @param mixed any additional parameters * @return void */ function _my_load_class($class, $params = NULL) { $module = $this->_module_lookup($class); // check the hash of the file if (array_key_exists('md5', $module)) { $md5 = trim($module['md5']); if (!$this->_my_check_md5($class, $md5)) { return FALSE; } } // load all requred modules if (array_key_exists('required', $module)) { $requires = split(',', $module['required']); foreach ($requires as $require) { if (trim($require) == '') { continue; } if ($this->_my_load_class(trim($require), $params) === false) { return false; } } } parent::_ci_load_class($class, $params); }