1 | <?php |
||
13 | class SparkPlug |
||
14 | { |
||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $constants = array(); |
||
19 | |||
20 | /** |
||
21 | * @var array |
||
22 | */ |
||
23 | protected $globals = array(); |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $path = ''; |
||
29 | |||
30 | /** |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $server = array(); |
||
34 | |||
35 | /** |
||
36 | * @param array $globals |
||
37 | * @param array $server |
||
38 | * @param string|null $path |
||
39 | */ |
||
40 | 24 | public function __construct(array &$globals, array $server, $path = null) |
|
56 | |||
57 | /** |
||
58 | * Returns the Codeigniter singleton. |
||
59 | * NOTE: To be removed in v1.0.0. Use instance() instead. |
||
60 | * |
||
61 | * @return \CI_Controller |
||
62 | */ |
||
63 | 12 | public function getCodeIgniter() |
|
67 | |||
68 | /** |
||
69 | * Returns the Codeigniter singleton. |
||
70 | * |
||
71 | * @return \CI_Controller |
||
72 | */ |
||
73 | 24 | public function instance() |
|
93 | |||
94 | /** |
||
95 | * Sets the constant with a value. |
||
96 | * |
||
97 | * @param string $key |
||
98 | * @param string $value |
||
99 | */ |
||
100 | 12 | public function set($key, $value) |
|
106 | |||
107 | /** |
||
108 | * Sets the base path. |
||
109 | * |
||
110 | * @return void |
||
111 | */ |
||
112 | 3 | protected function basepath() |
|
128 | |||
129 | /** |
||
130 | * Sets up important charset-related stuff. |
||
131 | * |
||
132 | * @return void |
||
133 | */ |
||
134 | 24 | protected function charset() |
|
135 | { |
||
136 | 24 | ini_set('default_charset', $charset = strtoupper(config_item('charset'))); |
|
137 | |||
138 | 24 | defined('MB_ENABLED') || define('MB_ENABLED', extension_loaded('mbstring')); |
|
139 | |||
140 | 24 | $encoding = 'mbstring.internal_encoding'; |
|
141 | |||
142 | 24 | ! is_php('5.6') && ! ini_get($encoding) && ini_set($encoding, $charset); |
|
143 | |||
144 | 24 | $this->iconv(); |
|
145 | 24 | } |
|
146 | |||
147 | /** |
||
148 | * Loads the Common and the Base Controller class. |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | 24 | protected function common() |
|
153 | { |
||
154 | 24 | $exists = class_exists('CI_Controller'); |
|
155 | |||
156 | 24 | require BASEPATH . 'core/Common.php'; |
|
157 | |||
158 | 24 | $exists || require BASEPATH . 'core/Controller.php'; |
|
159 | |||
160 | 24 | $this->charset(); |
|
161 | 24 | } |
|
162 | |||
163 | /** |
||
164 | * Sets global configurations. |
||
165 | * |
||
166 | * @return void |
||
167 | */ |
||
168 | 24 | protected function config() |
|
169 | { |
||
170 | 24 | $this->globals['CFG'] =& load_class('Config', 'core'); |
|
171 | |||
172 | 24 | $this->globals['UNI'] =& load_class('Utf8', 'core'); |
|
173 | |||
174 | 24 | $this->globals['SEC'] =& load_class('Security', 'core'); |
|
175 | |||
176 | 24 | $this->core(); |
|
177 | 24 | } |
|
178 | |||
179 | /** |
||
180 | * Loads the framework constants. |
||
181 | * |
||
182 | * @return void |
||
183 | */ |
||
184 | 24 | protected function constants() |
|
185 | { |
||
186 | 24 | $config = APPPATH . 'config/'; |
|
187 | |||
188 | 24 | $constants = $config . ENVIRONMENT . '/constants.php'; |
|
189 | |||
190 | 24 | $filename = $config . 'constants.php'; |
|
191 | |||
192 | 24 | file_exists($constants) && $filename = $constants; |
|
193 | |||
194 | 24 | defined('FILE_READ_MODE') || require $filename; |
|
195 | 24 | } |
|
196 | |||
197 | /** |
||
198 | * Loads the CodeIgniter's core classes. |
||
199 | * |
||
200 | * @return void |
||
201 | */ |
||
202 | 24 | protected function core() |
|
212 | |||
213 | /** |
||
214 | * Sets up the current environment. |
||
215 | * |
||
216 | * @return void |
||
217 | */ |
||
218 | 24 | protected function environment($value = 'development') |
|
224 | |||
225 | /** |
||
226 | * Sets the ICONV constants. |
||
227 | * |
||
228 | * @param boolean $enabled |
||
229 | * @return void |
||
230 | */ |
||
231 | 24 | protected function iconv($enabled = false) |
|
237 | |||
238 | /** |
||
239 | * Sets up the APPPATH, VENDOR, and BASEPATH constants. |
||
240 | * |
||
241 | * @return void |
||
242 | */ |
||
243 | 24 | protected function paths() |
|
259 | } |
||
260 |