@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function __set($name, $value) |
61 | 61 | { |
62 | - $setter = 'set' . $name; |
|
62 | + $setter = 'set'.$name; |
|
63 | 63 | if (method_exists($this, $setter)) { |
64 | 64 | $this->$setter($value); |
65 | 65 | } |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function getInputName() |
166 | 166 | { |
167 | 167 | if ($this->hasForm()) { |
168 | - return $this->getForm()->getInputName() . '[' . $this->getName() . ']'; |
|
168 | + return $this->getForm()->getInputName().'['.$this->getName().']'; |
|
169 | 169 | } |
170 | 170 | return $this->getName(); |
171 | 171 | } |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | return Arr::get($this->_errors, 0, ''); |
210 | 210 | } |
211 | 211 | |
212 | - public function setErrors($errors=[]) |
|
212 | + public function setErrors($errors = []) |
|
213 | 213 | { |
214 | 214 | $this->_errors = $errors; |
215 | 215 | } |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | /** |
278 | 278 | * @inheritdoc |
279 | 279 | */ |
280 | - public function setValidators($validators, $overwrite=true) |
|
280 | + public function setValidators($validators, $overwrite = true) |
|
281 | 281 | { |
282 | 282 | if ($overwrite) |
283 | 283 | $this->_validators = []; |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | else if (is_string($validator)) { |
335 | 335 | $ret = ['class' => $validator]; |
336 | 336 | } else { |
337 | - throw new \Exception("Invalid validator information. Probably missing neon class. ".print_r($validator,true)); |
|
337 | + throw new \Exception("Invalid validator information. Probably missing neon class. ".print_r($validator, true)); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | // finally normalise the validator class |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $key - a key to identify this validator - an md5 hash of the validator and its options |
360 | 360 | * @return \yii\validators\Validator |
361 | 361 | */ |
362 | - public function createValidator($validator, $options=[], &$key='') |
|
362 | + public function createValidator($validator, $options = [], &$key = '') |
|
363 | 363 | { |
364 | 364 | if (is_object($validator)) { |
365 | 365 | $validatorObject = $validator; |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | public function removeValidator($validator) |
380 | 380 | { |
381 | 381 | $class = $this->_getValidatorClass($validator); |
382 | - foreach($this->_validators as $key => $validatorObject) { |
|
382 | + foreach ($this->_validators as $key => $validatorObject) { |
|
383 | 383 | if ($validatorObject instanceof $class) { |
384 | 384 | unset($this->_validators[$key]); |
385 | 385 | } |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | // for example 'required' gives ['class'=>'\yii\validators\Required'] |
428 | 428 | // otherwise assume a validator class string has been passed in |
429 | 429 | $class = $this->_getValidatorClass($class); |
430 | - $value = collect($this->getValidators())->first(function ($validatorObject) use ($class) { |
|
430 | + $value = collect($this->getValidators())->first(function($validatorObject) use ($class) { |
|
431 | 431 | return $validatorObject instanceof $class; |
432 | 432 | }, false); |
433 | 433 | |
@@ -457,13 +457,13 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * @inheritdoc |
459 | 459 | */ |
460 | - public function getIdPath($delimiter='.') |
|
460 | + public function getIdPath($delimiter = '.') |
|
461 | 461 | { |
462 | 462 | // set the form id if not already set to something else |
463 | 463 | if ($this->isRootForm()) |
464 | 464 | return $this->getId() ?: $this->getName(); |
465 | 465 | return $this->hasForm() |
466 | - ? $this->getForm()->getIdPath($delimiter) . $delimiter . $this->getName() |
|
466 | + ? $this->getForm()->getIdPath($delimiter).$delimiter.$this->getName() |
|
467 | 467 | : $this->getName(); |
468 | 468 | } |
469 | 469 |
@@ -279,8 +279,9 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function setValidators($validators, $overwrite=true) |
281 | 281 | { |
282 | - if ($overwrite) |
|
283 | - $this->_validators = []; |
|
282 | + if ($overwrite) { |
|
283 | + $this->_validators = []; |
|
284 | + } |
|
284 | 285 | if (is_array($validators)) { |
285 | 286 | foreach ($validators as $key => $validator) { |
286 | 287 | if (is_numeric($key)) { |
@@ -407,10 +408,12 @@ discard block |
||
407 | 408 | */ |
408 | 409 | protected function _getValidatorClass($class) |
409 | 410 | { |
410 | - if (is_array($class) && isset($class['class'])) |
|
411 | - $class = $class['class']; |
|
412 | - if (is_object($class)) |
|
413 | - $class = get_class($class); |
|
411 | + if (is_array($class) && isset($class['class'])) { |
|
412 | + $class = $class['class']; |
|
413 | + } |
|
414 | + if (is_object($class)) { |
|
415 | + $class = get_class($class); |
|
416 | + } |
|
414 | 417 | |
415 | 418 | if (isset(Validator::$builtInValidators[$class])) { |
416 | 419 | $class = Validator::$builtInValidators[$class]['class']; |
@@ -460,8 +463,9 @@ discard block |
||
460 | 463 | public function getIdPath($delimiter='.') |
461 | 464 | { |
462 | 465 | // set the form id if not already set to something else |
463 | - if ($this->isRootForm()) |
|
464 | - return $this->getId() ?: $this->getName(); |
|
466 | + if ($this->isRootForm()) { |
|
467 | + return $this->getId() ?: $this->getName(); |
|
468 | + } |
|
465 | 469 | return $this->hasForm() |
466 | 470 | ? $this->getForm()->getIdPath($delimiter) . $delimiter . $this->getName() |
467 | 471 | : $this->getName(); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | if (!is_array($value)) |
106 | 106 | throw new \InvalidArgumentException('The value should be an array'); |
107 | 107 | |
108 | - foreach($value as $position => $values) { |
|
108 | + foreach ($value as $position => $values) { |
|
109 | 109 | if (!$this->hasField($position)) { |
110 | 110 | $this->addInstance($position); |
111 | 111 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $subFormCount = count(parent::getSubForms()); |
122 | 122 | if ($subFormCount < $this->count) { |
123 | - for ($i = $subFormCount; $i <= $this->count-1; $i++) { |
|
123 | + for ($i = $subFormCount; $i <= $this->count - 1; $i++) { |
|
124 | 124 | $this->addInstance($i); |
125 | 125 | } |
126 | 126 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * The fields in the template must register their scripts |
132 | 132 | * @param null $view |
133 | 133 | */ |
134 | - public function registerScripts($view=null, $mount=true) |
|
134 | + public function registerScripts($view = null, $mount = true) |
|
135 | 135 | { |
136 | 136 | $view = ($view === null) ? $this->getView() : $view; |
137 | 137 | foreach ($this->getTemplate()->getFields() as $field) |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | * Get fields - also add additional instances as appropriate |
210 | 210 | * @inheritdoc |
211 | 211 | */ |
212 | - public function getFields($names=null) |
|
212 | + public function getFields($names = null) |
|
213 | 213 | { |
214 | 214 | $subFormCount = count(parent::getSubForms()); |
215 | 215 | if ($subFormCount < $this->count) { |
216 | - for ($i = $subFormCount; $i <= $this->count-1; $i++) { |
|
216 | + for ($i = $subFormCount; $i <= $this->count - 1; $i++) { |
|
217 | 217 | $this->addInstance(Hash::uuid64()); |
218 | 218 | } |
219 | 219 | } |
@@ -60,8 +60,9 @@ discard block |
||
60 | 60 | public function loadFromDb($data) |
61 | 61 | { |
62 | 62 | foreach ($data as $name => $value) { |
63 | - if (!$this->hasField($name)) |
|
64 | - $this->addInstance($name); |
|
63 | + if (!$this->hasField($name)) { |
|
64 | + $this->addInstance($name); |
|
65 | + } |
|
65 | 66 | $this->getField($name)->setValueFromDb($value); |
66 | 67 | } |
67 | 68 | } |
@@ -102,8 +103,9 @@ discard block |
||
102 | 103 | { |
103 | 104 | // throw an exception - should probably cope with this scenario but set |
104 | 105 | // a validation to fail rather than throwing toys out of the pram |
105 | - if (!is_array($value)) |
|
106 | - throw new \InvalidArgumentException('The value should be an array'); |
|
106 | + if (!is_array($value)) { |
|
107 | + throw new \InvalidArgumentException('The value should be an array'); |
|
108 | + } |
|
107 | 109 | |
108 | 110 | foreach($value as $position => $values) { |
109 | 111 | if (!$this->hasField($position)) { |
@@ -134,8 +136,9 @@ discard block |
||
134 | 136 | public function registerScripts($view=null, $mount=true) |
135 | 137 | { |
136 | 138 | $view = ($view === null) ? $this->getView() : $view; |
137 | - foreach ($this->getTemplate()->getFields() as $field) |
|
138 | - $field->registerScripts($view, $mount); |
|
139 | + foreach ($this->getTemplate()->getFields() as $field) { |
|
140 | + $field->registerScripts($view, $mount); |
|
141 | + } |
|
139 | 142 | } |
140 | 143 | |
141 | 144 | /** |
@@ -240,16 +243,18 @@ discard block |
||
240 | 243 | { |
241 | 244 | // the root path bit can be the the name or the id. |
242 | 245 | $bits = explode('.', $path); |
243 | - if (!($bits[0] === $this->name)) |
|
244 | - throw new \Exception("The first part of the path should be the current repeater name. Repeater form name=$this->name, id=$this->id, path=$path."); |
|
246 | + if (!($bits[0] === $this->name)) { |
|
247 | + throw new \Exception("The first part of the path should be the current repeater name. Repeater form name=$this->name, id=$this->id, path=$path."); |
|
248 | + } |
|
245 | 249 | |
246 | 250 | // if the repeater has an existing instance - then lets return that |
247 | 251 | if ($this->hasField($bits[1])) { |
248 | 252 | $field = $this->getField($bits[1]); |
249 | 253 | // fields within repeaters should always be forms - so this should never happen |
250 | 254 | // but just to ensure we trap the error - lets throw an exception |
251 | - if (!$field->isForm()) |
|
252 | - throw new \InvalidArgumentException('FormRepeaters should only contain form instances.'); |
|
255 | + if (!$field->isForm()) { |
|
256 | + throw new \InvalidArgumentException('FormRepeaters should only contain form instances.'); |
|
257 | + } |
|
253 | 258 | array_splice($bits, 0, 1); |
254 | 259 | return $field->getFieldByPath(implode('.', $bits)); |
255 | 260 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $block = ['neonPlugin']; |
73 | 73 | |
74 | 74 | $block['plugin'] = $this->_getPluginNameFromLines($lines, $current); |
75 | - $block['attributes'] = $this->_getPluginAttributesFromLines($lines, $current); |
|
75 | + $block['attributes'] = $this->_getPluginAttributesFromLines($lines, $current); |
|
76 | 76 | $block['content'] = $this->_getPluginContentFromLines($lines, $current, $endLine); |
77 | 77 | |
78 | 78 | return [$block, $endLine]; |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | protected function renderNeonPlugin($block) |
82 | 82 | { |
83 | 83 | $plugin = $block['plugin']; |
84 | - $content = implode("\n",$block['content']); |
|
84 | + $content = implode("\n", $block['content']); |
|
85 | 85 | $attributes = $block['attributes']; |
86 | 86 | if (class_exists($plugin)) |
87 | 87 | return $plugin::widget(array_merge($attributes, ['content' => $content])); |
88 | - return '<div class="alert alert-danger">unknown plugin: "' . $plugin . '"</div>'; |
|
88 | + return '<div class="alert alert-danger">unknown plugin: "'.$plugin.'"</div>'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | protected function _getPluginAttributesFromLines($lines, $current) |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | } |
106 | 106 | // remove tag and open delimiter from first and last lines |
107 | 107 | $plugin = $this->_getPluginNameFromLines($lines, $current); |
108 | - $lastLine = \count($content)-1; |
|
108 | + $lastLine = \count($content) - 1; |
|
109 | 109 | $content[0] = Str::replaceFirst($openDelimiter, '', $content[0]); |
110 | 110 | $content[0] = Str::replaceFirst($plugin, '', $content[0]); |
111 | 111 | $content[$lastLine] = Str::replaceLast($closeDelimiter, '', $content[$lastLine]); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // xml part |
115 | 115 | $xml = simplexml_load_string("<attr $attrs></attr>"); |
116 | 116 | $attributes = []; |
117 | - foreach($xml[0]->attributes() as $a => $b) { |
|
117 | + foreach ($xml[0]->attributes() as $a => $b) { |
|
118 | 118 | $attributes[$a] = (string) $b; |
119 | 119 | } |
120 | 120 | return $attributes; |
@@ -83,8 +83,9 @@ discard block |
||
83 | 83 | $plugin = $block['plugin']; |
84 | 84 | $content = implode("\n",$block['content']); |
85 | 85 | $attributes = $block['attributes']; |
86 | - if (class_exists($plugin)) |
|
87 | - return $plugin::widget(array_merge($attributes, ['content' => $content])); |
|
86 | + if (class_exists($plugin)) { |
|
87 | + return $plugin::widget(array_merge($attributes, ['content' => $content])); |
|
88 | + } |
|
88 | 89 | return '<div class="alert alert-danger">unknown plugin: "' . $plugin . '"</div>'; |
89 | 90 | } |
90 | 91 | |
@@ -151,8 +152,9 @@ discard block |
||
151 | 152 | for ($i = $current + 1, $count = count($lines); $i < $count; $i++) { |
152 | 153 | $line = $lines[$i]; |
153 | 154 | // stop consuming lines if we find the closing tag |
154 | - if (strpos($line, $closingTag) !== false) |
|
155 | - break; |
|
155 | + if (strpos($line, $closingTag) !== false) { |
|
156 | + break; |
|
157 | + } |
|
156 | 158 | $content[] = $line; |
157 | 159 | } |
158 | 160 | return $content; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | trigger_error("path: missing 'route' parameter"); |
73 | 73 | } |
74 | 74 | |
75 | - array_unshift($params, $params['route']) ; |
|
75 | + array_unshift($params, $params['route']); |
|
76 | 76 | unset($params['route']); |
77 | 77 | |
78 | 78 | return Url::to($params); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | if ($type === 'block') { |
120 | 120 | // Register widget tag during compile time |
121 | 121 | $this->viewRenderer->widgets['blocks'][$alias] = $class; |
122 | - $this->smarty->registerPlugin('block', $alias, [$this->viewRenderer, '_widget_block__' . $alias]); |
|
122 | + $this->smarty->registerPlugin('block', $alias, [$this->viewRenderer, '_widget_block__'.$alias]); |
|
123 | 123 | |
124 | 124 | // Inject code to re-register widget tag during run-time |
125 | 125 | return <<<PHP |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } elseif ($type === 'function') { |
138 | 138 | // Register widget tag during compile time |
139 | 139 | $this->viewRenderer->widgets['functions'][$alias] = $class; |
140 | - $this->smarty->registerPlugin('function', $alias, [$this->viewRenderer, '_widget_function__' . $alias]); |
|
140 | + $this->smarty->registerPlugin('function', $alias, [$this->viewRenderer, '_widget_function__'.$alias]); |
|
141 | 141 | |
142 | 142 | // Inject code to re-register widget tag during run-time |
143 | 143 | return <<<PHP |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | */ |
284 | 284 | protected function getViewConstVal($string, $default) |
285 | 285 | { |
286 | - $val = @constant('yii\web\View::' . $string); |
|
286 | + $val = @constant('yii\web\View::'.$string); |
|
287 | 287 | return isset($val) ? $val : $default; |
288 | 288 | } |
289 | 289 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $params['content'] = $content; |
148 | 148 | if (class_exists($class)) { |
149 | 149 | $widget = new $class(); |
150 | - foreach($params as $key => $val) { |
|
150 | + foreach ($params as $key => $val) { |
|
151 | 151 | if ($widget->hasProperty($key)) |
152 | 152 | $widget->$key = $val; |
153 | 153 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $type = Arr::getRequired($params, 'type'); |
178 | 178 | $options = Arr::get($params, 'options', []); |
179 | 179 | if (!is_array($options)) |
180 | - throw new \InvalidArgumentException('"options" property must be an array "' . gettype($options) . '" given'); |
|
180 | + throw new \InvalidArgumentException('"options" property must be an array "'.gettype($options).'" given'); |
|
181 | 181 | $default = Arr::get($params, 'default', ''); |
182 | 182 | |
183 | 183 | $value = neon()->view->styleManager->add($name, $default, $type, $options); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | if (!isset($params['route'])) { |
215 | 215 | trigger_error("path: missing 'route' parameter"); |
216 | 216 | } |
217 | - array_unshift($params, $params['route']) ; |
|
217 | + array_unshift($params, $params['route']); |
|
218 | 218 | unset($params['route']); |
219 | 219 | return Url::toRoute($params, true); |
220 | 220 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function csrf_element($params) |
234 | 234 | { |
235 | - return '<input type="hidden" name="'.neon()->request->csrfParam.'" value="' . neon()->request->getCsrfToken() . '" />'; |
|
235 | + return '<input type="hidden" name="'.neon()->request->csrfParam.'" value="'.neon()->request->getCsrfToken().'" />'; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -328,39 +328,39 @@ discard block |
||
328 | 328 | $params['widths'] = self::IMG_SRCSET_DEFAULT_WIDTHS; |
329 | 329 | } |
330 | 330 | |
331 | - $id = Arr::pull($params,'firefly_id'); |
|
332 | - $widths = array_map('trim',explode(',',Arr::pull($params,'widths'))); |
|
331 | + $id = Arr::pull($params, 'firefly_id'); |
|
332 | + $widths = array_map('trim', explode(',', Arr::pull($params, 'widths'))); |
|
333 | 333 | $srcsetParts = []; |
334 | 334 | $srcSizeParts = []; |
335 | 335 | $useResolutions = []; |
336 | 336 | $minBreak = false; |
337 | 337 | if (isset($params['min-break'])) { |
338 | - $minBreak = Arr::pull($params,'min-break'); |
|
339 | - if (!Str::validateNumericWithUnits($minBreak,['px','vw'])) { |
|
338 | + $minBreak = Arr::pull($params, 'min-break'); |
|
339 | + if (!Str::validateNumericWithUnits($minBreak, ['px', 'vw'])) { |
|
340 | 340 | throw new \InvalidArgumentException("The min-break value '".$minBreak."' should be numeric and end with 'px' or 'vw'"); |
341 | 341 | } |
342 | 342 | } |
343 | 343 | if (isset($params['breaks'])) { |
344 | 344 | // optionally validate & collate the breaks for the 'sizes' attribute |
345 | - $breaks = array_map('trim',explode(',',Arr::pull($params,'breaks'))); |
|
345 | + $breaks = array_map('trim', explode(',', Arr::pull($params, 'breaks'))); |
|
346 | 346 | foreach ($breaks as $idx=>$break) { |
347 | - if (!Str::validateNumericWithUnits($break, ['px','vw'])) { |
|
347 | + if (!Str::validateNumericWithUnits($break, ['px', 'vw'])) { |
|
348 | 348 | throw new \InvalidArgumentException("The break value '".$break."' should be numeric and end with 'px' or 'vw'"); |
349 | 349 | } |
350 | - if ($idx==0 && $minBreak) { |
|
350 | + if ($idx == 0 && $minBreak) { |
|
351 | 351 | $break = "(min-width: ".$minBreak.") ".$break; |
352 | 352 | } |
353 | - $srcSizeParts[]=$break; |
|
353 | + $srcSizeParts[] = $break; |
|
354 | 354 | } |
355 | 355 | } |
356 | 356 | elseif (isset($params['resolutions'])) { |
357 | 357 | // optionally validate & collate any specified resolutions to use (if breaks haven't been specified) |
358 | - $useResolutions = array_map('trim',explode(',',Arr::pull($params,'resolutions'))); |
|
359 | - if (count($useResolutions) != count($widths)-1) { |
|
360 | - throw new \InvalidArgumentException("Since there are ".count($widths)." widths you should specify ".(count($widths)-1)." resolutions to apply"); |
|
358 | + $useResolutions = array_map('trim', explode(',', Arr::pull($params, 'resolutions'))); |
|
359 | + if (count($useResolutions) != count($widths) - 1) { |
|
360 | + throw new \InvalidArgumentException("Since there are ".count($widths)." widths you should specify ".(count($widths) - 1)." resolutions to apply"); |
|
361 | 361 | } |
362 | 362 | foreach ($useResolutions as $useResolution) { |
363 | - if (!Str::validateNumericWithUnits($useResolution,['x'])) { |
|
363 | + if (!Str::validateNumericWithUnits($useResolution, ['x'])) { |
|
364 | 364 | throw new \InvalidArgumentException("The resolution '".$useResolution."' is not a valid resolution, it should be numeric and then end with an 'x'"); |
365 | 365 | } |
366 | 366 | } |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | else { |
369 | 369 | // if neither 'breaks' or 'resolutions' was specified then use the widths |
370 | 370 | foreach ($widths as $idx=>$width) { |
371 | - if ($idx==0 && $minBreak) { |
|
371 | + if ($idx == 0 && $minBreak) { |
|
372 | 372 | $width = "(min-width: ".$minBreak.") ".$width; |
373 | 373 | } |
374 | 374 | $srcSizeParts[] = $width."px"; |
@@ -387,31 +387,31 @@ discard block |
||
387 | 387 | if (!is_numeric($width)) { |
388 | 388 | throw new \InvalidArgumentException("One of the widths specified was not numeric '".$width."'"); |
389 | 389 | } |
390 | - $useParams = ['id'=>$id, 'w'=>(int)$width]; |
|
390 | + $useParams = ['id'=>$id, 'w'=>(int) $width]; |
|
391 | 391 | if ($useQuality) { |
392 | 392 | $useParams['q'] = $useQuality; |
393 | 393 | } |
394 | 394 | $imageUrl = $this->firefly_image($useParams); |
395 | 395 | if ($useResolutions) { |
396 | - $srcsetParts[] = $imageUrl.( ($idx>=1) ? ' '.$useResolutions[$idx-1] : '' ); |
|
396 | + $srcsetParts[] = $imageUrl.(($idx >= 1) ? ' '.$useResolutions[$idx - 1] : ''); |
|
397 | 397 | } |
398 | 398 | else { |
399 | - $srcsetParts[] = $imageUrl . ' ' . $width . 'w'; |
|
399 | + $srcsetParts[] = $imageUrl.' '.$width.'w'; |
|
400 | 400 | } |
401 | - if ($idx==0 && !isset($params['src-width']) && !isset($params['src'])) { |
|
401 | + if ($idx == 0 && !isset($params['src-width']) && !isset($params['src'])) { |
|
402 | 402 | $params['src'] = $imageUrl; |
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
406 | 406 | // collate the tag attributes |
407 | 407 | if (isset($params['src-width'])) { |
408 | - $srcWidth = Arr::pull($params,'src-width'); |
|
408 | + $srcWidth = Arr::pull($params, 'src-width'); |
|
409 | 409 | if (!is_numeric($srcWidth)) { |
410 | 410 | throw new \InvalidArgumentException("src-width '".$srcWidth."' must be numeric"); |
411 | 411 | } |
412 | - $useParams = ['id'=>$id, 'w'=>(int)$srcWidth]; |
|
412 | + $useParams = ['id'=>$id, 'w'=>(int) $srcWidth]; |
|
413 | 413 | if (isset($params['quality'])) { |
414 | - $useParams = (int)$params['quality']; |
|
414 | + $useParams = (int) $params['quality']; |
|
415 | 415 | } |
416 | 416 | if (!isset($params['src'])) { |
417 | 417 | $params['src'] = $this->firefly_image($useParams); |
@@ -425,12 +425,12 @@ discard block |
||
425 | 425 | } |
426 | 426 | |
427 | 427 | // finally generate the tag ... note that these can overwrite the previously generated params |
428 | - $tagAttributes = []; |
|
428 | + $tagAttributes = []; |
|
429 | 429 | foreach ($params as $key=>$value) { |
430 | 430 | $tagAttributes[] = $key."='".htmlspecialchars($value)."'"; |
431 | 431 | } |
432 | 432 | |
433 | - return "<img ".implode(' ',$tagAttributes).">"; |
|
433 | + return "<img ".implode(' ', $tagAttributes).">"; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | else |
462 | 462 | return $value; |
463 | 463 | } else { |
464 | - return "Usage: you must provide an 'app' and a 'name' parameter. You provided ".print_r($params,true); |
|
464 | + return "Usage: you must provide an 'app' and a 'name' parameter. You provided ".print_r($params, true); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | { |
484 | 484 | $format = 'Y-m-d H:i:s'; |
485 | 485 | if (isset($params['stamp'])) |
486 | - return date($format, (integer)$params['stamp']); |
|
486 | + return date($format, (integer) $params['stamp']); |
|
487 | 487 | return date($format); |
488 | 488 | } |
489 | 489 | |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | */ |
496 | 496 | public function json($params) |
497 | 497 | { |
498 | - return '<pre>' . json_encode($params, JSON_PRETTY_PRINT) . '</pre>'; |
|
498 | + return '<pre>'.json_encode($params, JSON_PRETTY_PRINT).'</pre>'; |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @return int |
511 | 511 | * @throws \Exception |
512 | 512 | */ |
513 | - public function getAssetPosition($params, $default='end') |
|
513 | + public function getAssetPosition($params, $default = 'end') |
|
514 | 514 | { |
515 | 515 | $position = Arr::get($params, 'pos', Arr::get($params, 'position', $default)); |
516 | 516 | $positions = [ |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | 'load' => View::POS_LOAD, |
522 | 522 | ]; |
523 | 523 | if (!array_key_exists($position, $positions)) { |
524 | - throw new \Exception('The javascript position specified must be one of ' . print_r(array_keys($positions)) . ', you specified "'.$position.'"'); |
|
524 | + throw new \Exception('The javascript position specified must be one of '.print_r(array_keys($positions)).', you specified "'.$position.'"'); |
|
525 | 525 | } |
526 | 526 | return $positions[$position]; |
527 | 527 | } |
@@ -148,8 +148,9 @@ discard block |
||
148 | 148 | if (class_exists($class)) { |
149 | 149 | $widget = new $class(); |
150 | 150 | foreach($params as $key => $val) { |
151 | - if ($widget->hasProperty($key)) |
|
152 | - $widget->$key = $val; |
|
151 | + if ($widget->hasProperty($key)) { |
|
152 | + $widget->$key = $val; |
|
153 | + } |
|
153 | 154 | } |
154 | 155 | return $widget->run(); |
155 | 156 | } else { |
@@ -176,8 +177,9 @@ discard block |
||
176 | 177 | $name = Arr::getRequired($params, 'name'); |
177 | 178 | $type = Arr::getRequired($params, 'type'); |
178 | 179 | $options = Arr::get($params, 'options', []); |
179 | - if (!is_array($options)) |
|
180 | - throw new \InvalidArgumentException('"options" property must be an array "' . gettype($options) . '" given'); |
|
180 | + if (!is_array($options)) { |
|
181 | + throw new \InvalidArgumentException('"options" property must be an array "' . gettype($options) . '" given'); |
|
182 | + } |
|
181 | 183 | $default = Arr::get($params, 'default', ''); |
182 | 184 | |
183 | 185 | $value = neon()->view->styleManager->add($name, $default, $type, $options); |
@@ -259,8 +261,9 @@ discard block |
||
259 | 261 | */ |
260 | 262 | public function firefly_url($params) |
261 | 263 | { |
262 | - if (isset($params['id'])) |
|
263 | - return neon()->firefly->getUrl($params['id']); |
|
264 | + if (isset($params['id'])) { |
|
265 | + return neon()->firefly->getUrl($params['id']); |
|
266 | + } |
|
264 | 267 | } |
265 | 268 | |
266 | 269 | /** |
@@ -285,8 +288,9 @@ discard block |
||
285 | 288 | */ |
286 | 289 | public function firefly_image($params) |
287 | 290 | { |
288 | - if (isset($params['id'])) |
|
289 | - return neon()->firefly->getImage(Arr::pull($params, 'id'), $params); |
|
291 | + if (isset($params['id'])) { |
|
292 | + return neon()->firefly->getImage(Arr::pull($params, 'id'), $params); |
|
293 | + } |
|
290 | 294 | } |
291 | 295 | |
292 | 296 | /** |
@@ -352,8 +356,7 @@ discard block |
||
352 | 356 | } |
353 | 357 | $srcSizeParts[]=$break; |
354 | 358 | } |
355 | - } |
|
356 | - elseif (isset($params['resolutions'])) { |
|
359 | + } elseif (isset($params['resolutions'])) { |
|
357 | 360 | // optionally validate & collate any specified resolutions to use (if breaks haven't been specified) |
358 | 361 | $useResolutions = array_map('trim',explode(',',Arr::pull($params,'resolutions'))); |
359 | 362 | if (count($useResolutions) != count($widths)-1) { |
@@ -364,8 +367,7 @@ discard block |
||
364 | 367 | throw new \InvalidArgumentException("The resolution '".$useResolution."' is not a valid resolution, it should be numeric and then end with an 'x'"); |
365 | 368 | } |
366 | 369 | } |
367 | - } |
|
368 | - else { |
|
370 | + } else { |
|
369 | 371 | // if neither 'breaks' or 'resolutions' was specified then use the widths |
370 | 372 | foreach ($widths as $idx=>$width) { |
371 | 373 | if ($idx==0 && $minBreak) { |
@@ -394,8 +396,7 @@ discard block |
||
394 | 396 | $imageUrl = $this->firefly_image($useParams); |
395 | 397 | if ($useResolutions) { |
396 | 398 | $srcsetParts[] = $imageUrl.( ($idx>=1) ? ' '.$useResolutions[$idx-1] : '' ); |
397 | - } |
|
398 | - else { |
|
399 | + } else { |
|
399 | 400 | $srcsetParts[] = $imageUrl . ' ' . $width . 'w'; |
400 | 401 | } |
401 | 402 | if ($idx==0 && !isset($params['src-width']) && !isset($params['src'])) { |
@@ -456,10 +457,11 @@ discard block |
||
456 | 457 | $assign = isset($params['assign']) ? $params['assign'] : null; |
457 | 458 | if ($app && $name) { |
458 | 459 | $value = neon('settings')->manager->get($app, $name, $default); |
459 | - if ($assign) |
|
460 | - $smarty->assign($assign, $value); |
|
461 | - else |
|
462 | - return $value; |
|
460 | + if ($assign) { |
|
461 | + $smarty->assign($assign, $value); |
|
462 | + } else { |
|
463 | + return $value; |
|
464 | + } |
|
463 | 465 | } else { |
464 | 466 | return "Usage: you must provide an 'app' and a 'name' parameter. You provided ".print_r($params,true); |
465 | 467 | } |
@@ -482,8 +484,9 @@ discard block |
||
482 | 484 | public function time($params) |
483 | 485 | { |
484 | 486 | $format = 'Y-m-d H:i:s'; |
485 | - if (isset($params['stamp'])) |
|
486 | - return date($format, (integer)$params['stamp']); |
|
487 | + if (isset($params['stamp'])) { |
|
488 | + return date($format, (integer)$params['stamp']); |
|
489 | + } |
|
487 | 490 | return date($format); |
488 | 491 | } |
489 | 492 | |
@@ -555,7 +558,9 @@ discard block |
||
555 | 558 | */ |
556 | 559 | public function js($params, $content) |
557 | 560 | { |
558 | - if ($content == null) return; |
|
561 | + if ($content == null) { |
|
562 | + return; |
|
563 | + } |
|
559 | 564 | $key = Arr::get($params, 'key', null); |
560 | 565 | $content = str_replace(['<script>', '</script>'], '', $content); |
561 | 566 | neon()->view->registerJs($content, $this->getAssetPosition($params), $key); |
@@ -578,7 +583,9 @@ discard block |
||
578 | 583 | */ |
579 | 584 | public function css($params, $content) |
580 | 585 | { |
581 | - if ($content == null) return; |
|
586 | + if ($content == null) { |
|
587 | + return; |
|
588 | + } |
|
582 | 589 | $key = Arr::get($params, 'key', null); |
583 | 590 | $content = str_replace(['<style>', '</style>'], '', $content); |
584 | 591 | neon()->view->registerCss($content, ['position'=>$this->getAssetPosition($params, 'head')], $key); |
@@ -605,7 +612,9 @@ discard block |
||
605 | 612 | { |
606 | 613 | // get the bundle - will look for `name` or `bundle` or `path` keys |
607 | 614 | $class = Arr::get($params, 'name', Arr::get($params, 'path', null)); |
608 | - if ($class == null) return; |
|
615 | + if ($class == null) { |
|
616 | + return; |
|
617 | + } |
|
609 | 618 | |
610 | 619 | // get the position - will looks for `pos` or `position` keys - defaults View::POS_END |
611 | 620 | $position = Arr::get($params, 'pos', Arr::get($params, 'position', 'end')); |
@@ -703,8 +712,9 @@ discard block |
||
703 | 712 | */ |
704 | 713 | public function hasPermission($params, $smarty) |
705 | 714 | { |
706 | - if (empty($params['permission'])) |
|
707 | - trigger_error("permission: missing 'permission' parameter"); |
|
715 | + if (empty($params['permission'])) { |
|
716 | + trigger_error("permission: missing 'permission' parameter"); |
|
717 | + } |
|
708 | 718 | $permission = $params['permission']; |
709 | 719 | $assign = empty($params['assign']) ? $permission : $params['assign']; |
710 | 720 | $canDo = neon()->user->can($permission, $params); |
@@ -7,7 +7,7 @@ |
||
7 | 7 | */ |
8 | 8 | class JQueryUiAsset extends AssetBundle |
9 | 9 | { |
10 | - public $sourcePath = __DIR__ . '/publish/vendor/jqueryui'; |
|
10 | + public $sourcePath = __DIR__.'/publish/vendor/jqueryui'; |
|
11 | 11 | |
12 | 12 | public $js = [ |
13 | 13 | 'jquery-ui.min.js' |
@@ -17,7 +17,7 @@ |
||
17 | 17 | */ |
18 | 18 | class CoreAsset extends AssetBundle |
19 | 19 | { |
20 | - public $sourcePath = __DIR__ . '/publish'; |
|
20 | + public $sourcePath = __DIR__.'/publish'; |
|
21 | 21 | |
22 | 22 | public $js = [ |
23 | 23 | (YII_DEBUG ? 'vendor/vue.js' : 'vendor/vue.min.js'), |
@@ -553,9 +553,9 @@ discard block |
||
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
556 | - * The install specific to the core apps (admin, user, settings, etc) |
|
557 | - * @return void |
|
558 | - */ |
|
556 | + * The install specific to the core apps (admin, user, settings, etc) |
|
557 | + * @return void |
|
558 | + */ |
|
559 | 559 | public function installCore() |
560 | 560 | { |
561 | 561 | foreach ($this->getCoreApps() as $appName => $config) { |
@@ -565,9 +565,9 @@ discard block |
||
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
568 | - * Run the install function of each app |
|
569 | - * @return void |
|
570 | - */ |
|
568 | + * Run the install function of each app |
|
569 | + * @return void |
|
570 | + */ |
|
571 | 571 | public function installApps() |
572 | 572 | { |
573 | 573 | foreach ($this->getApps() as $appName => $config) { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function getApps() |
207 | 207 | { |
208 | - if ($this->_appsRequiredOrder==false) { |
|
208 | + if ($this->_appsRequiredOrder == false) { |
|
209 | 209 | $this->orderAppsByRequired($this->_apps, $ordered); |
210 | 210 | $this->setApps($ordered); |
211 | 211 | $this->_appsRequiredOrder = true; |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | */ |
241 | 241 | public function getCoreApps() |
242 | 242 | { |
243 | - if ($this->_coreAppsRequiredOrder==false) { |
|
243 | + if ($this->_coreAppsRequiredOrder == false) { |
|
244 | 244 | $this->orderAppsByRequired($this->_coreApps, $ordered); |
245 | 245 | $this->setCoreApps($ordered); |
246 | 246 | $this->_coreAppsRequiredOrder = true; |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | * |
278 | 278 | * @return array |
279 | 279 | */ |
280 | - public static function getConfig($path, $required=true) |
|
280 | + public static function getConfig($path, $required = true) |
|
281 | 281 | { |
282 | 282 | $file = Neon::getAlias($path); |
283 | 283 | $fileExists = file_exists($file); |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | throw new \Exception('The config file alias: "'.$path.'" can not be found. File path: "'.$file.'". This config file is required.'); |
289 | 289 | } |
290 | 290 | // The file does NOT exist and it is NOT required |
291 | - if (!$fileExists && !$required){ |
|
291 | + if (!$fileExists && !$required) { |
|
292 | 292 | // the config is not required so we can just return an empty array |
293 | 293 | return []; |
294 | 294 | } |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function registerApps($apps) |
352 | 352 | { |
353 | - foreach($apps as $name => $config) { |
|
353 | + foreach ($apps as $name => $config) { |
|
354 | 354 | $this->registerApp($name, $config); |
355 | 355 | } |
356 | 356 | } |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | { |
466 | 466 | $apps = array_merge($this->getCoreApps(), $this->getApps()); |
467 | 467 | $ret = []; |
468 | - foreach($apps as $app => $config) { |
|
468 | + foreach ($apps as $app => $config) { |
|
469 | 469 | $appObject = $this->getApp($app); |
470 | 470 | // apps that are disabled will return null |
471 | 471 | if ($appObject !== null) |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | */ |
527 | 527 | public function getClassAlias() |
528 | 528 | { |
529 | - return '@' . str_replace(['\\', 'Application'], ['/', ''], get_called_class()); |
|
529 | + return '@'.str_replace(['\\', 'Application'], ['/', ''], get_called_class()); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | $client = new \GuzzleHttp\Client(); |
624 | 624 | $res = $client->request('GET', 'https://neon.newicon.net/api/versions/', ['connect_timeout' => 2]); |
625 | 625 | $versions = json_decode((string) $res->getBody()); |
626 | - } catch(\Exception $e) { |
|
626 | + } catch (\Exception $e) { |
|
627 | 627 | $versions = []; |
628 | 628 | } |
629 | 629 | return $versions; |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | $versions = $this->getNeonVersions(); |
641 | 641 | $newerVersion = []; |
642 | 642 | $neonVersion = neon()->getVersion(); |
643 | - foreach($versions as $v) { |
|
643 | + foreach ($versions as $v) { |
|
644 | 644 | if (version_compare($v, $neonVersion, '>')) { |
645 | 645 | $newerVersion[] = $v; |
646 | 646 | } |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | */ |
678 | 678 | private function setModuleAliases($name, $aliases) |
679 | 679 | { |
680 | - foreach($aliases as $alias) |
|
680 | + foreach ($aliases as $alias) |
|
681 | 681 | static::$_moduleAliases[$alias] = $name; |
682 | 682 | } |
683 | 683 |
@@ -413,8 +413,9 @@ discard block |
||
413 | 413 | $this->setModule($name, $config); |
414 | 414 | |
415 | 415 | // set up any alternatives for this |
416 | - if (isset($config['appAliases'])) |
|
417 | - $this->setModuleAliases($name, $config['appAliases']); |
|
416 | + if (isset($config['appAliases'])) { |
|
417 | + $this->setModuleAliases($name, $config['appAliases']); |
|
418 | + } |
|
418 | 419 | } |
419 | 420 | |
420 | 421 | /** |
@@ -468,8 +469,9 @@ discard block |
||
468 | 469 | foreach($apps as $app => $config) { |
469 | 470 | $appObject = $this->getApp($app); |
470 | 471 | // apps that are disabled will return null |
471 | - if ($appObject !== null) |
|
472 | - $ret[$app] = $this->getApp($app); |
|
472 | + if ($appObject !== null) { |
|
473 | + $ret[$app] = $this->getApp($app); |
|
474 | + } |
|
473 | 475 | } |
474 | 476 | return $ret; |
475 | 477 | } |
@@ -485,8 +487,9 @@ discard block |
||
485 | 487 | public function orderAppsByRequired($apps, &$ordered = null, &$read = null) |
486 | 488 | { |
487 | 489 | static $initialApps = null; |
488 | - if ($ordered == null) |
|
489 | - $initialApps = $apps; |
|
490 | + if ($ordered == null) { |
|
491 | + $initialApps = $apps; |
|
492 | + } |
|
490 | 493 | $ordered = $ordered == null ? [] : $ordered; |
491 | 494 | $read = $read == null ? [] : $read; |
492 | 495 | foreach ($apps as $key=>$app) { |
@@ -497,15 +500,17 @@ discard block |
||
497 | 500 | foreach ($requires as $r) { |
498 | 501 | $r = trim($r); |
499 | 502 | // prevent circular references breaking the system |
500 | - if (!array_key_exists($r, $read)) |
|
501 | - $required[$r] = $initialApps[$r]; |
|
503 | + if (!array_key_exists($r, $read)) { |
|
504 | + $required[$r] = $initialApps[$r]; |
|
505 | + } |
|
502 | 506 | } |
503 | 507 | if (count($required)) { |
504 | 508 | $this->orderAppsByRequired($required, $ordered, $read); |
505 | 509 | } |
506 | 510 | } |
507 | - if (!array_key_exists($key, $ordered)) |
|
508 | - $ordered[$key] = $app; |
|
511 | + if (!array_key_exists($key, $ordered)) { |
|
512 | + $ordered[$key] = $app; |
|
513 | + } |
|
509 | 514 | } |
510 | 515 | } |
511 | 516 | |
@@ -677,8 +682,9 @@ discard block |
||
677 | 682 | */ |
678 | 683 | private function setModuleAliases($name, $aliases) |
679 | 684 | { |
680 | - foreach($aliases as $alias) |
|
681 | - static::$_moduleAliases[$alias] = $name; |
|
685 | + foreach($aliases as $alias) { |
|
686 | + static::$_moduleAliases[$alias] = $name; |
|
687 | + } |
|
682 | 688 | } |
683 | 689 | |
684 | 690 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | protected function hash($path) |
28 | 28 | { |
29 | - if (isset($this->publishOptions['path'])){ |
|
29 | + if (isset($this->publishOptions['path'])) { |
|
30 | 30 | // if a path is specified then use this instead of a hash |
31 | 31 | return $this->publishOptions['path']; |
32 | 32 | } |