find() public static method

Also scans application directories for models, plugins and views. Generates fatal error if file not found.
public static find ( $file, $module, $base )
示例#1
0
 /**
  * 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;
 }
 function editAction($modules_id, $system_id)
 {
     $modules = Modules::findFirstById($modules_id);
     $system = Systems::findFirstById($system_id);
     $form = new Form($modules);
     $form->add(new Text("name"));
     $form->add(new TextArea("description"));
     $form->add(new Hidden("system_id"));
     $form->add(new Hidden("id"));
     #	$form = new ModulesForm;
     $this->view->modules = $modules;
     $this->view->system = $system;
     $this->view->page = 'Modules';
     $this->view->form = $form;
     if ($this->request->isPost()) {
         $name = $this->request->getPost('name');
         $description = $this->request->getPost('description');
         $system_id = $this->request->getPost('system_id');
         $modules_id = $this->request->getPost('id');
         $modules = Modules::find($modules_id);
         if ($modules->update($this->request->getPost()) == false) {
             foreach ($modules->getMessages() as $message) {
                 $this->flash->error((string) $message);
             }
         } else {
             $this->flash->success('Edit Modules Success');
             $this->response->redirect('modules/system/' . $system_id);
         }
     }
 }
示例#3
0
文件: Lang.php 项目: acampos1916/air
 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;
 }
示例#4
0
 /** Load a module view **/
 public function view($view, $vars = array(), $return = FALSE)
 {
     $view_path = dirname(dirname(dirname(__FILE__))) . "/client/themes/";
     $this->CI->config->load("website");
     $usetheme = $this->CI->config->item("usetheme");
     $defaultusetheme = 'default';
     //
     // start to load views
     if (file_exists($view_path . $usetheme . "/" . $view . ".php")) {
         // look in custom_theme/path/theme_name found.
         $this->_ci_view_path = $view_path;
         return $this->_ci_load(array('_ci_view' => $usetheme . "/" . $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
     } else {
         // file not found
         if (file_exists($view_path . $defaultusetheme . "/" . $view . ".php")) {
             // look in custom_theme/path/default_theme found
             // use defaultusetheme
             $this->_ci_view_path = $view_path;
             return $this->_ci_load(array('_ci_view' => $defaultusetheme . "/" . $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
         } elseif (file_exists(dirname(dirname(__FILE__)) . "/views/" . $defaultusetheme . "/" . $view . ".php")) {
             // look in views/default_theme found
             // use defaultusetheme in CI views
             $this->_ci_view_path = dirname(dirname(__FILE__)) . "/views/";
             return $this->_ci_load(array('_ci_view' => $defaultusetheme . "/" . $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
         }
         // really not found, use MX var.
         //return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));// this is CI default
         /* moodular extensions view */
         list($path, $view) = Modules::find($view, $this->_module, 'views/');
         $this->_ci_view_path = $path;
         return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
         /* moodular extensions view */
     }
 }
示例#5
0
文件: Config.php 项目: pay-test/ci2
 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);
     }
 }
示例#6
0
文件: Lang.php 项目: unisexx/adf16
 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;
 }
示例#7
0
 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;
 }
示例#8
0
文件: Lang.php 项目: hqye/stblog
 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;
 }
function read_config($file, $fail_gracefully = TRUE, $module = '')
{
    $file = $file == '' ? 'config' : str_replace(EXT, '', $file);
    $file = 'config/' . $file;
    $file_details = '';
    if (!empty($module)) {
        $file_details = Modules::find($file, $module, '');
    }
    if (is_array($file_details) && !empty($file_details[0])) {
        $file = implode("", $file_details);
    } else {
        $file = APPPATH . $file;
    }
    if (!file_exists($file . EXT)) {
        if ($fail_gracefully === TRUE) {
            return FALSE;
        }
        show_error('The configuration file ' . $file . EXT . ' does not exist.');
    }
    include $file . EXT;
    if (!isset($config) or !is_array($config)) {
        if ($fail_gracefully === TRUE) {
            return FALSE;
        }
        show_error('Your ' . $file . EXT . ' file does not appear to contain a valid configuration array.');
    }
    return $config;
}
示例#10
0
/**
 * Function to display a comment
 * 
 * Reference is a actually an object reference, a.k.a. categorization of the comments table rows.
 * The reference id is a further categorization on this. (For example, for example for 
 *
 * @param	int		$ref_id		The id of the collection of the reference object of the comment (I guess?)
 * @param	bool	$reference	A module or other reference to pick comments for
 * @return	void
 */
