@@ -154,8 +154,9 @@ discard block |
||
154 | 154 | self::processTags($allowableTags, $tagsProcessed); |
155 | 155 | } |
156 | 156 | if (is_array($value)) { |
157 | - foreach ($value as $k => $v) |
|
158 | - $value[$k] = static::sanitise($v, $allowableTags); |
|
157 | + foreach ($value as $k => $v) { |
|
158 | + $value[$k] = static::sanitise($v, $allowableTags); |
|
159 | + } |
|
159 | 160 | } else { |
160 | 161 | if (!is_null($value)) { |
161 | 162 | if (isset($tagsProcessed[$allowableTags])) { |
@@ -189,14 +190,16 @@ discard block |
||
189 | 190 | { |
190 | 191 | profile_begin('Html::purify', 'html'); |
191 | 192 | if (is_array($value)) { |
192 | - foreach ($value as $k => $v) |
|
193 | - $value[$k] = static::purify($v, $allowedTags); |
|
193 | + foreach ($value as $k => $v) { |
|
194 | + $value[$k] = static::purify($v, $allowedTags); |
|
195 | + } |
|
194 | 196 | } else { |
195 | 197 | if (!is_null($value)) { |
196 | - if ($allowedTags === false) |
|
197 | - $value = trim(HtmlPurifier::process($value)); |
|
198 | - else |
|
199 | - $value = trim(HtmlPurifier::process(strip_tags($value, $allowedTags))); |
|
198 | + if ($allowedTags === false) { |
|
199 | + $value = trim(HtmlPurifier::process($value)); |
|
200 | + } else { |
|
201 | + $value = trim(HtmlPurifier::process(strip_tags($value, $allowedTags))); |
|
202 | + } |
|
200 | 203 | } |
201 | 204 | } |
202 | 205 | profile_end('Html::purify', 'html'); |
@@ -214,8 +217,9 @@ discard block |
||
214 | 217 | public static function encodeEntities($value, $entities = ENT_QUOTES) |
215 | 218 | { |
216 | 219 | if (is_array($value)) { |
217 | - foreach ($value as $k => $v) |
|
218 | - $value[$k] = static::encodeEntities($v, $entities); |
|
220 | + foreach ($value as $k => $v) { |
|
221 | + $value[$k] = static::encodeEntities($v, $entities); |
|
222 | + } |
|
219 | 223 | } else { |
220 | 224 | $value = htmlentities($value, $entities); |
221 | 225 | } |
@@ -251,18 +255,22 @@ discard block |
||
251 | 255 | */ |
252 | 256 | public static function highlight($search, $html, $empty='') |
253 | 257 | { |
254 | - if ($html === null) |
|
255 | - return neon()->formatter->nullDisplay; |
|
256 | - if ($html === '') |
|
257 | - return $empty; |
|
258 | - if (empty($search)) |
|
259 | - return $html; |
|
258 | + if ($html === null) { |
|
259 | + return neon()->formatter->nullDisplay; |
|
260 | + } |
|
261 | + if ($html === '') { |
|
262 | + return $empty; |
|
263 | + } |
|
264 | + if (empty($search)) { |
|
265 | + return $html; |
|
266 | + } |
|
260 | 267 | |
261 | 268 | profile_begin('Html::Highlight'); |
262 | 269 | // escape search and html entities as otherwise the loadHTML or appendXML |
263 | 270 | // can blow up if there are < & > in the data |
264 | - if (!is_array($search)) |
|
265 | - $search = [$search]; |
|
271 | + if (!is_array($search)) { |
|
272 | + $search = [$search]; |
|
273 | + } |
|
266 | 274 | try { |
267 | 275 | foreach ($search as $s) { |
268 | 276 | // now search and rebuild the data |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | $params['content'] = $content; |
149 | 149 | if (class_exists($class)) { |
150 | 150 | $widget = new $class(); |
151 | - foreach($params as $key => $val) { |
|
151 | + foreach ($params as $key => $val) { |
|
152 | 152 | if ($widget->hasProperty($key)) |
153 | 153 | $widget->$key = $val; |
154 | 154 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $type = Arr::getRequired($params, 'type'); |
179 | 179 | $options = Arr::get($params, 'options', []); |
180 | 180 | if (!is_array($options)) |
181 | - throw new \InvalidArgumentException('"options" property must be an array "' . gettype($options) . '" given'); |
|
181 | + throw new \InvalidArgumentException('"options" property must be an array "'.gettype($options).'" given'); |
|
182 | 182 | $default = Arr::get($params, 'default', ''); |
183 | 183 | |
184 | 184 | $value = neon()->view->styleManager->add($name, $default, $type, $options); |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if (!isset($params['route'])) { |
216 | 216 | trigger_error("path: missing 'route' parameter"); |
217 | 217 | } |
218 | - array_unshift($params, $params['route']) ; |
|
218 | + array_unshift($params, $params['route']); |
|
219 | 219 | unset($params['route']); |
220 | 220 | return Url::toRoute($params, true); |
221 | 221 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function csrf_element($params) |
235 | 235 | { |
236 | - return '<input type="hidden" name="'.neon()->request->csrfParam.'" value="' . neon()->request->getCsrfToken() . '" />'; |
|
236 | + return '<input type="hidden" name="'.neon()->request->csrfParam.'" value="'.neon()->request->getCsrfToken().'" />'; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -329,39 +329,39 @@ discard block |
||
329 | 329 | $params['widths'] = self::IMG_SRCSET_DEFAULT_WIDTHS; |
330 | 330 | } |
331 | 331 | |
332 | - $id = Arr::pull($params,'firefly_id'); |
|
333 | - $widths = array_map('trim',explode(',',Arr::pull($params,'widths'))); |
|
332 | + $id = Arr::pull($params, 'firefly_id'); |
|
333 | + $widths = array_map('trim', explode(',', Arr::pull($params, 'widths'))); |
|
334 | 334 | $srcsetParts = []; |
335 | 335 | $srcSizeParts = []; |
336 | 336 | $useResolutions = []; |
337 | 337 | $minBreak = false; |
338 | 338 | if (isset($params['min-break'])) { |
339 | - $minBreak = Arr::pull($params,'min-break'); |
|
340 | - if (!Str::validateNumericWithUnits($minBreak,['px','vw'])) { |
|
339 | + $minBreak = Arr::pull($params, 'min-break'); |
|
340 | + if (!Str::validateNumericWithUnits($minBreak, ['px', 'vw'])) { |
|
341 | 341 | throw new \InvalidArgumentException("The min-break value '".$minBreak."' should be numeric and end with 'px' or 'vw'"); |
342 | 342 | } |
343 | 343 | } |
344 | 344 | if (isset($params['breaks'])) { |
345 | 345 | // optionally validate & collate the breaks for the 'sizes' attribute |
346 | - $breaks = array_map('trim',explode(',',Arr::pull($params,'breaks'))); |
|
346 | + $breaks = array_map('trim', explode(',', Arr::pull($params, 'breaks'))); |
|
347 | 347 | foreach ($breaks as $idx=>$break) { |
348 | - if (!Str::validateNumericWithUnits($break, ['px','vw'])) { |
|
348 | + if (!Str::validateNumericWithUnits($break, ['px', 'vw'])) { |
|
349 | 349 | throw new \InvalidArgumentException("The break value '".$break."' should be numeric and end with 'px' or 'vw'"); |
350 | 350 | } |
351 | - if ($idx==0 && $minBreak) { |
|
351 | + if ($idx == 0 && $minBreak) { |
|
352 | 352 | $break = "(min-width: ".$minBreak.") ".$break; |
353 | 353 | } |
354 | - $srcSizeParts[]=$break; |
|
354 | + $srcSizeParts[] = $break; |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | elseif (isset($params['resolutions'])) { |
358 | 358 | // optionally validate & collate any specified resolutions to use (if breaks haven't been specified) |
359 | - $useResolutions = array_map('trim',explode(',',Arr::pull($params,'resolutions'))); |
|
360 | - if (count($useResolutions) != count($widths)-1) { |
|
361 | - throw new \InvalidArgumentException("Since there are ".count($widths)." widths you should specify ".(count($widths)-1)." resolutions to apply"); |
|
359 | + $useResolutions = array_map('trim', explode(',', Arr::pull($params, 'resolutions'))); |
|
360 | + if (count($useResolutions) != count($widths) - 1) { |
|
361 | + throw new \InvalidArgumentException("Since there are ".count($widths)." widths you should specify ".(count($widths) - 1)." resolutions to apply"); |
|
362 | 362 | } |
363 | 363 | foreach ($useResolutions as $useResolution) { |
364 | - if (!Str::validateNumericWithUnits($useResolution,['x'])) { |
|
364 | + if (!Str::validateNumericWithUnits($useResolution, ['x'])) { |
|
365 | 365 | throw new \InvalidArgumentException("The resolution '".$useResolution."' is not a valid resolution, it should be numeric and then end with an 'x'"); |
366 | 366 | } |
367 | 367 | } |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | else { |
370 | 370 | // if neither 'breaks' or 'resolutions' was specified then use the widths |
371 | 371 | foreach ($widths as $idx=>$width) { |
372 | - if ($idx==0 && $minBreak) { |
|
372 | + if ($idx == 0 && $minBreak) { |
|
373 | 373 | $width = "(min-width: ".$minBreak.") ".$width; |
374 | 374 | } |
375 | 375 | $srcSizeParts[] = $width."px"; |
@@ -388,31 +388,31 @@ discard block |
||
388 | 388 | if (!is_numeric($width)) { |
389 | 389 | throw new \InvalidArgumentException("One of the widths specified was not numeric '".$width."'"); |
390 | 390 | } |
391 | - $useParams = ['id'=>$id, 'w'=>(int)$width]; |
|
391 | + $useParams = ['id'=>$id, 'w'=>(int) $width]; |
|
392 | 392 | if ($useQuality) { |
393 | 393 | $useParams['q'] = $useQuality; |
394 | 394 | } |
395 | 395 | $imageUrl = $this->firefly_image($useParams); |
396 | 396 | if ($useResolutions) { |
397 | - $srcsetParts[] = $imageUrl.( ($idx>=1) ? ' '.$useResolutions[$idx-1] : '' ); |
|
397 | + $srcsetParts[] = $imageUrl.(($idx >= 1) ? ' '.$useResolutions[$idx - 1] : ''); |
|
398 | 398 | } |
399 | 399 | else { |
400 | - $srcsetParts[] = $imageUrl . ' ' . $width . 'w'; |
|
400 | + $srcsetParts[] = $imageUrl.' '.$width.'w'; |
|
401 | 401 | } |
402 | - if ($idx==0 && !isset($params['src-width']) && !isset($params['src'])) { |
|
402 | + if ($idx == 0 && !isset($params['src-width']) && !isset($params['src'])) { |
|
403 | 403 | $params['src'] = $imageUrl; |
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | 407 | // collate the tag attributes |
408 | 408 | if (isset($params['src-width'])) { |
409 | - $srcWidth = Arr::pull($params,'src-width'); |
|
409 | + $srcWidth = Arr::pull($params, 'src-width'); |
|
410 | 410 | if (!is_numeric($srcWidth)) { |
411 | 411 | throw new \InvalidArgumentException("src-width '".$srcWidth."' must be numeric"); |
412 | 412 | } |
413 | - $useParams = ['id'=>$id, 'w'=>(int)$srcWidth]; |
|
413 | + $useParams = ['id'=>$id, 'w'=>(int) $srcWidth]; |
|
414 | 414 | if (isset($params['quality'])) { |
415 | - $useParams = (int)$params['quality']; |
|
415 | + $useParams = (int) $params['quality']; |
|
416 | 416 | } |
417 | 417 | if (!isset($params['src'])) { |
418 | 418 | $params['src'] = $this->firefly_image($useParams); |
@@ -426,12 +426,12 @@ discard block |
||
426 | 426 | } |
427 | 427 | |
428 | 428 | // finally generate the tag ... note that these can overwrite the previously generated params |
429 | - $tagAttributes = []; |
|
429 | + $tagAttributes = []; |
|
430 | 430 | foreach ($params as $key=>$value) { |
431 | 431 | $tagAttributes[] = $key."='".htmlspecialchars($value)."'"; |
432 | 432 | } |
433 | 433 | |
434 | - return "<img ".implode(' ',$tagAttributes).">"; |
|
434 | + return "<img ".implode(' ', $tagAttributes).">"; |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | /** |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | else |
463 | 463 | return $value; |
464 | 464 | } else { |
465 | - return "Usage: you must provide an 'app' and a 'name' parameter. You provided ".print_r($params,true); |
|
465 | + return "Usage: you must provide an 'app' and a 'name' parameter. You provided ".print_r($params, true); |
|
466 | 466 | } |
467 | 467 | } |
468 | 468 | |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | { |
485 | 485 | $format = 'Y-m-d H:i:s'; |
486 | 486 | if (isset($params['stamp'])) |
487 | - return date($format, (integer)$params['stamp']); |
|
487 | + return date($format, (integer) $params['stamp']); |
|
488 | 488 | return date($format); |
489 | 489 | } |
490 | 490 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | */ |
497 | 497 | public function json($params) |
498 | 498 | { |
499 | - return '<pre>' . json_encode($params, JSON_PRETTY_PRINT) . '</pre>'; |
|
499 | + return '<pre>'.json_encode($params, JSON_PRETTY_PRINT).'</pre>'; |
|
500 | 500 | } |
501 | 501 | |
502 | 502 | /** |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | * @return int |
512 | 512 | * @throws \Exception |
513 | 513 | */ |
514 | - public function getAssetPosition($params, $default='end') |
|
514 | + public function getAssetPosition($params, $default = 'end') |
|
515 | 515 | { |
516 | 516 | $position = Arr::get($params, 'pos', Arr::get($params, 'position', $default)); |
517 | 517 | $positions = [ |
@@ -522,7 +522,7 @@ discard block |
||
522 | 522 | 'load' => View::POS_LOAD, |
523 | 523 | ]; |
524 | 524 | if (!array_key_exists($position, $positions)) { |
525 | - throw new \Exception('The javascript position specified must be one of ' . print_r(array_keys($positions)) . ', you specified "'.$position.'"'); |
|
525 | + throw new \Exception('The javascript position specified must be one of '.print_r(array_keys($positions)).', you specified "'.$position.'"'); |
|
526 | 526 | } |
527 | 527 | return $positions[$position]; |
528 | 528 | } |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | public function protectHtmlEntities($params, $smarty) |
727 | 727 | { |
728 | 728 | $input = $params['input']; |
729 | - $output = str_replace('&','&', $input); |
|
729 | + $output = str_replace('&', '&', $input); |
|
730 | 730 | if (!empty($params['assign'])) { |
731 | 731 | $smarty->assign($params['assign'], $output); |
732 | 732 | } else { |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | return $this->_width; |
165 | 165 | } |
166 | 166 | |
167 | - public function __construct($config=[]) |
|
167 | + public function __construct($config = []) |
|
168 | 168 | { |
169 | 169 | parent::__construct($config); |
170 | 170 | if (!isset($config['key'])) { |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @inheritDoc |
254 | 254 | */ |
255 | - public function setIsSortable($bool=true) |
|
255 | + public function setIsSortable($bool = true) |
|
256 | 256 | { |
257 | 257 | $this->_sortable = $bool; |
258 | 258 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | return $this->_sortable; |
266 | 266 | } |
267 | 267 | |
268 | - public function setAsIndex($bool=true) |
|
268 | + public function setAsIndex($bool = true) |
|
269 | 269 | { |
270 | 270 | $this->grid->setIndexedByColumn($this->key); |
271 | 271 | // thi is a bit gnarly but tests for yii Active record data providers specifically |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | return $this->_dataCellContentFunction; |
334 | 334 | } |
335 | 335 | // check for convention |
336 | - $functionName = 'render' . $this->key; |
|
336 | + $functionName = 'render'.$this->key; |
|
337 | 337 | if (method_exists($this->grid, $functionName) && $functionName !== 'renderfile') { |
338 | 338 | return $functionName; |
339 | 339 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | /** |
400 | 400 | * @inheritDoc |
401 | 401 | */ |
402 | - public function setDbField($field){ |
|
402 | + public function setDbField($field) { |
|
403 | 403 | $this->_dbKey = $field; |
404 | 404 | return $this; |
405 | 405 | } |
@@ -407,8 +407,8 @@ discard block |
||
407 | 407 | /** |
408 | 408 | * @inheritDoc |
409 | 409 | */ |
410 | - public function getDbField(){ |
|
411 | - if ($this->_dbKey === null){ |
|
410 | + public function getDbField() { |
|
411 | + if ($this->_dbKey === null) { |
|
412 | 412 | // set to be the key |
413 | 413 | $this->_dbKey = $this->key; |
414 | 414 | } |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | if ($this->grid->hasSort($this->key)) { |
458 | 458 | $sort = $this->grid->hasSortDescending() ? ' - ' : ' + '; |
459 | 459 | } |
460 | - $sortParam = $this->grid->hasSortDescending() ? $this->key : '-' . $this->key; |
|
460 | + $sortParam = $this->grid->hasSortDescending() ? $this->key : '-'.$this->key; |
|
461 | 461 | $url = neon()->getUrlManager()->createUrl([\Yii::$app->controller->getRoute(), $this->grid->id => ['sort' => $sortParam]]); |
462 | - return Html::a($this->getTitle() . $sort, $url, ['data-sort'=>$sortParam]); |
|
462 | + return Html::a($this->getTitle().$sort, $url, ['data-sort'=>$sortParam]); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | public function getFilterField() |
514 | 514 | { |
515 | 515 | $field = $this->getBaseFilterField(); |
516 | - foreach($this->filterFieldConfig as $key => $value) |
|
516 | + foreach ($this->filterFieldConfig as $key => $value) |
|
517 | 517 | $field[$key] = $value; |
518 | 518 | return $field; |
519 | 519 | } |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | |
530 | 530 | public function setMemberConfig($config) |
531 | 531 | { |
532 | - foreach($config as $key => $value) { |
|
532 | + foreach ($config as $key => $value) { |
|
533 | 533 | if (isset($this->member->$key)) |
534 | 534 | $this->member->$key = $value; |
535 | 535 | } |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | /** |
540 | 540 | * @inheritDoc |
541 | 541 | */ |
542 | - public function getCellData($row, $noValue='-') |
|
542 | + public function getCellData($row, $noValue = '-') |
|
543 | 543 | { |
544 | 544 | $data = null; |
545 | 545 | $key = $this->getKey(); |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | if (is_array($display)) { |
593 | 593 | $display = implode(',', $display); |
594 | 594 | } |
595 | - return "<span title=\"".str_replace('"',"'", html_entity_decode(strip_tags($display)))."\">$out</span>"; |
|
595 | + return "<span title=\"".str_replace('"', "'", html_entity_decode(strip_tags($display)))."\">$out</span>"; |
|
596 | 596 | } |
597 | 597 | return $this->getCellData($model); |
598 | 598 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | */ |
603 | 603 | public function getFieldName() |
604 | 604 | { |
605 | - return $this->getGrid()->getId() . '[' . $this->key . '][search]'; |
|
605 | + return $this->getGrid()->getId().'['.$this->key.'][search]'; |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -676,12 +676,12 @@ discard block |
||
676 | 676 | throw new \Exception('Unable to call a valid search function'); |
677 | 677 | } |
678 | 678 | |
679 | - protected $_actions =[]; |
|
679 | + protected $_actions = []; |
|
680 | 680 | |
681 | 681 | /** |
682 | 682 | * @inheritDoc |
683 | 683 | */ |
684 | - public function addRowAction($key, $text, $linkOptions=[]) |
|
684 | + public function addRowAction($key, $text, $linkOptions = []) |
|
685 | 685 | { |
686 | 686 | $linkOptions['text'] = $text; |
687 | 687 | $linkOptions['data-action'] = $key; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | } |
708 | 708 | $out = '<div class="neonGrid_rowActions">'; |
709 | 709 | $i = 0; |
710 | - foreach($this->_actions as $actionKey => $linkOptions) { |
|
710 | + foreach ($this->_actions as $actionKey => $linkOptions) { |
|
711 | 711 | if ($i > 0) $out .= ' | '; |
712 | 712 | if (isset($linkOptions['function'])) { |
713 | 713 | $func = $linkOptions['function']; |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * @param array $arguments of arguments |
735 | 735 | * @return mixed |
736 | 736 | */ |
737 | - public function callFunction($function, $arguments=[]) |
|
737 | + public function callFunction($function, $arguments = []) |
|
738 | 738 | { |
739 | 739 | if (is_string($function)) { |
740 | 740 | return call_user_func_array([$this->grid, $function], $arguments); |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | if (count($columnData)) { |
760 | 760 | $this->member->dataMapFilters = ['uuid' => $columnData]; |
761 | 761 | } |
762 | - foreach($models as $model) { |
|
762 | + foreach ($models as $model) { |
|
763 | 763 | $this->member->makeMapRequest($this->getCellData($model, null)); |
764 | 764 | } |
765 | 765 | } |