@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class ApcCache implements CacheInterface{ |
28 | 28 | |
@@ -90,13 +90,13 @@ discard block |
||
90 | 90 | $logger->debug('Setting cache data for key ['. $key .'], time to live [' .$ttl. '], expire at [' . date('Y-m-d H:i:s', $expire) . ']'); |
91 | 91 | $result = apc_store($key, $data, $ttl); |
92 | 92 | if($result === false){ |
93 | - $logger->error('Can not write cache data for the key ['. $key .'], return false'); |
|
94 | - return false; |
|
95 | - } |
|
96 | - else{ |
|
97 | - $logger->info('Cache data saved for the key ['. $key .']'); |
|
98 | - return true; |
|
99 | - } |
|
93 | + $logger->error('Can not write cache data for the key ['. $key .'], return false'); |
|
94 | + return false; |
|
95 | + } |
|
96 | + else{ |
|
97 | + $logger->info('Cache data saved for the key ['. $key .']'); |
|
98 | + return true; |
|
99 | + } |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | } |
117 | 117 | else{ |
118 | 118 | $logger->info('Found cache data for the key [' .$key. '] remove it'); |
119 | - return apc_delete($key); |
|
119 | + return apc_delete($key); |
|
120 | 120 | } |
121 | 121 | return false; |
122 | 122 | } |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | - * Return the array of cache information |
|
188 | - * |
|
189 | - * @param string $key the cache key to get the cache information |
|
190 | - * @return array |
|
191 | - */ |
|
187 | + * Return the array of cache information |
|
188 | + * |
|
189 | + * @param string $key the cache key to get the cache information |
|
190 | + * @return array |
|
191 | + */ |
|
192 | 192 | private function _getCacheInfo($key){ |
193 | 193 | $caches = apc_cache_info('user'); |
194 | 194 | if(! empty($caches['cache_list'])){ |
@@ -1,572 +1,572 @@ discard block |
||
1 | 1 | <?php |
2 | - defined('ROOT_PATH') || exit('Access denied'); |
|
3 | - /** |
|
4 | - * TNH Framework |
|
5 | - * |
|
6 | - * A simple PHP framework using HMVC architecture |
|
7 | - * |
|
8 | - * This content is released under the GNU GPL License (GPL) |
|
9 | - * |
|
10 | - * Copyright (C) 2017 Tony NGUEREZA |
|
11 | - * |
|
12 | - * This program is free software; you can redistribute it and/or |
|
13 | - * modify it under the terms of the GNU General Public License |
|
14 | - * as published by the Free Software Foundation; either version 3 |
|
15 | - * of the License, or (at your option) any later version. |
|
16 | - * |
|
17 | - * This program is distributed in the hope that it will be useful, |
|
18 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | - * GNU General Public License for more details. |
|
21 | - * |
|
22 | - * You should have received a copy of the GNU General Public License |
|
23 | - * along with this program; if not, write to the Free Software |
|
24 | - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | - */ |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * A base model with a series of CRUD functions (powered by CI's query builder), |
|
30 | - * validation-in-model support, event callbacks and more. |
|
31 | - * |
|
32 | - * @link http://github.com/jamierumbelow/codeigniter-base-model |
|
33 | - * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net> |
|
34 | - */ |
|
35 | - |
|
36 | - abstract class Model{ |
|
37 | - |
|
38 | - /* -------------------------------------------------------------- |
|
2 | + defined('ROOT_PATH') || exit('Access denied'); |
|
3 | + /** |
|
4 | + * TNH Framework |
|
5 | + * |
|
6 | + * A simple PHP framework using HMVC architecture |
|
7 | + * |
|
8 | + * This content is released under the GNU GPL License (GPL) |
|
9 | + * |
|
10 | + * Copyright (C) 2017 Tony NGUEREZA |
|
11 | + * |
|
12 | + * This program is free software; you can redistribute it and/or |
|
13 | + * modify it under the terms of the GNU General Public License |
|
14 | + * as published by the Free Software Foundation; either version 3 |
|
15 | + * of the License, or (at your option) any later version. |
|
16 | + * |
|
17 | + * This program is distributed in the hope that it will be useful, |
|
18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | + * GNU General Public License for more details. |
|
21 | + * |
|
22 | + * You should have received a copy of the GNU General Public License |
|
23 | + * along with this program; if not, write to the Free Software |
|
24 | + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
25 | + */ |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * A base model with a series of CRUD functions (powered by CI's query builder), |
|
30 | + * validation-in-model support, event callbacks and more. |
|
31 | + * |
|
32 | + * @link http://github.com/jamierumbelow/codeigniter-base-model |
|
33 | + * @copyright Copyright (c) 2012, Jamie Rumbelow <http://jamierumbelow.net> |
|
34 | + */ |
|
35 | + |
|
36 | + abstract class Model{ |
|
37 | + |
|
38 | + /* -------------------------------------------------------------- |
|
39 | 39 | * VARIABLES |
40 | 40 | * ------------------------------------------------------------ */ |
41 | 41 | |
42 | - /** |
|
43 | - * This model's default database table. Automatically |
|
44 | - * guessed by pluralising the model name. |
|
45 | - */ |
|
46 | - protected $_table; |
|
47 | - |
|
48 | - /** |
|
49 | - * The database connection object. Will be set to the default |
|
50 | - * connection. This allows individual models to use different DBs |
|
51 | - * without overwriting CI's global $this->db connection. |
|
52 | - */ |
|
53 | - protected $_database; |
|
54 | - |
|
55 | - /** |
|
56 | - * This model's default primary key or unique identifier. |
|
57 | - * Used by the get(), update() and delete() functions. |
|
58 | - */ |
|
59 | - protected $primary_key = 'id'; |
|
60 | - |
|
61 | - /** |
|
62 | - * Support for soft deletes and this model's 'deleted' key |
|
63 | - */ |
|
64 | - protected $soft_delete = false; |
|
65 | - protected $soft_delete_key = 'is_deleted'; |
|
66 | - protected $_temporary_with_deleted = FALSE; |
|
67 | - protected $_temporary_only_deleted = FALSE; |
|
68 | - |
|
69 | - /** |
|
70 | - * The various callbacks available to the model. Each are |
|
71 | - * simple lists of method names (methods will be run on $this). |
|
72 | - */ |
|
73 | - protected $before_create = array(); |
|
74 | - protected $after_create = array(); |
|
75 | - protected $before_update = array(); |
|
76 | - protected $after_update = array(); |
|
77 | - protected $before_get = array(); |
|
78 | - protected $after_get = array(); |
|
79 | - protected $before_delete = array(); |
|
80 | - protected $after_delete = array(); |
|
81 | - |
|
82 | - protected $callback_parameters = array(); |
|
83 | - |
|
84 | - /** |
|
85 | - * Protected, non-modifiable attributes |
|
86 | - */ |
|
87 | - protected $protected_attributes = array(); |
|
88 | - |
|
89 | - /** |
|
90 | - * Relationship arrays. Use flat strings for defaults or string |
|
91 | - * => array to customise the class name and primary key |
|
92 | - */ |
|
93 | - protected $belongs_to = array(); |
|
94 | - protected $has_many = array(); |
|
95 | - |
|
96 | - protected $_with = array(); |
|
97 | - |
|
98 | - /** |
|
99 | - * An array of validation rules. This needs to be the same format |
|
100 | - * as validation rules passed to the Form_validation library. |
|
101 | - */ |
|
102 | - protected $validate = array(); |
|
103 | - |
|
104 | - /** |
|
105 | - * Optionally skip the validation. Used in conjunction with |
|
106 | - * skip_validation() to skip data validation for any future calls. |
|
107 | - */ |
|
108 | - protected $skip_validation = FALSE; |
|
109 | - |
|
110 | - /** |
|
111 | - * By default we return our results as objects. If we need to override |
|
112 | - * this, we can, or, we could use the `as_array()` and `as_object()` scopes. |
|
113 | - */ |
|
114 | - protected $return_type = 'object'; |
|
115 | - protected $_temporary_return_type = NULL; |
|
42 | + /** |
|
43 | + * This model's default database table. Automatically |
|
44 | + * guessed by pluralising the model name. |
|
45 | + */ |
|
46 | + protected $_table; |
|
47 | + |
|
48 | + /** |
|
49 | + * The database connection object. Will be set to the default |
|
50 | + * connection. This allows individual models to use different DBs |
|
51 | + * without overwriting CI's global $this->db connection. |
|
52 | + */ |
|
53 | + protected $_database; |
|
54 | + |
|
55 | + /** |
|
56 | + * This model's default primary key or unique identifier. |
|
57 | + * Used by the get(), update() and delete() functions. |
|
58 | + */ |
|
59 | + protected $primary_key = 'id'; |
|
60 | + |
|
61 | + /** |
|
62 | + * Support for soft deletes and this model's 'deleted' key |
|
63 | + */ |
|
64 | + protected $soft_delete = false; |
|
65 | + protected $soft_delete_key = 'is_deleted'; |
|
66 | + protected $_temporary_with_deleted = FALSE; |
|
67 | + protected $_temporary_only_deleted = FALSE; |
|
68 | + |
|
69 | + /** |
|
70 | + * The various callbacks available to the model. Each are |
|
71 | + * simple lists of method names (methods will be run on $this). |
|
72 | + */ |
|
73 | + protected $before_create = array(); |
|
74 | + protected $after_create = array(); |
|
75 | + protected $before_update = array(); |
|
76 | + protected $after_update = array(); |
|
77 | + protected $before_get = array(); |
|
78 | + protected $after_get = array(); |
|
79 | + protected $before_delete = array(); |
|
80 | + protected $after_delete = array(); |
|
81 | + |
|
82 | + protected $callback_parameters = array(); |
|
83 | + |
|
84 | + /** |
|
85 | + * Protected, non-modifiable attributes |
|
86 | + */ |
|
87 | + protected $protected_attributes = array(); |
|
88 | + |
|
89 | + /** |
|
90 | + * Relationship arrays. Use flat strings for defaults or string |
|
91 | + * => array to customise the class name and primary key |
|
92 | + */ |
|
93 | + protected $belongs_to = array(); |
|
94 | + protected $has_many = array(); |
|
95 | + |
|
96 | + protected $_with = array(); |
|
97 | + |
|
98 | + /** |
|
99 | + * An array of validation rules. This needs to be the same format |
|
100 | + * as validation rules passed to the Form_validation library. |
|
101 | + */ |
|
102 | + protected $validate = array(); |
|
103 | + |
|
104 | + /** |
|
105 | + * Optionally skip the validation. Used in conjunction with |
|
106 | + * skip_validation() to skip data validation for any future calls. |
|
107 | + */ |
|
108 | + protected $skip_validation = FALSE; |
|
109 | + |
|
110 | + /** |
|
111 | + * By default we return our results as objects. If we need to override |
|
112 | + * this, we can, or, we could use the `as_array()` and `as_object()` scopes. |
|
113 | + */ |
|
114 | + protected $return_type = 'object'; |
|
115 | + protected $_temporary_return_type = NULL; |
|
116 | 116 | |
117 | 117 | |
118 | - /** |
|
118 | + /** |
|
119 | 119 | The database cache time |
120 | - */ |
|
121 | - protected $dbCacheTime = 0; |
|
120 | + */ |
|
121 | + protected $dbCacheTime = 0; |
|
122 | 122 | |
123 | - /* -------------------------------------------------------------- |
|
123 | + /* -------------------------------------------------------------- |
|
124 | 124 | * GENERIC METHODS |
125 | 125 | * ------------------------------------------------------------ */ |
126 | 126 | |
127 | - /** |
|
128 | - * Initialise the model, tie into the CodeIgniter superobject and |
|
129 | - * try our best to guess the table name. |
|
130 | - */ |
|
131 | - public function __construct(){ |
|
132 | - $obj = & get_instance(); |
|
133 | - if(!isset($obj->database)){ |
|
134 | - show_error('You must load the database library before to use the model class'); |
|
135 | - } |
|
136 | - /** |
|
137 | - * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
138 | - * to prevent duplication |
|
139 | - */ |
|
140 | - $this->_database = clone $obj->database; |
|
127 | + /** |
|
128 | + * Initialise the model, tie into the CodeIgniter superobject and |
|
129 | + * try our best to guess the table name. |
|
130 | + */ |
|
131 | + public function __construct(){ |
|
132 | + $obj = & get_instance(); |
|
133 | + if(!isset($obj->database)){ |
|
134 | + show_error('You must load the database library before to use the model class'); |
|
135 | + } |
|
136 | + /** |
|
137 | + * NOTE: Need use "clone" because some Model need have the personal instance of the database library |
|
138 | + * to prevent duplication |
|
139 | + */ |
|
140 | + $this->_database = clone $obj->database; |
|
141 | 141 | |
142 | - array_unshift($this->before_create, 'protect_attributes'); |
|
143 | - array_unshift($this->before_update, 'protect_attributes'); |
|
144 | - $this->_temporary_return_type = $this->return_type; |
|
145 | - if($this->dbCacheTime > 0){ |
|
146 | - $this->_database->setCache($this->dbCacheTime); |
|
147 | - } |
|
148 | - } |
|
149 | - |
|
150 | - /* -------------------------------------------------------------- |
|
142 | + array_unshift($this->before_create, 'protect_attributes'); |
|
143 | + array_unshift($this->before_update, 'protect_attributes'); |
|
144 | + $this->_temporary_return_type = $this->return_type; |
|
145 | + if($this->dbCacheTime > 0){ |
|
146 | + $this->_database->setCache($this->dbCacheTime); |
|
147 | + } |
|
148 | + } |
|
149 | + |
|
150 | + /* -------------------------------------------------------------- |
|
151 | 151 | * CRUD INTERFACE |
152 | 152 | * ------------------------------------------------------------ */ |
153 | 153 | |
154 | - /** |
|
155 | - * Fetch a single record based on the primary key. Returns an object. |
|
156 | - */ |
|
157 | - public function get($primary_value) |
|
158 | - { |
|
159 | - return $this->get_by($this->primary_key, $primary_value); |
|
160 | - } |
|
161 | - |
|
162 | - /** |
|
163 | - * Fetch a single record based on an arbitrary WHERE call. Can be |
|
164 | - * any valid value to $this->_database->where(). |
|
165 | - */ |
|
166 | - public function get_by() |
|
167 | - { |
|
168 | - $where = func_get_args(); |
|
169 | - |
|
170 | - if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
171 | - { |
|
172 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
173 | - } |
|
174 | - |
|
175 | - $this->_set_where($where); |
|
176 | - |
|
177 | - $this->trigger('before_get'); |
|
154 | + /** |
|
155 | + * Fetch a single record based on the primary key. Returns an object. |
|
156 | + */ |
|
157 | + public function get($primary_value) |
|
158 | + { |
|
159 | + return $this->get_by($this->primary_key, $primary_value); |
|
160 | + } |
|
161 | + |
|
162 | + /** |
|
163 | + * Fetch a single record based on an arbitrary WHERE call. Can be |
|
164 | + * any valid value to $this->_database->where(). |
|
165 | + */ |
|
166 | + public function get_by() |
|
167 | + { |
|
168 | + $where = func_get_args(); |
|
169 | + |
|
170 | + if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
171 | + { |
|
172 | + $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
173 | + } |
|
174 | + |
|
175 | + $this->_set_where($where); |
|
176 | + |
|
177 | + $this->trigger('before_get'); |
|
178 | 178 | $type = $this->_temporary_return_type == 'array' ? 'array':false; |
179 | - $row = $this->_database->from($this->_table)->get($type); |
|
180 | - $this->_temporary_return_type = $this->return_type; |
|
181 | - $row = $this->trigger('after_get', $row); |
|
182 | - $this->_with = array(); |
|
183 | - return $row; |
|
184 | - } |
|
185 | - |
|
186 | - /** |
|
187 | - * Fetch an array of records based on an array of primary values. |
|
188 | - */ |
|
189 | - public function get_many($values) |
|
190 | - { |
|
191 | - $this->_database->in($this->primary_key, $values); |
|
192 | - return $this->get_all(); |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Fetch an array of records based on an arbitrary WHERE call. |
|
197 | - */ |
|
198 | - public function get_many_by() |
|
199 | - { |
|
200 | - $where = func_get_args(); |
|
201 | - $this->_set_where($where); |
|
202 | - return $this->get_all(); |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Fetch all the records in the table. Can be used as a generic call |
|
207 | - * to $this->_database->get() with scoped methods. |
|
208 | - */ |
|
209 | - public function get_all() |
|
210 | - { |
|
211 | - $this->trigger('before_get'); |
|
212 | - if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
213 | - { |
|
214 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
215 | - } |
|
179 | + $row = $this->_database->from($this->_table)->get($type); |
|
180 | + $this->_temporary_return_type = $this->return_type; |
|
181 | + $row = $this->trigger('after_get', $row); |
|
182 | + $this->_with = array(); |
|
183 | + return $row; |
|
184 | + } |
|
185 | + |
|
186 | + /** |
|
187 | + * Fetch an array of records based on an array of primary values. |
|
188 | + */ |
|
189 | + public function get_many($values) |
|
190 | + { |
|
191 | + $this->_database->in($this->primary_key, $values); |
|
192 | + return $this->get_all(); |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Fetch an array of records based on an arbitrary WHERE call. |
|
197 | + */ |
|
198 | + public function get_many_by() |
|
199 | + { |
|
200 | + $where = func_get_args(); |
|
201 | + $this->_set_where($where); |
|
202 | + return $this->get_all(); |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Fetch all the records in the table. Can be used as a generic call |
|
207 | + * to $this->_database->get() with scoped methods. |
|
208 | + */ |
|
209 | + public function get_all() |
|
210 | + { |
|
211 | + $this->trigger('before_get'); |
|
212 | + if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
213 | + { |
|
214 | + $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
215 | + } |
|
216 | 216 | $type = $this->_temporary_return_type == 'array' ? 'array':false; |
217 | - $result = $this->_database->from($this->_table)->getAll($type); |
|
218 | - $this->_temporary_return_type = $this->return_type; |
|
219 | - |
|
220 | - foreach ($result as $key => &$row) |
|
221 | - { |
|
222 | - $row = $this->trigger('after_get', $row, ($key == count($result) - 1)); |
|
223 | - } |
|
224 | - $this->_with = array(); |
|
225 | - return $result; |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Insert a new row into the table. $data should be an associative array |
|
230 | - * of data to be inserted. Returns newly created ID. |
|
231 | - */ |
|
232 | - public function insert($data = array(), $skip_validation = FALSE, $escape = true) |
|
233 | - { |
|
234 | - if ($skip_validation === FALSE) |
|
235 | - { |
|
236 | - $data = $this->validate($data); |
|
237 | - } |
|
238 | - |
|
239 | - if ($data !== FALSE) |
|
240 | - { |
|
241 | - $data = $this->trigger('before_create', $data); |
|
242 | - $this->_database->from($this->_table)->insert($data, $escape); |
|
243 | - $insert_id = $this->_database->insertId(); |
|
244 | - $this->trigger('after_create', $insert_id); |
|
245 | - return $insert_id; |
|
246 | - } |
|
247 | - else |
|
248 | - { |
|
249 | - return FALSE; |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * Insert multiple rows into the table. Returns an array of multiple IDs. |
|
255 | - */ |
|
256 | - public function insert_many($data = array(), $skip_validation = FALSE, $escape = true) |
|
257 | - { |
|
258 | - $ids = array(); |
|
259 | - foreach ($data as $key => $row) |
|
260 | - { |
|
261 | - $ids[] = $this->insert($row, $skip_validation, $escape); |
|
262 | - } |
|
263 | - return $ids; |
|
264 | - } |
|
265 | - |
|
266 | - /** |
|
267 | - * Updated a record based on the primary value. |
|
268 | - */ |
|
269 | - public function update($primary_value, $data = array(), $skip_validation = FALSE, $escape = true) |
|
270 | - { |
|
271 | - $data = $this->trigger('before_update', $data); |
|
272 | - if ($skip_validation === FALSE) |
|
273 | - { |
|
274 | - $data = $this->validate($data); |
|
275 | - } |
|
276 | - |
|
277 | - if ($data !== FALSE) |
|
278 | - { |
|
279 | - $result = $this->_database->where($this->primary_key, $primary_value) |
|
280 | - ->from($this->_table) |
|
281 | - ->update($data, $escape); |
|
282 | - $this->trigger('after_update', array($data, $result)); |
|
283 | - return $result; |
|
284 | - } |
|
285 | - else |
|
286 | - { |
|
287 | - return FALSE; |
|
288 | - } |
|
289 | - } |
|
290 | - |
|
291 | - /** |
|
292 | - * Update many records, based on an array of primary values. |
|
293 | - */ |
|
294 | - public function update_many($primary_values, $data = array(), $skip_validation = FALSE, $escape = true) |
|
295 | - { |
|
296 | - $data = $this->trigger('before_update', $data); |
|
297 | - if ($skip_validation === FALSE) |
|
298 | - { |
|
299 | - $data = $this->validate($data); |
|
300 | - } |
|
301 | - if ($data !== FALSE) |
|
302 | - { |
|
303 | - $result = $this->_database->in($this->primary_key, $primary_values) |
|
304 | - ->from($this->_table) |
|
305 | - ->update($data, $escape); |
|
306 | - $this->trigger('after_update', array($data, $result)); |
|
307 | - return $result; |
|
308 | - } |
|
309 | - else |
|
310 | - { |
|
311 | - return FALSE; |
|
312 | - } |
|
313 | - } |
|
314 | - |
|
315 | - /** |
|
316 | - * Updated a record based on an arbitrary WHERE clause. |
|
317 | - */ |
|
318 | - public function update_by() |
|
319 | - { |
|
320 | - $args = func_get_args(); |
|
321 | - $data = array(); |
|
322 | - if(count($args) == 2){ |
|
323 | - if(is_array($args[1])){ |
|
324 | - $data = array_pop($args); |
|
325 | - } |
|
326 | - } |
|
327 | - else if(count($args) == 3){ |
|
328 | - if(is_array($args[2])){ |
|
329 | - $data = array_pop($args); |
|
330 | - } |
|
331 | - } |
|
332 | - $data = $this->trigger('before_update', $data); |
|
333 | - if ($this->validate($data) !== FALSE) |
|
334 | - { |
|
335 | - $this->_set_where($args); |
|
336 | - $result = $this->_database->from($this->_table)->update($data); |
|
337 | - $this->trigger('after_update', array($data, $result)); |
|
338 | - return $result; |
|
339 | - } |
|
340 | - else |
|
341 | - { |
|
342 | - return FALSE; |
|
343 | - } |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Update all records |
|
348 | - */ |
|
349 | - public function update_all($data = array(), $escape = true) |
|
350 | - { |
|
351 | - $data = $this->trigger('before_update', $data); |
|
352 | - $result = $this->_database->from($this->_table)->update($data, $escape); |
|
353 | - $this->trigger('after_update', array($data, $result)); |
|
354 | - return $result; |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Delete a row from the table by the primary value |
|
359 | - */ |
|
360 | - public function delete($id) |
|
361 | - { |
|
362 | - $this->trigger('before_delete', $id); |
|
363 | - $this->_database->where($this->primary_key, $id); |
|
364 | - if ($this->soft_delete) |
|
365 | - { |
|
366 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
367 | - } |
|
368 | - else |
|
369 | - { |
|
370 | - $result = $this->_database->from($this->_table)->delete(); |
|
371 | - } |
|
372 | - |
|
373 | - $this->trigger('after_delete', $result); |
|
374 | - return $result; |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Delete a row from the database table by an arbitrary WHERE clause |
|
379 | - */ |
|
380 | - public function delete_by() |
|
381 | - { |
|
382 | - $where = func_get_args(); |
|
383 | - $where = $this->trigger('before_delete', $where); |
|
384 | - $this->_set_where($where); |
|
385 | - if ($this->soft_delete) |
|
386 | - { |
|
387 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
388 | - } |
|
389 | - else |
|
390 | - { |
|
391 | - $result = $this->_database->from($this->_table)->delete(); |
|
392 | - } |
|
393 | - $this->trigger('after_delete', $result); |
|
394 | - return $result; |
|
395 | - } |
|
396 | - |
|
397 | - /** |
|
398 | - * Delete many rows from the database table by multiple primary values |
|
399 | - */ |
|
400 | - public function delete_many($primary_values) |
|
401 | - { |
|
402 | - $primary_values = $this->trigger('before_delete', $primary_values); |
|
403 | - $this->_database->in($this->primary_key, $primary_values); |
|
404 | - if ($this->soft_delete) |
|
405 | - { |
|
406 | - $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
407 | - } |
|
408 | - else |
|
409 | - { |
|
410 | - $result = $this->_database->from($this->_table)->delete(); |
|
411 | - } |
|
412 | - $this->trigger('after_delete', $result); |
|
413 | - return $result; |
|
414 | - } |
|
415 | - |
|
416 | - |
|
417 | - /** |
|
418 | - * Truncates the table |
|
419 | - */ |
|
420 | - public function truncate() |
|
421 | - { |
|
422 | - $result = $this->_database->from($this->_table)->delete(); |
|
423 | - return $result; |
|
424 | - } |
|
425 | - |
|
426 | - /* -------------------------------------------------------------- |
|
217 | + $result = $this->_database->from($this->_table)->getAll($type); |
|
218 | + $this->_temporary_return_type = $this->return_type; |
|
219 | + |
|
220 | + foreach ($result as $key => &$row) |
|
221 | + { |
|
222 | + $row = $this->trigger('after_get', $row, ($key == count($result) - 1)); |
|
223 | + } |
|
224 | + $this->_with = array(); |
|
225 | + return $result; |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Insert a new row into the table. $data should be an associative array |
|
230 | + * of data to be inserted. Returns newly created ID. |
|
231 | + */ |
|
232 | + public function insert($data = array(), $skip_validation = FALSE, $escape = true) |
|
233 | + { |
|
234 | + if ($skip_validation === FALSE) |
|
235 | + { |
|
236 | + $data = $this->validate($data); |
|
237 | + } |
|
238 | + |
|
239 | + if ($data !== FALSE) |
|
240 | + { |
|
241 | + $data = $this->trigger('before_create', $data); |
|
242 | + $this->_database->from($this->_table)->insert($data, $escape); |
|
243 | + $insert_id = $this->_database->insertId(); |
|
244 | + $this->trigger('after_create', $insert_id); |
|
245 | + return $insert_id; |
|
246 | + } |
|
247 | + else |
|
248 | + { |
|
249 | + return FALSE; |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * Insert multiple rows into the table. Returns an array of multiple IDs. |
|
255 | + */ |
|
256 | + public function insert_many($data = array(), $skip_validation = FALSE, $escape = true) |
|
257 | + { |
|
258 | + $ids = array(); |
|
259 | + foreach ($data as $key => $row) |
|
260 | + { |
|
261 | + $ids[] = $this->insert($row, $skip_validation, $escape); |
|
262 | + } |
|
263 | + return $ids; |
|
264 | + } |
|
265 | + |
|
266 | + /** |
|
267 | + * Updated a record based on the primary value. |
|
268 | + */ |
|
269 | + public function update($primary_value, $data = array(), $skip_validation = FALSE, $escape = true) |
|
270 | + { |
|
271 | + $data = $this->trigger('before_update', $data); |
|
272 | + if ($skip_validation === FALSE) |
|
273 | + { |
|
274 | + $data = $this->validate($data); |
|
275 | + } |
|
276 | + |
|
277 | + if ($data !== FALSE) |
|
278 | + { |
|
279 | + $result = $this->_database->where($this->primary_key, $primary_value) |
|
280 | + ->from($this->_table) |
|
281 | + ->update($data, $escape); |
|
282 | + $this->trigger('after_update', array($data, $result)); |
|
283 | + return $result; |
|
284 | + } |
|
285 | + else |
|
286 | + { |
|
287 | + return FALSE; |
|
288 | + } |
|
289 | + } |
|
290 | + |
|
291 | + /** |
|
292 | + * Update many records, based on an array of primary values. |
|
293 | + */ |
|
294 | + public function update_many($primary_values, $data = array(), $skip_validation = FALSE, $escape = true) |
|
295 | + { |
|
296 | + $data = $this->trigger('before_update', $data); |
|
297 | + if ($skip_validation === FALSE) |
|
298 | + { |
|
299 | + $data = $this->validate($data); |
|
300 | + } |
|
301 | + if ($data !== FALSE) |
|
302 | + { |
|
303 | + $result = $this->_database->in($this->primary_key, $primary_values) |
|
304 | + ->from($this->_table) |
|
305 | + ->update($data, $escape); |
|
306 | + $this->trigger('after_update', array($data, $result)); |
|
307 | + return $result; |
|
308 | + } |
|
309 | + else |
|
310 | + { |
|
311 | + return FALSE; |
|
312 | + } |
|
313 | + } |
|
314 | + |
|
315 | + /** |
|
316 | + * Updated a record based on an arbitrary WHERE clause. |
|
317 | + */ |
|
318 | + public function update_by() |
|
319 | + { |
|
320 | + $args = func_get_args(); |
|
321 | + $data = array(); |
|
322 | + if(count($args) == 2){ |
|
323 | + if(is_array($args[1])){ |
|
324 | + $data = array_pop($args); |
|
325 | + } |
|
326 | + } |
|
327 | + else if(count($args) == 3){ |
|
328 | + if(is_array($args[2])){ |
|
329 | + $data = array_pop($args); |
|
330 | + } |
|
331 | + } |
|
332 | + $data = $this->trigger('before_update', $data); |
|
333 | + if ($this->validate($data) !== FALSE) |
|
334 | + { |
|
335 | + $this->_set_where($args); |
|
336 | + $result = $this->_database->from($this->_table)->update($data); |
|
337 | + $this->trigger('after_update', array($data, $result)); |
|
338 | + return $result; |
|
339 | + } |
|
340 | + else |
|
341 | + { |
|
342 | + return FALSE; |
|
343 | + } |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Update all records |
|
348 | + */ |
|
349 | + public function update_all($data = array(), $escape = true) |
|
350 | + { |
|
351 | + $data = $this->trigger('before_update', $data); |
|
352 | + $result = $this->_database->from($this->_table)->update($data, $escape); |
|
353 | + $this->trigger('after_update', array($data, $result)); |
|
354 | + return $result; |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Delete a row from the table by the primary value |
|
359 | + */ |
|
360 | + public function delete($id) |
|
361 | + { |
|
362 | + $this->trigger('before_delete', $id); |
|
363 | + $this->_database->where($this->primary_key, $id); |
|
364 | + if ($this->soft_delete) |
|
365 | + { |
|
366 | + $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
367 | + } |
|
368 | + else |
|
369 | + { |
|
370 | + $result = $this->_database->from($this->_table)->delete(); |
|
371 | + } |
|
372 | + |
|
373 | + $this->trigger('after_delete', $result); |
|
374 | + return $result; |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Delete a row from the database table by an arbitrary WHERE clause |
|
379 | + */ |
|
380 | + public function delete_by() |
|
381 | + { |
|
382 | + $where = func_get_args(); |
|
383 | + $where = $this->trigger('before_delete', $where); |
|
384 | + $this->_set_where($where); |
|
385 | + if ($this->soft_delete) |
|
386 | + { |
|
387 | + $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
388 | + } |
|
389 | + else |
|
390 | + { |
|
391 | + $result = $this->_database->from($this->_table)->delete(); |
|
392 | + } |
|
393 | + $this->trigger('after_delete', $result); |
|
394 | + return $result; |
|
395 | + } |
|
396 | + |
|
397 | + /** |
|
398 | + * Delete many rows from the database table by multiple primary values |
|
399 | + */ |
|
400 | + public function delete_many($primary_values) |
|
401 | + { |
|
402 | + $primary_values = $this->trigger('before_delete', $primary_values); |
|
403 | + $this->_database->in($this->primary_key, $primary_values); |
|
404 | + if ($this->soft_delete) |
|
405 | + { |
|
406 | + $result = $this->_database->from($this->_table)->update(array( $this->soft_delete_key => TRUE )); |
|
407 | + } |
|
408 | + else |
|
409 | + { |
|
410 | + $result = $this->_database->from($this->_table)->delete(); |
|
411 | + } |
|
412 | + $this->trigger('after_delete', $result); |
|
413 | + return $result; |
|
414 | + } |
|
415 | + |
|
416 | + |
|
417 | + /** |
|
418 | + * Truncates the table |
|
419 | + */ |
|
420 | + public function truncate() |
|
421 | + { |
|
422 | + $result = $this->_database->from($this->_table)->delete(); |
|
423 | + return $result; |
|
424 | + } |
|
425 | + |
|
426 | + /* -------------------------------------------------------------- |
|
427 | 427 | * RELATIONSHIPS |
428 | 428 | * ------------------------------------------------------------ */ |
429 | 429 | |
430 | - public function with($relationship) |
|
431 | - { |
|
432 | - $this->_with[] = $relationship; |
|
433 | - if (!in_array('relate', $this->after_get)) |
|
434 | - { |
|
435 | - $this->after_get[] = 'relate'; |
|
436 | - } |
|
437 | - return $this; |
|
438 | - } |
|
439 | - |
|
440 | - public function relate($row) |
|
441 | - { |
|
442 | - if (empty($row)) |
|
443 | - { |
|
444 | - return $row; |
|
445 | - } |
|
446 | - |
|
447 | - foreach ($this->belongs_to as $key => $value) |
|
448 | - { |
|
449 | - if (is_string($value)) |
|
450 | - { |
|
451 | - $relationship = $value; |
|
452 | - $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
|
453 | - } |
|
454 | - else |
|
455 | - { |
|
456 | - $relationship = $key; |
|
457 | - $options = $value; |
|
458 | - } |
|
459 | - |
|
460 | - if (in_array($relationship, $this->_with)) |
|
461 | - { |
|
462 | - Loader::model($options['model'], $relationship . '_model'); |
|
463 | - if (is_object($row)) |
|
464 | - { |
|
465 | - $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
|
466 | - } |
|
467 | - else |
|
468 | - { |
|
469 | - $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
|
470 | - } |
|
471 | - } |
|
472 | - } |
|
473 | - |
|
474 | - foreach ($this->has_many as $key => $value) |
|
475 | - { |
|
476 | - if (is_string($value)) |
|
477 | - { |
|
478 | - $relationship = $value; |
|
479 | - $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
|
480 | - } |
|
481 | - else |
|
482 | - { |
|
483 | - $relationship = $key; |
|
484 | - $options = $value; |
|
485 | - } |
|
486 | - |
|
487 | - if (in_array($relationship, $this->_with)) |
|
488 | - { |
|
489 | - Loader::model($options['model'], $relationship . '_model'); |
|
490 | - if (is_object($row)) |
|
491 | - { |
|
492 | - $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
|
493 | - } |
|
494 | - else |
|
495 | - { |
|
496 | - $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
|
497 | - } |
|
498 | - } |
|
499 | - } |
|
500 | - return $row; |
|
501 | - } |
|
502 | - |
|
503 | - /* -------------------------------------------------------------- |
|
430 | + public function with($relationship) |
|
431 | + { |
|
432 | + $this->_with[] = $relationship; |
|
433 | + if (!in_array('relate', $this->after_get)) |
|
434 | + { |
|
435 | + $this->after_get[] = 'relate'; |
|
436 | + } |
|
437 | + return $this; |
|
438 | + } |
|
439 | + |
|
440 | + public function relate($row) |
|
441 | + { |
|
442 | + if (empty($row)) |
|
443 | + { |
|
444 | + return $row; |
|
445 | + } |
|
446 | + |
|
447 | + foreach ($this->belongs_to as $key => $value) |
|
448 | + { |
|
449 | + if (is_string($value)) |
|
450 | + { |
|
451 | + $relationship = $value; |
|
452 | + $options = array( 'primary_key' => $value . '_id', 'model' => $value . '_model' ); |
|
453 | + } |
|
454 | + else |
|
455 | + { |
|
456 | + $relationship = $key; |
|
457 | + $options = $value; |
|
458 | + } |
|
459 | + |
|
460 | + if (in_array($relationship, $this->_with)) |
|
461 | + { |
|
462 | + Loader::model($options['model'], $relationship . '_model'); |
|
463 | + if (is_object($row)) |
|
464 | + { |
|
465 | + $row->{$relationship} = $this->{$relationship . '_model'}->get($row->{$options['primary_key']}); |
|
466 | + } |
|
467 | + else |
|
468 | + { |
|
469 | + $row[$relationship] = $this->{$relationship . '_model'}->get($row[$options['primary_key']]); |
|
470 | + } |
|
471 | + } |
|
472 | + } |
|
473 | + |
|
474 | + foreach ($this->has_many as $key => $value) |
|
475 | + { |
|
476 | + if (is_string($value)) |
|
477 | + { |
|
478 | + $relationship = $value; |
|
479 | + $options = array( 'primary_key' => $this->_table . '_id', 'model' => $value . '_model' ); |
|
480 | + } |
|
481 | + else |
|
482 | + { |
|
483 | + $relationship = $key; |
|
484 | + $options = $value; |
|
485 | + } |
|
486 | + |
|
487 | + if (in_array($relationship, $this->_with)) |
|
488 | + { |
|
489 | + Loader::model($options['model'], $relationship . '_model'); |
|
490 | + if (is_object($row)) |
|
491 | + { |
|
492 | + $row->{$relationship} = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row->{$this->primary_key}); |
|
493 | + } |
|
494 | + else |
|
495 | + { |
|
496 | + $row[$relationship] = $this->{$relationship . '_model'}->get_many_by($options['primary_key'], $row[$this->primary_key]); |
|
497 | + } |
|
498 | + } |
|
499 | + } |
|
500 | + return $row; |
|
501 | + } |
|
502 | + |
|
503 | + /* -------------------------------------------------------------- |
|
504 | 504 | * UTILITY METHODS |
505 | 505 | * ------------------------------------------------------------ */ |
506 | 506 | |
507 | - /** |
|
508 | - * Retrieve and generate a form_dropdown friendly array |
|
509 | - */ |
|
510 | - public function dropdown() |
|
511 | - { |
|
512 | - $args = func_get_args(); |
|
513 | - if(count($args) == 2) |
|
514 | - { |
|
515 | - list($key, $value) = $args; |
|
516 | - } |
|
517 | - else |
|
518 | - { |
|
519 | - $key = $this->primary_key; |
|
520 | - $value = $args[0]; |
|
521 | - } |
|
522 | - $this->trigger('before_dropdown', array( $key, $value )); |
|
523 | - if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
524 | - { |
|
525 | - $this->_database->where($this->soft_delete_key, FALSE); |
|
526 | - } |
|
527 | - $result = $this->_database->select(array($key, $value)) |
|
528 | - ->from($this->_table) |
|
529 | - ->getAll(); |
|
530 | - $options = array(); |
|
531 | - foreach ($result as $row) |
|
532 | - { |
|
533 | - $options[$row->{$key}] = $row->{$value}; |
|
534 | - } |
|
535 | - $options = $this->trigger('after_dropdown', $options); |
|
536 | - return $options; |
|
537 | - } |
|
538 | - |
|
539 | - /** |
|
540 | - * Fetch a count of rows based on an arbitrary WHERE call. |
|
541 | - */ |
|
542 | - public function count_by() |
|
543 | - { |
|
544 | - if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
545 | - { |
|
546 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
547 | - } |
|
548 | - $where = func_get_args(); |
|
549 | - $this->_set_where($where); |
|
550 | - $this->_database->from($this->_table)->getAll(); |
|
551 | - return $this->_database->numRows(); |
|
552 | - } |
|
553 | - |
|
554 | - /** |
|
555 | - * Fetch a total count of rows, disregarding any previous conditions |
|
556 | - */ |
|
557 | - public function count_all() |
|
558 | - { |
|
559 | - if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
560 | - { |
|
561 | - $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
562 | - } |
|
563 | - $this->_database->from($this->_table)->getAll(); |
|
564 | - return $this->_database->numRows(); |
|
565 | - } |
|
507 | + /** |
|
508 | + * Retrieve and generate a form_dropdown friendly array |
|
509 | + */ |
|
510 | + public function dropdown() |
|
511 | + { |
|
512 | + $args = func_get_args(); |
|
513 | + if(count($args) == 2) |
|
514 | + { |
|
515 | + list($key, $value) = $args; |
|
516 | + } |
|
517 | + else |
|
518 | + { |
|
519 | + $key = $this->primary_key; |
|
520 | + $value = $args[0]; |
|
521 | + } |
|
522 | + $this->trigger('before_dropdown', array( $key, $value )); |
|
523 | + if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
524 | + { |
|
525 | + $this->_database->where($this->soft_delete_key, FALSE); |
|
526 | + } |
|
527 | + $result = $this->_database->select(array($key, $value)) |
|
528 | + ->from($this->_table) |
|
529 | + ->getAll(); |
|
530 | + $options = array(); |
|
531 | + foreach ($result as $row) |
|
532 | + { |
|
533 | + $options[$row->{$key}] = $row->{$value}; |
|
534 | + } |
|
535 | + $options = $this->trigger('after_dropdown', $options); |
|
536 | + return $options; |
|
537 | + } |
|
538 | + |
|
539 | + /** |
|
540 | + * Fetch a count of rows based on an arbitrary WHERE call. |
|
541 | + */ |
|
542 | + public function count_by() |
|
543 | + { |
|
544 | + if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
545 | + { |
|
546 | + $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
547 | + } |
|
548 | + $where = func_get_args(); |
|
549 | + $this->_set_where($where); |
|
550 | + $this->_database->from($this->_table)->getAll(); |
|
551 | + return $this->_database->numRows(); |
|
552 | + } |
|
553 | + |
|
554 | + /** |
|
555 | + * Fetch a total count of rows, disregarding any previous conditions |
|
556 | + */ |
|
557 | + public function count_all() |
|
558 | + { |
|
559 | + if ($this->soft_delete && $this->_temporary_with_deleted !== TRUE) |
|
560 | + { |
|
561 | + $this->_database->where($this->soft_delete_key, (bool)$this->_temporary_only_deleted); |
|
562 | + } |
|
563 | + $this->_database->from($this->_table)->getAll(); |
|
564 | + return $this->_database->numRows(); |
|
565 | + } |
|
566 | 566 | |
567 | 567 | /** |
568 | - * Enabled cache temporary |
|
569 | - */ |
|
568 | + * Enabled cache temporary |
|
569 | + */ |
|
570 | 570 | public function cached($ttl = 0){ |
571 | 571 | if($ttl > 0){ |
572 | 572 | $this->_database = $this->_database->cached($ttl); |
@@ -574,339 +574,339 @@ discard block |
||
574 | 574 | return $this; |
575 | 575 | } |
576 | 576 | |
577 | - /** |
|
578 | - * Tell the class to skip the insert validation |
|
579 | - */ |
|
580 | - public function skip_validation() |
|
581 | - { |
|
582 | - $this->skip_validation = TRUE; |
|
583 | - return $this; |
|
584 | - } |
|
585 | - |
|
586 | - /** |
|
587 | - * Get the skip validation status |
|
588 | - */ |
|
589 | - public function get_skip_validation() |
|
590 | - { |
|
591 | - return $this->skip_validation; |
|
592 | - } |
|
593 | - |
|
594 | - /** |
|
595 | - * Return the next auto increment of the table. Only tested on MySQL. |
|
596 | - */ |
|
597 | - public function get_next_id() |
|
598 | - { |
|
599 | - return (int) $this->_database->select('AUTO_INCREMENT') |
|
600 | - ->from('information_schema.TABLES') |
|
601 | - ->where('TABLE_NAME', $this->_table) |
|
602 | - ->where('TABLE_SCHEMA', $this->_database->getDatabaseName())->get()->AUTO_INCREMENT; |
|
603 | - } |
|
604 | - |
|
605 | - /** |
|
606 | - * Getter for the table name |
|
607 | - */ |
|
608 | - public function table() |
|
609 | - { |
|
610 | - return $this->_table; |
|
611 | - } |
|
612 | - |
|
613 | - /* -------------------------------------------------------------- |
|
577 | + /** |
|
578 | + * Tell the class to skip the insert validation |
|
579 | + */ |
|
580 | + public function skip_validation() |
|
581 | + { |
|
582 | + $this->skip_validation = TRUE; |
|
583 | + return $this; |
|
584 | + } |
|
585 | + |
|
586 | + /** |
|
587 | + * Get the skip validation status |
|
588 | + */ |
|
589 | + public function get_skip_validation() |
|
590 | + { |
|
591 | + return $this->skip_validation; |
|
592 | + } |
|
593 | + |
|
594 | + /** |
|
595 | + * Return the next auto increment of the table. Only tested on MySQL. |
|
596 | + */ |
|
597 | + public function get_next_id() |
|
598 | + { |
|
599 | + return (int) $this->_database->select('AUTO_INCREMENT') |
|
600 | + ->from('information_schema.TABLES') |
|
601 | + ->where('TABLE_NAME', $this->_table) |
|
602 | + ->where('TABLE_SCHEMA', $this->_database->getDatabaseName())->get()->AUTO_INCREMENT; |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Getter for the table name |
|
607 | + */ |
|
608 | + public function table() |
|
609 | + { |
|
610 | + return $this->_table; |
|
611 | + } |
|
612 | + |
|
613 | + /* -------------------------------------------------------------- |
|
614 | 614 | * GLOBAL SCOPES |
615 | 615 | * ------------------------------------------------------------ */ |
616 | 616 | |
617 | - /** |
|
618 | - * Return the next call as an array rather than an object |
|
619 | - */ |
|
620 | - public function as_array() |
|
621 | - { |
|
622 | - $this->_temporary_return_type = 'array'; |
|
623 | - return $this; |
|
624 | - } |
|
625 | - |
|
626 | - /** |
|
627 | - * Return the next call as an object rather than an array |
|
628 | - */ |
|
629 | - public function as_object() |
|
630 | - { |
|
631 | - $this->_temporary_return_type = 'object'; |
|
632 | - return $this; |
|
633 | - } |
|
634 | - |
|
635 | - /** |
|
636 | - * Don't care about soft deleted rows on the next call |
|
637 | - */ |
|
638 | - public function with_deleted() |
|
639 | - { |
|
640 | - $this->_temporary_with_deleted = TRUE; |
|
641 | - return $this; |
|
642 | - } |
|
643 | - |
|
644 | - /** |
|
645 | - * Only get deleted rows on the next call |
|
646 | - */ |
|
647 | - public function only_deleted() |
|
648 | - { |
|
649 | - $this->_temporary_only_deleted = TRUE; |
|
650 | - return $this; |
|
651 | - } |
|
652 | - |
|
653 | - /* -------------------------------------------------------------- |
|
617 | + /** |
|
618 | + * Return the next call as an array rather than an object |
|
619 | + */ |
|
620 | + public function as_array() |
|
621 | + { |
|
622 | + $this->_temporary_return_type = 'array'; |
|
623 | + return $this; |
|
624 | + } |
|
625 | + |
|
626 | + /** |
|
627 | + * Return the next call as an object rather than an array |
|
628 | + */ |
|
629 | + public function as_object() |
|
630 | + { |
|
631 | + $this->_temporary_return_type = 'object'; |
|
632 | + return $this; |
|
633 | + } |
|
634 | + |
|
635 | + /** |
|
636 | + * Don't care about soft deleted rows on the next call |
|
637 | + */ |
|
638 | + public function with_deleted() |
|
639 | + { |
|
640 | + $this->_temporary_with_deleted = TRUE; |
|
641 | + return $this; |
|
642 | + } |
|
643 | + |
|
644 | + /** |
|
645 | + * Only get deleted rows on the next call |
|
646 | + */ |
|
647 | + public function only_deleted() |
|
648 | + { |
|
649 | + $this->_temporary_only_deleted = TRUE; |
|
650 | + return $this; |
|
651 | + } |
|
652 | + |
|
653 | + /* -------------------------------------------------------------- |
|
654 | 654 | * OBSERVERS |
655 | 655 | * ------------------------------------------------------------ */ |
656 | 656 | |
657 | - /** |
|
658 | - * MySQL DATETIME created_at and updated_at |
|
659 | - */ |
|
660 | - public function created_at($row) |
|
661 | - { |
|
662 | - if (is_object($row)) |
|
663 | - { |
|
664 | - $row->created_at = date('Y-m-d H:i:s'); |
|
665 | - } |
|
666 | - else |
|
667 | - { |
|
668 | - $row['created_at'] = date('Y-m-d H:i:s'); |
|
669 | - } |
|
670 | - |
|
671 | - return $row; |
|
672 | - } |
|
673 | - |
|
674 | - public function updated_at($row) |
|
675 | - { |
|
676 | - if (is_object($row)) |
|
677 | - { |
|
678 | - $row->updated_at = date('Y-m-d H:i:s'); |
|
679 | - } |
|
680 | - else |
|
681 | - { |
|
682 | - $row['updated_at'] = date('Y-m-d H:i:s'); |
|
683 | - } |
|
684 | - return $row; |
|
685 | - } |
|
686 | - |
|
687 | - /** |
|
688 | - * Serialises data for you automatically, allowing you to pass |
|
689 | - * through objects and let it handle the serialisation in the background |
|
690 | - */ |
|
691 | - public function serialize($row) |
|
692 | - { |
|
693 | - foreach ($this->callback_parameters as $column) |
|
694 | - { |
|
695 | - $row[$column] = serialize($row[$column]); |
|
696 | - } |
|
697 | - return $row; |
|
698 | - } |
|
699 | - |
|
700 | - public function unserialize($row) |
|
701 | - { |
|
702 | - foreach ($this->callback_parameters as $column) |
|
703 | - { |
|
704 | - if (is_array($row)) |
|
705 | - { |
|
706 | - $row[$column] = unserialize($row[$column]); |
|
707 | - } |
|
708 | - else |
|
709 | - { |
|
710 | - $row->$column = unserialize($row->$column); |
|
711 | - } |
|
712 | - } |
|
713 | - return $row; |
|
714 | - } |
|
715 | - |
|
716 | - /** |
|
717 | - * Protect attributes by removing them from $row array |
|
718 | - */ |
|
719 | - public function protect_attributes($row) |
|
720 | - { |
|
721 | - foreach ($this->protected_attributes as $attr) |
|
722 | - { |
|
723 | - if (is_object($row)) |
|
724 | - { |
|
657 | + /** |
|
658 | + * MySQL DATETIME created_at and updated_at |
|
659 | + */ |
|
660 | + public function created_at($row) |
|
661 | + { |
|
662 | + if (is_object($row)) |
|
663 | + { |
|
664 | + $row->created_at = date('Y-m-d H:i:s'); |
|
665 | + } |
|
666 | + else |
|
667 | + { |
|
668 | + $row['created_at'] = date('Y-m-d H:i:s'); |
|
669 | + } |
|
670 | + |
|
671 | + return $row; |
|
672 | + } |
|
673 | + |
|
674 | + public function updated_at($row) |
|
675 | + { |
|
676 | + if (is_object($row)) |
|
677 | + { |
|
678 | + $row->updated_at = date('Y-m-d H:i:s'); |
|
679 | + } |
|
680 | + else |
|
681 | + { |
|
682 | + $row['updated_at'] = date('Y-m-d H:i:s'); |
|
683 | + } |
|
684 | + return $row; |
|
685 | + } |
|
686 | + |
|
687 | + /** |
|
688 | + * Serialises data for you automatically, allowing you to pass |
|
689 | + * through objects and let it handle the serialisation in the background |
|
690 | + */ |
|
691 | + public function serialize($row) |
|
692 | + { |
|
693 | + foreach ($this->callback_parameters as $column) |
|
694 | + { |
|
695 | + $row[$column] = serialize($row[$column]); |
|
696 | + } |
|
697 | + return $row; |
|
698 | + } |
|
699 | + |
|
700 | + public function unserialize($row) |
|
701 | + { |
|
702 | + foreach ($this->callback_parameters as $column) |
|
703 | + { |
|
704 | + if (is_array($row)) |
|
705 | + { |
|
706 | + $row[$column] = unserialize($row[$column]); |
|
707 | + } |
|
708 | + else |
|
709 | + { |
|
710 | + $row->$column = unserialize($row->$column); |
|
711 | + } |
|
712 | + } |
|
713 | + return $row; |
|
714 | + } |
|
715 | + |
|
716 | + /** |
|
717 | + * Protect attributes by removing them from $row array |
|
718 | + */ |
|
719 | + public function protect_attributes($row) |
|
720 | + { |
|
721 | + foreach ($this->protected_attributes as $attr) |
|
722 | + { |
|
723 | + if (is_object($row)) |
|
724 | + { |
|
725 | 725 | if(isset($row->$attr)){ |
726 | 726 | unset($row->$attr); |
727 | 727 | } |
728 | - } |
|
729 | - else |
|
730 | - { |
|
728 | + } |
|
729 | + else |
|
730 | + { |
|
731 | 731 | if(isset($row[$attr])){ |
732 | 732 | unset($row[$attr]); |
733 | 733 | } |
734 | - } |
|
735 | - } |
|
736 | - return $row; |
|
737 | - } |
|
734 | + } |
|
735 | + } |
|
736 | + return $row; |
|
737 | + } |
|
738 | 738 | |
739 | 739 | /** |
740 | - * Return the database instance |
|
741 | - * @return Database the database instance |
|
742 | - */ |
|
743 | - public function getDatabaseInstance(){ |
|
744 | - return $this->_database; |
|
745 | - } |
|
746 | - |
|
747 | - /* -------------------------------------------------------------- |
|
740 | + * Return the database instance |
|
741 | + * @return Database the database instance |
|
742 | + */ |
|
743 | + public function getDatabaseInstance(){ |
|
744 | + return $this->_database; |
|
745 | + } |
|
746 | + |
|
747 | + /* -------------------------------------------------------------- |
|
748 | 748 | * QUERY BUILDER DIRECT ACCESS METHODS |
749 | 749 | * ------------------------------------------------------------ */ |
750 | 750 | |
751 | - /** |
|
752 | - * A wrapper to $this->_database->orderBy() |
|
753 | - */ |
|
754 | - public function order_by($criteria, $order = 'ASC') |
|
755 | - { |
|
756 | - if ( is_array($criteria) ) |
|
757 | - { |
|
758 | - foreach ($criteria as $key => $value) |
|
759 | - { |
|
760 | - $this->_database->orderBy($key, $value); |
|
761 | - } |
|
762 | - } |
|
763 | - else |
|
764 | - { |
|
765 | - $this->_database->orderBy($criteria, $order); |
|
766 | - } |
|
767 | - return $this; |
|
768 | - } |
|
769 | - |
|
770 | - /** |
|
771 | - * A wrapper to $this->_database->limit() |
|
772 | - */ |
|
773 | - public function limit($offset = 0, $limit = 10) |
|
774 | - { |
|
775 | - $this->_database->limit($offset, $limit); |
|
776 | - return $this; |
|
777 | - } |
|
778 | - |
|
779 | - /* -------------------------------------------------------------- |
|
751 | + /** |
|
752 | + * A wrapper to $this->_database->orderBy() |
|
753 | + */ |
|
754 | + public function order_by($criteria, $order = 'ASC') |
|
755 | + { |
|
756 | + if ( is_array($criteria) ) |
|
757 | + { |
|
758 | + foreach ($criteria as $key => $value) |
|
759 | + { |
|
760 | + $this->_database->orderBy($key, $value); |
|
761 | + } |
|
762 | + } |
|
763 | + else |
|
764 | + { |
|
765 | + $this->_database->orderBy($criteria, $order); |
|
766 | + } |
|
767 | + return $this; |
|
768 | + } |
|
769 | + |
|
770 | + /** |
|
771 | + * A wrapper to $this->_database->limit() |
|
772 | + */ |
|
773 | + public function limit($offset = 0, $limit = 10) |
|
774 | + { |
|
775 | + $this->_database->limit($offset, $limit); |
|
776 | + return $this; |
|
777 | + } |
|
778 | + |
|
779 | + /* -------------------------------------------------------------- |
|
780 | 780 | * INTERNAL METHODS |
781 | 781 | * ------------------------------------------------------------ */ |
782 | 782 | |
783 | - /** |
|
784 | - * Trigger an event and call its observers. Pass through the event name |
|
785 | - * (which looks for an instance variable $this->event_name), an array of |
|
786 | - * parameters to pass through and an optional 'last in interation' boolean |
|
787 | - */ |
|
788 | - protected function trigger($event, $data = FALSE, $last = TRUE) |
|
789 | - { |
|
790 | - if (isset($this->$event) && is_array($this->$event)) |
|
791 | - { |
|
792 | - foreach ($this->$event as $method) |
|
793 | - { |
|
794 | - if (strpos($method, '(')) |
|
795 | - { |
|
796 | - preg_match('/([a-zA-Z0-9\_\-]+)(\(([a-zA-Z0-9\_\-\., ]+)\))?/', $method, $matches); |
|
797 | - |
|
798 | - $method = $matches[1]; |
|
799 | - $this->callback_parameters = explode(',', $matches[3]); |
|
800 | - } |
|
801 | - $data = call_user_func_array(array($this, $method), array($data, $last)); |
|
802 | - } |
|
803 | - } |
|
804 | - return $data; |
|
805 | - } |
|
806 | - |
|
807 | - /** |
|
808 | - * Run validation on the passed data |
|
809 | - */ |
|
810 | - protected function validate(array $data) |
|
811 | - { |
|
812 | - if($this->skip_validation) |
|
813 | - { |
|
814 | - return $data; |
|
815 | - } |
|
816 | - if(!empty($this->validate)) |
|
817 | - { |
|
818 | - foreach($data as $key => $val) |
|
819 | - { |
|
820 | - $_POST[$key] = $val; |
|
821 | - } |
|
822 | - Loader::library('FormValidation'); |
|
823 | - if(is_array($this->validate)) |
|
824 | - { |
|
825 | - $this->formvalidation->setRules($this->validate); |
|
826 | - |
|
827 | - if ($this->formvalidation->run()) |
|
828 | - { |
|
829 | - return $data; |
|
830 | - } |
|
831 | - else |
|
832 | - { |
|
833 | - return FALSE; |
|
834 | - } |
|
835 | - } |
|
836 | - else { |
|
837 | - return $data; |
|
838 | - } |
|
839 | - } |
|
840 | - else |
|
841 | - { |
|
842 | - return $data; |
|
843 | - } |
|
844 | - } |
|
845 | - |
|
846 | - |
|
847 | - /** |
|
848 | - * Set WHERE parameters, cleverly |
|
849 | - */ |
|
850 | - protected function _set_where($params) |
|
851 | - { |
|
852 | - if (count($params) == 1 && is_array($params[0])) |
|
853 | - { |
|
854 | - foreach ($params[0] as $field => $filter) |
|
855 | - { |
|
856 | - if (is_array($filter)) |
|
857 | - { |
|
858 | - $this->_database->in($field, $filter); |
|
859 | - } |
|
860 | - else |
|
861 | - { |
|
862 | - if (is_int($field)) |
|
863 | - { |
|
864 | - $this->_database->where($filter); |
|
865 | - } |
|
866 | - else |
|
867 | - { |
|
868 | - $this->_database->where($field, $filter); |
|
869 | - } |
|
870 | - } |
|
871 | - } |
|
872 | - } |
|
873 | - else if (count($params) == 1) |
|
874 | - { |
|
875 | - $this->_database->where($params[0]); |
|
876 | - } |
|
877 | - else if(count($params) == 2) |
|
878 | - { |
|
879 | - if (is_array($params[1])) |
|
880 | - { |
|
881 | - $this->_database->in($params[0], $params[1]); |
|
882 | - } |
|
883 | - else |
|
884 | - { |
|
885 | - $this->_database->where($params[0], $params[1]); |
|
886 | - } |
|
887 | - } |
|
888 | - else if(count($params) == 3) |
|
889 | - { |
|
890 | - $this->_database->where($params[0], $params[1], $params[2]); |
|
891 | - } |
|
892 | - else |
|
893 | - { |
|
894 | - if (is_array($params[1])) |
|
895 | - { |
|
896 | - $this->_database->in($params[0], $params[1]); |
|
897 | - } |
|
898 | - else |
|
899 | - { |
|
900 | - $this->_database->where($params[0], $params[1]); |
|
901 | - } |
|
902 | - } |
|
903 | - } |
|
904 | - |
|
905 | - /** |
|
783 | + /** |
|
784 | + * Trigger an event and call its observers. Pass through the event name |
|
785 | + * (which looks for an instance variable $this->event_name), an array of |
|
786 | + * parameters to pass through and an optional 'last in interation' boolean |
|
787 | + */ |
|
788 | + protected function trigger($event, $data = FALSE, $last = TRUE) |
|
789 | + { |
|
790 | + if (isset($this->$event) && is_array($this->$event)) |
|
791 | + { |
|
792 | + foreach ($this->$event as $method) |
|
793 | + { |
|
794 | + if (strpos($method, '(')) |
|
795 | + { |
|
796 | + preg_match('/([a-zA-Z0-9\_\-]+)(\(([a-zA-Z0-9\_\-\., ]+)\))?/', $method, $matches); |
|
797 | + |
|
798 | + $method = $matches[1]; |
|
799 | + $this->callback_parameters = explode(',', $matches[3]); |
|
800 | + } |
|
801 | + $data = call_user_func_array(array($this, $method), array($data, $last)); |
|
802 | + } |
|
803 | + } |
|
804 | + return $data; |
|
805 | + } |
|
806 | + |
|
807 | + /** |
|
808 | + * Run validation on the passed data |
|
809 | + */ |
|
810 | + protected function validate(array $data) |
|
811 | + { |
|
812 | + if($this->skip_validation) |
|
813 | + { |
|
814 | + return $data; |
|
815 | + } |
|
816 | + if(!empty($this->validate)) |
|
817 | + { |
|
818 | + foreach($data as $key => $val) |
|
819 | + { |
|
820 | + $_POST[$key] = $val; |
|
821 | + } |
|
822 | + Loader::library('FormValidation'); |
|
823 | + if(is_array($this->validate)) |
|
824 | + { |
|
825 | + $this->formvalidation->setRules($this->validate); |
|
826 | + |
|
827 | + if ($this->formvalidation->run()) |
|
828 | + { |
|
829 | + return $data; |
|
830 | + } |
|
831 | + else |
|
832 | + { |
|
833 | + return FALSE; |
|
834 | + } |
|
835 | + } |
|
836 | + else { |
|
837 | + return $data; |
|
838 | + } |
|
839 | + } |
|
840 | + else |
|
841 | + { |
|
842 | + return $data; |
|
843 | + } |
|
844 | + } |
|
845 | + |
|
846 | + |
|
847 | + /** |
|
848 | + * Set WHERE parameters, cleverly |
|
849 | + */ |
|
850 | + protected function _set_where($params) |
|
851 | + { |
|
852 | + if (count($params) == 1 && is_array($params[0])) |
|
853 | + { |
|
854 | + foreach ($params[0] as $field => $filter) |
|
855 | + { |
|
856 | + if (is_array($filter)) |
|
857 | + { |
|
858 | + $this->_database->in($field, $filter); |
|
859 | + } |
|
860 | + else |
|
861 | + { |
|
862 | + if (is_int($field)) |
|
863 | + { |
|
864 | + $this->_database->where($filter); |
|
865 | + } |
|
866 | + else |
|
867 | + { |
|
868 | + $this->_database->where($field, $filter); |
|
869 | + } |
|
870 | + } |
|
871 | + } |
|
872 | + } |
|
873 | + else if (count($params) == 1) |
|
874 | + { |
|
875 | + $this->_database->where($params[0]); |
|
876 | + } |
|
877 | + else if(count($params) == 2) |
|
878 | + { |
|
879 | + if (is_array($params[1])) |
|
880 | + { |
|
881 | + $this->_database->in($params[0], $params[1]); |
|
882 | + } |
|
883 | + else |
|
884 | + { |
|
885 | + $this->_database->where($params[0], $params[1]); |
|
886 | + } |
|
887 | + } |
|
888 | + else if(count($params) == 3) |
|
889 | + { |
|
890 | + $this->_database->where($params[0], $params[1], $params[2]); |
|
891 | + } |
|
892 | + else |
|
893 | + { |
|
894 | + if (is_array($params[1])) |
|
895 | + { |
|
896 | + $this->_database->in($params[0], $params[1]); |
|
897 | + } |
|
898 | + else |
|
899 | + { |
|
900 | + $this->_database->where($params[0], $params[1]); |
|
901 | + } |
|
902 | + } |
|
903 | + } |
|
904 | + |
|
905 | + /** |
|
906 | 906 | Shortcut to controller |
907 | - */ |
|
908 | - public function __get($key){ |
|
909 | - return get_instance()->{$key}; |
|
910 | - } |
|
907 | + */ |
|
908 | + public function __get($key){ |
|
909 | + return get_instance()->{$key}; |
|
910 | + } |
|
911 | 911 | |
912 | - } |
|
912 | + } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * DB session handler class |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | |
28 | 28 | class Url{ |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | class Session{ |
27 | 27 | |
28 | 28 | /** |
@@ -22,23 +22,23 @@ discard block |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class Router { |
28 | 28 | |
29 | 29 | /** |
30 | - * @var array $pattern: The list of URIs to validate against |
|
31 | - */ |
|
30 | + * @var array $pattern: The list of URIs to validate against |
|
31 | + */ |
|
32 | 32 | private $pattern = array(); |
33 | 33 | |
34 | 34 | /** |
35 | - * @var array $callback: The list of callback to call |
|
36 | - */ |
|
35 | + * @var array $callback: The list of callback to call |
|
36 | + */ |
|
37 | 37 | private $callback = array(); |
38 | 38 | |
39 | 39 | /** |
40 | - * @var string $uriTrim: The char to remove from the URIs |
|
41 | - */ |
|
40 | + * @var string $uriTrim: The char to remove from the URIs |
|
41 | + */ |
|
42 | 42 | protected $uriTrim = '/\^$'; |
43 | 43 | |
44 | 44 | /** |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function __construct(){ |
96 | 96 | $this->logger =& class_loader('Log', 'classes'); |
97 | - $this->logger->setLogger('Library::Router'); |
|
98 | - $routesPath = CONFIG_PATH . 'routes.php'; |
|
99 | - $this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...'); |
|
97 | + $this->logger->setLogger('Library::Router'); |
|
98 | + $routesPath = CONFIG_PATH . 'routes.php'; |
|
99 | + $this->logger->debug('Loading of routes configuration file --> ' . $routesPath . ' ...'); |
|
100 | 100 | if(file_exists($routesPath)){ |
101 | 101 | $this->logger->info('Found routes configuration file --> ' . $routesPath. ' now load it'); |
102 | 102 | require_once $routesPath; |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
150 | - * Add the URI and callback to the list of URIs to validate |
|
151 | - * |
|
152 | - * @param string $uri the request URI |
|
153 | - * @param object $callback the callback function |
|
154 | - */ |
|
150 | + * Add the URI and callback to the list of URIs to validate |
|
151 | + * |
|
152 | + * @param string $uri the request URI |
|
153 | + * @param object $callback the callback function |
|
154 | + */ |
|
155 | 155 | public function add($uri, $callback) { |
156 | 156 | $uri = trim($uri, $this->uriTrim); |
157 | 157 | if(in_array($uri, $this->pattern)){ |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * For application languages management |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * Construct new Lang instance |
69 | 69 | */ |
70 | 70 | public function __construct(){ |
71 | - $this->logger =& class_loader('Log', 'classes'); |
|
72 | - $this->logger->setLogger('Library::Lang'); |
|
71 | + $this->logger =& class_loader('Log', 'classes'); |
|
72 | + $this->logger->setLogger('Library::Lang'); |
|
73 | 73 | |
74 | 74 | $this->default = get_config('default_language', 'en'); |
75 | 75 | //determine the current language |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | class Security{ |
28 | 28 |
@@ -22,7 +22,7 @@ |
||
22 | 22 | * You should have received a copy of the GNU General Public License |
23 | 23 | * along with this program; if not, write to the Free Software |
24 | 24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
25 | - */ |
|
25 | + */ |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * This class represent the event dispatcher management, permit to record the listener and |