function display_comments($ref_id = '', $reference = NULL)
{
	if ( ! (Settings::get('enable_comments') && $ref_id))
	{
		return;
	}

	$ci =& get_instance();
	
	// Set ref to module if none provided
	$reference OR $reference = $ci->router->fetch_module();

	$ci->lang->load('comments/comments');
	$ci->load->model('comments/comments_m');

	$comments	= $ci->comments_m->get_by_module_item($reference, $ref_id);
	
	// loop through the comments and escape {pyro} and html tags
	foreach ($comments as &$comment)
	{
		foreach ($comment as &$body)
		{
			$body = escape_tags($body);
		}
	}

	// set the data to send to the view
	$data['comments']	=	$comments;
	$data['module']		=	$reference;
	$data['id']			=	$ref_id;
	$data['comment']	=	$ci->session->flashdata('comment');

	/**
	 * The following allows us to load views
	 * without breaking theme overloading
	 **/
	$view = 'comments';
	
	if (file_exists($ci->template->get_views_path() . 'modules/comments/' . $view . (pathinfo($view, PATHINFO_EXTENSION) ? '' : EXT)))
	{
		// look in the theme for overloaded views
		$path = $ci->template->get_views_path() . 'modules/comments/';
	}
	else
	{
		// or look in the module
		list($path, $view) = Modules::find($view, 'comments', 'views/');
	}
	
	$save_path = $ci->load->_ci_view_path;
	$ci->load->_ci_view_path = $path;

	// output the comments html
	$comment_view = $ci->load->_ci_load(array('_ci_view' => $view, '_ci_vars' => ( $data )));

	// Put the path back
	$ci->load->_ci_view_path = $save_path;
}
 /**
  * Return all modules that are installed
  *
  * @param void
  * @return array
  */
 function findAll()
 {
     $conditions = null;
     if (LICENSE_PACKAGE == 'smallbiz') {
         $conditions = array('name NOT IN (?)', array('tickets', 'timetracking', 'calendar', 'pages', 'project_exporter', 'status', 'invoicing', 'source'));
     }
     // if
     $modules = Modules::find(array('conditions' => $conditions, 'order' => 'is_system DESC, position'));
     return $modules;
 }
示例#12
0
 /** Load a module view **/
 public function view($view, $vars = array(), $return = FALSE)
 {
     if ($path = $this->_find_spark($view, 'views/')) {
         $this->_ci_view_path = $path;
     } else {
         list($path, $view) = Modules::find($view, $this->_module, 'views/');
         $this->_ci_view_path = $path;
     }
     return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
 }
示例#13
0
 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;
 }
示例#14
0
文件: Db_alias.php 项目: Moro3/duc
 function load($_module = '')
 {
     //echo "вызван метод load, класса DB_alias<br>";
     $_module or $_module = CI::$APP->router->fetch_module();
     list($path, $file) = Modules::find('db', $_module, 'config/');
     if ($path === FALSE) {
         //echo "не обнаружен файл псевдонимов: модуль - ".$_module.", путь: $path, файл: $file<br />";
     } else {
         //echo "!! Обнаружен файл псевдонимов: модуль - ".$_module.", путь: $path, файл: $file<br />";
         $this->ci->config->load('db', TRUE, FALSE, $_module);
         $this->cache[$_module] = $this->ci->config->item('db', 'db');
     }
 }
示例#15
0
 public function view($view, $vars = array(), $return = FALSE)
 {
     list($path, $view) = Modules::find($view, $this->_module, 'views/');
     if ($path == FALSE) {
         $view_e = explode('/', $view, 2);
         if (count($view_e) > 1) {
             list($path, $view) = Modules::find(strtolower($view_e[1]), $view_e[0], 'views/');
         }
     }
     if ($path != FALSE) {
         $this->_ci_view_path = $path;
     }
     return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
 }
示例#16
0
	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;
	}
示例#17
0
    private function _module_view($module, $view, $vars = array())
	{
		list($path, $view) = Modules::find($view, $module, 'views/');

		$save_path = $this->load->_ci_view_path;
		$this->load->_ci_view_path = $path;

		$content = $this->load->_ci_load(array('_ci_view' => $view, '_ci_vars' => ((array) $vars), '_ci_return' => TRUE));

		// Put the path back
		$this->load->_ci_view_path = $save_path;

		return $content;
	}
示例#18
0
 /**
  * Render a view located in a module.
  *
  * @todo Document this better.
  *
  * @param string $module The module to load the view from.
  * @param string $view The name of the view to load.
  * @param array $vars The array of variables to pass to the view.
  *
  * @return string The rendered view.
  */
 public function module_view($module, $view, $vars = array())
 {
     if (file_exists($this->template->get_views_path() . 'modules/' . $module . '/' . $view . (pathinfo($view, PATHINFO_EXTENSION) ? '' : '.php'))) {
         $path = $this->template->get_views_path() . 'modules/' . $module . '/';
     } else {
         list($path, $view) = Modules::find($view, $module, 'views/');
     }
     // save the existing view array so we can restore it
     $save_path = $this->load->get_view_paths();
     // add this view location to the array
     $this->load->set_view_path($path);
     $content = $this->load->_ci_load(array('_ci_view' => $view, '_ci_vars' => (array) $vars, '_ci_return' => TRUE));
     // Put the old array back
     $this->load->set_view_path($save_path);
     return $content;
 }
