@@ -27,19 +27,19 @@ discard block |
||
| 27 | 27 | $custom_template = null; |
| 28 | 28 | $method = $this->router()->target_method(); |
| 29 | 29 | |
| 30 | - foreach(['prepare', "before_$method", $method, "after_$method"] as $step => $chainling) |
|
| 30 | + foreach (['prepare', "before_$method", $method, "after_$method"] as $step => $chainling) |
|
| 31 | 31 | { |
| 32 | 32 | $this->search_and_execute_trait_methods($chainling); |
| 33 | - if(method_exists($this, $chainling) && empty($this->errors())) |
|
| 33 | + if (method_exists($this, $chainling) && empty($this->errors())) |
|
| 34 | 34 | { |
| 35 | 35 | $res = $this->$chainling(); |
| 36 | 36 | |
| 37 | - if($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution |
|
| 37 | + if ($this->logger()->has_halting_messages()) // logger handled a critical error during the chailing execution |
|
| 38 | 38 | { |
| 39 | 39 | break; // dont go on with other |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - if($chainling === $method) |
|
| 42 | + if ($chainling === $method) |
|
| 43 | 43 | { |
| 44 | 44 | |
| 45 | 45 | $custom_template = $res; |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages |
|
| 50 | + if (method_exists($this, 'conclude')) // conclude always executed, even with has_halting_messages |
|
| 51 | 51 | $this->conclude(); |
| 52 | 52 | |
| 53 | - if(method_exists($this, 'display')) |
|
| 53 | + if (method_exists($this, 'display')) |
|
| 54 | 54 | $template = $this->display($custom_template); |
| 55 | 55 | } |
| 56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | parent::prepare(); |
| 60 | 60 | |
| 61 | - if(!class_exists($this->model_class_name = $this->class_name())) |
|
| 61 | + if (!class_exists($this->model_class_name = $this->class_name())) |
|
| 62 | 62 | throw new \Exception("!class_exists($this->model_class_name)"); |
| 63 | 63 | |
| 64 | 64 | $this->model_type = $this->model_class_name::model_type(); |
@@ -68,22 +68,22 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | $pk_values = []; |
| 70 | 70 | |
| 71 | - if($this->router()->submits()) |
|
| 71 | + if ($this->router()->submits()) |
|
| 72 | 72 | { |
| 73 | 73 | $this->form_model->import($this->sanitize_post_data($this->router()->submitted())); |
| 74 | 74 | $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->submitted()); |
| 75 | 75 | |
| 76 | 76 | $this->load_model = $this->model_class_name::exists($pk_values); |
| 77 | 77 | } |
| 78 | - elseif($this->router()->requests()) |
|
| 78 | + elseif ($this->router()->requests()) |
|
| 79 | 79 | { |
| 80 | 80 | $pk_values = $this->model_class_name::table()->primary_keys_match($this->router()->params()); |
| 81 | 81 | |
| 82 | - if(!is_null($this->load_model = $this->model_class_name::exists($pk_values))) |
|
| 82 | + if (!is_null($this->load_model = $this->model_class_name::exists($pk_values))) |
|
| 83 | 83 | $this->form_model = clone $this->load_model; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if(!is_null($this->load_model) && $this->load_model->traceable()) |
|
| 86 | + if (!is_null($this->load_model) && $this->load_model->traceable()) |
|
| 87 | 87 | $this->viewport('load_model_history', $this->load_model->traces() ?? []); |
| 88 | 88 | } |
| 89 | 89 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | // ----------- META ----------- |
| 95 | 95 | public function class_name() : string |
| 96 | 96 | { |
| 97 | - if(is_null($this->model_class_name)) |
|
| 97 | + if (is_null($this->model_class_name)) |
|
| 98 | 98 | { |
| 99 | 99 | $this->model_class_name = get_called_class(); |
| 100 | 100 | $this->model_class_name = str_replace('\Controllers\\', '\Models\\', $this->model_class_name); |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | public function persist_model($model) : ?ModelInterface |
| 108 | 108 | { |
| 109 | 109 | $this->errors = $model->save($this->operator()->operator_id()); // returns [errors] |
| 110 | - if(empty($this->errors())) |
|
| 110 | + if (empty($this->errors())) |
|
| 111 | 111 | { |
| 112 | 112 | $this->logger()->nice('CRUDITES_INSTANCE_ALTERED', ['MODEL_'.get_class($model)::model_type().'_INSTANCE']); |
| 113 | 113 | return $model; |
| 114 | 114 | } |
| 115 | - foreach($this->errors() as $field => $error_msg) |
|
| 115 | + foreach ($this->errors() as $field => $error_msg) |
|
| 116 | 116 | $this->logger()->warning($error_msg, [$field]); |
| 117 | 117 | |
| 118 | 118 | return null; |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | return $this->listing(); //default dashboard is a listing |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function listing($model=null,$filters=[],$options=[]) |
|
| 126 | + public function listing($model = null, $filters = [], $options = []) |
|
| 127 | 127 | { |
| 128 | 128 | $class_name = is_null($model) ? $this->model_class_name : get_class($model); |
| 129 | 129 | |
| 130 | - if(!isset($filters['date_start'])) $filters['date_start'] = $this->box('StateAgent')->filters('date_start'); |
|
| 131 | - if(!isset($filters['date_stop'])) $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop'); |
|
| 130 | + if (!isset($filters['date_start'])) $filters['date_start'] = $this->box('StateAgent')->filters('date_start'); |
|
| 131 | + if (!isset($filters['date_stop'])) $filters['date_stop'] = $this->box('StateAgent')->filters('date_stop'); |
|
| 132 | 132 | |
| 133 | 133 | // dd($filters); |
| 134 | 134 | $listing = $class_name::filter($filters); |
@@ -139,24 +139,24 @@ discard block |
||
| 139 | 139 | public function viewport_listing($class_name, $listing, $listing_template) |
| 140 | 140 | { |
| 141 | 141 | $listing_fields = []; |
| 142 | - if(empty($listing)) |
|
| 142 | + if (empty($listing)) |
|
| 143 | 143 | { |
| 144 | - foreach($class_name::table()->columns() as $column) |
|
| 144 | + foreach ($class_name::table()->columns() as $column) |
|
| 145 | 145 | { |
| 146 | 146 | |
| 147 | - if(!$column->is_auto_incremented() && !$column->is_hidden()) |
|
| 148 | - $listing_fields[$column->name()]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name())); |
|
| 147 | + if (!$column->is_auto_incremented() && !$column->is_hidden()) |
|
| 148 | + $listing_fields[$column->name()] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $column->name())); |
|
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | else |
| 152 | 152 | { |
| 153 | 153 | $current = current($listing); |
| 154 | - if(is_object($current)) |
|
| 154 | + if (is_object($current)) |
|
| 155 | 155 | $current = get_object_vars($current); |
| 156 | 156 | |
| 157 | - foreach(array_keys($current) as $field) |
|
| 157 | + foreach (array_keys($current) as $field) |
|
| 158 | 158 | { |
| 159 | - $listing_fields[$field]=L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field)); |
|
| 159 | + $listing_fields[$field] = L(sprintf('MODEL_%s_FIELD_%s', $class_name::model_type(), $field)); |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | } |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | $this->edit(); |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function edit(){} |
|
| 181 | + public function edit() {} |
|
| 182 | 182 | |
| 183 | 183 | public function save() |
| 184 | 184 | { |
| 185 | 185 | $model = $this->persist_model($this->form_model); |
| 186 | 186 | |
| 187 | - if(empty($this->errors())) |
|
| 187 | + if (empty($this->errors())) |
|
| 188 | 188 | $this->route_back($model); |
| 189 | 189 | else |
| 190 | 190 | { |
@@ -195,21 +195,21 @@ discard block |
||
| 195 | 195 | |
| 196 | 196 | public function before_edit() |
| 197 | 197 | { |
| 198 | - if(!is_null($this->router()->params('id')) && is_null($this->load_model)) |
|
| 198 | + if (!is_null($this->router()->params('id')) && is_null($this->load_model)) |
|
| 199 | 199 | { |
| 200 | 200 | $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_class_name::model_type().'_INSTANCE']); |
| 201 | 201 | $this->router()->hop($this->model_class_name::model_type()); |
| 202 | 202 | } |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function before_save() : array { return [];} |
|
| 205 | + public function before_save() : array { return []; } |
|
| 206 | 206 | |
| 207 | 207 | // default: hop to altered object |
| 208 | - public function after_save() {$this->router()->hop($this->route_back());} |
|
| 208 | + public function after_save() {$this->router()->hop($this->route_back()); } |
|
| 209 | 209 | |
| 210 | 210 | public function destroy_confirm() |
| 211 | 211 | { |
| 212 | - if(is_null($this->load_model)) |
|
| 212 | + if (is_null($this->load_model)) |
|
| 213 | 213 | { |
| 214 | 214 | $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']); |
| 215 | 215 | $this->router()->hop($this->model_type); |
@@ -222,12 +222,12 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure |
| 224 | 224 | { |
| 225 | - if(is_null($this->load_model)) |
|
| 225 | + if (is_null($this->load_model)) |
|
| 226 | 226 | { |
| 227 | 227 | $this->logger()->warning('CRUDITES_ERR_INSTANCE_NOT_FOUND', ['MODEL_'.$this->model_type.'_INSTANCE']); |
| 228 | 228 | $this->router()->hop($this->model_type); |
| 229 | 229 | } |
| 230 | - elseif($this->load_model->immortal()) |
|
| 230 | + elseif ($this->load_model->immortal()) |
|
| 231 | 231 | { |
| 232 | 232 | |
| 233 | 233 | $this->logger()->warning('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', ['MODEL_'.$this->model_type.'_INSTANCE']); |
@@ -237,10 +237,10 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | public function destroy() |
| 239 | 239 | { |
| 240 | - if(!$this->router()->submits()) |
|
| 240 | + if (!$this->router()->submits()) |
|
| 241 | 241 | throw new \Exception('KADRO_ROUTER_MUST_SUBMIT'); |
| 242 | 242 | |
| 243 | - if($this->load_model->destroy($this->operator()->operator_id()) === false) |
|
| 243 | + if ($this->load_model->destroy($this->operator()->operator_id()) === false) |
|
| 244 | 244 | { |
| 245 | 245 | $this->logger()->info('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model]); |
| 246 | 246 | $this->route_back($this->load_model); |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $this->viewport('form_model_type', $this->model_type); |
| 265 | 265 | |
| 266 | - if(isset($this->load_model)) |
|
| 266 | + if (isset($this->load_model)) |
|
| 267 | 267 | $this->viewport('load_model', $this->load_model); |
| 268 | 268 | |
| 269 | - if(isset($this->form_model)) |
|
| 269 | + if (isset($this->form_model)) |
|
| 270 | 270 | $this->viewport('form_model', $this->form_model); |
| 271 | 271 | } |
| 272 | 272 | |
@@ -278,15 +278,15 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | $header = false; |
| 280 | 280 | |
| 281 | - foreach($collection as $line) |
|
| 281 | + foreach ($collection as $line) |
|
| 282 | 282 | { |
| 283 | 283 | $line = get_object_vars($line); |
| 284 | - if($header === false) |
|
| 284 | + if ($header === false) |
|
| 285 | 285 | { |
| 286 | - fputcsv($fp,array_keys($line)); |
|
| 286 | + fputcsv($fp, array_keys($line)); |
|
| 287 | 287 | $header = true; |
| 288 | 288 | } |
| 289 | - fputcsv($fp,$line); |
|
| 289 | + fputcsv($fp, $line); |
|
| 290 | 290 | } |
| 291 | 291 | fclose($fp); |
| 292 | 292 | |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | public function export() |
| 297 | 297 | { |
| 298 | 298 | $format = $this->router()->params('format'); |
| 299 | - switch($format) |
|
| 299 | + switch ($format) |
|
| 300 | 300 | { |
| 301 | 301 | case null: |
| 302 | 302 | $filename = $this->model_type; |
@@ -325,33 +325,33 @@ discard block |
||
| 325 | 325 | $route_params = []; |
| 326 | 326 | |
| 327 | 327 | $route_name = get_class($model)::model_type().'_'; |
| 328 | - if($model->is_new()) |
|
| 329 | - $route_name.= 'new'; |
|
| 328 | + if ($model->is_new()) |
|
| 329 | + $route_name .= 'new'; |
|
| 330 | 330 | else |
| 331 | 331 | { |
| 332 | - $route_name.= 'default'; |
|
| 332 | + $route_name .= 'default'; |
|
| 333 | 333 | $route_params = ['id' => $model->get_id()]; |
| 334 | 334 | } |
| 335 | 335 | $res = $this->router()->prehop($route_name, $route_params); |
| 336 | 336 | return $res; |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - public function route_factory($route=null, $route_params=[]) : string |
|
| 339 | + public function route_factory($route = null, $route_params = []) : string |
|
| 340 | 340 | { |
| 341 | - if(is_null($route) && $this->router()->submits()) |
|
| 341 | + if (is_null($route) && $this->router()->submits()) |
|
| 342 | 342 | $route = $this->form_model; |
| 343 | 343 | |
| 344 | - if(!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) |
|
| 344 | + if (!is_null($route) && is_subclass_of($route, '\HexMakina\Crudites\Interfaces\ModelInterface')) |
|
| 345 | 345 | $route = $this->route_model($route); |
| 346 | 346 | |
| 347 | 347 | return parent::route_factory($route, $route_params); |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | - private function sanitize_post_data($post_data=[]) |
|
| 350 | + private function sanitize_post_data($post_data = []) |
|
| 351 | 351 | { |
| 352 | - foreach($this->model_class_name::table()->columns() as $col) |
|
| 352 | + foreach ($this->model_class_name::table()->columns() as $col) |
|
| 353 | 353 | { |
| 354 | - if($col->type()->is_boolean()) |
|
| 354 | + if ($col->type()->is_boolean()) |
|
| 355 | 355 | { |
| 356 | 356 | $post_data[$col->name()] = !empty($post_data[$col->name()]); |
| 357 | 357 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | function __construct($file_manageable_model, $filetype) |
| 14 | 14 | { |
| 15 | - if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) |
|
| 15 | + if (!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) |
|
| 16 | 16 | throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
| 17 | 17 | |
| 18 | 18 | $this->pmi = $file_manageable_model; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | public function download($url) |
| 33 | 33 | { |
| 34 | 34 | $filename = $this->build_filename(); |
| 35 | - $filename .= '.' . pathinfo($url, PATHINFO_EXTENSION); |
|
| 35 | + $filename .= '.'.pathinfo($url, PATHINFO_EXTENSION); |
|
| 36 | 36 | |
| 37 | 37 | $filepath = $this->build_path_to_file($filename); |
| 38 | 38 | |
@@ -58,10 +58,10 @@ discard block |
||
| 58 | 58 | return $this->pmi->get_id().'/'; |
| 59 | 59 | |
| 60 | 60 | $pmi_model_type = get_class($this->pmi)::model_type(); |
| 61 | - if(!isset($this->pmi) || is_null($this->get_type())) |
|
| 61 | + if (!isset($this->pmi) || is_null($this->get_type())) |
|
| 62 | 62 | throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
| 63 | 63 | |
| 64 | - if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
| 64 | + if (!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
| 65 | 65 | throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
| 66 | 66 | |
| 67 | 67 | // global $settings; |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | return in_array($permission_name, self::permissions_names_for($op)); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function query_retrieve($filters=[], $options=[]) : Select |
|
| 21 | + public static function query_retrieve($filters = [], $options = []) : Select |
|
| 22 | 22 | { |
| 23 | 23 | $options['eager'] = false; |
| 24 | - $ret = parent::query_retrieve($filters,$options); |
|
| 24 | + $ret = parent::query_retrieve($filters, $options); |
|
| 25 | 25 | $eager_params = []; |
| 26 | - $eager_params[Permission::table_name()]=Permission::table_alias(); |
|
| 27 | - $eager_params[Operator::table_name()]=Operator::table_alias(); |
|
| 28 | - $eager_params[ACL::table_name()]=ACL::table_alias(); |
|
| 26 | + $eager_params[Permission::table_name()] = Permission::table_alias(); |
|
| 27 | + $eager_params[Operator::table_name()] = Operator::table_alias(); |
|
| 28 | + $eager_params[ACL::table_name()] = ACL::table_alias(); |
|
| 29 | 29 | |
| 30 | 30 | $ret->eager($eager_params); |
| 31 | 31 | |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | $res = self::any(['operator_id'=>$op->get_id()]); |
| 38 | 38 | |
| 39 | 39 | $permission_ids = []; |
| 40 | - foreach($res as $r) |
|
| 41 | - $permission_ids[]=$r->get('permission_id'); |
|
| 40 | + foreach ($res as $r) |
|
| 41 | + $permission_ids[] = $r->get('permission_id'); |
|
| 42 | 42 | |
| 43 | 43 | $ret = Permission::filter(['ids'=>$permission_ids]); |
| 44 | 44 | return $ret; |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $operator_with_perms = get_class($op)::exists($op->operator_id()); |
| 49 | 49 | // $operator_with_perms = get_class($op)::retrieve($operator_with_perms); |
| 50 | - if(is_null($operator_with_perms)) |
|
| 50 | + if (is_null($operator_with_perms)) |
|
| 51 | 51 | return []; |
| 52 | 52 | |
| 53 | - return explode(',',$operator_with_perms->get('permission_names')); |
|
| 53 | + return explode(',', $operator_with_perms->get('permission_names')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public static function allow_in(OperatorInterface $op, Permission $p) |
@@ -66,10 +66,10 @@ discard block |
||
| 66 | 66 | return $this->get('language_code');
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public static function query_retrieve($filters=[], $options=[]) : Select |
|
| 69 | + public static function query_retrieve($filters = [], $options = []) : Select |
|
| 70 | 70 | {
|
| 71 | 71 | $Query = static::table()->select(); |
| 72 | - if(isset($options['eager']) && $options['eager'] === true) |
|
| 72 | + if (isset($options['eager']) && $options['eager'] === true) |
|
| 73 | 73 | {
|
| 74 | 74 | $Query->group_by('id');
|
| 75 | 75 | |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if(isset($filters['model']) && !empty($filters['model'])) |
|
| 81 | + if (isset($filters['model']) && !empty($filters['model'])) |
|
| 82 | 82 | {
|
| 83 | 83 | $model = $filters['model']; |
| 84 | - $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
|
|
| 84 | + $Query->join([static::otm('t'), static::otm('a')], [[static::otm('a'), static::otm('k'), 't_from', 'id']], 'INNER');
|
|
| 85 | 85 | $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
|
| 86 | 86 | } |
| 87 | 87 | |
@@ -3,26 +3,26 @@ discard block |
||
| 3 | 3 | namespace HexMakina\kadro; |
| 4 | 4 | |
| 5 | 5 | use \HexMakina\Crudites\Interfaces\ModelInterface; |
| 6 | -use \HexMakina\Format\HTML\{Form,Element}; |
|
| 6 | +use \HexMakina\Format\HTML\{Form, Element}; |
|
| 7 | 7 | |
| 8 | 8 | class TableToForm |
| 9 | 9 | { |
| 10 | - private static function compute_field_value($model,$field_name) |
|
| 10 | + private static function compute_field_value($model, $field_name) |
|
| 11 | 11 | { |
| 12 | - if(method_exists($model,$field_name)) |
|
| 12 | + if (method_exists($model, $field_name)) |
|
| 13 | 13 | return $model->$field_name(); |
| 14 | 14 | |
| 15 | - if(property_exists($model,$field_name)) |
|
| 15 | + if (property_exists($model, $field_name)) |
|
| 16 | 16 | return $model->$field_name; |
| 17 | 17 | |
| 18 | 18 | return ''; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public static function label($model,$field_name,$attributes=[],$errors=[]) |
|
| 21 | + public static function label($model, $field_name, $attributes = [], $errors = []) |
|
| 22 | 22 | { |
| 23 | 23 | $label_content = $field_name; |
| 24 | 24 | |
| 25 | - if(isset($attributes['label'])) |
|
| 25 | + if (isset($attributes['label'])) |
|
| 26 | 26 | { |
| 27 | 27 | $label_content = $attributes['label']; |
| 28 | 28 | unset($attributes['label']); |
@@ -44,66 +44,66 @@ discard block |
||
| 44 | 44 | return $ret; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public static function field(ModelInterface $model,$field_name,$attributes=[],$errors=[]) : string |
|
| 47 | + public static function field(ModelInterface $model, $field_name, $attributes = [], $errors = []) : string |
|
| 48 | 48 | { |
| 49 | - $field_value = $attributes['value'] ?? self::compute_field_value($model,$field_name); |
|
| 49 | + $field_value = $attributes['value'] ?? self::compute_field_value($model, $field_name); |
|
| 50 | 50 | $attributes['name'] = $attributes['name'] ?? $field_name; |
| 51 | 51 | |
| 52 | 52 | $table = get_class($model)::table(); |
| 53 | 53 | |
| 54 | - if(is_null($table->column($field_name))) |
|
| 55 | - return Form::input($field_name,$field_value,$attributes,$errors); |
|
| 54 | + if (is_null($table->column($field_name))) |
|
| 55 | + return Form::input($field_name, $field_value, $attributes, $errors); |
|
| 56 | 56 | |
| 57 | 57 | $ret = ''; |
| 58 | 58 | |
| 59 | 59 | $field = $table->column($field_name); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | - if(isset($attributes['required']) && $attributes['required'] === false) |
|
| 62 | + if (isset($attributes['required']) && $attributes['required'] === false) |
|
| 63 | 63 | unset($attributes['required']); |
| 64 | 64 | |
| 65 | - elseif(!$field->is_nullable()) |
|
| 65 | + elseif (!$field->is_nullable()) |
|
| 66 | 66 | $attributes[] = 'required'; |
| 67 | 67 | |
| 68 | - if($field->is_auto_incremented()) |
|
| 68 | + if ($field->is_auto_incremented()) |
|
| 69 | 69 | { |
| 70 | - $ret .= Form::hidden($field->name(),$field_value); |
|
| 70 | + $ret .= Form::hidden($field->name(), $field_value); |
|
| 71 | 71 | } |
| 72 | - elseif($field->type()->is_boolean()) |
|
| 72 | + elseif ($field->type()->is_boolean()) |
|
| 73 | 73 | { |
| 74 | 74 | $option_list = $attributes['values'] ?? [0 => 0, 1 => 1]; |
| 75 | - $ret .= Form::select($field->name(), $option_list ,$field_value, $attributes); // |
|
| 75 | + $ret .= Form::select($field->name(), $option_list, $field_value, $attributes); // |
|
| 76 | 76 | } |
| 77 | - elseif($field->type()->is_integer()) |
|
| 77 | + elseif ($field->type()->is_integer()) |
|
| 78 | 78 | { |
| 79 | - $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
|
| 79 | + $ret .= Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 80 | 80 | } |
| 81 | - elseif($field->type()->is_year()) |
|
| 81 | + elseif ($field->type()->is_year()) |
|
| 82 | 82 | { |
| 83 | 83 | $attributes['size'] = $attributes['maxlength'] = 4; |
| 84 | - $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
|
| 84 | + $ret .= Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 85 | 85 | } |
| 86 | - elseif($field->type()->is_date()) |
|
| 86 | + elseif ($field->type()->is_date()) |
|
| 87 | 87 | { |
| 88 | - $ret .= Form::date($field->name(),$field_value,$attributes,$errors); |
|
| 88 | + $ret .= Form::date($field->name(), $field_value, $attributes, $errors); |
|
| 89 | 89 | } |
| 90 | - elseif($field->type()->is_time()) |
|
| 90 | + elseif ($field->type()->is_time()) |
|
| 91 | 91 | { |
| 92 | - $ret .= Form::time($field->name(),$field_value,$attributes,$errors); |
|
| 92 | + $ret .= Form::time($field->name(), $field_value, $attributes, $errors); |
|
| 93 | 93 | } |
| 94 | - elseif($field->type()->is_datetime()) |
|
| 94 | + elseif ($field->type()->is_datetime()) |
|
| 95 | 95 | { |
| 96 | - $ret .= Form::datetime($field->name(),$field_value,$attributes,$errors); |
|
| 96 | + $ret .= Form::datetime($field->name(), $field_value, $attributes, $errors); |
|
| 97 | 97 | } |
| 98 | - elseif($field->type()->is_text()) |
|
| 98 | + elseif ($field->type()->is_text()) |
|
| 99 | 99 | { |
| 100 | - $ret .= Form::textarea($field->name(),$field_value,$attributes,$errors); |
|
| 100 | + $ret .= Form::textarea($field->name(), $field_value, $attributes, $errors); |
|
| 101 | 101 | } |
| 102 | - elseif($field->type()->is_enum()) |
|
| 102 | + elseif ($field->type()->is_enum()) |
|
| 103 | 103 | { |
| 104 | 104 | |
| 105 | 105 | $enum_values = []; |
| 106 | - foreach($field->type()->enum_values() as $e_val) |
|
| 106 | + foreach ($field->type()->enum_values() as $e_val) |
|
| 107 | 107 | $enum_values[$e_val] = $e_val; |
| 108 | 108 | |
| 109 | 109 | $selected = $attributes['value'] ?? $field_value ?? ''; |
@@ -112,50 +112,50 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | // throw new \Exception('ENUM IS NOT HANDLED BY TableToFom'); |
| 114 | 114 | } |
| 115 | - elseif($field->type()->is_string()) |
|
| 115 | + elseif ($field->type()->is_string()) |
|
| 116 | 116 | { |
| 117 | 117 | $max_length = $field->type()->length(); |
| 118 | 118 | $attributes['size'] = $attributes['maxlength'] = $max_length; |
| 119 | - $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
|
| 119 | + $ret .= Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 120 | 120 | } |
| 121 | 121 | else |
| 122 | 122 | { |
| 123 | - $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
|
| 123 | + $ret .= Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | return $ret; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public static function field_with_label($model,$field_name,$attributes=[],$errors=[]) : string |
|
| 130 | + public static function field_with_label($model, $field_name, $attributes = [], $errors = []) : string |
|
| 131 | 131 | { |
| 132 | 132 | $field_attributes = $attributes; |
| 133 | - if(isset($attributes['label'])) |
|
| 133 | + if (isset($attributes['label'])) |
|
| 134 | 134 | unset($field_attributes['label']); |
| 135 | 135 | |
| 136 | - return sprintf('%s %s', self::label($model,$field_name,$attributes,$errors), self::field($model,$field_name,$field_attributes,$errors)); |
|
| 136 | + return sprintf('%s %s', self::label($model, $field_name, $attributes, $errors), self::field($model, $field_name, $field_attributes, $errors)); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | |
| 140 | - public static function fields(ModelInterface $model,$group_class=null) : string |
|
| 140 | + public static function fields(ModelInterface $model, $group_class = null) : string |
|
| 141 | 141 | { |
| 142 | 142 | $table = get_class($model)::table(); |
| 143 | 143 | $ret = ''; |
| 144 | - foreach($table->columns() as $column_name => $column) |
|
| 144 | + foreach ($table->columns() as $column_name => $column) |
|
| 145 | 145 | { |
| 146 | 146 | // vd($column_name); |
| 147 | 147 | |
| 148 | 148 | $form_field = ''; |
| 149 | - if($column->is_auto_incremented()) |
|
| 149 | + if ($column->is_auto_incremented()) |
|
| 150 | 150 | { |
| 151 | - if(!$model->is_new()) |
|
| 152 | - $form_field = self::field($model,$column_name); |
|
| 151 | + if (!$model->is_new()) |
|
| 152 | + $form_field = self::field($model, $column_name); |
|
| 153 | 153 | } |
| 154 | 154 | else |
| 155 | 155 | { |
| 156 | - $form_field = self::field_with_label($model,$column_name); |
|
| 157 | - if(!is_null($group_class)) |
|
| 158 | - $form_field = new Element('div',$form_field, ['class' => $group_class]); |
|
| 156 | + $form_field = self::field_with_label($model, $column_name); |
|
| 157 | + if (!is_null($group_class)) |
|
| 158 | + $form_field = new Element('div', $form_field, ['class' => $group_class]); |
|
| 159 | 159 | } |
| 160 | 160 | $ret .= PHP_EOL.$form_field; |
| 161 | 161 | } |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | return false; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - public static function query_retrieve($filters=[], $options=[]) : Select |
|
| 23 | + public static function query_retrieve($filters = [], $options = []) : Select |
|
| 24 | 24 | { |
| 25 | 25 | $Query = static::table()->select(); |
| 26 | 26 | $Query->order_by(['kategorio', 'ASC']); |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | class hopper extends \AltoRouter implements RouterInterface |
| 12 | 12 | { |
| 13 | - private $match=null; |
|
| 14 | - private $file_root=null; |
|
| 13 | + private $match = null; |
|
| 14 | + private $file_root = null; |
|
| 15 | 15 | private $controller_namespaces = null; |
| 16 | 16 | |
| 17 | 17 | //----------------------------------------------------------- INITIALISATION |
| 18 | 18 | public function __construct($settings) |
| 19 | 19 | { |
| 20 | - if(!isset($settings['route_home'])) |
|
| 20 | + if (!isset($settings['route_home'])) |
|
| 21 | 21 | throw new RouterException('ROUTE_HOME_UNDEFINED'); |
| 22 | 22 | |
| 23 | 23 | parent::__construct(); |
@@ -44,15 +44,15 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | $this->match = parent::match($requestUrl, $requestMethod); |
| 46 | 46 | |
| 47 | - if($this->match === false) |
|
| 47 | + if ($this->match === false) |
|
| 48 | 48 | throw new RouterException('ROUTE_MATCH_FALSE'); |
| 49 | 49 | |
| 50 | 50 | $res = explode('::', self::target()); |
| 51 | 51 | |
| 52 | - if($res === false || !isset($res[1]) || isset($ret[2])) |
|
| 52 | + if ($res === false || !isset($res[1]) || isset($ret[2])) |
|
| 53 | 53 | throw new RouterException('INVALID_TARGET'); |
| 54 | 54 | |
| 55 | - if($this->match['name'] === 'akadok_controller_method') |
|
| 55 | + if ($this->match['name'] === 'akadok_controller_method') |
|
| 56 | 56 | $res = [ucfirst(self::params('controller')).'Controller', ucfirst(self::params('method'))]; |
| 57 | 57 | |
| 58 | 58 | |
@@ -60,11 +60,11 @@ discard block |
||
| 60 | 60 | $target_method = $res[1]; |
| 61 | 61 | $found = false; |
| 62 | 62 | |
| 63 | - foreach($this->controller_namespaces as $controller_ns) |
|
| 64 | - if($found = class_exists($controller_class_name = "$controller_ns$target_controller")) |
|
| 63 | + foreach ($this->controller_namespaces as $controller_ns) |
|
| 64 | + if ($found = class_exists($controller_class_name = "$controller_ns$target_controller")) |
|
| 65 | 65 | break; |
| 66 | 66 | |
| 67 | - if($found === false) |
|
| 67 | + if ($found === false) |
|
| 68 | 68 | throw new RouterException('INVALID_CONTROLLER_NAME'); |
| 69 | 69 | |
| 70 | 70 | $this->match['target_controller'] = $controller_class_name; |
@@ -73,29 +73,29 @@ discard block |
||
| 73 | 73 | return [$controller_class_name, $target_method]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - public function params($param_name=null) |
|
| 76 | + public function params($param_name = null) |
|
| 77 | 77 | { |
| 78 | 78 | return $this->extract_request($this->match['params'] ?? [], $param_name); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - public function submitted($param_name=null) |
|
| 81 | + public function submitted($param_name = null) |
|
| 82 | 82 | { |
| 83 | 83 | return $this->extract_request($_POST, $param_name); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - private function extract_request($dat_ass, $key=null) |
|
| 86 | + private function extract_request($dat_ass, $key = null) |
|
| 87 | 87 | { |
| 88 | 88 | |
| 89 | 89 | // $key is null, returns $dat_ass or empty array |
| 90 | - if(is_null($key)) |
|
| 90 | + if (is_null($key)) |
|
| 91 | 91 | return $dat_ass ?? []; |
| 92 | 92 | |
| 93 | 93 | // $dat_ass[$key] not set, returns null |
| 94 | - if(!isset($dat_ass[$key])) |
|
| 94 | + if (!isset($dat_ass[$key])) |
|
| 95 | 95 | return null; |
| 96 | 96 | |
| 97 | 97 | // $dat_ass[$key] is a string, returns decoded value |
| 98 | - if(is_string($dat_ass[$key])) |
|
| 98 | + if (is_string($dat_ass[$key])) |
|
| 99 | 99 | return urldecode($dat_ass[$key]); |
| 100 | 100 | |
| 101 | 101 | // $dat_ass[$key] is not a string, return match[$key] |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | * - an assoc_array of url params (strongly AltoRouter-based) |
| 143 | 143 | * returns: something to put in a href="", action="" or header('Location:'); |
| 144 | 144 | */ |
| 145 | - public function prehop($route, $route_params=[]) |
|
| 145 | + public function prehop($route, $route_params = []) |
|
| 146 | 146 | { |
| 147 | - try{ |
|
| 147 | + try { |
|
| 148 | 148 | $url = $this->generate($route, $route_params); |
| 149 | - }catch(\Exception $e){ |
|
| 149 | + } catch (\Exception $e) { |
|
| 150 | 150 | $url = $this->prehop(self::ROUTE_HOME_NAME); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return $url; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function prehop_here($url=null) |
|
| 156 | + public function prehop_here($url = null) |
|
| 157 | 157 | { |
| 158 | 158 | return $url ?? $_SERVER['REQUEST_URI']; |
| 159 | 159 | } |
@@ -165,13 +165,13 @@ discard block |
||
| 165 | 165 | * - a url, go there |
| 166 | 166 | * @params $route_params, assoc_data for url creation (i:id, a:format, ..) |
| 167 | 167 | */ |
| 168 | - public function hop($route=null, $route_params=[]) |
|
| 168 | + public function hop($route = null, $route_params = []) |
|
| 169 | 169 | { |
| 170 | 170 | $url = null; |
| 171 | 171 | |
| 172 | - if(is_null($route)) |
|
| 172 | + if (is_null($route)) |
|
| 173 | 173 | $url = $this->prehop(self::ROUTE_HOME_NAME, $route_params); |
| 174 | - elseif(is_string($route) && $this->route_exists($route)) |
|
| 174 | + elseif (is_string($route) && $this->route_exists($route)) |
|
| 175 | 175 | $url = $this->prehop($route, $route_params); |
| 176 | 176 | else |
| 177 | 177 | $url = $route; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // hops back to previous page (referer()), or home if no referer |
| 183 | 183 | public function hop_back() |
| 184 | 184 | { |
| 185 | - if(!is_null($back = $this->referer())) |
|
| 185 | + if (!is_null($back = $this->referer())) |
|
| 186 | 186 | $this->hop_url($back); |
| 187 | 187 | |
| 188 | 188 | $this->hop(); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | // returns null if same as current URL (prevents endless redirection loop) |
| 201 | 201 | public function referer() |
| 202 | 202 | { |
| 203 | - if(isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host() .$_SERVER['REQUEST_URI']) |
|
| 203 | + if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != $this->web_host().$_SERVER['REQUEST_URI']) |
|
| 204 | 204 | return $_SERVER['HTTP_REFERER']; |
| 205 | 205 | |
| 206 | 206 | return null; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | public function send_file($file_path) |
| 210 | 210 | { |
| 211 | - if(!file_exists($file_path)) |
|
| 211 | + if (!file_exists($file_path)) |
|
| 212 | 212 | throw new RouterException('SENDING_NON_EXISTING_FILE'); |
| 213 | 213 | |
| 214 | 214 | $file_name = basename($file_path); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | //Get file type and set it as Content Type |
| 217 | 217 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 218 | 218 | |
| 219 | - header('Content-Type: ' . finfo_file($finfo, $file_path)); |
|
| 219 | + header('Content-Type: '.finfo_file($finfo, $file_path)); |
|
| 220 | 220 | |
| 221 | 221 | finfo_close($finfo); |
| 222 | 222 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | header('Pragma: public'); |
| 230 | 230 | |
| 231 | 231 | //Define file size |
| 232 | - header('Content-Length: ' . filesize($file_path)); |
|
| 232 | + header('Content-Length: '.filesize($file_path)); |
|
| 233 | 233 | |
| 234 | 234 | ob_clean(); |
| 235 | 235 | flush(); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | |
| 256 | 256 | public function web_root() : string |
| 257 | 257 | { |
| 258 | - return $this->web_host() . $this->web_base(); |
|
| 258 | + return $this->web_host().$this->web_base(); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | public function web_base() : string |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | require APP_BASE.'vendor/autoload.php'; |
| 14 | 14 | |
| 15 | 15 | require 'PSR4Autoloader.class.php'; |
| 16 | - $loader=new PSR4Autoloader; |
|
| 16 | + $loader = new PSR4Autoloader; |
|
| 17 | 17 | $loader->register(); //Register loader with SPL autoloader stack. |
| 18 | 18 | |
| 19 | 19 | $loader->addNamespace('HexMakina', APP_BASE.'/lib/');
|
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | //--------------------------------------------------------------- parametroj |
| 40 | 40 | require_once APP_BASE.'configs/settings.php'; |
| 41 | - $box=new Container\LeMarchand($settings); |
|
| 41 | + $box = new Container\LeMarchand($settings); |
|
| 42 | 42 | |
| 43 | - foreach($box->get('settings.app.namespaces') as $namespace => $path)
|
|
| 43 | + foreach ($box->get('settings.app.namespaces') as $namespace => $path)
|
|
| 44 | 44 | {
|
| 45 | 45 | $loader->addNamespace($namespace, $path); |
| 46 | 46 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | //--------------------------------------------------------------- kuketoj |
| 58 | 58 | setcookie('cookie_test', 'test_value', time()+(365 * 24 * 60 * 60), "/", "");
|
| 59 | - $cookies_enabled=isset($_COOKIE['cookie_test']); // houston, do we have cookies ? |
|
| 59 | + $cookies_enabled = isset($_COOKIE['cookie_test']); // houston, do we have cookies ? |
|
| 60 | 60 | |
| 61 | - if($cookies_enabled === false) |
|
| 61 | + if ($cookies_enabled === false) |
|
| 62 | 62 | {
|
| 63 | 63 | ini_set('session.use_cookies', 0);
|
| 64 | 64 | ini_set('session.use_only_cookies', 0);
|
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | //--------------------------------------------------------------- Session Management |
| 70 | - $StateAgent=new StateAgent($box->get('settings.app.session_start_options') ?? []);
|
|
| 70 | + $StateAgent = new StateAgent($box->get('settings.app.session_start_options') ?? []);
|
|
| 71 | 71 | $StateAgent->add_runtime_filters((array)$box->get('settings.filter'));
|
| 72 | 72 | $StateAgent->add_runtime_filters((array)($_SESSION['filter'] ?? [])); |
| 73 | 73 | $StateAgent->add_runtime_filters((array)($_REQUEST['filter'] ?? [])); |
@@ -91,42 +91,42 @@ discard block |
||
| 91 | 91 | //--------------------------------------------------------------- ŝablonoj |
| 92 | 92 | require_once 'smarty/smarty/libs/Smarty.class.php'; |
| 93 | 93 | // Load smarty template parser |
| 94 | - if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) |
|
| 94 | + if (is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path'))) |
|
| 95 | 95 | throw new \Exception("SMARTY CONFIG ERROR: missing parameters"); |
| 96 | 96 | |
| 97 | - $smarty=new \Smarty(); |
|
| 97 | + $smarty = new \Smarty(); |
|
| 98 | 98 | $box->register('template_engine', $smarty); |
| 99 | 99 | |
| 100 | - $smarty->setTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path').'app'); |
|
| 101 | - $smarty->addTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path')); |
|
| 102 | - $smarty->addTemplateDir(KADRO_BASE . 'Views/'); |
|
| 100 | + $smarty->setTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path').'app'); |
|
| 101 | + $smarty->addTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path')); |
|
| 102 | + $smarty->addTemplateDir(KADRO_BASE.'Views/'); |
|
| 103 | 103 | |
| 104 | - $smarty->setCompileDir(APP_BASE . $box->get('settings.smarty.compiled_path')); |
|
| 104 | + $smarty->setCompileDir(APP_BASE.$box->get('settings.smarty.compiled_path')); |
|
| 105 | 105 | $smarty->setDebugging($box->get('settings.smarty.debug')); |
| 106 | 106 | |
| 107 | - $smarty->registerClass('Lezer', '\HexMakina\Lezer\Lezer'); |
|
| 108 | - $smarty->registerClass('Marker', '\HexMakina\Format\HTML\Marker'); |
|
| 109 | - $smarty->registerClass('Form', '\HexMakina\Format\HTML\Form'); |
|
| 110 | - $smarty->registerClass('TableToForm', '\HexMakina\kadro\TableToForm'); |
|
| 111 | - $smarty->registerClass('Dato', '\HexMakina\Format\Tempo\Dato'); |
|
| 107 | + $smarty->registerClass('Lezer', '\HexMakina\Lezer\Lezer'); |
|
| 108 | + $smarty->registerClass('Marker', '\HexMakina\Format\HTML\Marker'); |
|
| 109 | + $smarty->registerClass('Form', '\HexMakina\Format\HTML\Form'); |
|
| 110 | + $smarty->registerClass('TableToForm', '\HexMakina\kadro\TableToForm'); |
|
| 111 | + $smarty->registerClass('Dato', '\HexMakina\Format\Tempo\Dato'); |
|
| 112 | 112 | |
| 113 | 113 | $smarty->assign('APP_NAME', $box->get('settings.app.name')); |
| 114 | 114 | |
| 115 | 115 | //--------------------------------------------------------------- lingva |
| 116 | 116 | |
| 117 | - $languages=\HexMakina\Lezer\Lezer::languages_by_file(APP_BASE.'locale/'); |
|
| 117 | + $languages = \HexMakina\Lezer\Lezer::languages_by_file(APP_BASE.'locale/'); |
|
| 118 | 118 | |
| 119 | 119 | $smarty->assign('languages', $languages); |
| 120 | 120 | |
| 121 | - $language=null; |
|
| 121 | + $language = null; |
|
| 122 | 122 | |
| 123 | 123 | // changing / setting the language |
| 124 | - if(isset($_GET['lang'])) |
|
| 124 | + if (isset($_GET['lang'])) |
|
| 125 | 125 | { |
| 126 | - if(isset($languages[$_GET['lang']])) |
|
| 126 | + if (isset($languages[$_GET['lang']])) |
|
| 127 | 127 | { |
| 128 | - $language=$_GET['lang']; |
|
| 129 | - if($cookies_enabled === true) |
|
| 128 | + $language = $_GET['lang']; |
|
| 129 | + if ($cookies_enabled === true) |
|
| 130 | 130 | setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", ""); |
| 131 | 131 | else |
| 132 | 132 | trigger_error('KADRO_SYSTEM_ERR_COOKIES_ARE_DISABLED_LANGUAGE_CANNOT_BE_STORED', E_USER_WARNING); |
@@ -134,15 +134,15 @@ discard block |
||
| 134 | 134 | else |
| 135 | 135 | throw new \Exception('KADRO_SYSTEM_ERR_INVALID_PARAMETER'); |
| 136 | 136 | } |
| 137 | - else if($cookies_enabled === true && array_key_exists('lang', $_COOKIE) && array_key_exists($_COOKIE['lang'], $languages)) |
|
| 138 | - $language=$_COOKIE['lang']; |
|
| 137 | + else if ($cookies_enabled === true && array_key_exists('lang', $_COOKIE) && array_key_exists($_COOKIE['lang'], $languages)) |
|
| 138 | + $language = $_COOKIE['lang']; |
|
| 139 | 139 | |
| 140 | - if(is_null($language) && !empty($languages)) |
|
| 140 | + if (is_null($language) && !empty($languages)) |
|
| 141 | 141 | { |
| 142 | - if(count($languages) === 1) |
|
| 143 | - $language=key($languages); |
|
| 144 | - elseif(array_key_exists($box->get('settings.default.language'), $languages)) |
|
| 145 | - $language=$box->get('settings.default.language'); |
|
| 142 | + if (count($languages) === 1) |
|
| 143 | + $language = key($languages); |
|
| 144 | + elseif (array_key_exists($box->get('settings.default.language'), $languages)) |
|
| 145 | + $language = $box->get('settings.default.language'); |
|
| 146 | 146 | else |
| 147 | 147 | throw new \Exception('FALLBACK_TO_DEFAULT_LANGUAGE_FAILED'); |
| 148 | 148 | $i18n = new \HexMakina\Lezer\Lezer(APP_BASE.'locale/'.$language.'/user_interface.json', APP_BASE.'locale/cache/', $language); |