@@ -22,7 +22,7 @@ |
||
| 22 | 22 | |
| 23 | 23 | public function event_label() |
| 24 | 24 | { |
| 25 | - return '' . $this; |
|
| 25 | + return ''.$this; |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public static function today($format = Dato::FORMAT) |
@@ -58,15 +58,15 @@ |
||
| 58 | 58 | |
| 59 | 59 | private function trim_request_data() |
| 60 | 60 | { |
| 61 | - array_walk_recursive($_GET, function (&$value) { |
|
| 61 | + array_walk_recursive($_GET, function(&$value) { |
|
| 62 | 62 | $value = trim($value); |
| 63 | 63 | }); |
| 64 | - array_walk_recursive($_REQUEST, function (&$value) { |
|
| 64 | + array_walk_recursive($_REQUEST, function(&$value) { |
|
| 65 | 65 | $value = trim($value); |
| 66 | 66 | }); |
| 67 | 67 | |
| 68 | 68 | if ($this->router()->submits()) { |
| 69 | - array_walk_recursive($_POST, function (&$value) { |
|
| 69 | + array_walk_recursive($_POST, function(&$value) { |
|
| 70 | 70 | $value = trim($value); |
| 71 | 71 | }); |
| 72 | 72 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | namespace HexMakina\kadro\Controllers; |
| 14 | 14 | |
| 15 | 15 | use HexMakina\Crudites\Crudites; |
| 16 | -use HexMakina\kadro\Auth\{ACL,AccessRefusedException}; |
|
| 16 | +use HexMakina\kadro\Auth\{ACL, AccessRefusedException}; |
|
| 17 | 17 | |
| 18 | 18 | class Operator extends \HexMakina\kadro\Controllers\ORM |
| 19 | 19 | { |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | public function dashboard() |
| 57 | 57 | { |
| 58 | 58 | $real_operator_class = get_class($this->operator()); |
| 59 | - $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null,'username', 'ASC']])); |
|
| 59 | + $this->viewport('users', $real_operator_class::filter([], ['order_by' => [null, 'username', 'ASC']])); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | public function destroy() |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | namespace HexMakina\kadro; |
| 4 | 4 | |
| 5 | 5 | use HexMakina\BlackBox\ORM\ModelInterface; |
| 6 | -use HexMakina\Marker\{Form,Element}; |
|
| 6 | +use HexMakina\Marker\{Form, Element}; |
|
| 7 | 7 | |
| 8 | 8 | class TableToForm |
| 9 | 9 | { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $form_field = new Element('div', $form_field, ['class' => $group_class]); |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | - $ret .= PHP_EOL . $form_field; |
|
| 85 | + $ret .= PHP_EOL.$form_field; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return $ret; |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | $ret = ''; |
| 13 | 13 | if (method_exists($model, $field_name)) { |
| 14 | 14 | $ret = $model->$field_name(); |
| 15 | - }elseif (property_exists($model, $field_name)) { |
|
| 15 | + } elseif (property_exists($model, $field_name)) { |
|
| 16 | 16 | $ret = $model->$field_name; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -93,31 +93,23 @@ discard block |
||
| 93 | 93 | $ret = null; |
| 94 | 94 | if ($field->isAutoIncremented()) { |
| 95 | 95 | $ret = Form::hidden($field->name(), $field_value); |
| 96 | - } |
|
| 97 | - elseif ($field->type()->isBoolean()) { |
|
| 96 | + } elseif ($field->type()->isBoolean()) { |
|
| 98 | 97 | $option_list = $attributes['values'] ?? [0 => 0, 1 => 1]; |
| 99 | 98 | $ret = Form::select($field->name(), $option_list, $field_value, $attributes); // |
| 100 | - } |
|
| 101 | - elseif ($field->type()->isInteger()) { |
|
| 99 | + } elseif ($field->type()->isInteger()) { |
|
| 102 | 100 | $ret = Form::input($field->name(), $field_value, $attributes, $errors); |
| 103 | - } |
|
| 104 | - elseif ($field->type()->isYear()) { |
|
| 101 | + } elseif ($field->type()->isYear()) { |
|
| 105 | 102 | $attributes['size'] = $attributes['maxlength'] = 4; |
| 106 | 103 | $ret = Form::input($field->name(), $field_value, $attributes, $errors); |
| 107 | - } |
|
| 108 | - elseif ($field->type()->isDate()) { |
|
| 104 | + } elseif ($field->type()->isDate()) { |
|
| 109 | 105 | $ret = Form::date($field->name(), $field_value, $attributes, $errors); |
| 110 | - } |
|
| 111 | - elseif ($field->type()->isTime()) { |
|
| 106 | + } elseif ($field->type()->isTime()) { |
|
| 112 | 107 | $ret = Form::time($field->name(), $field_value, $attributes, $errors); |
| 113 | - } |
|
| 114 | - elseif ($field->type()->isDatetime()) { |
|
| 108 | + } elseif ($field->type()->isDatetime()) { |
|
| 115 | 109 | $ret = Form::datetime($field->name(), $field_value, $attributes, $errors); |
| 116 | - } |
|
| 117 | - elseif ($field->type()->isText()) { |
|
| 110 | + } elseif ($field->type()->isText()) { |
|
| 118 | 111 | $ret = Form::textarea($field->name(), $field_value, $attributes, $errors); |
| 119 | - } |
|
| 120 | - elseif ($field->type()->isEnum()) { |
|
| 112 | + } elseif ($field->type()->isEnum()) { |
|
| 121 | 113 | $enum_values = []; |
| 122 | 114 | foreach ($field->type()->getEnumValues() as $e_val) { |
| 123 | 115 | $enum_values[$e_val] = $e_val; |
@@ -125,14 +117,13 @@ discard block |
||
| 125 | 117 | |
| 126 | 118 | $selected = $attributes['value'] ?? $field_value ?? ''; |
| 127 | 119 | $ret = Form::select($field->name(), $enum_values, $selected, $attributes); // |
| 128 | - } |
|
| 129 | - elseif ($field->type()->isString()) { |
|
| 120 | + } elseif ($field->type()->isString()) { |
|
| 130 | 121 | $max_length = $field->type()->getLength(); |
| 131 | 122 | $attributes['size'] = $attributes['maxlength'] = $max_length; |
| 132 | 123 | $ret = Form::input($field->name(), $field_value, $attributes, $errors); |
| 124 | + } else { |
|
| 125 | + $ret = Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 133 | 126 | } |
| 134 | - else |
|
| 135 | - $ret = Form::input($field->name(), $field_value, $attributes, $errors); |
|
| 136 | 127 | |
| 137 | 128 | return $ret; |
| 138 | 129 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace HexMakina\kadro\Controllers; |
| 4 | 4 | |
| 5 | -use Psr\Container\{ContainerInterface,ContainerExceptionInterface,NotFoundExceptionInterface}; |
|
| 5 | +use Psr\Container\{ContainerInterface, ContainerExceptionInterface, NotFoundExceptionInterface}; |
|
| 6 | 6 | use HexMakina\BlackBox\RouterInterface; |
| 7 | 7 | use HexMakina\BlackBox\Controllers\BaseControllerInterface; |
| 8 | 8 | use Psr\Log\LoggerInterface; |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | $this->viewport('user_messages', $this->get('HexMakina\BlackBox\StateAgentInterface')->messages()); |
| 52 | 52 | |
| 53 | 53 | $this->viewport('web_root', $this->router()->webRoot()); |
| 54 | - $this->viewport('view_path', $this->router()->filePath() . $this->get('settings.smarty.template_path') . 'app/'); |
|
| 55 | - $this->viewport('view_url', $this->router()->webRoot() . $this->get('settings.smarty.template_path')); |
|
| 56 | - $this->viewport('images_url', $this->router()->webRoot() . $this->get('settings.smarty.template_path') . 'images/'); |
|
| 54 | + $this->viewport('view_path', $this->router()->filePath().$this->get('settings.smarty.template_path').'app/'); |
|
| 55 | + $this->viewport('view_url', $this->router()->webRoot().$this->get('settings.smarty.template_path')); |
|
| 56 | + $this->viewport('images_url', $this->router()->webRoot().$this->get('settings.smarty.template_path').'images/'); |
|
| 57 | 57 | |
| 58 | 58 | foreach ($this->viewport() as $template_var_name => $value) { |
| 59 | 59 | $smarty->assign($template_var_name, $value); |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | // 1. check for custom template in the current controller directory |
| 84 | 84 | $templates ['custom_3'] = sprintf('%s/%s.html', $controller_template_path, $custom_template); |
| 85 | 85 | // 2. check for custom template formatted as controller/view |
| 86 | - $templates ['custom_2'] = $custom_template . '.html'; |
|
| 87 | - $templates ['custom_1'] = '_layouts/' . $custom_template . '.html'; |
|
| 86 | + $templates ['custom_2'] = $custom_template.'.html'; |
|
| 87 | + $templates ['custom_1'] = '_layouts/'.$custom_template.'.html'; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | if (!empty($this->router()->targetMethod())) { |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function __toString() |
| 30 | 30 | { |
| 31 | - return $this->iso_name() . ' (' . $this->get(self::ISO_3) . ')'; |
|
| 31 | + return $this->iso_name().' ('.$this->get(self::ISO_3).')'; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function traceable(): bool |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if (isset($filter['types'])) { |
| 77 | - $wc = sprintf("AND " . self::ISO_TYPE . " IN ('%s') ", implode('\', \'', array_keys(self::ISO_TYPES))); |
|
| 77 | + $wc = sprintf("AND ".self::ISO_TYPE." IN ('%s') ", implode('\', \'', array_keys(self::ISO_TYPES))); |
|
| 78 | 78 | $Query->where($wc); |
| 79 | 79 | } |
| 80 | 80 | if (isset($filter['scopes'])) { |
| 81 | - $wc = sprintf("AND " . self::ISO_SCOPE . " IN ('%s') ", implode('\', \'', array_keys(self::ISO_SCOPES))); |
|
| 81 | + $wc = sprintf("AND ".self::ISO_SCOPE." IN ('%s') ", implode('\', \'', array_keys(self::ISO_SCOPES))); |
|
| 82 | 82 | $Query->where($wc); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | namespace HexMakina\kadro\Controllers; |
| 4 | 4 | |
| 5 | -use HexMakina\kadro\Auth\{Operator,Permission,ACL}; |
|
| 5 | +use HexMakina\kadro\Auth\{Operator, Permission, ACL}; |
|
| 6 | 6 | use HexMakina\kadro\Auth\AccessRefusedException; |
| 7 | 7 | use HexMakina\BlackBox\Auth\OperatorInterface; |
| 8 | 8 | |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | // MVC Cascade |
| 28 | - $target_controller = $this->get('Controllers\\' . $router->targetController()); |
|
| 28 | + $target_controller = $this->get('Controllers\\'.$router->targetController()); |
|
| 29 | 29 | |
| 30 | 30 | if ($target_controller->requiresOperator()) { |
| 31 | 31 | if (is_null($operator_id = $this->get('HexMakina\BlackBox\StateAgentInterface')->operatorId())) { |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | $this->logger()->notice('PAGE_CHECKIN_WELCOME', [$operator->name()]); |
| 73 | 73 | $this->router()->hop(); |
| 74 | 74 | } catch (\Exception $e) { |
| 75 | - $this->logger()->warning('KADRO_operator_' . $e->getMessage()); |
|
| 75 | + $this->logger()->warning('KADRO_operator_'.$e->getMessage()); |
|
| 76 | 76 | $this->router()->hop('checkin'); |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | $ret = $this->modelType(); |
| 59 | 59 | |
| 60 | 60 | if (!is_null($suffix)) { |
| 61 | - $ret .= '_' . $suffix; |
|
| 61 | + $ret .= '_'.$suffix; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | return $ret; |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | if (is_null($this->model_class_name)) { |
| 105 | 105 | preg_match(LeMarchand::RX_MVC, get_called_class(), $m); |
| 106 | - $this->model_class_name = $this->get('Models\\' . $m[2] . '::class'); |
|
| 106 | + $this->model_class_name = $this->get('Models\\'.$m[2].'::class'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | return $this->model_class_name; |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | $this->viewport('listing_fields', $listing_fields); |
| 168 | 168 | $this->viewport('listing_template', $listing_template); |
| 169 | 169 | |
| 170 | - $this->viewport('route_new', $this->router()->hyp($class_name::model_type() . '_new')); |
|
| 171 | - $this->viewport('route_export', $this->router()->hyp($class_name::model_type() . '_export')); |
|
| 170 | + $this->viewport('route_new', $this->router()->hyp($class_name::model_type().'_new')); |
|
| 171 | + $this->viewport('route_export', $this->router()->hyp($class_name::model_type().'_export')); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | public function copy() |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $this->errors = $model->save($this->operator()->getId()); // returns [errors] |
| 201 | 201 | if (empty($this->errors())) { |
| 202 | - $this->logger()->notice($this->l('CRUDITES_INSTANCE_ALTERED', [$this->l('MODEL_' . get_class($model)::model_type() . '_INSTANCE')])); |
|
| 202 | + $this->logger()->notice($this->l('CRUDITES_INSTANCE_ALTERED', [$this->l('MODEL_'.get_class($model)::model_type().'_INSTANCE')])); |
|
| 203 | 203 | return $model; |
| 204 | 204 | } |
| 205 | 205 | foreach ($this->errors() as $field => $error_msg) { |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | public function before_edit() |
| 213 | 213 | { |
| 214 | 214 | if (!is_null($this->router()->params('id')) && is_null($this->load_model)) { |
| 215 | - $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->modelClassName()::model_type() . '_INSTANCE')])); |
|
| 215 | + $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->modelClassName()::model_type().'_INSTANCE')])); |
|
| 216 | 216 | $this->router()->hop($this->modelClassName()::model_type()); |
| 217 | 217 | } |
| 218 | 218 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | public function destroy_confirm() |
| 232 | 232 | { |
| 233 | 233 | if (is_null($this->load_model)) { |
| 234 | - $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')])); |
|
| 234 | + $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')])); |
|
| 235 | 235 | $this->router()->hop($this->model_type); |
| 236 | 236 | } |
| 237 | 237 | |
@@ -243,10 +243,10 @@ discard block |
||
| 243 | 243 | public function before_destroy() // default: checks for load_model and immortality, hops back to object on failure |
| 244 | 244 | { |
| 245 | 245 | if (is_null($this->load_model)) { |
| 246 | - $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')])); |
|
| 246 | + $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_NOT_FOUND', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')])); |
|
| 247 | 247 | $this->router()->hop($this->model_type); |
| 248 | 248 | } elseif ($this->load_model->immortal()) { |
| 249 | - $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')])); |
|
| 249 | + $this->logger()->warning($this->l('CRUDITES_ERR_INSTANCE_IS_IMMORTAL', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')])); |
|
| 250 | 250 | $this->router()->hop($this->route_model($this->load_model)); |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -258,10 +258,10 @@ discard block |
||
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | if ($this->load_model->destroy($this->operator()->getId()) === false) { |
| 261 | - $this->logger()->info($this->l('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', ['' . $this->load_model])); |
|
| 261 | + $this->logger()->info($this->l('CRUDITES_ERR_INSTANCE_IS_UNDELETABLE', [''.$this->load_model])); |
|
| 262 | 262 | $this->routeBack($this->load_model); |
| 263 | 263 | } else { |
| 264 | - $this->logger()->notice($this->l('CRUDITES_INSTANCE_DESTROYED', [$this->l('MODEL_' . $this->model_type . '_INSTANCE')])); |
|
| 264 | + $this->logger()->notice($this->l('CRUDITES_INSTANCE_DESTROYED', [$this->l('MODEL_'.$this->model_type.'_INSTANCE')])); |
|
| 265 | 265 | $this->routeBack($this->model_type); |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | public function collection_to_csv($collection, $filename) |
| 286 | 286 | { |
| 287 | 287 | // TODO use Format/File/CSV class to generate file |
| 288 | - $file_path = $this->get('settings.export.directory') . $filename . '.csv'; |
|
| 288 | + $file_path = $this->get('settings.export.directory').$filename.'.csv'; |
|
| 289 | 289 | $fp = fopen($file_path, 'w'); |
| 290 | 290 | |
| 291 | 291 | $header = false; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | public function route_new(ModelInterface $model): string |
| 324 | 324 | { |
| 325 | - return $this->router()->hyp(get_class($model)::model_type() . '_new'); |
|
| 325 | + return $this->router()->hyp(get_class($model)::model_type().'_new'); |
|
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | public function route_list(ModelInterface $model): string |
@@ -334,7 +334,7 @@ discard block |
||
| 334 | 334 | { |
| 335 | 335 | $route_params = []; |
| 336 | 336 | |
| 337 | - $route_name = get_class($model)::model_type() . '_'; |
|
| 337 | + $route_name = get_class($model)::model_type().'_'; |
|
| 338 | 338 | if ($model->isNew()) { |
| 339 | 339 | $route_name .= 'new'; |
| 340 | 340 | } else { |