@@ -1,34 +1,34 @@ discard block |
||
1 | 1 | <?php namespace Myth\Settings; |
2 | 2 | /** |
3 | - * Sprint |
|
4 | - * |
|
5 | - * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow. |
|
6 | - * |
|
7 | - * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 | - * of this software and associated documentation files (the "Software"), to deal |
|
9 | - * in the Software without restriction, including without limitation the rights |
|
10 | - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 | - * copies of the Software, and to permit persons to whom the Software is |
|
12 | - * furnished to do so, subject to the following conditions: |
|
13 | - * |
|
14 | - * The above copyright notice and this permission notice shall be included in |
|
15 | - * all copies or substantial portions of the Software. |
|
16 | - * |
|
17 | - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 | - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 | - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 | - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 | - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 | - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 | - * THE SOFTWARE. |
|
24 | - * |
|
25 | - * @package Sprint |
|
26 | - * @author Lonnie Ezell |
|
27 | - * @copyright Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com) |
|
28 | - * @license http://opensource.org/licenses/MIT (MIT) |
|
29 | - * @link http://sprintphp.com |
|
30 | - * @since Version 1.0 |
|
31 | - */ |
|
3 | + * Sprint |
|
4 | + * |
|
5 | + * A set of power tools to enhance the CodeIgniter framework and provide consistent workflow. |
|
6 | + * |
|
7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
|
8 | + * of this software and associated documentation files (the "Software"), to deal |
|
9 | + * in the Software without restriction, including without limitation the rights |
|
10 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
11 | + * copies of the Software, and to permit persons to whom the Software is |
|
12 | + * furnished to do so, subject to the following conditions: |
|
13 | + * |
|
14 | + * The above copyright notice and this permission notice shall be included in |
|
15 | + * all copies or substantial portions of the Software. |
|
16 | + * |
|
17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
19 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
20 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
21 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
22 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
23 | + * THE SOFTWARE. |
|
24 | + * |
|
25 | + * @package Sprint |
|
26 | + * @author Lonnie Ezell |
|
27 | + * @copyright Copyright 2014-2015, New Myth Media, LLC (http://newmythmedia.com) |
|
28 | + * @license http://opensource.org/licenses/MIT (MIT) |
|
29 | + * @link http://sprintphp.com |
|
30 | + * @since Version 1.0 |
|
31 | + */ |
|
32 | 32 | |
33 | 33 | /** |
34 | 34 | * Class Settings |
@@ -40,253 +40,253 @@ discard block |
||
40 | 40 | */ |
41 | 41 | class Settings { |
42 | 42 | |
43 | - /** |
|
44 | - * Holds instantiated data stores. |
|
45 | - * |
|
46 | - * @var array |
|
47 | - */ |
|
48 | - protected static $stores = []; |
|
49 | - |
|
50 | - protected static $default_store = ''; |
|
51 | - |
|
52 | - protected static $initialized = false; |
|
53 | - |
|
54 | - //-------------------------------------------------------------------- |
|
55 | - |
|
56 | - /** |
|
57 | - * Fires up instances of the datastores and gets us ready to roll. |
|
58 | - */ |
|
59 | - public static function init() |
|
60 | - { |
|
61 | - if (self::$initialized === true) |
|
62 | - { |
|
63 | - return; |
|
64 | - } |
|
65 | - |
|
66 | - // Load up and instantiate our setting stores. |
|
67 | - $user_stores = config_item('settings.stores'); |
|
68 | - |
|
69 | - if (is_array($user_stores)) |
|
70 | - { |
|
71 | - foreach ($user_stores as $alias => $class) |
|
72 | - { |
|
73 | - self::$stores[ strtolower($alias) ] = new $class(); |
|
74 | - } |
|
75 | - } |
|
76 | - |
|
77 | - self::$default_store = config_item('settings.default_store'); |
|
78 | - |
|
79 | - if (empty(self::$stores[ self::$default_store ])) |
|
80 | - { |
|
81 | - show_error( lang('settings.bad_default') ); |
|
82 | - } |
|
83 | - } |
|
84 | - |
|
85 | - //-------------------------------------------------------------------- |
|
86 | - |
|
87 | - /** |
|
88 | - * Inserts/Replaces a single setting item. |
|
89 | - * |
|
90 | - * @param $key |
|
91 | - * @param null $value |
|
92 | - * @param string $group |
|
93 | - * @param string $store |
|
94 | - */ |
|
95 | - public static function save($key, $value=null, $group='app', $store=null) |
|
96 | - { |
|
97 | - self::init(); |
|
98 | - |
|
99 | - if (empty($store) || empty(self::$stores[$store])) |
|
100 | - { |
|
101 | - // we've already determined that the default store exists |
|
102 | - // in the init() method. |
|
103 | - $store = self::$default_store; |
|
104 | - } |
|
105 | - |
|
106 | - return self::$stores[ $store ]->save($key, $value, $group); |
|
107 | - } |
|
108 | - |
|
109 | - //-------------------------------------------------------------------- |
|
110 | - |
|
111 | - /** |
|
112 | - * Retrieves a single item. If not $store is specified, will loop |
|
113 | - * through the stores in order until it finds it. If $store is |
|
114 | - * specified, will only look within that store for it. |
|
115 | - * |
|
116 | - * @param $key |
|
117 | - * @param string $group |
|
118 | - * @param string $store |
|
119 | - * @return mixed |
|
120 | - */ |
|
121 | - public static function get($key, $group='app', $store=null) |
|
122 | - { |
|
123 | - self::init(); |
|
124 | - |
|
125 | - $group = strtolower($group); |
|
126 | - |
|
127 | - // If the store is specified but doesn't exist, crap out |
|
128 | - // so that they developer has a chance to fix it. |
|
129 | - if (! is_null($store) && empty(self::$stores[$store])) |
|
130 | - { |
|
131 | - show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
132 | - } |
|
133 | - |
|
134 | - // If $store is set, get the value from that store only. |
|
135 | - if (! empty($store)) |
|
136 | - { |
|
137 | - return self::$stores[$store]->get($key, $group); |
|
138 | - } |
|
139 | - |
|
140 | - // Otherwise loop through each store until we find it |
|
141 | - foreach (self::$stores as $s) |
|
142 | - { |
|
143 | - if ($found = $s->get($key, $group)) |
|
144 | - { |
|
145 | - return $found; |
|
146 | - } |
|
147 | - } |
|
148 | - |
|
149 | - // Still here... guess we didn't find anything, then... |
|
150 | - return false; |
|
151 | - } |
|
152 | - |
|
153 | - //-------------------------------------------------------------------- |
|
154 | - |
|
155 | - /** |
|
156 | - * Deletes a single item. |
|
157 | - * |
|
158 | - * @param $key |
|
159 | - * @param $group |
|
160 | - * @param $store |
|
161 | - * @return mixed |
|
162 | - */ |
|
163 | - public static function delete($key, $group='app', $store=null) |
|
164 | - { |
|
165 | - self::init(); |
|
166 | - |
|
167 | - $group = strtolower($group); |
|
168 | - |
|
169 | - // If the store is specified but doesn't exist, crap out |
|
170 | - // so that they developer has a chance to fix it. |
|
171 | - if (! is_null($store) && empty(self::$stores[$store])) |
|
172 | - { |
|
173 | - show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
174 | - } |
|
175 | - |
|
176 | - // If $store is set, get the value from that store only. |
|
177 | - if (! empty($store)) |
|
178 | - { |
|
179 | - return self::$stores[$store]->delete($key, $group); |
|
180 | - } |
|
181 | - |
|
182 | - // Otherwise delete from the default store |
|
183 | - return self::$stores[ self::$default_store ]->delete($key, $group); |
|
184 | - } |
|
185 | - |
|
186 | - //-------------------------------------------------------------------- |
|
187 | - |
|
188 | - /** |
|
189 | - * Searches the store for any items with $field = $value. |
|
190 | - * |
|
191 | - * @param $field |
|
192 | - * @param $value |
|
193 | - * @return mixed |
|
194 | - */ |
|
195 | - public static function findBy($field, $value) |
|
196 | - { |
|
197 | - self::init(); |
|
198 | - |
|
199 | - foreach (self::$stores as $s) |
|
200 | - { |
|
201 | - if ($found = $s->findBy($field, $value)) |
|
202 | - { |
|
203 | - return $found; |
|
204 | - } |
|
205 | - } |
|
206 | - |
|
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - //-------------------------------------------------------------------- |
|
211 | - |
|
212 | - /** |
|
213 | - * Retrieves all items in the store either globally or for a single group. |
|
214 | - * |
|
215 | - * @param string $group |
|
216 | - * @return mixed |
|
217 | - */ |
|
218 | - public static function all($group=null, $store=null) |
|
219 | - { |
|
220 | - self::init(); |
|
221 | - |
|
222 | - $group = strtolower($group); |
|
223 | - |
|
224 | - if (! empty($store)) |
|
225 | - { |
|
226 | - return self::$stores[ $store ]->all($group); |
|
227 | - } |
|
228 | - |
|
229 | - // Otherwise combine the results from all stores |
|
230 | - $results = []; |
|
231 | - |
|
232 | - foreach (self::$stores as $s) |
|
233 | - { |
|
234 | - $found = $s->all($group); |
|
235 | - if ($found) |
|
236 | - { |
|
237 | - $results = array_merge($results, (array)$found); |
|
238 | - } |
|
239 | - } |
|
240 | - |
|
241 | - return $results; |
|
242 | - } |
|
243 | - |
|
244 | - //-------------------------------------------------------------------- |
|
245 | - |
|
246 | - /** |
|
247 | - * Appends a new datastore the end of the curent stores. |
|
248 | - * |
|
249 | - * @param $alias |
|
250 | - * @param $class |
|
251 | - * @return bool |
|
252 | - */ |
|
253 | - public static function addStore($alias, $class) |
|
254 | - { |
|
255 | - self::init(); |
|
256 | - |
|
257 | - if (class_exists($class)) |
|
258 | - { |
|
259 | - self::$stores[ strtolower($alias) ] = new $class(); |
|
260 | - return true; |
|
261 | - } |
|
262 | - |
|
263 | - return false; |
|
264 | - } |
|
265 | - |
|
266 | - //-------------------------------------------------------------------- |
|
267 | - |
|
268 | - /** |
|
269 | - * Removes a datastore from the list of stores currently available. |
|
270 | - * |
|
271 | - * @param $alias |
|
272 | - * @return bool |
|
273 | - */ |
|
274 | - public static function removeStore($alias) |
|
275 | - { |
|
276 | - self::init(); |
|
277 | - |
|
278 | - $alias = strtolower($alias); |
|
279 | - |
|
280 | - if (empty(self::$stores[$alias])) |
|
281 | - { |
|
282 | - return false; |
|
283 | - } |
|
284 | - |
|
285 | - unset(self::$stores[$alias]); |
|
286 | - |
|
287 | - return true; |
|
288 | - } |
|
289 | - |
|
290 | - //-------------------------------------------------------------------- |
|
43 | + /** |
|
44 | + * Holds instantiated data stores. |
|
45 | + * |
|
46 | + * @var array |
|
47 | + */ |
|
48 | + protected static $stores = []; |
|
49 | + |
|
50 | + protected static $default_store = ''; |
|
51 | + |
|
52 | + protected static $initialized = false; |
|
53 | + |
|
54 | + //-------------------------------------------------------------------- |
|
55 | + |
|
56 | + /** |
|
57 | + * Fires up instances of the datastores and gets us ready to roll. |
|
58 | + */ |
|
59 | + public static function init() |
|
60 | + { |
|
61 | + if (self::$initialized === true) |
|
62 | + { |
|
63 | + return; |
|
64 | + } |
|
65 | + |
|
66 | + // Load up and instantiate our setting stores. |
|
67 | + $user_stores = config_item('settings.stores'); |
|
68 | + |
|
69 | + if (is_array($user_stores)) |
|
70 | + { |
|
71 | + foreach ($user_stores as $alias => $class) |
|
72 | + { |
|
73 | + self::$stores[ strtolower($alias) ] = new $class(); |
|
74 | + } |
|
75 | + } |
|
76 | + |
|
77 | + self::$default_store = config_item('settings.default_store'); |
|
78 | + |
|
79 | + if (empty(self::$stores[ self::$default_store ])) |
|
80 | + { |
|
81 | + show_error( lang('settings.bad_default') ); |
|
82 | + } |
|
83 | + } |
|
84 | + |
|
85 | + //-------------------------------------------------------------------- |
|
86 | + |
|
87 | + /** |
|
88 | + * Inserts/Replaces a single setting item. |
|
89 | + * |
|
90 | + * @param $key |
|
91 | + * @param null $value |
|
92 | + * @param string $group |
|
93 | + * @param string $store |
|
94 | + */ |
|
95 | + public static function save($key, $value=null, $group='app', $store=null) |
|
96 | + { |
|
97 | + self::init(); |
|
98 | + |
|
99 | + if (empty($store) || empty(self::$stores[$store])) |
|
100 | + { |
|
101 | + // we've already determined that the default store exists |
|
102 | + // in the init() method. |
|
103 | + $store = self::$default_store; |
|
104 | + } |
|
105 | + |
|
106 | + return self::$stores[ $store ]->save($key, $value, $group); |
|
107 | + } |
|
108 | + |
|
109 | + //-------------------------------------------------------------------- |
|
110 | + |
|
111 | + /** |
|
112 | + * Retrieves a single item. If not $store is specified, will loop |
|
113 | + * through the stores in order until it finds it. If $store is |
|
114 | + * specified, will only look within that store for it. |
|
115 | + * |
|
116 | + * @param $key |
|
117 | + * @param string $group |
|
118 | + * @param string $store |
|
119 | + * @return mixed |
|
120 | + */ |
|
121 | + public static function get($key, $group='app', $store=null) |
|
122 | + { |
|
123 | + self::init(); |
|
124 | + |
|
125 | + $group = strtolower($group); |
|
126 | + |
|
127 | + // If the store is specified but doesn't exist, crap out |
|
128 | + // so that they developer has a chance to fix it. |
|
129 | + if (! is_null($store) && empty(self::$stores[$store])) |
|
130 | + { |
|
131 | + show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
132 | + } |
|
133 | + |
|
134 | + // If $store is set, get the value from that store only. |
|
135 | + if (! empty($store)) |
|
136 | + { |
|
137 | + return self::$stores[$store]->get($key, $group); |
|
138 | + } |
|
139 | + |
|
140 | + // Otherwise loop through each store until we find it |
|
141 | + foreach (self::$stores as $s) |
|
142 | + { |
|
143 | + if ($found = $s->get($key, $group)) |
|
144 | + { |
|
145 | + return $found; |
|
146 | + } |
|
147 | + } |
|
148 | + |
|
149 | + // Still here... guess we didn't find anything, then... |
|
150 | + return false; |
|
151 | + } |
|
152 | + |
|
153 | + //-------------------------------------------------------------------- |
|
154 | + |
|
155 | + /** |
|
156 | + * Deletes a single item. |
|
157 | + * |
|
158 | + * @param $key |
|
159 | + * @param $group |
|
160 | + * @param $store |
|
161 | + * @return mixed |
|
162 | + */ |
|
163 | + public static function delete($key, $group='app', $store=null) |
|
164 | + { |
|
165 | + self::init(); |
|
166 | + |
|
167 | + $group = strtolower($group); |
|
168 | + |
|
169 | + // If the store is specified but doesn't exist, crap out |
|
170 | + // so that they developer has a chance to fix it. |
|
171 | + if (! is_null($store) && empty(self::$stores[$store])) |
|
172 | + { |
|
173 | + show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
174 | + } |
|
175 | + |
|
176 | + // If $store is set, get the value from that store only. |
|
177 | + if (! empty($store)) |
|
178 | + { |
|
179 | + return self::$stores[$store]->delete($key, $group); |
|
180 | + } |
|
181 | + |
|
182 | + // Otherwise delete from the default store |
|
183 | + return self::$stores[ self::$default_store ]->delete($key, $group); |
|
184 | + } |
|
185 | + |
|
186 | + //-------------------------------------------------------------------- |
|
187 | + |
|
188 | + /** |
|
189 | + * Searches the store for any items with $field = $value. |
|
190 | + * |
|
191 | + * @param $field |
|
192 | + * @param $value |
|
193 | + * @return mixed |
|
194 | + */ |
|
195 | + public static function findBy($field, $value) |
|
196 | + { |
|
197 | + self::init(); |
|
198 | + |
|
199 | + foreach (self::$stores as $s) |
|
200 | + { |
|
201 | + if ($found = $s->findBy($field, $value)) |
|
202 | + { |
|
203 | + return $found; |
|
204 | + } |
|
205 | + } |
|
206 | + |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + //-------------------------------------------------------------------- |
|
211 | + |
|
212 | + /** |
|
213 | + * Retrieves all items in the store either globally or for a single group. |
|
214 | + * |
|
215 | + * @param string $group |
|
216 | + * @return mixed |
|
217 | + */ |
|
218 | + public static function all($group=null, $store=null) |
|
219 | + { |
|
220 | + self::init(); |
|
221 | + |
|
222 | + $group = strtolower($group); |
|
223 | + |
|
224 | + if (! empty($store)) |
|
225 | + { |
|
226 | + return self::$stores[ $store ]->all($group); |
|
227 | + } |
|
228 | + |
|
229 | + // Otherwise combine the results from all stores |
|
230 | + $results = []; |
|
231 | + |
|
232 | + foreach (self::$stores as $s) |
|
233 | + { |
|
234 | + $found = $s->all($group); |
|
235 | + if ($found) |
|
236 | + { |
|
237 | + $results = array_merge($results, (array)$found); |
|
238 | + } |
|
239 | + } |
|
240 | + |
|
241 | + return $results; |
|
242 | + } |
|
243 | + |
|
244 | + //-------------------------------------------------------------------- |
|
245 | + |
|
246 | + /** |
|
247 | + * Appends a new datastore the end of the curent stores. |
|
248 | + * |
|
249 | + * @param $alias |
|
250 | + * @param $class |
|
251 | + * @return bool |
|
252 | + */ |
|
253 | + public static function addStore($alias, $class) |
|
254 | + { |
|
255 | + self::init(); |
|
256 | + |
|
257 | + if (class_exists($class)) |
|
258 | + { |
|
259 | + self::$stores[ strtolower($alias) ] = new $class(); |
|
260 | + return true; |
|
261 | + } |
|
262 | + |
|
263 | + return false; |
|
264 | + } |
|
265 | + |
|
266 | + //-------------------------------------------------------------------- |
|
267 | + |
|
268 | + /** |
|
269 | + * Removes a datastore from the list of stores currently available. |
|
270 | + * |
|
271 | + * @param $alias |
|
272 | + * @return bool |
|
273 | + */ |
|
274 | + public static function removeStore($alias) |
|
275 | + { |
|
276 | + self::init(); |
|
277 | + |
|
278 | + $alias = strtolower($alias); |
|
279 | + |
|
280 | + if (empty(self::$stores[$alias])) |
|
281 | + { |
|
282 | + return false; |
|
283 | + } |
|
284 | + |
|
285 | + unset(self::$stores[$alias]); |
|
286 | + |
|
287 | + return true; |
|
288 | + } |
|
289 | + |
|
290 | + //-------------------------------------------------------------------- |
|
291 | 291 | |
292 | 292 | } |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | { |
71 | 71 | foreach ($user_stores as $alias => $class) |
72 | 72 | { |
73 | - self::$stores[ strtolower($alias) ] = new $class(); |
|
73 | + self::$stores[strtolower($alias)] = new $class(); |
|
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | 77 | self::$default_store = config_item('settings.default_store'); |
78 | 78 | |
79 | - if (empty(self::$stores[ self::$default_store ])) |
|
79 | + if (empty(self::$stores[self::$default_store])) |
|
80 | 80 | { |
81 | - show_error( lang('settings.bad_default') ); |
|
81 | + show_error(lang('settings.bad_default')); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * @param string $group |
93 | 93 | * @param string $store |
94 | 94 | */ |
95 | - public static function save($key, $value=null, $group='app', $store=null) |
|
95 | + public static function save($key, $value = null, $group = 'app', $store = null) |
|
96 | 96 | { |
97 | 97 | self::init(); |
98 | 98 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $store = self::$default_store; |
104 | 104 | } |
105 | 105 | |
106 | - return self::$stores[ $store ]->save($key, $value, $group); |
|
106 | + return self::$stores[$store]->save($key, $value, $group); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | //-------------------------------------------------------------------- |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param string $store |
119 | 119 | * @return mixed |
120 | 120 | */ |
121 | - public static function get($key, $group='app', $store=null) |
|
121 | + public static function get($key, $group = 'app', $store = null) |
|
122 | 122 | { |
123 | 123 | self::init(); |
124 | 124 | |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | |
127 | 127 | // If the store is specified but doesn't exist, crap out |
128 | 128 | // so that they developer has a chance to fix it. |
129 | - if (! is_null($store) && empty(self::$stores[$store])) |
|
129 | + if ( ! is_null($store) && empty(self::$stores[$store])) |
|
130 | 130 | { |
131 | - show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
131 | + show_error(sprintf(lang('settings.cant_retrieve'), $store)); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | // If $store is set, get the value from that store only. |
135 | - if (! empty($store)) |
|
135 | + if ( ! empty($store)) |
|
136 | 136 | { |
137 | 137 | return self::$stores[$store]->get($key, $group); |
138 | 138 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | * @param $store |
161 | 161 | * @return mixed |
162 | 162 | */ |
163 | - public static function delete($key, $group='app', $store=null) |
|
163 | + public static function delete($key, $group = 'app', $store = null) |
|
164 | 164 | { |
165 | 165 | self::init(); |
166 | 166 | |
@@ -168,19 +168,19 @@ discard block |
||
168 | 168 | |
169 | 169 | // If the store is specified but doesn't exist, crap out |
170 | 170 | // so that they developer has a chance to fix it. |
171 | - if (! is_null($store) && empty(self::$stores[$store])) |
|
171 | + if ( ! is_null($store) && empty(self::$stores[$store])) |
|
172 | 172 | { |
173 | - show_error( sprintf( lang('settings.cant_retrieve'), $store ) ); |
|
173 | + show_error(sprintf(lang('settings.cant_retrieve'), $store)); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | // If $store is set, get the value from that store only. |
177 | - if (! empty($store)) |
|
177 | + if ( ! empty($store)) |
|
178 | 178 | { |
179 | 179 | return self::$stores[$store]->delete($key, $group); |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Otherwise delete from the default store |
183 | - return self::$stores[ self::$default_store ]->delete($key, $group); |
|
183 | + return self::$stores[self::$default_store]->delete($key, $group); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | //-------------------------------------------------------------------- |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | * @param string $group |
216 | 216 | * @return mixed |
217 | 217 | */ |
218 | - public static function all($group=null, $store=null) |
|
218 | + public static function all($group = null, $store = null) |
|
219 | 219 | { |
220 | 220 | self::init(); |
221 | 221 | |
222 | 222 | $group = strtolower($group); |
223 | 223 | |
224 | - if (! empty($store)) |
|
224 | + if ( ! empty($store)) |
|
225 | 225 | { |
226 | - return self::$stores[ $store ]->all($group); |
|
226 | + return self::$stores[$store]->all($group); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | // Otherwise combine the results from all stores |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $found = $s->all($group); |
235 | 235 | if ($found) |
236 | 236 | { |
237 | - $results = array_merge($results, (array)$found); |
|
237 | + $results = array_merge($results, (array) $found); |
|
238 | 238 | } |
239 | 239 | } |
240 | 240 | |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | |
257 | 257 | if (class_exists($class)) |
258 | 258 | { |
259 | - self::$stores[ strtolower($alias) ] = new $class(); |
|
259 | + self::$stores[strtolower($alias)] = new $class(); |
|
260 | 260 | return true; |
261 | 261 | } |
262 | 262 |
@@ -40,58 +40,58 @@ |
||
40 | 40 | */ |
41 | 41 | interface SettingsStoreInterface { |
42 | 42 | |
43 | - /** |
|
44 | - * Inserts/Replaces a single setting item. |
|
45 | - * |
|
46 | - * @param $key |
|
47 | - * @param null $value |
|
48 | - * @param string $group |
|
49 | - */ |
|
50 | - public function save($key, $value=null, $group='app'); |
|
43 | + /** |
|
44 | + * Inserts/Replaces a single setting item. |
|
45 | + * |
|
46 | + * @param $key |
|
47 | + * @param null $value |
|
48 | + * @param string $group |
|
49 | + */ |
|
50 | + public function save($key, $value=null, $group='app'); |
|
51 | 51 | |
52 | - //-------------------------------------------------------------------- |
|
52 | + //-------------------------------------------------------------------- |
|
53 | 53 | |
54 | - /** |
|
55 | - * Retrieves a single item. |
|
56 | - * |
|
57 | - * @param $key |
|
58 | - * @param string $group |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public function get($key, $group='app'); |
|
54 | + /** |
|
55 | + * Retrieves a single item. |
|
56 | + * |
|
57 | + * @param $key |
|
58 | + * @param string $group |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public function get($key, $group='app'); |
|
62 | 62 | |
63 | - //-------------------------------------------------------------------- |
|
63 | + //-------------------------------------------------------------------- |
|
64 | 64 | |
65 | - /** |
|
66 | - * Deletes a single item. |
|
67 | - * |
|
68 | - * @param $key |
|
69 | - * @param $group |
|
70 | - * @return mixed |
|
71 | - */ |
|
72 | - public function delete($key, $group='app'); |
|
65 | + /** |
|
66 | + * Deletes a single item. |
|
67 | + * |
|
68 | + * @param $key |
|
69 | + * @param $group |
|
70 | + * @return mixed |
|
71 | + */ |
|
72 | + public function delete($key, $group='app'); |
|
73 | 73 | |
74 | - //-------------------------------------------------------------------- |
|
74 | + //-------------------------------------------------------------------- |
|
75 | 75 | |
76 | - /** |
|
77 | - * Searches the store for any items with $field = $value. |
|
78 | - * |
|
79 | - * @param $field |
|
80 | - * @param $value |
|
81 | - * @return mixed |
|
82 | - */ |
|
83 | - public function findBy($field, $value); |
|
76 | + /** |
|
77 | + * Searches the store for any items with $field = $value. |
|
78 | + * |
|
79 | + * @param $field |
|
80 | + * @param $value |
|
81 | + * @return mixed |
|
82 | + */ |
|
83 | + public function findBy($field, $value); |
|
84 | 84 | |
85 | - //-------------------------------------------------------------------- |
|
85 | + //-------------------------------------------------------------------- |
|
86 | 86 | |
87 | - /** |
|
88 | - * Retrieves all items in the store either globally or for a single group. |
|
89 | - * |
|
90 | - * @param string $group |
|
91 | - * @return mixed |
|
92 | - */ |
|
93 | - public function all($group=null); |
|
87 | + /** |
|
88 | + * Retrieves all items in the store either globally or for a single group. |
|
89 | + * |
|
90 | + * @param string $group |
|
91 | + * @return mixed |
|
92 | + */ |
|
93 | + public function all($group=null); |
|
94 | 94 | |
95 | - //-------------------------------------------------------------------- |
|
95 | + //-------------------------------------------------------------------- |
|
96 | 96 | |
97 | 97 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param null $value |
48 | 48 | * @param string $group |
49 | 49 | */ |
50 | - public function save($key, $value=null, $group='app'); |
|
50 | + public function save($key, $value = null, $group = 'app'); |
|
51 | 51 | |
52 | 52 | //-------------------------------------------------------------------- |
53 | 53 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * @param string $group |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function get($key, $group='app'); |
|
61 | + public function get($key, $group = 'app'); |
|
62 | 62 | |
63 | 63 | //-------------------------------------------------------------------- |
64 | 64 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @param $group |
70 | 70 | * @return mixed |
71 | 71 | */ |
72 | - public function delete($key, $group='app'); |
|
72 | + public function delete($key, $group = 'app'); |
|
73 | 73 | |
74 | 74 | //-------------------------------------------------------------------- |
75 | 75 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $group |
91 | 91 | * @return mixed |
92 | 92 | */ |
93 | - public function all($group=null); |
|
93 | + public function all($group = null); |
|
94 | 94 | |
95 | 95 | //-------------------------------------------------------------------- |
96 | 96 |
@@ -35,219 +35,219 @@ |
||
35 | 35 | |
36 | 36 | class MetaCollection implements MetaInterface { |
37 | 37 | |
38 | - /** |
|
39 | - * Stores the meta values the user has set. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - protected $meta = []; |
|
44 | - |
|
45 | - /** |
|
46 | - * Stores the standard meta-value names |
|
47 | - * Mostly here for reference, I guess. |
|
48 | - * |
|
49 | - * @var array |
|
50 | - */ |
|
51 | - protected $std_meta = [ |
|
52 | - 'application-name', |
|
53 | - 'author', |
|
54 | - 'copyright', |
|
55 | - 'description', |
|
56 | - 'generator', |
|
57 | - 'keywords', |
|
58 | - 'robots', |
|
59 | - 'googlebot' |
|
60 | - ]; |
|
61 | - |
|
62 | - /** |
|
63 | - * Stores the HTTP-Equiv meta tags |
|
64 | - * since they need to be rendered differently. |
|
65 | - * |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - protected $http_equiv_meta = [ |
|
69 | - 'cache-control', |
|
70 | - 'content-language', |
|
71 | - 'content-type', |
|
72 | - 'default-style', |
|
73 | - 'expires', |
|
74 | - 'pragma', |
|
75 | - 'refresh', |
|
76 | - 'set-cookie' |
|
77 | - ]; |
|
78 | - |
|
79 | - /** |
|
80 | - * Stores the document's character encoding. |
|
81 | - * |
|
82 | - * @var string |
|
83 | - */ |
|
84 | - public $charset = 'utf-8'; |
|
85 | - |
|
86 | - //-------------------------------------------------------------------- |
|
87 | - |
|
88 | - public function __construct($ci) |
|
89 | - { |
|
90 | - $ci->config->load('html_meta', true); |
|
91 | - |
|
92 | - $config = $ci->config->item('html_meta'); |
|
93 | - |
|
94 | - $this->meta = $config['meta']; |
|
95 | - |
|
96 | - $this->http_equiv_meta = array_merge($this->http_equiv_meta, $config['http-equiv']); |
|
97 | - } |
|
98 | - |
|
99 | - //-------------------------------------------------------------------- |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * Sets a single meta item. |
|
104 | - * $alias can also be an array of key/value pairs to set. |
|
105 | - * |
|
106 | - * @param string|array $alias |
|
107 | - * @param null $value |
|
108 | - * |
|
109 | - * @return mixed |
|
110 | - */ |
|
111 | - public function set($alias, $value=null, $escape=true) |
|
112 | - { |
|
113 | - if (is_array($alias)) |
|
114 | - { |
|
115 | - foreach ($alias as $key => $val) |
|
116 | - { |
|
117 | - $this->set($key, $val); |
|
118 | - } |
|
119 | - |
|
120 | - return $this; |
|
121 | - } |
|
122 | - |
|
123 | - // Charset |
|
124 | - if (strtolower($alias) == 'charset') |
|
125 | - { |
|
126 | - $this->charset = $value; |
|
127 | - |
|
128 | - return $this; |
|
129 | - } |
|
130 | - |
|
131 | - $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
132 | - |
|
133 | - return $this; |
|
134 | - } |
|
135 | - |
|
136 | - //-------------------------------------------------------------------- |
|
137 | - |
|
138 | - /** |
|
139 | - * Returns a single meta item. |
|
140 | - * |
|
141 | - * @param $alias |
|
142 | - * |
|
143 | - * @return mixed |
|
144 | - */ |
|
145 | - public function get($alias) |
|
146 | - { |
|
147 | - $alias = strtolower($alias); |
|
148 | - |
|
149 | - return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
150 | - } |
|
151 | - |
|
152 | - //-------------------------------------------------------------------- |
|
153 | - |
|
154 | - /** |
|
155 | - * Renders out all defined meta tags. |
|
156 | - * |
|
157 | - * @return mixed |
|
158 | - */ |
|
159 | - public function renderTags() |
|
160 | - { |
|
161 | - if (! count($this->meta)) |
|
162 | - { |
|
163 | - return null; |
|
164 | - } |
|
165 | - |
|
166 | - $output = ''; |
|
167 | - |
|
168 | - // Character Encoding |
|
169 | - $output .= "\t<meta charset=\"{$this->charset}\" >"; |
|
170 | - |
|
171 | - // Everything else |
|
172 | - foreach ($this->meta as $name => $content) |
|
173 | - { |
|
174 | - if (is_array($content)) |
|
175 | - { |
|
176 | - $content = implode(',', $content); |
|
177 | - } |
|
178 | - |
|
179 | - if (empty($content)) |
|
180 | - { |
|
181 | - continue; |
|
182 | - } |
|
183 | - |
|
184 | - // Http Equivalent meta tags. |
|
185 | - if (in_array($name, $this->http_equiv_meta)) |
|
186 | - { |
|
187 | - $output .= "\t<meta http-equiv=\"{$name}\" content=\"{$content}\">\n"; |
|
188 | - } |
|
189 | - // Standard Meta Tag |
|
190 | - else { |
|
191 | - $output .= "\t<meta name=\"{$name}\" content=\"{$content}\">\n"; |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - return $output; |
|
196 | - } |
|
197 | - |
|
198 | - //-------------------------------------------------------------------- |
|
199 | - |
|
200 | - /** |
|
201 | - * Registers a new HTTP Equivalent meta tag so it can be |
|
202 | - * rendered out properly. |
|
203 | - * |
|
204 | - * @param $name |
|
205 | - * |
|
206 | - * @return $this |
|
207 | - */ |
|
208 | - public function registerHTTPEquivTag($name) |
|
209 | - { |
|
210 | - if (is_null($name)) |
|
211 | - { |
|
212 | - return $this; |
|
213 | - } |
|
214 | - |
|
215 | - $this->http_equiv_meta[] = strtolower($name); |
|
216 | - |
|
217 | - return $this; |
|
218 | - } |
|
219 | - |
|
220 | - //-------------------------------------------------------------------- |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * Convenience implementation to set a value |
|
225 | - * as if it was a property of the class. |
|
226 | - * |
|
227 | - * @param $alias |
|
228 | - * @param null $value |
|
229 | - */ |
|
230 | - public function __set($alias, $value=null) |
|
231 | - { |
|
232 | - $this->set($alias, $value); |
|
233 | - } |
|
234 | - |
|
235 | - //-------------------------------------------------------------------- |
|
236 | - |
|
237 | - /** |
|
238 | - * Convenience method to access a value |
|
239 | - * as if it was a property of the class. |
|
240 | - * |
|
241 | - * @param $alias |
|
242 | - * |
|
243 | - * @return mixed |
|
244 | - */ |
|
245 | - public function __get($alias) |
|
246 | - { |
|
247 | - return $this->get($alias); |
|
248 | - } |
|
249 | - |
|
250 | - //-------------------------------------------------------------------- |
|
38 | + /** |
|
39 | + * Stores the meta values the user has set. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + protected $meta = []; |
|
44 | + |
|
45 | + /** |
|
46 | + * Stores the standard meta-value names |
|
47 | + * Mostly here for reference, I guess. |
|
48 | + * |
|
49 | + * @var array |
|
50 | + */ |
|
51 | + protected $std_meta = [ |
|
52 | + 'application-name', |
|
53 | + 'author', |
|
54 | + 'copyright', |
|
55 | + 'description', |
|
56 | + 'generator', |
|
57 | + 'keywords', |
|
58 | + 'robots', |
|
59 | + 'googlebot' |
|
60 | + ]; |
|
61 | + |
|
62 | + /** |
|
63 | + * Stores the HTTP-Equiv meta tags |
|
64 | + * since they need to be rendered differently. |
|
65 | + * |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + protected $http_equiv_meta = [ |
|
69 | + 'cache-control', |
|
70 | + 'content-language', |
|
71 | + 'content-type', |
|
72 | + 'default-style', |
|
73 | + 'expires', |
|
74 | + 'pragma', |
|
75 | + 'refresh', |
|
76 | + 'set-cookie' |
|
77 | + ]; |
|
78 | + |
|
79 | + /** |
|
80 | + * Stores the document's character encoding. |
|
81 | + * |
|
82 | + * @var string |
|
83 | + */ |
|
84 | + public $charset = 'utf-8'; |
|
85 | + |
|
86 | + //-------------------------------------------------------------------- |
|
87 | + |
|
88 | + public function __construct($ci) |
|
89 | + { |
|
90 | + $ci->config->load('html_meta', true); |
|
91 | + |
|
92 | + $config = $ci->config->item('html_meta'); |
|
93 | + |
|
94 | + $this->meta = $config['meta']; |
|
95 | + |
|
96 | + $this->http_equiv_meta = array_merge($this->http_equiv_meta, $config['http-equiv']); |
|
97 | + } |
|
98 | + |
|
99 | + //-------------------------------------------------------------------- |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * Sets a single meta item. |
|
104 | + * $alias can also be an array of key/value pairs to set. |
|
105 | + * |
|
106 | + * @param string|array $alias |
|
107 | + * @param null $value |
|
108 | + * |
|
109 | + * @return mixed |
|
110 | + */ |
|
111 | + public function set($alias, $value=null, $escape=true) |
|
112 | + { |
|
113 | + if (is_array($alias)) |
|
114 | + { |
|
115 | + foreach ($alias as $key => $val) |
|
116 | + { |
|
117 | + $this->set($key, $val); |
|
118 | + } |
|
119 | + |
|
120 | + return $this; |
|
121 | + } |
|
122 | + |
|
123 | + // Charset |
|
124 | + if (strtolower($alias) == 'charset') |
|
125 | + { |
|
126 | + $this->charset = $value; |
|
127 | + |
|
128 | + return $this; |
|
129 | + } |
|
130 | + |
|
131 | + $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
132 | + |
|
133 | + return $this; |
|
134 | + } |
|
135 | + |
|
136 | + //-------------------------------------------------------------------- |
|
137 | + |
|
138 | + /** |
|
139 | + * Returns a single meta item. |
|
140 | + * |
|
141 | + * @param $alias |
|
142 | + * |
|
143 | + * @return mixed |
|
144 | + */ |
|
145 | + public function get($alias) |
|
146 | + { |
|
147 | + $alias = strtolower($alias); |
|
148 | + |
|
149 | + return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
150 | + } |
|
151 | + |
|
152 | + //-------------------------------------------------------------------- |
|
153 | + |
|
154 | + /** |
|
155 | + * Renders out all defined meta tags. |
|
156 | + * |
|
157 | + * @return mixed |
|
158 | + */ |
|
159 | + public function renderTags() |
|
160 | + { |
|
161 | + if (! count($this->meta)) |
|
162 | + { |
|
163 | + return null; |
|
164 | + } |
|
165 | + |
|
166 | + $output = ''; |
|
167 | + |
|
168 | + // Character Encoding |
|
169 | + $output .= "\t<meta charset=\"{$this->charset}\" >"; |
|
170 | + |
|
171 | + // Everything else |
|
172 | + foreach ($this->meta as $name => $content) |
|
173 | + { |
|
174 | + if (is_array($content)) |
|
175 | + { |
|
176 | + $content = implode(',', $content); |
|
177 | + } |
|
178 | + |
|
179 | + if (empty($content)) |
|
180 | + { |
|
181 | + continue; |
|
182 | + } |
|
183 | + |
|
184 | + // Http Equivalent meta tags. |
|
185 | + if (in_array($name, $this->http_equiv_meta)) |
|
186 | + { |
|
187 | + $output .= "\t<meta http-equiv=\"{$name}\" content=\"{$content}\">\n"; |
|
188 | + } |
|
189 | + // Standard Meta Tag |
|
190 | + else { |
|
191 | + $output .= "\t<meta name=\"{$name}\" content=\"{$content}\">\n"; |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + return $output; |
|
196 | + } |
|
197 | + |
|
198 | + //-------------------------------------------------------------------- |
|
199 | + |
|
200 | + /** |
|
201 | + * Registers a new HTTP Equivalent meta tag so it can be |
|
202 | + * rendered out properly. |
|
203 | + * |
|
204 | + * @param $name |
|
205 | + * |
|
206 | + * @return $this |
|
207 | + */ |
|
208 | + public function registerHTTPEquivTag($name) |
|
209 | + { |
|
210 | + if (is_null($name)) |
|
211 | + { |
|
212 | + return $this; |
|
213 | + } |
|
214 | + |
|
215 | + $this->http_equiv_meta[] = strtolower($name); |
|
216 | + |
|
217 | + return $this; |
|
218 | + } |
|
219 | + |
|
220 | + //-------------------------------------------------------------------- |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * Convenience implementation to set a value |
|
225 | + * as if it was a property of the class. |
|
226 | + * |
|
227 | + * @param $alias |
|
228 | + * @param null $value |
|
229 | + */ |
|
230 | + public function __set($alias, $value=null) |
|
231 | + { |
|
232 | + $this->set($alias, $value); |
|
233 | + } |
|
234 | + |
|
235 | + //-------------------------------------------------------------------- |
|
236 | + |
|
237 | + /** |
|
238 | + * Convenience method to access a value |
|
239 | + * as if it was a property of the class. |
|
240 | + * |
|
241 | + * @param $alias |
|
242 | + * |
|
243 | + * @return mixed |
|
244 | + */ |
|
245 | + public function __get($alias) |
|
246 | + { |
|
247 | + return $this->get($alias); |
|
248 | + } |
|
249 | + |
|
250 | + //-------------------------------------------------------------------- |
|
251 | 251 | |
252 | 252 | |
253 | 253 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php namespace Myth\Themers; |
2 | 2 | |
3 | -require_once dirname(__FILE__) .'/escape.php'; |
|
3 | +require_once dirname(__FILE__).'/escape.php'; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Sprint |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * |
109 | 109 | * @return mixed |
110 | 110 | */ |
111 | - public function set($alias, $value=null, $escape=true) |
|
111 | + public function set($alias, $value = null, $escape = true) |
|
112 | 112 | { |
113 | 113 | if (is_array($alias)) |
114 | 114 | { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | return $this; |
129 | 129 | } |
130 | 130 | |
131 | - $this->meta[ strtolower($alias) ] = $escape ? esc($value, 'htmlAttr') : $value; |
|
131 | + $this->meta[strtolower($alias)] = $escape ? esc($value, 'htmlAttr') : $value; |
|
132 | 132 | |
133 | 133 | return $this; |
134 | 134 | } |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | { |
147 | 147 | $alias = strtolower($alias); |
148 | 148 | |
149 | - return isset($this->meta[ $alias ]) ? $this->meta[$alias] : null; |
|
149 | + return isset($this->meta[$alias]) ? $this->meta[$alias] : null; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | //-------------------------------------------------------------------- |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function renderTags() |
160 | 160 | { |
161 | - if (! count($this->meta)) |
|
161 | + if ( ! count($this->meta)) |
|
162 | 162 | { |
163 | 163 | return null; |
164 | 164 | } |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * @param $alias |
228 | 228 | * @param null $value |
229 | 229 | */ |
230 | - public function __set($alias, $value=null) |
|
230 | + public function __set($alias, $value = null) |
|
231 | 231 | { |
232 | 232 | $this->set($alias, $value); |
233 | 233 | } |
@@ -38,219 +38,219 @@ |
||
38 | 38 | */ |
39 | 39 | interface ThemerInterface |
40 | 40 | { |
41 | - /** |
|
42 | - * The main entryway into rendering a view. This is called from the |
|
43 | - * controller and is generally the last method called. |
|
44 | - * |
|
45 | - * @param string $layout If provided, will override the default layout. |
|
46 | - */ |
|
47 | - public function render($layout = null); |
|
48 | - |
|
49 | - //-------------------------------------------------------------------- |
|
50 | - |
|
51 | - /** |
|
52 | - * Used within the template layout file to render the current content. |
|
53 | - * This content is typically used to display the current view. |
|
54 | - */ |
|
55 | - public function content(); |
|
56 | - |
|
57 | - //-------------------------------------------------------------------- |
|
58 | - |
|
59 | - /** |
|
60 | - * Sets the active theme to use. This theme should be |
|
61 | - * relative to one of the 'theme_paths' folders. |
|
62 | - * |
|
63 | - * @param $theme |
|
64 | - */ |
|
65 | - public function setTheme($theme); |
|
66 | - |
|
67 | - //-------------------------------------------------------------------- |
|
68 | - |
|
69 | - /** |
|
70 | - * Returns the current theme. |
|
71 | - * |
|
72 | - * @return mixed|string |
|
73 | - */ |
|
74 | - public function theme(); |
|
75 | - |
|
76 | - //-------------------------------------------------------------------- |
|
77 | - |
|
78 | - /** |
|
79 | - * Sets the default theme to use. |
|
80 | - * |
|
81 | - * @param $theme |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - public function setDefaultTheme($theme); |
|
85 | - |
|
86 | - //-------------------------------------------------------------------- |
|
87 | - |
|
88 | - /** |
|
89 | - * Sets the current view file to render. |
|
90 | - * |
|
91 | - * @param $file |
|
92 | - * @return mixed |
|
93 | - */ |
|
94 | - public function setView($file); |
|
95 | - |
|
96 | - //-------------------------------------------------------------------- |
|
97 | - |
|
98 | - /** |
|
99 | - * Returns the current view. |
|
100 | - * |
|
101 | - * @return mixed|string |
|
102 | - */ |
|
103 | - public function view(); |
|
104 | - |
|
105 | - //-------------------------------------------------------------------- |
|
106 | - |
|
107 | - /** |
|
108 | - * Sets the current layout to be used. MUST be the name of one of |
|
109 | - * the layout files within the current theme. Case-sensitive. |
|
110 | - * |
|
111 | - * @param $file |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public function setLayout($file); |
|
115 | - |
|
116 | - //-------------------------------------------------------------------- |
|
117 | - |
|
118 | - /** |
|
119 | - * Returns the active layout. |
|
120 | - * |
|
121 | - * @return mixed |
|
122 | - */ |
|
123 | - public function layout(); |
|
124 | - |
|
125 | - //-------------------------------------------------------------------- |
|
126 | - |
|
127 | - /** |
|
128 | - * Stores one or more pieces of data to be passed to the views when |
|
129 | - * they are rendered out. |
|
130 | - * |
|
131 | - * If both $key and $value are ! empty, then it will treat it as a |
|
132 | - * key/value pair. If $key is an array of key/value pairs, then $value |
|
133 | - * is ignored and each element of the array are made available to the |
|
134 | - * view as if it was a single $key/$value pair. |
|
135 | - * |
|
136 | - * @param string|array $key |
|
137 | - * @param mixed $value |
|
138 | - */ |
|
139 | - public function set($key, $value = null); |
|
140 | - |
|
141 | - //-------------------------------------------------------------------- |
|
142 | - |
|
143 | - /** |
|
144 | - * Returns a value that has been previously set(). |
|
145 | - * |
|
146 | - * @param $key |
|
147 | - * @return mixed |
|
148 | - */ |
|
149 | - public function get($key); |
|
150 | - |
|
151 | - //-------------------------------------------------------------------- |
|
152 | - |
|
153 | - /** |
|
154 | - * Determines whether or not the view should be parsed with the |
|
155 | - * CodeIgniter's parser. |
|
156 | - * |
|
157 | - * @param bool $parse |
|
158 | - * @return mixed |
|
159 | - */ |
|
160 | - public function parseViews($parse = false); |
|
161 | - |
|
162 | - //-------------------------------------------------------------------- |
|
163 | - |
|
164 | - /** |
|
165 | - * Theme paths allow you to have multiple locations for themes to be |
|
166 | - * stored. This might be used for separating themes for different sub- |
|
167 | - * applications, or a core theme and user-submitted themes. |
|
168 | - * |
|
169 | - * @param $alias The name the theme can be referenced by |
|
170 | - * @param $path A new path where themes can be found. |
|
171 | - * |
|
172 | - * @return mixed |
|
173 | - */ |
|
174 | - public function addThemePath($alias, $path); |
|
175 | - |
|
176 | - //-------------------------------------------------------------------- |
|
177 | - |
|
178 | - /** |
|
179 | - * Removes a single theme path. |
|
180 | - * |
|
181 | - * @param $alias |
|
182 | - */ |
|
183 | - public function removeThemePath($alias); |
|
184 | - //-------------------------------------------------------------------- |
|
185 | - |
|
186 | - /** |
|
187 | - * Loads a view file. Useful to control caching. Intended for use |
|
188 | - * from within view files. |
|
189 | - * |
|
190 | - * You can specify that a view should belong to a theme by prefixing |
|
191 | - * the name of the theme and a colon to the view name. For example, |
|
192 | - * "admin:header" would try to display the "header.php" file within |
|
193 | - * the "admin" theme. |
|
194 | - * |
|
195 | - * @param string $view |
|
196 | - * @param array $data |
|
197 | - * @param int $cache_time The number of MINUTES to cache the output |
|
198 | - * @return mixed |
|
199 | - */ |
|
200 | - public function display($view, $data = array(), $cache_time = 0); |
|
201 | - |
|
202 | - //-------------------------------------------------------------------- |
|
203 | - |
|
204 | - /** |
|
205 | - * Sets the variant used when creating view names. These variants can |
|
206 | - * be anything, but by default are used to render specific templates |
|
207 | - * for desktop, tablet, and phone. The name of the variant is added |
|
208 | - * to the view name, joined by a "+" symbol. |
|
209 | - * |
|
210 | - * Example: |
|
211 | - * $this->setVariant('phone'); |
|
212 | - * $this->display('header'); |
|
213 | - * |
|
214 | - * Tries to display "views/header+phone.php" |
|
215 | - * |
|
216 | - * @param $variant |
|
217 | - * @return mixed |
|
218 | - */ |
|
219 | - public function setVariant($variant); |
|
220 | - |
|
221 | - //-------------------------------------------------------------------- |
|
222 | - |
|
223 | - /** |
|
224 | - * Adds a new variant to the system. |
|
225 | - * |
|
226 | - * @param $name |
|
227 | - * @param $postfix |
|
228 | - * @return mixed |
|
229 | - */ |
|
230 | - public function addVariant($name, $postfix); |
|
231 | - |
|
232 | - //-------------------------------------------------------------------- |
|
233 | - |
|
234 | - /** |
|
235 | - * Removes a variant from the system. |
|
236 | - * |
|
237 | - * @param $name |
|
238 | - * @param $postfix |
|
239 | - * @return mixed |
|
240 | - */ |
|
241 | - public function removeVariant($name); |
|
242 | - |
|
243 | - //-------------------------------------------------------------------- |
|
244 | - |
|
245 | - /** |
|
246 | - * Runs a callback method and returns the contents to the view. |
|
247 | - * |
|
248 | - * @param $command |
|
249 | - * @param int $cache_minutes |
|
250 | - * @return mixed |
|
251 | - */ |
|
252 | - public function call($command, $cache_minutes=0); |
|
253 | - |
|
254 | - //-------------------------------------------------------------------- |
|
41 | + /** |
|
42 | + * The main entryway into rendering a view. This is called from the |
|
43 | + * controller and is generally the last method called. |
|
44 | + * |
|
45 | + * @param string $layout If provided, will override the default layout. |
|
46 | + */ |
|
47 | + public function render($layout = null); |
|
48 | + |
|
49 | + //-------------------------------------------------------------------- |
|
50 | + |
|
51 | + /** |
|
52 | + * Used within the template layout file to render the current content. |
|
53 | + * This content is typically used to display the current view. |
|
54 | + */ |
|
55 | + public function content(); |
|
56 | + |
|
57 | + //-------------------------------------------------------------------- |
|
58 | + |
|
59 | + /** |
|
60 | + * Sets the active theme to use. This theme should be |
|
61 | + * relative to one of the 'theme_paths' folders. |
|
62 | + * |
|
63 | + * @param $theme |
|
64 | + */ |
|
65 | + public function setTheme($theme); |
|
66 | + |
|
67 | + //-------------------------------------------------------------------- |
|
68 | + |
|
69 | + /** |
|
70 | + * Returns the current theme. |
|
71 | + * |
|
72 | + * @return mixed|string |
|
73 | + */ |
|
74 | + public function theme(); |
|
75 | + |
|
76 | + //-------------------------------------------------------------------- |
|
77 | + |
|
78 | + /** |
|
79 | + * Sets the default theme to use. |
|
80 | + * |
|
81 | + * @param $theme |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + public function setDefaultTheme($theme); |
|
85 | + |
|
86 | + //-------------------------------------------------------------------- |
|
87 | + |
|
88 | + /** |
|
89 | + * Sets the current view file to render. |
|
90 | + * |
|
91 | + * @param $file |
|
92 | + * @return mixed |
|
93 | + */ |
|
94 | + public function setView($file); |
|
95 | + |
|
96 | + //-------------------------------------------------------------------- |
|
97 | + |
|
98 | + /** |
|
99 | + * Returns the current view. |
|
100 | + * |
|
101 | + * @return mixed|string |
|
102 | + */ |
|
103 | + public function view(); |
|
104 | + |
|
105 | + //-------------------------------------------------------------------- |
|
106 | + |
|
107 | + /** |
|
108 | + * Sets the current layout to be used. MUST be the name of one of |
|
109 | + * the layout files within the current theme. Case-sensitive. |
|
110 | + * |
|
111 | + * @param $file |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public function setLayout($file); |
|
115 | + |
|
116 | + //-------------------------------------------------------------------- |
|
117 | + |
|
118 | + /** |
|
119 | + * Returns the active layout. |
|
120 | + * |
|
121 | + * @return mixed |
|
122 | + */ |
|
123 | + public function layout(); |
|
124 | + |
|
125 | + //-------------------------------------------------------------------- |
|
126 | + |
|
127 | + /** |
|
128 | + * Stores one or more pieces of data to be passed to the views when |
|
129 | + * they are rendered out. |
|
130 | + * |
|
131 | + * If both $key and $value are ! empty, then it will treat it as a |
|
132 | + * key/value pair. If $key is an array of key/value pairs, then $value |
|
133 | + * is ignored and each element of the array are made available to the |
|
134 | + * view as if it was a single $key/$value pair. |
|
135 | + * |
|
136 | + * @param string|array $key |
|
137 | + * @param mixed $value |
|
138 | + */ |
|
139 | + public function set($key, $value = null); |
|
140 | + |
|
141 | + //-------------------------------------------------------------------- |
|
142 | + |
|
143 | + /** |
|
144 | + * Returns a value that has been previously set(). |
|
145 | + * |
|
146 | + * @param $key |
|
147 | + * @return mixed |
|
148 | + */ |
|
149 | + public function get($key); |
|
150 | + |
|
151 | + //-------------------------------------------------------------------- |
|
152 | + |
|
153 | + /** |
|
154 | + * Determines whether or not the view should be parsed with the |
|
155 | + * CodeIgniter's parser. |
|
156 | + * |
|
157 | + * @param bool $parse |
|
158 | + * @return mixed |
|
159 | + */ |
|
160 | + public function parseViews($parse = false); |
|
161 | + |
|
162 | + //-------------------------------------------------------------------- |
|
163 | + |
|
164 | + /** |
|
165 | + * Theme paths allow you to have multiple locations for themes to be |
|
166 | + * stored. This might be used for separating themes for different sub- |
|
167 | + * applications, or a core theme and user-submitted themes. |
|
168 | + * |
|
169 | + * @param $alias The name the theme can be referenced by |
|
170 | + * @param $path A new path where themes can be found. |
|
171 | + * |
|
172 | + * @return mixed |
|
173 | + */ |
|
174 | + public function addThemePath($alias, $path); |
|
175 | + |
|
176 | + //-------------------------------------------------------------------- |
|
177 | + |
|
178 | + /** |
|
179 | + * Removes a single theme path. |
|
180 | + * |
|
181 | + * @param $alias |
|
182 | + */ |
|
183 | + public function removeThemePath($alias); |
|
184 | + //-------------------------------------------------------------------- |
|
185 | + |
|
186 | + /** |
|
187 | + * Loads a view file. Useful to control caching. Intended for use |
|
188 | + * from within view files. |
|
189 | + * |
|
190 | + * You can specify that a view should belong to a theme by prefixing |
|
191 | + * the name of the theme and a colon to the view name. For example, |
|
192 | + * "admin:header" would try to display the "header.php" file within |
|
193 | + * the "admin" theme. |
|
194 | + * |
|
195 | + * @param string $view |
|
196 | + * @param array $data |
|
197 | + * @param int $cache_time The number of MINUTES to cache the output |
|
198 | + * @return mixed |
|
199 | + */ |
|
200 | + public function display($view, $data = array(), $cache_time = 0); |
|
201 | + |
|
202 | + //-------------------------------------------------------------------- |
|
203 | + |
|
204 | + /** |
|
205 | + * Sets the variant used when creating view names. These variants can |
|
206 | + * be anything, but by default are used to render specific templates |
|
207 | + * for desktop, tablet, and phone. The name of the variant is added |
|
208 | + * to the view name, joined by a "+" symbol. |
|
209 | + * |
|
210 | + * Example: |
|
211 | + * $this->setVariant('phone'); |
|
212 | + * $this->display('header'); |
|
213 | + * |
|
214 | + * Tries to display "views/header+phone.php" |
|
215 | + * |
|
216 | + * @param $variant |
|
217 | + * @return mixed |
|
218 | + */ |
|
219 | + public function setVariant($variant); |
|
220 | + |
|
221 | + //-------------------------------------------------------------------- |
|
222 | + |
|
223 | + /** |
|
224 | + * Adds a new variant to the system. |
|
225 | + * |
|
226 | + * @param $name |
|
227 | + * @param $postfix |
|
228 | + * @return mixed |
|
229 | + */ |
|
230 | + public function addVariant($name, $postfix); |
|
231 | + |
|
232 | + //-------------------------------------------------------------------- |
|
233 | + |
|
234 | + /** |
|
235 | + * Removes a variant from the system. |
|
236 | + * |
|
237 | + * @param $name |
|
238 | + * @param $postfix |
|
239 | + * @return mixed |
|
240 | + */ |
|
241 | + public function removeVariant($name); |
|
242 | + |
|
243 | + //-------------------------------------------------------------------- |
|
244 | + |
|
245 | + /** |
|
246 | + * Runs a callback method and returns the contents to the view. |
|
247 | + * |
|
248 | + * @param $command |
|
249 | + * @param int $cache_minutes |
|
250 | + * @return mixed |
|
251 | + */ |
|
252 | + public function call($command, $cache_minutes=0); |
|
253 | + |
|
254 | + //-------------------------------------------------------------------- |
|
255 | 255 | |
256 | 256 | } |
@@ -249,7 +249,7 @@ |
||
249 | 249 | * @param int $cache_minutes |
250 | 250 | * @return mixed |
251 | 251 | */ |
252 | - public function call($command, $cache_minutes=0); |
|
252 | + public function call($command, $cache_minutes = 0); |
|
253 | 253 | |
254 | 254 | //-------------------------------------------------------------------- |
255 | 255 |
@@ -4,79 +4,79 @@ |
||
4 | 4 | |
5 | 5 | if (! function_exists('esc')) |
6 | 6 | { |
7 | - /** |
|
8 | - * Escapes strings to make them safe for use |
|
9 | - * within HTML templates. Used by the auto-escaping |
|
10 | - * functionality in setVar() and available to |
|
11 | - * use within your views. |
|
12 | - * |
|
13 | - * Uses ZendFramework's Escaper to handle the actual escaping, |
|
14 | - * based on context. Valid contexts are: |
|
15 | - * - html |
|
16 | - * - htmlAttr |
|
17 | - * - js |
|
18 | - * - css |
|
19 | - * - url |
|
20 | - * |
|
21 | - * References: |
|
22 | - * - https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet |
|
23 | - * - http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html |
|
24 | - * |
|
25 | - * @param $data |
|
26 | - * @param $context |
|
27 | - * @param escaper // An instance of ZF's Escaper to avoid repeated class instantiation. |
|
28 | - * |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - function esc($data, $context='html', $escaper=null) |
|
32 | - { |
|
33 | - if (is_array($data)) |
|
34 | - { |
|
35 | - foreach ($data as $key => &$value) |
|
36 | - { |
|
37 | - $value = esc($value, $context); |
|
38 | - } |
|
39 | - } |
|
7 | + /** |
|
8 | + * Escapes strings to make them safe for use |
|
9 | + * within HTML templates. Used by the auto-escaping |
|
10 | + * functionality in setVar() and available to |
|
11 | + * use within your views. |
|
12 | + * |
|
13 | + * Uses ZendFramework's Escaper to handle the actual escaping, |
|
14 | + * based on context. Valid contexts are: |
|
15 | + * - html |
|
16 | + * - htmlAttr |
|
17 | + * - js |
|
18 | + * - css |
|
19 | + * - url |
|
20 | + * |
|
21 | + * References: |
|
22 | + * - https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet |
|
23 | + * - http://framework.zend.com/manual/current/en/modules/zend.escaper.introduction.html |
|
24 | + * |
|
25 | + * @param $data |
|
26 | + * @param $context |
|
27 | + * @param escaper // An instance of ZF's Escaper to avoid repeated class instantiation. |
|
28 | + * |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + function esc($data, $context='html', $escaper=null) |
|
32 | + { |
|
33 | + if (is_array($data)) |
|
34 | + { |
|
35 | + foreach ($data as $key => &$value) |
|
36 | + { |
|
37 | + $value = esc($value, $context); |
|
38 | + } |
|
39 | + } |
|
40 | 40 | |
41 | - $context = strtolower($context); |
|
41 | + $context = strtolower($context); |
|
42 | 42 | |
43 | - if (! is_object($escaper)) |
|
44 | - { |
|
45 | - $escaper = new Escaper(config_item('charset')); |
|
46 | - } |
|
43 | + if (! is_object($escaper)) |
|
44 | + { |
|
45 | + $escaper = new Escaper(config_item('charset')); |
|
46 | + } |
|
47 | 47 | |
48 | - // Valid context? |
|
49 | - if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
50 | - { |
|
51 | - throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
52 | - } |
|
48 | + // Valid context? |
|
49 | + if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
50 | + { |
|
51 | + throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
52 | + } |
|
53 | 53 | |
54 | - if (! is_string($data)) |
|
55 | - { |
|
56 | - return $data; |
|
57 | - } |
|
54 | + if (! is_string($data)) |
|
55 | + { |
|
56 | + return $data; |
|
57 | + } |
|
58 | 58 | |
59 | - switch ($context) |
|
60 | - { |
|
61 | - case 'html': |
|
62 | - $data = $escaper->escapeHtml($data); |
|
63 | - break; |
|
64 | - case 'htmlattr': |
|
65 | - $data = $escaper->escapeHtmlAttr($data); |
|
66 | - break; |
|
67 | - case 'js': |
|
68 | - $data = $escaper->escapeJs($data); |
|
69 | - break; |
|
70 | - case 'css': |
|
71 | - $data = $escaper->escapeCss($data); |
|
72 | - break; |
|
73 | - case 'url': |
|
74 | - $data = $escaper->escapeUrl($data); |
|
75 | - break; |
|
76 | - default: |
|
77 | - break; |
|
78 | - } |
|
59 | + switch ($context) |
|
60 | + { |
|
61 | + case 'html': |
|
62 | + $data = $escaper->escapeHtml($data); |
|
63 | + break; |
|
64 | + case 'htmlattr': |
|
65 | + $data = $escaper->escapeHtmlAttr($data); |
|
66 | + break; |
|
67 | + case 'js': |
|
68 | + $data = $escaper->escapeJs($data); |
|
69 | + break; |
|
70 | + case 'css': |
|
71 | + $data = $escaper->escapeCss($data); |
|
72 | + break; |
|
73 | + case 'url': |
|
74 | + $data = $escaper->escapeUrl($data); |
|
75 | + break; |
|
76 | + default: |
|
77 | + break; |
|
78 | + } |
|
79 | 79 | |
80 | - return $data; |
|
81 | - } |
|
80 | + return $data; |
|
81 | + } |
|
82 | 82 | } |
83 | 83 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | |
3 | 3 | use Zend\Escaper\Escaper; |
4 | 4 | |
5 | -if (! function_exists('esc')) |
|
5 | +if ( ! function_exists('esc')) |
|
6 | 6 | { |
7 | 7 | /** |
8 | 8 | * Escapes strings to make them safe for use |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - function esc($data, $context='html', $escaper=null) |
|
31 | + function esc($data, $context = 'html', $escaper = null) |
|
32 | 32 | { |
33 | 33 | if (is_array($data)) |
34 | 34 | { |
@@ -40,18 +40,18 @@ discard block |
||
40 | 40 | |
41 | 41 | $context = strtolower($context); |
42 | 42 | |
43 | - if (! is_object($escaper)) |
|
43 | + if ( ! is_object($escaper)) |
|
44 | 44 | { |
45 | 45 | $escaper = new Escaper(config_item('charset')); |
46 | 46 | } |
47 | 47 | |
48 | 48 | // Valid context? |
49 | - if (! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
49 | + if ( ! in_array($context, ['html', 'htmlattr', 'js', 'css', 'url'])) |
|
50 | 50 | { |
51 | - throw new \InvalidArgumentException('Invalid Context type: '. $context); |
|
51 | + throw new \InvalidArgumentException('Invalid Context type: '.$context); |
|
52 | 52 | } |
53 | 53 | |
54 | - if (! is_string($data)) |
|
54 | + if ( ! is_string($data)) |
|
55 | 55 | { |
56 | 56 | return $data; |
57 | 57 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | if (! empty($model) ) |
25 | 25 | { |
26 | - $index_method = <<<EOD |
|
26 | + $index_method = <<<EOD |
|
27 | 27 | \$this->load->library('table'); |
28 | 28 | |
29 | 29 | \$offset = \$this->uri->segment( \$this->uri->total_segments() ); |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | |
45 | 45 | if (! empty($model)) |
46 | 46 | { |
47 | - $create_method = <<<EOD |
|
47 | + $create_method = <<<EOD |
|
48 | 48 | \$this->load->helper('form'); |
49 | 49 | \$this->load->helper('inflector'); |
50 | 50 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | if (! empty($model)) |
74 | 74 | { |
75 | - $show_method = <<<EOD |
|
75 | + $show_method = <<<EOD |
|
76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
77 | 77 | |
78 | 78 | if (! \$item) |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | if (! empty($model)) |
96 | 96 | { |
97 | - $update_method = <<<EOD |
|
97 | + $update_method = <<<EOD |
|
98 | 98 | \$this->load->helper('form'); |
99 | 99 | \$this->load->helper('inflector'); |
100 | 100 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | if (! empty($model)) |
127 | 127 | { |
128 | - $delete_method = <<<EOD |
|
128 | + $delete_method = <<<EOD |
|
129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
130 | 130 | { |
131 | 131 | \$this->setMessage('Successfully deleted item.', 'success'); |
@@ -145,12 +145,12 @@ discard block |
||
145 | 145 | |
146 | 146 | if ($themed) |
147 | 147 | { |
148 | - $index_method .= "\$this->render();"; |
|
149 | - $create_method .= "\$this->render();"; |
|
150 | - $show_method .= "\$this->render();"; |
|
151 | - $update_method .= "\$this->render();"; |
|
148 | + $index_method .= "\$this->render();"; |
|
149 | + $create_method .= "\$this->render();"; |
|
150 | + $show_method .= "\$this->render();"; |
|
151 | + $update_method .= "\$this->render();"; |
|
152 | 152 | |
153 | - $fields = " |
|
153 | + $fields = " |
|
154 | 154 | /** |
155 | 155 | * Allows per-controller override of theme. |
156 | 156 | * @var null |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | //-------------------------------------------------------------------- |
6 | 6 | |
7 | 7 | $model_string = $model ? "'{$model}'" : 'null'; |
8 | -$lower_model = trim( strtolower($model_string), "' " ); |
|
8 | +$lower_model = trim(strtolower($model_string), "' "); |
|
9 | 9 | $lower_model_esc = strpos($lower_model, 'null') !== false ? 'null' : "'{$lower_model}'"; |
10 | -$lower_controller = strtolower($controller_name); |
|
10 | +$lower_controller = strtolower($controller_name); |
|
11 | 11 | |
12 | 12 | //-------------------------------------------------------------------- |
13 | 13 | // Build our Methods |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | $index_method = ''; |
23 | 23 | |
24 | -if (! empty($model) ) |
|
24 | +if ( ! empty($model)) |
|
25 | 25 | { |
26 | 26 | $index_method = <<<EOD |
27 | 27 | \$this->load->library('table'); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | */ |
43 | 43 | $create_method = ''; |
44 | 44 | |
45 | -if (! empty($model)) |
|
45 | +if ( ! empty($model)) |
|
46 | 46 | { |
47 | 47 | $create_method = <<<EOD |
48 | 48 | \$this->load->helper('form'); |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | $show_method = ''; |
72 | 72 | |
73 | -if (! empty($model)) |
|
73 | +if ( ! empty($model)) |
|
74 | 74 | { |
75 | 75 | $show_method = <<<EOD |
76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | $update_method = ''; |
94 | 94 | |
95 | -if (! empty($model)) |
|
95 | +if ( ! empty($model)) |
|
96 | 96 | { |
97 | 97 | $update_method = <<<EOD |
98 | 98 | \$this->load->helper('form'); |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | $delete_method = ''; |
125 | 125 | |
126 | -if (! empty($model)) |
|
126 | +if ( ! empty($model)) |
|
127 | 127 | { |
128 | 128 | $delete_method = <<<EOD |
129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | |
33 | 33 | $descriptions = [ |
34 | - 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
34 | + 'controller' => ['controller <name> [<base>]', 'Creates a new controller file that extends from <base> or BaseController.'] |
|
35 | 35 | ]; |
36 | 36 | |
37 | 37 | $long_description = <<<EOT |
@@ -4,43 +4,43 @@ |
||
4 | 4 | |
5 | 5 | <?= $uikit->row([], function() use($uikit, $fields) { |
6 | 6 | |
7 | - $sizes = [ |
|
8 | - 's' => 12, |
|
9 | - 'm' => 6, |
|
10 | - 'l' => 4 |
|
11 | - ]; |
|
12 | - echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
13 | - |
|
14 | - foreach ($fields as $field) |
|
15 | - { |
|
16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | - |
|
18 | - switch ($field['type']) |
|
19 | - { |
|
20 | - case 'text': |
|
21 | - echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
22 | - break; |
|
23 | - case 'number': |
|
24 | - echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
25 | - break; |
|
26 | - case 'date': |
|
27 | - echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
28 | - break; |
|
29 | - case 'datetime': |
|
30 | - echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
31 | - break; |
|
32 | - case 'time': |
|
33 | - echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
34 | - break; |
|
35 | - case 'textarea': |
|
36 | - echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
37 | - break; |
|
38 | - } |
|
39 | - |
|
40 | - } ); |
|
41 | - } |
|
42 | - |
|
43 | - }); |
|
7 | + $sizes = [ |
|
8 | + 's' => 12, |
|
9 | + 'm' => 6, |
|
10 | + 'l' => 4 |
|
11 | + ]; |
|
12 | + echo $uikit->column(['sizes' => $sizes], function() use($uikit, $fields) { |
|
13 | + |
|
14 | + foreach ($fields as $field) |
|
15 | + { |
|
16 | + echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | + |
|
18 | + switch ($field['type']) |
|
19 | + { |
|
20 | + case 'text': |
|
21 | + echo " <input type='text' class='form-control' name='{$field['name']}' />\n"; |
|
22 | + break; |
|
23 | + case 'number': |
|
24 | + echo " <input type='number' class='form-control' name='{$field['name']}' />\n"; |
|
25 | + break; |
|
26 | + case 'date': |
|
27 | + echo " <input type='date' class='form-control' name='{$field['name']}' />\n"; |
|
28 | + break; |
|
29 | + case 'datetime': |
|
30 | + echo " <input type='datetime' class='form-control' name='{$field['name']}' />\n"; |
|
31 | + break; |
|
32 | + case 'time': |
|
33 | + echo " <input type='time' class='form-control' name='{$field['name']}' />\n"; |
|
34 | + break; |
|
35 | + case 'textarea': |
|
36 | + echo " <textarea name='{$field['name']}' class='form-control'></textarea>\n"; |
|
37 | + break; |
|
38 | + } |
|
39 | + |
|
40 | + } ); |
|
41 | + } |
|
42 | + |
|
43 | + }); |
|
44 | 44 | |
45 | 45 | }); ?> |
46 | 46 |
@@ -13,7 +13,7 @@ |
||
13 | 13 | |
14 | 14 | foreach ($fields as $field) |
15 | 15 | { |
16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
16 | + echo $uikit->inputWrap(humanize($field['name']), null, function() use($uikit, $field) { |
|
17 | 17 | |
18 | 18 | switch ($field['type']) |
19 | 19 | { |
@@ -5,45 +5,45 @@ |
||
5 | 5 | <?= $uikit->row([], function() use($uikit, $fields) |
6 | 6 | { |
7 | 7 | |
8 | - $sizes = [ |
|
9 | - 's' => 12, |
|
10 | - 'm' => 6, |
|
11 | - 'l' => 4 |
|
12 | - ]; |
|
13 | - echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
14 | - { |
|
15 | - |
|
16 | - foreach ( $fields as $field ) |
|
17 | - { |
|
18 | - |
|
19 | - echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
20 | - { |
|
21 | - |
|
22 | - switch ( $field['type'] ) |
|
23 | - { |
|
24 | - case 'text': |
|
25 | - echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
26 | - break; |
|
27 | - case 'number': |
|
28 | - echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
29 | - break; |
|
30 | - case 'date': |
|
31 | - echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
32 | - break; |
|
33 | - case 'datetime': |
|
34 | - echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
35 | - break; |
|
36 | - case 'time': |
|
37 | - echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
38 | - break; |
|
39 | - case 'textarea': |
|
40 | - echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
41 | - break; |
|
42 | - } |
|
43 | - |
|
44 | - } ); |
|
45 | - } |
|
46 | - } ); |
|
8 | + $sizes = [ |
|
9 | + 's' => 12, |
|
10 | + 'm' => 6, |
|
11 | + 'l' => 4 |
|
12 | + ]; |
|
13 | + echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
14 | + { |
|
15 | + |
|
16 | + foreach ( $fields as $field ) |
|
17 | + { |
|
18 | + |
|
19 | + echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
20 | + { |
|
21 | + |
|
22 | + switch ( $field['type'] ) |
|
23 | + { |
|
24 | + case 'text': |
|
25 | + echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
26 | + break; |
|
27 | + case 'number': |
|
28 | + echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
29 | + break; |
|
30 | + case 'date': |
|
31 | + echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
32 | + break; |
|
33 | + case 'datetime': |
|
34 | + echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
35 | + break; |
|
36 | + case 'time': |
|
37 | + echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
38 | + break; |
|
39 | + case 'textarea': |
|
40 | + echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
41 | + break; |
|
42 | + } |
|
43 | + |
|
44 | + } ); |
|
45 | + } |
|
46 | + } ); |
|
47 | 47 | } ); |
48 | 48 | ?> |
49 | 49 |
@@ -10,34 +10,34 @@ |
||
10 | 10 | 'm' => 6, |
11 | 11 | 'l' => 4 |
12 | 12 | ]; |
13 | - echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
13 | + echo $uikit->column(['sizes' => $sizes], function() use ($uikit, $fields) |
|
14 | 14 | { |
15 | 15 | |
16 | - foreach ( $fields as $field ) |
|
16 | + foreach ($fields as $field) |
|
17 | 17 | { |
18 | 18 | |
19 | - echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
19 | + echo $uikit->inputWrap(humanize($field['name']), NULL, function() use ($uikit, $field) |
|
20 | 20 | { |
21 | 21 | |
22 | - switch ( $field['type'] ) |
|
22 | + switch ($field['type']) |
|
23 | 23 | { |
24 | 24 | case 'text': |
25 | - echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
25 | + echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
26 | 26 | break; |
27 | 27 | case 'number': |
28 | - echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
28 | + echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
29 | 29 | break; |
30 | 30 | case 'date': |
31 | - echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
31 | + echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
32 | 32 | break; |
33 | 33 | case 'datetime': |
34 | - echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
34 | + echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
35 | 35 | break; |
36 | 36 | case 'time': |
37 | - echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
37 | + echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
38 | 38 | break; |
39 | 39 | case 'textarea': |
40 | - echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
40 | + echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('".$field["name"]."') ?></textarea>\n"; |
|
41 | 41 | break; |
42 | 42 | } |
43 | 43 |