@@ -39,7 +39,7 @@ |
||
39 | 39 | $user_un10 = $user_un10[1]; |
40 | 40 | } else { $user_un10 = NULL; } |
41 | 41 | |
42 | - if ($furniture == "No Furniture"){ |
|
42 | + if ($furniture == "No Furniture") { |
|
43 | 43 | $status = "1"; |
44 | 44 | } else { |
45 | 45 | $status = "0"; |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | public function create($first_name, $last_name, $ern, $position, $faculty, $department, $room, $ext, $con_start, $con_end, $password, $site) { |
10 | 10 | |
11 | 11 | $firstchar = substr($this->input->post('first_name'), 0, 1); |
12 | - $builtUsername = strtolower($firstchar) . strtolower($this->input->post('last_name')); |
|
12 | + $builtUsername = strtolower($firstchar).strtolower($this->input->post('last_name')); |
|
13 | 13 | //check user name is new |
14 | 14 | |
15 | - $username = $this->config->item('ldapshortdomain') . $builtUsername; |
|
15 | + $username = $this->config->item('ldapshortdomain').$builtUsername; |
|
16 | 16 | // specify the LDAP server to connect to |
17 | 17 | $conn = ldap_connect($this->config->item('ldapserver')) or die("Oh no can't create LDAP connection"); |
18 | 18 | // bind to the LDAP server specified above |
19 | - if (!ldap_bind($conn, $this->config->item('ldapbindun'),"@".$this->config->item('ldapdomain'), $this->config->item('ldapbindpass'))) |
|
19 | + if (!ldap_bind($conn, $this->config->item('ldapbindun'), "@".$this->config->item('ldapdomain'), $this->config->item('ldapbindpass'))) |
|
20 | 20 | echo "Invalid credentials."; |
21 | 21 | // Search for user in directory |
22 | 22 | $cred = explode('\\', $username); |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $info = ldap_count_entries($conn, $result); |
28 | 28 | |
29 | 29 | if ($info != 0) { |
30 | - $builtUsername = $builtUsername . "2"; |
|
30 | + $builtUsername = $builtUsername."2"; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | $this->email->message('A new staff account has been requested by yourself |
39 | 39 | |
40 | 40 | Account Details: |
41 | - Name: ' . $this->input->post('first_name') . ' ' . $this->input->post('last_name') . ' |
|
42 | - Position: ' . $this->input->post('position') . ' |
|
43 | - ERN: ' . $this->input->post('ern') . ' |
|
44 | - Faculty: ' . $this->input->post('faculty') . ' |
|
45 | - Department: ' . $this->input->post('department') . ' |
|
46 | - Room: ' . $this->input->post('room') . ' |
|
47 | - Phone: ' . $this->input->post('ext') . ' |
|
48 | - Site: ' . $this->input->post('site') . ' |
|
41 | + Name: ' . $this->input->post('first_name').' '.$this->input->post('last_name').' |
|
42 | + Position: ' . $this->input->post('position').' |
|
43 | + ERN: ' . $this->input->post('ern').' |
|
44 | + Faculty: ' . $this->input->post('faculty').' |
|
45 | + Department: ' . $this->input->post('department').' |
|
46 | + Room: ' . $this->input->post('room').' |
|
47 | + Phone: ' . $this->input->post('ext').' |
|
48 | + Site: ' . $this->input->post('site').' |
|
49 | 49 | |
50 | - Username: ' . $builtUsername . ' |
|
51 | - Password: ' . $this->input->post('password') . ' |
|
50 | + Username: ' . $builtUsername.' |
|
51 | + Password: ' . $this->input->post('password').' |
|
52 | 52 | |
53 | 53 | |
54 | 54 | If this account was made by mistake please contact Computing Support. |
@@ -10,14 +10,14 @@ discard block |
||
10 | 10 | public function create($logged, $faculty, $department, $requester, $first_name, $last_name, $email, $username, $expiry) { |
11 | 11 | |
12 | 12 | $firstchar = substr($this->input->post('first_name'), 0, 1); |
13 | - $builtUsername = strtolower($firstchar) . strtolower($this->input->post('last_name')); |
|
13 | + $builtUsername = strtolower($firstchar).strtolower($this->input->post('last_name')); |
|
14 | 14 | |
15 | 15 | //check user name is new |
16 | - $username = $this->config->item('ldapshortdomain') . $builtUsername; |
|
16 | + $username = $this->config->item('ldapshortdomain').$builtUsername; |
|
17 | 17 | // specify the LDAP server to connect to |
18 | 18 | $conn = ldap_connect($this->config->item('ldapserver')) or die("Oh no can't create LDAP connection"); |
19 | 19 | // bind to the LDAP server specified above |
20 | - if (!ldap_bind($conn, $this->config->item('ldapbindun'),"@".$this->config->item('ldapdomain'), $this->config->item('ldapbindpass'))) |
|
20 | + if (!ldap_bind($conn, $this->config->item('ldapbindun'), "@".$this->config->item('ldapdomain'), $this->config->item('ldapbindpass'))) |
|
21 | 21 | echo "Invalid credentials."; |
22 | 22 | // Search for user in directory |
23 | 23 | $cred = explode('\\', $username); |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $info = ldap_count_entries($conn, $result); |
29 | 29 | |
30 | 30 | if ($info != 0) { |
31 | - $builtUsername = $builtUsername . "2"; |
|
31 | + $builtUsername = $builtUsername."2"; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | function randomPassword() { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | //Format hh:mm:ss |
51 | 51 | $timeFromForm = "00:00:00"; |
52 | - $dateWithTime = $dateFromForm . " " . $timeFromForm; |
|
52 | + $dateWithTime = $dateFromForm." ".$timeFromForm; |
|
53 | 53 | |
54 | 54 | function convertDateToUnix($input) { |
55 | 55 | $format = 'd-m-Y H:i:s'; |
@@ -44,19 +44,18 @@ discard block |
||
44 | 44 | return $this->field_types; |
45 | 45 | } |
46 | 46 | |
47 | - $types = array(); |
|
48 | - foreach($this->basic_model->get_field_types_basic_table() as $field_info) |
|
47 | + $types = array(); |
|
48 | + foreach ($this->basic_model->get_field_types_basic_table() as $field_info) |
|
49 | 49 | { |
50 | - $field_info->required = !empty($this->required_fields) && in_array($field_info->name,$this->required_fields) ? true : false; |
|
50 | + $field_info->required = !empty($this->required_fields) && in_array($field_info->name, $this->required_fields) ? true : false; |
|
51 | 51 | |
52 | 52 | $field_info->display_as = |
53 | 53 | isset($this->display_as[$field_info->name]) ? |
54 | - $this->display_as[$field_info->name] : |
|
55 | - ucfirst(str_replace("_"," ",$field_info->name)); |
|
54 | + $this->display_as[$field_info->name] : ucfirst(str_replace("_", " ", $field_info->name)); |
|
56 | 55 | |
57 | - if($this->change_field_type !== null && isset($this->change_field_type[$field_info->name])) |
|
56 | + if ($this->change_field_type !== null && isset($this->change_field_type[$field_info->name])) |
|
58 | 57 | { |
59 | - $field_type = $this->change_field_type[$field_info->name]; |
|
58 | + $field_type = $this->change_field_type[$field_info->name]; |
|
60 | 59 | |
61 | 60 | if (isset($this->relation[$field_info->name])) { |
62 | 61 | $field_info->crud_type = "relation_".$field_type->type; |
@@ -64,21 +63,21 @@ discard block |
||
64 | 63 | elseif (isset($this->upload_fields[$field_info->name])) { |
65 | 64 | $field_info->crud_type = "upload_file_".$field_type->type; |
66 | 65 | } else { |
67 | - $field_info->crud_type = $field_type->type; |
|
68 | - $field_info->extras = $field_type->extras; |
|
66 | + $field_info->crud_type = $field_type->type; |
|
67 | + $field_info->extras = $field_type->extras; |
|
69 | 68 | } |
70 | 69 | |
71 | - $real_type = $field_info->crud_type; |
|
70 | + $real_type = $field_info->crud_type; |
|
72 | 71 | } |
73 | - elseif(isset($this->relation[$field_info->name])) |
|
72 | + elseif (isset($this->relation[$field_info->name])) |
|
74 | 73 | { |
75 | - $real_type = 'relation'; |
|
76 | - $field_info->crud_type = 'relation'; |
|
74 | + $real_type = 'relation'; |
|
75 | + $field_info->crud_type = 'relation'; |
|
77 | 76 | } |
78 | - elseif(isset($this->upload_fields[$field_info->name])) |
|
77 | + elseif (isset($this->upload_fields[$field_info->name])) |
|
79 | 78 | { |
80 | - $real_type = 'upload_file'; |
|
81 | - $field_info->crud_type = 'upload_file'; |
|
79 | + $real_type = 'upload_file'; |
|
80 | + $field_info->crud_type = 'upload_file'; |
|
82 | 81 | } |
83 | 82 | else |
84 | 83 | { |
@@ -88,7 +87,7 @@ discard block |
||
88 | 87 | |
89 | 88 | switch ($real_type) { |
90 | 89 | case 'text': |
91 | - if(!empty($this->unset_texteditor) && in_array($field_info->name,$this->unset_texteditor)) |
|
90 | + if (!empty($this->unset_texteditor) && in_array($field_info->name, $this->unset_texteditor)) |
|
92 | 91 | $field_info->extras = false; |
93 | 92 | else |
94 | 93 | $field_info->extras = 'text_editor'; |
@@ -96,16 +95,16 @@ discard block |
||
96 | 95 | |
97 | 96 | case 'relation': |
98 | 97 | case 'relation_readonly': |
99 | - $field_info->extras = $this->relation[$field_info->name]; |
|
98 | + $field_info->extras = $this->relation[$field_info->name]; |
|
100 | 99 | break; |
101 | 100 | |
102 | 101 | case 'upload_file': |
103 | 102 | case 'upload_file_readonly': |
104 | - $field_info->extras = $this->upload_fields[$field_info->name]; |
|
103 | + $field_info->extras = $this->upload_fields[$field_info->name]; |
|
105 | 104 | break; |
106 | 105 | |
107 | 106 | default: |
108 | - if(empty($field_info->extras)) |
|
107 | + if (empty($field_info->extras)) |
|
109 | 108 | $field_info->extras = false; |
110 | 109 | break; |
111 | 110 | } |
@@ -113,51 +112,48 @@ discard block |
||
113 | 112 | $types[$field_info->name] = $field_info; |
114 | 113 | } |
115 | 114 | |
116 | - if(!empty($this->relation_n_n)) |
|
115 | + if (!empty($this->relation_n_n)) |
|
117 | 116 | { |
118 | - foreach($this->relation_n_n as $field_name => $field_extras) |
|
117 | + foreach ($this->relation_n_n as $field_name => $field_extras) |
|
119 | 118 | { |
120 | 119 | $is_read_only = $this->change_field_type !== null |
121 | 120 | && isset($this->change_field_type[$field_name]) |
122 | 121 | && $this->change_field_type[$field_name]->type == 'readonly' |
123 | 122 | ? true : false; |
124 | - $field_info = (object)array(); |
|
125 | - $field_info->name = $field_name; |
|
123 | + $field_info = (object) array(); |
|
124 | + $field_info->name = $field_name; |
|
126 | 125 | $field_info->crud_type = $is_read_only ? 'readonly' : 'relation_n_n'; |
127 | - $field_info->extras = $field_extras; |
|
128 | - $field_info->required = !empty($this->required_fields) && in_array($field_name,$this->required_fields) ? true : false;; |
|
126 | + $field_info->extras = $field_extras; |
|
127 | + $field_info->required = !empty($this->required_fields) && in_array($field_name, $this->required_fields) ? true : false; ; |
|
129 | 128 | $field_info->display_as = |
130 | 129 | isset($this->display_as[$field_name]) ? |
131 | - $this->display_as[$field_name] : |
|
132 | - ucfirst(str_replace("_"," ",$field_name)); |
|
130 | + $this->display_as[$field_name] : ucfirst(str_replace("_", " ", $field_name)); |
|
133 | 131 | |
134 | 132 | $types[$field_name] = $field_info; |
135 | 133 | } |
136 | 134 | } |
137 | 135 | |
138 | - if(!empty($this->add_fields)) |
|
139 | - foreach($this->add_fields as $field_object) |
|
136 | + if (!empty($this->add_fields)) |
|
137 | + foreach ($this->add_fields as $field_object) |
|
140 | 138 | { |
141 | 139 | $field_name = isset($field_object->field_name) ? $field_object->field_name : $field_object; |
142 | 140 | |
143 | - if(!isset($types[$field_name]))//Doesn't exist in the database? Create it for the CRUD |
|
141 | + if (!isset($types[$field_name]))//Doesn't exist in the database? Create it for the CRUD |
|
144 | 142 | { |
145 | 143 | $extras = false; |
146 | - if($this->change_field_type !== null && isset($this->change_field_type[$field_name])) |
|
144 | + if ($this->change_field_type !== null && isset($this->change_field_type[$field_name])) |
|
147 | 145 | { |
148 | 146 | $field_type = $this->change_field_type[$field_name]; |
149 | - $extras = $field_type->extras; |
|
147 | + $extras = $field_type->extras; |
|
150 | 148 | } |
151 | 149 | |
152 | - $field_info = (object)array( |
|
150 | + $field_info = (object) array( |
|
153 | 151 | 'name' => $field_name, |
154 | 152 | 'crud_type' => $this->change_field_type !== null && isset($this->change_field_type[$field_name]) ? |
155 | - $this->change_field_type[$field_name]->type : |
|
156 | - 'string', |
|
153 | + $this->change_field_type[$field_name]->type : 'string', |
|
157 | 154 | 'display_as' => isset($this->display_as[$field_name]) ? |
158 | - $this->display_as[$field_name] : |
|
159 | - ucfirst(str_replace("_"," ",$field_name)), |
|
160 | - 'required' => !empty($this->required_fields) && in_array($field_name,$this->required_fields) ? true : false, |
|
155 | + $this->display_as[$field_name] : ucfirst(str_replace("_", " ", $field_name)), |
|
156 | + 'required' => !empty($this->required_fields) && in_array($field_name, $this->required_fields) ? true : false, |
|
161 | 157 | 'extras' => $extras |
162 | 158 | ); |
163 | 159 | |
@@ -165,29 +161,27 @@ discard block |
||
165 | 161 | } |
166 | 162 | } |
167 | 163 | |
168 | - if(!empty($this->edit_fields)) |
|
169 | - foreach($this->edit_fields as $field_object) |
|
164 | + if (!empty($this->edit_fields)) |
|
165 | + foreach ($this->edit_fields as $field_object) |
|
170 | 166 | { |
171 | 167 | $field_name = isset($field_object->field_name) ? $field_object->field_name : $field_object; |
172 | 168 | |
173 | - if(!isset($types[$field_name]))//Doesn't exist in the database? Create it for the CRUD |
|
169 | + if (!isset($types[$field_name]))//Doesn't exist in the database? Create it for the CRUD |
|
174 | 170 | { |
175 | 171 | $extras = false; |
176 | - if($this->change_field_type !== null && isset($this->change_field_type[$field_name])) |
|
172 | + if ($this->change_field_type !== null && isset($this->change_field_type[$field_name])) |
|
177 | 173 | { |
178 | 174 | $field_type = $this->change_field_type[$field_name]; |
179 | - $extras = $field_type->extras; |
|
175 | + $extras = $field_type->extras; |
|
180 | 176 | } |
181 | 177 | |
182 | - $field_info = (object)array( |
|
178 | + $field_info = (object) array( |
|
183 | 179 | 'name' => $field_name, |
184 | 180 | 'crud_type' => $this->change_field_type !== null && isset($this->change_field_type[$field_name]) ? |
185 | - $this->change_field_type[$field_name]->type : |
|
186 | - 'string', |
|
181 | + $this->change_field_type[$field_name]->type : 'string', |
|
187 | 182 | 'display_as' => isset($this->display_as[$field_name]) ? |
188 | - $this->display_as[$field_name] : |
|
189 | - ucfirst(str_replace("_"," ",$field_name)), |
|
190 | - 'required' => in_array($field_name,$this->required_fields) ? true : false, |
|
183 | + $this->display_as[$field_name] : ucfirst(str_replace("_", " ", $field_name)), |
|
184 | + 'required' => in_array($field_name, $this->required_fields) ? true : false, |
|
191 | 185 | 'extras' => $extras |
192 | 186 | ); |
193 | 187 | |
@@ -238,16 +232,16 @@ discard block |
||
238 | 232 | 'multiselect' |
239 | 233 | ); |
240 | 234 | |
241 | - if (in_array($real_type,$types_array)) { |
|
235 | + if (in_array($real_type, $types_array)) { |
|
242 | 236 | /* A quick way to go to an internal method of type $this->get_{type}_input . |
243 | 237 | * For example if the real type is integer then we will use the method |
244 | 238 | * $this->get_integer_input |
245 | 239 | * */ |
246 | - $field_info->input = $this->{"get_".$real_type."_input"}($field_info,$value); |
|
240 | + $field_info->input = $this->{"get_".$real_type."_input"}($field_info, $value); |
|
247 | 241 | } |
248 | 242 | else |
249 | 243 | { |
250 | - $field_info->input = $this->get_string_input($field_info,$value); |
|
244 | + $field_info->input = $this->get_string_input($field_info, $value); |
|
251 | 245 | } |
252 | 246 | |
253 | 247 | return $field_info; |
@@ -264,24 +258,24 @@ discard block |
||
264 | 258 | |
265 | 259 | break; |
266 | 260 | case 'true_false': |
267 | - if(is_array($field_info->extras) && array_key_exists($value,$field_info->extras)) { |
|
261 | + if (is_array($field_info->extras) && array_key_exists($value, $field_info->extras)) { |
|
268 | 262 | $value = $field_info->extras[$value]; |
269 | - } else if(isset($this->default_true_false_text[$value])) { |
|
263 | + } else if (isset($this->default_true_false_text[$value])) { |
|
270 | 264 | $value = $this->default_true_false_text[$value]; |
271 | 265 | } |
272 | 266 | break; |
273 | 267 | case 'string': |
274 | - $value = $this->character_limiter($value,$this->character_limiter,"..."); |
|
268 | + $value = $this->character_limiter($value, $this->character_limiter, "..."); |
|
275 | 269 | break; |
276 | 270 | case 'text': |
277 | - $value = $this->character_limiter(strip_tags($value),$this->character_limiter,"..."); |
|
271 | + $value = $this->character_limiter(strip_tags($value), $this->character_limiter, "..."); |
|
278 | 272 | break; |
279 | 273 | case 'date': |
280 | - if(!empty($value) && $value != '0000-00-00' && $value != '1970-01-01') |
|
274 | + if (!empty($value) && $value != '0000-00-00' && $value != '1970-01-01') |
|
281 | 275 | { |
282 | - list($year,$month,$day) = explode("-",$value); |
|
276 | + list($year, $month, $day) = explode("-", $value); |
|
283 | 277 | |
284 | - $value = date($this->php_date_format, mktime (0, 0, 0, (int)$month , (int)$day , (int)$year)); |
|
278 | + $value = date($this->php_date_format, mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)); |
|
285 | 279 | } |
286 | 280 | else |
287 | 281 | { |
@@ -289,12 +283,12 @@ discard block |
||
289 | 283 | } |
290 | 284 | break; |
291 | 285 | case 'datetime': |
292 | - if(!empty($value) && $value != '0000-00-00 00:00:00' && $value != '1970-01-01 00:00:00') |
|
286 | + if (!empty($value) && $value != '0000-00-00 00:00:00' && $value != '1970-01-01 00:00:00') |
|
293 | 287 | { |
294 | - list($year,$month,$day) = explode("-",$value); |
|
295 | - list($hours,$minutes) = explode(":",substr($value,11)); |
|
288 | + list($year, $month, $day) = explode("-", $value); |
|
289 | + list($hours, $minutes) = explode(":", substr($value, 11)); |
|
296 | 290 | |
297 | - $value = date($this->php_date_format." - H:i", mktime ((int)$hours , (int)$minutes , 0, (int)$month , (int)$day ,(int)$year)); |
|
291 | + $value = date($this->php_date_format." - H:i", mktime((int) $hours, (int) $minutes, 0, (int) $month, (int) $day, (int) $year)); |
|
298 | 292 | } |
299 | 293 | else |
300 | 294 | { |
@@ -302,20 +296,20 @@ discard block |
||
302 | 296 | } |
303 | 297 | break; |
304 | 298 | case 'enum': |
305 | - $value = $this->character_limiter($value,$this->character_limiter,"..."); |
|
299 | + $value = $this->character_limiter($value, $this->character_limiter, "..."); |
|
306 | 300 | break; |
307 | 301 | |
308 | 302 | case 'multiselect': |
309 | 303 | $value_as_array = array(); |
310 | - foreach(explode(",",$value) as $row_value) |
|
304 | + foreach (explode(",", $value) as $row_value) |
|
311 | 305 | { |
312 | - $value_as_array[] = array_key_exists($row_value,$field_info->extras) ? $field_info->extras[$row_value] : $row_value; |
|
306 | + $value_as_array[] = array_key_exists($row_value, $field_info->extras) ? $field_info->extras[$row_value] : $row_value; |
|
313 | 307 | } |
314 | - $value = implode(",",$value_as_array); |
|
308 | + $value = implode(",", $value_as_array); |
|
315 | 309 | break; |
316 | 310 | |
317 | 311 | case 'relation_n_n': |
318 | - $value = $this->character_limiter(str_replace(',',', ',$value),$this->character_limiter,"..."); |
|
312 | + $value = $this->character_limiter(str_replace(',', ', ', $value), $this->character_limiter, "..."); |
|
319 | 313 | break; |
320 | 314 | |
321 | 315 | case 'password': |
@@ -323,34 +317,34 @@ discard block |
||
323 | 317 | break; |
324 | 318 | |
325 | 319 | case 'dropdown': |
326 | - $value = array_key_exists($value,$field_info->extras) ? $field_info->extras[$value] : $value; |
|
320 | + $value = array_key_exists($value, $field_info->extras) ? $field_info->extras[$value] : $value; |
|
327 | 321 | break; |
328 | 322 | |
329 | 323 | case 'upload_file': |
330 | - if(empty($value)) |
|
324 | + if (empty($value)) |
|
331 | 325 | { |
332 | 326 | $value = ""; |
333 | 327 | } |
334 | 328 | else |
335 | 329 | { |
336 | 330 | $is_image = !empty($value) && |
337 | - ( substr($value,-4) == '.jpg' |
|
338 | - || substr($value,-4) == '.png' |
|
339 | - || substr($value,-5) == '.jpeg' |
|
340 | - || substr($value,-4) == '.gif' |
|
341 | - || substr($value,-5) == '.tiff') |
|
331 | + (substr($value, -4) == '.jpg' |
|
332 | + || substr($value, -4) == '.png' |
|
333 | + || substr($value, -5) == '.jpeg' |
|
334 | + || substr($value, -4) == '.gif' |
|
335 | + || substr($value, -5) == '.tiff') |
|
342 | 336 | ? true : false; |
343 | 337 | |
344 | 338 | $file_url = base_url().$field_info->extras->upload_path."/$value"; |
345 | 339 | |
346 | 340 | $file_url_anchor = '<a href="'.$file_url.'"'; |
347 | - if($is_image) |
|
341 | + if ($is_image) |
|
348 | 342 | { |
349 | 343 | $file_url_anchor .= ' class="image-thumbnail"><img src="'.$file_url.'" height="50px">'; |
350 | 344 | } |
351 | 345 | else |
352 | 346 | { |
353 | - $file_url_anchor .= ' target="_blank">'.$this->character_limiter($value,$this->character_limiter,'...',true); |
|
347 | + $file_url_anchor .= ' target="_blank">'.$this->character_limiter($value, $this->character_limiter, '...', true); |
|
354 | 348 | } |
355 | 349 | $file_url_anchor .= '</a>'; |
356 | 350 | |
@@ -359,7 +353,7 @@ discard block |
||
359 | 353 | break; |
360 | 354 | |
361 | 355 | default: |
362 | - $value = $this->character_limiter($value,$this->character_limiter,"..."); |
|
356 | + $value = $this->character_limiter($value, $this->character_limiter, "..."); |
|
363 | 357 | break; |
364 | 358 | } |
365 | 359 | |
@@ -409,7 +403,7 @@ discard block |
||
409 | 403 | protected function get_type($db_type) |
410 | 404 | { |
411 | 405 | $type = false; |
412 | - if(!empty($db_type->type)) |
|
406 | + if (!empty($db_type->type)) |
|
413 | 407 | { |
414 | 408 | switch ($db_type->type) { |
415 | 409 | case '1': |
@@ -418,7 +412,7 @@ discard block |
||
418 | 412 | case 'tinyint': |
419 | 413 | case 'mediumint': |
420 | 414 | case 'longint': |
421 | - if( $db_type->db_type == 'tinyint' && $db_type->db_max_length == 1) |
|
415 | + if ($db_type->db_type == 'tinyint' && $db_type->db_max_length == 1) |
|
422 | 416 | $type = 'true_false'; |
423 | 417 | else |
424 | 418 | $type = 'integer'; |
@@ -426,13 +420,13 @@ discard block |
||
426 | 420 | case '254': |
427 | 421 | case 'string': |
428 | 422 | case 'enum': |
429 | - if($db_type->db_type != 'enum') |
|
423 | + if ($db_type->db_type != 'enum') |
|
430 | 424 | $type = 'string'; |
431 | 425 | else |
432 | 426 | $type = 'enum'; |
433 | 427 | break; |
434 | 428 | case 'set': |
435 | - if($db_type->db_type != 'set') |
|
429 | + if ($db_type->db_type != 'set') |
|
436 | 430 | $type = 'string'; |
437 | 431 | else |
438 | 432 | $type = 'set'; |
@@ -488,41 +482,41 @@ discard block |
||
488 | 482 | |
489 | 483 | protected function get_total_results() |
490 | 484 | { |
491 | - if(!empty($this->where)) |
|
492 | - foreach($this->where as $where) |
|
493 | - $this->basic_model->where($where[0],$where[1],$where[2]); |
|
485 | + if (!empty($this->where)) |
|
486 | + foreach ($this->where as $where) |
|
487 | + $this->basic_model->where($where[0], $where[1], $where[2]); |
|
494 | 488 | |
495 | - if(!empty($this->or_where)) |
|
496 | - foreach($this->or_where as $or_where) |
|
497 | - $this->basic_model->or_where($or_where[0],$or_where[1],$or_where[2]); |
|
489 | + if (!empty($this->or_where)) |
|
490 | + foreach ($this->or_where as $or_where) |
|
491 | + $this->basic_model->or_where($or_where[0], $or_where[1], $or_where[2]); |
|
498 | 492 | |
499 | - if(!empty($this->like)) |
|
500 | - foreach($this->like as $like) |
|
501 | - $this->basic_model->like($like[0],$like[1],$like[2]); |
|
493 | + if (!empty($this->like)) |
|
494 | + foreach ($this->like as $like) |
|
495 | + $this->basic_model->like($like[0], $like[1], $like[2]); |
|
502 | 496 | |
503 | - if(!empty($this->or_like)) |
|
504 | - foreach($this->or_like as $or_like) |
|
505 | - $this->basic_model->or_like($or_like[0],$or_like[1],$or_like[2]); |
|
497 | + if (!empty($this->or_like)) |
|
498 | + foreach ($this->or_like as $or_like) |
|
499 | + $this->basic_model->or_like($or_like[0], $or_like[1], $or_like[2]); |
|
506 | 500 | |
507 | - if(!empty($this->having)) |
|
508 | - foreach($this->having as $having) |
|
509 | - $this->basic_model->having($having[0],$having[1],$having[2]); |
|
501 | + if (!empty($this->having)) |
|
502 | + foreach ($this->having as $having) |
|
503 | + $this->basic_model->having($having[0], $having[1], $having[2]); |
|
510 | 504 | |
511 | - if(!empty($this->or_having)) |
|
512 | - foreach($this->or_having as $or_having) |
|
513 | - $this->basic_model->or_having($or_having[0],$or_having[1],$or_having[2]); |
|
505 | + if (!empty($this->or_having)) |
|
506 | + foreach ($this->or_having as $or_having) |
|
507 | + $this->basic_model->or_having($or_having[0], $or_having[1], $or_having[2]); |
|
514 | 508 | |
515 | - if(!empty($this->relation)) |
|
516 | - foreach($this->relation as $relation) |
|
517 | - $this->basic_model->join_relation($relation[0],$relation[1],$relation[2]); |
|
509 | + if (!empty($this->relation)) |
|
510 | + foreach ($this->relation as $relation) |
|
511 | + $this->basic_model->join_relation($relation[0], $relation[1], $relation[2]); |
|
518 | 512 | |
519 | - if(!empty($this->relation_n_n)) |
|
513 | + if (!empty($this->relation_n_n)) |
|
520 | 514 | { |
521 | 515 | $columns = $this->get_columns(); |
522 | - foreach($columns as $column) |
|
516 | + foreach ($columns as $column) |
|
523 | 517 | { |
524 | 518 | //Use the relation_n_n ONLY if the column is called . The set_relation_n_n are slow and it will make the table slower without any reason as we don't need those queries. |
525 | - if(isset($this->relation_n_n[$column->field_name])) |
|
519 | + if (isset($this->relation_n_n[$column->field_name])) |
|
526 | 520 | { |
527 | 521 | $this->basic_model->set_relation_n_n_field($this->relation_n_n[$column->field_name]); |
528 | 522 | } |
@@ -540,9 +534,9 @@ discard block |
||
540 | 534 | |
541 | 535 | $ci->load->model($model_name); |
542 | 536 | |
543 | - $temp = explode('/',$model_name); |
|
537 | + $temp = explode('/', $model_name); |
|
544 | 538 | krsort($temp); |
545 | - foreach($temp as $t) |
|
539 | + foreach ($temp as $t) |
|
546 | 540 | { |
547 | 541 | $real_model_name = $t; |
548 | 542 | break; |
@@ -553,23 +547,23 @@ discard block |
||
553 | 547 | |
554 | 548 | protected function set_ajax_list_queries($state_info = null) |
555 | 549 | { |
556 | - if(!empty($state_info->per_page)) |
|
550 | + if (!empty($state_info->per_page)) |
|
557 | 551 | { |
558 | - if(empty($state_info->page) || !is_numeric($state_info->page) ) |
|
552 | + if (empty($state_info->page) || !is_numeric($state_info->page)) |
|
559 | 553 | $this->limit($state_info->per_page); |
560 | 554 | else |
561 | 555 | { |
562 | - $limit_page = ( ($state_info->page-1) * $state_info->per_page ); |
|
556 | + $limit_page = (($state_info->page - 1) * $state_info->per_page); |
|
563 | 557 | $this->limit($state_info->per_page, $limit_page); |
564 | 558 | } |
565 | 559 | } |
566 | 560 | |
567 | - if(!empty($state_info->order_by)) |
|
561 | + if (!empty($state_info->order_by)) |
|
568 | 562 | { |
569 | - $this->order_by($state_info->order_by[0],$state_info->order_by[1]); |
|
563 | + $this->order_by($state_info->order_by[0], $state_info->order_by[1]); |
|
570 | 564 | } |
571 | 565 | |
572 | - if(!empty($state_info->search)) |
|
566 | + if (!empty($state_info->search)) |
|
573 | 567 | { |
574 | 568 | if (!empty($this->relation)) { |
575 | 569 | foreach ($this->relation as $relation_name => $relation_values) { |
@@ -584,12 +578,12 @@ discard block |
||
584 | 578 | if (isset($temp_relation[$search_field])) { |
585 | 579 | if (is_array($temp_relation[$search_field])) { |
586 | 580 | foreach ($temp_relation[$search_field] as $relation_field) { |
587 | - $this->or_like($relation_field , $search_text); |
|
581 | + $this->or_like($relation_field, $search_text); |
|
588 | 582 | } |
589 | 583 | } else { |
590 | - $this->like($temp_relation[$search_field] , $search_text); |
|
584 | + $this->like($temp_relation[$search_field], $search_text); |
|
591 | 585 | } |
592 | - } elseif(isset($this->relation_n_n[$search_field])) { |
|
586 | + } elseif (isset($this->relation_n_n[$search_field])) { |
|
593 | 587 | $escaped_text = $this->basic_model->escape_str($search_text); |
594 | 588 | $this->having($search_field." LIKE '%".$escaped_text."%'"); |
595 | 589 | } else { |
@@ -603,16 +597,16 @@ discard block |
||
603 | 597 | if (isset($temp_relation[$state_info->search->field])) { |
604 | 598 | if (is_array($temp_relation[$state_info->search->field])) { |
605 | 599 | foreach ($temp_relation[$state_info->search->field] as $search_field) { |
606 | - $this->or_like($search_field , $state_info->search->text); |
|
600 | + $this->or_like($search_field, $state_info->search->text); |
|
607 | 601 | } |
608 | 602 | } else { |
609 | - $this->like($temp_relation[$state_info->search->field] , $state_info->search->text); |
|
603 | + $this->like($temp_relation[$state_info->search->field], $state_info->search->text); |
|
610 | 604 | } |
611 | - } elseif(isset($this->relation_n_n[$state_info->search->field])) { |
|
605 | + } elseif (isset($this->relation_n_n[$state_info->search->field])) { |
|
612 | 606 | $escaped_text = $this->basic_model->escape_str($state_info->search->text); |
613 | 607 | $this->having($state_info->search->field." LIKE '%".$escaped_text."%'"); |
614 | 608 | } else { |
615 | - $this->like($state_info->search->field , $state_info->search->text); |
|
609 | + $this->like($state_info->search->field, $state_info->search->text); |
|
616 | 610 | } |
617 | 611 | } |
618 | 612 | else |
@@ -621,17 +615,17 @@ discard block |
||
621 | 615 | |
622 | 616 | $search_text = $state_info->search->text; |
623 | 617 | |
624 | - if(!empty($this->where)) |
|
625 | - foreach($this->where as $where) |
|
626 | - $this->basic_model->having($where[0],$where[1],$where[2]); |
|
618 | + if (!empty($this->where)) |
|
619 | + foreach ($this->where as $where) |
|
620 | + $this->basic_model->having($where[0], $where[1], $where[2]); |
|
627 | 621 | |
628 | - foreach($columns as $column) |
|
622 | + foreach ($columns as $column) |
|
629 | 623 | { |
630 | - if(isset($temp_relation[$column->field_name])) |
|
624 | + if (isset($temp_relation[$column->field_name])) |
|
631 | 625 | { |
632 | - if(is_array($temp_relation[$column->field_name])) |
|
626 | + if (is_array($temp_relation[$column->field_name])) |
|
633 | 627 | { |
634 | - foreach($temp_relation[$column->field_name] as $search_field) |
|
628 | + foreach ($temp_relation[$column->field_name] as $search_field) |
|
635 | 629 | { |
636 | 630 | $this->or_like($search_field, $search_text); |
637 | 631 | } |
@@ -641,7 +635,7 @@ discard block |
||
641 | 635 | $this->or_like($temp_relation[$column->field_name], $search_text); |
642 | 636 | } |
643 | 637 | } |
644 | - elseif(isset($this->relation_n_n[$column->field_name])) |
|
638 | + elseif (isset($this->relation_n_n[$column->field_name])) |
|
645 | 639 | { |
646 | 640 | //@todo have a where for the relation_n_n statement |
647 | 641 | } |
@@ -656,16 +650,16 @@ discard block |
||
656 | 650 | |
657 | 651 | protected function table_exists($table_name = null) |
658 | 652 | { |
659 | - if($this->basic_model->db_table_exists($table_name)) |
|
653 | + if ($this->basic_model->db_table_exists($table_name)) |
|
660 | 654 | return true; |
661 | 655 | return false; |
662 | 656 | } |
663 | 657 | |
664 | 658 | protected function get_relation_array($relation_info, $primary_key_value = null, $limit = null) |
665 | 659 | { |
666 | - list($field_name , $related_table , $related_field_title, $where_clause, $order_by) = $relation_info; |
|
660 | + list($field_name, $related_table, $related_field_title, $where_clause, $order_by) = $relation_info; |
|
667 | 661 | |
668 | - if($primary_key_value !== null) |
|
662 | + if ($primary_key_value !== null) |
|
669 | 663 | { |
670 | 664 | $primary_key = $this->basic_model->get_primary_key($related_table); |
671 | 665 | |
@@ -673,59 +667,59 @@ discard block |
||
673 | 667 | $where_clause = array($primary_key => $primary_key_value); |
674 | 668 | } |
675 | 669 | |
676 | - $relation_array = $this->basic_model->get_relation_array($field_name , $related_table , $related_field_title, $where_clause, $order_by, $limit); |
|
670 | + $relation_array = $this->basic_model->get_relation_array($field_name, $related_table, $related_field_title, $where_clause, $order_by, $limit); |
|
677 | 671 | |
678 | 672 | return $relation_array; |
679 | 673 | } |
680 | 674 | |
681 | 675 | protected function get_relation_total_rows($relation_info) |
682 | 676 | { |
683 | - list($field_name , $related_table , $related_field_title, $where_clause) = $relation_info; |
|
677 | + list($field_name, $related_table, $related_field_title, $where_clause) = $relation_info; |
|
684 | 678 | |
685 | - $relation_array = $this->basic_model->get_relation_total_rows($field_name , $related_table , $related_field_title, $where_clause); |
|
679 | + $relation_array = $this->basic_model->get_relation_total_rows($field_name, $related_table, $related_field_title, $where_clause); |
|
686 | 680 | |
687 | 681 | return $relation_array; |
688 | 682 | } |
689 | 683 | |
690 | 684 | protected function db_insert_validation() |
691 | 685 | { |
692 | - $validation_result = (object)array('success'=>false); |
|
686 | + $validation_result = (object) array('success'=>false); |
|
693 | 687 | |
694 | 688 | $field_types = $this->get_field_types(); |
695 | 689 | $required_fields = $this->required_fields; |
696 | 690 | $unique_fields = $this->_unique_fields; |
697 | 691 | $add_fields = $this->get_add_fields(); |
698 | 692 | |
699 | - if(!empty($required_fields)) |
|
693 | + if (!empty($required_fields)) |
|
700 | 694 | { |
701 | - foreach($add_fields as $add_field) |
|
695 | + foreach ($add_fields as $add_field) |
|
702 | 696 | { |
703 | 697 | $field_name = $add_field->field_name; |
704 | - if(!isset($this->validation_rules[$field_name]) && in_array( $field_name, $required_fields) ) |
|
698 | + if (!isset($this->validation_rules[$field_name]) && in_array($field_name, $required_fields)) |
|
705 | 699 | { |
706 | - $this->set_rules( $field_name, $field_types[$field_name]->display_as, 'required'); |
|
700 | + $this->set_rules($field_name, $field_types[$field_name]->display_as, 'required'); |
|
707 | 701 | } |
708 | 702 | } |
709 | 703 | } |
710 | 704 | |
711 | 705 | /** Checking for unique fields. If the field value is not unique then |
712 | 706 | * return a validation error straight away, if not continue... */ |
713 | - if(!empty($unique_fields)) |
|
707 | + if (!empty($unique_fields)) |
|
714 | 708 | { |
715 | 709 | $form_validation = $this->form_validation(); |
716 | 710 | |
717 | - foreach($add_fields as $add_field) |
|
711 | + foreach ($add_fields as $add_field) |
|
718 | 712 | { |
719 | 713 | $field_name = $add_field->field_name; |
720 | - if(in_array( $field_name, $unique_fields) ) |
|
714 | + if (in_array($field_name, $unique_fields)) |
|
721 | 715 | { |
722 | - $form_validation->set_rules( $field_name, |
|
716 | + $form_validation->set_rules($field_name, |
|
723 | 717 | $field_types[$field_name]->display_as, |
724 | 718 | 'is_unique['.$this->basic_db_table.'.'.$field_name.']'); |
725 | 719 | } |
726 | 720 | } |
727 | 721 | |
728 | - if(!$form_validation->run()) |
|
722 | + if (!$form_validation->run()) |
|
729 | 723 | { |
730 | 724 | $validation_result->error_message = $form_validation->error_string(); |
731 | 725 | $validation_result->error_fields = $form_validation->_error_array; |
@@ -734,23 +728,23 @@ discard block |
||
734 | 728 | } |
735 | 729 | } |
736 | 730 | |
737 | - if(!empty($this->validation_rules)) |
|
731 | + if (!empty($this->validation_rules)) |
|
738 | 732 | { |
739 | 733 | $form_validation = $this->form_validation(); |
740 | 734 | |
741 | 735 | $add_fields = $this->get_add_fields(); |
742 | 736 | |
743 | - foreach($add_fields as $add_field) |
|
737 | + foreach ($add_fields as $add_field) |
|
744 | 738 | { |
745 | 739 | $field_name = $add_field->field_name; |
746 | - if(isset($this->validation_rules[$field_name])) |
|
740 | + if (isset($this->validation_rules[$field_name])) |
|
747 | 741 | { |
748 | 742 | $rule = $this->validation_rules[$field_name]; |
749 | - $form_validation->set_rules($rule['field'],$rule['label'],$rule['rules']); |
|
743 | + $form_validation->set_rules($rule['field'], $rule['label'], $rule['rules']); |
|
750 | 744 | } |
751 | 745 | } |
752 | 746 | |
753 | - if($form_validation->run()) |
|
747 | + if ($form_validation->run()) |
|
754 | 748 | { |
755 | 749 | $validation_result->success = true; |
756 | 750 | } |
@@ -770,7 +764,7 @@ discard block |
||
770 | 764 | |
771 | 765 | protected function form_validation() |
772 | 766 | { |
773 | - if($this->form_validation === null) |
|
767 | + if ($this->form_validation === null) |
|
774 | 768 | { |
775 | 769 | $this->form_validation = new grocery_CRUD_Form_validation(); |
776 | 770 | $ci = &get_instance(); |
@@ -782,21 +776,21 @@ discard block |
||
782 | 776 | |
783 | 777 | protected function db_update_validation() |
784 | 778 | { |
785 | - $validation_result = (object)array('success'=>false); |
|
779 | + $validation_result = (object) array('success'=>false); |
|
786 | 780 | |
787 | 781 | $field_types = $this->get_field_types(); |
788 | 782 | $required_fields = $this->required_fields; |
789 | 783 | $unique_fields = $this->_unique_fields; |
790 | 784 | $edit_fields = $this->get_edit_fields(); |
791 | 785 | |
792 | - if(!empty($required_fields)) |
|
786 | + if (!empty($required_fields)) |
|
793 | 787 | { |
794 | - foreach($edit_fields as $edit_field) |
|
788 | + foreach ($edit_fields as $edit_field) |
|
795 | 789 | { |
796 | 790 | $field_name = $edit_field->field_name; |
797 | - if(!isset($this->validation_rules[$field_name]) && in_array( $field_name, $required_fields) ) |
|
791 | + if (!isset($this->validation_rules[$field_name]) && in_array($field_name, $required_fields)) |
|
798 | 792 | { |
799 | - $this->set_rules( $field_name, $field_types[$field_name]->display_as, 'required'); |
|
793 | + $this->set_rules($field_name, $field_types[$field_name]->display_as, 'required'); |
|
800 | 794 | } |
801 | 795 | } |
802 | 796 | } |
@@ -804,25 +798,25 @@ discard block |
||
804 | 798 | |
805 | 799 | /** Checking for unique fields. If the field value is not unique then |
806 | 800 | * return a validation error straight away, if not continue... */ |
807 | - if(!empty($unique_fields)) |
|
801 | + if (!empty($unique_fields)) |
|
808 | 802 | { |
809 | 803 | $form_validation = $this->form_validation(); |
810 | 804 | |
811 | 805 | $form_validation_check = false; |
812 | 806 | |
813 | - foreach($edit_fields as $edit_field) |
|
807 | + foreach ($edit_fields as $edit_field) |
|
814 | 808 | { |
815 | 809 | $field_name = $edit_field->field_name; |
816 | - if(in_array( $field_name, $unique_fields) ) |
|
810 | + if (in_array($field_name, $unique_fields)) |
|
817 | 811 | { |
818 | 812 | $state_info = $this->getStateInfo(); |
819 | 813 | $primary_key = $this->get_primary_key(); |
820 | 814 | $field_name_value = $_POST[$field_name]; |
821 | 815 | |
822 | - $this->basic_model->where($primary_key,$state_info->primary_key); |
|
816 | + $this->basic_model->where($primary_key, $state_info->primary_key); |
|
823 | 817 | $row = $this->basic_model->get_row(); |
824 | 818 | |
825 | - if(!isset($row->$field_name)) { |
|
819 | + if (!isset($row->$field_name)) { |
|
826 | 820 | throw new Exception("The field name doesn't exist in the database. ". |
827 | 821 | "Please use the unique fields only for fields ". |
828 | 822 | "that exist in the database"); |
@@ -830,8 +824,8 @@ discard block |
||
830 | 824 | |
831 | 825 | $previous_field_name_value = $row->$field_name; |
832 | 826 | |
833 | - if(!empty($previous_field_name_value) && $previous_field_name_value != $field_name_value) { |
|
834 | - $form_validation->set_rules( $field_name, |
|
827 | + if (!empty($previous_field_name_value) && $previous_field_name_value != $field_name_value) { |
|
828 | + $form_validation->set_rules($field_name, |
|
835 | 829 | $field_types[$field_name]->display_as, |
836 | 830 | 'is_unique['.$this->basic_db_table.'.'.$field_name.']'); |
837 | 831 | |
@@ -840,7 +834,7 @@ discard block |
||
840 | 834 | } |
841 | 835 | } |
842 | 836 | |
843 | - if($form_validation_check && !$form_validation->run()) |
|
837 | + if ($form_validation_check && !$form_validation->run()) |
|
844 | 838 | { |
845 | 839 | $validation_result->error_message = $form_validation->error_string(); |
846 | 840 | $validation_result->error_fields = $form_validation->_error_array; |
@@ -849,23 +843,23 @@ discard block |
||
849 | 843 | } |
850 | 844 | } |
851 | 845 | |
852 | - if(!empty($this->validation_rules)) |
|
846 | + if (!empty($this->validation_rules)) |
|
853 | 847 | { |
854 | 848 | $form_validation = $this->form_validation(); |
855 | 849 | |
856 | 850 | $edit_fields = $this->get_edit_fields(); |
857 | 851 | |
858 | - foreach($edit_fields as $edit_field) |
|
852 | + foreach ($edit_fields as $edit_field) |
|
859 | 853 | { |
860 | 854 | $field_name = $edit_field->field_name; |
861 | - if(isset($this->validation_rules[$field_name])) |
|
855 | + if (isset($this->validation_rules[$field_name])) |
|
862 | 856 | { |
863 | 857 | $rule = $this->validation_rules[$field_name]; |
864 | - $form_validation->set_rules($rule['field'],$rule['label'],$rule['rules']); |
|
858 | + $form_validation->set_rules($rule['field'], $rule['label'], $rule['rules']); |
|
865 | 859 | } |
866 | 860 | } |
867 | 861 | |
868 | - if($form_validation->run()) |
|
862 | + if ($form_validation->run()) |
|
869 | 863 | { |
870 | 864 | $validation_result->success = true; |
871 | 865 | } |
@@ -887,59 +881,59 @@ discard block |
||
887 | 881 | { |
888 | 882 | $validation_result = $this->db_insert_validation(); |
889 | 883 | |
890 | - if($validation_result->success) |
|
884 | + if ($validation_result->success) |
|
891 | 885 | { |
892 | 886 | $post_data = $state_info->unwrapped_data; |
893 | 887 | |
894 | 888 | $add_fields = $this->get_add_fields(); |
895 | 889 | |
896 | - if($this->callback_insert === null) |
|
890 | + if ($this->callback_insert === null) |
|
897 | 891 | { |
898 | - if($this->callback_before_insert !== null) |
|
892 | + if ($this->callback_before_insert !== null) |
|
899 | 893 | { |
900 | 894 | $callback_return = call_user_func($this->callback_before_insert, $post_data); |
901 | 895 | |
902 | - if(!empty($callback_return) && is_array($callback_return)) |
|
896 | + if (!empty($callback_return) && is_array($callback_return)) |
|
903 | 897 | $post_data = $callback_return; |
904 | - elseif($callback_return === false) |
|
898 | + elseif ($callback_return === false) |
|
905 | 899 | return false; |
906 | 900 | } |
907 | 901 | |
908 | 902 | $insert_data = array(); |
909 | 903 | $types = $this->get_field_types(); |
910 | - foreach($add_fields as $num_row => $field) |
|
904 | + foreach ($add_fields as $num_row => $field) |
|
911 | 905 | { |
912 | 906 | /* If the multiselect or the set is empty then the browser doesn't send an empty array. Instead it sends nothing */ |
913 | - if(isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect') && !isset($post_data[$field->field_name])) |
|
907 | + if (isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect') && !isset($post_data[$field->field_name])) |
|
914 | 908 | { |
915 | 909 | $post_data[$field->field_name] = array(); |
916 | 910 | } |
917 | 911 | |
918 | - if(isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name])) |
|
912 | + if (isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name])) |
|
919 | 913 | { |
920 | - if(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name])) |
|
914 | + if (isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name])) |
|
921 | 915 | { |
922 | 916 | $insert_data[$field->field_name] = null; |
923 | 917 | } |
924 | - elseif(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && $post_data[$field->field_name] === '') |
|
918 | + elseif (isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && $post_data[$field->field_name] === '') |
|
925 | 919 | { |
926 | 920 | $insert_data[$field->field_name] = null; |
927 | 921 | } |
928 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'date') |
|
922 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'date') |
|
929 | 923 | { |
930 | 924 | $insert_data[$field->field_name] = $this->_convert_date_to_sql_date($post_data[$field->field_name]); |
931 | 925 | } |
932 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'readonly') |
|
926 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'readonly') |
|
933 | 927 | { |
934 | 928 | //This empty if statement is to make sure that a readonly field will never inserted/updated |
935 | 929 | } |
936 | - elseif(isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect')) |
|
930 | + elseif (isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect')) |
|
937 | 931 | { |
938 | - $insert_data[$field->field_name] = !empty($post_data[$field->field_name]) ? implode(',',$post_data[$field->field_name]) : ''; |
|
932 | + $insert_data[$field->field_name] = !empty($post_data[$field->field_name]) ? implode(',', $post_data[$field->field_name]) : ''; |
|
939 | 933 | } |
940 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'datetime'){ |
|
941 | - $insert_data[$field->field_name] = $this->_convert_date_to_sql_date(substr($post_data[$field->field_name],0,10)). |
|
942 | - substr($post_data[$field->field_name],10); |
|
934 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'datetime') { |
|
935 | + $insert_data[$field->field_name] = $this->_convert_date_to_sql_date(substr($post_data[$field->field_name], 0, 10)). |
|
936 | + substr($post_data[$field->field_name], 10); |
|
943 | 937 | } |
944 | 938 | else |
945 | 939 | { |
@@ -948,9 +942,9 @@ discard block |
||
948 | 942 | } |
949 | 943 | } |
950 | 944 | |
951 | - $insert_result = $this->basic_model->db_insert($insert_data); |
|
945 | + $insert_result = $this->basic_model->db_insert($insert_data); |
|
952 | 946 | |
953 | - if($insert_result !== false) |
|
947 | + if ($insert_result !== false) |
|
954 | 948 | { |
955 | 949 | $insert_primary_key = $insert_result; |
956 | 950 | } |
@@ -959,36 +953,36 @@ discard block |
||
959 | 953 | return false; |
960 | 954 | } |
961 | 955 | |
962 | - if(!empty($this->relation_n_n)) |
|
956 | + if (!empty($this->relation_n_n)) |
|
963 | 957 | { |
964 | - foreach($this->relation_n_n as $field_name => $field_info) |
|
958 | + foreach ($this->relation_n_n as $field_name => $field_info) |
|
965 | 959 | { |
966 | - $relation_data = isset( $post_data[$field_name] ) ? $post_data[$field_name] : array() ; |
|
967 | - $this->db_relation_n_n_update($field_info, $relation_data ,$insert_primary_key); |
|
960 | + $relation_data = isset($post_data[$field_name]) ? $post_data[$field_name] : array(); |
|
961 | + $this->db_relation_n_n_update($field_info, $relation_data, $insert_primary_key); |
|
968 | 962 | } |
969 | 963 | } |
970 | 964 | |
971 | - if($this->callback_after_insert !== null) |
|
965 | + if ($this->callback_after_insert !== null) |
|
972 | 966 | { |
973 | 967 | $callback_return = call_user_func($this->callback_after_insert, $post_data, $insert_primary_key); |
974 | 968 | |
975 | - if($callback_return === false) |
|
969 | + if ($callback_return === false) |
|
976 | 970 | { |
977 | 971 | return false; |
978 | 972 | } |
979 | 973 | |
980 | 974 | } |
981 | - }else |
|
975 | + } else |
|
982 | 976 | { |
983 | 977 | $callback_return = call_user_func($this->callback_insert, $post_data); |
984 | 978 | |
985 | - if($callback_return === false) |
|
979 | + if ($callback_return === false) |
|
986 | 980 | { |
987 | 981 | return false; |
988 | 982 | } |
989 | 983 | } |
990 | 984 | |
991 | - if(isset($insert_primary_key)) |
|
985 | + if (isset($insert_primary_key)) |
|
992 | 986 | return $insert_primary_key; |
993 | 987 | else |
994 | 988 | return true; |
@@ -1004,22 +998,22 @@ discard block |
||
1004 | 998 | |
1005 | 999 | $edit_fields = $this->get_edit_fields(); |
1006 | 1000 | |
1007 | - if($validation_result->success) |
|
1001 | + if ($validation_result->success) |
|
1008 | 1002 | { |
1009 | - $post_data = $state_info->unwrapped_data; |
|
1010 | - $primary_key = $state_info->primary_key; |
|
1003 | + $post_data = $state_info->unwrapped_data; |
|
1004 | + $primary_key = $state_info->primary_key; |
|
1011 | 1005 | |
1012 | - if($this->callback_update === null) |
|
1006 | + if ($this->callback_update === null) |
|
1013 | 1007 | { |
1014 | - if($this->callback_before_update !== null) |
|
1008 | + if ($this->callback_before_update !== null) |
|
1015 | 1009 | { |
1016 | 1010 | $callback_return = call_user_func($this->callback_before_update, $post_data, $primary_key); |
1017 | 1011 | |
1018 | - if(!empty($callback_return) && is_array($callback_return)) |
|
1012 | + if (!empty($callback_return) && is_array($callback_return)) |
|
1019 | 1013 | { |
1020 | 1014 | $post_data = $callback_return; |
1021 | 1015 | } |
1022 | - elseif($callback_return === false) |
|
1016 | + elseif ($callback_return === false) |
|
1023 | 1017 | { |
1024 | 1018 | return false; |
1025 | 1019 | } |
@@ -1028,39 +1022,39 @@ discard block |
||
1028 | 1022 | |
1029 | 1023 | $update_data = array(); |
1030 | 1024 | $types = $this->get_field_types(); |
1031 | - foreach($edit_fields as $num_row => $field) |
|
1025 | + foreach ($edit_fields as $num_row => $field) |
|
1032 | 1026 | { |
1033 | 1027 | /* If the multiselect or the set is empty then the browser doesn't send an empty array. Instead it sends nothing */ |
1034 | - if(isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect') && !isset($post_data[$field->field_name])) |
|
1028 | + if (isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect') && !isset($post_data[$field->field_name])) |
|
1035 | 1029 | { |
1036 | 1030 | $post_data[$field->field_name] = array(); |
1037 | 1031 | } |
1038 | 1032 | |
1039 | - if(isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name])) |
|
1033 | + if (isset($post_data[$field->field_name]) && !isset($this->relation_n_n[$field->field_name])) |
|
1040 | 1034 | { |
1041 | - if(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name])) |
|
1035 | + if (isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && is_array($post_data[$field->field_name]) && empty($post_data[$field->field_name])) |
|
1042 | 1036 | { |
1043 | 1037 | $update_data[$field->field_name] = null; |
1044 | 1038 | } |
1045 | - elseif(isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && $post_data[$field->field_name] === '') |
|
1039 | + elseif (isset($types[$field->field_name]->db_null) && $types[$field->field_name]->db_null && $post_data[$field->field_name] === '') |
|
1046 | 1040 | { |
1047 | 1041 | $update_data[$field->field_name] = null; |
1048 | 1042 | } |
1049 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'date') |
|
1043 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'date') |
|
1050 | 1044 | { |
1051 | 1045 | $update_data[$field->field_name] = $this->_convert_date_to_sql_date($post_data[$field->field_name]); |
1052 | 1046 | } |
1053 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'readonly') |
|
1047 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'readonly') |
|
1054 | 1048 | { |
1055 | 1049 | //This empty if statement is to make sure that a readonly field will never inserted/updated |
1056 | 1050 | } |
1057 | - elseif(isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect')) |
|
1051 | + elseif (isset($types[$field->field_name]->crud_type) && ($types[$field->field_name]->crud_type == 'set' || $types[$field->field_name]->crud_type == 'multiselect')) |
|
1058 | 1052 | { |
1059 | - $update_data[$field->field_name] = !empty($post_data[$field->field_name]) ? implode(',',$post_data[$field->field_name]) : ''; |
|
1053 | + $update_data[$field->field_name] = !empty($post_data[$field->field_name]) ? implode(',', $post_data[$field->field_name]) : ''; |
|
1060 | 1054 | } |
1061 | - elseif(isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'datetime'){ |
|
1062 | - $update_data[$field->field_name] = $this->_convert_date_to_sql_date(substr($post_data[$field->field_name],0,10)). |
|
1063 | - substr($post_data[$field->field_name],10); |
|
1055 | + elseif (isset($types[$field->field_name]->crud_type) && $types[$field->field_name]->crud_type == 'datetime') { |
|
1056 | + $update_data[$field->field_name] = $this->_convert_date_to_sql_date(substr($post_data[$field->field_name], 0, 10)). |
|
1057 | + substr($post_data[$field->field_name], 10); |
|
1064 | 1058 | } |
1065 | 1059 | else |
1066 | 1060 | { |
@@ -1069,32 +1063,32 @@ discard block |
||
1069 | 1063 | } |
1070 | 1064 | } |
1071 | 1065 | |
1072 | - if($this->basic_model->db_update($update_data, $primary_key) === false) |
|
1066 | + if ($this->basic_model->db_update($update_data, $primary_key) === false) |
|
1073 | 1067 | { |
1074 | 1068 | return false; |
1075 | 1069 | } |
1076 | 1070 | |
1077 | - if(!empty($this->relation_n_n)) |
|
1071 | + if (!empty($this->relation_n_n)) |
|
1078 | 1072 | { |
1079 | - foreach($this->relation_n_n as $field_name => $field_info) |
|
1073 | + foreach ($this->relation_n_n as $field_name => $field_info) |
|
1080 | 1074 | { |
1081 | - if ( $this->unset_edit_fields !== null |
|
1075 | + if ($this->unset_edit_fields !== null |
|
1082 | 1076 | && is_array($this->unset_edit_fields) |
1083 | - && in_array($field_name,$this->unset_edit_fields) |
|
1077 | + && in_array($field_name, $this->unset_edit_fields) |
|
1084 | 1078 | ) { |
1085 | 1079 | continue; |
1086 | 1080 | } |
1087 | 1081 | |
1088 | - $relation_data = isset( $post_data[$field_name] ) ? $post_data[$field_name] : array() ; |
|
1089 | - $this->db_relation_n_n_update($field_info, $relation_data ,$primary_key); |
|
1082 | + $relation_data = isset($post_data[$field_name]) ? $post_data[$field_name] : array(); |
|
1083 | + $this->db_relation_n_n_update($field_info, $relation_data, $primary_key); |
|
1090 | 1084 | } |
1091 | 1085 | } |
1092 | 1086 | |
1093 | - if($this->callback_after_update !== null) |
|
1087 | + if ($this->callback_after_update !== null) |
|
1094 | 1088 | { |
1095 | 1089 | $callback_return = call_user_func($this->callback_after_update, $post_data, $primary_key); |
1096 | 1090 | |
1097 | - if($callback_return === false) |
|
1091 | + if ($callback_return === false) |
|
1098 | 1092 | { |
1099 | 1093 | return false; |
1100 | 1094 | } |
@@ -1105,7 +1099,7 @@ discard block |
||
1105 | 1099 | { |
1106 | 1100 | $callback_return = call_user_func($this->callback_update, $post_data, $primary_key); |
1107 | 1101 | |
1108 | - if($callback_return === false) |
|
1102 | + if ($callback_return === false) |
|
1109 | 1103 | { |
1110 | 1104 | return false; |
1111 | 1105 | } |
@@ -1121,24 +1115,24 @@ discard block |
||
1121 | 1115 | |
1122 | 1116 | protected function _convert_date_to_sql_date($date) |
1123 | 1117 | { |
1124 | - $date = substr($date,0,10); |
|
1125 | - if(preg_match('/\d{4}-\d{2}-\d{2}/',$date)) |
|
1118 | + $date = substr($date, 0, 10); |
|
1119 | + if (preg_match('/\d{4}-\d{2}-\d{2}/', $date)) |
|
1126 | 1120 | { |
1127 | 1121 | //If it's already a sql-date don't convert it! |
1128 | 1122 | return $date; |
1129 | - }elseif(empty($date)) |
|
1123 | + }elseif (empty($date)) |
|
1130 | 1124 | { |
1131 | 1125 | return ''; |
1132 | 1126 | } |
1133 | 1127 | |
1134 | - $date_array = preg_split( '/[-\.\/ ]/', $date); |
|
1135 | - if($this->php_date_format == 'd/m/Y') |
|
1128 | + $date_array = preg_split('/[-\.\/ ]/', $date); |
|
1129 | + if ($this->php_date_format == 'd/m/Y') |
|
1136 | 1130 | { |
1137 | - $sql_date = date('Y-m-d',mktime(0,0,0,$date_array[1],$date_array[0],$date_array[2])); |
|
1131 | + $sql_date = date('Y-m-d', mktime(0, 0, 0, $date_array[1], $date_array[0], $date_array[2])); |
|
1138 | 1132 | } |
1139 | - elseif($this->php_date_format == 'm/d/Y') |
|
1133 | + elseif ($this->php_date_format == 'm/d/Y') |
|
1140 | 1134 | { |
1141 | - $sql_date = date('Y-m-d',mktime(0,0,0,$date_array[0],$date_array[1],$date_array[2])); |
|
1135 | + $sql_date = date('Y-m-d', mktime(0, 0, 0, $date_array[0], $date_array[1], $date_array[2])); |
|
1142 | 1136 | } |
1143 | 1137 | else |
1144 | 1138 | { |
@@ -1150,17 +1144,17 @@ discard block |
||
1150 | 1144 | |
1151 | 1145 | protected function _get_field_names_to_search(array $relation_values) |
1152 | 1146 | { |
1153 | - if(!strstr($relation_values[2],'{')) |
|
1147 | + if (!strstr($relation_values[2], '{')) |
|
1154 | 1148 | return $this->_unique_join_name($relation_values[0]).'.'.$relation_values[2]; |
1155 | 1149 | else |
1156 | 1150 | { |
1157 | 1151 | $relation_values[2] = ' '.$relation_values[2].' '; |
1158 | - $temp1 = explode('{',$relation_values[2]); |
|
1152 | + $temp1 = explode('{', $relation_values[2]); |
|
1159 | 1153 | unset($temp1[0]); |
1160 | 1154 | |
1161 | 1155 | $field_names_array = array(); |
1162 | - foreach($temp1 as $field) |
|
1163 | - list($field_names_array[]) = explode('}',$field); |
|
1156 | + foreach ($temp1 as $field) |
|
1157 | + list($field_names_array[]) = explode('}', $field); |
|
1164 | 1158 | |
1165 | 1159 | return $field_names_array; |
1166 | 1160 | } |
@@ -1168,18 +1162,18 @@ discard block |
||
1168 | 1162 | |
1169 | 1163 | protected function _unique_join_name($field_name) |
1170 | 1164 | { |
1171 | - return 'j'.substr(md5($field_name),0,8); //This j is because is better for a string to begin with a letter and not a number |
|
1165 | + return 'j'.substr(md5($field_name), 0, 8); //This j is because is better for a string to begin with a letter and not a number |
|
1172 | 1166 | } |
1173 | 1167 | |
1174 | 1168 | protected function _unique_field_name($field_name) |
1175 | 1169 | { |
1176 | - return 's'.substr(md5($field_name),0,8); //This s is because is better for a string to begin with a letter and not a number |
|
1170 | + return 's'.substr(md5($field_name), 0, 8); //This s is because is better for a string to begin with a letter and not a number |
|
1177 | 1171 | } |
1178 | 1172 | |
1179 | 1173 | protected function db_multiple_delete($state_info) |
1180 | 1174 | { |
1181 | 1175 | foreach ($state_info->ids as $delete_id) { |
1182 | - $result = $this->db_delete((object)array('primary_key' => $delete_id)); |
|
1176 | + $result = $this->db_delete((object) array('primary_key' => $delete_id)); |
|
1183 | 1177 | if (!$result) { |
1184 | 1178 | return false; |
1185 | 1179 | } |
@@ -1190,41 +1184,41 @@ discard block |
||
1190 | 1184 | |
1191 | 1185 | protected function db_delete($state_info) |
1192 | 1186 | { |
1193 | - $primary_key_value = $state_info->primary_key; |
|
1187 | + $primary_key_value = $state_info->primary_key; |
|
1194 | 1188 | |
1195 | - if($this->callback_delete === null) |
|
1189 | + if ($this->callback_delete === null) |
|
1196 | 1190 | { |
1197 | - if($this->callback_before_delete !== null) |
|
1191 | + if ($this->callback_before_delete !== null) |
|
1198 | 1192 | { |
1199 | 1193 | $callback_return = call_user_func($this->callback_before_delete, $primary_key_value); |
1200 | 1194 | |
1201 | - if($callback_return === false) |
|
1195 | + if ($callback_return === false) |
|
1202 | 1196 | { |
1203 | 1197 | return false; |
1204 | 1198 | } |
1205 | 1199 | |
1206 | 1200 | } |
1207 | 1201 | |
1208 | - if(!empty($this->relation_n_n)) |
|
1202 | + if (!empty($this->relation_n_n)) |
|
1209 | 1203 | { |
1210 | - foreach($this->relation_n_n as $field_name => $field_info) |
|
1204 | + foreach ($this->relation_n_n as $field_name => $field_info) |
|
1211 | 1205 | { |
1212 | - $this->db_relation_n_n_delete( $field_info, $primary_key_value ); |
|
1206 | + $this->db_relation_n_n_delete($field_info, $primary_key_value); |
|
1213 | 1207 | } |
1214 | 1208 | } |
1215 | 1209 | |
1216 | 1210 | $delete_result = $this->basic_model->db_delete($primary_key_value); |
1217 | 1211 | |
1218 | - if($delete_result === false) |
|
1212 | + if ($delete_result === false) |
|
1219 | 1213 | { |
1220 | 1214 | return false; |
1221 | 1215 | } |
1222 | 1216 | |
1223 | - if($this->callback_after_delete !== null) |
|
1217 | + if ($this->callback_after_delete !== null) |
|
1224 | 1218 | { |
1225 | 1219 | $callback_return = call_user_func($this->callback_after_delete, $primary_key_value); |
1226 | 1220 | |
1227 | - if($callback_return === false) |
|
1221 | + if ($callback_return === false) |
|
1228 | 1222 | { |
1229 | 1223 | return false; |
1230 | 1224 | } |
@@ -1235,7 +1229,7 @@ discard block |
||
1235 | 1229 | { |
1236 | 1230 | $callback_return = call_user_func($this->callback_delete, $primary_key_value); |
1237 | 1231 | |
1238 | - if($callback_return === false) |
|
1232 | + if ($callback_return === false) |
|
1239 | 1233 | { |
1240 | 1234 | return false; |
1241 | 1235 | } |
@@ -1244,9 +1238,9 @@ discard block |
||
1244 | 1238 | return true; |
1245 | 1239 | } |
1246 | 1240 | |
1247 | - protected function db_relation_n_n_update($field_info, $post_data , $primary_key_value) |
|
1241 | + protected function db_relation_n_n_update($field_info, $post_data, $primary_key_value) |
|
1248 | 1242 | { |
1249 | - $this->basic_model->db_relation_n_n_update($field_info, $post_data , $primary_key_value); |
|
1243 | + $this->basic_model->db_relation_n_n_update($field_info, $post_data, $primary_key_value); |
|
1250 | 1244 | } |
1251 | 1245 | |
1252 | 1246 | protected function db_relation_n_n_delete($field_info, $primary_key_value) |
@@ -1256,44 +1250,44 @@ discard block |
||
1256 | 1250 | |
1257 | 1251 | protected function get_list() |
1258 | 1252 | { |
1259 | - if(!empty($this->order_by)) |
|
1260 | - $this->basic_model->order_by($this->order_by[0],$this->order_by[1]); |
|
1253 | + if (!empty($this->order_by)) |
|
1254 | + $this->basic_model->order_by($this->order_by[0], $this->order_by[1]); |
|
1261 | 1255 | |
1262 | - if(!empty($this->where)) |
|
1263 | - foreach($this->where as $where) |
|
1264 | - $this->basic_model->where($where[0],$where[1],$where[2]); |
|
1256 | + if (!empty($this->where)) |
|
1257 | + foreach ($this->where as $where) |
|
1258 | + $this->basic_model->where($where[0], $where[1], $where[2]); |
|
1265 | 1259 | |
1266 | - if(!empty($this->or_where)) |
|
1267 | - foreach($this->or_where as $or_where) |
|
1268 | - $this->basic_model->or_where($or_where[0],$or_where[1],$or_where[2]); |
|
1260 | + if (!empty($this->or_where)) |
|
1261 | + foreach ($this->or_where as $or_where) |
|
1262 | + $this->basic_model->or_where($or_where[0], $or_where[1], $or_where[2]); |
|
1269 | 1263 | |
1270 | - if(!empty($this->like)) |
|
1271 | - foreach($this->like as $like) |
|
1272 | - $this->basic_model->like($like[0],$like[1],$like[2]); |
|
1264 | + if (!empty($this->like)) |
|
1265 | + foreach ($this->like as $like) |
|
1266 | + $this->basic_model->like($like[0], $like[1], $like[2]); |
|
1273 | 1267 | |
1274 | - if(!empty($this->or_like)) |
|
1275 | - foreach($this->or_like as $or_like) |
|
1276 | - $this->basic_model->or_like($or_like[0],$or_like[1],$or_like[2]); |
|
1268 | + if (!empty($this->or_like)) |
|
1269 | + foreach ($this->or_like as $or_like) |
|
1270 | + $this->basic_model->or_like($or_like[0], $or_like[1], $or_like[2]); |
|
1277 | 1271 | |
1278 | - if(!empty($this->having)) |
|
1279 | - foreach($this->having as $having) |
|
1280 | - $this->basic_model->having($having[0],$having[1],$having[2]); |
|
1272 | + if (!empty($this->having)) |
|
1273 | + foreach ($this->having as $having) |
|
1274 | + $this->basic_model->having($having[0], $having[1], $having[2]); |
|
1281 | 1275 | |
1282 | - if(!empty($this->or_having)) |
|
1283 | - foreach($this->or_having as $or_having) |
|
1284 | - $this->basic_model->or_having($or_having[0],$or_having[1],$or_having[2]); |
|
1276 | + if (!empty($this->or_having)) |
|
1277 | + foreach ($this->or_having as $or_having) |
|
1278 | + $this->basic_model->or_having($or_having[0], $or_having[1], $or_having[2]); |
|
1285 | 1279 | |
1286 | - if(!empty($this->relation)) |
|
1287 | - foreach($this->relation as $relation) |
|
1288 | - $this->basic_model->join_relation($relation[0],$relation[1],$relation[2]); |
|
1280 | + if (!empty($this->relation)) |
|
1281 | + foreach ($this->relation as $relation) |
|
1282 | + $this->basic_model->join_relation($relation[0], $relation[1], $relation[2]); |
|
1289 | 1283 | |
1290 | - if(!empty($this->relation_n_n)) |
|
1284 | + if (!empty($this->relation_n_n)) |
|
1291 | 1285 | { |
1292 | 1286 | $columns = $this->get_columns(); |
1293 | - foreach($columns as $column) |
|
1287 | + foreach ($columns as $column) |
|
1294 | 1288 | { |
1295 | 1289 | //Use the relation_n_n ONLY if the column is called . The set_relation_n_n are slow and it will make the table slower without any reason as we don't need those queries. |
1296 | - if(isset($this->relation_n_n[$column->field_name])) |
|
1290 | + if (isset($this->relation_n_n[$column->field_name])) |
|
1297 | 1291 | { |
1298 | 1292 | $this->basic_model->set_relation_n_n_field($this->relation_n_n[$column->field_name]); |
1299 | 1293 | } |
@@ -1301,12 +1295,12 @@ discard block |
||
1301 | 1295 | |
1302 | 1296 | } |
1303 | 1297 | |
1304 | - if($this->theme_config['crud_paging'] === true) |
|
1298 | + if ($this->theme_config['crud_paging'] === true) |
|
1305 | 1299 | { |
1306 | - if($this->limit === null) |
|
1300 | + if ($this->limit === null) |
|
1307 | 1301 | { |
1308 | 1302 | $default_per_page = $this->config->default_per_page; |
1309 | - if(is_numeric($default_per_page) && $default_per_page >1) |
|
1303 | + if (is_numeric($default_per_page) && $default_per_page > 1) |
|
1310 | 1304 | { |
1311 | 1305 | $this->basic_model->limit($default_per_page); |
1312 | 1306 | } |
@@ -1317,7 +1311,7 @@ discard block |
||
1317 | 1311 | } |
1318 | 1312 | else |
1319 | 1313 | { |
1320 | - $this->basic_model->limit($this->limit[0],$this->limit[1]); |
|
1314 | + $this->basic_model->limit($this->limit[0], $this->limit[1]); |
|
1321 | 1315 | } |
1322 | 1316 | } |
1323 | 1317 | |
@@ -1330,9 +1324,9 @@ discard block |
||
1330 | 1324 | { |
1331 | 1325 | $values = $this->basic_model->get_edit_values($primary_key_value); |
1332 | 1326 | |
1333 | - if(!empty($this->relation_n_n)) |
|
1327 | + if (!empty($this->relation_n_n)) |
|
1334 | 1328 | { |
1335 | - foreach($this->relation_n_n as $field_name => $field_info) |
|
1329 | + foreach ($this->relation_n_n as $field_name => $field_info) |
|
1336 | 1330 | { |
1337 | 1331 | $values->$field_name = $this->get_relation_n_n_selection_array($primary_key_value, $field_info); |
1338 | 1332 | } |
@@ -1358,17 +1352,17 @@ discard block |
||
1358 | 1352 | |
1359 | 1353 | protected function upload_file($state_info) |
1360 | 1354 | { |
1361 | - if(isset($this->upload_fields[$state_info->field_name]) ) |
|
1355 | + if (isset($this->upload_fields[$state_info->field_name])) |
|
1362 | 1356 | { |
1363 | - if($this->callback_upload === null) |
|
1357 | + if ($this->callback_upload === null) |
|
1364 | 1358 | { |
1365 | - if($this->callback_before_upload !== null) |
|
1359 | + if ($this->callback_before_upload !== null) |
|
1366 | 1360 | { |
1367 | - $callback_before_upload_response = call_user_func($this->callback_before_upload, $_FILES, $this->upload_fields[$state_info->field_name]); |
|
1361 | + $callback_before_upload_response = call_user_func($this->callback_before_upload, $_FILES, $this->upload_fields[$state_info->field_name]); |
|
1368 | 1362 | |
1369 | - if($callback_before_upload_response === false) |
|
1363 | + if ($callback_before_upload_response === false) |
|
1370 | 1364 | return false; |
1371 | - elseif(is_string($callback_before_upload_response)) |
|
1365 | + elseif (is_string($callback_before_upload_response)) |
|
1372 | 1366 | return $callback_before_upload_response; |
1373 | 1367 | } |
1374 | 1368 | |
@@ -1385,9 +1379,9 @@ discard block |
||
1385 | 1379 | $allowed_files = $this->config->file_upload_allow_file_types; |
1386 | 1380 | |
1387 | 1381 | $reg_exp = ''; |
1388 | - if(!empty($upload_info->allowed_file_types)){ |
|
1382 | + if (!empty($upload_info->allowed_file_types)) { |
|
1389 | 1383 | $reg_exp = '/(\\.|\\/)('.$upload_info->allowed_file_types.')$/i'; |
1390 | - }else{ |
|
1384 | + } else { |
|
1391 | 1385 | $reg_exp = '/(\\.|\\/)('.$allowed_files.')$/i'; |
1392 | 1386 | } |
1393 | 1387 | |
@@ -1405,24 +1399,24 @@ discard block |
||
1405 | 1399 | $upload_handler->default_config_path = $this->default_config_path; |
1406 | 1400 | $uploader_response = $upload_handler->post(); |
1407 | 1401 | |
1408 | - if(is_array($uploader_response)) |
|
1402 | + if (is_array($uploader_response)) |
|
1409 | 1403 | { |
1410 | - foreach($uploader_response as &$response) |
|
1404 | + foreach ($uploader_response as &$response) |
|
1411 | 1405 | { |
1412 | 1406 | unset($response->delete_url); |
1413 | 1407 | unset($response->delete_type); |
1414 | 1408 | } |
1415 | 1409 | } |
1416 | 1410 | |
1417 | - if($this->callback_after_upload !== null) |
|
1411 | + if ($this->callback_after_upload !== null) |
|
1418 | 1412 | { |
1419 | - $callback_after_upload_response = call_user_func($this->callback_after_upload, $uploader_response , $this->upload_fields[$state_info->field_name] , $_FILES ); |
|
1413 | + $callback_after_upload_response = call_user_func($this->callback_after_upload, $uploader_response, $this->upload_fields[$state_info->field_name], $_FILES); |
|
1420 | 1414 | |
1421 | - if($callback_after_upload_response === false) |
|
1415 | + if ($callback_after_upload_response === false) |
|
1422 | 1416 | return false; |
1423 | - elseif(is_string($callback_after_upload_response)) |
|
1417 | + elseif (is_string($callback_after_upload_response)) |
|
1424 | 1418 | return $callback_after_upload_response; |
1425 | - elseif(is_array($callback_after_upload_response)) |
|
1419 | + elseif (is_array($callback_after_upload_response)) |
|
1426 | 1420 | $uploader_response = $callback_after_upload_response; |
1427 | 1421 | } |
1428 | 1422 | |
@@ -1430,9 +1424,9 @@ discard block |
||
1430 | 1424 | } |
1431 | 1425 | else |
1432 | 1426 | { |
1433 | - $upload_response = call_user_func($this->callback_upload, $_FILES, $this->upload_fields[$state_info->field_name] ); |
|
1427 | + $upload_response = call_user_func($this->callback_upload, $_FILES, $this->upload_fields[$state_info->field_name]); |
|
1434 | 1428 | |
1435 | - if($upload_response === false) |
|
1429 | + if ($upload_response === false) |
|
1436 | 1430 | { |
1437 | 1431 | return false; |
1438 | 1432 | } |
@@ -1451,13 +1445,13 @@ discard block |
||
1451 | 1445 | protected function delete_file($state_info) |
1452 | 1446 | { |
1453 | 1447 | |
1454 | - if(isset($state_info->field_name) && isset($this->upload_fields[$state_info->field_name])) |
|
1448 | + if (isset($state_info->field_name) && isset($this->upload_fields[$state_info->field_name])) |
|
1455 | 1449 | { |
1456 | 1450 | $upload_info = $this->upload_fields[$state_info->field_name]; |
1457 | 1451 | |
1458 | - if(file_exists("{$upload_info->upload_path}/{$state_info->file_name}")) |
|
1452 | + if (file_exists("{$upload_info->upload_path}/{$state_info->file_name}")) |
|
1459 | 1453 | { |
1460 | - if( unlink("{$upload_info->upload_path}/{$state_info->file_name}") ) |
|
1454 | + if (unlink("{$upload_info->upload_path}/{$state_info->file_name}")) |
|
1461 | 1455 | { |
1462 | 1456 | $this->basic_model->db_file_delete($state_info->field_name, $state_info->file_name); |
1463 | 1457 | |
@@ -1482,10 +1476,10 @@ discard block |
||
1482 | 1476 | |
1483 | 1477 | protected function ajax_relation($state_info) |
1484 | 1478 | { |
1485 | - if(!isset($this->relation[$state_info->field_name])) |
|
1479 | + if (!isset($this->relation[$state_info->field_name])) |
|
1486 | 1480 | return false; |
1487 | 1481 | |
1488 | - list($field_name, $related_table, $related_field_title, $where_clause, $order_by) = $this->relation[$state_info->field_name]; |
|
1482 | + list($field_name, $related_table, $related_field_title, $where_clause, $order_by) = $this->relation[$state_info->field_name]; |
|
1489 | 1483 | |
1490 | 1484 | return $this->basic_model->get_ajax_relation_array($state_info->search, $field_name, $related_table, $related_field_title, $where_clause, $order_by); |
1491 | 1485 | } |
@@ -1521,20 +1515,20 @@ discard block |
||
1521 | 1515 | */ |
1522 | 1516 | class grocery_CRUD_Layout extends grocery_CRUD_Model_Driver |
1523 | 1517 | { |
1524 | - private $theme_path = null; |
|
1525 | - private $views_as_string = ''; |
|
1526 | - private $echo_and_die = false; |
|
1527 | - protected $theme = null; |
|
1528 | - protected $default_true_false_text = array('inactive' , 'active'); |
|
1518 | + private $theme_path = null; |
|
1519 | + private $views_as_string = ''; |
|
1520 | + private $echo_and_die = false; |
|
1521 | + protected $theme = null; |
|
1522 | + protected $default_true_false_text = array('inactive', 'active'); |
|
1529 | 1523 | |
1530 | 1524 | protected $css_files = array(); |
1531 | 1525 | protected $js_files = array(); |
1532 | - protected $js_lib_files = array(); |
|
1533 | - protected $js_config_files = array(); |
|
1526 | + protected $js_lib_files = array(); |
|
1527 | + protected $js_config_files = array(); |
|
1534 | 1528 | |
1535 | 1529 | protected function set_basic_Layout() |
1536 | 1530 | { |
1537 | - if(!file_exists($this->theme_path.$this->theme.'/views/list_template.php')) |
|
1531 | + if (!file_exists($this->theme_path.$this->theme.'/views/list_template.php')) |
|
1538 | 1532 | { |
1539 | 1533 | throw new Exception('The template does not exist. Please check your files and try again.', 12); |
1540 | 1534 | die(); |
@@ -1545,32 +1539,32 @@ discard block |
||
1545 | 1539 | { |
1546 | 1540 | $data = $this->get_common_data(); |
1547 | 1541 | |
1548 | - $data->order_by = $this->order_by; |
|
1542 | + $data->order_by = $this->order_by; |
|
1549 | 1543 | |
1550 | - $data->types = $this->get_field_types(); |
|
1544 | + $data->types = $this->get_field_types(); |
|
1551 | 1545 | |
1552 | 1546 | $data->list = $this->get_list(); |
1553 | - $data->list = $this->change_list($data->list , $data->types); |
|
1547 | + $data->list = $this->change_list($data->list, $data->types); |
|
1554 | 1548 | $data->list = $this->change_list_add_actions($data->list); |
1555 | 1549 | |
1556 | 1550 | $data->total_results = $this->get_total_results(); |
1557 | 1551 | |
1558 | - $data->columns = $this->get_columns(); |
|
1552 | + $data->columns = $this->get_columns(); |
|
1559 | 1553 | |
1560 | - $data->success_message = $this->get_success_message_at_list($state_info); |
|
1554 | + $data->success_message = $this->get_success_message_at_list($state_info); |
|
1561 | 1555 | |
1562 | - $data->primary_key = $this->get_primary_key(); |
|
1563 | - $data->add_url = $this->getAddUrl(); |
|
1556 | + $data->primary_key = $this->get_primary_key(); |
|
1557 | + $data->add_url = $this->getAddUrl(); |
|
1564 | 1558 | $data->edit_url = $this->getEditUrl(); |
1565 | - $data->delete_url = $this->getDeleteUrl(); |
|
1566 | - $data->delete_multiple_url = $this->getDeleteMultipleUrl(); |
|
1559 | + $data->delete_url = $this->getDeleteUrl(); |
|
1560 | + $data->delete_multiple_url = $this->getDeleteMultipleUrl(); |
|
1567 | 1561 | $data->read_url = $this->getReadUrl(); |
1568 | - $data->ajax_list_url = $this->getAjaxListUrl(); |
|
1569 | - $data->ajax_list_info_url = $this->getAjaxListInfoUrl(); |
|
1570 | - $data->export_url = $this->getExportToExcelUrl(); |
|
1562 | + $data->ajax_list_url = $this->getAjaxListUrl(); |
|
1563 | + $data->ajax_list_info_url = $this->getAjaxListInfoUrl(); |
|
1564 | + $data->export_url = $this->getExportToExcelUrl(); |
|
1571 | 1565 | $data->print_url = $this->getPrintUrl(); |
1572 | - $data->actions = $this->actions; |
|
1573 | - $data->unique_hash = $this->get_method_hash(); |
|
1566 | + $data->actions = $this->actions; |
|
1567 | + $data->unique_hash = $this->get_method_hash(); |
|
1574 | 1568 | $data->order_by = $this->order_by; |
1575 | 1569 | |
1576 | 1570 | $data->unset_add = $this->unset_add; |
@@ -1578,19 +1572,19 @@ discard block |
||
1578 | 1572 | $data->unset_read = $this->unset_read; |
1579 | 1573 | $data->unset_delete = $this->unset_delete; |
1580 | 1574 | $data->unset_export = $this->unset_export; |
1581 | - $data->unset_print = $this->unset_print; |
|
1575 | + $data->unset_print = $this->unset_print; |
|
1582 | 1576 | |
1583 | 1577 | $default_per_page = $this->config->default_per_page; |
1584 | 1578 | $data->paging_options = $this->config->paging_options; |
1585 | - $data->default_per_page = is_numeric($default_per_page) && $default_per_page >1 && in_array($default_per_page,$data->paging_options)? $default_per_page : 25; |
|
1579 | + $data->default_per_page = is_numeric($default_per_page) && $default_per_page > 1 && in_array($default_per_page, $data->paging_options) ? $default_per_page : 25; |
|
1586 | 1580 | |
1587 | - if($data->list === false) |
|
1581 | + if ($data->list === false) |
|
1588 | 1582 | { |
1589 | 1583 | throw new Exception('It is impossible to get data. Please check your model and try again.', 13); |
1590 | 1584 | $data->list = array(); |
1591 | 1585 | } |
1592 | 1586 | |
1593 | - foreach($data->list as $num_row => $row) |
|
1587 | + foreach ($data->list as $num_row => $row) |
|
1594 | 1588 | { |
1595 | 1589 | $data->list[$num_row]->primary_key_value = $row->{$data->primary_key}; |
1596 | 1590 | $data->list[$num_row]->edit_url = $data->edit_url.'/'.$row->{$data->primary_key}; |
@@ -1598,17 +1592,17 @@ discard block |
||
1598 | 1592 | $data->list[$num_row]->read_url = $data->read_url.'/'.$row->{$data->primary_key}; |
1599 | 1593 | } |
1600 | 1594 | |
1601 | - if(!$ajax) |
|
1595 | + if (!$ajax) |
|
1602 | 1596 | { |
1603 | 1597 | $this->_add_js_vars(array('dialog_forms' => $this->config->dialog_forms)); |
1604 | 1598 | |
1605 | - $data->list_view = $this->_theme_view('list.php',$data,true); |
|
1606 | - $this->_theme_view('list_template.php',$data); |
|
1599 | + $data->list_view = $this->_theme_view('list.php', $data, true); |
|
1600 | + $this->_theme_view('list_template.php', $data); |
|
1607 | 1601 | } |
1608 | 1602 | else |
1609 | 1603 | { |
1610 | 1604 | $this->set_echo_and_die(); |
1611 | - $this->_theme_view('list.php',$data); |
|
1605 | + $this->_theme_view('list.php', $data); |
|
1612 | 1606 | } |
1613 | 1607 | } |
1614 | 1608 | |
@@ -1616,17 +1610,17 @@ discard block |
||
1616 | 1610 | { |
1617 | 1611 | $data = $this->get_common_data(); |
1618 | 1612 | |
1619 | - $data->order_by = $this->order_by; |
|
1620 | - $data->types = $this->get_field_types(); |
|
1613 | + $data->order_by = $this->order_by; |
|
1614 | + $data->types = $this->get_field_types(); |
|
1621 | 1615 | |
1622 | 1616 | $data->list = $this->get_list(); |
1623 | - $data->list = $this->change_list($data->list , $data->types); |
|
1617 | + $data->list = $this->change_list($data->list, $data->types); |
|
1624 | 1618 | $data->list = $this->change_list_add_actions($data->list); |
1625 | 1619 | |
1626 | 1620 | $data->total_results = $this->get_total_results(); |
1627 | 1621 | |
1628 | - $data->columns = $this->get_columns(); |
|
1629 | - $data->primary_key = $this->get_primary_key(); |
|
1622 | + $data->columns = $this->get_columns(); |
|
1623 | + $data->primary_key = $this->get_primary_key(); |
|
1630 | 1624 | |
1631 | 1625 | @ob_end_clean(); |
1632 | 1626 | $this->_export_to_excel($data); |
@@ -1640,20 +1634,20 @@ discard block |
||
1640 | 1634 | * */ |
1641 | 1635 | |
1642 | 1636 | $string_to_export = ""; |
1643 | - foreach($data->columns as $column){ |
|
1637 | + foreach ($data->columns as $column) { |
|
1644 | 1638 | $string_to_export .= $column->display_as."\t"; |
1645 | 1639 | } |
1646 | 1640 | $string_to_export .= "\n"; |
1647 | 1641 | |
1648 | - foreach($data->list as $num_row => $row){ |
|
1649 | - foreach($data->columns as $column){ |
|
1642 | + foreach ($data->list as $num_row => $row) { |
|
1643 | + foreach ($data->columns as $column) { |
|
1650 | 1644 | $string_to_export .= $this->_trim_export_string($row->{$column->field_name})."\t"; |
1651 | 1645 | } |
1652 | 1646 | $string_to_export .= "\n"; |
1653 | 1647 | } |
1654 | 1648 | |
1655 | 1649 | // Convert to UTF-16LE and Prepend BOM |
1656 | - $string_to_export = "\xFF\xFE" .mb_convert_encoding($string_to_export, 'UTF-16LE', 'UTF-8'); |
|
1650 | + $string_to_export = "\xFF\xFE".mb_convert_encoding($string_to_export, 'UTF-16LE', 'UTF-8'); |
|
1657 | 1651 | |
1658 | 1652 | $filename = "export-".date("Y-m-d_H:i:s").".xls"; |
1659 | 1653 | |
@@ -1668,17 +1662,17 @@ discard block |
||
1668 | 1662 | { |
1669 | 1663 | $data = $this->get_common_data(); |
1670 | 1664 | |
1671 | - $data->order_by = $this->order_by; |
|
1672 | - $data->types = $this->get_field_types(); |
|
1665 | + $data->order_by = $this->order_by; |
|
1666 | + $data->types = $this->get_field_types(); |
|
1673 | 1667 | |
1674 | 1668 | $data->list = $this->get_list(); |
1675 | - $data->list = $this->change_list($data->list , $data->types); |
|
1669 | + $data->list = $this->change_list($data->list, $data->types); |
|
1676 | 1670 | $data->list = $this->change_list_add_actions($data->list); |
1677 | 1671 | |
1678 | 1672 | $data->total_results = $this->get_total_results(); |
1679 | 1673 | |
1680 | - $data->columns = $this->get_columns(); |
|
1681 | - $data->primary_key = $this->get_primary_key(); |
|
1674 | + $data->columns = $this->get_columns(); |
|
1675 | + $data->primary_key = $this->get_primary_key(); |
|
1682 | 1676 | |
1683 | 1677 | @ob_end_clean(); |
1684 | 1678 | $this->_print_webpage($data); |
@@ -1696,14 +1690,14 @@ discard block |
||
1696 | 1690 | $string_to_print .= "<div id='print-table'>"; |
1697 | 1691 | |
1698 | 1692 | $string_to_print .= '<table width="100%" cellpadding="0" cellspacing="0" ><tr>'; |
1699 | - foreach($data->columns as $column){ |
|
1693 | + foreach ($data->columns as $column) { |
|
1700 | 1694 | $string_to_print .= "<th>".$column->display_as."</th>"; |
1701 | 1695 | } |
1702 | 1696 | $string_to_print .= "</tr>"; |
1703 | 1697 | |
1704 | - foreach($data->list as $num_row => $row){ |
|
1698 | + foreach ($data->list as $num_row => $row) { |
|
1705 | 1699 | $string_to_print .= "<tr>"; |
1706 | - foreach($data->columns as $column){ |
|
1700 | + foreach ($data->columns as $column) { |
|
1707 | 1701 | $string_to_print .= "<td>".$this->_trim_print_string($row->{$column->field_name})."</td>"; |
1708 | 1702 | } |
1709 | 1703 | $string_to_print .= "</tr>"; |
@@ -1717,16 +1711,16 @@ discard block |
||
1717 | 1711 | |
1718 | 1712 | protected function _trim_export_string($value) |
1719 | 1713 | { |
1720 | - $value = str_replace(array(" ","&",">","<"),array(" ","&",">","<"),$value); |
|
1721 | - return strip_tags(str_replace(array("\t","\n","\r"),"",$value)); |
|
1714 | + $value = str_replace(array(" ", "&", ">", "<"), array(" ", "&", ">", "<"), $value); |
|
1715 | + return strip_tags(str_replace(array("\t", "\n", "\r"), "", $value)); |
|
1722 | 1716 | } |
1723 | 1717 | |
1724 | 1718 | protected function _trim_print_string($value) |
1725 | 1719 | { |
1726 | - $value = str_replace(array(" ","&",">","<"),array(" ","&",">","<"),$value); |
|
1720 | + $value = str_replace(array(" ", "&", ">", "<"), array(" ", "&", ">", "<"), $value); |
|
1727 | 1721 | |
1728 | 1722 | //If the value has only spaces and nothing more then add the whitespace html character |
1729 | - if(str_replace(" ","",$value) == "") |
|
1723 | + if (str_replace(" ", "", $value) == "") |
|
1730 | 1724 | $value = " "; |
1731 | 1725 | |
1732 | 1726 | return strip_tags($value); |
@@ -1746,7 +1740,7 @@ discard block |
||
1746 | 1740 | { |
1747 | 1741 | $this->set_echo_and_die(); |
1748 | 1742 | |
1749 | - $total_results = (int)$this->get_total_results(); |
|
1743 | + $total_results = (int) $this->get_total_results(); |
|
1750 | 1744 | @ob_end_clean(); |
1751 | 1745 | echo json_encode(array('total_results' => $total_results)); |
1752 | 1746 | die(); |
@@ -1754,17 +1748,17 @@ discard block |
||
1754 | 1748 | |
1755 | 1749 | protected function change_list_add_actions($list) |
1756 | 1750 | { |
1757 | - if(empty($this->actions)) |
|
1751 | + if (empty($this->actions)) |
|
1758 | 1752 | return $list; |
1759 | 1753 | |
1760 | 1754 | $primary_key = $this->get_primary_key(); |
1761 | 1755 | |
1762 | - foreach($list as $num_row => $row) |
|
1756 | + foreach ($list as $num_row => $row) |
|
1763 | 1757 | { |
1764 | 1758 | $actions_urls = array(); |
1765 | - foreach($this->actions as $unique_id => $action) |
|
1759 | + foreach ($this->actions as $unique_id => $action) |
|
1766 | 1760 | { |
1767 | - if(!empty($action->url_callback)) |
|
1761 | + if (!empty($action->url_callback)) |
|
1768 | 1762 | { |
1769 | 1763 | $actions_urls[$unique_id] = call_user_func($action->url_callback, $row->$primary_key, $row); |
1770 | 1764 | } |
@@ -1772,8 +1766,7 @@ discard block |
||
1772 | 1766 | { |
1773 | 1767 | $actions_urls[$unique_id] = |
1774 | 1768 | $action->url_has_http ? |
1775 | - $action->link_url.$row->$primary_key : |
|
1776 | - site_url($action->link_url.'/'.$row->$primary_key); |
|
1769 | + $action->link_url.$row->$primary_key : site_url($action->link_url.'/'.$row->$primary_key); |
|
1777 | 1770 | } |
1778 | 1771 | } |
1779 | 1772 | $row->action_urls = $actions_urls; |
@@ -1782,21 +1775,21 @@ discard block |
||
1782 | 1775 | return $list; |
1783 | 1776 | } |
1784 | 1777 | |
1785 | - protected function change_list($list,$types) |
|
1778 | + protected function change_list($list, $types) |
|
1786 | 1779 | { |
1787 | 1780 | $primary_key = $this->get_primary_key(); |
1788 | 1781 | $has_callbacks = !empty($this->callback_column) ? true : false; |
1789 | 1782 | $output_columns = $this->get_columns(); |
1790 | - foreach($list as $num_row => $row) |
|
1783 | + foreach ($list as $num_row => $row) |
|
1791 | 1784 | { |
1792 | - foreach($output_columns as $column) |
|
1785 | + foreach ($output_columns as $column) |
|
1793 | 1786 | { |
1794 | - $field_name = $column->field_name; |
|
1795 | - $field_value = isset( $row->{$column->field_name} ) ? $row->{$column->field_name} : null; |
|
1796 | - if( $has_callbacks && isset($this->callback_column[$field_name]) ) |
|
1787 | + $field_name = $column->field_name; |
|
1788 | + $field_value = isset($row->{$column->field_name} ) ? $row->{$column->field_name} : null; |
|
1789 | + if ($has_callbacks && isset($this->callback_column[$field_name])) |
|
1797 | 1790 | $list[$num_row]->$field_name = call_user_func($this->callback_column[$field_name], $field_value, $row); |
1798 | - elseif(isset($types[$field_name])) |
|
1799 | - $list[$num_row]->$field_name = $this->change_list_value($types[$field_name] , $field_value); |
|
1791 | + elseif (isset($types[$field_name])) |
|
1792 | + $list[$num_row]->$field_name = $this->change_list_value($types[$field_name], $field_value); |
|
1800 | 1793 | else |
1801 | 1794 | $list[$num_row]->$field_name = $field_value; |
1802 | 1795 | } |
@@ -1809,21 +1802,21 @@ discard block |
||
1809 | 1802 | { |
1810 | 1803 | $this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY); |
1811 | 1804 | |
1812 | - $data = $this->get_common_data(); |
|
1813 | - $data->types = $this->get_field_types(); |
|
1805 | + $data = $this->get_common_data(); |
|
1806 | + $data->types = $this->get_field_types(); |
|
1814 | 1807 | |
1815 | - $data->list_url = $this->getListUrl(); |
|
1816 | - $data->insert_url = $this->getInsertUrl(); |
|
1817 | - $data->validation_url = $this->getValidationInsertUrl(); |
|
1808 | + $data->list_url = $this->getListUrl(); |
|
1809 | + $data->insert_url = $this->getInsertUrl(); |
|
1810 | + $data->validation_url = $this->getValidationInsertUrl(); |
|
1818 | 1811 | $data->input_fields = $this->get_add_input_fields(); |
1819 | 1812 | |
1820 | - $data->fields = $this->get_add_fields(); |
|
1813 | + $data->fields = $this->get_add_fields(); |
|
1821 | 1814 | $data->hidden_fields = $this->get_add_hidden_fields(); |
1822 | - $data->unset_back_to_list = $this->unset_back_to_list; |
|
1815 | + $data->unset_back_to_list = $this->unset_back_to_list; |
|
1823 | 1816 | $data->unique_hash = $this->get_method_hash(); |
1824 | - $data->is_ajax = $this->_is_ajax(); |
|
1817 | + $data->is_ajax = $this->_is_ajax(); |
|
1825 | 1818 | |
1826 | - $this->_theme_view('add.php',$data); |
|
1819 | + $this->_theme_view('add.php', $data); |
|
1827 | 1820 | $this->_inline_js("var js_date_format = '".$this->js_date_format."';"); |
1828 | 1821 | |
1829 | 1822 | $this->_get_ajax_results(); |
@@ -1833,12 +1826,12 @@ discard block |
||
1833 | 1826 | { |
1834 | 1827 | $this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY); |
1835 | 1828 | |
1836 | - $data = $this->get_common_data(); |
|
1837 | - $data->types = $this->get_field_types(); |
|
1829 | + $data = $this->get_common_data(); |
|
1830 | + $data->types = $this->get_field_types(); |
|
1838 | 1831 | |
1839 | 1832 | $data->field_values = $this->get_edit_values($state_info->primary_key); |
1840 | 1833 | |
1841 | - $data->add_url = $this->getAddUrl(); |
|
1834 | + $data->add_url = $this->getAddUrl(); |
|
1842 | 1835 | |
1843 | 1836 | $data->list_url = $this->getListUrl(); |
1844 | 1837 | $data->update_url = $this->getUpdateUrl($state_info); |
@@ -1847,14 +1840,14 @@ discard block |
||
1847 | 1840 | $data->input_fields = $this->get_edit_input_fields($data->field_values); |
1848 | 1841 | $data->unique_hash = $this->get_method_hash(); |
1849 | 1842 | |
1850 | - $data->fields = $this->get_edit_fields(); |
|
1843 | + $data->fields = $this->get_edit_fields(); |
|
1851 | 1844 | $data->hidden_fields = $this->get_edit_hidden_fields(); |
1852 | - $data->unset_back_to_list = $this->unset_back_to_list; |
|
1845 | + $data->unset_back_to_list = $this->unset_back_to_list; |
|
1853 | 1846 | |
1854 | - $data->validation_url = $this->getValidationUpdateUrl($state_info->primary_key); |
|
1855 | - $data->is_ajax = $this->_is_ajax(); |
|
1847 | + $data->validation_url = $this->getValidationUpdateUrl($state_info->primary_key); |
|
1848 | + $data->is_ajax = $this->_is_ajax(); |
|
1856 | 1849 | |
1857 | - $this->_theme_view('edit.php',$data); |
|
1850 | + $this->_theme_view('edit.php', $data); |
|
1858 | 1851 | $this->_inline_js("var js_date_format = '".$this->js_date_format."';"); |
1859 | 1852 | |
1860 | 1853 | $this->_get_ajax_results(); |
@@ -1864,12 +1857,12 @@ discard block |
||
1864 | 1857 | { |
1865 | 1858 | $this->set_js_lib($this->default_javascript_path.'/'.grocery_CRUD::JQUERY); |
1866 | 1859 | |
1867 | - $data = $this->get_common_data(); |
|
1868 | - $data->types = $this->get_field_types(); |
|
1860 | + $data = $this->get_common_data(); |
|
1861 | + $data->types = $this->get_field_types(); |
|
1869 | 1862 | |
1870 | 1863 | $data->field_values = $this->get_edit_values($state_info->primary_key); |
1871 | 1864 | |
1872 | - $data->add_url = $this->getAddUrl(); |
|
1865 | + $data->add_url = $this->getAddUrl(); |
|
1873 | 1866 | |
1874 | 1867 | $data->list_url = $this->getListUrl(); |
1875 | 1868 | $data->update_url = $this->getUpdateUrl($state_info); |
@@ -1878,14 +1871,14 @@ discard block |
||
1878 | 1871 | $data->input_fields = $this->get_read_input_fields($data->field_values); |
1879 | 1872 | $data->unique_hash = $this->get_method_hash(); |
1880 | 1873 | |
1881 | - $data->fields = $this->get_read_fields(); |
|
1874 | + $data->fields = $this->get_read_fields(); |
|
1882 | 1875 | $data->hidden_fields = $this->get_edit_hidden_fields(); |
1883 | - $data->unset_back_to_list = $this->unset_back_to_list; |
|
1876 | + $data->unset_back_to_list = $this->unset_back_to_list; |
|
1884 | 1877 | |
1885 | - $data->validation_url = $this->getValidationUpdateUrl($state_info->primary_key); |
|
1886 | - $data->is_ajax = $this->_is_ajax(); |
|
1878 | + $data->validation_url = $this->getValidationUpdateUrl($state_info->primary_key); |
|
1879 | + $data->is_ajax = $this->_is_ajax(); |
|
1887 | 1880 | |
1888 | - $this->_theme_view('read.php',$data); |
|
1881 | + $this->_theme_view('read.php', $data); |
|
1889 | 1882 | $this->_inline_js("var js_date_format = '".$this->js_date_format."';"); |
1890 | 1883 | |
1891 | 1884 | $this->_get_ajax_results(); |
@@ -1894,26 +1887,26 @@ discard block |
||
1894 | 1887 | protected function delete_layout($delete_result = true) |
1895 | 1888 | { |
1896 | 1889 | @ob_end_clean(); |
1897 | - if($delete_result === false) |
|
1890 | + if ($delete_result === false) |
|
1898 | 1891 | { |
1899 | 1892 | $error_message = '<p>'.$this->l('delete_error_message').'</p>'; |
1900 | 1893 | |
1901 | - echo json_encode(array('success' => $delete_result ,'error_message' => $error_message)); |
|
1894 | + echo json_encode(array('success' => $delete_result, 'error_message' => $error_message)); |
|
1902 | 1895 | } |
1903 | 1896 | else |
1904 | 1897 | { |
1905 | 1898 | $success_message = '<p>'.$this->l('delete_success_message').'</p>'; |
1906 | 1899 | |
1907 | - echo json_encode(array('success' => true , 'success_message' => $success_message)); |
|
1900 | + echo json_encode(array('success' => true, 'success_message' => $success_message)); |
|
1908 | 1901 | } |
1909 | 1902 | $this->set_echo_and_die(); |
1910 | 1903 | } |
1911 | 1904 | |
1912 | 1905 | protected function get_success_message_at_list($field_info = null) |
1913 | 1906 | { |
1914 | - if($field_info !== null && isset($field_info->success_message) && $field_info->success_message) |
|
1907 | + if ($field_info !== null && isset($field_info->success_message) && $field_info->success_message) |
|
1915 | 1908 | { |
1916 | - if(!empty($field_info->primary_key) && !$this->unset_edit) |
|
1909 | + if (!empty($field_info->primary_key) && !$this->unset_edit) |
|
1917 | 1910 | { |
1918 | 1911 | return $this->l('insert_success_message')." <a class='go-to-edit-form' href='".$this->getEditUrl($field_info->primary_key)."'>".$this->l('form_edit')." {$this->subject}</a> "; |
1919 | 1912 | } |
@@ -1931,7 +1924,7 @@ discard block |
||
1931 | 1924 | protected function insert_layout($insert_result = false) |
1932 | 1925 | { |
1933 | 1926 | @ob_end_clean(); |
1934 | - if($insert_result === false) |
|
1927 | + if ($insert_result === false) |
|
1935 | 1928 | { |
1936 | 1929 | echo json_encode(array('success' => false)); |
1937 | 1930 | } |
@@ -1939,7 +1932,7 @@ discard block |
||
1939 | 1932 | { |
1940 | 1933 | $success_message = '<p>'.$this->l('insert_success_message'); |
1941 | 1934 | |
1942 | - if(!$this->unset_back_to_list && !empty($insert_result) && !$this->unset_edit) |
|
1935 | + if (!$this->unset_back_to_list && !empty($insert_result) && !$this->unset_edit) |
|
1943 | 1936 | { |
1944 | 1937 | $success_message .= " <a class='go-to-edit-form' href='".$this->getEditUrl($insert_result)."'>".$this->l('form_edit')." {$this->subject}</a> "; |
1945 | 1938 | |
@@ -1948,7 +1941,7 @@ discard block |
||
1948 | 1941 | } |
1949 | 1942 | } |
1950 | 1943 | |
1951 | - if(!$this->unset_back_to_list && !$this->_is_ajax()) |
|
1944 | + if (!$this->unset_back_to_list && !$this->_is_ajax()) |
|
1952 | 1945 | { |
1953 | 1946 | $success_message .= " <a href='".$this->getListUrl()."'>".$this->l('form_go_back_to_list')."</a>"; |
1954 | 1947 | } |
@@ -1956,7 +1949,7 @@ discard block |
||
1956 | 1949 | $success_message .= '</p>'; |
1957 | 1950 | |
1958 | 1951 | echo json_encode(array( |
1959 | - 'success' => true , |
|
1952 | + 'success' => true, |
|
1960 | 1953 | 'insert_primary_key' => $insert_result, |
1961 | 1954 | 'success_message' => $success_message, |
1962 | 1955 | 'success_list_url' => $this->getListSuccessUrl($insert_result) |
@@ -1975,20 +1968,20 @@ discard block |
||
1975 | 1968 | protected function upload_layout($upload_result, $field_name) |
1976 | 1969 | { |
1977 | 1970 | @ob_end_clean(); |
1978 | - if($upload_result !== false && !is_string($upload_result) && empty($upload_result[0]->error)) |
|
1971 | + if ($upload_result !== false && !is_string($upload_result) && empty($upload_result[0]->error)) |
|
1979 | 1972 | { |
1980 | 1973 | echo json_encode( |
1981 | - (object)array( |
|
1974 | + (object) array( |
|
1982 | 1975 | 'success' => true, |
1983 | 1976 | 'files' => $upload_result |
1984 | 1977 | )); |
1985 | 1978 | } |
1986 | 1979 | else |
1987 | 1980 | { |
1988 | - $result = (object)array('success' => false); |
|
1989 | - if(is_string($upload_result)) |
|
1981 | + $result = (object) array('success' => false); |
|
1982 | + if (is_string($upload_result)) |
|
1990 | 1983 | $result->message = $upload_result; |
1991 | - if(!empty($upload_result[0]->error)) |
|
1984 | + if (!empty($upload_result[0]->error)) |
|
1992 | 1985 | $result->message = $upload_result[0]->error; |
1993 | 1986 | |
1994 | 1987 | echo json_encode($result); |
@@ -2000,13 +1993,13 @@ discard block |
||
2000 | 1993 | protected function delete_file_layout($upload_result) |
2001 | 1994 | { |
2002 | 1995 | @ob_end_clean(); |
2003 | - if($upload_result !== false) |
|
1996 | + if ($upload_result !== false) |
|
2004 | 1997 | { |
2005 | - echo json_encode( (object)array( 'success' => true ) ); |
|
1998 | + echo json_encode((object) array('success' => true)); |
|
2006 | 1999 | } |
2007 | 2000 | else |
2008 | 2001 | { |
2009 | - echo json_encode((object)array('success' => false)); |
|
2002 | + echo json_encode((object) array('success' => false)); |
|
2010 | 2003 | } |
2011 | 2004 | |
2012 | 2005 | $this->set_echo_and_die(); |
@@ -2102,7 +2095,7 @@ discard block |
||
2102 | 2095 | protected function get_layout() |
2103 | 2096 | { |
2104 | 2097 | $js_files = $this->get_js_files(); |
2105 | - $css_files = $this->get_css_files(); |
|
2098 | + $css_files = $this->get_css_files(); |
|
2106 | 2099 | |
2107 | 2100 | $js_lib_files = $this->get_js_lib_files(); |
2108 | 2101 | $js_config_files = $this->get_js_config_files(); |
@@ -2127,10 +2120,10 @@ discard block |
||
2127 | 2120 | unset($css_files[sha1($this->default_theme_path.'/bootstrap-v4/css/bootstrap/bootstrap.min.css')]); |
2128 | 2121 | } |
2129 | 2122 | |
2130 | - if($this->echo_and_die === false) |
|
2123 | + if ($this->echo_and_die === false) |
|
2131 | 2124 | { |
2132 | 2125 | /** Initialize JavaScript variables */ |
2133 | - $js_vars = array( |
|
2126 | + $js_vars = array( |
|
2134 | 2127 | 'default_javascript_path' => base_url().$this->default_javascript_path, |
2135 | 2128 | 'default_css_path' => base_url().$this->default_css_path, |
2136 | 2129 | 'default_texteditor_path' => base_url().$this->default_texteditor_path, |
@@ -2139,7 +2132,7 @@ discard block |
||
2139 | 2132 | ); |
2140 | 2133 | $this->_add_js_vars($js_vars); |
2141 | 2134 | |
2142 | - return (object)array( |
|
2135 | + return (object) array( |
|
2143 | 2136 | 'js_files' => $js_files, |
2144 | 2137 | 'js_lib_files' => $js_lib_files, |
2145 | 2138 | 'js_config_files' => $js_config_files, |
@@ -2147,7 +2140,7 @@ discard block |
||
2147 | 2140 | 'output' => $this->views_as_string, |
2148 | 2141 | ); |
2149 | 2142 | } |
2150 | - elseif($this->echo_and_die === true) |
|
2143 | + elseif ($this->echo_and_die === true) |
|
2151 | 2144 | { |
2152 | 2145 | echo $this->views_as_string; |
2153 | 2146 | die(); |
@@ -2157,21 +2150,21 @@ discard block |
||
2157 | 2150 | protected function update_layout($update_result = false, $state_info = null) |
2158 | 2151 | { |
2159 | 2152 | @ob_end_clean(); |
2160 | - if($update_result === false) |
|
2153 | + if ($update_result === false) |
|
2161 | 2154 | { |
2162 | 2155 | echo json_encode(array('success' => $update_result)); |
2163 | 2156 | } |
2164 | 2157 | else |
2165 | 2158 | { |
2166 | 2159 | $success_message = '<p>'.$this->l('update_success_message'); |
2167 | - if(!$this->unset_back_to_list && !$this->_is_ajax()) |
|
2160 | + if (!$this->unset_back_to_list && !$this->_is_ajax()) |
|
2168 | 2161 | { |
2169 | 2162 | $success_message .= " <a href='".$this->getListUrl()."'>".$this->l('form_go_back_to_list')."</a>"; |
2170 | 2163 | } |
2171 | 2164 | $success_message .= '</p>'; |
2172 | 2165 | |
2173 | 2166 | echo json_encode(array( |
2174 | - 'success' => true , |
|
2167 | + 'success' => true, |
|
2175 | 2168 | 'insert_primary_key' => $update_result, |
2176 | 2169 | 'success_message' => $success_message, |
2177 | 2170 | 'success_list_url' => $this->getListSuccessUrl($state_info->primary_key) |
@@ -2180,24 +2173,24 @@ discard block |
||
2180 | 2173 | $this->set_echo_and_die(); |
2181 | 2174 | } |
2182 | 2175 | |
2183 | - protected function get_integer_input($field_info,$value) |
|
2176 | + protected function get_integer_input($field_info, $value) |
|
2184 | 2177 | { |
2185 | 2178 | $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery.numeric.min.js'); |
2186 | 2179 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.numeric.config.js'); |
2187 | 2180 | $extra_attributes = ''; |
2188 | - if(!empty($field_info->db_max_length)) |
|
2181 | + if (!empty($field_info->db_max_length)) |
|
2189 | 2182 | $extra_attributes .= "maxlength='{$field_info->db_max_length}'"; |
2190 | 2183 | $input = "<input id='field-{$field_info->name}' name='{$field_info->name}' type='text' value='$value' class='numeric form-control' $extra_attributes />"; |
2191 | 2184 | return $input; |
2192 | 2185 | } |
2193 | 2186 | |
2194 | - protected function get_true_false_input($field_info,$value) |
|
2187 | + protected function get_true_false_input($field_info, $value) |
|
2195 | 2188 | { |
2196 | 2189 | $value_is_null = empty($value) && $value !== '0' && $value !== 0 ? true : false; |
2197 | 2190 | |
2198 | 2191 | $input = "<div class='pretty-radio-buttons'>"; |
2199 | 2192 | |
2200 | - $true_string = is_array($field_info->extras) && array_key_exists(1,$field_info->extras) ? $field_info->extras[1] : $this->default_true_false_text[1]; |
|
2193 | + $true_string = is_array($field_info->extras) && array_key_exists(1, $field_info->extras) ? $field_info->extras[1] : $this->default_true_false_text[1]; |
|
2201 | 2194 | $checked = $value === '1' || ($value_is_null && $field_info->default === '1') ? "checked = 'checked'" : ""; |
2202 | 2195 | $input .= |
2203 | 2196 | "<div class=\"radio\"><label> |
@@ -2205,7 +2198,7 @@ discard block |
||
2205 | 2198 | $true_string |
2206 | 2199 | </label> </div>"; |
2207 | 2200 | |
2208 | - $false_string = is_array($field_info->extras) && array_key_exists(0,$field_info->extras) ? $field_info->extras[0] : $this->default_true_false_text[0]; |
|
2201 | + $false_string = is_array($field_info->extras) && array_key_exists(0, $field_info->extras) ? $field_info->extras[0] : $this->default_true_false_text[0]; |
|
2209 | 2202 | $checked = $value === '0' || ($value_is_null && $field_info->default === '0') ? "checked = 'checked'" : ""; |
2210 | 2203 | $input .= |
2211 | 2204 | "<div class=\"radio\"><label> |
@@ -2218,18 +2211,18 @@ discard block |
||
2218 | 2211 | return $input; |
2219 | 2212 | } |
2220 | 2213 | |
2221 | - protected function get_string_input($field_info,$value) |
|
2214 | + protected function get_string_input($field_info, $value) |
|
2222 | 2215 | { |
2223 | - $value = !is_string($value) ? '' : str_replace('"',""",$value); |
|
2216 | + $value = !is_string($value) ? '' : str_replace('"', """, $value); |
|
2224 | 2217 | |
2225 | 2218 | $extra_attributes = ''; |
2226 | 2219 | if (!empty($field_info->db_max_length)) { |
2227 | 2220 | |
2228 | 2221 | if (in_array($field_info->type, array("decimal", "float"))) { |
2229 | 2222 | $decimal_lentgh = explode(",", $field_info->db_max_length); |
2230 | - $decimal_lentgh = ((int)$decimal_lentgh[0]) + 1; |
|
2223 | + $decimal_lentgh = ((int) $decimal_lentgh[0]) + 1; |
|
2231 | 2224 | |
2232 | - $extra_attributes .= "maxlength='" . $decimal_lentgh . "'"; |
|
2225 | + $extra_attributes .= "maxlength='".$decimal_lentgh."'"; |
|
2233 | 2226 | } else { |
2234 | 2227 | $extra_attributes .= "maxlength='{$field_info->db_max_length}'"; |
2235 | 2228 | } |
@@ -2239,9 +2232,9 @@ discard block |
||
2239 | 2232 | return $input; |
2240 | 2233 | } |
2241 | 2234 | |
2242 | - protected function get_text_input($field_info,$value) |
|
2235 | + protected function get_text_input($field_info, $value) |
|
2243 | 2236 | { |
2244 | - if($field_info->extras == 'text_editor') |
|
2237 | + if ($field_info->extras == 'text_editor') |
|
2245 | 2238 | { |
2246 | 2239 | $editor = $this->config->default_text_editor; |
2247 | 2240 | switch ($editor) { |
@@ -2276,7 +2269,7 @@ discard block |
||
2276 | 2269 | return $input; |
2277 | 2270 | } |
2278 | 2271 | |
2279 | - protected function get_datetime_input($field_info,$value) |
|
2272 | + protected function get_datetime_input($field_info, $value) |
|
2280 | 2273 | { |
2281 | 2274 | $this->set_css($this->default_css_path.'/ui/simple/'.grocery_CRUD::JQUERY_UI_CSS); |
2282 | 2275 | $this->set_css($this->default_css_path.'/jquery_plugins/jquery.ui.datetime.css'); |
@@ -2284,19 +2277,19 @@ discard block |
||
2284 | 2277 | $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/ui/'.grocery_CRUD::JQUERY_UI_JS); |
2285 | 2278 | $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/jquery-ui-timepicker-addon.js'); |
2286 | 2279 | |
2287 | - if($this->language !== 'english') |
|
2280 | + if ($this->language !== 'english') |
|
2288 | 2281 | { |
2289 | 2282 | include($this->default_config_path.'/language_alias.php'); |
2290 | - if(array_key_exists($this->language, $language_alias)) |
|
2283 | + if (array_key_exists($this->language, $language_alias)) |
|
2291 | 2284 | { |
2292 | 2285 | $i18n_date_js_file = $this->default_javascript_path.'/jquery_plugins/ui/i18n/datepicker/jquery.ui.datepicker-'.$language_alias[$this->language].'.js'; |
2293 | - if(file_exists($i18n_date_js_file)) |
|
2286 | + if (file_exists($i18n_date_js_file)) |
|
2294 | 2287 | { |
2295 | 2288 | $this->set_js_lib($i18n_date_js_file); |
2296 | 2289 | } |
2297 | 2290 | |
2298 | 2291 | $i18n_datetime_js_file = $this->default_javascript_path.'/jquery_plugins/ui/i18n/timepicker/jquery-ui-timepicker-'.$language_alias[$this->language].'.js'; |
2299 | - if(file_exists($i18n_datetime_js_file)) |
|
2292 | + if (file_exists($i18n_datetime_js_file)) |
|
2300 | 2293 | { |
2301 | 2294 | $this->set_js_lib($i18n_datetime_js_file); |
2302 | 2295 | } |
@@ -2305,10 +2298,10 @@ discard block |
||
2305 | 2298 | |
2306 | 2299 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery-ui-timepicker-addon.config.js'); |
2307 | 2300 | |
2308 | - if(!empty($value) && $value != '0000-00-00 00:00:00' && $value != '1970-01-01 00:00:00'){ |
|
2309 | - list($year,$month,$day) = explode('-',substr($value,0,10)); |
|
2310 | - $date = date($this->php_date_format, mktime(0,0,0,$month,$day,$year)); |
|
2311 | - $datetime = $date.substr($value,10); |
|
2301 | + if (!empty($value) && $value != '0000-00-00 00:00:00' && $value != '1970-01-01 00:00:00') { |
|
2302 | + list($year, $month, $day) = explode('-', substr($value, 0, 10)); |
|
2303 | + $date = date($this->php_date_format, mktime(0, 0, 0, $month, $day, $year)); |
|
2304 | + $datetime = $date.substr($value, 10); |
|
2312 | 2305 | } |
2313 | 2306 | else |
2314 | 2307 | { |
@@ -2320,37 +2313,37 @@ discard block |
||
2320 | 2313 | return $input; |
2321 | 2314 | } |
2322 | 2315 | |
2323 | - protected function get_hidden_input($field_info,$value) |
|
2316 | + protected function get_hidden_input($field_info, $value) |
|
2324 | 2317 | { |
2325 | - if($field_info->extras !== null && $field_info->extras != false) |
|
2318 | + if ($field_info->extras !== null && $field_info->extras != false) |
|
2326 | 2319 | $value = $field_info->extras; |
2327 | 2320 | $input = "<input id='field-{$field_info->name}' type='hidden' name='{$field_info->name}' value='$value' />"; |
2328 | 2321 | return $input; |
2329 | 2322 | } |
2330 | 2323 | |
2331 | - protected function get_password_input($field_info,$value) |
|
2324 | + protected function get_password_input($field_info, $value) |
|
2332 | 2325 | { |
2333 | 2326 | $value = !is_string($value) ? '' : $value; |
2334 | 2327 | |
2335 | 2328 | $extra_attributes = ''; |
2336 | - if(!empty($field_info->db_max_length)) |
|
2329 | + if (!empty($field_info->db_max_length)) |
|
2337 | 2330 | $extra_attributes .= "maxlength='{$field_info->db_max_length}'"; |
2338 | 2331 | $input = "<input id='field-{$field_info->name}' class='form-control' name='{$field_info->name}' type='password' value='$value' $extra_attributes />"; |
2339 | 2332 | return $input; |
2340 | 2333 | } |
2341 | 2334 | |
2342 | - protected function get_date_input($field_info,$value) |
|
2335 | + protected function get_date_input($field_info, $value) |
|
2343 | 2336 | { |
2344 | 2337 | $this->set_css($this->default_css_path.'/ui/simple/'.grocery_CRUD::JQUERY_UI_CSS); |
2345 | 2338 | $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/ui/'.grocery_CRUD::JQUERY_UI_JS); |
2346 | 2339 | |
2347 | - if($this->language !== 'english') |
|
2340 | + if ($this->language !== 'english') |
|
2348 | 2341 | { |
2349 | 2342 | include($this->default_config_path.'/language_alias.php'); |
2350 | - if(array_key_exists($this->language, $language_alias)) |
|
2343 | + if (array_key_exists($this->language, $language_alias)) |
|
2351 | 2344 | { |
2352 | 2345 | $i18n_date_js_file = $this->default_javascript_path.'/jquery_plugins/ui/i18n/datepicker/jquery.ui.datepicker-'.$language_alias[$this->language].'.js'; |
2353 | - if(file_exists($i18n_date_js_file)) |
|
2346 | + if (file_exists($i18n_date_js_file)) |
|
2354 | 2347 | { |
2355 | 2348 | $this->set_js_lib($i18n_date_js_file); |
2356 | 2349 | } |
@@ -2359,10 +2352,10 @@ discard block |
||
2359 | 2352 | |
2360 | 2353 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.datepicker.config.js'); |
2361 | 2354 | |
2362 | - if(!empty($value) && $value != '0000-00-00' && $value != '1970-01-01') |
|
2355 | + if (!empty($value) && $value != '0000-00-00' && $value != '1970-01-01') |
|
2363 | 2356 | { |
2364 | - list($year,$month,$day) = explode('-',substr($value,0,10)); |
|
2365 | - $date = date($this->php_date_format, mktime(0,0,0,$month,$day,$year)); |
|
2357 | + list($year, $month, $day) = explode('-', substr($value, 0, 10)); |
|
2358 | + $date = date($this->php_date_format, mktime(0, 0, 0, $month, $day, $year)); |
|
2366 | 2359 | } |
2367 | 2360 | else |
2368 | 2361 | { |
@@ -2374,16 +2367,16 @@ discard block |
||
2374 | 2367 | return $input; |
2375 | 2368 | } |
2376 | 2369 | |
2377 | - protected function get_dropdown_input($field_info,$value) |
|
2370 | + protected function get_dropdown_input($field_info, $value) |
|
2378 | 2371 | { |
2379 | 2372 | $this->load_js_chosen(); |
2380 | 2373 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.chosen.config.js'); |
2381 | 2374 | |
2382 | - $select_title = str_replace('{field_display_as}',$field_info->display_as,$this->l('set_relation_title')); |
|
2375 | + $select_title = str_replace('{field_display_as}', $field_info->display_as, $this->l('set_relation_title')); |
|
2383 | 2376 | |
2384 | 2377 | $input = "<select id='field-{$field_info->name}' name='{$field_info->name}' class='chosen-select' data-placeholder='".$select_title."'>"; |
2385 | 2378 | $options = array('' => '') + $field_info->extras; |
2386 | - foreach($options as $option_value => $option_label) |
|
2379 | + foreach ($options as $option_value => $option_label) |
|
2387 | 2380 | { |
2388 | 2381 | $selected = !empty($value) && $value == $option_value ? "selected='selected'" : ''; |
2389 | 2382 | $input .= "<option value='$option_value' $selected >$option_label</option>"; |
@@ -2393,18 +2386,18 @@ discard block |
||
2393 | 2386 | return $input; |
2394 | 2387 | } |
2395 | 2388 | |
2396 | - protected function get_enum_input($field_info,$value) |
|
2389 | + protected function get_enum_input($field_info, $value) |
|
2397 | 2390 | { |
2398 | 2391 | $this->load_js_chosen(); |
2399 | 2392 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.chosen.config.js'); |
2400 | 2393 | |
2401 | - $select_title = str_replace('{field_display_as}',$field_info->display_as,$this->l('set_relation_title')); |
|
2394 | + $select_title = str_replace('{field_display_as}', $field_info->display_as, $this->l('set_relation_title')); |
|
2402 | 2395 | |
2403 | 2396 | $input = "<select id='field-{$field_info->name}' name='{$field_info->name}' class='chosen-select' data-placeholder='".$select_title."'>"; |
2404 | - $options_array = $field_info->extras !== false && is_array($field_info->extras)? $field_info->extras : explode("','",substr($field_info->db_max_length,1,-1)); |
|
2397 | + $options_array = $field_info->extras !== false && is_array($field_info->extras) ? $field_info->extras : explode("','", substr($field_info->db_max_length, 1, -1)); |
|
2405 | 2398 | $options_array = array('' => '') + $options_array; |
2406 | 2399 | |
2407 | - foreach($options_array as $option) |
|
2400 | + foreach ($options_array as $option) |
|
2408 | 2401 | { |
2409 | 2402 | $selected = !empty($value) && $value == $option ? "selected='selected'" : ''; |
2410 | 2403 | $input .= "<option value='$option' $selected >$option</option>"; |
@@ -2422,26 +2415,26 @@ discard block |
||
2422 | 2415 | $read_only_value = $value; |
2423 | 2416 | } elseif (is_array($value)) { |
2424 | 2417 | $all_values = array_values($value); |
2425 | - $read_only_value = implode(", ",$all_values); |
|
2418 | + $read_only_value = implode(", ", $all_values); |
|
2426 | 2419 | } |
2427 | 2420 | |
2428 | 2421 | return '<div id="field-'.$field_info->name.'" class="readonly_label">'.$read_only_value.'</div>'; |
2429 | 2422 | } |
2430 | 2423 | |
2431 | - protected function get_set_input($field_info,$value) |
|
2424 | + protected function get_set_input($field_info, $value) |
|
2432 | 2425 | { |
2433 | 2426 | $this->load_js_chosen(); |
2434 | 2427 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.chosen.config.js'); |
2435 | 2428 | |
2436 | - $options_array = $field_info->extras !== false && is_array($field_info->extras)? $field_info->extras : explode("','",substr($field_info->db_max_length,1,-1)); |
|
2437 | - $selected_values = !empty($value) ? explode(",",$value) : array(); |
|
2429 | + $options_array = $field_info->extras !== false && is_array($field_info->extras) ? $field_info->extras : explode("','", substr($field_info->db_max_length, 1, -1)); |
|
2430 | + $selected_values = !empty($value) ? explode(",", $value) : array(); |
|
2438 | 2431 | |
2439 | - $select_title = str_replace('{field_display_as}',$field_info->display_as,$this->l('set_relation_title')); |
|
2432 | + $select_title = str_replace('{field_display_as}', $field_info->display_as, $this->l('set_relation_title')); |
|
2440 | 2433 | $input = "<select id='field-{$field_info->name}' name='{$field_info->name}[]' multiple='multiple' size='8' class='chosen-multiple-select' data-placeholder='$select_title' style='width:510px;' >"; |
2441 | 2434 | |
2442 | - foreach($options_array as $option) |
|
2435 | + foreach ($options_array as $option) |
|
2443 | 2436 | { |
2444 | - $selected = !empty($value) && in_array($option,$selected_values) ? "selected='selected'" : ''; |
|
2437 | + $selected = !empty($value) && in_array($option, $selected_values) ? "selected='selected'" : ''; |
|
2445 | 2438 | $input .= "<option value='$option' $selected >$option</option>"; |
2446 | 2439 | } |
2447 | 2440 | |
@@ -2450,20 +2443,20 @@ discard block |
||
2450 | 2443 | return $input; |
2451 | 2444 | } |
2452 | 2445 | |
2453 | - protected function get_multiselect_input($field_info,$value) |
|
2446 | + protected function get_multiselect_input($field_info, $value) |
|
2454 | 2447 | { |
2455 | 2448 | $this->load_js_chosen(); |
2456 | 2449 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.chosen.config.js'); |
2457 | 2450 | |
2458 | 2451 | $options_array = $field_info->extras; |
2459 | - $selected_values = !empty($value) ? explode(",",$value) : array(); |
|
2452 | + $selected_values = !empty($value) ? explode(",", $value) : array(); |
|
2460 | 2453 | |
2461 | - $select_title = str_replace('{field_display_as}',$field_info->display_as,$this->l('set_relation_title')); |
|
2454 | + $select_title = str_replace('{field_display_as}', $field_info->display_as, $this->l('set_relation_title')); |
|
2462 | 2455 | $input = "<select id='field-{$field_info->name}' name='{$field_info->name}[]' multiple='multiple' size='8' class='chosen-multiple-select' data-placeholder='$select_title' style='width:510px;' >"; |
2463 | 2456 | |
2464 | - foreach($options_array as $option_value => $option_label) |
|
2457 | + foreach ($options_array as $option_value => $option_label) |
|
2465 | 2458 | { |
2466 | - $selected = !empty($value) && in_array($option_value,$selected_values) ? "selected='selected'" : ''; |
|
2459 | + $selected = !empty($value) && in_array($option_value, $selected_values) ? "selected='selected'" : ''; |
|
2467 | 2460 | $input .= "<option value='$option_value' $selected >$option_label</option>"; |
2468 | 2461 | } |
2469 | 2462 | |
@@ -2472,7 +2465,7 @@ discard block |
||
2472 | 2465 | return $input; |
2473 | 2466 | } |
2474 | 2467 | |
2475 | - protected function get_relation_input($field_info,$value) |
|
2468 | + protected function get_relation_input($field_info, $value) |
|
2476 | 2469 | { |
2477 | 2470 | $this->load_js_chosen(); |
2478 | 2471 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.chosen.config.js'); |
@@ -2492,23 +2485,23 @@ discard block |
||
2492 | 2485 | |
2493 | 2486 | $this->_inline_js("var ajax_relation_url = '".$this->getAjaxRelationUrl()."';\n"); |
2494 | 2487 | |
2495 | - $select_title = str_replace('{field_display_as}',$field_info->display_as,$this->l('set_relation_title')); |
|
2488 | + $select_title = str_replace('{field_display_as}', $field_info->display_as, $this->l('set_relation_title')); |
|
2496 | 2489 | $input = "<select id='field-{$field_info->name}' name='{$field_info->name}' class='$ajax_or_not_class' data-placeholder='$select_title' style='width:300px'>"; |
2497 | 2490 | $input .= "<option value=''></option>"; |
2498 | 2491 | |
2499 | - if(!$using_ajax) |
|
2492 | + if (!$using_ajax) |
|
2500 | 2493 | { |
2501 | 2494 | $options_array = $this->get_relation_array($field_info->extras); |
2502 | - foreach($options_array as $option_value => $option) |
|
2495 | + foreach ($options_array as $option_value => $option) |
|
2503 | 2496 | { |
2504 | 2497 | $selected = !empty($value) && $value == $option_value ? "selected='selected'" : ''; |
2505 | 2498 | $input .= "<option value='$option_value' $selected >$option</option>"; |
2506 | 2499 | } |
2507 | 2500 | } |
2508 | - elseif(!empty($value) || (is_numeric($value) && $value == '0') ) //If it's ajax then we only need the selected items and not all the items |
|
2501 | + elseif (!empty($value) || (is_numeric($value) && $value == '0')) //If it's ajax then we only need the selected items and not all the items |
|
2509 | 2502 | { |
2510 | 2503 | $selected_options_array = $this->get_relation_array($field_info->extras, $value); |
2511 | - foreach($selected_options_array as $option_value => $option) |
|
2504 | + foreach ($selected_options_array as $option_value => $option) |
|
2512 | 2505 | { |
2513 | 2506 | $input .= "<option value='$option_value'selected='selected' >$option</option>"; |
2514 | 2507 | } |
@@ -2518,7 +2511,7 @@ discard block |
||
2518 | 2511 | return $input; |
2519 | 2512 | } |
2520 | 2513 | |
2521 | - protected function get_relation_readonly_input($field_info,$value) |
|
2514 | + protected function get_relation_readonly_input($field_info, $value) |
|
2522 | 2515 | { |
2523 | 2516 | $options_array = $this->get_relation_array($field_info->extras); |
2524 | 2517 | |
@@ -2527,7 +2520,7 @@ discard block |
||
2527 | 2520 | return $this->get_readonly_input($field_info, $value); |
2528 | 2521 | } |
2529 | 2522 | |
2530 | - protected function get_upload_file_readonly_input($field_info,$value) |
|
2523 | + protected function get_upload_file_readonly_input($field_info, $value) |
|
2531 | 2524 | { |
2532 | 2525 | $file = $file_url = base_url().$field_info->extras->upload_path.'/'.$value; |
2533 | 2526 | |
@@ -2541,7 +2534,7 @@ discard block |
||
2541 | 2534 | $has_priority_field = !empty($field_info_type->extras->priority_field_relation_table) ? true : false; |
2542 | 2535 | $is_ie_7 = isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7') !== false) ? true : false; |
2543 | 2536 | |
2544 | - if($has_priority_field || $is_ie_7) |
|
2537 | + if ($has_priority_field || $is_ie_7) |
|
2545 | 2538 | { |
2546 | 2539 | $this->set_css($this->default_css_path.'/ui/simple/'.grocery_CRUD::JQUERY_UI_CSS); |
2547 | 2540 | $this->set_css($this->default_css_path.'/jquery_plugins/ui.multiselect.css'); |
@@ -2549,13 +2542,13 @@ discard block |
||
2549 | 2542 | $this->set_js_lib($this->default_javascript_path.'/jquery_plugins/ui.multiselect.min.js'); |
2550 | 2543 | $this->set_js_config($this->default_javascript_path.'/jquery_plugins/config/jquery.multiselect.js'); |
2551 | 2544 | |
2552 | - if($this->language !== 'english') |
|
2545 | + if ($this->language !== 'english') |
|
2553 | 2546 | { |
2554 | 2547 | include($this->default_config_path.'/language_alias.php'); |
2555 | - if(array_key_exists($this->language, $language_alias)) |
|
2548 | + if (array_key_exists($this->language, $language_alias)) |
|
2556 | 2549 | { |
2557 | 2550 | $i18n_date_js_file = $this->default_javascript_path.'/jquery_plugins/ui/i18n/multiselect/ui-multiselect-'.$language_alias[$this->language].'.js'; |
2558 | - if(file_exists($i18n_date_js_file)) |
|
2551 | + if (file_exists($i18n_date_js_file)) |
|
2559 | 2552 | { |
2560 | 2553 | $this->set_js_lib($i18n_date_js_file); |
2561 | 2554 | } |
@@ -2571,29 +2564,29 @@ discard block |
||
2571 | 2564 | |
2572 | 2565 | $this->_inline_js("var ajax_relation_url = '".$this->getAjaxRelationUrl()."';\n"); |
2573 | 2566 | |
2574 | - $field_info = $this->relation_n_n[$field_info_type->name]; //As we use this function the relation_n_n exists, so don't need to check |
|
2575 | - $unselected_values = $this->get_relation_n_n_unselected_array($field_info, $selected_values); |
|
2567 | + $field_info = $this->relation_n_n[$field_info_type->name]; //As we use this function the relation_n_n exists, so don't need to check |
|
2568 | + $unselected_values = $this->get_relation_n_n_unselected_array($field_info, $selected_values); |
|
2576 | 2569 | |
2577 | - if(empty($unselected_values) && empty($selected_values)) |
|
2570 | + if (empty($unselected_values) && empty($selected_values)) |
|
2578 | 2571 | { |
2579 | 2572 | $input = "Please add {$field_info_type->display_as} first"; |
2580 | 2573 | } |
2581 | 2574 | else |
2582 | 2575 | { |
2583 | - $css_class = $has_priority_field || $is_ie_7 ? 'multiselect': 'chosen-multiple-select'; |
|
2576 | + $css_class = $has_priority_field || $is_ie_7 ? 'multiselect' : 'chosen-multiple-select'; |
|
2584 | 2577 | $width_style = $has_priority_field || $is_ie_7 ? '' : 'width:510px;'; |
2585 | 2578 | |
2586 | - $select_title = str_replace('{field_display_as}',$field_info_type->display_as,$this->l('set_relation_title')); |
|
2579 | + $select_title = str_replace('{field_display_as}', $field_info_type->display_as, $this->l('set_relation_title')); |
|
2587 | 2580 | $input = "<select id='field-{$field_info_type->name}' name='{$field_info_type->name}[]' multiple='multiple' size='8' class='$css_class' data-placeholder='$select_title' style='$width_style' >"; |
2588 | 2581 | |
2589 | - if(!empty($unselected_values)) |
|
2590 | - foreach($unselected_values as $id => $name) |
|
2582 | + if (!empty($unselected_values)) |
|
2583 | + foreach ($unselected_values as $id => $name) |
|
2591 | 2584 | { |
2592 | 2585 | $input .= "<option value='$id'>$name</option>"; |
2593 | 2586 | } |
2594 | 2587 | |
2595 | - if(!empty($selected_values)) |
|
2596 | - foreach($selected_values as $id => $name) |
|
2588 | + if (!empty($selected_values)) |
|
2589 | + foreach ($selected_values as $id => $name) |
|
2597 | 2590 | { |
2598 | 2591 | $input .= "<option value='$id' selected='selected'>$name</option>"; |
2599 | 2592 | } |
@@ -2606,15 +2599,15 @@ discard block |
||
2606 | 2599 | |
2607 | 2600 | protected function _convert_bytes_ui_to_bytes($bytes_ui) |
2608 | 2601 | { |
2609 | - $bytes_ui = str_replace(' ','',$bytes_ui); |
|
2610 | - if(strstr($bytes_ui,'MB')) |
|
2611 | - $bytes = (int)(str_replace('MB','',$bytes_ui))*1024*1024; |
|
2612 | - elseif(strstr($bytes_ui,'KB')) |
|
2613 | - $bytes = (int)(str_replace('KB','',$bytes_ui))*1024; |
|
2614 | - elseif(strstr($bytes_ui,'B')) |
|
2615 | - $bytes = (int)(str_replace('B','',$bytes_ui)); |
|
2602 | + $bytes_ui = str_replace(' ', '', $bytes_ui); |
|
2603 | + if (strstr($bytes_ui, 'MB')) |
|
2604 | + $bytes = (int) (str_replace('MB', '', $bytes_ui)) * 1024 * 1024; |
|
2605 | + elseif (strstr($bytes_ui, 'KB')) |
|
2606 | + $bytes = (int) (str_replace('KB', '', $bytes_ui)) * 1024; |
|
2607 | + elseif (strstr($bytes_ui, 'B')) |
|
2608 | + $bytes = (int) (str_replace('B', '', $bytes_ui)); |
|
2616 | 2609 | else |
2617 | - $bytes = (int)($bytes_ui); |
|
2610 | + $bytes = (int) ($bytes_ui); |
|
2618 | 2611 | |
2619 | 2612 | return $bytes; |
2620 | 2613 | } |
@@ -2631,7 +2624,7 @@ discard block |
||
2631 | 2624 | $unique = mt_rand(); |
2632 | 2625 | |
2633 | 2626 | $allowed_files = $this->config->file_upload_allow_file_types; |
2634 | - $allowed_files_ui = '.'.str_replace('|',',.',$allowed_files); |
|
2627 | + $allowed_files_ui = '.'.str_replace('|', ',.', $allowed_files); |
|
2635 | 2628 | $max_file_size_ui = $this->config->file_upload_max_file_size; |
2636 | 2629 | $max_file_size_bytes = $this->_convert_bytes_ui_to_bytes($max_file_size_ui); |
2637 | 2630 | |
@@ -2651,22 +2644,22 @@ discard block |
||
2651 | 2644 | |
2652 | 2645 | var error_max_number_of_files = "'.$this->l('error_max_number_of_files').'"; |
2653 | 2646 | var error_accept_file_types = "'.$this->l('error_accept_file_types').'"; |
2654 | - var error_max_file_size = "'.str_replace("{max_file_size}",$max_file_size_ui,$this->l('error_max_file_size')).'"; |
|
2647 | + var error_max_file_size = "'.str_replace("{max_file_size}", $max_file_size_ui, $this->l('error_max_file_size')).'"; |
|
2655 | 2648 | var error_min_file_size = "'.$this->l('error_min_file_size').'"; |
2656 | 2649 | |
2657 | 2650 | var base_url = "'.base_url().'"; |
2658 | 2651 | var upload_a_file_string = "'.$this->l('form_upload_a_file').'"; |
2659 | 2652 | '); |
2660 | 2653 | |
2661 | - $uploader_display_none = empty($value) ? "" : "display:none;"; |
|
2662 | - $file_display_none = empty($value) ? "display:none;" : ""; |
|
2654 | + $uploader_display_none = empty($value) ? "" : "display:none;"; |
|
2655 | + $file_display_none = empty($value) ? "display:none;" : ""; |
|
2663 | 2656 | |
2664 | 2657 | $is_image = !empty($value) && |
2665 | - ( substr($value,-4) == '.jpg' |
|
2666 | - || substr($value,-4) == '.png' |
|
2667 | - || substr($value,-5) == '.jpeg' |
|
2668 | - || substr($value,-4) == '.gif' |
|
2669 | - || substr($value,-5) == '.tiff') |
|
2658 | + (substr($value, -4) == '.jpg' |
|
2659 | + || substr($value, -4) == '.png' |
|
2660 | + || substr($value, -5) == '.jpeg' |
|
2661 | + || substr($value, -4) == '.gif' |
|
2662 | + || substr($value, -5) == '.tiff') |
|
2670 | 2663 | ? true : false; |
2671 | 2664 | |
2672 | 2665 | $image_class = $is_image ? 'image-thumbnail' : ''; |
@@ -2712,13 +2705,13 @@ discard block |
||
2712 | 2705 | |
2713 | 2706 | $input_fields = array(); |
2714 | 2707 | |
2715 | - foreach($fields as $field_num => $field) |
|
2708 | + foreach ($fields as $field_num => $field) |
|
2716 | 2709 | { |
2717 | 2710 | $field_info = $types[$field->field_name]; |
2718 | 2711 | |
2719 | 2712 | $field_value = !empty($field_values) && isset($field_values->{$field->field_name}) ? $field_values->{$field->field_name} : null; |
2720 | 2713 | |
2721 | - if(!isset($this->callback_add_field[$field->field_name])) |
|
2714 | + if (!isset($this->callback_add_field[$field->field_name])) |
|
2722 | 2715 | { |
2723 | 2716 | $field_input = $this->get_field_input($field_info, $field_value); |
2724 | 2717 | } |
@@ -2755,12 +2748,12 @@ discard block |
||
2755 | 2748 | |
2756 | 2749 | $input_fields = array(); |
2757 | 2750 | |
2758 | - foreach($fields as $field_num => $field) |
|
2751 | + foreach ($fields as $field_num => $field) |
|
2759 | 2752 | { |
2760 | 2753 | $field_info = $types[$field->field_name]; |
2761 | 2754 | |
2762 | 2755 | $field_value = !empty($field_values) && isset($field_values->{$field->field_name}) ? $field_values->{$field->field_name} : null; |
2763 | - if(!isset($this->callback_edit_field[$field->field_name])) |
|
2756 | + if (!isset($this->callback_edit_field[$field->field_name])) |
|
2764 | 2757 | { |
2765 | 2758 | $field_input = $this->get_field_input($field_info, $field_value); |
2766 | 2759 | } |
@@ -2813,12 +2806,12 @@ discard block |
||
2813 | 2806 | |
2814 | 2807 | $input_fields = array(); |
2815 | 2808 | |
2816 | - foreach($fields as $field_num => $field) |
|
2809 | + foreach ($fields as $field_num => $field) |
|
2817 | 2810 | { |
2818 | 2811 | $field_info = $types[$field->field_name]; |
2819 | 2812 | |
2820 | 2813 | $field_value = !empty($field_values) && isset($field_values->{$field->field_name}) ? $field_values->{$field->field_name} : null; |
2821 | - if(!isset($this->callback_read_field[$field->field_name])) |
|
2814 | + if (!isset($this->callback_read_field[$field->field_name])) |
|
2822 | 2815 | { |
2823 | 2816 | $field_input = $this->get_field_input($field_info, $field_value); |
2824 | 2817 | } |
@@ -2852,7 +2845,7 @@ discard block |
||
2852 | 2845 | protected function setThemeBasics() |
2853 | 2846 | { |
2854 | 2847 | $this->theme_path = $this->default_theme_path; |
2855 | - if(substr($this->theme_path,-1) != '/') |
|
2848 | + if (substr($this->theme_path, -1) != '/') |
|
2856 | 2849 | $this->theme_path = $this->theme_path.'/'; |
2857 | 2850 | |
2858 | 2851 | include($this->theme_path.$this->theme.'/config.php'); |
@@ -2873,7 +2866,7 @@ discard block |
||
2873 | 2866 | //Codeigniter doesn't like the $_GET requests so much! |
2874 | 2867 | if ($this->_is_ajax()) { |
2875 | 2868 | @ob_end_clean(); |
2876 | - $results= (object)array( |
|
2869 | + $results = (object) array( |
|
2877 | 2870 | 'output' => $this->views_as_string, |
2878 | 2871 | 'js_files' => array_values($this->get_js_files()), |
2879 | 2872 | 'js_lib_files' => array_values($this->get_js_lib_files()), |
@@ -2889,7 +2882,7 @@ discard block |
||
2889 | 2882 | |
2890 | 2883 | protected function _is_ajax() |
2891 | 2884 | { |
2892 | - return array_key_exists('is_ajax', $_POST) && $_POST['is_ajax'] == 'true' ? true: false; |
|
2885 | + return array_key_exists('is_ajax', $_POST) && $_POST['is_ajax'] == 'true' ? true : false; |
|
2893 | 2886 | } |
2894 | 2887 | |
2895 | 2888 | protected function _theme_view($view, $vars = array(), $return = FALSE) |
@@ -2909,7 +2902,7 @@ discard block |
||
2909 | 2902 | $file_exists = TRUE; |
2910 | 2903 | } |
2911 | 2904 | |
2912 | - if ( ! $file_exists) |
|
2905 | + if (!$file_exists) |
|
2913 | 2906 | { |
2914 | 2907 | throw new Exception('Unable to load the requested file: '.$file, 16); |
2915 | 2908 | } |
@@ -2950,7 +2943,7 @@ discard block |
||
2950 | 2943 | |
2951 | 2944 | protected function get_views_as_string() |
2952 | 2945 | { |
2953 | - if(!empty($this->views_as_string)) |
|
2946 | + if (!empty($this->views_as_string)) |
|
2954 | 2947 | return $this->views_as_string; |
2955 | 2948 | else |
2956 | 2949 | return null; |
@@ -3028,7 +3021,7 @@ discard block |
||
3028 | 3021 | $first_parameter = $segment_object->first_parameter; |
3029 | 3022 | $second_parameter = $segment_object->second_parameter; |
3030 | 3023 | |
3031 | - $state_info = (object)array(); |
|
3024 | + $state_info = (object) array(); |
|
3032 | 3025 | |
3033 | 3026 | switch ($state_code) { |
3034 | 3027 | case self::STATE_LIST: |
@@ -3050,7 +3043,7 @@ discard block |
||
3050 | 3043 | if ($first_parameter !== null) { |
3051 | 3044 | $state_info = (object) array('primary_key' => $first_parameter); |
3052 | 3045 | } else { |
3053 | - throw new Exception('On the state "delete" the Primary key cannot be null',7); |
|
3046 | + throw new Exception('On the state "delete" the Primary key cannot be null', 7); |
|
3054 | 3047 | die(); |
3055 | 3048 | } |
3056 | 3049 | break; |
@@ -3065,30 +3058,30 @@ discard block |
||
3065 | 3058 | break; |
3066 | 3059 | |
3067 | 3060 | case self::STATE_INSERT: |
3068 | - if(!empty($_POST)) |
|
3061 | + if (!empty($_POST)) |
|
3069 | 3062 | { |
3070 | - $state_info = (object)array('unwrapped_data' => $_POST); |
|
3063 | + $state_info = (object) array('unwrapped_data' => $_POST); |
|
3071 | 3064 | } |
3072 | 3065 | else |
3073 | 3066 | { |
3074 | - throw new Exception('On the state "insert" you must have post data',8); |
|
3067 | + throw new Exception('On the state "insert" you must have post data', 8); |
|
3075 | 3068 | die(); |
3076 | 3069 | } |
3077 | 3070 | break; |
3078 | 3071 | |
3079 | 3072 | case 6: |
3080 | - if(!empty($_POST) && $first_parameter !== null) |
|
3073 | + if (!empty($_POST) && $first_parameter !== null) |
|
3081 | 3074 | { |
3082 | - $state_info = (object)array('primary_key' => $first_parameter,'unwrapped_data' => $_POST); |
|
3075 | + $state_info = (object) array('primary_key' => $first_parameter, 'unwrapped_data' => $_POST); |
|
3083 | 3076 | } |
3084 | - elseif(empty($_POST)) |
|
3077 | + elseif (empty($_POST)) |
|
3085 | 3078 | { |
3086 | - throw new Exception('On the state "update" you must have post data',9); |
|
3079 | + throw new Exception('On the state "update" you must have post data', 9); |
|
3087 | 3080 | die(); |
3088 | 3081 | } |
3089 | 3082 | else |
3090 | 3083 | { |
3091 | - throw new Exception('On the state "update" the Primary key cannot be null',10); |
|
3084 | + throw new Exception('On the state "update" the Primary key cannot be null', 10); |
|
3092 | 3085 | die(); |
3093 | 3086 | } |
3094 | 3087 | break; |
@@ -3097,31 +3090,31 @@ discard block |
||
3097 | 3090 | case 8: |
3098 | 3091 | case 16: //export to excel |
3099 | 3092 | case 17: //print |
3100 | - $state_info = (object)array(); |
|
3101 | - if(!empty($_POST['per_page'])) |
|
3093 | + $state_info = (object) array(); |
|
3094 | + if (!empty($_POST['per_page'])) |
|
3102 | 3095 | { |
3103 | 3096 | $state_info->per_page = is_numeric($_POST['per_page']) ? $_POST['per_page'] : null; |
3104 | 3097 | } |
3105 | - if(!empty($_POST['page'])) |
|
3098 | + if (!empty($_POST['page'])) |
|
3106 | 3099 | { |
3107 | 3100 | $state_info->page = is_numeric($_POST['page']) ? $_POST['page'] : null; |
3108 | 3101 | } |
3109 | 3102 | //If we request an export or a print we don't care about what page we are |
3110 | - if($state_code === 16 || $state_code === 17) |
|
3103 | + if ($state_code === 16 || $state_code === 17) |
|
3111 | 3104 | { |
3112 | 3105 | $state_info->page = 1; |
3113 | 3106 | $state_info->per_page = 1000000; //a very big number! |
3114 | 3107 | } |
3115 | - if(!empty($_POST['order_by'][0])) |
|
3108 | + if (!empty($_POST['order_by'][0])) |
|
3116 | 3109 | { |
3117 | 3110 | $state_info->order_by = $_POST['order_by']; |
3118 | 3111 | } |
3119 | - if(!empty($_POST['search_text'])) |
|
3112 | + if (!empty($_POST['search_text'])) |
|
3120 | 3113 | { |
3121 | - if(empty($_POST['search_field'])) |
|
3114 | + if (empty($_POST['search_field'])) |
|
3122 | 3115 | { |
3123 | 3116 | $search_text = strip_tags($_POST['search_field']); |
3124 | - $state_info->search = (object)array('field' => null , 'text' => $_POST['search_text']); |
|
3117 | + $state_info->search = (object) array('field' => null, 'text' => $_POST['search_text']); |
|
3125 | 3118 | } |
3126 | 3119 | else |
3127 | 3120 | { |
@@ -3132,8 +3125,8 @@ discard block |
||
3132 | 3125 | } |
3133 | 3126 | $state_info->search = $search_array; |
3134 | 3127 | } else { |
3135 | - $state_info->search = (object)array( |
|
3136 | - 'field' => strip_tags($_POST['search_field']) , |
|
3128 | + $state_info->search = (object) array( |
|
3129 | + 'field' => strip_tags($_POST['search_field']), |
|
3137 | 3130 | 'text' => $_POST['search_text'] ); |
3138 | 3131 | } |
3139 | 3132 | } |
@@ -3145,9 +3138,9 @@ discard block |
||
3145 | 3138 | break; |
3146 | 3139 | |
3147 | 3140 | case 10: |
3148 | - if($first_parameter !== null) |
|
3141 | + if ($first_parameter !== null) |
|
3149 | 3142 | { |
3150 | - $state_info = (object)array('primary_key' => $first_parameter); |
|
3143 | + $state_info = (object) array('primary_key' => $first_parameter); |
|
3151 | 3144 | } |
3152 | 3145 | break; |
3153 | 3146 | |
@@ -3162,16 +3155,16 @@ discard block |
||
3162 | 3155 | |
3163 | 3156 | case 13: |
3164 | 3157 | $state_info->field_name = $_POST['field_name']; |
3165 | - $state_info->search = $_POST['term']; |
|
3158 | + $state_info->search = $_POST['term']; |
|
3166 | 3159 | break; |
3167 | 3160 | |
3168 | 3161 | case 14: |
3169 | 3162 | $state_info->field_name = $_POST['field_name']; |
3170 | - $state_info->search = $_POST['term']; |
|
3163 | + $state_info->search = $_POST['term']; |
|
3171 | 3164 | break; |
3172 | 3165 | |
3173 | 3166 | case 15: |
3174 | - $state_info = (object)array( |
|
3167 | + $state_info = (object) array( |
|
3175 | 3168 | 'primary_key' => $first_parameter, |
3176 | 3169 | 'success_message' => true |
3177 | 3170 | ); |
@@ -3185,8 +3178,8 @@ discard block |
||
3185 | 3178 | { |
3186 | 3179 | $state_string = $this->get_state_info_from_url()->operation; |
3187 | 3180 | |
3188 | - if( $state_string != 'unknown' && in_array( $state_string, $this->states ) ) |
|
3189 | - $state_code = array_search($state_string, $this->states); |
|
3181 | + if ($state_string != 'unknown' && in_array($state_string, $this->states)) |
|
3182 | + $state_code = array_search($state_string, $this->states); |
|
3190 | 3183 | else |
3191 | 3184 | $state_code = 0; |
3192 | 3185 | |
@@ -3197,9 +3190,8 @@ discard block |
||
3197 | 3190 | { |
3198 | 3191 | //Easy scenario, we had set the crud_url_path |
3199 | 3192 | if (!empty($this->crud_url_path)) { |
3200 | - $state_url = !empty($this->list_url_path) && $is_list_page? |
|
3201 | - $this->list_url_path : |
|
3202 | - $this->crud_url_path.'/'.$url ; |
|
3193 | + $state_url = !empty($this->list_url_path) && $is_list_page ? |
|
3194 | + $this->list_url_path : $this->crud_url_path.'/'.$url; |
|
3203 | 3195 | } else { |
3204 | 3196 | //Complicated scenario. The crud_url_path is not specified so we are |
3205 | 3197 | //trying to understand what is going on from the URL. |
@@ -3211,19 +3203,19 @@ discard block |
||
3211 | 3203 | |
3212 | 3204 | $state_url_array = array(); |
3213 | 3205 | |
3214 | - if( sizeof($ci->uri->segments) > 0 ) { |
|
3215 | - foreach($ci->uri->segments as $num => $value) |
|
3206 | + if (sizeof($ci->uri->segments) > 0) { |
|
3207 | + foreach ($ci->uri->segments as $num => $value) |
|
3216 | 3208 | { |
3217 | 3209 | $state_url_array[$num] = $value; |
3218 | - if($num == ($segment_position - 1)) |
|
3210 | + if ($num == ($segment_position - 1)) |
|
3219 | 3211 | break; |
3220 | 3212 | } |
3221 | 3213 | |
3222 | - if( $method_name == 'index' && !in_array( 'index', $state_url_array ) ) //there is a scenario that you don't have the index to your url |
|
3223 | - $state_url_array[$num+1] = 'index'; |
|
3214 | + if ($method_name == 'index' && !in_array('index', $state_url_array)) //there is a scenario that you don't have the index to your url |
|
3215 | + $state_url_array[$num + 1] = 'index'; |
|
3224 | 3216 | } |
3225 | 3217 | |
3226 | - $state_url = site_url(implode('/',$state_url_array).'/'.$url); |
|
3218 | + $state_url = site_url(implode('/', $state_url_array).'/'.$url); |
|
3227 | 3219 | } |
3228 | 3220 | |
3229 | 3221 | return $state_url; |
@@ -3237,24 +3229,24 @@ discard block |
||
3237 | 3229 | $operation = 'list'; |
3238 | 3230 | |
3239 | 3231 | $segements = $ci->uri->segments; |
3240 | - foreach($segements as $num => $value) |
|
3232 | + foreach ($segements as $num => $value) |
|
3241 | 3233 | { |
3242 | - if($value != 'unknown' && in_array($value, $this->states)) |
|
3234 | + if ($value != 'unknown' && in_array($value, $this->states)) |
|
3243 | 3235 | { |
3244 | - $segment_position = (int)$num; |
|
3236 | + $segment_position = (int) $num; |
|
3245 | 3237 | $operation = $value; //I don't have a "break" here because I want to ensure that is the LAST segment with name that is in the array. |
3246 | 3238 | } |
3247 | 3239 | } |
3248 | 3240 | |
3249 | 3241 | $function_name = $this->get_method_name(); |
3250 | 3242 | |
3251 | - if($function_name == 'index' && !in_array('index',$ci->uri->segments)) |
|
3243 | + if ($function_name == 'index' && !in_array('index', $ci->uri->segments)) |
|
3252 | 3244 | $segment_position++; |
3253 | 3245 | |
3254 | - $first_parameter = isset($segements[$segment_position+1]) ? $segements[$segment_position+1] : null; |
|
3255 | - $second_parameter = isset($segements[$segment_position+2]) ? $segements[$segment_position+2] : null; |
|
3246 | + $first_parameter = isset($segements[$segment_position + 1]) ? $segements[$segment_position + 1] : null; |
|
3247 | + $second_parameter = isset($segements[$segment_position + 2]) ? $segements[$segment_position + 2] : null; |
|
3256 | 3248 | |
3257 | - return (object)array('segment_position' => $segment_position, 'operation' => $operation, 'first_parameter' => $first_parameter, 'second_parameter' => $second_parameter); |
|
3249 | + return (object) array('segment_position' => $segment_position, 'operation' => $operation, 'first_parameter' => $first_parameter, 'second_parameter' => $second_parameter); |
|
3258 | 3250 | } |
3259 | 3251 | |
3260 | 3252 | protected function get_method_hash() |
@@ -3288,7 +3280,7 @@ discard block |
||
3288 | 3280 | |
3289 | 3281 | protected function getListUrl() |
3290 | 3282 | { |
3291 | - return $this->state_url('',true); |
|
3283 | + return $this->state_url('', true); |
|
3292 | 3284 | } |
3293 | 3285 | |
3294 | 3286 | protected function getAjaxListUrl() |
@@ -3328,7 +3320,7 @@ discard block |
||
3328 | 3320 | |
3329 | 3321 | protected function getValidationUpdateUrl($primary_key = null) |
3330 | 3322 | { |
3331 | - if($primary_key === null) |
|
3323 | + if ($primary_key === null) |
|
3332 | 3324 | return $this->state_url('update_validation'); |
3333 | 3325 | else |
3334 | 3326 | return $this->state_url('update_validation/'.$primary_key); |
@@ -3336,7 +3328,7 @@ discard block |
||
3336 | 3328 | |
3337 | 3329 | protected function getEditUrl($primary_key = null) |
3338 | 3330 | { |
3339 | - if($primary_key === null) |
|
3331 | + if ($primary_key === null) |
|
3340 | 3332 | return $this->state_url('edit'); |
3341 | 3333 | else |
3342 | 3334 | return $this->state_url('edit/'.$primary_key); |
@@ -3344,7 +3336,7 @@ discard block |
||
3344 | 3336 | |
3345 | 3337 | protected function getReadUrl($primary_key = null) |
3346 | 3338 | { |
3347 | - if($primary_key === null) |
|
3339 | + if ($primary_key === null) |
|
3348 | 3340 | return $this->state_url('read'); |
3349 | 3341 | else |
3350 | 3342 | return $this->state_url('read/'.$primary_key); |
@@ -3371,10 +3363,10 @@ discard block |
||
3371 | 3363 | |
3372 | 3364 | protected function getListSuccessUrl($primary_key = null) |
3373 | 3365 | { |
3374 | - if(empty($primary_key)) |
|
3375 | - return $this->state_url('success',true); |
|
3366 | + if (empty($primary_key)) |
|
3367 | + return $this->state_url('success', true); |
|
3376 | 3368 | else |
3377 | - return $this->state_url('success/'.$primary_key,true); |
|
3369 | + return $this->state_url('success/'.$primary_key, true); |
|
3378 | 3370 | } |
3379 | 3371 | |
3380 | 3372 | protected function getUploadUrl($field_name) |
@@ -3437,73 +3429,73 @@ discard block |
||
3437 | 3429 | */ |
3438 | 3430 | const VERSION = "1.5.6"; |
3439 | 3431 | |
3440 | - const JQUERY = "jquery-1.11.1.min.js"; |
|
3441 | - const JQUERY_UI_JS = "jquery-ui-1.10.3.custom.min.js"; |
|
3442 | - const JQUERY_UI_CSS = "jquery-ui-1.10.1.custom.min.css"; |
|
3432 | + const JQUERY = "jquery-1.11.1.min.js"; |
|
3433 | + const JQUERY_UI_JS = "jquery-ui-1.10.3.custom.min.js"; |
|
3434 | + const JQUERY_UI_CSS = "jquery-ui-1.10.1.custom.min.css"; |
|
3443 | 3435 | |
3444 | 3436 | protected $state_code = null; |
3445 | 3437 | protected $state_info = null; |
3446 | - protected $columns = null; |
|
3438 | + protected $columns = null; |
|
3447 | 3439 | |
3448 | 3440 | private $basic_db_table_checked = false; |
3449 | - private $columns_checked = false; |
|
3441 | + private $columns_checked = false; |
|
3450 | 3442 | private $add_fields_checked = false; |
3451 | 3443 | private $edit_fields_checked = false; |
3452 | 3444 | private $read_fields_checked = false; |
3453 | 3445 | |
3454 | 3446 | protected $default_theme = 'flexigrid'; |
3455 | - protected $language = null; |
|
3447 | + protected $language = null; |
|
3456 | 3448 | protected $lang_strings = array(); |
3457 | - protected $php_date_format = null; |
|
3449 | + protected $php_date_format = null; |
|
3458 | 3450 | protected $js_date_format = null; |
3459 | 3451 | protected $ui_date_format = null; |
3460 | - protected $character_limiter = null; |
|
3452 | + protected $character_limiter = null; |
|
3461 | 3453 | protected $config = null; |
3462 | 3454 | |
3463 | 3455 | protected $add_fields = null; |
3464 | 3456 | protected $edit_fields = null; |
3465 | 3457 | protected $read_fields = null; |
3466 | - protected $add_hidden_fields = array(); |
|
3467 | - protected $edit_hidden_fields = array(); |
|
3458 | + protected $add_hidden_fields = array(); |
|
3459 | + protected $edit_hidden_fields = array(); |
|
3468 | 3460 | protected $field_types = null; |
3469 | 3461 | protected $basic_db_table = null; |
3470 | 3462 | protected $theme_config = array(); |
3471 | 3463 | protected $subject = null; |
3472 | 3464 | protected $subject_plural = null; |
3473 | - protected $display_as = array(); |
|
3465 | + protected $display_as = array(); |
|
3474 | 3466 | protected $order_by = null; |
3475 | - protected $where = array(); |
|
3476 | - protected $like = array(); |
|
3477 | - protected $having = array(); |
|
3478 | - protected $or_having = array(); |
|
3479 | - protected $limit = null; |
|
3480 | - protected $required_fields = array(); |
|
3467 | + protected $where = array(); |
|
3468 | + protected $like = array(); |
|
3469 | + protected $having = array(); |
|
3470 | + protected $or_having = array(); |
|
3471 | + protected $limit = null; |
|
3472 | + protected $required_fields = array(); |
|
3481 | 3473 | protected $_unique_fields = array(); |
3482 | 3474 | protected $validation_rules = array(); |
3483 | - protected $relation = array(); |
|
3475 | + protected $relation = array(); |
|
3484 | 3476 | protected $relation_n_n = array(); |
3485 | 3477 | protected $upload_fields = array(); |
3486 | - protected $actions = array(); |
|
3478 | + protected $actions = array(); |
|
3487 | 3479 | |
3488 | - protected $form_validation = null; |
|
3489 | - protected $change_field_type = null; |
|
3480 | + protected $form_validation = null; |
|
3481 | + protected $change_field_type = null; |
|
3490 | 3482 | protected $primary_keys = array(); |
3491 | 3483 | protected $crud_url_path = null; |
3492 | 3484 | protected $list_url_path = null; |
3493 | 3485 | |
3494 | 3486 | /* The unsetters */ |
3495 | - protected $unset_texteditor = array(); |
|
3496 | - protected $unset_add = false; |
|
3487 | + protected $unset_texteditor = array(); |
|
3488 | + protected $unset_add = false; |
|
3497 | 3489 | protected $unset_edit = false; |
3498 | 3490 | protected $unset_delete = false; |
3499 | 3491 | protected $unset_read = false; |
3500 | 3492 | protected $unset_jquery = false; |
3501 | - protected $unset_jquery_ui = false; |
|
3502 | - protected $unset_bootstrap = false; |
|
3503 | - protected $unset_list = false; |
|
3493 | + protected $unset_jquery_ui = false; |
|
3494 | + protected $unset_bootstrap = false; |
|
3495 | + protected $unset_list = false; |
|
3504 | 3496 | protected $unset_export = false; |
3505 | - protected $unset_print = false; |
|
3506 | - protected $unset_back_to_list = false; |
|
3497 | + protected $unset_print = false; |
|
3498 | + protected $unset_back_to_list = false; |
|
3507 | 3499 | protected $unset_columns = null; |
3508 | 3500 | protected $unset_add_fields = null; |
3509 | 3501 | protected $unset_edit_fields = null; |
@@ -3520,17 +3512,17 @@ discard block |
||
3520 | 3512 | protected $callback_after_delete = null; |
3521 | 3513 | protected $callback_delete = null; |
3522 | 3514 | protected $callback_column = array(); |
3523 | - protected $callback_add_field = array(); |
|
3524 | - protected $callback_edit_field = array(); |
|
3515 | + protected $callback_add_field = array(); |
|
3516 | + protected $callback_edit_field = array(); |
|
3525 | 3517 | protected $callback_upload = null; |
3526 | - protected $callback_before_upload = null; |
|
3527 | - protected $callback_after_upload = null; |
|
3528 | - |
|
3529 | - protected $default_javascript_path = null; //autogenerate, please do not modify |
|
3530 | - protected $default_css_path = null; //autogenerate, please do not modify |
|
3531 | - protected $default_texteditor_path = null; //autogenerate, please do not modify |
|
3532 | - protected $default_theme_path = null; //autogenerate, please do not modify |
|
3533 | - protected $default_language_path = 'assets/grocery_crud/languages'; |
|
3518 | + protected $callback_before_upload = null; |
|
3519 | + protected $callback_after_upload = null; |
|
3520 | + |
|
3521 | + protected $default_javascript_path = null; //autogenerate, please do not modify |
|
3522 | + protected $default_css_path = null; //autogenerate, please do not modify |
|
3523 | + protected $default_texteditor_path = null; //autogenerate, please do not modify |
|
3524 | + protected $default_theme_path = null; //autogenerate, please do not modify |
|
3525 | + protected $default_language_path = 'assets/grocery_crud/languages'; |
|
3534 | 3526 | protected $default_config_path = 'assets/grocery_crud/config'; |
3535 | 3527 | protected $default_assets_path = 'assets/grocery_crud'; |
3536 | 3528 | |
@@ -3557,7 +3549,7 @@ discard block |
||
3557 | 3549 | { |
3558 | 3550 | $args = func_get_args(); |
3559 | 3551 | |
3560 | - if(isset($args[0]) && is_array($args[0])) |
|
3552 | + if (isset($args[0]) && is_array($args[0])) |
|
3561 | 3553 | { |
3562 | 3554 | $args = $args[0]; |
3563 | 3555 | } |
@@ -3580,12 +3572,12 @@ discard block |
||
3580 | 3572 | */ |
3581 | 3573 | function set_rules($field, $label = '', $rules = '') |
3582 | 3574 | { |
3583 | - if(is_string($field)) |
|
3575 | + if (is_string($field)) |
|
3584 | 3576 | { |
3585 | 3577 | $this->validation_rules[$field] = array('field' => $field, 'label' => $label, 'rules' => $rules); |
3586 | - }elseif(is_array($field)) |
|
3578 | + }elseif (is_array($field)) |
|
3587 | 3579 | { |
3588 | - foreach($field as $num_field => $field_array) |
|
3580 | + foreach ($field as $num_field => $field_array) |
|
3589 | 3581 | { |
3590 | 3582 | $this->validation_rules[$field_array['field']] = $field_array; |
3591 | 3583 | } |
@@ -3600,9 +3592,9 @@ discard block |
||
3600 | 3592 | * @param string $type |
3601 | 3593 | * @param array|string $extras |
3602 | 3594 | */ |
3603 | - public function change_field_type($field , $type, $extras = null) |
|
3595 | + public function change_field_type($field, $type, $extras = null) |
|
3604 | 3596 | { |
3605 | - $field_type = (object)array('type' => $type); |
|
3597 | + $field_type = (object) array('type' => $type); |
|
3606 | 3598 | |
3607 | 3599 | $field_type->extras = $extras; |
3608 | 3600 | |
@@ -3618,9 +3610,9 @@ discard block |
||
3618 | 3610 | * @param string $type |
3619 | 3611 | * @param array|string $extras |
3620 | 3612 | */ |
3621 | - public function field_type($field , $type, $extras = null) |
|
3613 | + public function field_type($field, $type, $extras = null) |
|
3622 | 3614 | { |
3623 | - return $this->change_field_type($field , $type, $extras); |
|
3615 | + return $this->change_field_type($field, $type, $extras); |
|
3624 | 3616 | } |
3625 | 3617 | |
3626 | 3618 | /** |
@@ -3649,11 +3641,11 @@ discard block |
||
3649 | 3641 | { |
3650 | 3642 | $args = func_get_args(); |
3651 | 3643 | |
3652 | - if(isset($args[0]) && is_array($args[0])) |
|
3644 | + if (isset($args[0]) && is_array($args[0])) |
|
3653 | 3645 | { |
3654 | 3646 | $args = $args[0]; |
3655 | 3647 | } |
3656 | - foreach($args as $arg) |
|
3648 | + foreach ($args as $arg) |
|
3657 | 3649 | { |
3658 | 3650 | $this->unset_texteditor[] = $arg; |
3659 | 3651 | } |
@@ -3792,7 +3784,7 @@ discard block |
||
3792 | 3784 | public function unset_operations() |
3793 | 3785 | { |
3794 | 3786 | $this->unset_add = true; |
3795 | - $this->unset_edit = true; |
|
3787 | + $this->unset_edit = true; |
|
3796 | 3788 | $this->unset_delete = true; |
3797 | 3789 | $this->unset_read = true; |
3798 | 3790 | $this->unset_export = true; |
@@ -3810,7 +3802,7 @@ discard block |
||
3810 | 3802 | { |
3811 | 3803 | $args = func_get_args(); |
3812 | 3804 | |
3813 | - if(isset($args[0]) && is_array($args[0])) |
|
3805 | + if (isset($args[0]) && is_array($args[0])) |
|
3814 | 3806 | { |
3815 | 3807 | $args = $args[0]; |
3816 | 3808 | } |
@@ -3831,7 +3823,7 @@ discard block |
||
3831 | 3823 | { |
3832 | 3824 | $args = func_get_args(); |
3833 | 3825 | |
3834 | - if(isset($args[0]) && is_array($args[0])) |
|
3826 | + if (isset($args[0]) && is_array($args[0])) |
|
3835 | 3827 | { |
3836 | 3828 | $args = $args[0]; |
3837 | 3829 | } |
@@ -3847,7 +3839,7 @@ discard block |
||
3847 | 3839 | { |
3848 | 3840 | $args = func_get_args(); |
3849 | 3841 | |
3850 | - if(isset($args[0]) && is_array($args[0])) |
|
3842 | + if (isset($args[0]) && is_array($args[0])) |
|
3851 | 3843 | { |
3852 | 3844 | $args = $args[0]; |
3853 | 3845 | } |
@@ -3861,7 +3853,7 @@ discard block |
||
3861 | 3853 | { |
3862 | 3854 | $args = func_get_args(); |
3863 | 3855 | |
3864 | - if(isset($args[0]) && is_array($args[0])) |
|
3856 | + if (isset($args[0]) && is_array($args[0])) |
|
3865 | 3857 | { |
3866 | 3858 | $args = $args[0]; |
3867 | 3859 | } |
@@ -3875,7 +3867,7 @@ discard block |
||
3875 | 3867 | { |
3876 | 3868 | $args = func_get_args(); |
3877 | 3869 | |
3878 | - if(isset($args[0]) && is_array($args[0])) |
|
3870 | + if (isset($args[0]) && is_array($args[0])) |
|
3879 | 3871 | { |
3880 | 3872 | $args = $args[0]; |
3881 | 3873 | } |
@@ -3911,7 +3903,7 @@ discard block |
||
3911 | 3903 | { |
3912 | 3904 | $args = func_get_args(); |
3913 | 3905 | |
3914 | - if(isset($args[0]) && is_array($args[0])) |
|
3906 | + if (isset($args[0]) && is_array($args[0])) |
|
3915 | 3907 | { |
3916 | 3908 | $args = $args[0]; |
3917 | 3909 | } |
@@ -3930,7 +3922,7 @@ discard block |
||
3930 | 3922 | { |
3931 | 3923 | $args = func_get_args(); |
3932 | 3924 | |
3933 | - if(isset($args[0]) && is_array($args[0])) |
|
3925 | + if (isset($args[0]) && is_array($args[0])) |
|
3934 | 3926 | { |
3935 | 3927 | $args = $args[0]; |
3936 | 3928 | } |
@@ -3948,7 +3940,7 @@ discard block |
||
3948 | 3940 | { |
3949 | 3941 | $args = func_get_args(); |
3950 | 3942 | |
3951 | - if(isset($args[0]) && is_array($args[0])) |
|
3943 | + if (isset($args[0]) && is_array($args[0])) |
|
3952 | 3944 | { |
3953 | 3945 | $args = $args[0]; |
3954 | 3946 | } |
@@ -3962,7 +3954,7 @@ discard block |
||
3962 | 3954 | { |
3963 | 3955 | $args = func_get_args(); |
3964 | 3956 | |
3965 | - if(isset($args[0]) && is_array($args[0])) { |
|
3957 | + if (isset($args[0]) && is_array($args[0])) { |
|
3966 | 3958 | $args = $args[0]; |
3967 | 3959 | } |
3968 | 3960 | |
@@ -3980,14 +3972,14 @@ discard block |
||
3980 | 3972 | */ |
3981 | 3973 | public function display_as($field_name, $display_as = null) |
3982 | 3974 | { |
3983 | - if(is_array($field_name)) |
|
3975 | + if (is_array($field_name)) |
|
3984 | 3976 | { |
3985 | - foreach($field_name as $field => $display_as) |
|
3977 | + foreach ($field_name as $field => $display_as) |
|
3986 | 3978 | { |
3987 | 3979 | $this->display_as[$field] = $display_as; |
3988 | 3980 | } |
3989 | 3981 | } |
3990 | - elseif($display_as !== null) |
|
3982 | + elseif ($display_as !== null) |
|
3991 | 3983 | { |
3992 | 3984 | $this->display_as[$field_name] = $display_as; |
3993 | 3985 | } |
@@ -4000,44 +3992,44 @@ discard block |
||
4000 | 3992 | */ |
4001 | 3993 | protected function _load_language() |
4002 | 3994 | { |
4003 | - if($this->language === null) |
|
3995 | + if ($this->language === null) |
|
4004 | 3996 | { |
4005 | 3997 | $this->language = strtolower($this->config->default_language); |
4006 | 3998 | } |
4007 | 3999 | include($this->default_language_path.'/'.$this->language.'.php'); |
4008 | 4000 | |
4009 | - foreach($lang as $handle => $lang_string) |
|
4010 | - if(!isset($this->lang_strings[$handle])) |
|
4001 | + foreach ($lang as $handle => $lang_string) |
|
4002 | + if (!isset($this->lang_strings[$handle])) |
|
4011 | 4003 | $this->lang_strings[$handle] = $lang_string; |
4012 | 4004 | |
4013 | - $this->default_true_false_text = array( $this->l('form_inactive') , $this->l('form_active')); |
|
4005 | + $this->default_true_false_text = array($this->l('form_inactive'), $this->l('form_active')); |
|
4014 | 4006 | $this->subject = $this->subject === null ? $this->l('list_record') : $this->subject; |
4015 | 4007 | |
4016 | 4008 | } |
4017 | 4009 | |
4018 | 4010 | protected function _load_date_format() |
4019 | 4011 | { |
4020 | - list($php_day, $php_month, $php_year) = array('d','m','Y'); |
|
4021 | - list($js_day, $js_month, $js_year) = array('dd','mm','yy'); |
|
4012 | + list($php_day, $php_month, $php_year) = array('d', 'm', 'Y'); |
|
4013 | + list($js_day, $js_month, $js_year) = array('dd', 'mm', 'yy'); |
|
4022 | 4014 | list($ui_day, $ui_month, $ui_year) = array($this->l('ui_day'), $this->l('ui_month'), $this->l('ui_year')); |
4023 | 4015 | |
4024 | 4016 | $date_format = $this->config->date_format; |
4025 | 4017 | switch ($date_format) { |
4026 | 4018 | case 'uk-date': |
4027 | - $this->php_date_format = "$php_day/$php_month/$php_year"; |
|
4019 | + $this->php_date_format = "$php_day/$php_month/$php_year"; |
|
4028 | 4020 | $this->js_date_format = "$js_day/$js_month/$js_year"; |
4029 | 4021 | $this->ui_date_format = "$ui_day/$ui_month/$ui_year"; |
4030 | 4022 | break; |
4031 | 4023 | |
4032 | 4024 | case 'us-date': |
4033 | - $this->php_date_format = "$php_month/$php_day/$php_year"; |
|
4025 | + $this->php_date_format = "$php_month/$php_day/$php_year"; |
|
4034 | 4026 | $this->js_date_format = "$js_month/$js_day/$js_year"; |
4035 | 4027 | $this->ui_date_format = "$ui_month/$ui_day/$ui_year"; |
4036 | 4028 | break; |
4037 | 4029 | |
4038 | 4030 | case 'sql-date': |
4039 | 4031 | default: |
4040 | - $this->php_date_format = "$php_year-$php_month-$php_day"; |
|
4032 | + $this->php_date_format = "$php_year-$php_month-$php_day"; |
|
4041 | 4033 | $this->js_date_format = "$js_year-$js_month-$js_day"; |
4042 | 4034 | $this->ui_date_format = "$ui_year-$ui_month-$ui_day"; |
4043 | 4035 | break; |
@@ -4050,7 +4042,7 @@ discard block |
||
4050 | 4042 | * @param string $handle |
4051 | 4043 | * @param string $string |
4052 | 4044 | */ |
4053 | - public function set_lang_string($handle, $lang_string){ |
|
4045 | + public function set_lang_string($handle, $lang_string) { |
|
4054 | 4046 | $this->lang_strings[$handle] = $lang_string; |
4055 | 4047 | |
4056 | 4048 | return $this; |
@@ -4095,29 +4087,29 @@ discard block |
||
4095 | 4087 | */ |
4096 | 4088 | protected function get_columns() |
4097 | 4089 | { |
4098 | - if($this->columns_checked === false) |
|
4090 | + if ($this->columns_checked === false) |
|
4099 | 4091 | { |
4100 | 4092 | $field_types = $this->get_field_types(); |
4101 | - if(empty($this->columns)) |
|
4093 | + if (empty($this->columns)) |
|
4102 | 4094 | { |
4103 | 4095 | $this->columns = array(); |
4104 | - foreach($field_types as $field) |
|
4096 | + foreach ($field_types as $field) |
|
4105 | 4097 | { |
4106 | - if( !isset($field->db_extra) || $field->db_extra != 'auto_increment' ) |
|
4098 | + if (!isset($field->db_extra) || $field->db_extra != 'auto_increment') |
|
4107 | 4099 | $this->columns[] = $field->name; |
4108 | 4100 | } |
4109 | 4101 | } |
4110 | 4102 | |
4111 | - foreach($this->columns as $col_num => $column) |
|
4103 | + foreach ($this->columns as $col_num => $column) |
|
4112 | 4104 | { |
4113 | 4105 | |
4114 | - if(isset($this->relation[$column])) |
|
4106 | + if (isset($this->relation[$column])) |
|
4115 | 4107 | { |
4116 | 4108 | |
4117 | 4109 | $new_column = $this->_unique_field_name($this->relation[$column][0]); |
4118 | 4110 | $this->columns[$col_num] = $new_column; |
4119 | 4111 | |
4120 | - if(isset($this->display_as[$column])) |
|
4112 | + if (isset($this->display_as[$column])) |
|
4121 | 4113 | { |
4122 | 4114 | $display_as = $this->display_as[$column]; |
4123 | 4115 | unset($this->display_as[$column]); |
@@ -4125,7 +4117,7 @@ discard block |
||
4125 | 4117 | } |
4126 | 4118 | else |
4127 | 4119 | { |
4128 | - $this->display_as[$new_column] = ucfirst(str_replace('_',' ',$column)); |
|
4120 | + $this->display_as[$new_column] = ucfirst(str_replace('_', ' ', $column)); |
|
4129 | 4121 | } |
4130 | 4122 | |
4131 | 4123 | $column = $new_column; |
@@ -4133,15 +4125,15 @@ discard block |
||
4133 | 4125 | } |
4134 | 4126 | else |
4135 | 4127 | { |
4136 | - if(!empty($this->relation)) |
|
4128 | + if (!empty($this->relation)) |
|
4137 | 4129 | { |
4138 | - $table_name = $this->get_table(); |
|
4139 | - foreach($this->relation as $relation) |
|
4130 | + $table_name = $this->get_table(); |
|
4131 | + foreach ($this->relation as $relation) |
|
4140 | 4132 | { |
4141 | - if( $relation[2] == $column ) |
|
4133 | + if ($relation[2] == $column) |
|
4142 | 4134 | { |
4143 | 4135 | $new_column = $table_name.'.'.$column; |
4144 | - if(isset($this->display_as[$column])) |
|
4136 | + if (isset($this->display_as[$column])) |
|
4145 | 4137 | { |
4146 | 4138 | $display_as = $this->display_as[$column]; |
4147 | 4139 | unset($this->display_as[$column]); |
@@ -4149,7 +4141,7 @@ discard block |
||
4149 | 4141 | } |
4150 | 4142 | else |
4151 | 4143 | { |
4152 | - $this->display_as[$new_column] = ucfirst(str_replace('_',' ',$column)); |
|
4144 | + $this->display_as[$new_column] = ucfirst(str_replace('_', ' ', $column)); |
|
4153 | 4145 | } |
4154 | 4146 | |
4155 | 4147 | $column = $new_column; |
@@ -4160,15 +4152,15 @@ discard block |
||
4160 | 4152 | |
4161 | 4153 | } |
4162 | 4154 | |
4163 | - if(isset($this->display_as[$column])) |
|
4164 | - $this->columns[$col_num] = (object)array('field_name' => $column, 'display_as' => $this->display_as[$column]); |
|
4165 | - elseif(isset($field_types[$column])) |
|
4166 | - $this->columns[$col_num] = (object)array('field_name' => $column, 'display_as' => $field_types[$column]->display_as); |
|
4155 | + if (isset($this->display_as[$column])) |
|
4156 | + $this->columns[$col_num] = (object) array('field_name' => $column, 'display_as' => $this->display_as[$column]); |
|
4157 | + elseif (isset($field_types[$column])) |
|
4158 | + $this->columns[$col_num] = (object) array('field_name' => $column, 'display_as' => $field_types[$column]->display_as); |
|
4167 | 4159 | else |
4168 | - $this->columns[$col_num] = (object)array('field_name' => $column, 'display_as' => |
|
4169 | - ucfirst(str_replace('_',' ',$column))); |
|
4160 | + $this->columns[$col_num] = (object) array('field_name' => $column, 'display_as' => |
|
4161 | + ucfirst(str_replace('_', ' ', $column))); |
|
4170 | 4162 | |
4171 | - if(!empty($this->unset_columns) && in_array($column,$this->unset_columns)) |
|
4163 | + if (!empty($this->unset_columns) && in_array($column, $this->unset_columns)) |
|
4172 | 4164 | { |
4173 | 4165 | unset($this->columns[$col_num]); |
4174 | 4166 | } |
@@ -4187,36 +4179,36 @@ discard block |
||
4187 | 4179 | */ |
4188 | 4180 | protected function get_add_fields() |
4189 | 4181 | { |
4190 | - if($this->add_fields_checked === false) |
|
4182 | + if ($this->add_fields_checked === false) |
|
4191 | 4183 | { |
4192 | 4184 | $field_types = $this->get_field_types(); |
4193 | - if(!empty($this->add_fields)) |
|
4185 | + if (!empty($this->add_fields)) |
|
4194 | 4186 | { |
4195 | - foreach($this->add_fields as $field_num => $field) |
|
4187 | + foreach ($this->add_fields as $field_num => $field) |
|
4196 | 4188 | { |
4197 | - if(isset($this->display_as[$field])) |
|
4198 | - $this->add_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4199 | - elseif(isset($field_types[$field]->display_as)) |
|
4200 | - $this->add_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4189 | + if (isset($this->display_as[$field])) |
|
4190 | + $this->add_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4191 | + elseif (isset($field_types[$field]->display_as)) |
|
4192 | + $this->add_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4201 | 4193 | else |
4202 | - $this->add_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => ucfirst(str_replace('_',' ',$field))); |
|
4194 | + $this->add_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => ucfirst(str_replace('_', ' ', $field))); |
|
4203 | 4195 | } |
4204 | 4196 | } |
4205 | 4197 | else |
4206 | 4198 | { |
4207 | 4199 | $this->add_fields = array(); |
4208 | - foreach($field_types as $field) |
|
4200 | + foreach ($field_types as $field) |
|
4209 | 4201 | { |
4210 | 4202 | //Check if an unset_add_field is initialize for this field name |
4211 | - if($this->unset_add_fields !== null && is_array($this->unset_add_fields) && in_array($field->name,$this->unset_add_fields)) |
|
4203 | + if ($this->unset_add_fields !== null && is_array($this->unset_add_fields) && in_array($field->name, $this->unset_add_fields)) |
|
4212 | 4204 | continue; |
4213 | 4205 | |
4214 | - if( (!isset($field->db_extra) || $field->db_extra != 'auto_increment') ) |
|
4206 | + if ((!isset($field->db_extra) || $field->db_extra != 'auto_increment')) |
|
4215 | 4207 | { |
4216 | - if(isset($this->display_as[$field->name])) |
|
4217 | - $this->add_fields[] = (object)array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4208 | + if (isset($this->display_as[$field->name])) |
|
4209 | + $this->add_fields[] = (object) array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4218 | 4210 | else |
4219 | - $this->add_fields[] = (object)array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4211 | + $this->add_fields[] = (object) array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4220 | 4212 | } |
4221 | 4213 | } |
4222 | 4214 | } |
@@ -4232,34 +4224,34 @@ discard block |
||
4232 | 4224 | */ |
4233 | 4225 | protected function get_edit_fields() |
4234 | 4226 | { |
4235 | - if($this->edit_fields_checked === false) |
|
4227 | + if ($this->edit_fields_checked === false) |
|
4236 | 4228 | { |
4237 | 4229 | $field_types = $this->get_field_types(); |
4238 | - if(!empty($this->edit_fields)) |
|
4230 | + if (!empty($this->edit_fields)) |
|
4239 | 4231 | { |
4240 | - foreach($this->edit_fields as $field_num => $field) |
|
4232 | + foreach ($this->edit_fields as $field_num => $field) |
|
4241 | 4233 | { |
4242 | - if(isset($this->display_as[$field])) |
|
4243 | - $this->edit_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4234 | + if (isset($this->display_as[$field])) |
|
4235 | + $this->edit_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4244 | 4236 | else |
4245 | - $this->edit_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4237 | + $this->edit_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4246 | 4238 | } |
4247 | 4239 | } |
4248 | 4240 | else |
4249 | 4241 | { |
4250 | 4242 | $this->edit_fields = array(); |
4251 | - foreach($field_types as $field) |
|
4243 | + foreach ($field_types as $field) |
|
4252 | 4244 | { |
4253 | 4245 | //Check if an unset_edit_field is initialize for this field name |
4254 | - if($this->unset_edit_fields !== null && is_array($this->unset_edit_fields) && in_array($field->name,$this->unset_edit_fields)) |
|
4246 | + if ($this->unset_edit_fields !== null && is_array($this->unset_edit_fields) && in_array($field->name, $this->unset_edit_fields)) |
|
4255 | 4247 | continue; |
4256 | 4248 | |
4257 | - if(!isset($field->db_extra) || $field->db_extra != 'auto_increment') |
|
4249 | + if (!isset($field->db_extra) || $field->db_extra != 'auto_increment') |
|
4258 | 4250 | { |
4259 | - if(isset($this->display_as[$field->name])) |
|
4260 | - $this->edit_fields[] = (object)array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4251 | + if (isset($this->display_as[$field->name])) |
|
4252 | + $this->edit_fields[] = (object) array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4261 | 4253 | else |
4262 | - $this->edit_fields[] = (object)array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4254 | + $this->edit_fields[] = (object) array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4263 | 4255 | } |
4264 | 4256 | } |
4265 | 4257 | } |
@@ -4275,34 +4267,34 @@ discard block |
||
4275 | 4267 | */ |
4276 | 4268 | protected function get_read_fields() |
4277 | 4269 | { |
4278 | - if($this->read_fields_checked === false) |
|
4270 | + if ($this->read_fields_checked === false) |
|
4279 | 4271 | { |
4280 | 4272 | $field_types = $this->get_field_types(); |
4281 | - if(!empty($this->read_fields)) |
|
4273 | + if (!empty($this->read_fields)) |
|
4282 | 4274 | { |
4283 | - foreach($this->read_fields as $field_num => $field) |
|
4275 | + foreach ($this->read_fields as $field_num => $field) |
|
4284 | 4276 | { |
4285 | - if(isset($this->display_as[$field])) |
|
4286 | - $this->read_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4277 | + if (isset($this->display_as[$field])) |
|
4278 | + $this->read_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $this->display_as[$field]); |
|
4287 | 4279 | else |
4288 | - $this->read_fields[$field_num] = (object)array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4280 | + $this->read_fields[$field_num] = (object) array('field_name' => $field, 'display_as' => $field_types[$field]->display_as); |
|
4289 | 4281 | } |
4290 | 4282 | } |
4291 | 4283 | else |
4292 | 4284 | { |
4293 | 4285 | $this->read_fields = array(); |
4294 | - foreach($field_types as $field) |
|
4286 | + foreach ($field_types as $field) |
|
4295 | 4287 | { |
4296 | 4288 | //Check if an unset_read_field is initialize for this field name |
4297 | - if($this->unset_read_fields !== null && is_array($this->unset_read_fields) && in_array($field->name,$this->unset_read_fields)) |
|
4289 | + if ($this->unset_read_fields !== null && is_array($this->unset_read_fields) && in_array($field->name, $this->unset_read_fields)) |
|
4298 | 4290 | continue; |
4299 | 4291 | |
4300 | - if(!isset($field->db_extra) || $field->db_extra != 'auto_increment') |
|
4292 | + if (!isset($field->db_extra) || $field->db_extra != 'auto_increment') |
|
4301 | 4293 | { |
4302 | - if(isset($this->display_as[$field->name])) |
|
4303 | - $this->read_fields[] = (object)array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4294 | + if (isset($this->display_as[$field->name])) |
|
4295 | + $this->read_fields[] = (object) array('field_name' => $field->name, 'display_as' => $this->display_as[$field->name]); |
|
4304 | 4296 | else |
4305 | - $this->read_fields[] = (object)array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4297 | + $this->read_fields[] = (object) array('field_name' => $field->name, 'display_as' => $field->display_as); |
|
4306 | 4298 | } |
4307 | 4299 | } |
4308 | 4300 | } |
@@ -4314,21 +4306,21 @@ discard block |
||
4314 | 4306 | |
4315 | 4307 | public function order_by($order_by, $direction = 'asc') |
4316 | 4308 | { |
4317 | - $this->order_by = array($order_by,$direction); |
|
4309 | + $this->order_by = array($order_by, $direction); |
|
4318 | 4310 | |
4319 | 4311 | return $this; |
4320 | 4312 | } |
4321 | 4313 | |
4322 | 4314 | public function where($key, $value = NULL, $escape = TRUE) |
4323 | 4315 | { |
4324 | - $this->where[] = array($key,$value,$escape); |
|
4316 | + $this->where[] = array($key, $value, $escape); |
|
4325 | 4317 | |
4326 | 4318 | return $this; |
4327 | 4319 | } |
4328 | 4320 | |
4329 | 4321 | public function or_where($key, $value = NULL, $escape = TRUE) |
4330 | 4322 | { |
4331 | - $this->or_where[] = array($key,$value,$escape); |
|
4323 | + $this->or_where[] = array($key, $value, $escape); |
|
4332 | 4324 | |
4333 | 4325 | return $this; |
4334 | 4326 | } |
@@ -4363,7 +4355,7 @@ discard block |
||
4363 | 4355 | |
4364 | 4356 | public function limit($limit, $offset = '') |
4365 | 4357 | { |
4366 | - $this->limit = array($limit,$offset); |
|
4358 | + $this->limit = array($limit, $offset); |
|
4367 | 4359 | |
4368 | 4360 | return $this; |
4369 | 4361 | } |
@@ -4381,33 +4373,33 @@ discard block |
||
4381 | 4373 | $ci = &get_instance(); |
4382 | 4374 | $ci->load->config('grocery_crud'); |
4383 | 4375 | |
4384 | - $this->config = (object)array(); |
|
4376 | + $this->config = (object) array(); |
|
4385 | 4377 | |
4386 | 4378 | /** Initialize all the config variables into this object */ |
4387 | 4379 | $this->config->default_language = $ci->config->item('grocery_crud_default_language'); |
4388 | - $this->config->date_format = $ci->config->item('grocery_crud_date_format'); |
|
4380 | + $this->config->date_format = $ci->config->item('grocery_crud_date_format'); |
|
4389 | 4381 | $this->config->default_per_page = $ci->config->item('grocery_crud_default_per_page'); |
4390 | - $this->config->file_upload_allow_file_types = $ci->config->item('grocery_crud_file_upload_allow_file_types'); |
|
4391 | - $this->config->file_upload_max_file_size = $ci->config->item('grocery_crud_file_upload_max_file_size'); |
|
4392 | - $this->config->default_text_editor = $ci->config->item('grocery_crud_default_text_editor'); |
|
4382 | + $this->config->file_upload_allow_file_types = $ci->config->item('grocery_crud_file_upload_allow_file_types'); |
|
4383 | + $this->config->file_upload_max_file_size = $ci->config->item('grocery_crud_file_upload_max_file_size'); |
|
4384 | + $this->config->default_text_editor = $ci->config->item('grocery_crud_default_text_editor'); |
|
4393 | 4385 | $this->config->text_editor_type = $ci->config->item('grocery_crud_text_editor_type'); |
4394 | 4386 | $this->config->character_limiter = $ci->config->item('grocery_crud_character_limiter'); |
4395 | - $this->config->dialog_forms = $ci->config->item('grocery_crud_dialog_forms'); |
|
4396 | - $this->config->paging_options = $ci->config->item('grocery_crud_paging_options'); |
|
4387 | + $this->config->dialog_forms = $ci->config->item('grocery_crud_dialog_forms'); |
|
4388 | + $this->config->paging_options = $ci->config->item('grocery_crud_paging_options'); |
|
4397 | 4389 | $this->config->default_theme = $ci->config->item('grocery_crud_default_theme'); |
4398 | 4390 | $this->config->environment = $ci->config->item('grocery_crud_environment'); |
4399 | 4391 | |
4400 | 4392 | /** Initialize default paths */ |
4401 | - $this->default_javascript_path = $this->default_assets_path.'/js'; |
|
4402 | - $this->default_css_path = $this->default_assets_path.'/css'; |
|
4403 | - $this->default_texteditor_path = $this->default_assets_path.'/texteditor'; |
|
4404 | - $this->default_theme_path = $this->default_assets_path.'/themes'; |
|
4393 | + $this->default_javascript_path = $this->default_assets_path.'/js'; |
|
4394 | + $this->default_css_path = $this->default_assets_path.'/css'; |
|
4395 | + $this->default_texteditor_path = $this->default_assets_path.'/texteditor'; |
|
4396 | + $this->default_theme_path = $this->default_assets_path.'/themes'; |
|
4405 | 4397 | |
4406 | 4398 | $this->character_limiter = $this->config->character_limiter; |
4407 | 4399 | |
4408 | 4400 | if ($this->character_limiter === 0 || $this->character_limiter === '0') { |
4409 | 4401 | $this->character_limiter = 1000000; //a very big number |
4410 | - } elseif($this->character_limiter === null || $this->character_limiter === false) { |
|
4402 | + } elseif ($this->character_limiter === null || $this->character_limiter === false) { |
|
4411 | 4403 | $this->character_limiter = 30; //is better to have the number 30 rather than the 0 value |
4412 | 4404 | } |
4413 | 4405 | |
@@ -4418,11 +4410,11 @@ discard block |
||
4418 | 4410 | |
4419 | 4411 | protected function _set_primary_keys_to_model() |
4420 | 4412 | { |
4421 | - if(!empty($this->primary_keys)) |
|
4413 | + if (!empty($this->primary_keys)) |
|
4422 | 4414 | { |
4423 | - foreach($this->primary_keys as $primary_key) |
|
4415 | + foreach ($this->primary_keys as $primary_key) |
|
4424 | 4416 | { |
4425 | - $this->basic_model->set_primary_key($primary_key['field_name'],$primary_key['table_name']); |
|
4417 | + $this->basic_model->set_primary_key($primary_key['field_name'], $primary_key['table_name']); |
|
4426 | 4418 | } |
4427 | 4419 | } |
4428 | 4420 | } |
@@ -4437,7 +4429,7 @@ discard block |
||
4437 | 4429 | $this->_load_language(); |
4438 | 4430 | $this->state_code = $this->getStateCode(); |
4439 | 4431 | |
4440 | - if($this->basic_model === null) |
|
4432 | + if ($this->basic_model === null) |
|
4441 | 4433 | $this->set_default_Model(); |
4442 | 4434 | |
4443 | 4435 | $this->set_basic_db_table($this->get_table()); |
@@ -4458,7 +4450,7 @@ discard block |
||
4458 | 4450 | { |
4459 | 4451 | $this->pre_render(); |
4460 | 4452 | |
4461 | - if( $this->state_code != 0 ) |
|
4453 | + if ($this->state_code != 0) |
|
4462 | 4454 | { |
4463 | 4455 | $this->state_info = $this->getStateInfo(); |
4464 | 4456 | } |
@@ -4471,13 +4463,13 @@ discard block |
||
4471 | 4463 | switch ($this->state_code) { |
4472 | 4464 | case 15://success |
4473 | 4465 | case 1://list |
4474 | - if($this->unset_list) |
|
4466 | + if ($this->unset_list) |
|
4475 | 4467 | { |
4476 | 4468 | throw new Exception('You don\'t have permissions for this operation', 14); |
4477 | 4469 | die(); |
4478 | 4470 | } |
4479 | 4471 | |
4480 | - if($this->theme === null) |
|
4472 | + if ($this->theme === null) |
|
4481 | 4473 | $this->set_theme($this->default_theme); |
4482 | 4474 | $this->setThemeBasics(); |
4483 | 4475 | |
@@ -4485,18 +4477,18 @@ discard block |
||
4485 | 4477 | |
4486 | 4478 | $state_info = $this->getStateInfo(); |
4487 | 4479 | |
4488 | - $this->showList(false,$state_info); |
|
4480 | + $this->showList(false, $state_info); |
|
4489 | 4481 | |
4490 | 4482 | break; |
4491 | 4483 | |
4492 | 4484 | case 2://add |
4493 | - if($this->unset_add) |
|
4485 | + if ($this->unset_add) |
|
4494 | 4486 | { |
4495 | 4487 | throw new Exception('You don\'t have permissions for this operation', 14); |
4496 | 4488 | die(); |
4497 | 4489 | } |
4498 | 4490 | |
4499 | - if($this->theme === null) |
|
4491 | + if ($this->theme === null) |
|
4500 | 4492 | $this->set_theme($this->default_theme); |
4501 | 4493 | $this->setThemeBasics(); |
4502 | 4494 | |
@@ -4507,13 +4499,13 @@ discard block |
||
4507 | 4499 | break; |
4508 | 4500 | |
4509 | 4501 | case 3://edit |
4510 | - if($this->unset_edit) |
|
4502 | + if ($this->unset_edit) |
|
4511 | 4503 | { |
4512 | 4504 | throw new Exception('You don\'t have permissions for this operation', 14); |
4513 | 4505 | die(); |
4514 | 4506 | } |
4515 | 4507 | |
4516 | - if($this->theme === null) |
|
4508 | + if ($this->theme === null) |
|
4517 | 4509 | $this->set_theme($this->default_theme); |
4518 | 4510 | $this->setThemeBasics(); |
4519 | 4511 | |
@@ -4526,7 +4518,7 @@ discard block |
||
4526 | 4518 | break; |
4527 | 4519 | |
4528 | 4520 | case 4://delete |
4529 | - if($this->unset_delete) |
|
4521 | + if ($this->unset_delete) |
|
4530 | 4522 | { |
4531 | 4523 | throw new Exception('This user is not allowed to do this operation', 14); |
4532 | 4524 | die(); |
@@ -4535,11 +4527,11 @@ discard block |
||
4535 | 4527 | $state_info = $this->getStateInfo(); |
4536 | 4528 | $delete_result = $this->db_delete($state_info); |
4537 | 4529 | |
4538 | - $this->delete_layout( $delete_result ); |
|
4530 | + $this->delete_layout($delete_result); |
|
4539 | 4531 | break; |
4540 | 4532 | |
4541 | 4533 | case 5://insert |
4542 | - if($this->unset_add) |
|
4534 | + if ($this->unset_add) |
|
4543 | 4535 | { |
4544 | 4536 | throw new Exception('This user is not allowed to do this operation', 14); |
4545 | 4537 | die(); |
@@ -4552,7 +4544,7 @@ discard block |
||
4552 | 4544 | break; |
4553 | 4545 | |
4554 | 4546 | case 6://update |
4555 | - if($this->unset_edit) |
|
4547 | + if ($this->unset_edit) |
|
4556 | 4548 | { |
4557 | 4549 | throw new Exception('This user is not allowed to do this operation', 14); |
4558 | 4550 | die(); |
@@ -4561,18 +4553,18 @@ discard block |
||
4561 | 4553 | $state_info = $this->getStateInfo(); |
4562 | 4554 | $update_result = $this->db_update($state_info); |
4563 | 4555 | |
4564 | - $this->update_layout( $update_result,$state_info); |
|
4556 | + $this->update_layout($update_result, $state_info); |
|
4565 | 4557 | break; |
4566 | 4558 | |
4567 | 4559 | case 7://ajax_list |
4568 | 4560 | |
4569 | - if($this->unset_list) |
|
4561 | + if ($this->unset_list) |
|
4570 | 4562 | { |
4571 | 4563 | throw new Exception('You don\'t have permissions for this operation', 14); |
4572 | 4564 | die(); |
4573 | 4565 | } |
4574 | 4566 | |
4575 | - if($this->theme === null) |
|
4567 | + if ($this->theme === null) |
|
4576 | 4568 | $this->set_theme($this->default_theme); |
4577 | 4569 | $this->setThemeBasics(); |
4578 | 4570 | |
@@ -4587,7 +4579,7 @@ discard block |
||
4587 | 4579 | |
4588 | 4580 | case 8://ajax_list_info |
4589 | 4581 | |
4590 | - if($this->theme === null) |
|
4582 | + if ($this->theme === null) |
|
4591 | 4583 | $this->set_theme($this->default_theme); |
4592 | 4584 | $this->setThemeBasics(); |
4593 | 4585 | |
@@ -4650,13 +4642,13 @@ discard block |
||
4650 | 4642 | //a big number just to ensure that the table characters will not be cutted. |
4651 | 4643 | $this->character_limiter = 1000000; |
4652 | 4644 | |
4653 | - if($this->unset_export) |
|
4645 | + if ($this->unset_export) |
|
4654 | 4646 | { |
4655 | 4647 | throw new Exception('You don\'t have permissions for this operation', 15); |
4656 | 4648 | die(); |
4657 | 4649 | } |
4658 | 4650 | |
4659 | - if($this->theme === null) |
|
4651 | + if ($this->theme === null) |
|
4660 | 4652 | $this->set_theme($this->default_theme); |
4661 | 4653 | $this->setThemeBasics(); |
4662 | 4654 | |
@@ -4671,13 +4663,13 @@ discard block |
||
4671 | 4663 | //a big number just to ensure that the table characters will not be cutted. |
4672 | 4664 | $this->character_limiter = 1000000; |
4673 | 4665 | |
4674 | - if($this->unset_print) |
|
4666 | + if ($this->unset_print) |
|
4675 | 4667 | { |
4676 | 4668 | throw new Exception('You don\'t have permissions for this operation', 15); |
4677 | 4669 | die(); |
4678 | 4670 | } |
4679 | 4671 | |
4680 | - if($this->theme === null) |
|
4672 | + if ($this->theme === null) |
|
4681 | 4673 | $this->set_theme($this->default_theme); |
4682 | 4674 | $this->setThemeBasics(); |
4683 | 4675 | |
@@ -4689,13 +4681,13 @@ discard block |
||
4689 | 4681 | break; |
4690 | 4682 | |
4691 | 4683 | case grocery_CRUD_States::STATE_READ: |
4692 | - if($this->unset_read) |
|
4684 | + if ($this->unset_read) |
|
4693 | 4685 | { |
4694 | 4686 | throw new Exception('You don\'t have permissions for this operation', 14); |
4695 | 4687 | die(); |
4696 | 4688 | } |
4697 | 4689 | |
4698 | - if($this->theme === null) |
|
4690 | + if ($this->theme === null) |
|
4699 | 4691 | $this->set_theme($this->default_theme); |
4700 | 4692 | $this->setThemeBasics(); |
4701 | 4693 | |
@@ -4709,7 +4701,7 @@ discard block |
||
4709 | 4701 | |
4710 | 4702 | case grocery_CRUD_States::STATE_DELETE_MULTIPLE: |
4711 | 4703 | |
4712 | - if($this->unset_delete) |
|
4704 | + if ($this->unset_delete) |
|
4713 | 4705 | { |
4714 | 4706 | throw new Exception('This user is not allowed to do this operation'); |
4715 | 4707 | die(); |
@@ -4729,10 +4721,10 @@ discard block |
||
4729 | 4721 | |
4730 | 4722 | protected function get_common_data() |
4731 | 4723 | { |
4732 | - $data = (object)array(); |
|
4724 | + $data = (object) array(); |
|
4733 | 4725 | |
4734 | - $data->subject = $this->subject; |
|
4735 | - $data->subject_plural = $this->subject_plural; |
|
4726 | + $data->subject = $this->subject; |
|
4727 | + $data->subject_plural = $this->subject_plural; |
|
4736 | 4728 | |
4737 | 4729 | return $data; |
4738 | 4730 | } |
@@ -4845,7 +4837,7 @@ discard block |
||
4845 | 4837 | * @param string $column |
4846 | 4838 | * @param mixed $callback |
4847 | 4839 | */ |
4848 | - public function callback_column($column ,$callback = null) |
|
4840 | + public function callback_column($column, $callback = null) |
|
4849 | 4841 | { |
4850 | 4842 | $this->callback_column[$column] = $callback; |
4851 | 4843 | |
@@ -4940,15 +4932,15 @@ discard block |
||
4940 | 4932 | */ |
4941 | 4933 | public function get_table() |
4942 | 4934 | { |
4943 | - if($this->basic_db_table_checked) |
|
4935 | + if ($this->basic_db_table_checked) |
|
4944 | 4936 | { |
4945 | 4937 | return $this->basic_db_table; |
4946 | 4938 | } |
4947 | - elseif( $this->basic_db_table !== null ) |
|
4939 | + elseif ($this->basic_db_table !== null) |
|
4948 | 4940 | { |
4949 | - if(!$this->table_exists($this->basic_db_table)) |
|
4941 | + if (!$this->table_exists($this->basic_db_table)) |
|
4950 | 4942 | { |
4951 | - throw new Exception('The table name does not exist. Please check you database and try again.',11); |
|
4943 | + throw new Exception('The table name does not exist. Please check you database and try again.', 11); |
|
4952 | 4944 | die(); |
4953 | 4945 | } |
4954 | 4946 | $this->basic_db_table_checked = true; |
@@ -4958,7 +4950,7 @@ discard block |
||
4958 | 4950 | { |
4959 | 4951 | //Last try , try to find the table from your view / function name!!! Not suggested but it works . |
4960 | 4952 | $last_chance_table_name = $this->get_method_name(); |
4961 | - if($this->table_exists($last_chance_table_name)) |
|
4953 | + if ($this->table_exists($last_chance_table_name)) |
|
4962 | 4954 | { |
4963 | 4955 | $this->set_table($last_chance_table_name); |
4964 | 4956 | } |
@@ -4978,7 +4970,7 @@ discard block |
||
4978 | 4970 | { |
4979 | 4971 | $args = func_get_args(); |
4980 | 4972 | |
4981 | - if(isset($args[0]) && is_array($args[0])) |
|
4973 | + if (isset($args[0]) && is_array($args[0])) |
|
4982 | 4974 | { |
4983 | 4975 | $args = $args[0]; |
4984 | 4976 | } |
@@ -4997,7 +4989,7 @@ discard block |
||
4997 | 4989 | { |
4998 | 4990 | $args = func_get_args(); |
4999 | 4991 | |
5000 | - if(isset($args[0]) && is_array($args[0])) |
|
4992 | + if (isset($args[0]) && is_array($args[0])) |
|
5001 | 4993 | { |
5002 | 4994 | $args = $args[0]; |
5003 | 4995 | } |
@@ -5015,11 +5007,11 @@ discard block |
||
5015 | 5007 | */ |
5016 | 5008 | public function set_table($table_name) |
5017 | 5009 | { |
5018 | - if(!empty($table_name) && $this->basic_db_table === null) |
|
5010 | + if (!empty($table_name) && $this->basic_db_table === null) |
|
5019 | 5011 | { |
5020 | 5012 | $this->basic_db_table = $table_name; |
5021 | 5013 | } |
5022 | - elseif(!empty($table_name)) |
|
5014 | + elseif (!empty($table_name)) |
|
5023 | 5015 | { |
5024 | 5016 | throw new Exception('You have already insert a table name once...', 1); |
5025 | 5017 | } |
@@ -5076,7 +5068,7 @@ discard block |
||
5076 | 5068 | public function set_subject($subject, $subject_plural = null) |
5077 | 5069 | { |
5078 | 5070 | $this->subject = $subject; |
5079 | - $this->subject_plural = $subject_plural === null ? $subject : $subject_plural; |
|
5071 | + $this->subject_plural = $subject_plural === null ? $subject : $subject_plural; |
|
5080 | 5072 | |
5081 | 5073 | return $this; |
5082 | 5074 | } |
@@ -5090,17 +5082,17 @@ discard block |
||
5090 | 5082 | * @param $css_class |
5091 | 5083 | * @param $url_callback |
5092 | 5084 | */ |
5093 | - public function add_action( $label, $image_url = '', $link_url = '', $css_class = '', $url_callback = null) |
|
5085 | + public function add_action($label, $image_url = '', $link_url = '', $css_class = '', $url_callback = null) |
|
5094 | 5086 | { |
5095 | - $unique_id = substr($label,0,1).substr(md5($label.$link_url),-8); //The unique id is used for class name so it must begin with a string |
|
5087 | + $unique_id = substr($label, 0, 1).substr(md5($label.$link_url), -8); //The unique id is used for class name so it must begin with a string |
|
5096 | 5088 | |
5097 | - $this->actions[$unique_id] = (object)array( |
|
5089 | + $this->actions[$unique_id] = (object) array( |
|
5098 | 5090 | 'label' => $label, |
5099 | 5091 | 'image_url' => $image_url, |
5100 | 5092 | 'link_url' => $link_url, |
5101 | 5093 | 'css_class' => $css_class, |
5102 | 5094 | 'url_callback' => $url_callback, |
5103 | - 'url_has_http' => substr($link_url,0,7) == 'http://' || substr($link_url,0,8) == 'https://' ? true : false |
|
5095 | + 'url_has_http' => substr($link_url, 0, 7) == 'http://' || substr($link_url, 0, 8) == 'https://' ? true : false |
|
5104 | 5096 | ); |
5105 | 5097 | |
5106 | 5098 | return $this; |
@@ -5116,9 +5108,9 @@ discard block |
||
5116 | 5108 | * @param string $order_by |
5117 | 5109 | * @return Grocery_CRUD |
5118 | 5110 | */ |
5119 | - public function set_relation($field_name , $related_table, $related_title_field, $where_clause = null, $order_by = null) |
|
5111 | + public function set_relation($field_name, $related_table, $related_title_field, $where_clause = null, $order_by = null) |
|
5120 | 5112 | { |
5121 | - $this->relation[$field_name] = array($field_name, $related_table,$related_title_field, $where_clause, $order_by); |
|
5113 | + $this->relation[$field_name] = array($field_name, $related_table, $related_title_field, $where_clause, $order_by); |
|
5122 | 5114 | return $this; |
5123 | 5115 | } |
5124 | 5116 | |
@@ -5135,16 +5127,16 @@ discard block |
||
5135 | 5127 | * @param mixed $where_clause |
5136 | 5128 | * @return Grocery_CRUD |
5137 | 5129 | */ |
5138 | - public function set_relation_n_n($field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table, $primary_key_alias_to_selection_table , $title_field_selection_table , $priority_field_relation_table = null, $where_clause = null) |
|
5130 | + public function set_relation_n_n($field_name, $relation_table, $selection_table, $primary_key_alias_to_this_table, $primary_key_alias_to_selection_table, $title_field_selection_table, $priority_field_relation_table = null, $where_clause = null) |
|
5139 | 5131 | { |
5140 | 5132 | $this->relation_n_n[$field_name] = |
5141 | - (object)array( |
|
5133 | + (object) array( |
|
5142 | 5134 | 'field_name' => $field_name, |
5143 | 5135 | 'relation_table' => $relation_table, |
5144 | 5136 | 'selection_table' => $selection_table, |
5145 | 5137 | 'primary_key_alias_to_this_table' => $primary_key_alias_to_this_table, |
5146 | - 'primary_key_alias_to_selection_table' => $primary_key_alias_to_selection_table , |
|
5147 | - 'title_field_selection_table' => $title_field_selection_table , |
|
5138 | + 'primary_key_alias_to_selection_table' => $primary_key_alias_to_selection_table, |
|
5139 | + 'title_field_selection_table' => $title_field_selection_table, |
|
5148 | 5140 | 'priority_field_relation_table' => $priority_field_relation_table, |
5149 | 5141 | 'where_clause' => $where_clause |
5150 | 5142 | ); |
@@ -5162,8 +5154,8 @@ discard block |
||
5162 | 5154 | */ |
5163 | 5155 | public function set_field_upload($field_name, $upload_dir = '', $allowed_file_types = '') |
5164 | 5156 | { |
5165 | - $upload_dir = !empty($upload_dir) && substr($upload_dir,-1,1) == '/' |
|
5166 | - ? substr($upload_dir,0,-1) |
|
5157 | + $upload_dir = !empty($upload_dir) && substr($upload_dir, -1, 1) == '/' |
|
5158 | + ? substr($upload_dir, 0, -1) |
|
5167 | 5159 | : $upload_dir; |
5168 | 5160 | $upload_dir = !empty($upload_dir) ? $upload_dir : 'assets/uploads/files'; |
5169 | 5161 | |
@@ -5182,22 +5174,22 @@ discard block |
||
5182 | 5174 | } |
5183 | 5175 | } |
5184 | 5176 | |
5185 | -if(defined('CI_VERSION')) |
|
5177 | +if (defined('CI_VERSION')) |
|
5186 | 5178 | { |
5187 | 5179 | $ci = &get_instance(); |
5188 | 5180 | $ci->load->library('Form_validation'); |
5189 | 5181 | |
5190 | - class grocery_CRUD_Form_validation extends CI_Form_validation{ |
|
5182 | + class grocery_CRUD_Form_validation extends CI_Form_validation { |
|
5191 | 5183 | |
5192 | 5184 | public $CI; |
5193 | 5185 | public $_field_data = array(); |
5194 | 5186 | public $_config_rules = array(); |
5195 | 5187 | public $_error_array = array(); |
5196 | - public $_error_messages = array(); |
|
5188 | + public $_error_messages = array(); |
|
5197 | 5189 | public $_error_prefix = '<p>'; |
5198 | 5190 | public $_error_suffix = '</p>'; |
5199 | - public $error_string = ''; |
|
5200 | - public $_safe_form_data = FALSE; |
|
5191 | + public $error_string = ''; |
|
5192 | + public $_safe_form_data = FALSE; |
|
5201 | 5193 | } |
5202 | 5194 | } |
5203 | 5195 | |
@@ -5217,7 +5209,7 @@ discard block |
||
5217 | 5209 | private $options; |
5218 | 5210 | public $default_config_path = null; |
5219 | 5211 | |
5220 | - function __construct($options=null) { |
|
5212 | + function __construct($options = null) { |
|
5221 | 5213 | $this->options = array( |
5222 | 5214 | 'script_url' => $this->getFullUrl().'/'.basename(__FILE__), |
5223 | 5215 | 'upload_dir' => dirname(__FILE__).'/files/', |
@@ -5256,7 +5248,7 @@ discard block |
||
5256 | 5248 | ); |
5257 | 5249 | if ($options) { |
5258 | 5250 | // Or else for PHP >= 5.3.0 use: $this->options = array_replace_recursive($this->options, $options); |
5259 | - foreach($options as $option_name => $option) |
|
5251 | + foreach ($options as $option_name => $option) |
|
5260 | 5252 | { |
5261 | 5253 | $this->options[$option_name] = $option; |
5262 | 5254 | } |
@@ -5270,7 +5262,7 @@ discard block |
||
5270 | 5262 | (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. |
5271 | 5263 | (isset($_SERVER['HTTPS']) && $_SERVER['SERVER_PORT'] === 443 || |
5272 | 5264 | $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). |
5273 | - substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); |
|
5265 | + substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')); |
|
5274 | 5266 | } |
5275 | 5267 | |
5276 | 5268 | private function get_file_object($file_name) { |
@@ -5280,7 +5272,7 @@ discard block |
||
5280 | 5272 | $file->name = $file_name; |
5281 | 5273 | $file->size = filesize($file_path); |
5282 | 5274 | $file->url = $this->options['upload_url'].rawurlencode($file->name); |
5283 | - foreach($this->options['image_versions'] as $version => $options) { |
|
5275 | + foreach ($this->options['image_versions'] as $version => $options) { |
|
5284 | 5276 | if (is_file($options['upload_dir'].$file_name)) { |
5285 | 5277 | $file->{$version.'_url'} = $options['upload_url'] |
5286 | 5278 | .rawurlencode($file->name); |
@@ -5356,7 +5348,7 @@ discard block |
||
5356 | 5348 | |
5357 | 5349 | private function has_error($uploaded_file, $file, $error) { |
5358 | 5350 | if ($error) { |
5359 | - switch($error) { |
|
5351 | + switch ($error) { |
|
5360 | 5352 | case UPLOAD_ERR_INI_SIZE: |
5361 | 5353 | return 'The uploaded file exceeds the upload_max_filesize directive in php.ini.'; |
5362 | 5354 | break; |
@@ -5416,7 +5408,7 @@ discard block |
||
5416 | 5408 | } |
5417 | 5409 | |
5418 | 5410 | //Ensure that we don't have disallowed characters and add a unique id just to ensure that the file name will be unique |
5419 | - $file_name = substr(uniqid(),-5).'-'.$this->_transliterate_characters($file_name); |
|
5411 | + $file_name = substr(uniqid(), -5).'-'.$this->_transliterate_characters($file_name); |
|
5420 | 5412 | |
5421 | 5413 | //all the characters has to be lowercase |
5422 | 5414 | $file_name = strtolower($file_name); |
@@ -5427,7 +5419,7 @@ discard block |
||
5427 | 5419 | private function _transliterate_characters($file_name) |
5428 | 5420 | { |
5429 | 5421 | include($this->default_config_path.'/translit_chars.php'); |
5430 | - if ( isset($translit_characters)) |
|
5422 | + if (isset($translit_characters)) |
|
5431 | 5423 | { |
5432 | 5424 | $file_name = preg_replace(array_keys($translit_characters), array_values($translit_characters), $file_name); |
5433 | 5425 | } |
@@ -5500,7 +5492,7 @@ discard block |
||
5500 | 5492 | $this->orient_image($file_path); |
5501 | 5493 | } |
5502 | 5494 | $file->url = $this->options['upload_url'].rawurlencode($file->name); |
5503 | - foreach($this->options['image_versions'] as $version => $options) { |
|
5495 | + foreach ($this->options['image_versions'] as $version => $options) { |
|
5504 | 5496 | if ($this->create_scaled_image($file->name, $options)) { |
5505 | 5497 | $file->{$version.'_url'} = $options['upload_url'] |
5506 | 5498 | .rawurlencode($file->name); |
@@ -5587,7 +5579,7 @@ discard block |
||
5587 | 5579 | $file_path = $this->options['upload_dir'].$file_name; |
5588 | 5580 | $success = is_file($file_path) && $file_name[0] !== '.' && unlink($file_path); |
5589 | 5581 | if ($success) { |
5590 | - foreach($this->options['image_versions'] as $version => $options) { |
|
5582 | + foreach ($this->options['image_versions'] as $version => $options) { |
|
5591 | 5583 | $file = $options['upload_dir'].$file_name; |
5592 | 5584 | if (is_file($file)) { |
5593 | 5585 | unlink($file); |
@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php defined('BASEPATH') OR exit('No direct script access allowed'); ?> |
2 | 2 | |
3 | -<?php foreach($css_files as $file): ?> |
|
3 | +<?php foreach ($css_files as $file): ?> |
|
4 | 4 | <link type="text/css" rel="stylesheet" href="<?= $file; ?>" /> |
5 | 5 | <?php endforeach; ?> |
6 | -<?php foreach($js_files as $file): ?> |
|
6 | +<?php foreach ($js_files as $file): ?> |
|
7 | 7 | <script src="<?= $file; ?>"></script> |
8 | 8 | <?php endforeach; ?> |
9 | 9 | \ No newline at end of file |
@@ -56,13 +56,13 @@ |
||
56 | 56 | <tbody> |
57 | 57 | <tr> |
58 | 58 | <td><i class="fa fa-paperclip" aria-hidden="true"></i> <a href="<?= base_url('computing-support/new-account'); ?>">New Staff Account</a> |
59 | - - <a href="<?= base_url('/computing-support/new-account/pending');?>">Pending</a> |
|
59 | + - <a href="<?= base_url('/computing-support/new-account/pending'); ?>">Pending</a> |
|
60 | 60 | - <a href="<?= base_url('/computing-support/new-account/history'); ?>">History</a> |
61 | 61 | <td></td><td></td><td></td> |
62 | 62 | </tr> |
63 | 63 | <tr> |
64 | 64 | <td><i class="fa fa-paperclip" aria-hidden="true"></i> <a href="<?= base_url('computing-support/new-account/disable-account'); ?>">Disable Staff Account</a> |
65 | - - <a href="<?= base_url('/computing-support/new-account/disable-account/pending');?>">Pending</a> |
|
65 | + - <a href="<?= base_url('/computing-support/new-account/disable-account/pending'); ?>">Pending</a> |
|
66 | 66 | - <a href="<?= base_url('/computing-support/new-account/disable-account/history'); ?>">History</a> |
67 | 67 | </td> |
68 | 68 | <td></td><td></td><td></td> |
@@ -47,7 +47,7 @@ |
||
47 | 47 | <tbody> |
48 | 48 | <tr> |
49 | 49 | <td><i class="fa fa-paperclip" aria-hidden="true"></i> <a href="<?= base_url('admin/jobs-logs/ad-user-sync'); ?>">AD User Sync</a> |
50 | - - <a href="<?= base_url('core/jobs/ad-users-sync');?>">Run Now</a> |
|
50 | + - <a href="<?= base_url('core/jobs/ad-users-sync'); ?>">Run Now</a> |
|
51 | 51 | <td></td><td></td><td></td> |
52 | 52 | </tr> |
53 | 53 | </tbody> |
@@ -41,8 +41,8 @@ |
||
41 | 41 | </thead> |
42 | 42 | <tbody> |
43 | 43 | <tr> |
44 | - <td><i class="fa fa-paperclip" aria-hidden="true"></i> <a href="<?= base_url('marketing/visitor');?>">Open Day Visitor Form</a> |
|
45 | - - <a href="<?= base_url('marketing/visitor/history');?>">History</a> |
|
44 | + <td><i class="fa fa-paperclip" aria-hidden="true"></i> <a href="<?= base_url('marketing/visitor'); ?>">Open Day Visitor Form</a> |
|
45 | + - <a href="<?= base_url('marketing/visitor/history'); ?>">History</a> |
|
46 | 46 | <td></td><td></td><td></td> |
47 | 47 | </tr> |
48 | 48 | <tr> |
@@ -6,7 +6,7 @@ |
||
6 | 6 | $query = $this->db->get('users_ad'); |
7 | 7 | if ($query->num_rows() > 0) { |
8 | 8 | foreach ($query->result_array() as $row) { |
9 | - $row_set[] = htmlentities(stripslashes($row['first_name'] . ' ' . $row['last_name'])); //build an array |
|
9 | + $row_set[] = htmlentities(stripslashes($row['first_name'].' '.$row['last_name'])); //build an array |
|
10 | 10 | } |
11 | 11 | } |
12 | 12 | ?> |