Passed
Push — main ( 532590...120ebc )
by Sammy
01:27
created
Models/Traduko.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
     return false;
21 21
   }
22 22
 
23
-  public static function query_retrieve($filters=[], $options=[]) : SelectInterface
23
+  public static function query_retrieve($filters = [], $options = []) : SelectInterface
24 24
   {
25 25
     $Query = static::table()->select();
26 26
     $Query->order_by(['kategorio', 'ASC']);
Please login to merge, or discard this patch.
Controllers/Interfaces/DisplayControllerInterface.class.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,9 +42,9 @@
 block discarded – undo
42 42
            returns null
43 43
    */
44 44
    
45
-   public function viewport($key=null, $value=null, $coercion=false);
45
+   public function viewport($key = null, $value = null, $coercion = false);
46 46
 
47
-   public function display($custom_template = null, $standalone=false);
47
+   public function display($custom_template = null, $standalone = false);
48 48
 
49 49
 }
50 50
 
Please login to merge, or discard this patch.
Router/hopper.class.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@  discard block
 block discarded – undo
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,12 +44,12 @@  discard block
 block discarded – undo
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 55
     // if($this->match['name'] === 'akadok_controller_method')
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
common.inc.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
   require APP_BASE.'vendor/autoload.php';
15 15
 
16 16
   require 'PSR4Autoloader.class.php';
17
-  $loader=new PSR4Autoloader;
17
+  $loader = new PSR4Autoloader;
18 18
   $loader->register(); //Register loader with SPL autoloader stack.
19 19
 
20 20
   $loader->addNamespace('HexMakina', APP_BASE.'/lib/');
@@ -39,9 +39,9 @@  discard block
 block discarded – undo
39 39
 
40 40
   //---------------------------------------------------------------     parametroj
41 41
   require_once APP_BASE.'configs/settings.php';
42
-  $box=new Container\LeMarchand($settings);
42
+  $box = new Container\LeMarchand($settings);
43 43
 
44
-  foreach($box->get('settings.app.namespaces') as $namespace => $path)
44
+  foreach ($box->get('settings.app.namespaces') as $namespace => $path)
45 45
   {
46 46
     $loader->addNamespace($namespace, $path);
47 47
   }
@@ -57,9 +57,9 @@  discard block
 block discarded – undo
57 57
 
58 58
   //---------------------------------------------------------------        kuketoj
59 59
   setcookie('cookie_test', 'test_value', time()+(365 * 24 * 60 * 60), "/", "");
60
-  $cookies_enabled=isset($_COOKIE['cookie_test']); // houston, do we have cookies ?
60
+  $cookies_enabled = isset($_COOKIE['cookie_test']); // houston, do we have cookies ?
61 61
 
62
-  if($cookies_enabled === false)
62
+  if ($cookies_enabled === false)
63 63
   {
64 64
     ini_set('session.use_cookies', 0);
65 65
     ini_set('session.use_only_cookies', 0);
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
   }
69 69
 
70 70
 //---------------------------------------------------------------        Session Management
71
-  $StateAgent=new StateAgent($box->get('settings.app.session_start_options') ?? []);
71
+  $StateAgent = new StateAgent($box->get('settings.app.session_start_options') ?? []);
72 72
   $StateAgent->add_runtime_filters((array)$box->get('settings.filter'));
73 73
   $StateAgent->add_runtime_filters((array)($_SESSION['filter'] ?? []));
74 74
   $StateAgent->add_runtime_filters((array)($_REQUEST['filter'] ?? []));
@@ -92,24 +92,24 @@  discard block
 block discarded – undo
92 92
   //---------------------------------------------------------------     ŝablonoj
93 93
   require_once 'smarty/smarty/libs/Smarty.class.php';
94 94
   // Load smarty template parser
95
-  if(is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path')))
95
+  if (is_null($box->get('settings.smarty.template_path')) || is_null($box->get('settings.smarty.compiled_path')))
96 96
       throw new \Exception("SMARTY CONFIG ERROR: missing parameters");
97 97
 
98
-  $smarty=new \Smarty();
98
+  $smarty = new \Smarty();
99 99
   $box->register('template_engine', $smarty);
100 100
 
101
-  $smarty->setTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path').'app');
102
-  $smarty->addTemplateDir($box->get('RouterInterface')->file_root() . $box->get('settings.smarty.template_path'));
103
-  $smarty->addTemplateDir(KADRO_BASE . 'Views/');
101
+  $smarty->setTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path').'app');
102
+  $smarty->addTemplateDir($box->get('RouterInterface')->file_root().$box->get('settings.smarty.template_path'));
103
+  $smarty->addTemplateDir(KADRO_BASE.'Views/');
104 104
 
105
-  $smarty->setCompileDir(APP_BASE . $box->get('settings.smarty.compiled_path'));
105
+  $smarty->setCompileDir(APP_BASE.$box->get('settings.smarty.compiled_path'));
106 106
   $smarty->setDebugging($box->get('settings.smarty.debug'));
107 107
 
108
-  $smarty->registerClass('Lezer',       '\HexMakina\Lezer\Lezer');
109
-  $smarty->registerClass('Marker',       '\HexMakina\Marker\Marker');
110
-  $smarty->registerClass('Form',         '\HexMakina\Marker\Form');
111
-  $smarty->registerClass('TableToForm',  '\HexMakina\kadro\TableToForm');
112
-  $smarty->registerClass('Dato',         '\HexMakina\Format\Tempo\Dato');
108
+  $smarty->registerClass('Lezer', '\HexMakina\Lezer\Lezer');
109
+  $smarty->registerClass('Marker', '\HexMakina\Marker\Marker');
110
+  $smarty->registerClass('Form', '\HexMakina\Marker\Form');
111
+  $smarty->registerClass('TableToForm', '\HexMakina\kadro\TableToForm');
112
+  $smarty->registerClass('Dato', '\HexMakina\Format\Tempo\Dato');
113 113
 
114 114
   $smarty->assign('APP_NAME', $box->get('settings.app.name'));
115 115
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
   $lezer->init();
125 125
 
126 126
   $smarty->assign('language', $language);
127
-  if($cookies_enabled === true)
127
+  if ($cookies_enabled === true)
128 128
     setcookie('lang', $language, time()+(365 * 24 * 60 * 60), "/", "");
129 129
 
130 130
 }
Please login to merge, or discard this patch.
TableToForm.class.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -3,26 +3,26 @@  discard block
 block discarded – undo
3 3
 namespace HexMakina\kadro;
4 4
 
5 5
 use \HexMakina\Crudites\Interfaces\ModelInterface;
6
-use \HexMakina\Marker\{Form,Element};
6
+use \HexMakina\Marker\{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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.