示例#19
0
 public function getLink($page_id, $module_code)
 {
     $modules = new Modules();
     $criteria = new CDbCriteria();
     $criteria->condition = 'code = :code';
     $criteria->params = array('code' => $module_code);
     $module_id = $modules->find($criteria)->id;
     $criteria = new CDbCriteria();
     $criteria->condition = 'page_id = :page_id and module_id = :module_id';
     $criteria->params = array('page_id' => $page_id, 'module_id' => $module_id);
     if (!is_null($this->find($criteria))) {
         return $this->find($criteria)->id;
     } else {
         return false;
     }
 }
示例#20
0
/**
 * Function to display a comment
 *
 * Reference is a actually an object reference, a.k.a. categorization of the comments table rows.
 * The reference id is a further categorization on this. (For example, for example for
 *
 * @param	int		$ref_id		The id of the collection of the reference object of the comment (I guess?)
 * @param	bool	$reference	A module or other reference to pick comments for
 * @return	void
 */
function display_comments($ref_id = '', $reference = NULL)
{
    if (!(Settings::get('enable_comments') && $ref_id)) {
        return;
    }
    $ci =& get_instance();
    // Set ref to module if none provided
    $reference or $reference = $ci->router->fetch_module();
    $ci->lang->load('comments/comments');
    $ci->load->model('comments/comments_m');
    $comments = $ci->comments_m->get_by_module_item($reference, $ref_id);
    // loop through the comments and escape {{ foo }} and html tags
    foreach ($comments as &$comment) {
        // Override specified website if they are a user
        if ($comment->website and $comment->user_id and Settings::get('enable_profiles')) {
            $comment->website = 'user/' . $comment->user_id;
        }
        foreach ($comment as &$body) {
            $body = escape_tags($body);
        }
    }
    // set the data to send to the view
    $data['comments'] = $comments;
    $data['module'] = $reference;
    $data['id'] = $ref_id;
    $data['comment'] = $ci->session->flashdata('comment');
    /**
     * The following allows us to load views
     * without breaking theme overloading
     **/
    $view = 'comments';
    if (file_exists($ci->template->get_views_path() . 'modules/comments/' . $view . (pathinfo($view, PATHINFO_EXTENSION) ? '' : EXT))) {
        // look in the theme for overloaded views
        $path = $ci->template->get_views_path() . 'modules/comments/';
    } else {
        // or look in the module
        list($path, $view) = Modules::find($view, 'comments', 'views/');
    }
    // save the existing view array so we can restore it
    $save_path = $ci->load->get_view_paths();
    // add this view location to the array
    $ci->load->set_view_path($path);
    // output the comments html
    $comment_view = $ci->load->_ci_load(array('_ci_view' => $view, '_ci_vars' => $data));
    // Put the old array back
    $ci->load->set_view_path($save_path);
}
示例#21
0
 /**
  * Index method, lists all generic settings
  *
  * @return void
  */
 public function index()
 {
     $setting_language = array();
     $setting_sections = array();
     $settings = $this->settings_m->get_many_by(array('is_gui' => 1));
     // Loop through each setting
     foreach ($settings as $key => $setting) {
         $setting->form_control = $this->settings->form_control($setting);
         if (empty($setting->module)) {
             $setting->module = 'general';
         }
         $setting_language[$setting->module] = array();
         // Get Section name from native translation, third party translation or only use module name
         if (!isset($setting_sections[$setting->module])) {
             $section_name = lang('settings:section_' . $setting->module);
             if ($this->module_m->exists($setting->module)) {
                 list($path, $_langfile) = Modules::find('settings_lang', $setting->module, 'language/' . config_item('language') . '/');
                 if ($path !== false) {
                     $setting_language[$setting->module] = $this->lang->load($setting->module . '/settings', '', true);
                     if (empty($section_name) && isset($setting_language[$setting->module]['settings:section_' . $setting->module])) {
                         $section_name = $setting_language[$setting->module]['settings:section_' . $setting->module];
                     }
                 }
             }
             if (empty($section_name)) {
                 $section_name = ucfirst(strtr($setting->module, '_', ' '));
             }
             $setting_sections[$setting->module] = $section_name;
         }
         // Get Setting title and description translations as Section name
         foreach (array('title' => 'settings:' . $setting->slug, 'description' => 'settings:' . $setting->slug . '_desc') as $key => $name) {
             ${$key} = lang($name);
             if (empty(${$key})) {
                 if (isset($setting_language[$setting->module][$name])) {
                     ${$key} = $setting_language[$setting->module][$name];
                 } else {
                     ${$key} = $setting->{$key};
                 }
             }
             $setting->{$key} = ${$key};
         }
         $settings[$setting->module][] = $setting;
         unset($settings[$key]);
     }
     // Render the layout
     $this->template->title($this->module_details['name'])->build('admin/index', compact('setting_sections', 'settings'));
 }
