Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/core/view/SmartySharedPlugins.php 5 patches
Indentation   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -923,7 +923,4 @@
 block discarded – undo
923 923
 		if (!empty($params['assign'])) {
924 924
 			$smarty->assign($params['assign'], $output);
925 925
 		} else {
926
-			return $output;
927
-		}
928
-	}
929
-}
926
+			return $output
930 927
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -923,7 +923,4 @@
 block discarded – undo
923 923
 		if (!empty($params['assign'])) {
924 924
 			$smarty->assign($params['assign'], $output);
925 925
 		} else {
926
-			return $output;
927
-		}
928
-	}
929
-}
926
+			return $output
930 927
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +4 added lines, -5 removed lines patch added patch discarded remove patch
@@ -126,7 +126,9 @@  discard block
 block discarded – undo
126 126
 	public function googleCode($params)
127 127
 	{
128 128
 		$id = setting('cms', 'google_code');
129
-		if (empty($id)) return '';
129
+		if (empty($id)) {
130
+			return '';
131
+		}
130 132
 		// if using google tag manager
131 133
 		if (substr($id, 0, 3) === 'GTM') {
132 134
 			$head = <<<HEADJS
@@ -923,7 +925,4 @@  discard block
 block discarded – undo
923 925
 		if (!empty($params['assign'])) {
924 926
 			$smarty->assign($params['assign'], $output);
925 927
 		} else {
926
-			return $output;
927
-		}
928
-	}
929
-}
928
+			return $output
930 929
\ No newline at end of file
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -4 removed lines patch added patch discarded remove patch
@@ -923,7 +923,4 @@
 block discarded – undo
923 923
 		if (!empty($params['assign'])) {
924 924
 			$smarty->assign($params['assign'], $output);
925 925
 		} else {
926
-			return $output;
927
-		}
928
-	}
929
-}
926
+			return $output
930 927
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 
562 562
 		$html = [];
563 563
 		$params['loading'] = Arr::get($params, 'loading', 'lazy');
564
-		$params[Arr::get($params, 'srcset-name', 'srcset')] = Arr::get($params, 'srcset', $this->image_srcset(array_merge(['src' => $id], $params)));
565
-		$params[Arr::get($params, 'src-name', 'src')] = $this->firefly_image(array_merge(['id' => $id, 'w' => (int)$srcWidth], $params));
564
+		$params[Arr::get($params,  'srcset-name', 'srcset')] = Arr::get($params, 'srcset', $this->image_srcset(array_merge(['src' => $id], $params)));
565
+		$params[Arr::get($params,  'src-name', 'src')] = $this->firefly_image(array_merge(['id' => $id, 'w' => (int)$srcWidth], $params));
566 566
 
567 567
 		// alt
568 568
 		$params['alt'] = Arr::get($params, 'alt', $this->image_alt(['src' => $id]));
@@ -917,7 +917,4 @@  discard block
 block discarded – undo
917 917
 		if (!empty($params['assign'])) {
918 918
 			$smarty->assign($params['assign'], $output);
919 919
 		} else {
920
-			return $output;
921
-		}
922
-	}
923
-}
920
+			return $output
924 921
\ No newline at end of file
Please login to merge, or discard this patch.
neon/cms/components/CmsUrlRule.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@
 block discarded – undo
30 30
 	 */
31 31
 	public function parseRequest($manager, $request)
