/** * Loads the library's dependencies and configuration. * * @return void */ public static function initialize() { // get all installed extensions if (empty(self::$extensions)) { self::$CI =& get_instance(); self::$extensions = self::$CI->extension->getInstalledExtensions(); } // Merge events from indivdual modules. foreach (Modules::list_modules() as $module) { // Skip if module is not installed if (!isset(self::$extensions[$module])) { continue; } $path = ROOTPATH . EXTPATH . "{$module}/config/"; if (is_file($path . 'events.php')) { $module_events = Modules::load_file('events', $path, 'config'); if (is_array($module_events)) { self::$events = array_merge_recursive(self::$events, $module_events); } } } if (self::$events === FALSE) { self::$events = array(); } }
public function load($langfile, $lang = '', $return = FALSE, $_module = NULL) { if (is_array($langfile)) { return $this->load_many($langfile); } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) { return $this->language; } $_module or $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); // Falls back to a default language if the current language file is missing. if ($path === FALSE && FALLBACK_LANGUAGE) { list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . FALLBACK_LANGUAGE . '/'); } if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang'; unset($lang); } } return $this->language; }
public function load($langfile, $lang = '', $return = FALSE, $_module = NULL) { if (is_array($langfile)) { return $this->load_many($langfile); } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang', $this->is_loaded, TRUE)) { return $this->language; } $_module || ($_module = CI::$APP->router->fetch_module()); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang'; unset($lang); } } return $this->language; }
public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { if (is_array($langfile)) { foreach ($langfile as $_lang) { $this->load($_lang); } return $this->language; } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this->language; } $_module or $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang' . EXT; unset($lang); } } return $this->language; }
function control($name, $vars = array(), $flag = '') { if (!class_exists('MY_Control')) { $control = load_class('Control', 'core'); } $module = CI::$APP->router->fetch_module(); // list($path, $_control) = Modules::find($name.'_control', $module, 'controls/'); $path = APPPATH . 'modules/' . $module . '/controls/' . $name . '_control'; if (file_exists($path . '.php')) { $_control = $name . '_control'; //$_control = ucfirst($name.'_control'); Modules::load_file($_control, APPPATH . 'modules/' . $module . '/controls/'); $control = new $_control($vars); $control->set_file($_control); return $control->render($vars); } else { if (empty($vars)) { include_once APPPATH . 'libraries/Template.php'; $template = new Template(); $content = $template->sreadfile($path . '.htm'); } else { $control->set_file($path); $content = $control->render($vars); } return $content; } }
public function load($file = 'config', $use_sections = FALSE, $fail_gracefully = FALSE, $_module = '') { if (in_array($file, $this->is_loaded, TRUE)) { return $this->item($file); } $_module or $_module = CI::$APP->router->fetch_module(); list($path, $file) = Modules::find($file, $_module, 'config/'); if ($path === FALSE) { parent::load($file, $use_sections, $fail_gracefully); return $this->item($file); } if ($config = Modules::load_file($file, $path, 'config')) { /* reference to the config array */ $current_config =& $this->config; if ($use_sections === TRUE) { if (isset($current_config[$file])) { $current_config[$file] = array_merge($current_config[$file], $config); } else { $current_config[$file] = $config; } } else { $current_config = array_merge($current_config, $config); } $this->is_loaded[] = $file; unset($config); return $this->item($file); } }
public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { // Are we loading an array of languages? If so, handle each one on its own. if (is_array($langfile)) { foreach ($langfile as $_lang) { $this->load($_lang); } return $this->language; } // -------------------------------------------------------------------------- // Determine which language we're using, if not specified, use the app's default $_default = CI::$APP->config->item('language'); $idiom = $lang == '' ? $_default : $lang; // -------------------------------------------------------------------------- // Check to see if the language file has already been loaded if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this->language; } // -------------------------------------------------------------------------- // Look for the language $_module or $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); /** * * Confession. I'm not entirely sure how/why this works. Dumping out debug statements confuses * me as they don't make sense, but the right lang files seem to be laoded. Sorry, future Pablo. * **/ if ($path === FALSE) { // File not found, fallback to the default language if not already using it if ($idiom != $_default) { // Using MXs version seems to work as expected. if ($lang = parent::load($langfile, $_default, $return, $add_suffix, $alt_path)) { return $lang; } } else { // Not found within modules, try normal load() if ($lang = CI_Lang::load($langfile, $idiom, $return, $add_suffix, $alt_path)) { return $lang; } } } else { // Lang file was found. Load it. if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang' . EXT; unset($lang); } } // -------------------------------------------------------------------------- return $this->language; }
public function load($langfile, $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { if (is_array($langfile)) { foreach($langfile as $_lang) $this->load($_lang); return $this->language; } $deft_lang = CI::$APP->config->item('language'); $idiom = ($lang == '') ? $deft_lang : $lang; if (in_array($langfile . '_lang'.EXT, $this->is_loaded, TRUE)) { return $this->language; } $_module OR $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); // Falls back to a default language if the current language file is missing. if ($path === FALSE && self::$fall_back) { list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/'); } if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang'.EXT; unset($lang); } } return $this->language; }
/** * Load a helper contained within a module. * * Copied from MX_Loader, modified to check the /bonfire/helpers directory for * a 'BF_' prefixed helper. * * @param string $helper The helper to load. * * @return void; **/ public function helper($helper = array()) { if (is_array($helper)) { return $this->helpers($helper); } if (isset($this->_ci_helpers[$helper])) { return; } list($path, $_helper) = Modules::find($helper . '_helper', $this->_module, 'helpers/'); if ($path === false) { if (file_exists(BFPATH . "helpers/BF_{$helper}_helper.php")) { include_once BFPATH . "helpers/BF_{$helper}_helper.php"; } return parent::helper($helper); } Modules::load_file($_helper, $path); $this->_ci_helpers[$_helper] = TRUE; }
public function loadConfig($module, $fail_gracefully = FALSE, $non_persistent = FALSE) { if (!is_string($module)) { return FALSE; } // and retrieve the configuration items if ($non_persistent === TRUE) { $path = ROOTPATH . EXTPATH . "{$module}/config/"; $config = is_file($path . "{$module}.php") ? Modules::load_file($module, $path, 'config') : NULL; } else { $this->CI->config->load($module . '/' . $module, TRUE); $config = $this->CI->config->item($module); } if ($error = $this->checkConfig($module, $config)) { return $fail_gracefully === FALSE ? $error : show_error($error); } return $config; }
function run($file, $param = null) { $args = func_get_args(); $module = ''; /* is module in filename? */ if (($pos = strrpos($file, '/')) !== FALSE) { $module = substr($file, 0, $pos); $file = substr($file, $pos + 1); } list($path, $file) = Modules::find($file, $module, 'widgets/'); if ($path === FALSE) { $path = APPPATH . 'widgets/'; } Modules::load_file($file, $path); $file = ucfirst($file); $widget = new $file($param); return $widget->run(); }
public function load($file = 'config', $use_sections = FALSE, $fail_gracefully = FALSE, $_module = '') { //if (in_array($file, $this->is_loaded, TRUE)) return $this->item($file); //echo "Модуль до определения = $_module<br>"; if ($_module === false) { $_module = ''; } else { $_module or $_module = CI::$APP->router->fetch_module(); } //echo "Модуль после определения = $_module<br>"; list($path, $file) = Modules::find($file, $_module, 'config/'); if ($path === FALSE) { parent::load($file, $use_sections, $fail_gracefully); return $this->item($file); } //echo "Путь - $path, файл-$file<br>"; // добавлено для корректной работы уже загруженных файлов модулей $file_path = $path . $file . EXT; //echo "Данные $file_path:<br>"; //print_r($this->item($file_path)); //if (in_array($file_path, $this->is_loaded, TRUE)) return $this->item($file); // конец добавления if ($config = Modules::load_file($file, $path, 'config')) { /* reference to the config array */ $current_config =& $this->config; if ($use_sections === TRUE) { if (isset($current_config[$file])) { //$current_config[$file] = array_merge($current_config[$file], $config); $current_config[$file] = $this->array_merge_recursive_distinct($current_config[$file], $config); } else { $current_config[$file] = $config; } } else { $current_config = array_merge($current_config, $config); } //$this->is_loaded[] = $file; // исправлено на: $this->is_loaded[] = $file_path; unset($config); return $this->item($file); } }
/** * Run ImageCMS modules autoload method for admin-page * @access private * @copyright ImageCMS (c) 2013, Kaero <*****@*****.**> */ private function autoloadModules() { /** Search module with autoload */ $query = $this->db->select('name')->where('autoload', 1)->get('components'); if ($query) { $moduleName = null; /** Run all Admin autoload method */ foreach ($query->result_array() as $module) { $moduleName = $module['name']; Modules::load_file($moduleName, APPPATH . 'modules' . DIRECTORY_SEPARATOR . $moduleName . DIRECTORY_SEPARATOR); $moduleName = ucfirst($moduleName); if (class_exists($moduleName)) { if (method_exists($moduleName, 'adminAutoload')) { $moduleName::adminAutoload(); // self::$detect_load_admin[$moduleName] = 1; } } } } }
/** Load a module model **/ public function model($model, $object_name = NULL, $connect = FALSE) { if (is_array($model)) { return $this->models($model); } $_alias = $object_name or $_alias = basename($model); if (in_array($_alias, $this->_ci_models, TRUE)) { return CI::$APP->{$_alias}; } /* check module */ list($path, $_model) = Modules::find(strtolower($model), $this->_module, 'models/'); //AG_ *************************** if ($path == FALSE) { $model_e = explode('/', $model, 2); if (count($model_e) > 1) { list($path, $_model) = Modules::find(strtolower($model_e[1]), $model_e[0], 'models/'); } } //AG_ ---------------------------- if ($path == FALSE) { /* check application & packages */ parent::model($model, $object_name); } else { class_exists('CI_Model', FALSE) or load_class('Model', 'core'); if ($connect !== FALSE and !class_exists('CI_DB', FALSE)) { if ($connect === TRUE) { $connect = ''; } $this->database($connect, FALSE, TRUE); } Modules::load_file($_model, $path); $model = ucfirst($_model); if (class_exists(users_class_prefix . $model)) { $model = users_class_prefix . $model; } CI::$APP->{$_alias} = new $model(); $this->_ci_models[] = $_alias; } return CI::$APP->{$_alias}; }
public function load($langfile = '', $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { if (is_array($langfile)) { foreach ($langfile as $_lang) { $this->load($_lang); } return $this->language; } if (!class_exists('CI')) { exit('An error has occured that cannot be reported correctly. Check your database settings.'); } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this->language; } $_module or $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); // Falls back to a default language if the current language file is missing. if ($path === FALSE && self::$fall_back) { list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . self::$fall_back . '/'); } if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang' . EXT; unset($lang); } } return $this->language; }
function load($_module = '') { //echo "вызван метод load, класса DB_alias<br>"; $_module or $_module = $this->current_module(); list($path, $file) = Modules::find('index_request', $_module, 'config/'); if ($path === FALSE) { //echo "не обнаружен файл псевдонимов: модуль - ".$_module.", путь: $path, файл: $file<br />"; } else { //echo "!! Обнаружен файл псевдонимов: модуль - ".$_module.", путь: $path, файл: $file<br />"; if (!isset($this->cache[$_module])) { //$this->ci->config->load('index_request', TRUE); if ($index_request = Modules::load_file($file, $path, 'config')) { //$index_request = $this->ci->config->item('index_request', 'index_request'); $this->cache[$_module] = $index_request['index_request']; } else { exit('Не найден файл "index_request" в модуле "' . $_module . '"'); } } if (isset($this->cache[$_module]) && is_array($this->cache[$_module])) { $this->set_index($this->cache[$_module]); } } }
public function load($langfile = array(), $lang = '', $return = FALSE, $add_suffix = TRUE, $alt_path = '', $_module = '') { if (!class_exists('CI')) { // This happens before the whole core has been loaded. $alt_path = COMMONPATH; return parent::load($langfile, $lang, $return, $add_suffix, $alt_path); } if (is_array($langfile)) { foreach ($langfile as $_lang) { $this->load($_lang); } return $this->language; } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang.php', $this->is_loaded, TRUE)) { return $this->language; } $_module or $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/' . $idiom . '/'); if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return, $add_suffix, $alt_path)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang.php'; unset($lang); } } return $this->language; }
function widget($widget = '', $params = NULL, $object_name = NULL) { $class = strtolower(end(explode('/', $widget))); if (isset($this->_ci_classes[$class]) and $_alias = $this->_ci_classes[$class]) { return CI::$APP->{$_alias}; } $_alias = $object_name or $_alias = $class; if ($widget == '') { return FALSE; } if (!is_null($params) and !is_array($params)) { $params = NULL; } list($path, $_widget) = Modules::find($widget, $this->_module, 'widgets/'); if ($path === FALSE) { $path = APPPATH . 'widgets/' . $widget . '/'; Modules::load_file($widget, $path); } else { Modules::load_file($_widget, $path); $widget = ucfirst($_widget); } CI::$APP->{$_alias} = new $widget($params); $this->_ci_classes[$class] = $_alias; }
/** * Utils Autoloader * * The config/autoload.php file contains an array that permits sub-systems, * utils to be loaded automatically. * * @param array * @return void */ private function _ci_utils_autoloader() { if (defined('ENVIRONMENT') and file_exists(APPPATH . 'config/' . ENVIRONMENT . '/autoload.php')) { include APPPATH . 'config/' . ENVIRONMENT . '/autoload.php'; } else { include APPPATH . 'config/autoload.php'; } if (!isset($autoload)) { return FALSE; } // try to load from module and merge into $path = FALSE; if ($this->_module) { list($path, $file) = Modules::find('autoload', $this->_module, 'config/'); /* module constants file */ if ($path != FALSE) { include_once $path . $file . EXT; } /* module autoload file */ if ($path != FALSE) { $autoload = array_merge(Modules::load_file($file, $path, 'autoload'), $autoload); } } // auto load utils if (isset($autoload['utils']) and count($autoload['utils']) > 0) { $this->utils($autoload['utils']); } }
/** * Migrate to the latest version or drop all migrations * for a given module migration * * @param $module * @param bool $downgrade * * @return bool */ public function runMigration($module, $downgrade = FALSE) { $path = Modules::path($module, 'config/'); if (!is_file($path . 'migration.php')) { return FALSE; } $migration = Modules::load_file('migration', $path, 'config'); $migration['migration_enabled'] = TRUE; $this->CI->load->library('migration', $migration); if ($downgrade === TRUE) { $this->CI->migration->version('0', $module); } else { $this->CI->migration->current($module); } }
/** Load a module model **/ public function model($model, $object_name = NULL, $connect = FALSE, $module = NULL) { if (!isset($module)) { $module = $this->_module; } // FUEL if (is_array($model)) { return $this->models($model); } $_alias = $object_name or $_alias = end(explode('/', $model)); if (in_array($_alias, $this->_ci_models, TRUE)) { return CI::$APP->{$_alias}; } list($path, $model) = Modules::find(strtolower($model), $module, 'models/'); CI_VERSION < 2 ? load_class('Model', FALSE) : load_class('Model', 'core'); if ($connect !== FALSE) { if ($connect === TRUE) { $connect = ''; } $this->database($connect, FALSE, TRUE); } Modules::load_file($model, $path); $model = ucfirst($model); CI::$APP->{$_alias} = new $model(); if (CI_VERSION < 2) { $this->_ci_assign_to_models(); } $this->_ci_models[] = $_alias; return CI::$APP->{$_alias}; }
/** * Load a library contained within a module. * * Copied from MX_Loader, modified to check the bonfire/libraries directory * for a 'BF_' prefixed library. * * @param string $library The library to load. * @param mixed $params Parameters to pass to the library. * @param string $object_name An alias for the library. * * @return $this */ public function library($library, $params = null, $object_name = null) { if (is_array($library)) { return $this->libraries($library); } $class = strtolower(basename($library)); if (isset($this->_ci_classes[$class]) && ($_alias = $this->_ci_classes[$class])) { return $this; } $_alias = strtolower($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 && ($params = Modules::load_file($file, $path2, 'config')); } if ($path === false) { // Use $this->_ci_load_library() in CI 3 if (substr(CI_VERSION, 0, 1) != '2') { $this->_ci_load_library($library, $params, $object_name); } else { $this->_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; } return $this; }
public function init_module($module = 'ci_core') { if ($module === 'ci_core') { $config = $this->_core_config; if (!isset($config['migration_path']) or !$config['migration_path']) { $config['migration_path'] = APPPATH . 'migrations/'; } // _print_r( $config ); } else { list($path, $file) = Modules::find('migration', $module, 'config/'); if ($path === FALSE) { return FALSE; } if (!($config = Modules::load_file($file, $path, 'config'))) { return FALSE; } if (!isset($config['migration_path']) or !$config['migration_path']) { $config['migration_path'] = '../migrations'; } $config['migration_path'] = $path . $config['migration_path']; } foreach ($config as $key => $val) { $this->{'_' . $key} = $val; } if ($this->_migration_enabled !== TRUE) { return FALSE; } $this->_migration_path = rtrim($this->_migration_path, '/') . '/'; if (!file_exists($this->_migration_path)) { return FALSE; } $this->_current_module = $module; return TRUE; }
public function load($langfile, $lang = '', $return = FALSE, $_module = NULL) { if (is_array($langfile)) { return $this->load_multi($langfile); } $deft_lang = MY_Loader::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this->language; } $_module || ($_module = MY_Loader::$APP->router->fetch_module()); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', $idiom); // Falls back to a default language if the current language file is missing. if ($path === FALSE && self::$fall_back) { list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', self::$fall_back); } if ($path === FALSE) { if ($lang = parent::load($langfile, $lang, $return)) { return $lang; } } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { if ($return) { return $lang; } $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang' . EXT; unset($lang); } } return $this->language; }
private function __load($langfile, $idiom, $add_suffix, $alt_path, $module) { $lang = array(); list($path, $file) = Modules::find($langfile . '_lang', $module, 'language/' . $idiom . '/'); if ($path) { // Module file $lang = Modules::load_file($file, $path, 'lang'); // Save full path for debug message below $file = $path . $file; } if (empty($lang)) { // This code copied from CI Lang. Obviously this means // passing $add_suffix=FALSE doesn't work for module files // (above); the resulting behaviour matches MX_Lang. $langfile = str_replace('.php', '', $langfile); if ($add_suffix == TRUE) { // Extra period matches code from CI Lang // so in reality this won't work if you pass the '_lang' in. $langfile = str_replace('_lang.', '', $langfile) . '_lang'; } $langfile .= '.php'; if (in_array($langfile, $this->is_loaded, TRUE)) { // Inefficient, but this should only happen in the add_suffix=FALSE bugpath. // Note CI would incorrectly return void to the caller, but we need to // let load() know we suceeded otherwise it'll abort the script. return $this->language; } // Determine where the language file is and load it if ($alt_path != '' && file_exists($alt_path . 'language/' . $idiom . '/' . $langfile)) { $file = $alt_path . 'language/' . $idiom . '/' . $langfile; include $file; } else { foreach (get_instance()->load->get_package_paths(TRUE) as $package_path) { $file = $package_path . 'language/' . $idiom . '/' . $langfile; if (file_exists($file)) { include $file; if (!isset($lang)) { log_message('error', "Language file contains no data? {$file}"); } break; } } } } if (!empty($lang)) { log_message('debug', 'Bonfire MY_Lang: Language file loaded: ' . $file); } return $lang; }
/** * Load Helper * * This function loads the specified helper file. * Overloading this method so that extended helpers in NAILS are correctly loaded. * Slightly more complex as the helper() method for ModuleExtensions also needs to * be fired (i.e it's functionality needs to exist in here too). * * @param mixed * @return void */ public function helper($helpers = array()) { // Need to make the $helpers variable into an array immediately and loop through // it so MX knows what to do. Also specify a to_load variable which will contain // helpers which the fallback, CI, method will attempt to load. $_helpers = $this->_ci_prep_filename($helpers, '_helper'); $_to_load = array(); // Modded MX Loader: foreach ($_helpers as $helper) { if (isset($this->_ci_helpers[$helper])) { return; } list($path, $_helper) = Modules::find($helper . '_helper', $this->_module, 'helpers/'); if ($path === FALSE) { $_to_load[] = $helper; } else { Modules::load_file($_helper, $path); $this->_ci_helpers[$_helper] = TRUE; } } // -------------------------------------------------------------------------- foreach ($_to_load as $helper) { if (isset($this->_ci_helpers[$helper])) { continue; } $ext_helper = APPPATH . 'helpers/' . config_item('subclass_prefix') . $helper . EXT; $_nails_ext_helper = NAILS_PATH . 'helpers/' . config_item('subclass_prefix') . $helper . EXT; $_nails_ext_module_helper = $this->router->current_module() ? NAILS_PATH . 'modules/' . $this->router->current_module() . '/helpers/' . config_item('subclass_prefix') . $helper . EXT : NULL; $_nails_module_helper = $this->router->current_module() ? NAILS_PATH . 'modules/' . $this->router->current_module() . '/helpers/' . $helper . EXT : NULL; // Is this a helper extension request? if (file_exists($ext_helper)) { $base_helper = BASEPATH . 'helpers/' . $helper . EXT; if (!file_exists($base_helper)) { show_error('Unable to load the requested file: helpers/' . $helper . EXT); } include_once $ext_helper; // If a Nails version exists, load that too; allows the app to overload the nails version // but also allows the app to extend the nails version without destorying existing functions if (file_exists($_nails_ext_helper)) { include_once $_nails_ext_helper; // If there isn't an explicit Nails version, check the current module for one } elseif ($_nails_ext_module_helper && file_exists($_nails_ext_module_helper)) { include_once $_nails_ext_module_helper; } include_once $base_helper; $this->_ci_helpers[$helper] = TRUE; log_message('debug', 'Helper loaded: ' . $helper); continue; } // App version didn't exist, see if a Nails version does if (file_exists($_nails_ext_helper)) { $base_helper = BASEPATH . 'helpers/' . $helper . EXT; if (!file_exists($base_helper)) { show_error('Unable to load the requested file: helpers/' . $helper . EXT); } include_once $_nails_ext_helper; include_once $base_helper; $this->_ci_helpers[$helper] = TRUE; log_message('debug', 'Helper loaded: ' . $helper); continue; } // See if the helper resides within the current Nails module if (file_exists($_nails_module_helper)) { include_once $_nails_module_helper; $this->_ci_helpers[$helper] = TRUE; log_message('debug', 'Helper loaded: ' . $helper); continue; } // Try to load the helper foreach ($this->_ci_helper_paths as $path) { if (file_exists($path . 'helpers/' . $helper . EXT)) { include_once $path . 'helpers/' . $helper . EXT; $this->_ci_helpers[$helper] = TRUE; log_message('debug', 'Helper loaded: ' . $helper); break; } } // unable to load the helper if (!isset($this->_ci_helpers[$helper])) { show_error('Unable to load the requested file: helpers/' . $helper . EXT); } } }
/** * Theme Language line * * Fetch a single line of text from the language array * * Usage: * * {{ theme:lang lang="theme" line="theme_title" [default="PyroCMS"] }} * * @return string. */ public function lang() { $lang_file = $this->attribute('lang'); $line = $this->attribute('line'); $default = $this->attribute('default'); // Return an empty string as the attribute LINE is missing if (!isset($line)) { return ""; } $deft_lang = CI::$APP->config->item('language'); if ($lang = Modules::load_file($lang_file . '_lang', CI::$APP->template->get_theme_path() . '/language/' . $deft_lang . '/', 'lang')) { CI::$APP->lang->language = array_merge(CI::$APP->lang->language, $lang); CI::$APP->lang->is_loaded[] = $lang_file . '_lang' . EXT; unset($lang); } $value = $this->lang->line($line); return $value ? $value : $default; }
public function load($langfile, $lang = '') { if (is_array($langfile)) { return $this->load_multi($langfile); } $deft_lang = CI::$APP->config->item('language'); $idiom = $lang == '' ? $deft_lang : $lang; if (in_array($langfile . '_lang' . EXT, $this->is_loaded, TRUE)) { return $this; } $_module = CI::$APP->router->fetch_module(); list($path, $_langfile) = Modules::find($langfile . '_lang', $_module, 'language/', $idiom); if ($path === FALSE) { parent::load($langfile, $lang); } else { if ($lang = Modules::load_file($_langfile, $path, 'lang')) { $this->language = array_merge($this->language, $lang); $this->is_loaded[] = $langfile . '_lang' . EXT; unset($lang); } } return $this; }
/** Autoload module items **/ public function _autoloader($autoload) { $path = FALSE; if ($this->_module) { list($path, $file) = Modules::find('constants', $this->_module, 'config/'); /* module constants file */ if ($path != FALSE) { include_once $path . $file . EXT; } list($path, $file) = Modules::find('autoload', $this->_module, 'config/'); /* module autoload file */ if ($path != FALSE) { $autoload = array_merge(Modules::load_file($file, $path, 'autoload'), $autoload); } } /* nothing to do */ if (count($autoload) == 0) { return; } /* autoload package paths */ if (isset($autoload['packages'])) { foreach ($autoload['packages'] as $package_path) { $this->add_package_path($package_path); } } /* autoload config */ if (isset($autoload['config'])) { foreach ($autoload['config'] as $config) { $this->config($config); } } /* autoload helpers, plugins, languages */ foreach (array('helper', 'plugin', 'language') as $type) { if (isset($autoload[$type])) { foreach ($autoload[$type] as $item) { $this->{$type}($item); } } } /* autoload database & libraries */ if (isset($autoload['libraries'])) { if (in_array('database', $autoload['libraries'])) { /* autoload database */ if (!($db = CI::$APP->config->item('database'))) { $db['params'] = 'default'; $db['active_record'] = TRUE; } $this->database($db['params'], FALSE, $db['active_record']); $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); } /* autoload libraries */ foreach ($autoload['libraries'] as $library) { $this->library($library); } } /* autoload models */ if (isset($autoload['model'])) { foreach ($autoload['model'] as $model => $alias) { is_numeric($model) ? $this->model($alias) : $this->model($model, $alias); } } /* autoload module controllers */ if (isset($autoload['modules'])) { foreach ($autoload['modules'] as $controller) { $controller != $this->_module and $this->module($controller); } } }
/** Autload items **/ public function _ci_autoloader($autoload = array(), $path = FALSE) { if ($this->_module) { list($path, $file) = Modules::find('autoload', $this->_module, 'config/'); } /* module autoload file */ if ($path != FALSE) { $autoload = array_merge(Modules::load_file($file, $path, 'autoload'), $autoload); } /* nothing to do */ if (count($autoload) == 0) { return; } /* autoload config */ if (isset($autoload['config'])) { foreach ($autoload['config'] as $key => $val) { self::config($val); } } /* autoload helpers, plugins, languages */ foreach (array('helper', 'plugin', 'language') as $type) { if (isset($autoload[$type])) { foreach ($autoload[$type] as $item) { self::$type($item); } } } /* autoload database & libraries */ if (isset($autoload['libraries'])) { if (in_array('database', $autoload['libraries'])) { /* autoload database */ if (!($db = $this->config->item('database'))) { $db['params'] = 'default'; $db['active_record'] = TRUE; } self::database($db['params'], FALSE, $db['active_record']); $autoload['libraries'] = array_diff($autoload['libraries'], array('database')); } /* autoload libraries */ foreach ($autoload['libraries'] as $library) { self::library($library); } } /* autoload models */ if (isset($autoload['model'])) { foreach ($autoload['model'] as $model => $alias) { is_numeric($model) ? self::model($alias) : self::model($model, $alias); } } /* autoload module controllers */ if (isset($autoload['modules'])) { foreach ($autoload['modules'] as $controller) { $controller != $this->_module and Loader::module($controller); } } }