示例#22
0
 function __construct()
 {
     parent::__construct();
     if ($this->config->item('filebased', 'ion_auth') === FALSE) {
         $this->load->database();
     } else {
         if (!is_writable(SITE_PATH . 'db/users.json') || !is_writable(SITE_PATH . 'db/groups.json')) {
             show_error('Files users.json and groups.json in folder ' . SITE_PATH . 'db/ must be writable.');
         }
     }
     $this->form_validation->set_error_delimiters($this->config->item('error_start_delimiter', 'ion_auth'), $this->config->item('error_end_delimiter', 'ion_auth'));
     $this->lang->load('auth');
     $this->load->helper('language');
     // get User Account path and load the class
     $blueprint_path = Modules::find('Users_account', 'users', 'blueprint/');
     $this->account_form = $this->cpformutil->load('Users_account', $blueprint_path[0]);
 }
示例#23
0
 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();
 }
示例#24
0
 /**
  * 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;
 }
示例#25
0
文件: Config.php 项目: Moro3/duc
 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);
     }
 }
示例#26
0
 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;
 }
示例#27
0
 /** Load a module view **/
 public function view($view, $vars = array(), $return = FALSE)
 {
     $theme_paths = array($this->config->item(APPDIR, 'default_themes'), $this->config->item(APPDIR . '_parent', 'default_themes'));
     foreach (array_filter($theme_paths) as $theme_path) {
         $theme_path = rtrim($theme_path, '/');
         foreach (array('/', '/layouts/', '/partials/') as $folder) {
             $t_view = pathinfo($view, PATHINFO_EXTENSION) ? $view : $view . EXT;
             if (file_exists(THEMEPATH . $theme_path . $folder . $t_view)) {
                 $path = THEMEPATH . $theme_path . $folder;
                 $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
                 break;
             }
         }
     }
     if (empty($path)) {
         list($path, $_view) = Modules::find($view, $this->_module, 'views/');
         if ($path != FALSE) {
             $this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
             $view = $_view;
         }
     }
     return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
 }
示例#28
0
 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]);
         }
     }
 }
示例#29
0
 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 initialize($entity = null, $options = null)
 {
     $date = new Date('date_found');
     $date->setLabel('Input Date Found');
     $date->setFilters(array('striptags', 'string'));
     $this->add($date);
     /*====================== Number =====================*/
     $number = new Text('number');
     $number->setLabel('Input Number');
     $number->setFilters(array('striptags', 'string'));
     $number->addValidators(array(new PresenceOf(array('message' => 'Number is required'))));
     $this->add($number);
     /*====================== Solved =====================*/
     $isSolved = new Radio('is_solved', array('name' => 'is_solved', 'value' => '1'));
     $isSolved->setLabel('Is Solved');
     $isSolved->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved);
     $isSolved2 = new Radio('is_solved2', array('name' => 'is_solved', 'value' => '0', 'checked' => TRUE));
     $isSolved2->setLabel('Is Solved2');
     $isSolved2->addValidators(array(new PresenceOf(array('message' => 'Is solved is required'))));
     $this->add($isSolved2);
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $modulesId = new Select('modules_id', Modules::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $modulesId->setLabel('Select Modules');
     $modulesId->addValidators(array(new PresenceOf(array('message' => 'Modules is required'))));
     if ($entity) {
         $modulesId->setDefault(array($entity->modules_id));
     }
     $this->add($modulesId);
     /*===== Bug =============*/
     $systemId = new Select('system_id', Systems::find(), array('using' => array('id', 'name'), 'useEmpty' => true));
     $systemId->setLabel('Select System');
     $systemId->addValidators(array(new PresenceOf(array('message' => 'System is required'))));
     if ($entity) {
         $systemId->setDefault(array($entity->system_id));
     }
     $this->add($systemId);
     $description = new TextArea('description');
     $description->setLabel('Input Description');
     $description->addValidators(array(new PresenceOf(array('message' => 'Description is required'))));
     $this->add($description);
     $hidden = new Hidden('id');
     if ($entity) {
         $hidden->setDefault(array($entity->id));
     }
     $this->add($hidden);
 }