Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
12694 anikendra 1
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
2
 
3
/**
4
 * Modular Extensions - HMVC
5
 *
6
 * Adapted from the CodeIgniter Core Classes
7
 * @link	http://codeigniter.com
8
 *
9
 * Description:
10
 * This library extends the CodeIgniter CI_Config class
11
 * and adds features allowing use of modules and the HMVC design pattern.
12
 *
13
 * Install this file as application/third_party/MX/Config.php
14
 *
15
 * @copyright	Copyright (c) 2011 Wiredesignz
16
 * @version 	5.4
17
 * 
18
 * Permission is hereby granted, free of charge, to any person obtaining a copy
19
 * of this software and associated documentation files (the "Software"), to deal
20
 * in the Software without restriction, including without limitation the rights
21
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22
 * copies of the Software, and to permit persons to whom the Software is
23
 * furnished to do so, subject to the following conditions:
24
 * 
25
 * The above copyright notice and this permission notice shall be included in
26
 * all copies or substantial portions of the Software.
27
 * 
28
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34
 * THE SOFTWARE.
35
 **/
36
class MX_Config extends CI_Config 
37
{	
38
	public function load($file = 'config', $use_sections = FALSE, $fail_gracefully = FALSE, $_module = '') {
39
 
40
		if (in_array($file, $this->is_loaded, TRUE)) return $this->item($file);
41
 
42
		$_module OR $_module = CI::$APP->router->fetch_module();
43
		list($path, $file) = Modules::find($file, $_module, 'config/');
44
 
45
		if ($path === FALSE) {
46
			parent::load($file, $use_sections, $fail_gracefully);					
47
			return $this->item($file);
48
		}  
49
 
50
		if ($config = Modules::load_file($file, $path, 'config')) {
51
 
52
			/* reference to the config array */
53
			$current_config =& $this->config;
54
 
55
			if ($use_sections === TRUE)	{
56
 
57
				if (isset($current_config[$file])) {
58
					$current_config[$file] = array_merge($current_config[$file], $config);
59
				} else {
60
					$current_config[$file] = $config;
61
				}
62
 
63
			} else {
64
				$current_config = array_merge($current_config, $config);
65
			}
66
			$this->is_loaded[] = $file;
67
			unset($config);
68
			return $this->item($file);
69
		}
70
	}
71
}