@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | $this->temp_return_type = $this->return_type; |
302 | 302 | |
303 | 303 | // Make sure our database is loaded |
304 | - if (!is_null($db)) { |
|
304 | + if ( ! is_null($db)) { |
|
305 | 305 | $this->db = $db; |
306 | 306 | } |
307 | 307 | else { |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | |
312 | 312 | // Do we have a form_validation library? |
313 | - if (! is_null($form_validation)) { |
|
313 | + if ( ! is_null($form_validation)) { |
|
314 | 314 | $this->form_validation = $form_validation; |
315 | 315 | } |
316 | 316 | else { |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | if (is_array($rows)) { |
482 | 482 | foreach ($rows as $key => &$row) { |
483 | - $row = $this->trigger('after_find', ['method' => 'find_all', 'fields' => $row] ); |
|
483 | + $row = $this->trigger('after_find', ['method' => 'find_all', 'fields' => $row]); |
|
484 | 484 | } |
485 | 485 | } |
486 | 486 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | if ($data !== FALSE) { |
511 | 511 | $data = $this->trigger('before_insert', ['method' => 'insert', 'fields' => $data]); |
512 | 512 | |
513 | - $this->db->insert($this->table_name, $this->prep_data($data) ); |
|
513 | + $this->db->insert($this->table_name, $this->prep_data($data)); |
|
514 | 514 | |
515 | 515 | if ($this->return_insert_id) { |
516 | 516 | $id = $this->db->insert_id(); |
@@ -555,7 +555,7 @@ discard block |
||
555 | 555 | |
556 | 556 | if ($data !== FALSE) { |
557 | 557 | $data['batch'] = true; |
558 | - $data = $this->trigger('before_insert', ['method' => 'insert_batch', 'fields' => $data] ); |
|
558 | + $data = $this->trigger('before_insert', ['method' => 'insert_batch', 'fields' => $data]); |
|
559 | 559 | unset($data['batch']); |
560 | 560 | |
561 | 561 | return $this->db->insert_batch($this->table_name, $data); |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param null $skip_validation |
578 | 578 | * @return bool |
579 | 579 | */ |
580 | - public function replace($data, $skip_validation=null) |
|
580 | + public function replace($data, $skip_validation = null) |
|
581 | 581 | { |
582 | 582 | $skip_validation = is_null($skip_validation) ? $this->skip_validation : $skip_validation; |
583 | 583 | |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | // Will be false if it didn't validate. |
625 | 625 | if ($data !== FALSE) { |
626 | 626 | |
627 | - $data = $this->trigger('before_update', ['id' => $id, 'method' =>'update', 'fields' => $data] ); |
|
627 | + $data = $this->trigger('before_update', ['id' => $id, 'method' =>'update', 'fields' => $data]); |
|
628 | 628 | |
629 | 629 | $this->db->where($this->primary_key, $id); |
630 | - $this->db->set( $this->prep_data($data) ); |
|
630 | + $this->db->set($this->prep_data($data)); |
|
631 | 631 | $result = $this->db->update($this->table_name); |
632 | 632 | |
633 | 633 | $this->trigger('after_update', ['id' => $id, 'fields' => $data, 'result' => $result, 'method' => 'update']); |
@@ -666,7 +666,7 @@ discard block |
||
666 | 666 | public function update_batch($data, $where_key) |
667 | 667 | { |
668 | 668 | foreach ($data as &$row) { |
669 | - $row = $this->trigger('before_update', ['method' => 'update_batch', 'fields' => $row] ); |
|
669 | + $row = $this->trigger('before_update', ['method' => 'update_batch', 'fields' => $row]); |
|
670 | 670 | } |
671 | 671 | |
672 | 672 | $result = $this->db->update_batch($this->table_name, $data, $where_key); |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | */ |
701 | 701 | public function update_many($ids, $data, $skip_validation = null) |
702 | 702 | { |
703 | - if (!is_array($ids) || count($ids) == 0) return NULL; |
|
703 | + if ( ! is_array($ids) || count($ids) == 0) return NULL; |
|
704 | 704 | |
705 | 705 | $skip_validation = is_null($skip_validation) ? $this->skip_validation : $skip_validation; |
706 | 706 | |
@@ -754,10 +754,10 @@ discard block |
||
754 | 754 | |
755 | 755 | // Will be false if it didn't validate. |
756 | 756 | if ($this->validate($data) !== FALSE) { |
757 | - $this->db->set( $this->prep_data($data) ); |
|
757 | + $this->db->set($this->prep_data($data)); |
|
758 | 758 | $result = $this->db->update($this->table_name); |
759 | 759 | |
760 | - $this->trigger('after_update', ['method' => 'update_by', 'fields' => $data, 'result' => $result] ); |
|
760 | + $this->trigger('after_update', ['method' => 'update_by', 'fields' => $data, 'result' => $result]); |
|
761 | 761 | |
762 | 762 | return $result; |
763 | 763 | } else { |
@@ -776,7 +776,7 @@ discard block |
||
776 | 776 | */ |
777 | 777 | public function update_all($data, $skip_validation = FALSE) |
778 | 778 | { |
779 | - $data = $this->trigger('before_update', ['method' => 'update_all', 'fields' => $data] ); |
|
779 | + $data = $this->trigger('before_update', ['method' => 'update_all', 'fields' => $data]); |
|
780 | 780 | |
781 | 781 | $skip_validation = is_null($skip_validation) ? $this->skip_validation : $skip_validation; |
782 | 782 | |
@@ -786,10 +786,10 @@ discard block |
||
786 | 786 | |
787 | 787 | // Will be false if it didn't validate. |
788 | 788 | if ($data !== FALSE) { |
789 | - $this->db->set( $this->prep_data($data) ); |
|
789 | + $this->db->set($this->prep_data($data)); |
|
790 | 790 | $result = $this->db->update($this->table_name); |
791 | 791 | |
792 | - $this->trigger('after_update', ['method' => 'update_all', 'fields' => $data, 'result' => $result] ); |
|
792 | + $this->trigger('after_update', ['method' => 'update_all', 'fields' => $data, 'result' => $result]); |
|
793 | 793 | |
794 | 794 | return $result; |
795 | 795 | } else { |
@@ -808,9 +808,9 @@ discard block |
||
808 | 808 | * @param int $value |
809 | 809 | * @return mixed |
810 | 810 | */ |
811 | - public function increment($id, $field, $value=1) |
|
811 | + public function increment($id, $field, $value = 1) |
|
812 | 812 | { |
813 | - $value = (int)abs($value); |
|
813 | + $value = (int) abs($value); |
|
814 | 814 | |
815 | 815 | $this->db->where($this->primary_key, $id); |
816 | 816 | $this->db->set($field, "{$field}+{$value}", false); |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * @param int $value |
830 | 830 | * @return mixed |
831 | 831 | */ |
832 | - public function decrement($id, $field, $value=1) |
|
832 | + public function decrement($id, $field, $value = 1) |
|
833 | 833 | { |
834 | - $value = (int)abs($value); |
|
834 | + $value = (int) abs($value); |
|
835 | 835 | |
836 | 836 | $this->db->where($this->primary_key, $id); |
837 | 837 | $this->db->set($field, "{$field}-{$value}", false); |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | */ |
850 | 850 | public function delete($id) |
851 | 851 | { |
852 | - $this->trigger('before_delete', ['id' => $id, 'method' => 'delete'] ); |
|
852 | + $this->trigger('before_delete', ['id' => $id, 'method' => 'delete']); |
|
853 | 853 | |
854 | 854 | $this->db->where($this->primary_key, $id); |
855 | 855 | |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | $result = $this->db->delete($this->table_name); |
865 | 865 | } |
866 | 866 | |
867 | - $this->trigger('after_delete', ['id' => $id, 'method' => 'delete', 'result' => $result] ); |
|
867 | + $this->trigger('after_delete', ['id' => $id, 'method' => 'delete', 'result' => $result]); |
|
868 | 868 | |
869 | 869 | return $result; |
870 | 870 | } |
@@ -888,7 +888,7 @@ discard block |
||
888 | 888 | $result = $this->db->delete($this->table_name); |
889 | 889 | } |
890 | 890 | |
891 | - $this->trigger('after_delete', ['method' => 'delete_by', 'fields' => $where, 'result' => $result] ); |
|
891 | + $this->trigger('after_delete', ['method' => 'delete_by', 'fields' => $where, 'result' => $result]); |
|
892 | 892 | |
893 | 893 | return $result; |
894 | 894 | } |
@@ -897,9 +897,9 @@ discard block |
||
897 | 897 | |
898 | 898 | public function delete_many($ids) |
899 | 899 | { |
900 | - if (!is_array($ids) || count($ids) == 0) return NULL; |
|
900 | + if ( ! is_array($ids) || count($ids) == 0) return NULL; |
|
901 | 901 | |
902 | - $ids = $this->trigger('before_delete', ['ids' => $ids, 'method' => 'delete_many'] ); |
|
902 | + $ids = $this->trigger('before_delete', ['ids' => $ids, 'method' => 'delete_many']); |
|
903 | 903 | |
904 | 904 | $this->db->where_in($this->primary_key, $ids); |
905 | 905 | |
@@ -960,7 +960,7 @@ discard block |
||
960 | 960 | * @param string $class |
961 | 961 | * @return $this |
962 | 962 | */ |
963 | - public function as_object($class=null) |
|
963 | + public function as_object($class = null) |
|
964 | 964 | { |
965 | 965 | $this->temp_return_type = ! empty($class) ? $class : 'object'; |
966 | 966 | |
@@ -1060,7 +1060,7 @@ discard block |
||
1060 | 1060 | */ |
1061 | 1061 | public function return_insert_id($return = true) |
1062 | 1062 | { |
1063 | - $this->return_insert_id = (bool)$return; |
|
1063 | + $this->return_insert_id = (bool) $return; |
|
1064 | 1064 | |
1065 | 1065 | return $this; |
1066 | 1066 | } |
@@ -1170,7 +1170,7 @@ discard block |
||
1170 | 1170 | |
1171 | 1171 | // Though the model doesn't support multiple keys well, $this->key |
1172 | 1172 | // could be an array or a string... |
1173 | - $skippedFields = array_merge($skippedFields, (array)$this->primary_key); |
|
1173 | + $skippedFields = array_merge($skippedFields, (array) $this->primary_key); |
|
1174 | 1174 | |
1175 | 1175 | // Remove any protected attributes |
1176 | 1176 | $skippedFields = array_merge($skippedFields, $this->protected_attributes); |
@@ -1200,7 +1200,7 @@ discard block |
||
1200 | 1200 | * |
1201 | 1201 | * @return string |
1202 | 1202 | */ |
1203 | - public function last_query () |
|
1203 | + public function last_query() |
|
1204 | 1204 | { |
1205 | 1205 | return $this->db->last_query(); |
1206 | 1206 | } |
@@ -1213,11 +1213,11 @@ discard block |
||
1213 | 1213 | * |
1214 | 1214 | * @return mixed |
1215 | 1215 | */ |
1216 | - public function last_query_time () |
|
1216 | + public function last_query_time() |
|
1217 | 1217 | { |
1218 | 1218 | $times = $this->db->query_times; |
1219 | 1219 | |
1220 | - if (! is_array($this->db->query_times) || ! count($this->db->query_times)) |
|
1220 | + if ( ! is_array($this->db->query_times) || ! count($this->db->query_times)) |
|
1221 | 1221 | { |
1222 | 1222 | return null; |
1223 | 1223 | } |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | $row = $row['fields']; |
1250 | 1250 | |
1251 | 1251 | // Created_on |
1252 | - if (! array_key_exists($this->created_field, $row)) |
|
1252 | + if ( ! array_key_exists($this->created_field, $row)) |
|
1253 | 1253 | { |
1254 | 1254 | $row[$this->created_field] = $this->set_date(); |
1255 | 1255 | } |
@@ -1260,7 +1260,7 @@ discard block |
||
1260 | 1260 | // If you're here because of an error with $this->authenticate |
1261 | 1261 | // not being available, it's likely due to you not using |
1262 | 1262 | // the AuthTrait and/or setting log_user after model is instantiated. |
1263 | - $row[$this->created_by_field] = (int)$this->authenticate->id(); |
|
1263 | + $row[$this->created_by_field] = (int) $this->authenticate->id(); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | return $row; |
@@ -1332,7 +1332,7 @@ discard block |
||
1332 | 1332 | */ |
1333 | 1333 | public function trigger($event, $data = false) |
1334 | 1334 | { |
1335 | - if (! isset($this->$event) || ! is_array($this->$event)) |
|
1335 | + if ( ! isset($this->$event) || ! is_array($this->$event)) |
|
1336 | 1336 | { |
1337 | 1337 | if (isset($data['fields'])) |
1338 | 1338 | { |
@@ -1397,18 +1397,18 @@ discard block |
||
1397 | 1397 | $this->load->database(); |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - if (!empty($this->validation_rules)) { |
|
1400 | + if ( ! empty($this->validation_rules)) { |
|
1401 | 1401 | $this->form_validation->set_data($data); |
1402 | 1402 | |
1403 | 1403 | if (is_array($this->validation_rules)) { |
1404 | 1404 | // Any insert additions? |
1405 | 1405 | if ($type == 'insert' |
1406 | - && !empty($this->insert_validate_rules) |
|
1406 | + && ! empty($this->insert_validate_rules) |
|
1407 | 1407 | && is_array($this->insert_validate_rules) |
1408 | 1408 | ) { |
1409 | 1409 | foreach ($this->validation_rules as &$row) { |
1410 | 1410 | if (isset($this->insert_validate_rules[$row['field']])) { |
1411 | - $row ['rules'] .= '|' . $this->insert_validate_rules[$row['field']]; |
|
1411 | + $row ['rules'] .= '|'.$this->insert_validate_rules[$row['field']]; |
|
1412 | 1412 | } |
1413 | 1413 | } |
1414 | 1414 | } |
@@ -1475,7 +1475,7 @@ discard block |
||
1475 | 1475 | */ |
1476 | 1476 | protected function set_date($user_date = NULL) |
1477 | 1477 | { |
1478 | - $curr_date = !empty($user_date) ? $user_date : time(); |
|
1478 | + $curr_date = ! empty($user_date) ? $user_date : time(); |
|
1479 | 1479 | |
1480 | 1480 | switch ($this->date_format) { |
1481 | 1481 | case 'int': |
@@ -1499,7 +1499,7 @@ discard block |
||
1499 | 1499 | * |
1500 | 1500 | * @return mixed |
1501 | 1501 | */ |
1502 | - public function error($db_array_only=false) |
|
1502 | + public function error($db_array_only = false) |
|
1503 | 1503 | { |
1504 | 1504 | // Send any validation errors if we have any. |
1505 | 1505 | if (function_exists('validation_errors') && validation_errors() && ! $db_array_only) |
@@ -1515,7 +1515,7 @@ discard block |
||
1515 | 1515 | return $error; |
1516 | 1516 | } |
1517 | 1517 | |
1518 | - if (! empty($error['code'])) |
|
1518 | + if ( ! empty($error['code'])) |
|
1519 | 1519 | { |
1520 | 1520 | return "Database Error {$error['code']}: {$error['message']}."; |
1521 | 1521 | } |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | * @param $name |
1566 | 1566 | * @param $params |
1567 | 1567 | */ |
1568 | - public function __call($name, $params=null) |
|
1568 | + public function __call($name, $params = null) |
|
1569 | 1569 | { |
1570 | 1570 | if (method_exists($this->db, $name)) |
1571 | 1571 | { |
@@ -37,20 +37,20 @@ discard block |
||
37 | 37 | * available within the Router class, before get_instance() is available we'll have to |
38 | 38 | * live with it for now. |
39 | 39 | */ |
40 | -include APPPATH . 'config/config.php'; |
|
40 | +include APPPATH.'config/config.php'; |
|
41 | 41 | |
42 | -if ( isset( $config ) ) |
|
42 | +if (isset($config)) |
|
43 | 43 | { |
44 | - if ( is_array( $config['modules_locations'] ) ) |
|
44 | + if (is_array($config['modules_locations'])) |
|
45 | 45 | { |
46 | 46 | Modules::$locations = $config['modules_locations']; |
47 | 47 | } |
48 | 48 | else |
49 | 49 | { |
50 | - Modules::$locations = array( APPPATH . 'modules/' => '../modules/' ); |
|
50 | + Modules::$locations = array(APPPATH.'modules/' => '../modules/'); |
|
51 | 51 | } |
52 | 52 | |
53 | - unset( $config ); |
|
53 | + unset($config); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public static function load_file( $file, $path, $type = 'other', $result = TRUE ) |
|
110 | + public static function load_file($file, $path, $type = 'other', $result = TRUE) |
|
111 | 111 | { |
112 | 112 | |
113 | - $file = str_replace( '.php', '', $file ); |
|
114 | - $location = $path . $file . '.php'; |
|
113 | + $file = str_replace('.php', '', $file); |
|
114 | + $location = $path.$file.'.php'; |
|
115 | 115 | |
116 | - if ( $type === 'other' ) |
|
116 | + if ($type === 'other') |
|
117 | 117 | { |
118 | - if ( class_exists( $file, FALSE ) ) |
|
118 | + if (class_exists($file, FALSE)) |
|
119 | 119 | { |
120 | - log_message( 'debug', "File already loaded: {$location}" ); |
|
120 | + log_message('debug', "File already loaded: {$location}"); |
|
121 | 121 | |
122 | 122 | return $result; |
123 | 123 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | /* load config or language array */ |
130 | 130 | include $location; |
131 | 131 | |
132 | - if ( ! isset( $$type ) OR ! is_array( $$type ) ) |
|
132 | + if ( ! isset($$type) OR ! is_array($$type)) |
|
133 | 133 | { |
134 | - show_error( "{$location} does not contain a valid {$type} array" ); |
|
134 | + show_error("{$location} does not contain a valid {$type} array"); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $result = $$type; |
138 | 138 | } |
139 | - log_message( 'debug', "File loaded: {$location}" ); |
|
139 | + log_message('debug', "File loaded: {$location}"); |
|
140 | 140 | |
141 | 141 | return $result; |
142 | 142 | } |
@@ -156,64 +156,64 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return array [ {full_path_to_file}, {file} ] or FALSE |
158 | 158 | */ |
159 | - public static function find( $file, $module, $base ) |
|
159 | + public static function find($file, $module, $base) |
|
160 | 160 | { |
161 | - if (! is_string($module) || ! is_string($file) || ! is_string($base)) |
|
161 | + if ( ! is_string($module) || ! is_string($file) || ! is_string($base)) |
|
162 | 162 | { |
163 | 163 | throw new \InvalidArgumentException('Argument must be a string for Modules::find()'); |
164 | 164 | } |
165 | 165 | |
166 | 166 | // Find the actual file name. It will always be the last element. |
167 | - $segments = explode( '/', $file ); |
|
168 | - $file = array_pop( $segments ); |
|
169 | - $file_ext = ( pathinfo( $file, PATHINFO_EXTENSION ) ) ? $file : $file . '.php'; |
|
167 | + $segments = explode('/', $file); |
|
168 | + $file = array_pop($segments); |
|
169 | + $file_ext = (pathinfo($file, PATHINFO_EXTENSION)) ? $file : $file.'.php'; |
|
170 | 170 | |
171 | 171 | // Put the pieces back to get the path. |
172 | - $path = implode( '/', $segments ) . '/'; |
|
173 | - $base = rtrim( $base, '/' ) . '/'; |
|
172 | + $path = implode('/', $segments).'/'; |
|
173 | + $base = rtrim($base, '/').'/'; |
|
174 | 174 | |
175 | 175 | // Look in any possible module locations based on the string segments. |
176 | 176 | $modules = array(); |
177 | - if ( ! empty( $module ) ) |
|
177 | + if ( ! empty($module)) |
|
178 | 178 | { |
179 | - $modules[ $module ] = $path; |
|
179 | + $modules[$module] = $path; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Collect the modules from the segments |
183 | - if ( ! empty( $segments ) ) |
|
183 | + if ( ! empty($segments)) |
|
184 | 184 | { |
185 | - $modules[ array_shift( $segments ) ] = ltrim( implode( '/', $segments ) . '/', '/' ); |
|
185 | + $modules[array_shift($segments)] = ltrim(implode('/', $segments).'/', '/'); |
|
186 | 186 | } |
187 | 187 | |
188 | - foreach ( self::$locations as $location ) |
|
188 | + foreach (self::$locations as $location) |
|
189 | 189 | { |
190 | 190 | |
191 | - foreach ( $modules as $module => $subpath ) |
|
191 | + foreach ($modules as $module => $subpath) |
|
192 | 192 | { |
193 | 193 | // Combine the elements to make an actual path to the file |
194 | - $fullpath = str_replace( '//', '/', "{$location}{$module}/{$base}{$subpath}" ); |
|
194 | + $fullpath = str_replace('//', '/', "{$location}{$module}/{$base}{$subpath}"); |
|
195 | 195 | |
196 | 196 | // If it starts with a '/' assume it's a full path already |
197 | - if ( substr( $path, 0, 1 ) == '/' && strlen( $path ) > 1 ) |
|
197 | + if (substr($path, 0, 1) == '/' && strlen($path) > 1) |
|
198 | 198 | { |
199 | 199 | $fullpath = $path; |
200 | 200 | } |
201 | 201 | |
202 | 202 | // Libraries are a special consideration since they are |
203 | 203 | // frequently ucfirst. |
204 | - if ( $base == 'libraries/' AND is_file( $fullpath . ucfirst( $file_ext ) ) ) |
|
204 | + if ($base == 'libraries/' AND is_file($fullpath.ucfirst($file_ext))) |
|
205 | 205 | { |
206 | - return array( $fullpath, ucfirst( $file ) ); |
|
206 | + return array($fullpath, ucfirst($file)); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( is_file( $fullpath . $file_ext ) ) |
|
209 | + if (is_file($fullpath.$file_ext)) |
|
210 | 210 | { |
211 | - return array( $fullpath, $file ); |
|
211 | + return array($fullpath, $file); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | } |
215 | 215 | |
216 | - return array( FALSE, $file ); |
|
216 | + return array(FALSE, $file); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | //-------------------------------------------------------------------- |
@@ -225,33 +225,33 @@ discard block |
||
225 | 225 | */ |
226 | 226 | public static function listModules() |
227 | 227 | { |
228 | - if ( ! function_exists( 'directory_map' ) ) |
|
228 | + if ( ! function_exists('directory_map')) |
|
229 | 229 | { |
230 | - require BASEPATH . 'helpers/directory_helper.php'; |
|
230 | + require BASEPATH.'helpers/directory_helper.php'; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | $map = array(); |
234 | 234 | |
235 | - foreach ( self::$locations as $folder ) |
|
235 | + foreach (self::$locations as $folder) |
|
236 | 236 | { |
237 | 237 | |
238 | - $dirs = directory_map( $folder, 1 ); |
|
239 | - if ( ! is_array( $dirs ) ) |
|
238 | + $dirs = directory_map($folder, 1); |
|
239 | + if ( ! is_array($dirs)) |
|
240 | 240 | { |
241 | 241 | $dirs = array(); |
242 | 242 | } |
243 | 243 | |
244 | - $map = array_merge( $map, $dirs ); |
|
244 | + $map = array_merge($map, $dirs); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | // Clean out any html or php files |
248 | - if ( $count = count( $map ) ) |
|
248 | + if ($count = count($map)) |
|
249 | 249 | { |
250 | - for ( $i = 0; $i < $count; $i ++ ) |
|
250 | + for ($i = 0; $i < $count; $i++) |
|
251 | 251 | { |
252 | - if ( strpos( $map[ $i ], '.html' ) !== FALSE || strpos( $map[ $i ], '.php' ) !== FALSE ) |
|
252 | + if (strpos($map[$i], '.html') !== FALSE || strpos($map[$i], '.php') !== FALSE) |
|
253 | 253 | { |
254 | - unset( $map[ $i ] ); |
|
254 | + unset($map[$i]); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | } |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | * |
279 | 279 | * @return boolean |
280 | 280 | */ |
281 | - public static function controllerExists($controller, $module ) |
|
281 | + public static function controllerExists($controller, $module) |
|
282 | 282 | { |
283 | - if (! is_string($module) || ! is_string($controller)) |
|
283 | + if ( ! is_string($module) || ! is_string($controller)) |
|
284 | 284 | { |
285 | 285 | throw new \InvalidArgumentException('Argument must be a string for Modules::controllerExists()'); |
286 | 286 | } |
287 | 287 | |
288 | 288 | // Look in all module paths |
289 | - foreach ( self::$locations as $folder ) |
|
289 | + foreach (self::$locations as $folder) |
|
290 | 290 | { |
291 | - if ( is_file( "{$folder}{$module}/controllers/{$controller}.php" ) ) |
|
291 | + if (is_file("{$folder}{$module}/controllers/{$controller}.php")) |
|
292 | 292 | { |
293 | 293 | return TRUE; |
294 | 294 | } |
@@ -308,18 +308,18 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return string The full path to the file, or false if the file was not found |
310 | 310 | */ |
311 | - public static function filePath( $module, $folder, $file ) |
|
311 | + public static function filePath($module, $folder, $file) |
|
312 | 312 | { |
313 | - if (! is_string($module) || ! is_string($folder) || ! is_string($file)) |
|
313 | + if ( ! is_string($module) || ! is_string($folder) || ! is_string($file)) |
|
314 | 314 | { |
315 | 315 | throw new \InvalidArgumentException('Argument must be a string for Modules::filePath()'); |
316 | 316 | } |
317 | 317 | |
318 | - foreach ( self::$locations as $location ) |
|
318 | + foreach (self::$locations as $location) |
|
319 | 319 | { |
320 | 320 | $test_file = "{$location}{$module}/{$folder}/{$file}"; |
321 | 321 | |
322 | - if ( is_file( $test_file ) ) |
|
322 | + if (is_file($test_file)) |
|
323 | 323 | { |
324 | 324 | return $test_file; |
325 | 325 | } |
@@ -338,23 +338,23 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @return string The path, relative to the front controller, or false if the folder was not found |
340 | 340 | */ |
341 | - public static function path( $module, $folder = null ) |
|
341 | + public static function path($module, $folder = null) |
|
342 | 342 | { |
343 | - if (! is_string($module) || (! is_string($folder) && !is_null($folder) ) ) |
|
343 | + if ( ! is_string($module) || ( ! is_string($folder) && ! is_null($folder))) |
|
344 | 344 | { |
345 | 345 | throw new \InvalidArgumentException('Argument must be a string for Modules::path()'); |
346 | 346 | } |
347 | 347 | |
348 | - foreach ( self::$locations as $module_folder ) |
|
348 | + foreach (self::$locations as $module_folder) |
|
349 | 349 | { |
350 | - if ( is_dir( $module_folder . $module ) ) |
|
350 | + if (is_dir($module_folder.$module)) |
|
351 | 351 | { |
352 | - if ( ! empty( $folder ) && is_dir( "{$module_folder}{$module}/{$folder}" ) ) |
|
352 | + if ( ! empty($folder) && is_dir("{$module_folder}{$module}/{$folder}")) |
|
353 | 353 | { |
354 | 354 | return "{$module_folder}{$module}/{$folder}/"; |
355 | 355 | } |
356 | 356 | |
357 | - return $module_folder . $module . '/'; |
|
357 | + return $module_folder.$module.'/'; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
@@ -372,58 +372,58 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @return array An associative array, like: array('module_name' => array('folder' => array('file1', 'file2'))) |
374 | 374 | */ |
375 | - public static function files( $module_name = NULL, $module_folder = NULL ) |
|
375 | + public static function files($module_name = NULL, $module_folder = NULL) |
|
376 | 376 | { |
377 | - if ( ! function_exists( 'directory_map' ) ) |
|
377 | + if ( ! function_exists('directory_map')) |
|
378 | 378 | { |
379 | - require BASEPATH . 'helpers/directory_helper.php'; |
|
379 | + require BASEPATH.'helpers/directory_helper.php'; |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | $files = array(); |
383 | 383 | |
384 | - foreach ( self::$locations as $path ) |
|
384 | + foreach (self::$locations as $path) |
|
385 | 385 | { |
386 | 386 | |
387 | 387 | // Only map the whole modules directory if $module_name isn't passed |
388 | - if ( empty( $module_name ) ) |
|
388 | + if (empty($module_name)) |
|
389 | 389 | { |
390 | - $modules = directory_map( $path ); |
|
390 | + $modules = directory_map($path); |
|
391 | 391 | } |
392 | 392 | // Only map the $module_name directory if it exists |
393 | - elseif ( is_dir( $path . $module_name ) ) |
|
393 | + elseif (is_dir($path.$module_name)) |
|
394 | 394 | { |
395 | - $path = $path . $module_name; |
|
396 | - $modules[ $module_name ] = directory_map( $path ); |
|
395 | + $path = $path.$module_name; |
|
396 | + $modules[$module_name] = directory_map($path); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | // If the element is not an array, it's a file, so ignore it. |
400 | 400 | // Otherwise it is assumed to be a module. |
401 | - if ( empty( $modules ) || ! is_array( $modules ) ) |
|
401 | + if (empty($modules) || ! is_array($modules)) |
|
402 | 402 | { |
403 | 403 | continue; |
404 | 404 | } |
405 | 405 | |
406 | - foreach ( $modules as $mod_name => $values ) |
|
406 | + foreach ($modules as $mod_name => $values) |
|
407 | 407 | { |
408 | - if ( is_array( $values ) ) |
|
408 | + if (is_array($values)) |
|
409 | 409 | { |
410 | 410 | // Add just the specified folder for this module |
411 | - if ( ! empty( $module_folder ) && isset( $values[ $module_folder .'/' ] ) && count( $values[ $module_folder .'/' ] ) ) |
|
411 | + if ( ! empty($module_folder) && isset($values[$module_folder.'/']) && count($values[$module_folder.'/'])) |
|
412 | 412 | { |
413 | - $files[ $mod_name ] = array( |
|
414 | - $module_folder .'/' => $values[ $module_folder .'/' ], |
|
413 | + $files[$mod_name] = array( |
|
414 | + $module_folder.'/' => $values[$module_folder.'/'], |
|
415 | 415 | ); |
416 | 416 | } |
417 | 417 | // Add the entire module |
418 | - elseif ( empty( $module_folder ) ) |
|
418 | + elseif (empty($module_folder)) |
|
419 | 419 | { |
420 | - $files[ $mod_name ] = $values; |
|
420 | + $files[$mod_name] = $values; |
|
421 | 421 | } |
422 | 422 | } |
423 | 423 | } |
424 | 424 | } |
425 | 425 | |
426 | - return count( $files ) ? $files : null; |
|
426 | + return count($files) ? $files : null; |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | //-------------------------------------------------------------------- |
@@ -436,37 +436,37 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @return array |
438 | 438 | */ |
439 | - public static function parse_routes( $module, $uri ) |
|
439 | + public static function parse_routes($module, $uri) |
|
440 | 440 | { |
441 | 441 | |
442 | 442 | /* load the route file */ |
443 | - if ( ! isset( self::$routes[ $module ] ) ) |
|
443 | + if ( ! isset(self::$routes[$module])) |
|
444 | 444 | { |
445 | - if ( list( $path ) = self::find( 'routes', $module, 'config/' ) AND $path ) |
|
445 | + if (list($path) = self::find('routes', $module, 'config/') AND $path) |
|
446 | 446 | { |
447 | - self::$routes[ $module ] = self::load_file( 'routes', $path, 'route' ); |
|
447 | + self::$routes[$module] = self::load_file('routes', $path, 'route'); |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if ( ! isset( self::$routes[ $module ] ) ) |
|
451 | + if ( ! isset(self::$routes[$module])) |
|
452 | 452 | { |
453 | 453 | return; |
454 | 454 | } |
455 | 455 | |
456 | 456 | /* parse module routes */ |
457 | - foreach ( self::$routes[ $module ] as $key => $val ) |
|
457 | + foreach (self::$routes[$module] as $key => $val) |
|
458 | 458 | { |
459 | 459 | |
460 | - $key = str_replace( array( ':any', ':num' ), array( '.+', '[0-9]+' ), $key ); |
|
460 | + $key = str_replace(array(':any', ':num'), array('.+', '[0-9]+'), $key); |
|
461 | 461 | |
462 | - if ( preg_match( '#^' . $key . '$#', $uri ) ) |
|
462 | + if (preg_match('#^'.$key.'$#', $uri)) |
|
463 | 463 | { |
464 | - if ( strpos( $val, '$' ) !== FALSE AND strpos( $key, '(' ) !== FALSE ) |
|
464 | + if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) |
|
465 | 465 | { |
466 | - $val = preg_replace( '#^' . $key . '$#', $val, $uri ); |
|
466 | + $val = preg_replace('#^'.$key.'$#', $val, $uri); |
|
467 | 467 | } |
468 | 468 | |
469 | - return explode( '/', $module . '/' . $val ); |
|
469 | + return explode('/', $module.'/'.$val); |
|
470 | 470 | } |
471 | 471 | } |
472 | 472 | } |
@@ -482,17 +482,17 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @param $class |
484 | 484 | */ |
485 | - public static function autoload( $class ) |
|
485 | + public static function autoload($class) |
|
486 | 486 | { |
487 | 487 | |
488 | 488 | /* don't autoload CI_ prefixed classes or those using the config subclass_prefix */ |
489 | - if ( strstr( $class, 'CI_' ) OR strstr( $class, config_item( 'subclass_prefix' ) ) ) |
|
489 | + if (strstr($class, 'CI_') OR strstr($class, config_item('subclass_prefix'))) |
|
490 | 490 | { |
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | 494 | /* autoload core classes */ |
495 | - if ( is_file( $location = APPPATH . 'core/' . $class . '.php' ) ) |
|
495 | + if (is_file($location = APPPATH.'core/'.$class.'.php')) |
|
496 | 496 | { |
497 | 497 | include_once $location; |
498 | 498 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | } |
501 | 501 | |
502 | 502 | /* autoload library classes */ |
503 | - if ( is_file( $location = APPPATH . 'libraries/' . $class . '.php' ) ) |
|
503 | + if (is_file($location = APPPATH.'libraries/'.$class.'.php')) |
|
504 | 504 | { |
505 | 505 | include_once $location; |
506 | 506 |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | { |
163 | 163 | // Ensure consistency |
164 | 164 | $name = trim($name, '{} '); |
165 | - $pattern = '(' . trim($pattern, '() ') . ')'; |
|
165 | + $pattern = '('.trim($pattern, '() ').')'; |
|
166 | 166 | |
167 | 167 | // Not here? Add it and leave... |
168 | - if (! array_key_exists($name, $this->constraints)) { |
|
168 | + if ( ! array_key_exists($name, $this->constraints)) { |
|
169 | 169 | $this->constraints[$name] = $pattern; |
170 | 170 | |
171 | 171 | return; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | // To register a route, we'll set a flag so that our router |
233 | 233 | // so it will see the groupname. |
234 | - $this->group = ltrim($old_group . '/' . $name, '/'); |
|
234 | + $this->group = ltrim($old_group.'/'.$name, '/'); |
|
235 | 235 | |
236 | 236 | call_user_func($callback); |
237 | 237 | |
@@ -429,24 +429,23 @@ discard block |
||
429 | 429 | // If a new module was specified, simply put that path |
430 | 430 | // in front of the controller. |
431 | 431 | if (isset($options['module'])) { |
432 | - $new_name = $options['module'] . '/' . $new_name; |
|
432 | + $new_name = $options['module'].'/'.$new_name; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // In order to allow customization of allowed id values |
436 | 436 | // we need someplace to store them. |
437 | - $id = isset($this->constraints[$this->default_constraint]) ? $this->constraints[$this->default_constraint] : |
|
438 | - '(:any)'; |
|
437 | + $id = isset($this->constraints[$this->default_constraint]) ? $this->constraints[$this->default_constraint] : '(:any)'; |
|
439 | 438 | |
440 | 439 | if (isset($options['constraint'])) { |
441 | 440 | $id = $options['constraint']; |
442 | 441 | } |
443 | 442 | |
444 | - $this->get($name, $new_name . '/list_all', $options); |
|
445 | - $this->get($name . '/' . $id, $new_name . '/show/$1', $options); |
|
446 | - $this->post($name, $new_name . '/create', $options); |
|
447 | - $this->put($name . '/' . $id, $new_name . '/update/$1', $options); |
|
448 | - $this->delete($name . '/' . $id, $new_name . '/delete/$1', $options); |
|
449 | - $this->options($name, $new_name . '/index', $options); |
|
443 | + $this->get($name, $new_name.'/list_all', $options); |
|
444 | + $this->get($name.'/'.$id, $new_name.'/show/$1', $options); |
|
445 | + $this->post($name, $new_name.'/create', $options); |
|
446 | + $this->put($name.'/'.$id, $new_name.'/update/$1', $options); |
|
447 | + $this->delete($name.'/'.$id, $new_name.'/delete/$1', $options); |
|
448 | + $this->options($name, $new_name.'/index', $options); |
|
450 | 449 | } |
451 | 450 | |
452 | 451 | //-------------------------------------------------------------------- |
@@ -468,11 +467,11 @@ discard block |
||
468 | 467 | self::$areas[$area] = $controller; |
469 | 468 | |
470 | 469 | // Create routes for this area. |
471 | - $this->create($area . '/(:any)/(:any)/(:any)/(:any)/(:any)', '$1/' . $controller . '/$2/$3/$4/$5', $options); |
|
472 | - $this->create($area . '/(:any)/(:any)/(:any)/(:any)', '$1/' . $controller . '/$2/$3/$4', $options); |
|
473 | - $this->create($area . '/(:any)/(:any)/(:any)', '$1/' . $controller . '/$2/$3', $options); |
|
474 | - $this->create($area . '/(:any)/(:any)', '$1/' . $controller . '/$2', $options); |
|
475 | - $this->create($area . '/(:any)', '$1/' . $controller, $options); |
|
470 | + $this->create($area.'/(:any)/(:any)/(:any)/(:any)/(:any)', '$1/'.$controller.'/$2/$3/$4/$5', $options); |
|
471 | + $this->create($area.'/(:any)/(:any)/(:any)/(:any)', '$1/'.$controller.'/$2/$3/$4', $options); |
|
472 | + $this->create($area.'/(:any)/(:any)/(:any)', '$1/'.$controller.'/$2/$3', $options); |
|
473 | + $this->create($area.'/(:any)/(:any)', '$1/'.$controller.'/$2', $options); |
|
474 | + $this->create($area.'/(:any)', '$1/'.$controller, $options); |
|
476 | 475 | } |
477 | 476 | |
478 | 477 | //-------------------------------------------------------------------- |
@@ -534,7 +533,7 @@ discard block |
||
534 | 533 | { |
535 | 534 | $paths = func_get_args(); |
536 | 535 | |
537 | - if (! is_array($paths) || ! count($paths)) { |
|
536 | + if ( ! is_array($paths) || ! count($paths)) { |
|
538 | 537 | return; |
539 | 538 | } |
540 | 539 | |
@@ -577,20 +576,20 @@ discard block |
||
577 | 576 | */ |
578 | 577 | private function create($from, $to, $options = array()) |
579 | 578 | { |
580 | - $prefix = is_null($this->group) ? '' : $this->group . '/'; |
|
579 | + $prefix = is_null($this->group) ? '' : $this->group.'/'; |
|
581 | 580 | |
582 | - $from = $prefix . $from; |
|
581 | + $from = $prefix.$from; |
|
583 | 582 | |
584 | 583 | // Are we saving the name for this one? |
585 | - if (isset($options['as']) && !empty($options['as'])) { |
|
584 | + if (isset($options['as']) && ! empty($options['as'])) { |
|
586 | 585 | self::$names[$options['as']] = $from; |
587 | 586 | } |
588 | 587 | |
589 | 588 | // Limiting to subdomains? |
590 | - if (isset($options['subdomain']) && !empty($options['subdomain'])) { |
|
589 | + if (isset($options['subdomain']) && ! empty($options['subdomain'])) { |
|
591 | 590 | // If we don't match the current subdomain, then |
592 | 591 | // we don't need to add the route. |
593 | - if (!$this->checkSubdomains($options['subdomain'])) { |
|
592 | + if ( ! $this->checkSubdomains($options['subdomain'])) { |
|
594 | 593 | return; |
595 | 594 | } |
596 | 595 | } |
@@ -602,11 +601,11 @@ discard block |
||
602 | 601 | // Get a constant string to work with. |
603 | 602 | $to = preg_replace('/(\$\d+)/', '$X', $to); |
604 | 603 | |
605 | - for ($i = (int)$options['offset'] + 1; $i < (int)$options['offset'] + 7; $i ++) { |
|
604 | + for ($i = (int) $options['offset'] + 1; $i < (int) $options['offset'] + 7; $i++) { |
|
606 | 605 | $to = preg_replace_callback( |
607 | 606 | '/\$X/', |
608 | - function ($m) use ($i) { |
|
609 | - return '$' . $i; |
|
607 | + function($m) use ($i) { |
|
608 | + return '$'.$i; |
|
610 | 609 | }, |
611 | 610 | $to, |
612 | 611 | 1 |
@@ -616,7 +615,7 @@ discard block |
||
616 | 615 | |
617 | 616 | // Convert any custom constraints to the CI/pattern equivalent |
618 | 617 | foreach ($this->constraints as $name => $pattern) { |
619 | - $from = str_replace('{' . $name . '}', $pattern, $from); |
|
618 | + $from = str_replace('{'.$name.'}', $pattern, $from); |
|
620 | 619 | } |
621 | 620 | |
622 | 621 | $this->routes[$from] = $to; |
@@ -637,7 +636,7 @@ discard block |
||
637 | 636 | $this->determineCurrentSubdomain(); |
638 | 637 | } |
639 | 638 | |
640 | - if (!is_array($subdomains)) { |
|
639 | + if ( ! is_array($subdomains)) { |
|
641 | 640 | $subdomains = array($subdomains); |
642 | 641 | } |
643 | 642 | |
@@ -645,7 +644,7 @@ discard block |
||
645 | 644 | |
646 | 645 | array_walk( |
647 | 646 | $subdomains, |
648 | - function ($subdomain) use (&$matched) { |
|
647 | + function($subdomain) use (&$matched) { |
|
649 | 648 | if ($subdomain == $this->current_subdomain || $subdomain == '*') { |
650 | 649 | $matched = true; |
651 | 650 | } |
@@ -670,7 +669,7 @@ discard block |
||
670 | 669 | // If we only have 2 parts, then we don't have a subdomain. |
671 | 670 | // This won't be totally accurate, since URL's like example.co.uk |
672 | 671 | // would still pass, but it helps to separate the chaff... |
673 | - if (!is_array($host) || count($host) == 2) { |
|
672 | + if ( ! is_array($host) || count($host) == 2) { |
|
674 | 673 | // Set it to false so we don't make it back here again. |
675 | 674 | $this->current_subdomain = false; |
676 | 675 | return; |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | |
54 | 54 | //-------------------------------------------------------------------- |
55 | 55 | |
56 | - public function __construct( $ci=null ) |
|
56 | + public function __construct($ci = null) |
|
57 | 57 | { |
58 | 58 | if (is_object($ci)) |
59 | 59 | { |
60 | - $this->ci =& $ci; |
|
60 | + $this->ci = & $ci; |
|
61 | 61 | } |
62 | 62 | else { |
63 | - $this->ci =& get_instance(); |
|
63 | + $this->ci = & get_instance(); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @param null $value |
74 | 74 | * @param string $group |
75 | 75 | */ |
76 | - public function save($key, $value=null, $group='app') |
|
76 | + public function save($key, $value = null, $group = 'app') |
|
77 | 77 | { |
78 | 78 | // Treat the 'app' group as our primary, un-sectioned |
79 | 79 | // config files. |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | // Otherwise, we'll need to ensure a section exists |
86 | - if (! isset($this->ci->config->config[$group])) |
|
86 | + if ( ! isset($this->ci->config->config[$group])) |
|
87 | 87 | { |
88 | 88 | $this->ci->config->config[$group] = []; |
89 | 89 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param string $group |
103 | 103 | * @return mixed |
104 | 104 | */ |
105 | - public function get($key, $group='application') |
|
105 | + public function get($key, $group = 'application') |
|
106 | 106 | { |
107 | 107 | // First, see if CI already has this key loaded. |
108 | 108 | $result = $this->ci->config->item($key); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param $group |
135 | 135 | * @return mixed |
136 | 136 | */ |
137 | - public function delete($key, $group='app') |
|
137 | + public function delete($key, $group = 'app') |
|
138 | 138 | { |
139 | 139 | return false; |
140 | 140 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @param string $group |
164 | 164 | * @return mixed |
165 | 165 | */ |
166 | - public function all($group=null) |
|
166 | + public function all($group = null) |
|
167 | 167 | { |
168 | 168 | if (empty($group)) |
169 | 169 | { |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | //-------------------------------------------------------------------- |
40 | 40 | |
41 | - public function __construct( $ci=null ) |
|
41 | + public function __construct($ci = null) |
|
42 | 42 | { |
43 | 43 | if (is_object($ci)) |
44 | 44 | { |
45 | - $this->ci =& $ci; |
|
45 | + $this->ci = & $ci; |
|
46 | 46 | } |
47 | 47 | else { |
48 | - $this->ci =& get_instance(); |
|
48 | + $this->ci = & get_instance(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // Ensure that the database is loaded. |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param string $group |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - public function save($key, $value=null, $group='app') |
|
68 | + public function save($key, $value = null, $group = 'app') |
|
69 | 69 | { |
70 | 70 | if (empty($this->ci->db) || ! is_object($this->ci->db)) |
71 | 71 | { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $group |
101 | 101 | * @return mixed |
102 | 102 | */ |
103 | - public function get($key, $group='app') |
|
103 | + public function get($key, $group = 'app') |
|
104 | 104 | { |
105 | 105 | if (empty($this->ci->db) || ! is_object($this->ci->db)) |
106 | 106 | { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $query = $this->ci->db->where($where) |
116 | 116 | ->get('settings'); |
117 | 117 | |
118 | - if (! $query->num_rows()) |
|
118 | + if ( ! $query->num_rows()) |
|
119 | 119 | { |
120 | 120 | return false; |
121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $value = $query->row()->value; |
124 | 124 | |
125 | 125 | // Check to see if it needs to be unserialized |
126 | - $data = @unserialize($value); // We don't need to issue an E_NOTICE here... |
|
126 | + $data = @unserialize($value); // We don't need to issue an E_NOTICE here... |
|
127 | 127 | |
128 | 128 | // Check for a value of false or |
129 | 129 | if ($value === 'b:0;' || $data !== false) |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | * @param $group |
144 | 144 | * @return mixed |
145 | 145 | */ |
146 | - public function delete($key, $group='app') |
|
146 | + public function delete($key, $group = 'app') |
|
147 | 147 | { |
148 | 148 | if (empty($this->ci->db) || ! is_object($this->ci->db)) |
149 | 149 | { |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $query = $this->ci->db->where($field, $value) |
178 | 178 | ->get('settings'); |
179 | 179 | |
180 | - if (! $query->num_rows()) |
|
180 | + if ( ! $query->num_rows()) |
|
181 | 181 | { |
182 | 182 | return false; |
183 | 183 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @param string $group |
194 | 194 | * @return mixed |
195 | 195 | */ |
196 | - public function all($group=null) |
|
196 | + public function all($group = null) |
|
197 | 197 | { |
198 | 198 | if (empty($this->ci->db) || ! is_object($this->ci->db)) |
199 | 199 | { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | $query = $this->ci->db->get('settings'); |
204 | 204 | |
205 | - if (! $query->num_rows()) |
|
205 | + if ( ! $query->num_rows()) |
|
206 | 206 | { |
207 | 207 | return false; |
208 | 208 | } |
@@ -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 |
@@ -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 |
@@ -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 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | * |
42 | 42 | * @return mixed |
43 | 43 | */ |
44 | - public function set($alias, $value=null); |
|
44 | + public function set($alias, $value = null); |
|
45 | 45 | |
46 | 46 | //-------------------------------------------------------------------- |
47 | 47 |