32 32
 	{
33
-		$pathInfo = '/' . $request->getPathInfo();
33
+		$pathInfo = '/'.$request->getPathInfo();
34 34
 		$url = CmsUrl::find()->where(['url' => $pathInfo])->limit(1)->one();
35 35
 		// if the url is not in the url table then return false to continue processing other route rules
36 36
 		// typically in a neon setup the module/controller/action rule
37
-		if (! $url) return false;
37
+		if (!$url) return false;
38 38
 		// check if the url found represents a redirect
39 39
 		if ($url['redirect'] !== null) {
40 40
 			neon()->response->redirect($url['redirect'], 301)->send();
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,9 @@
 block discarded – undo
34 34
 		$url = CmsUrl::find()->where(['url' => $pathInfo])->limit(1)->one();
35 35
 		// if the url is not in the url table then return false to continue processing other route rules
36 36
 		// typically in a neon setup the module/controller/action rule
37
-		if (! $url) return false;
37
+		if (! $url) {
38
+			return false;
39
+		}
38 40
 		// check if the url found represents a redirect
39 41
 		if ($url['redirect'] !== null) {
40 42
 			neon()->response->redirect($url['redirect'], 301)->send();
Please login to merge, or discard this patch.
neon/core/grid/column/Column.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 		return $this->_width;
174 174
 	}
175 175
 
176
-	public function __construct($config=[])
176
+	public function __construct($config = [])
177 177
 	{
178 178
 		parent::__construct($config);
179 179
 		if (!isset($config['key'])) {
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	/**
274 274
 	 * @inheritDoc
275 275
 	 */
276
-	public function setIsSortable($sortable=true)
276
+	public function setIsSortable($sortable = true)
277 277
 	{
278 278
 		$this->_sortable = $sortable;
279 279
 		return $this;
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		return $this->_sortable;
288 288
 	}
289 289
 
290
-	public function setAsIndex($bool=true)
290
+	public function setAsIndex($bool = true)
291 291
 	{
292 292
 		$this->grid->setIndexedByColumn($this->key);
293 293
 		// thi is a bit gnarly but tests for yii Active record data providers specifically
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 			return $this->_dataCellContentFunction;
356 356
 		}
357 357
 		// check for convention
358
-		$functionName = 'render' . $this->key;
358
+		$functionName = 'render'.$this->key;
359 359
 		if (method_exists($this->grid, $functionName) && $functionName !== 'renderfile') {
360 360
 			return $functionName;
361 361
 		}
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
 	/**
427 427
 	 * @inheritDoc
428 428
 	 */
429
-	public function setDbField($field){
429
+	public function setDbField($field) {
430 430
 		$this->_dbField = $field;
431 431
 		return $this;
432 432
 	}
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
 	/**
435 435
 	 * @inheritDoc
436 436
 	 */
437
-	public function getDbField(){
438
-		if ($this->_dbField === null){
437
+	public function getDbField() {
438
+		if ($this->_dbField === null) {
439 439
 			// set to be the key
440 440
 			$this->_dbField = $this->key;
441 441
 		}
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	/**
453 453
 	 * @inheritDoc
454 454
 	 */
455
-	public function setDbSortField($field){
455
+	public function setDbSortField($field) {
456 456
 		$this->_dbSortField = $field;
457 457
 		return $this;
458 458
 	}
@@ -460,8 +460,8 @@  discard block
 block discarded – undo
460 460
 	/**
461 461
 	 * @inheritDoc
462 462
 	 */
463
-	public function getDbSortField(){
464
-		if ($this->_dbSortField === null){
463
+	public function getDbSortField() {
464
+		if ($this->_dbSortField === null) {
465 465
 			// set to be the key
466 466
 			$this->_dbSortField = $this->dbField;
467 467
 		}
@@ -510,9 +510,9 @@  discard block
 block discarded – undo
510 510
 		if ($this->grid->hasSort($this->key)) {
511 511
 			$sort = $this->grid->hasSortDescending() ? ' - ' : ' + ';
512 512
 		}
513
-		$sortParam = $this->grid->hasSortDescending() ? $this->key : '-' . $this->key;
513
+		$sortParam = $this->grid->hasSortDescending() ? $this->key : '-'.$this->key;
514 514
 		$url = neon()->getUrlManager()->createUrl([\Yii::$app->controller->getRoute(), $this->grid->id => ['sort' => $sortParam]]);
515
-		return Html::a($this->getTitle() . $sort, $url, ['data-sort'=>$sortParam]);
515
+		return Html::a($this->getTitle().$sort, $url, ['data-sort'=>$sortParam]);
516 516
 	}
517 517
 
518 518
 	/**
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	public function getFilterField()
567 567
 	{
568 568
 		$field = $this->getBaseFilterField();
569
-		foreach($this->filterFieldConfig as $key => $value)
569
+		foreach ($this->filterFieldConfig as $key => $value)
570 570
 			$field[$key] = $value;
571 571
 		return $field;
572 572
 	}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 
583 583
 	public function setMemberConfig($config)
584 584
 	{
585
-		foreach($config as $key => $value) {
585
+		foreach ($config as $key => $value) {
586 586
 			if (isset($this->member->$key))
587 587
 				$this->member->$key = $value;
588 588
 		}
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 	/**
593 593
 	 * @inheritDoc
594 594
 	 */
595
-	public function getCellData($row, $noValue='-')
595
+	public function getCellData($row, $noValue = '-')
596 596
 	{
597 597
 		$data = null;
598 598
 		$key = $this->getKey();
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 			if (is_array($display)) {
644 644
 				$display = implode(',', $display);
645 645
 			}
646
-			return "<span title=\"".str_replace('"',"'", html_entity_decode(strip_tags($display)))."\">$out</span>";
646
+			return "<span title=\"".str_replace('"', "'", html_entity_decode(strip_tags($display)))."\">$out</span>";
647 647
 		}
648 648
 		return $this->getCellData($model);
649 649
 	}
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	 */
654 654
 	public function getFieldName()
655 655
 	{
656
-		return $this->getGrid()->getId() . '[' . $this->key . '][search]';
656
+		return $this->getGrid()->getId().'['.$this->key.'][search]';
657 657
 	}
658 658
 
659 659
 	/**
@@ -727,12 +727,12 @@  discard block
 block discarded – undo
727 727
 		throw new \Exception('Unable to call a valid search function');
728 728
 	}
729 729
 
730
-	protected $_actions =[];
730
+	protected $_actions = [];
731 731
 
732 732
 	/**
733 733
 	 * @inheritDoc
734 734
 	 */
735
-	public function addRowAction($key, $text, $linkOptions=[])
735
+	public function addRowAction($key, $text, $linkOptions = [])
736 736
 	{
737 737
 		$linkOptions['text'] = $text;
738 738
 		$linkOptions['data-action'] = $key;
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 		}
759 759
 		$out = '<div class="neonGrid_rowActions">';
760 760
 		$i = 0;
761
-		foreach($this->_actions as $actionKey => $linkOptions) {
761
+		foreach ($this->_actions as $actionKey => $linkOptions) {
762 762
 			if ($i > 0) $out .= ' | ';
763 763
 			if (isset($linkOptions['function'])) {
764 764
 				$func = $linkOptions['function'];
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 	 * @param array $arguments of arguments
786 786
 	 * @return mixed
787 787
 	 */
788
-	public function callFunction($function, $arguments=[])
788
+	public function callFunction($function, $arguments = [])
789 789
 	{
790 790
 		if (is_string($function)) {
791 791
 			return call_user_func_array([$this->grid, $function], $arguments);
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 			if (count($columnData)) {
811 811
 				$this->member->dataMapFilters = ['uuid' => $columnData];
812 812
 			}
813
-			foreach($models as $model) {
813
+			foreach ($models as $model) {
814 814
 				$this->member->makeMapRequest($this->getCellData($model, null));
815 815
 			}
816 816
 		}
Please login to merge, or discard this patch.
Braces   +27 added lines, -17 removed lines patch added patch discarded remove patch
@@ -105,8 +105,9 @@  discard block
 block discarded – undo
105 105
 	 */
106 106
 	public function getEmptyCellDisplay()
107 107
 	{
108
-		if ($this->_emptyCellDisplay !== null)
109
-			return $this->_emptyCellDisplay;
108
+		if ($this->_emptyCellDisplay !== null) {
109
+					return $this->_emptyCellDisplay;
110
+		}
110 111
 		return $this->getGrid()->emptyCellDisplay;
111 112
 	}
112 113
 
@@ -490,10 +491,12 @@  discard block
 block discarded – undo
490 491
 	public function renderHeaderCell()
491 492
 	{
492 493
 		$options = $this->getHeaderCellAttributes();
493
-		if ($this->grid->hasSort($this->key))
494
-			Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc'));
495
-		if (trim($this->width) != '')
496
-			Html::addCssStyle($options, ["width" => $this->width]);
494
+		if ($this->grid->hasSort($this->key)) {
495
+					Html::addCssClass($options, ($this->grid->hasSortDescending() ? 'desc' : 'asc'));
496
+		}
497
+		if (trim($this->width) != '') {
498
+					Html::addCssStyle($options, ["width" => $this->width]);
499
+		}
497 500
 		Html::addCssStyle($options, $this->_style);
498 501
 
499 502
 		return Html::tag('th', $this->renderHeaderCellContent(), $options);
@@ -504,8 +507,9 @@  discard block
 block discarded – undo
504 507
 	 */
505 508
 	public function renderHeaderCellContent()
506 509
 	{
507
-		if (!$this->isSortable)
508
-			return $this->getTitle();
510
+		if (!$this->isSortable) {
511
+					return $this->getTitle();
512
+		}
509 513
 		$sort = '';
510 514
 		if ($this->grid->hasSort($this->key)) {
511 515
 			$sort = $this->grid->hasSortDescending() ? ' - ' : ' + ';
@@ -535,10 +539,12 @@  discard block
 block discarded – undo
535 539
 	 */
536 540
 	public function renderFilterCellContent()
537 541
 	{
538
-		if ($this->filter === false)
539
-			return '';
540
-		if (!$this->getGrid()->getFilterForm()->hasField($this->getKey()))
541
-			return '';
542
+		if ($this->filter === false) {
543
+					return '';
544
+		}
545
+		if (!$this->getGrid()->getFilterForm()->hasField($this->getKey())) {
546
+					return '';
547
+		}
542 548
 		$field = $this->getGrid()->getFilterForm()->getField($this->getKey());
543 549
 		// remove any automatic validators
544 550
 		$field->setValidators([], true);
@@ -566,8 +572,9 @@  discard block
 block discarded – undo
566 572
 	public function getFilterField()
567 573
 	{
568 574
 		$field = $this->getBaseFilterField();
569
-		foreach($this->filterFieldConfig as $key => $value)
570
-			$field[$key] = $value;
575
+		foreach($this->filterFieldConfig as $key => $value) {
576
+					$field[$key] = $value;
577
+		}
571 578
 		return $field;
572 579
 	}
573 580
 
@@ -583,8 +590,9 @@  discard block
 block discarded – undo
583 590
 	public function setMemberConfig($config)
584 591
 	{
585 592
 		foreach($config as $key => $value) {
586
-			if (isset($this->member->$key))
587
-				$this->member->$key = $value;
593
+			if (isset($this->member->$key)) {
594
+							$this->member->$key = $value;
595
+			}
588 596
 		}
589 597
 		return $this;
590 598
 	}
@@ -759,7 +767,9 @@  discard block
 block discarded – undo
759 767
 		$out = '<div class="neonGrid_rowActions">';
760 768
 		$i = 0;
761 769
 		foreach($this->_actions as $actionKey => $linkOptions) {
762
-			if ($i > 0) $out .= ' | ';
770
+			if ($i > 0) {
771
+				$out .= ' | ';
772
+			}
763 773
 			if (isset($linkOptions['function'])) {
764 774
 				$func = $linkOptions['function'];
765 775
 				$out .= $this->callFunction($func, [$model, $key, $index]);
Please login to merge, or discard this patch.
neon/core/grid/column/IColumn.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
 
15 15
 interface IColumn
16 16
 {
17
-	public function __construct($config=[]);
17
+	public function __construct($config = []);
18 18
 
19
-	public function renderDataCell($model, $key, $index);  // GRID: called by grid
19
+	public function renderDataCell($model, $key, $index); // GRID: called by grid
20 20
 
21 21
 	/**
22 22
 	 * Renders the contents of the cell (can be overriden by setting self::setDataCellContentFunction)
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * @param bool $sortable
154 154
 	 * @return $this
155 155
 	 */
156
-	public function setIsSortable($sortable=true);
156
+	public function setIsSortable($sortable = true);
157 157
 
158 158
 	/**
159 159
 	 * Is the column sortable
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 	 *
255 255
 	 * @param boolean $bool
256 256
 	 */
257
-	public function setAsIndex($bool=true);
257
+	public function setAsIndex($bool = true);
258 258
 
259 259
 	/**
260 260
 	 * Set the title of the column
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @return null|callable
305 305
 	 */
306
-	public function getSearchFunction();  // GRID: called by grid
306
+	public function getSearchFunction(); // GRID: called by grid
307 307
 
308 308
 	/**
309 309
 	 * Set the database field name. This is used to lookup the row data, and in filters and ordering
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 	 * @param array $linkOptions
367 367
 	 * @return mixed
368 368
 	 */
369
-	public function addRowAction($key, $text, $linkOptions=[]);
369
+	public function addRowAction($key, $text, $linkOptions = []);
370 370
 
371 371
 	public function renderRowActions($model, $key, $index);
372 372
 
Please login to merge, or discard this patch.
neon/cms/components/Widget.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		if (isset($params['type'])) {
118 118
 			$defaults['type'] = $params['type'];
119 119
 			// path to the file is determined by the theme hierarchy
120
-			$defaults['file'] = $params['type'] . '.tpl';
120
+			$defaults['file'] = $params['type'].'.tpl';
121 121
 			if (isset($params['key'])) {
122 122
 				self::buildDataFromCmsKeyAttributes($params);
123 123
 			}
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 			return $this->createStaticEditable($content);
233 233
 		} else {
234 234
 			$file = $this->params['file'];
235
-			$this->params['hasData'] = count($this->data)>0;
235
+			$this->params['hasData'] = count($this->data) > 0;
236 236
 			$this->params['hasResponse'] = true;
237 237
 			$this->params['data'] = $this->data;
238 238
 			$this->params['edit'] = $this->createDynamicEditable();
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 	public function getId()
299 299
 	{
300 300
 		if ($this->_id === null) {
301
-			$this->_id = $this->getPage()->getId() . '_' . static::$autoIdPrefix . static::$counter++;
301
+			$this->_id = $this->getPage()->getId().'_'.static::$autoIdPrefix.static::$counter++;
302 302
 		}
303 303
 		return $this->_id;
304 304
 	}
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			$dataKey = $this->params['data-key'];
341 341
 			$dataPageId = $this->params['data-page-id'];
342 342
 			if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0)))
343
-				return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">' . $value . '</div>';
343
+				return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">'.$value.'</div>';
344 344
 			else
345 345
 				return "<div style='display:inline-block;' class='cobe-editable cobe-static'  data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>";
346 346
 		} else {
Please login to merge, or discard this patch.
Braces   +26 added lines, -18 removed lines patch added patch discarded remove patch
@@ -123,8 +123,9 @@  discard block
 block discarded – undo
123 123
 			}
124 124
  		}
125 125
 		 
126
-		if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class']))
127
-			Daedalus::buildDataFromDdsAttributes($params);
126
+		if (isset($params['dds']) || isset($params['dds_page']) || isset($params['dds_class'])) {
127
+					Daedalus::buildDataFromDdsAttributes($params);
128
+		}
128 129
 		$resolvedParams = Arr::merge($defaults, $params);
129 130
 		return $widget->render($resolvedParams, $template);
130 131
 	}
@@ -171,8 +172,9 @@  discard block
 block discarded – undo
171 172
 		}
172 173
 		// scb = static content block
173 174
 		$params['type'] = '_scb';
174
-		if (isset($params['key']))
175
-			self::buildDataFromCmsKeyAttributes($params);
175
+		if (isset($params['key'])) {
176
+					self::buildDataFromCmsKeyAttributes($params);
177
+		}
176 178
 		$params['content'] = $content;
177 179
 		$params['wys'] = (isset($params['wys']) ? $params['wys'] : true);
178 180
 		return $widget->render($params, $template);
@@ -208,8 +210,9 @@  discard block
 block discarded – undo
208 210
 		$data = [];
209 211
 		if (($dataRequest = $this->getDataRequest()) !== null) {
210 212
 			$id = $meta = null;
211
-			if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta))
212
-				return $id;
213
+			if (!$this->getPage()->requestWidgetData($dataRequest, $data, $id, $this->isStatic, $meta)) {
214
+							return $id;
215
+			}
213 216
 			$this->saveData($data);
214 217
 			$this->saveDataMetaInformation($meta);
215 218
 		}
@@ -239,8 +242,9 @@  discard block
 block discarded – undo
239 242
 			$this->params['meta'] = $this->meta;
240 243
 
241 244
 			// createTemplate is an expensive call so only call it once per file and reset all variables on the stored template.
242
-			if (!isset($templates[$file]))
243
-				$templates[$file] = $this->renderer->createTemplate($file);
245
+			if (!isset($templates[$file])) {
246
+							$templates[$file] = $this->renderer->createTemplate($file);
247
+			}
244 248
 			$tpl = $templates[$file];
245 249
 			$tpl->tpl_vars = $tpl->config_vars = [];
246 250
 
@@ -258,8 +262,9 @@  discard block
 block discarded – undo
258 262
 	 */
259 263
 	protected function getDataRequest()
260 264
 	{
261
-		if (isset($this->params['data']))
262
-			return Daedalus::convertDataRequestToJson($this->params['data']);
265
+		if (isset($this->params['data'])) {
266
+					return Daedalus::convertDataRequestToJson($this->params['data']);
267
+		}
263 268
 		return null;
264 269
 	}
265 270
 
@@ -315,15 +320,17 @@  discard block
 block discarded – undo
315 320
 	 */
316 321
 	protected static function buildDataFromCmsKeyAttributes(&$params)
317 322
 	{
318
-		if (!isset($params['type'], $params['key']))
319
-			return;
323
+		if (!isset($params['type'], $params['key'])) {
324
+					return;
325
+		}
320 326
 		$key = "$params[type]_$params[key]";
321 327
 		$pageId = isset($params['page']) ? self::$page->getId() : null;
322 328
 		$params['data-key'] = $key;
323 329
 		$params['data-page-id'] = $pageId;
324 330
 		$params['data'] = "'key':'$key','pageId':'$pageId'";
325
-		if (!isset($params['content']))
326
-			$params['content'] = "Add Content for $params[key] here";
331
+		if (!isset($params['content'])) {
332
+					$params['content'] = "Add Content for $params[key] here";
333
+		}
327 334
 		$params['is_static'] = true;
328 335
 	}
329 336
 
@@ -339,10 +346,11 @@  discard block
 block discarded – undo
339 346
 		if ($this->getPage()->isInEditMode()) {
340 347
 			$dataKey = $this->params['data-key'];
341 348
 			$dataPageId = $this->params['data-page-id'];
342
-			if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0)))
343
-				return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">' . $value . '</div>';
344
-			else
345
-				return "<div style='display:inline-block;' class='cobe-editable cobe-static'  data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>";
349
+			if ((isset($this->params['wys']) || isset($this->params['wysiwyg'])) || (isset($this->params['editor']) && strpos('wys', $this->params['editor'] === 0))) {
350
+							return '<div id="'.$this->getId().'" data-id="'.$this->getId().'" data-key="'.$dataKey.'" data-page-id="'.$dataPageId.'" class="cobe-editable cobe-static-block" contenteditable="true">' . $value . '</div>';
351
+			} else {
352
+							return "<div style='display:inline-block;' class='cobe-editable cobe-static'  data-key='$dataKey' data-page-id='$dataPageId' contenteditable='true' />$value</div>";
353
+			}
346 354
 		} else {
347 355
 			return $value;
348 356
 		}
Please login to merge, or discard this patch.
neon/cms/components/Page.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function isInEditMode()
81 81
 	{
82
-		if (neon()->session===null) return false;
82
+		if (neon()->session === null) return false;
83 83
 		return neon()->session->get(self::COBE_EDITING, false);
84 84
 	}
85 85
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		$params = array_merge($data['page_params'], neon()->request->get(), neon()->request->post());
218 218
 		unset($data['page_params']);
219 219
 		$data['params'] = Html::encodeEntities($params);
220
-		$data['url'] = '/' . neon()->request->pathInfo;
220
+		$data['url'] = '/'.neon()->request->pathInfo;
221 221
 		$data['uri'] = $_SERVER['REQUEST_URI'];
222 222
 		$data['host'] = Url::base(true);
223 223
 		$data['editing'] = $this->isInEditMode();
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
 		// If the number of renders are excessive (4+), issue a warning.
361 361
 		if ($numberOfRenders >= 4)
362
-			\Neon::debug('Excessive number of renders (>=4): ' . $numberOfRenders);
362
+			\Neon::debug('Excessive number of renders (>=4): '.$numberOfRenders);
363 363
 
364 364
 		// inject assets into template
365 365
 		$html = neon()->view->injectHtml($html);
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	 * @param
434 434
 	 * @return string
435 435
 	 */
436
-	protected function canonicaliseRequest(&$dataRequest, $isStatic=false)
436
+	protected function canonicaliseRequest(&$dataRequest, $isStatic = false)
437 437
 	{
438 438
 		if ($isStatic) {
439 439
 			$id = $this->createStaticContentId($dataRequest);
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
 		} else {
442 442
 			$request = array('class'=>null, 'filters'=>[], 'order'=>[], 'limit'=>[]);
443 443
 			$dataRequest = array_merge($request, $dataRequest);
444
-			$id = md5(str_replace([' '],'', json_encode($dataRequest)));
444
+			$id = md5(str_replace([' '], '', json_encode($dataRequest)));
445 445
 		}
446 446
 		return $id;
447 447
 	}
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 */
467 467
 	protected function makeDynamicDataRequests()
468 468
 	{
469
-		if (count($this->dynamicDataRequests)>0) {
469
+		if (count($this->dynamicDataRequests) > 0) {
470 470
 			$dds = $this->getIDdsObjectManagement();
471 471
 			foreach ($this->dynamicDataRequests as $id=>$dr) {
472 472
 				$dds->addObjectRequest($dr['class'], $dr['filters'], $dr['order'], $dr['limit'], $id);
@@ -492,11 +492,11 @@  discard block
 block discarded – undo
492 492
 	 */
493 493
 	protected function makeStaticDataRequests()
494 494
 	{
495
-		if (count($this->staticDataRequests)>0) {
495
+		if (count($this->staticDataRequests) > 0) {
496 496
 			$cms = $this->getICmsStaticData();
497 497
 			$data = $cms->bulkStaticContentRequest($this->staticDataRequests);
498 498
 			foreach ($data as $i=>$d)
499
-				$this->requestedData[$i] = ($d===null ? 'not found' : $d);
499
+				$this->requestedData[$i] = ($d === null ? 'not found' : $d);
500 500
 			$this->staticDataRequests = [];
501 501
 		}
502 502
 	}
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	protected function hasDataRequests()
509 509
 	{
510
-		return (count($this->staticDataRequests)+count($this->dynamicDataRequests) > 0);
510
+		return (count($this->staticDataRequests) + count($this->dynamicDataRequests) > 0);
511 511
 	}
512 512
 
513 513
 	/**
Please login to merge, or discard this patch.
Braces   +29 added lines, -18 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function isInEditMode()
81 81
 	{
82
-		if (neon()->session===null) return false;
82
+		if (neon()->session===null) {
83
+			return false;
84
+		}
83 85
 		return neon()->session->get(self::COBE_EDITING, false);
84 86
 	}
85 87
 
@@ -211,8 +213,9 @@  discard block
 block discarded – undo
211 213
 			$data = $this->_page;
212 214
 			// add the nice_id as CmnUrRoute will add this on first parse through Cobe without gets but
213 215
 			// not on requests with get parameters which has led to hard-to-debug runtime coding errors
214
-			if (!isset($data['page_params']['nice_id']) && isset($data['nice_id']))
215
-				$data['page_params']['nice_id'] = $data['nice_id'];
216
+			if (!isset($data['page_params']['nice_id']) && isset($data['nice_id'])) {
217
+							$data['page_params']['nice_id'] = $data['nice_id'];
218
+			}
216 219
 		}
217 220
 		$params = array_merge($data['page_params'], neon()->request->get(), neon()->request->post());
218 221
 		unset($data['page_params']);
@@ -255,7 +258,9 @@  discard block
 block discarded – undo
255 258
 	 */
256 259
 	public function getUrlOfPage($id)
257 260
 	{
258
-		if (!$id) return '';
261
+		if (!$id) {
262
+			return '';
263
+		}
259 264
 		return $url = url(['/cms/render/page', 'nice_id'=>$id]);
260 265
 	}
261 266
 
@@ -353,13 +358,15 @@  discard block
 block discarded – undo
353 358
 		do {
354 359
 			$numberOfRenders++;
355 360
 			$html = $renderer->renderTemplate($template);
356
-			if (($hasDataRequests = $this->hasDataRequests()))
357
-				$this->makeDataRequests();
361
+			if (($hasDataRequests = $this->hasDataRequests())) {
362
+							$this->makeDataRequests();
363
+			}
358 364
 		} while ($hasDataRequests == true);
359 365
 
360 366
 		// If the number of renders are excessive (4+), issue a warning.
361
-		if ($numberOfRenders >= 4)
362
-			\Neon::debug('Excessive number of renders (>=4): ' . $numberOfRenders);
367
+		if ($numberOfRenders >= 4) {
368
+					\Neon::debug('Excessive number of renders (>=4): ' . $numberOfRenders);
369
+		}
363 370
 
364 371
 		// inject assets into template
365 372
 		$html = neon()->view->injectHtml($html);
@@ -390,15 +397,17 @@  discard block
 block discarded – undo
390 397
 		// see if we have the data
391 398
 		if (isset($this->requestedData[$id])) {
392 399
 			$data = $this->requestedData[$id];
393
-			if (!$isStatic && isset($this->requestedDataMeta[$id]))
394
-				$meta = $this->requestedDataMeta[$id];
400
+			if (!$isStatic && isset($this->requestedDataMeta[$id])) {
401
+							$meta = $this->requestedDataMeta[$id];
402
+			}
395 403
 			return true;
396 404
 		}
397 405
 		// if not then add it to the list of requested data
398
-		if ($isStatic)
399
-			$this->staticDataRequests[$id] = $dataRequest;
400
-		else
401
-			$this->dynamicDataRequests[$id] = $dataRequest;
406
+		if ($isStatic) {
407
+					$this->staticDataRequests[$id] = $dataRequest;
408
+		} else {
409
+					$this->dynamicDataRequests[$id] = $dataRequest;
410
+		}
402 411
 		return false;
403 412
 	}
404 413
 
@@ -495,8 +504,9 @@  discard block
 block discarded – undo
495 504
 		if (count($this->staticDataRequests)>0) {
496 505
 			$cms = $this->getICmsStaticData();
497 506
 			$data = $cms->bulkStaticContentRequest($this->staticDataRequests);
498
-			foreach ($data as $i=>$d)
499
-				$this->requestedData[$i] = ($d===null ? 'not found' : $d);
507
+			foreach ($data as $i=>$d) {
508
+							$this->requestedData[$i] = ($d===null ? 'not found' : $d);
509
+			}
500 510
 			$this->staticDataRequests = [];
501 511
 		}
502 512
 	}
@@ -539,8 +549,9 @@  discard block
 block discarded – undo
539 549
 	private $cmsStaticData = null;
540 550
 	private function getICmsStaticData()
541 551
 	{
542
-		if ($this->cmsStaticData === null)
543
-			$this->cmsStaticData = neon('cms')->ICmsStaticData;
552
+		if ($this->cmsStaticData === null) {
553
+					$this->cmsStaticData = neon('cms')->ICmsStaticData;
554
+		}
544 555
 		return $this->cmsStaticData;
545 556
 	}
546 557
 
Please login to merge, or discard this patch.
neon/daedalus/services/ddsManager/DdsCore.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 		$member = $storage[$memberRef];
113 113
 		// handle some storage differences
114 114
 		$columnCheck = substr($member['column'], 0, 4);
115
-		if ($columnCheck=='CHAR' || $columnCheck=='UUID') {
115
+		if ($columnCheck == 'CHAR' || $columnCheck == 'UUID') {
116 116
 			$size = (isset($member['definition']['size'])) ? $member['definition']['size'] : 150;
117 117
 			$member['column'] = str_replace($columnCheck, "CHAR($size)", $member['column']);
118 118
 		}
@@ -161,10 +161,10 @@  discard block
 block discarded – undo
161 161
 	 * @return []  array of ['member_ref']=>['data_type_ref', 'column', 'index']
162 162
 	 *  where column is the db column type
163 163
 	 */
164
-	protected function getMemberStorage($classType, $memberRef=null)
164
+	protected function getMemberStorage($classType, $memberRef = null)
165 165
 	{
166 166
 		$boundValues = [];
167
-		$query =<<<EOQ
167
+		$query = <<<EOQ
168 168
 SELECT `m`.`member_ref`, `s`.`type`, d.`definition` FROM dds_member m
169 169
 JOIN `dds_data_type` d ON `m`.`data_type_ref`=d.`data_type_ref`
170 170
 JOIN `dds_storage` s ON `d`.`storage_ref`=s.`storage_ref`
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
 			$memberStorage[$r['member_ref']] = [
184 184
 				'column' => $this->getColumnType($r['type']),
185 185
 				'index' => $this->getIndexType($r['type']),
186
-				'definition' => empty($r['definition']) ? null : json_decode($r['definition'],true)
186
+				'definition' => empty($r['definition']) ? null : json_decode($r['definition'], true)
187 187
 			];
188 188
 		}
189 189
 		return $memberStorage;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			case 'BINARY_LONG': $type = 'LONGBLOB'; break;
211 211
 			case 'CHAR': $type = 'CHAR'; break;
212 212
 			case 'UUID': $type = 'UUID'; break;
213
-			default: $type="UNKNOWN STORAGE TYPE $storageType"; break;
213
+			default: $type = "UNKNOWN STORAGE TYPE $storageType"; break;
214 214
 		}
215 215
 		$collation = $this->getCollation($storageType);
216 216
 		if ($collation)
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @throws InvalidArgumentException if class not found and $throwException is true
286 286
 	 * @return bool  whether or not found
287 287
 	 */
288
-	protected function findClass($classType, &$class=null, $throwException=false)
288
+	protected function findClass($classType, &$class = null, $throwException = false)
289 289
 	{
290 290
 		$ct = $this->canonicaliseRef($classType);
291 291
 		if (empty(self::$_classCache[$ct])) {
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 	/**
335 335
 	 * @see IDdsClassManagement::listMembers
336 336
 	 */
337
-	protected function listMembersForClass($classType, $includeDeleted=false, $keyBy='member_ref')
337
+	protected function listMembersForClass($classType, $includeDeleted = false, $keyBy = 'member_ref')
338 338
 	{
339 339
 		if (!is_string($classType))
340 340
 			throw new InvalidArgumentException('The class type $classType parameter should be a string');
341 341
 		$select = ['member_ref', 'label', 'data_type_ref', 'description', 'choices', 'map_field', 'link_class'];
342 342
 		if (!empty($keyBy) && !in_array($keyBy, $select))
343
-			throw new InvalidArgumentException('Parameter keyBy must be empty or one of ' .print_r($select, true));
343
+			throw new InvalidArgumentException('Parameter keyBy must be empty or one of '.print_r($select, true));
344 344
 
345 345
 		// see if we have a cached version or getting from the database
346 346
 		if (empty(static::$_classMembersCache[$classType][$includeDeleted])) {
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 */
392 392
 	protected function setClassMapMemberCache($classType, $member)
393 393
 	{
394
-		static::$_classMemberMapCache[$classType]=$member;
394
+		static::$_classMemberMapCache[$classType] = $member;
395 395
 	}
396 396
 
397 397
 	/**
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	 * @param DdsDataType &$dataType
401 401
 	 * @return bool  whether or not found
402 402
 	 */
403
-	protected function findDataType($dataTypeRef, &$dataType=null)
403
+	protected function findDataType($dataTypeRef, &$dataType = null)
404 404
 	{
405 405
 		$dataType = DdsDataType::findOne(['data_type_ref'=>$dataTypeRef]);
406 406
 		return ($dataType !== null);
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 	 * @param char $separator  the single character separator to split the string into its parts
455 455
 	 * @return string  the canonicalised result
456 456
 	 */
457
-	protected function canonicaliseRefByParts($ref, $separator= '.')
457
+	protected function canonicaliseRefByParts($ref, $separator = '.')
458 458
 	{
459 459
 		$parts = explode($separator, $ref);
460 460
 		$canons = [];
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 	 * @param $ref
469 469
 	 * @return string
470 470
 	 */
471
-	protected function quoteField($ref, $ddsObjectAlias='o')
471
+	protected function quoteField($ref, $ddsObjectAlias = 'o')
472 472
 	{
473 473
 		if (in_array($ref, ['_uuid', '_created', '_updated', '_class_ref'])) {
474 474
 			return "`$ddsObjectAlias`.`$ref`";
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
 		try {
489 489
 			$this->canonicaliseFiltersRecursive($filters);
490 490
 		} catch (InvalidArgumentException $ex) {
491
-			throw new InvalidArgumentException($ex->getMessage(). ' Filters passed in: ' .print_r($filters, true));
491
+			throw new InvalidArgumentException($ex->getMessage().' Filters passed in: '.print_r($filters, true));
492 492
 		}
493 493
 		return $filters;
494 494
 	}
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 	protected function canonicaliseFiltersRecursive(&$filters)
504 504
 	{
505 505
 		// is this a filter clause or set of filter clauses??
506
-		if (!is_array($filters) || count($filters)==0)
506
+		if (!is_array($filters) || count($filters) == 0)
507 507
 			return;
508 508
 
509 509
 		// recursively descend until one finds a filter clause
@@ -514,9 +514,9 @@  discard block
 block discarded – undo
514 514
 		}
515 515
 		// so canonicalise a filter clause
516 516
 		if (array_key_exists(0, $filters))
517
-			$this->canonicaliseFilter($filters[0],0);
517
+			$this->canonicaliseFilter($filters[0], 0);
518 518
 		if (array_key_exists(1, $filters))
519
-			$this->canonicaliseFilter($filters[1],1);
519
+			$this->canonicaliseFilter($filters[1], 1);
520 520
 
521 521
 		// Handle nulls passed as values
522 522
 		// ['field', '=', null] and ['field', '!=', null]
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 		}
546 546
 		if ($key === 1) {
547 547
 			// accept only these operators
548
-			switch(strtolower($item)) {
548
+			switch (strtolower($item)) {
549 549
 				case '=': case '!=':
550 550
 				case '<': case '<=':
551 551
 				case '>': case '>=':
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	{
581 581
 		// check there are no integer keys as this means not all keys are in the logic
582 582
 		foreach ($keys as $k) {
583
-			if ((int)$k === $k) {
583
+			if ((int) $k === $k) {
584 584
 				throw new InvalidArgumentException(
585 585
 					'Daedalus: You have provided a logic string to the query, but it looks like not all filter clauses have a logic name added to them. All filter clauses need to represented in the logic statement.'
586 586
 				);
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 			['AND', 'and', 'NOT', 'not', 'OR', 'or', ' ', ')', '('],
594 594
 			'', $subLogic
595 595
 		);
596
-		if (strlen($subLogic)>0)
597
-			throw new InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true). ' for a logic statement of ' .print_r($logic, true). ' The remaining characters are ' .print_r($subLogic, true));
596
+		if (strlen($subLogic) > 0)
597
+			throw new InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true).' for a logic statement of '.print_r($logic, true).' The remaining characters are '.print_r($subLogic, true));
598 598
 		return $logic;
599 599
 	}
600 600
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 				switch ($drn) {
631 631
 					case 'ASC': case 'DESC':
632 632
 						// allow -ve key starts for nulls last in MySql
633
-						if (strpos($k,'-') === 0)
633
+						if (strpos($k, '-') === 0)
634 634
 							$canon['-'.$this->quoteField($k)] = $drn;
635 635
 						else
636 636
 							$canon[$this->quoteField($k)] = $drn;
@@ -654,10 +654,10 @@  discard block
 block discarded – undo
654 654
 	protected function canonicaliseLimit($limit, &$total, &$calculateTotal)
655 655
 	{
656 656
 		$canon = [];
657
-		$total=null;
657
+		$total = null;
658 658
 		$calculateTotal = false;
659 659
 		if (is_array($limit)) {
660
-			$canon = ['start'=>0,'length'=>self::MAX_LENGTH];
660
+			$canon = ['start'=>0, 'length'=>self::MAX_LENGTH];
661 661
 			foreach ($limit as $k=>$v) {
662 662
 				$key = strtolower($k);
663 663
 				switch ($key) {
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 					case 'total':
671 671
 						// $v can be truthy or the previous integer
672 672
 						$total = is_numeric($v) ? (int) $v : null;
673
-						$calculateTotal = ($v===true || $v==='true');
673
+						$calculateTotal = ($v === true || $v === 'true');
674 674
 					break;
675 675
 				}
676 676
 			}
@@ -685,14 +685,14 @@  discard block
 block discarded – undo
685 685
 	 * @param [] $row  the row of data to be converted
686 686
 	 * @param string $classTypeKey the key in the data that will give the class type
687 687
 	 */
688
-	protected function convertFromDBToPHP(&$row, $links=[], $classTypeKey='_class_type')
688
+	protected function convertFromDBToPHP(&$row, $links = [], $classTypeKey = '_class_type')
689 689
 	{
690 690
 		$classType = $row[$classTypeKey];
691 691
 		$members = $this->getClassMembers($classType);
692 692
 		// now process only the member defined fields:
693 693
 		foreach ($row as $key => &$value) {
694 694
 			if (isset($members[$key])) {
695
-				$memberLinks = isset($links[$key])?$links[$key]:[];
695
+				$memberLinks = isset($links[$key]) ? $links[$key] : [];
696 696
 				$this->doConversionFromDBToPHP($members[$key], $value, $memberLinks);
697 697
 			}
698 698
 		}
@@ -704,9 +704,9 @@  discard block
 block discarded – undo
704 704
 	 * @param string $dataType the data type ref of the value
705 705
 	 * @param mixed $value  the value returned by the database
706 706
 	 */
707
-	protected function doConversionFromDBToPHP($member, &$value, $memberLinks=[])
707
+	protected function doConversionFromDBToPHP($member, &$value, $memberLinks = [])
708 708
 	{
709
-		switch($member['data_type_ref']) {
709
+		switch ($member['data_type_ref']) {
710 710
 			case 'choice':
711 711
 				// silently ignore deleted old choice as no longer valid
712 712
 				if (is_array($member['choices']) && isset($member['choices'][$value])) {
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	protected function doConversionFromPHPToDB($member, &$value, &$links)
770 770
 	{
771 771
 		$links = null;
772
-		switch($member['data_type_ref']) {
772
+		switch ($member['data_type_ref']) {
773 773
 			case 'choice':
774 774
 				// convert from the value array to the key if the array
775 775
 				// the array was returned
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	 * @param array $dataTypes  add to restrict members to certain types
806 806
 	 * @return array the members
807 807
 	 */
808
-	protected function getClassMembers($classType, array $dataTypes=[])
808
+	protected function getClassMembers($classType, array $dataTypes = [])
809 809
 	{
810 810
 		static $_classMembers = [];
811 811
 		if (!array_key_exists($classType, $_classMembers)) {
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	 */
839 839
 	protected function getTableFromClassType($classType)
840 840
 	{
841
-		return 'ddt_' .$this->canonicaliseRef($classType);
841
+		return 'ddt_'.$this->canonicaliseRef($classType);
842 842
 	}
843 843
 
844 844
 	/**
@@ -884,11 +884,11 @@  discard block
 block discarded – undo
884 884
 		$fields = [];
885 885
 		$values = [];
886 886
 		foreach ($row as $f=>$v) {
887
-			$fields[]=$f;
887
+			$fields[] = $f;
888 888
 			$values[] = $this->pdoQuote($v);
889 889
 		}
890 890
 		if (count($fields))
891
-			return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(',', $values)). ');';
891
+			return "REPLACE INTO `$table` (`".(implode('`,`', $fields)).'`) VALUES ('.(implode(',', $values)).');';
892 892
 		return null;
893 893
 	}
894 894
 
Please login to merge, or discard this patch.
Braces   +94 added lines, -64 removed lines patch added patch discarded remove patch
@@ -100,8 +100,9 @@  discard block
 block discarded – undo
100 100
 		$tableName = $this->getTableFromClassType($classType);
101 101
 		$upSql = $this->getDropTableSql($classType);
102 102
 		$downSql = $this->getCreateTableSql($tableName);
103
-		foreach ($upSql as $up)
104
-			neon()->db->createCommand($up)->execute();
103
+		foreach ($upSql as $up) {
104
+					neon()->db->createCommand($up)->execute();
105
+		}
105 106
 		$this->storeMigration($upSql, $downSql);
106 107
 	}
107 108
 
@@ -213,8 +214,9 @@  discard block
 block discarded – undo
213 214
 			default: $type="UNKNOWN STORAGE TYPE $storageType"; break;
214 215
 		}
215 216
 		$collation = $this->getCollation($storageType);
216
-		if ($collation)
217
-			return "$type $collation DEFAULT NULL ";
217
+		if ($collation) {
218
+					return "$type $collation DEFAULT NULL ";
219
+		}
218 220
 		return "$type DEFAULT NULL ";
219 221
 	}
220 222
 
@@ -292,8 +294,9 @@  discard block
 block discarded – undo
292 294
 			self::$_classCache[$ct] = DdsClass::findOne(['class_type' => $ct]);
293 295
 		}
294 296
 		$class = self::$_classCache[$ct];
295
-		if (!$class && $throwException)
296
-			throw new InvalidArgumentException('Unknown class type "'.$ct.'"');
297
+		if (!$class && $throwException) {
298
+					throw new InvalidArgumentException('Unknown class type "'.$ct.'"');
299
+		}
297 300
 		return ($class !== null);
298 301
 	}
299 302
 
@@ -336,32 +339,38 @@  discard block
 block discarded – undo
336 339
 	 */
337 340
 	protected function listMembersForClass($classType, $includeDeleted=false, $keyBy='member_ref')
338 341
 	{
339
-		if (!is_string($classType))
340
-			throw new InvalidArgumentException('The class type $classType parameter should be a string');
342
+		if (!is_string($classType)) {
343
+					throw new InvalidArgumentException('The class type $classType parameter should be a string');
344
+		}
341 345
 		$select = ['member_ref', 'label', 'data_type_ref', 'description', 'choices', 'map_field', 'link_class'];
342
-		if (!empty($keyBy) && !in_array($keyBy, $select))
343
-			throw new InvalidArgumentException('Parameter keyBy must be empty or one of ' .print_r($select, true));
346
+		if (!empty($keyBy) && !in_array($keyBy, $select)) {
347
+					throw new InvalidArgumentException('Parameter keyBy must be empty or one of ' .print_r($select, true));
348
+		}
344 349
 
345 350
 		// see if we have a cached version or getting from the database
346 351
 		if (empty(static::$_classMembersCache[$classType][$includeDeleted])) {
347 352
 			$query = DdsMember::find()->where(['class_type' => $classType]);
348
-			if ($includeDeleted)
349
-				$select[] = 'deleted';
350
-			else
351
-				$query->andWhere(['deleted' => 0]);
353
+			if ($includeDeleted) {
354
+							$select[] = 'deleted';
355
+			} else {
356
+							$query->andWhere(['deleted' => 0]);
357
+			}
352 358
 			$rows = $query->select($select)->orderBy('created')->asArray()->all();
353
-			foreach ($rows as $k=>$r)
354
-				$rows[$k]['choices'] = json_decode($r['choices'], true);
359
+			foreach ($rows as $k=>$r) {
360
+							$rows[$k]['choices'] = json_decode($r['choices'], true);
361
+			}
355 362
 			static::$_classMembersCache[$classType][$includeDeleted] = $rows;
356 363
 		}
357 364
 
358
-		if (empty($keyBy))
359
-			return static::$_classMembersCache[$classType][$includeDeleted];
365
+		if (empty($keyBy)) {
366
+					return static::$_classMembersCache[$classType][$includeDeleted];
367
+		}
360 368
 
361 369
 		// key by a particular ref
362 370
 		$results = [];
363
-		foreach (static::$_classMembersCache[$classType][$includeDeleted] as $r)
364
-			$results[$r[$keyBy]] = $r;
371
+		foreach (static::$_classMembersCache[$classType][$includeDeleted] as $r) {
372
+					$results[$r[$keyBy]] = $r;
373
+		}
365 374
 
366 375
 		return $results;
367 376
 	}
@@ -458,8 +467,9 @@  discard block
 block discarded – undo
458 467
 	{
459 468
 		$parts = explode($separator, $ref);
460 469
 		$canons = [];
461
-		foreach ($parts as $p)
462
-			$canons[] = $this->canonicaliseRef($p);
470
+		foreach ($parts as $p) {
471
+					$canons[] = $this->canonicaliseRef($p);
472
+		}
463 473
 		return implode($separator, $canons);
464 474
 	}
465 475
 
@@ -483,8 +493,9 @@  discard block
 block discarded – undo
483 493
 	 */
484 494
 	protected function canonicaliseFilters($filters)
485 495
 	{
486
-		if (!is_array($filters))
487
-			return [];
496
+		if (!is_array($filters)) {
497
+					return [];
498
+		}
488 499
 		try {
489 500
 			$this->canonicaliseFiltersRecursive($filters);
490 501
 		} catch (InvalidArgumentException $ex) {
@@ -503,20 +514,24 @@  discard block
 block discarded – undo
503 514
 	protected function canonicaliseFiltersRecursive(&$filters)
504 515
 	{
505 516
 		// is this a filter clause or set of filter clauses??
506
-		if (!is_array($filters) || count($filters)==0)
507
-			return;
517
+		if (!is_array($filters) || count($filters)==0) {
518
+					return;
519
+		}
508 520
 
509 521
 		// recursively descend until one finds a filter clause
510 522
 		if (is_array($filters[0])) {
511
-			foreach ($filters as &$f)
512
-				$this->canonicaliseFiltersRecursive($f);
523
+			foreach ($filters as &$f) {
524
+							$this->canonicaliseFiltersRecursive($f);
525
+			}
513 526
 			return;
514 527
 		}
515 528
 		// so canonicalise a filter clause
516
-		if (array_key_exists(0, $filters))
517
-			$this->canonicaliseFilter($filters[0],0);
518
-		if (array_key_exists(1, $filters))
519
-			$this->canonicaliseFilter($filters[1],1);
529
+		if (array_key_exists(0, $filters)) {
530
+					$this->canonicaliseFilter($filters[0],0);
531
+		}
532
+		if (array_key_exists(1, $filters)) {
533
+					$this->canonicaliseFilter($filters[1],1);
534
+		}
520 535
 
521 536
 		// Handle nulls passed as values
522 537
 		// ['field', '=', null] and ['field', '!=', null]
@@ -593,8 +608,9 @@  discard block
 block discarded – undo
593 608
 			['AND', 'and', 'NOT', 'not', 'OR', 'or', ' ', ')', '('],
594 609
 			'', $subLogic
595 610
 		);
596
-		if (strlen($subLogic)>0)
597
-			throw new InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true). ' for a logic statement of ' .print_r($logic, true). ' The remaining characters are ' .print_r($subLogic, true));
611
+		if (strlen($subLogic)>0) {
612
+					throw new InvalidArgumentException("Daedalus: Invalid logic operator provided. Maybe you haven't defined all keys or have other logic than 'AND', 'OR', 'NOT' and '(',')' characters in your logic? You have defined the keys as ".print_r($keys, true). ' for a logic statement of ' .print_r($logic, true). ' The remaining characters are ' .print_r($subLogic, true));
613
+		}
598 614
 		return $logic;
599 615
 	}
600 616
 
@@ -630,10 +646,11 @@  discard block
 block discarded – undo
630 646
 				switch ($drn) {
631 647
 					case 'ASC': case 'DESC':
632 648
 						// allow -ve key starts for nulls last in MySql
633
-						if (strpos($k,'-') === 0)
634
-							$canon['-'.$this->quoteField($k)] = $drn;
635
-						else
636
-							$canon[$this->quoteField($k)] = $drn;
649
+						if (strpos($k,'-') === 0) {
650
+													$canon['-'.$this->quoteField($k)] = $drn;
651
+						} else {
652
+													$canon[$this->quoteField($k)] = $drn;
653
+						}
637 654
 					break;
638 655
 					case 'RAND':
639 656
 						$canon['RAND'] = 'RAND';
@@ -721,14 +738,16 @@  discard block
 block discarded – undo
721 738
 				if (!empty($choices) && is_array($choices)) {
722 739
 					foreach ($choices as $choice) {
723 740
 						// silently ignore deleted old choice as no longer valid
724
-						if (isset($member['choices'][$choice]))
725
-							$value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]];
741
+						if (isset($member['choices'][$choice])) {
742
+													$value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]];
743
+						}
726 744
 					}
727 745
 				}
728 746
 			break;
729 747
 			case 'boolean':
730
-				if ($value === NULL)
731
-					return;
748
+				if ($value === NULL) {
749
+									return;
750
+				}
732 751
 				$value = !!$value;
733 752
 			break;
734 753
 			case 'json': $value = json_decode($value, true); break;
@@ -753,8 +772,9 @@  discard block
 block discarded – undo
753 772
 			$itemLinks = null;
754 773
 			if (isset($members[$key])) {
755 774
 				$this->doConversionFromPHPToDB($members[$key], $value, $itemLinks);
756
-				if ($itemLinks !== null)
757
-					$links[$key] = $itemLinks;
775
+				if ($itemLinks !== null) {
776
+									$links[$key] = $itemLinks;
777
+				}
758 778
 			}
759 779
 		}
760 780
 	}
@@ -773,16 +793,18 @@  discard block
 block discarded – undo
773 793
 			case 'choice':
774 794
 				// convert from the value array to the key if the array
775 795
 				// the array was returned
776
-				if (is_array($value) && isset($value['key']))
777
-					$value = $value['key'];
796
+				if (is_array($value) && isset($value['key'])) {
797
+									$value = $value['key'];
798
+				}
778 799
 			break;
779 800
 			case 'choice_multiple':
780 801
 				$value = json_encode($value);
781 802
 			break;
782 803
 			case 'boolean':
783 804
 				// check for null values
784
-				if ($value === null)
785
-					return;
805
+				if ($value === null) {
806
+									return;
807
+				}
786 808
 				// convert from truthy to database 1 or 0
787 809
 				$value = $value ? 1 : 0;
788 810
 			break;
@@ -814,19 +836,22 @@  discard block
 block discarded – undo
814 836
 				// make sure model afterFind has been run
815 837
 				$members = DdsMember::find()->where(['class_type'=>$classType])->all();
816 838
 				$membersByRef = [];
817
-				foreach ($members as $member)
818
-					$membersByRef[$member['member_ref']] = $member->attributes;
839
+				foreach ($members as $member) {
840
+									$membersByRef[$member['member_ref']] = $member->attributes;
841
+				}
819 842
 				$_classMembers[$classType] = $membersByRef;
820 843
 			} catch (Exception $e) {
821 844
 				throw new InvalidArgumentException("Error attempting to get members for $classType.");
822 845
 			}
823 846
 		}
824
-		if (empty($dataTypes))
825
-			return $_classMembers[$classType];
847
+		if (empty($dataTypes)) {
848
+					return $_classMembers[$classType];
849
+		}
826 850
 		$dataMembers = [];
827 851
 		foreach ($_classMembers[$classType] as $k=>$m) {
828
-			if (in_array($m['data_type_ref'], $dataTypes))
829
-				$dataMembers[$k] = $m;
852
+			if (in_array($m['data_type_ref'], $dataTypes)) {
853
+							$dataMembers[$k] = $m;
854
+			}
830 855
 		}
831 856
 		return $dataMembers;
832 857
 	}
@@ -879,16 +904,18 @@  discard block
 block discarded – undo
879 904
 	 */
880 905
 	protected function getTableRowReplaceSql($table, $row)
881 906
 	{
882
-		if (!is_array($row))
883
-			$row = $row->toArray();
907
+		if (!is_array($row)) {
908
+					$row = $row->toArray();
909
+		}
884 910
 		$fields = [];
885 911
 		$values = [];
886 912
 		foreach ($row as $f=>$v) {
887 913
 			$fields[]=$f;
888 914
 			$values[] = $this->pdoQuote($v);
889 915
 		}
890
-		if (count($fields))
891
-			return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(',', $values)). ');';
916
+		if (count($fields)) {
917
+					return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(',', $values)). ');';
918
+		}
892 919
 		return null;
893 920
 	}
894 921
 
@@ -899,10 +926,12 @@  discard block
 block discarded – undo
899 926
 	 */
900 927
 	private function pdoQuote($value)
901 928
 	{
902
-		if (is_array($value))
903
-			$value = json_encode($value);
904
-		if (is_null($value))
905
-			return 'null';
929
+		if (is_array($value)) {
930
+					$value = json_encode($value);
931
+		}
932
+		if (is_null($value)) {
933
+					return 'null';
934
+		}
906 935
 		return neon()->db->pdo->quote($value);
907 936
 	}
908 937
 
@@ -937,8 +966,9 @@  discard block
 block discarded – undo
937 966
 	protected function areUUIDs(array $candidates)
938 967
 	{
939 968
 		foreach ($candidates as $candidate) {
940
-			if (!$this->isUUID($candidate))
941
-				return false;
969
+			if (!$this->isUUID($candidate)) {
970
+							return false;
971
+			}
942 972
 		}
943 973
 		return true;
944 974
 	}
Please login to merge, or discard this patch.
neon/user/forms/Login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
129 129
 	 * @param boolean $activeOnly whether to fetch only active users
130 130
 	 * @return User|null
131 131
 	 */
132
-	public function getUser($activeOnly=false)
132
+	public function getUser($activeOnly = false)
133 133
 	{
134 134
 		if ($this->_user === false) {
135 135
 			$this->_user = call_user_func(
Please login to merge, or discard this patch.
neon/user/forms/PasswordReset.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@
 block discarded – undo
49 49
 		if ($hasExpired) {
50 50
 			throw new InvalidArgumentException('This password reset token has expired.');
51 51
 		}
52
-		if ( !$this->_user ) {
52
+		if (!$this->_user) {
53 53
 			throw new InvalidArgumentException('Wrong password reset token.');
54 54
 		}
55 55
 		parent::__construct($config);
Please login to merge, or discard this patch.