@@ -9,11 +9,13 @@ discard block |
||
| 9 | 9 | { |
| 10 | 10 | private static function compute_field_value($model,$field_name) |
| 11 | 11 | { |
| 12 | - if(method_exists($model,$field_name)) |
|
| 13 | - return $model->$field_name(); |
|
| 12 | + if(method_exists($model,$field_name)) { |
|
| 13 | + return $model->$field_name(); |
|
| 14 | + } |
|
| 14 | 15 | |
| 15 | - if(property_exists($model,$field_name)) |
|
| 16 | - return $model->$field_name; |
|
| 16 | + if(property_exists($model,$field_name)) { |
|
| 17 | + return $model->$field_name; |
|
| 18 | + } |
|
| 17 | 19 | |
| 18 | 20 | return ''; |
| 19 | 21 | } |
@@ -51,74 +53,66 @@ discard block |
||
| 51 | 53 | |
| 52 | 54 | $table = get_class($model)::table(); |
| 53 | 55 | |
| 54 | - if(is_null($table->column($field_name))) |
|
| 55 | - return Form::input($field_name,$field_value,$attributes,$errors); |
|
| 56 | + if(is_null($table->column($field_name))) { |
|
| 57 | + return Form::input($field_name,$field_value,$attributes,$errors); |
|
| 58 | + } |
|
| 56 | 59 | |
| 57 | 60 | $ret = ''; |
| 58 | 61 | |
| 59 | 62 | $field = $table->column($field_name); |
| 60 | 63 | |
| 61 | 64 | |
| 62 | - if(isset($attributes['required']) && $attributes['required'] === false) |
|
| 63 | - unset($attributes['required']); |
|
| 64 | - |
|
| 65 | - elseif(!$field->is_nullable()) |
|
| 66 | - $attributes[] = 'required'; |
|
| 65 | + if(isset($attributes['required']) && $attributes['required'] === false) { |
|
| 66 | + unset($attributes['required']); |
|
| 67 | + } elseif(!$field->is_nullable()) { |
|
| 68 | + $attributes[] = 'required'; |
|
| 69 | + } |
|
| 67 | 70 | |
| 68 | 71 | if($field->is_auto_incremented()) |
| 69 | 72 | { |
| 70 | 73 | $ret .= Form::hidden($field->name(),$field_value); |
| 71 | - } |
|
| 72 | - elseif($field->type()->is_boolean()) |
|
| 74 | + } elseif($field->type()->is_boolean()) |
|
| 73 | 75 | { |
| 74 | 76 | $option_list = $attributes['values'] ?? [0 => 0, 1 => 1]; |
| 75 | 77 | $ret .= Form::select($field->name(), $option_list ,$field_value, $attributes); // |
| 76 | - } |
|
| 77 | - elseif($field->type()->is_integer()) |
|
| 78 | + } elseif($field->type()->is_integer()) |
|
| 78 | 79 | { |
| 79 | 80 | $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
| 80 | - } |
|
| 81 | - elseif($field->type()->is_year()) |
|
| 81 | + } elseif($field->type()->is_year()) |
|
| 82 | 82 | { |
| 83 | 83 | $attributes['size'] = $attributes['maxlength'] = 4; |
| 84 | 84 | $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
| 85 | - } |
|
| 86 | - elseif($field->type()->is_date()) |
|
| 85 | + } elseif($field->type()->is_date()) |
|
| 87 | 86 | { |
| 88 | 87 | $ret .= Form::date($field->name(),$field_value,$attributes,$errors); |
| 89 | - } |
|
| 90 | - elseif($field->type()->is_time()) |
|
| 88 | + } elseif($field->type()->is_time()) |
|
| 91 | 89 | { |
| 92 | 90 | $ret .= Form::time($field->name(),$field_value,$attributes,$errors); |
| 93 | - } |
|
| 94 | - elseif($field->type()->is_datetime()) |
|
| 91 | + } elseif($field->type()->is_datetime()) |
|
| 95 | 92 | { |
| 96 | 93 | $ret .= Form::datetime($field->name(),$field_value,$attributes,$errors); |
| 97 | - } |
|
| 98 | - elseif($field->type()->is_text()) |
|
| 94 | + } elseif($field->type()->is_text()) |
|
| 99 | 95 | { |
| 100 | 96 | $ret .= Form::textarea($field->name(),$field_value,$attributes,$errors); |
| 101 | - } |
|
| 102 | - elseif($field->type()->is_enum()) |
|
| 97 | + } elseif($field->type()->is_enum()) |
|
| 103 | 98 | { |
| 104 | 99 | |
| 105 | 100 | $enum_values = []; |
| 106 | - foreach($field->type()->enum_values() as $e_val) |
|
| 107 | - $enum_values[$e_val] = $e_val; |
|
| 101 | + foreach($field->type()->enum_values() as $e_val) { |
|
| 102 | + $enum_values[$e_val] = $e_val; |
|
| 103 | + } |
|
| 108 | 104 | |
| 109 | 105 | $selected = $attributes['value'] ?? $field_value ?? ''; |
| 110 | 106 | // foreach($field->) |
| 111 | 107 | $ret .= Form::select($field->name(), $enum_values, $selected, $attributes); // |
| 112 | 108 | |
| 113 | 109 | // throw new \Exception('ENUM IS NOT HANDLED BY TableToFom'); |
| 114 | - } |
|
| 115 | - elseif($field->type()->is_string()) |
|
| 110 | + } elseif($field->type()->is_string()) |
|
| 116 | 111 | { |
| 117 | 112 | $max_length = $field->type()->length(); |
| 118 | 113 | $attributes['size'] = $attributes['maxlength'] = $max_length; |
| 119 | 114 | $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
| 120 | - } |
|
| 121 | - else |
|
| 115 | + } else |
|
| 122 | 116 | { |
| 123 | 117 | $ret .= Form::input($field->name(),$field_value,$attributes,$errors); |
| 124 | 118 | } |
@@ -130,8 +124,9 @@ discard block |
||
| 130 | 124 | public static function field_with_label($model,$field_name,$attributes=[],$errors=[]) : string |
| 131 | 125 | { |
| 132 | 126 | $field_attributes = $attributes; |
| 133 | - if(isset($attributes['label'])) |
|
| 134 | - unset($field_attributes['label']); |
|
| 127 | + if(isset($attributes['label'])) { |
|
| 128 | + unset($field_attributes['label']); |
|
| 129 | + } |
|
| 135 | 130 | |
| 136 | 131 | return sprintf('%s %s', self::label($model,$field_name,$attributes,$errors), self::field($model,$field_name,$field_attributes,$errors)); |
| 137 | 132 | } |
@@ -148,14 +143,15 @@ discard block |
||
| 148 | 143 | $form_field = ''; |
| 149 | 144 | if($column->is_auto_incremented()) |
| 150 | 145 | { |
| 151 | - if(!$model->is_new()) |
|
| 152 | - $form_field = self::field($model,$column_name); |
|
| 153 | - } |
|
| 154 | - else |
|
| 146 | + if(!$model->is_new()) { |
|
| 147 | + $form_field = self::field($model,$column_name); |
|
| 148 | + } |
|
| 149 | + } else |
|
| 155 | 150 | { |
| 156 | 151 | $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]); |
|
| 152 | + if(!is_null($group_class)) { |
|
| 153 | + $form_field = new Element('div',$form_field, ['class' => $group_class]); |
|
| 154 | + } |
|
| 159 | 155 | } |
| 160 | 156 | $ret .= PHP_EOL.$form_field; |
| 161 | 157 | } |
@@ -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 | } |
@@ -31,10 +31,10 @@ discard block |
||
| 31 | 31 | return $this->iso_name().' ('.$this->Part3.')'; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - public function traceable() : bool |
|
| 35 | - { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 34 | + public function traceable() : bool |
|
| 35 | + { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | public function iso_name() |
| 40 | 40 | { |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | public static function search_language($term, $authority=null) |
| 103 | 103 | { |
| 104 | 104 | $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass(); |
| 105 | - $ret = []; |
|
| 106 | - foreach($rows as $row) |
|
| 107 | - $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 105 | + $ret = []; |
|
| 106 | + foreach($rows as $row) |
|
| 107 | + $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 108 | 108 | |
| 109 | 109 | return $ret; |
| 110 | 110 | } |
@@ -52,39 +52,39 @@ discard block |
||
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | |
| 55 | - public static function query_retrieve($filter=[], $options=[]) : \HexMakina\Crudites\Queries\BaseQuery |
|
| 55 | + public static function query_retrieve($filter = [], $options = []) : \HexMakina\Crudites\Queries\BaseQuery |
|
| 56 | 56 | { |
| 57 | 57 | |
| 58 | 58 | $searchable_fields = [self::ISO_NAME, self::ISO_3, self::ISO_2B, self::ISO_2T, self::ISO_1]; |
| 59 | 59 | |
| 60 | 60 | $Query = static::table()->select(); |
| 61 | 61 | |
| 62 | - if(isset($filter['name'])) |
|
| 62 | + if (isset($filter['name'])) |
|
| 63 | 63 | { |
| 64 | 64 | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - if(isset($filter['code'])) |
|
| 67 | + if (isset($filter['code'])) |
|
| 68 | 68 | { |
| 69 | 69 | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(isset($filter['term'])) |
|
| 72 | + if (isset($filter['term'])) |
|
| 73 | 73 | { |
| 74 | 74 | $Query->aw_filter_content(['term' => $filter['term'], 'fields' => $searchable_fields], $Query->table_label(), 'OR'); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - if(isset($filter['requires_authority']) && isset(self::ISO_SETS[$filter['requires_authority']])) |
|
| 77 | + if (isset($filter['requires_authority']) && isset(self::ISO_SETS[$filter['requires_authority']])) |
|
| 78 | 78 | { |
| 79 | 79 | $Query->aw_not_empty($filter['requires_authority']); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if(isset($filter['types'])) |
|
| 82 | + if (isset($filter['types'])) |
|
| 83 | 83 | { |
| 84 | 84 | $wc = sprintf('AND Type IN (\'%s\') ', implode('\', \'', array_keys(self::types()))); |
| 85 | 85 | $Query->and_where($wc); |
| 86 | 86 | } |
| 87 | - if(isset($filter['scopes'])) |
|
| 87 | + if (isset($filter['scopes'])) |
|
| 88 | 88 | { |
| 89 | 89 | $wc = sprintf('AND Scope IN (\'%s\') ', implode('\', \'', array_keys(self::scopes()))); |
| 90 | 90 | $Query->and_where($wc); |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | return $Query; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - public static function search_language($term, $authority=null) |
|
| 102 | + public static function search_language($term, $authority = null) |
|
| 103 | 103 | { |
| 104 | 104 | $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass(); |
| 105 | 105 | $ret = []; |
| 106 | - foreach($rows as $row) |
|
| 106 | + foreach ($rows as $row) |
|
| 107 | 107 | $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
| 108 | 108 | |
| 109 | 109 | return $ret; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | $Query->aw_eq(self::ISO_3, $code); |
| 116 | 116 | $rows = $Query->ret_col(); |
| 117 | 117 | |
| 118 | - if(isset($rows[0])) // only 1 result |
|
| 118 | + if (isset($rows[0])) // only 1 result |
|
| 119 | 119 | return current($rows); |
| 120 | 120 | |
| 121 | 121 | return null; // no results |
@@ -103,8 +103,9 @@ discard block |
||
| 103 | 103 | { |
| 104 | 104 | $rows = self::query_retrieve(['term' => $term, 'requires_authority' => $authority])->ret_ass(); |
| 105 | 105 | $ret = []; |
| 106 | - foreach($rows as $row) |
|
| 107 | - $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 106 | + foreach($rows as $row) { |
|
| 107 | + $ret[$row[self::ISO_3]] = $row[self::ISO_NAME]; |
|
| 108 | + } |
|
| 108 | 109 | |
| 109 | 110 | return $ret; |
| 110 | 111 | } |
@@ -115,8 +116,10 @@ discard block |
||
| 115 | 116 | $Query->aw_eq(self::ISO_3, $code); |
| 116 | 117 | $rows = $Query->ret_col(); |
| 117 | 118 | |
| 118 | - if(isset($rows[0])) // only 1 result |
|
| 119 | + if(isset($rows[0])) { |
|
| 120 | + // only 1 result |
|
| 119 | 121 | return current($rows); |
| 122 | + } |
|
| 120 | 123 | |
| 121 | 124 | return null; // no results |
| 122 | 125 | } |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | const TABLE_NAME = 'kadro_traduki'; |
| 11 | 11 | const TABLE_ALIAS = 'traduko'; |
| 12 | 12 | |
| 13 | - public function traceable() : bool |
|
| 14 | - { |
|
| 15 | - return false; |
|
| 16 | - } |
|
| 13 | + public function traceable() : bool |
|
| 14 | + { |
|
| 15 | + return false; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | 18 | public function immortal() : bool |
| 19 | 19 | { |
@@ -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']); |
@@ -23,22 +23,22 @@ |
||
| 23 | 23 | |
| 24 | 24 | public static function today($format=Dato::FORMAT) |
| 25 | 25 | { |
| 26 | - return Dato::today($format); |
|
| 27 | - } |
|
| 26 | + return Dato::today($format); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | 29 | public static function date($date=null, $format=Dato::FORMAT) : string |
| 30 | - { |
|
| 31 | - return Dato::format($date); |
|
| 32 | - } |
|
| 30 | + { |
|
| 31 | + return Dato::format($date); |
|
| 32 | + } |
|
| 33 | 33 | // |
| 34 | 34 | // //------------------------------------------------------------ MySQL DateTime helpers |
| 35 | 35 | // public static function year($date=null) : string |
| 36 | - // { |
|
| 37 | - // return Dato::format($date, Dato::FORMAT_YEAR); |
|
| 38 | - // } |
|
| 36 | + // { |
|
| 37 | + // return Dato::format($date, Dato::FORMAT_YEAR); |
|
| 38 | + // } |
|
| 39 | 39 | // |
| 40 | - // public static function datetime($date=null) : string |
|
| 41 | - // { |
|
| 42 | - // return DatoTempo::format($date); |
|
| 43 | - // } |
|
| 40 | + // public static function datetime($date=null) : string |
|
| 41 | + // { |
|
| 42 | + // return DatoTempo::format($date); |
|
| 43 | + // } |
|
| 44 | 44 | } |
@@ -21,12 +21,12 @@ |
||
| 21 | 21 | return $this->__toString(); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public static function today($format=Dato::FORMAT) |
|
| 24 | + public static function today($format = Dato::FORMAT) |
|
| 25 | 25 | { |
| 26 | 26 | return Dato::today($format); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public static function date($date=null, $format=Dato::FORMAT) : string |
|
| 29 | + public static function date($date = null, $format = Dato::FORMAT) : string |
|
| 30 | 30 | { |
| 31 | 31 | return Dato::format($date); |
| 32 | 32 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | public function __debugInfo() |
| 17 | 17 | { |
| 18 | 18 | $dbg = get_object_vars($this); |
| 19 | - $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine'])? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
| 19 | + $dbg['configurations']['template_engine'] = isset($dbg['configurations']['template_engine']) ? get_class($dbg['configurations']['template_engine']) : 'NOT SET'; |
|
| 20 | 20 | |
| 21 | 21 | return $dbg; |
| 22 | 22 | } |
@@ -34,45 +34,45 @@ discard block |
||
| 34 | 34 | public function get($configuration) |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - if(!is_string($configuration)) |
|
| 37 | + if (!is_string($configuration)) |
|
| 38 | 38 | throw new LamentException($configuration); |
| 39 | 39 | |
| 40 | - if($this->has($configuration)) |
|
| 40 | + if ($this->has($configuration)) |
|
| 41 | 41 | return $this->configurations[$configuration]; |
| 42 | 42 | |
| 43 | 43 | |
| 44 | 44 | // fallbacks |
| 45 | - if(preg_match('/^settings\./', $configuration, $m) === 1) |
|
| 45 | + if (preg_match('/^settings\./', $configuration, $m) === 1) |
|
| 46 | 46 | { |
| 47 | 47 | $ret = $this->configurations; |
| 48 | - foreach(explode('.', $configuration) as $k) |
|
| 48 | + foreach (explode('.', $configuration) as $k) |
|
| 49 | 49 | { |
| 50 | - if(!isset($ret[$k])) |
|
| 50 | + if (!isset($ret[$k])) |
|
| 51 | 51 | throw new ConfigurationException($configuration); |
| 52 | 52 | $ret = $ret[$k]; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | return $ret; |
| 56 | 56 | } |
| 57 | - elseif(class_exists($configuration)) // auto create instances |
|
| 57 | + elseif (class_exists($configuration)) // auto create instances |
|
| 58 | 58 | { |
| 59 | 59 | |
| 60 | 60 | $rc = new \ReflectionClass($configuration); |
| 61 | 61 | |
| 62 | 62 | $construction_args = []; |
| 63 | 63 | $instance = null; |
| 64 | - if(!is_null($rc->getConstructor())) |
|
| 64 | + if (!is_null($rc->getConstructor())) |
|
| 65 | 65 | { |
| 66 | - foreach($rc->getConstructor()->getParameters() as $param) |
|
| 66 | + foreach ($rc->getConstructor()->getParameters() as $param) |
|
| 67 | 67 | { |
| 68 | - $construction_args []= $this->get($param->getType().''); |
|
| 68 | + $construction_args [] = $this->get($param->getType().''); |
|
| 69 | 69 | } |
| 70 | 70 | $instance = $rc->newInstanceArgs($construction_args); |
| 71 | 71 | } |
| 72 | 72 | else |
| 73 | 73 | $instance = $rc->newInstanceArgs(); |
| 74 | 74 | |
| 75 | - if($rc->hasMethod('set_container')) |
|
| 75 | + if ($rc->hasMethod('set_container')) |
|
| 76 | 76 | $instance->set_container($this); |
| 77 | 77 | |
| 78 | 78 | return $instance; |
@@ -34,11 +34,13 @@ discard block |
||
| 34 | 34 | public function get($configuration) |
| 35 | 35 | { |
| 36 | 36 | |
| 37 | - if(!is_string($configuration)) |
|
| 38 | - throw new LamentException($configuration); |
|
| 37 | + if(!is_string($configuration)) { |
|
| 38 | + throw new LamentException($configuration); |
|
| 39 | + } |
|
| 39 | 40 | |
| 40 | - if($this->has($configuration)) |
|
| 41 | - return $this->configurations[$configuration]; |
|
| 41 | + if($this->has($configuration)) { |
|
| 42 | + return $this->configurations[$configuration]; |
|
| 43 | + } |
|
| 42 | 44 | |
| 43 | 45 | |
| 44 | 46 | // fallbacks |
@@ -47,17 +49,19 @@ discard block |
||
| 47 | 49 | $ret = $this->configurations; |
| 48 | 50 | foreach(explode('.', $configuration) as $k) |
| 49 | 51 | { |
| 50 | - if(!isset($ret[$k])) |
|
| 51 | - throw new ConfigurationException($configuration); |
|
| 52 | + if(!isset($ret[$k])) { |
|
| 53 | + throw new ConfigurationException($configuration); |
|
| 54 | + } |
|
| 52 | 55 | $ret = $ret[$k]; |
| 53 | 56 | } |
| 54 | 57 | |
| 55 | 58 | return $ret; |
| 56 | - } |
|
| 57 | - elseif(class_exists($configuration)) // auto create instances |
|
| 59 | + } elseif(class_exists($configuration)) { |
|
| 60 | + // auto create instances |
|
| 58 | 61 | { |
| 59 | 62 | |
| 60 | 63 | $rc = new \ReflectionClass($configuration); |
| 64 | + } |
|
| 61 | 65 | |
| 62 | 66 | $construction_args = []; |
| 63 | 67 | $instance = null; |
@@ -68,12 +72,13 @@ discard block |
||
| 68 | 72 | $construction_args []= $this->get($param->getType().''); |
| 69 | 73 | } |
| 70 | 74 | $instance = $rc->newInstanceArgs($construction_args); |
| 75 | + } else { |
|
| 76 | + $instance = $rc->newInstanceArgs(); |
|
| 71 | 77 | } |
| 72 | - else |
|
| 73 | - $instance = $rc->newInstanceArgs(); |
|
| 74 | 78 | |
| 75 | - if($rc->hasMethod('set_container')) |
|
| 76 | - $instance->set_container($this); |
|
| 79 | + if($rc->hasMethod('set_container')) { |
|
| 80 | + $instance->set_container($this); |
|
| 81 | + } |
|
| 77 | 82 | |
| 78 | 83 | return $instance; |
| 79 | 84 | } |
@@ -265,7 +265,7 @@ |
||
| 265 | 265 | * const NOTICE = 'notice'; // Normal but significant events. |
| 266 | 266 | * const INFO = 'info'; // Interesting events. User logs in, SQL logs. |
| 267 | 267 | * const DEBUG = 'debug'; // Detailed debug information. |
| 268 | - */ |
|
| 268 | + */ |
|
| 269 | 269 | private static function map_error_level_to_log_level($level) : string |
| 270 | 270 | { |
| 271 | 271 | // http://php.net/manual/en/errorfunc.constants.php |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | $context['class'] = get_class($throwable); |
| 55 | 55 | $context['trace'] = $throwable->getTrace(); |
| 56 | 56 | |
| 57 | - if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
| 57 | + if (is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
| 58 | 58 | (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
| 59 | - elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
| 59 | + elseif (is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
| 60 | 60 | (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
| 61 | 61 | else |
| 62 | 62 | { |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | public function system_halted($level) |
| 69 | 69 | { |
| 70 | - switch($level) |
|
| 70 | + switch ($level) |
|
| 71 | 71 | { |
| 72 | 72 | case LogLevel::ERROR: |
| 73 | 73 | case LogLevel::CRITICAL: |
@@ -86,19 +86,19 @@ discard block |
||
| 86 | 86 | $display_error = null; |
| 87 | 87 | |
| 88 | 88 | // --- Handles Throwables (exception_handler()) |
| 89 | - if($message==self::INTERNAL_ERROR || $message== self::USER_EXCEPTION) |
|
| 89 | + if ($message == self::INTERNAL_ERROR || $message == self::USER_EXCEPTION) |
|
| 90 | 90 | { |
| 91 | 91 | $this->has_halting_messages = true; |
| 92 | 92 | $display_error = \HexMakina\Debugger\Debugger::format_throwable_message($context['class'], $context['code'], $context['file'], $context['line'], $context['text']); |
| 93 | 93 | error_log($display_error); |
| 94 | - $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
|
| 94 | + $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
|
| 95 | 95 | self::HTTP_500($display_error); |
| 96 | 96 | } |
| 97 | - elseif($this->system_halted($level)) // analyses error level |
|
| 97 | + elseif ($this->system_halted($level)) // analyses error level |
|
| 98 | 98 | { |
| 99 | 99 | $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, \HexMakina\Debugger\Debugger::format_file($context['file']), $context['line'], $message); |
| 100 | 100 | error_log($display_error); |
| 101 | - $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
|
| 101 | + $display_error .= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
|
| 102 | 102 | self::HTTP_500($display_error); |
| 103 | 103 | } |
| 104 | 104 | else |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | // ----------------------------------------------------------- User messages:add one |
| 151 | 151 | public function report_to_user($level, $message, $context = []) |
| 152 | 152 | { |
| 153 | - if(!isset($_SESSION[self::REPORTING_USER])) |
|
| 153 | + if (!isset($_SESSION[self::REPORTING_USER])) |
|
| 154 | 154 | $_SESSION[self::REPORTING_USER] = []; |
| 155 | 155 | |
| 156 | - if(!isset($_SESSION[self::REPORTING_USER][$level])) |
|
| 156 | + if (!isset($_SESSION[self::REPORTING_USER][$level])) |
|
| 157 | 157 | $_SESSION[self::REPORTING_USER][$level] = []; |
| 158 | 158 | |
| 159 | 159 | $_SESSION[self::REPORTING_USER][$level][] = [$message, $context]; |
@@ -185,21 +185,21 @@ discard block |
||
| 185 | 185 | private static function map_error_level_to_log_level($level) : string |
| 186 | 186 | { |
| 187 | 187 | // http://php.net/manual/en/errorfunc.constants.php |
| 188 | - $m=[]; |
|
| 188 | + $m = []; |
|
| 189 | 189 | |
| 190 | - $m[E_ERROR]=$m[E_PARSE]=$m[E_CORE_ERROR]=$m[E_COMPILE_ERROR]=$m[E_USER_ERROR]=$m[E_RECOVERABLE_ERROR]=LogLevel::ALERT; |
|
| 191 | - $m[1]=$m[4]=$m[16]=$m[64]=$m[256]=$m[4096]=LogLevel::ALERT; |
|
| 190 | + $m[E_ERROR] = $m[E_PARSE] = $m[E_CORE_ERROR] = $m[E_COMPILE_ERROR] = $m[E_USER_ERROR] = $m[E_RECOVERABLE_ERROR] = LogLevel::ALERT; |
|
| 191 | + $m[1] = $m[4] = $m[16] = $m[64] = $m[256] = $m[4096] = LogLevel::ALERT; |
|
| 192 | 192 | |
| 193 | - $m[E_WARNING]=$m[E_CORE_WARNING]=$m[E_COMPILE_WARNING]=$m[E_USER_WARNING]=LogLevel::CRITICAL; |
|
| 194 | - $m[2]=$m[32]=$m[128]=$m[512]=LogLevel::CRITICAL; |
|
| 193 | + $m[E_WARNING] = $m[E_CORE_WARNING] = $m[E_COMPILE_WARNING] = $m[E_USER_WARNING] = LogLevel::CRITICAL; |
|
| 194 | + $m[2] = $m[32] = $m[128] = $m[512] = LogLevel::CRITICAL; |
|
| 195 | 195 | |
| 196 | - $m[E_NOTICE]=$m[E_USER_NOTICE]=LogLevel::ERROR; |
|
| 197 | - $m[8]=$m[1024]=LogLevel::ERROR; |
|
| 196 | + $m[E_NOTICE] = $m[E_USER_NOTICE] = LogLevel::ERROR; |
|
| 197 | + $m[8] = $m[1024] = LogLevel::ERROR; |
|
| 198 | 198 | |
| 199 | - $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG; |
|
| 200 | - $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG; |
|
| 199 | + $m[E_STRICT] = $m[E_DEPRECATED] = $m[E_USER_DEPRECATED] = $m[E_ALL] = LogLevel::DEBUG; |
|
| 200 | + $m[2048] = $m[8192] = $m[16384] = $m[32767] = LogLevel::DEBUG; |
|
| 201 | 201 | |
| 202 | - if(isset($m[$level])) |
|
| 202 | + if (isset($m[$level])) |
|
| 203 | 203 | return $m[$level]; |
| 204 | 204 | |
| 205 | 205 | throw new \Exception(__FUNCTION__."($level): $level is unknown"); |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | $context['class'] = get_class($throwable); |
| 55 | 55 | $context['trace'] = $throwable->getTrace(); |
| 56 | 56 | |
| 57 | - if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') |
|
| 58 | - (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
|
| 59 | - elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') |
|
| 60 | - (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
|
| 61 | - else |
|
| 57 | + if(is_subclass_of($throwable, 'Error') || get_class($throwable) === 'Error') { |
|
| 58 | + (new LogLaddy())->alert(self::INTERNAL_ERROR, $context); |
|
| 59 | + } elseif(is_subclass_of($throwable, 'Exception') || get_class($throwable) === 'Exception') { |
|
| 60 | + (new LogLaddy())->notice(self::USER_EXCEPTION, $context); |
|
| 61 | + } else |
|
| 62 | 62 | { |
| 63 | 63 | die('This Throwable is not an Error or an Exception. This is unfortunate.'); |
| 64 | 64 | } |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | error_log($display_error); |
| 94 | 94 | $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
| 95 | 95 | self::HTTP_500($display_error); |
| 96 | - } |
|
| 97 | - elseif($this->system_halted($level)) // analyses error level |
|
| 96 | + } elseif($this->system_halted($level)) { |
|
| 97 | + // analyses error level |
|
| 98 | 98 | { |
| 99 | 99 | $display_error = sprintf(PHP_EOL.'%s in file %s:%d'.PHP_EOL.'%s', $level, \HexMakina\Debugger\Debugger::format_file($context['file']), $context['line'], $message); |
| 100 | + } |
|
| 100 | 101 | error_log($display_error); |
| 101 | 102 | $display_error.= \HexMakina\Debugger\Debugger::format_trace($context['trace'], false); |
| 102 | 103 | self::HTTP_500($display_error); |
| 103 | - } |
|
| 104 | - else |
|
| 104 | + } else |
|
| 105 | 105 | {// --- Handles user messages, through SESSION storage |
| 106 | 106 | $this->report_to_user($level, $message, $context); |
| 107 | 107 | } |
@@ -150,11 +150,13 @@ discard block |
||
| 150 | 150 | // ----------------------------------------------------------- User messages:add one |
| 151 | 151 | public function report_to_user($level, $message, $context = []) |
| 152 | 152 | { |
| 153 | - if(!isset($_SESSION[self::REPORTING_USER])) |
|
| 154 | - $_SESSION[self::REPORTING_USER] = []; |
|
| 153 | + if(!isset($_SESSION[self::REPORTING_USER])) { |
|
| 154 | + $_SESSION[self::REPORTING_USER] = []; |
|
| 155 | + } |
|
| 155 | 156 | |
| 156 | - if(!isset($_SESSION[self::REPORTING_USER][$level])) |
|
| 157 | - $_SESSION[self::REPORTING_USER][$level] = []; |
|
| 157 | + if(!isset($_SESSION[self::REPORTING_USER][$level])) { |
|
| 158 | + $_SESSION[self::REPORTING_USER][$level] = []; |
|
| 159 | + } |
|
| 158 | 160 | |
| 159 | 161 | $_SESSION[self::REPORTING_USER][$level][] = [$message, $context]; |
| 160 | 162 | } |
@@ -199,8 +201,9 @@ discard block |
||
| 199 | 201 | $m[E_STRICT]=$m[E_DEPRECATED]=$m[E_USER_DEPRECATED]=$m[E_ALL]=LogLevel::DEBUG; |
| 200 | 202 | $m[2048]=$m[8192]=$m[16384]=$m[32767]=LogLevel::DEBUG; |
| 201 | 203 | |
| 202 | - if(isset($m[$level])) |
|
| 203 | - return $m[$level]; |
|
| 204 | + if(isset($m[$level])) { |
|
| 205 | + return $m[$level]; |
|
| 206 | + } |
|
| 204 | 207 | |
| 205 | 208 | throw new \Exception(__FUNCTION__."($level): $level is unknown"); |
| 206 | 209 | } |
@@ -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; |
@@ -12,8 +12,9 @@ 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')) |
|
| 16 | - throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
|
| 15 | + if(!is_subclass_of($file_manageable_model, '\HexMakina\Crudites\TightModel')) { |
|
| 16 | + throw new \Exception("__construct($file_manageable_model) // only Model items are manageable"); |
|
| 17 | + } |
|
| 17 | 18 | |
| 18 | 19 | $this->pmi = $file_manageable_model; |
| 19 | 20 | $this->picture_type = $filetype; |
@@ -58,11 +59,13 @@ discard block |
||
| 58 | 59 | return $this->pmi->get_id().'/'; |
| 59 | 60 | |
| 60 | 61 | $pmi_model_type = get_class($this->pmi)::model_type(); |
| 61 | - if(!isset($this->pmi) || is_null($this->get_type())) |
|
| 62 | - throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
|
| 62 | + if(!isset($this->pmi) || is_null($this->get_type())) { |
|
| 63 | + throw new \Exception(__FUNCTION__." // undefined manageable item or picture type"); |
|
| 64 | + } |
|
| 63 | 65 | |
| 64 | - if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) |
|
| 65 | - throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
|
| 66 | + if(!isset($settings[$pmi_model_type][$this->get_type()]['import_directory'])) { |
|
| 67 | + throw new \Exception(__FUNCTION__." // undefined configuration for '".($pmi_model_type)."'>'".$this->get_type()."'>'import_directory'"); |
|
| 68 | + } |
|
| 66 | 69 | |
| 67 | 70 | // global $settings; |
| 68 | 71 | // return $settings[$pmi_model_type][$this->get_type()]['import_directory'].$this->pmi->get_id().'/'; |
@@ -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 | |
@@ -12,12 +12,12 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | use Permissionability; |
| 14 | 14 | |
| 15 | - public function __toString() |
|
| 15 | + public function __toString() |
|
| 16 | 16 | {
|
| 17 | 17 | return $this->get('username');
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function is_active() : bool |
|
| 20 | + public function is_active() : bool |
|
| 21 | 21 | {
|
| 22 | 22 | return !empty($this->get('active'));
|
| 23 | 23 | } |
@@ -38,14 +38,14 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function password_change($string) |
| 41 | - {
|
|
| 42 | - $this->password = password_hash($string, PASSWORD_DEFAULT); |
|
| 43 | - } |
|
| 41 | + {
|
|
| 42 | + $this->password = password_hash($string, PASSWORD_DEFAULT); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - public function password_verify($string) : bool |
|
| 46 | - {
|
|
| 47 | - return password_verify($string, $this->password()); |
|
| 48 | - } |
|
| 45 | + public function password_verify($string) : bool |
|
| 46 | + {
|
|
| 47 | + return password_verify($string, $this->password()); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | public function name() |
| 51 | 51 | {
|
@@ -61,39 +61,39 @@ discard block |
||
| 61 | 61 | return $this->get('phone');
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - public function language_code() |
|
| 64 | + public function language_code() |
|
| 65 | 65 | {
|
| 66 | 66 | return $this->get('language_code');
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - public static function query_retrieve($filters=[], $options=[]) : Select |
|
| 70 | - {
|
|
| 71 | - $Query = static::table()->select(); |
|
| 72 | - if(isset($options['eager']) && $options['eager'] === true) |
|
| 73 | - {
|
|
| 69 | + public static function query_retrieve($filters=[], $options=[]) : Select |
|
| 70 | + {
|
|
| 71 | + $Query = static::table()->select(); |
|
| 72 | + if(isset($options['eager']) && $options['eager'] === true) |
|
| 73 | + {
|
|
| 74 | 74 | $Query->group_by('id');
|
| 75 | 75 | |
| 76 | 76 | $Query->auto_join([ACL::table(), 'acl'], null, 'LEFT OUTER'); |
| 77 | 77 | $Query->auto_join([Permission::table(), 'kadro_permission'], null, 'LEFT OUTER'); |
| 78 | - $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]); |
|
| 79 | - } |
|
| 78 | + $Query->select_also(["GROUP_CONCAT(DISTINCT kadro_permission.id) as permission_ids", "GROUP_CONCAT(DISTINCT kadro_permission.name) as permission_names"]); |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if(isset($filters['model']) && !empty($filters['model'])) |
|
| 82 | - {
|
|
| 83 | - $model = $filters['model']; |
|
| 84 | - $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
|
|
| 85 | - $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
|
|
| 86 | - } |
|
| 81 | + if(isset($filters['model']) && !empty($filters['model'])) |
|
| 82 | + {
|
|
| 83 | + $model = $filters['model']; |
|
| 84 | + $Query->join([static::otm('t'), static::otm('a')],[[static::otm('a'),static::otm('k'), 't_from','id']], 'INNER');
|
|
| 85 | + $Query->aw_fields_eq(['model_id' => $filters['model']->get_id(), 'model_type' => get_class($filters['model'])::model_type()], static::otm('a'));
|
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | $Query->order_by([$Query->table_label(), 'name', 'ASC']); |
| 89 | 89 | |
| 90 | 90 | |
| 91 | - return $Query; |
|
| 92 | - } |
|
| 91 | + return $Query; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public function immortal() : bool |
|
| 95 | - {
|
|
| 96 | - return true; // never delete a user, always deactivate |
|
| 97 | - } |
|
| 94 | + public function immortal() : bool |
|
| 95 | + {
|
|
| 96 | + return true; // never delete a user, always deactivate |
|
| 97 | + } |
|
| 98 | 98 | } |
| 99 | 99 | |
@@ -4,14 +4,14 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface CRUDController |
| 6 | 6 | { |
| 7 | - public function dashboard(); |
|
| 8 | - public function edit(); |
|
| 9 | - public function save(); |
|
| 10 | - public function listing(); |
|
| 7 | + public function dashboard(); |
|
| 8 | + public function edit(); |
|
| 9 | + public function save(); |
|
| 10 | + public function listing(); |
|
| 11 | 11 | |
| 12 | - public function destroy(); |
|
| 12 | + public function destroy(); |
|
| 13 | 13 | |
| 14 | - public function errors() : array; |
|
| 14 | + public function errors() : array; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | |