@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | /** |
| 34 | 34 | * @inheritdoc |
| 35 | 35 | */ |
| 36 | - public function processAsFilter(IQuery $query, $searchData=null) |
|
| 36 | + public function processAsFilter(IQuery $query, $searchData = null) |
|
| 37 | 37 | { |
| 38 | 38 | $searchData = ($searchData === null) ? $this->getValue() : $searchData; |
| 39 | 39 | if (!empty($searchData)) { |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | public function getComponentDetails() |
| 60 | 60 | { |
| 61 | 61 | return [ |
| 62 | - 'label' => 'Colour', 'icon' => 'fa fa-paint-brush', 'group' => 'Text', 'order' => 170, |
|
| 62 | + 'label' => 'Colour', 'icon' => 'fa fa-paint-brush', 'group' => 'Text', 'order' => 170, |
|
| 63 | 63 | ]; |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | \ No newline at end of file |
@@ -99,9 +99,9 @@ |
||
| 99 | 99 | * or if you force it to return a total (this should be |
| 100 | 100 | * avoided if possible as counts are very expensive operations) |
| 101 | 101 | */ |
| 102 | - public function returnTotal(bool $force=false) |
|
| 102 | + public function returnTotal(bool $force = false) |
|
| 103 | 103 | { |
| 104 | - $this->_returnTotal=($force? true : ($this->_start == 0)); |
|
| 104 | + $this->_returnTotal = ($force ? true : ($this->_start == 0)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -100,8 +100,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 'ASC_L': |
| 639 | 656 | $canon[$k] = 'ASC'; |
@@ -727,14 +744,16 @@ discard block |
||
| 727 | 744 | if (!empty($choices) && is_array($choices)) { |
| 728 | 745 | foreach ($choices as $choice) { |
| 729 | 746 | // silently ignore deleted old choice as no longer valid |
| 730 | - if (isset($member['choices'][$choice])) |
|
| 731 | - $value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]]; |
|
| 747 | + if (isset($member['choices'][$choice])) { |
|
| 748 | + $value[] = ['key'=>$choice, 'value'=>$member['choices'][$choice]]; |
|
| 749 | + } |
|
| 732 | 750 | } |
| 733 | 751 | } |
| 734 | 752 | break; |
| 735 | 753 | case 'boolean': |
| 736 | - if ($value === NULL) |
|
| 737 | - return; |
|
| 754 | + if ($value === NULL) { |
|
| 755 | + return; |
|
| 756 | + } |
|
| 738 | 757 | $value = !!$value; |
| 739 | 758 | break; |
| 740 | 759 | case 'json': $value = json_decode($value, true); break; |
@@ -759,8 +778,9 @@ discard block |
||
| 759 | 778 | $itemLinks = null; |
| 760 | 779 | if (isset($members[$key])) { |
| 761 | 780 | $this->doConversionFromPHPToDB($members[$key], $value, $itemLinks); |
| 762 | - if ($itemLinks !== null) |
|
| 763 | - $links[$key] = $itemLinks; |
|
| 781 | + if ($itemLinks !== null) { |
|
| 782 | + $links[$key] = $itemLinks; |
|
| 783 | + } |
|
| 764 | 784 | } |
| 765 | 785 | } |
| 766 | 786 | } |
@@ -779,16 +799,18 @@ discard block |
||
| 779 | 799 | case 'choice': |
| 780 | 800 | // convert from the value array to the key if the array |
| 781 | 801 | // the array was returned |
| 782 | - if (is_array($value) && isset($value['key'])) |
|
| 783 | - $value = $value['key']; |
|
| 802 | + if (is_array($value) && isset($value['key'])) { |
|
| 803 | + $value = $value['key']; |
|
| 804 | + } |
|
| 784 | 805 | break; |
| 785 | 806 | case 'choice_multiple': |
| 786 | 807 | $value = json_encode($value); |
| 787 | 808 | break; |
| 788 | 809 | case 'boolean': |
| 789 | 810 | // check for null values |
| 790 | - if ($value === null) |
|
| 791 | - return; |
|
| 811 | + if ($value === null) { |
|
| 812 | + return; |
|
| 813 | + } |
|
| 792 | 814 | // convert from truthy to database 1 or 0 |
| 793 | 815 | $value = $value ? 1 : 0; |
| 794 | 816 | break; |
@@ -820,19 +842,22 @@ discard block |
||
| 820 | 842 | // make sure model afterFind has been run |
| 821 | 843 | $members = DdsMember::find()->where(['class_type'=>$classType])->all(); |
| 822 | 844 | $membersByRef = []; |
| 823 | - foreach ($members as $member) |
|
| 824 | - $membersByRef[$member['member_ref']] = $member->attributes; |
|
| 845 | + foreach ($members as $member) { |
|
| 846 | + $membersByRef[$member['member_ref']] = $member->attributes; |
|
| 847 | + } |
|
| 825 | 848 | $_classMembers[$classType] = $membersByRef; |
| 826 | 849 | } catch (Exception $e) { |
| 827 | 850 | throw new InvalidArgumentException("Error attempting to get members for $classType."); |
| 828 | 851 | } |
| 829 | 852 | } |
| 830 | - if (empty($dataTypes)) |
|
| 831 | - return $_classMembers[$classType]; |
|
| 853 | + if (empty($dataTypes)) { |
|
| 854 | + return $_classMembers[$classType]; |
|
| 855 | + } |
|
| 832 | 856 | $dataMembers = []; |
| 833 | 857 | foreach ($_classMembers[$classType] as $k=>$m) { |
| 834 | - if (in_array($m['data_type_ref'], $dataTypes)) |
|
| 835 | - $dataMembers[$k] = $m; |
|
| 858 | + if (in_array($m['data_type_ref'], $dataTypes)) { |
|
| 859 | + $dataMembers[$k] = $m; |
|
| 860 | + } |
|
| 836 | 861 | } |
| 837 | 862 | return $dataMembers; |
| 838 | 863 | } |
@@ -885,16 +910,18 @@ discard block |
||
| 885 | 910 | */ |
| 886 | 911 | protected function getTableRowReplaceSql($table, $row) |
| 887 | 912 | { |
| 888 | - if (!is_array($row)) |
|
| 889 | - $row = $row->toArray(); |
|
| 913 | + if (!is_array($row)) { |
|
| 914 | + $row = $row->toArray(); |
|
| 915 | + } |
|
| 890 | 916 | $fields = []; |
| 891 | 917 | $values = []; |
| 892 | 918 | foreach ($row as $f=>$v) { |
| 893 | 919 | $fields[]=$f; |
| 894 | 920 | $values[] = $this->pdoQuote($v); |
| 895 | 921 | } |
| 896 | - if (count($fields)) |
|
| 897 | - return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(',', $values)). ');'; |
|
| 922 | + if (count($fields)) { |
|
| 923 | + return "REPLACE INTO `$table` (`".(implode('`,`',$fields)).'`) VALUES ('.(implode(',', $values)). ');'; |
|
| 924 | + } |
|
| 898 | 925 | return null; |
| 899 | 926 | } |
| 900 | 927 | |
@@ -905,10 +932,12 @@ discard block |
||
| 905 | 932 | */ |
| 906 | 933 | private function pdoQuote($value) |
| 907 | 934 | { |
| 908 | - if (is_array($value)) |
|
| 909 | - $value = json_encode($value); |
|
| 910 | - if (is_null($value)) |
|
| 911 | - return 'null'; |
|
| 935 | + if (is_array($value)) { |
|
| 936 | + $value = json_encode($value); |
|
| 937 | + } |
|
| 938 | + if (is_null($value)) { |
|
| 939 | + return 'null'; |
|
| 940 | + } |
|
| 912 | 941 | return neon()->db->pdo->quote($value); |
| 913 | 942 | } |
| 914 | 943 | |
@@ -943,8 +972,9 @@ discard block |
||
| 943 | 972 | protected function areUUIDs(array $candidates) |
| 944 | 973 | { |
| 945 | 974 | foreach ($candidates as $candidate) { |
| 946 | - if (!$this->isUUID($candidate)) |
|
| 947 | - return false; |
|
| 975 | + if (!$this->isUUID($candidate)) { |
|
| 976 | + return false; |
|
| 977 | + } |
|
| 948 | 978 | } |
| 949 | 979 | return true; |
| 950 | 980 | } |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public function getThemeAlias() |
| 234 | 234 | { |
| 235 | - return '@root/themes/' . $this->getThemeName(); |
|
| 235 | + return '@root/themes/'.$this->getThemeName(); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @inheritdoc |
| 276 | 276 | * @unsupported - $filters is not currently supported |
| 277 | 277 | */ |
| 278 | - public function getDataMap($key, $query='', $filters=[], $fields=[], $start = 0, $limit = 100) |
|
| 278 | + public function getDataMap($key, $query = '', $filters = [], $fields = [], $start = 0, $limit = 100) |
|
| 279 | 279 | { |
| 280 | 280 | if ($key === 'pages') { |
| 281 | 281 | return $this->getPagesMap($query, $filters, $fields, $start, $limit); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | public function formatPageMapResults($pages, $fields) |
| 330 | 330 | { |
| 331 | - return collect($pages)->mapWithKeys(function ($item) use($fields) { |
|
| 331 | + return collect($pages)->mapWithKeys(function($item) use($fields) { |
|
| 332 | 332 | if (empty($fields)) |
| 333 | 333 | return [$item['id'] => "$item[title] (nice=$item[nice_id])"]; |
| 334 | 334 | return [$item['id'] => $item]; |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | * @param array $fields |
| 359 | 359 | * @return array - @see $this->formatPageMapResults(); |
| 360 | 360 | */ |
| 361 | - public function getPagesMap($query=null, $filters=[], $fields=[], $start=0, $limit=100) |
|
| 361 | + public function getPagesMap($query = null, $filters = [], $fields = [], $start = 0, $limit = 100) |
|
| 362 | 362 | { |
| 363 | 363 | $pages = CmsPage::find() |
| 364 | 364 | ->select(array_merge(['id', 'nice_id', 'title'], $fields)) |
@@ -392,10 +392,10 @@ discard block |
||
| 392 | 392 | */ |
| 393 | 393 | private function checkThemeName($name) |
| 394 | 394 | { |
| 395 | - if ( preg_match('/[^A-Za-z0-9_-]/', $name, $matches) ) { |
|
| 395 | + if (preg_match('/[^A-Za-z0-9_-]/', $name, $matches)) { |
|
| 396 | 396 | throw new \InvalidArgumentException("Error trying to set the theme name to '$name'" |
| 397 | 397 | ."\n"."The theme name must consist of only 'a-z', '0-9', '_' and '-' characters." |
| 398 | - ."\n".'The following character is not allowed in theme names: ' . \yii\helpers\VarDumper::dumpAsString($matches[0]) ); |
|
| 398 | + ."\n".'The following character is not allowed in theme names: '.\yii\helpers\VarDumper::dumpAsString($matches[0])); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | |
@@ -171,11 +171,13 @@ discard block |
||
| 171 | 171 | public function getThemeHierarchy() |
| 172 | 172 | { |
| 173 | 173 | // if we have a theme hierarchy use that |
| 174 | - if (count($this->_themeHierarchy)) |
|
| 175 | - return $this->_themeHierarchy; |
|
| 174 | + if (count($this->_themeHierarchy)) { |
|
| 175 | + return $this->_themeHierarchy; |
|
| 176 | + } |
|
| 176 | 177 | // otherwise drop back to the themeName |
| 177 | - if (!empty($this->_themeName)) |
|
| 178 | - return [$this->_themeName]; |
|
| 178 | + if (!empty($this->_themeName)) { |
|
| 179 | + return [$this->_themeName]; |
|
| 180 | + } |
|
| 179 | 181 | // otherwise return nothing |
| 180 | 182 | return []; |
| 181 | 183 | } |
@@ -248,7 +250,9 @@ discard block |
||
| 248 | 250 | public function themeAssetUrl($path) |
| 249 | 251 | { |
| 250 | 252 | // loading external resource so just return |
| 251 | - if (Str::startsWith($path, 'http')) return $path; |
|
| 253 | + if (Str::startsWith($path, 'http')) { |
|
| 254 | + return $path; |
|
| 255 | + } |
|
| 252 | 256 | list($assetPath, $assetUrl) = $this->publishThemeAssets(); |
| 253 | 257 | $path = ltrim($path, '/'); |
| 254 | 258 | $assetUrl = ltrim($assetUrl, '/'); |
@@ -316,8 +320,9 @@ discard block |
||
| 316 | 320 | */ |
| 317 | 321 | public function getMapResults($requestKey) |
| 318 | 322 | { |
| 319 | - if (!isset($this->_mapRequestKey[$requestKey])) |
|
| 320 | - throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
| 323 | + if (!isset($this->_mapRequestKey[$requestKey])) { |
|
| 324 | + throw new \InvalidArgumentException('The provided request key "'.$requestKey.'" does not exist'); |
|
| 325 | + } |
|
| 321 | 326 | list($key, $ids, $fields) = $this->_mapRequestKey[$requestKey]; |
| 322 | 327 | if ($key === 'pages') { |
| 323 | 328 | $pages = CmsPage::find()->select(array_merge(['id', 'nice_id', 'title'], $fields)) |
@@ -353,8 +358,9 @@ discard block |
||
| 353 | 358 | public function formatPageMapResults($pages, $fields) |
| 354 | 359 | { |
| 355 | 360 | return collect($pages)->mapWithKeys(function ($item) use($fields) { |
| 356 | - if (empty($fields)) |
|
| 357 | - return [$item['id'] => "$item[title] (nice=$item[nice_id])"]; |
|
| 361 | + if (empty($fields)) { |
|
| 362 | + return [$item['id'] => "$item[title] (nice=$item[nice_id])"]; |
|
| 363 | + } |
|
| 358 | 364 | return [$item['id'] => $item]; |
| 359 | 365 | })->all(); |
| 360 | 366 | } |
@@ -23,7 +23,9 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public static function editor($params, $content, \Smarty_Internal_Template $template, &$repeat) |
| 25 | 25 | { |
| 26 | - if ($repeat) return; |
|
| 26 | + if ($repeat) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 27 | 29 | $id = Arr::get($params, 'id', neon()->cms->getPage()->getId()); |
| 28 | 30 | |
| 29 | 31 | |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | $this->addColumn('og_image')->setTitle('Social')->setWidth('100px')->setMember(new \neon\core\form\fields\Image('og_image')); |
| 55 | 55 | |
| 56 | 56 | $this->addButtonColumn('edit') |
| 57 | - ->addButton('edit', ['/cms/editor/index' , 'id' => '{{nice_id}}'], '', '', '', ['data-toggle' => 'tooltip', 'title'=>'Edit']); |
|
| 57 | + ->addButton('edit', ['/cms/editor/index', 'id' => '{{nice_id}}'], '', '', '', ['data-toggle' => 'tooltip', 'title'=>'Edit']); |
|
| 58 | 58 | |
| 59 | 59 | $this->addScope('published', 'Published'); |
| 60 | 60 | $this->addScope('draft', 'Draft'); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function renderTitle($model) |
| 80 | 80 | { |
| 81 | - return '<div style="font-weight:600;">' . $model['title'] . '</div><div stlye="margin-top:4px;">' . $model['description'] . '</div>'; |
|
| 81 | + return '<div style="font-weight:600;">'.$model['title'].'</div><div stlye="margin-top:4px;">'.$model['description'].'</div>'; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | public function renderUrl($model, $key, $index, $column) |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | use \Carbon\Carbon; |
| 18 | 18 | use neon\core\helpers\Url; |
| 19 | 19 | |
| 20 | -if (! function_exists('dp')) { |
|
| 20 | +if (!function_exists('dp')) { |
|
| 21 | 21 | /** |
| 22 | 22 | * Debug function. Prints all passed in arguments to the screen. |
| 23 | 23 | * arguments containing objects or arrays are output using print_r |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | -if (! function_exists('backtrace_line_by_function')) { |
|
| 42 | +if (!function_exists('backtrace_line_by_function')) { |
|
| 43 | 43 | /** |
| 44 | 44 | * Tries to get the line and file that called the specified functions |
| 45 | 45 | * - will return the earliest match in execution order that it found. |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | { |
| 52 | 52 | $bt = debug_backtrace(); |
| 53 | 53 | $lineInfo = ''; |
| 54 | - foreach($bt as $trace) { |
|
| 54 | + foreach ($bt as $trace) { |
|
| 55 | 55 | if (isset($trace['function']) && $trace['function'] === $functionToShow) { |
| 56 | - $lineInfo = '==> [' . (isset($trace['file']) ? $trace['file'] : ' unknown file '). ':' . (isset($trace['line']) ? $trace['line'] : ' unknown line ' ) . ']'; |
|
| 56 | + $lineInfo = '==> ['.(isset($trace['file']) ? $trace['file'] : ' unknown file ').':'.(isset($trace['line']) ? $trace['line'] : ' unknown line ').']'; |
|
| 57 | 57 | break; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | -if (! function_exists('dp_string')) { |
|
| 64 | +if (!function_exists('dp_string')) { |
|
| 65 | 65 | /** |
| 66 | 66 | * This generates a nice debug string and returns it. It will only |
| 67 | 67 | * print to the screen if you are in debug mode. Otherwise it prints |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | -if (! function_exists('dd')) { |
|
| 96 | +if (!function_exists('dd')) { |
|
| 97 | 97 | /** |
| 98 | 98 | * This is the same as the dp (debug print) function but exits after |
| 99 | 99 | * **Note:** If not in debug will print to log error and not exit |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | -if (! function_exists('debug_message')) { |
|
| 116 | +if (!function_exists('debug_message')) { |
|
| 117 | 117 | /** |
| 118 | 118 | * This is the same as the dp_string (debug print) function however it returns the string |
| 119 | 119 | * The main difference is that it will only output a message if neon is in debug mode |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
| 135 | -if (! function_exists('neon')) { |
|
| 135 | +if (!function_exists('neon')) { |
|
| 136 | 136 | /** |
| 137 | 137 | * Shortcut method to ```\Neon::$app``` |
| 138 | 138 | * @param string $name |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | -if (! function_exists('setting')) { |
|
| 147 | +if (!function_exists('setting')) { |
|
| 148 | 148 | /** |
| 149 | 149 | * Get a setting value |
| 150 | 150 | * |
@@ -155,13 +155,13 @@ discard block |
||
| 155 | 155 | * the setting has been set in the current session |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - function setting($app, $name, $default=null, $refresh=false) |
|
| 158 | + function setting($app, $name, $default = null, $refresh = false) |
|
| 159 | 159 | { |
| 160 | 160 | return neon()->getSettingsManager()->get($app, $name, $default, $refresh); |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | -if (! function_exists('set_setting')) { |
|
| 164 | +if (!function_exists('set_setting')) { |
|
| 165 | 165 | /** |
| 166 | 166 | * @param string $app the app responsible for this setting |
| 167 | 167 | * @param string $name the setting name |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | -if (! function_exists('url')) { |
|
| 177 | +if (!function_exists('url')) { |
|
| 178 | 178 | /** |
| 179 | 179 | * Alias of \neon\core\helpers\Url::to |
| 180 | 180 | * @see \neon\core\helpers\Url::to() |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | -if (! function_exists('url_base')) { |
|
| 200 | +if (!function_exists('url_base')) { |
|
| 201 | 201 | /** |
| 202 | 202 | * Returns the base URL of the current request. |
| 203 | 203 | * @param boolean|string $scheme the URI scheme to use in the returned base URL: |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | |
| 216 | -if (! function_exists('to_bytes')) { |
|
| 216 | +if (!function_exists('to_bytes')) { |
|
| 217 | 217 | /** |
| 218 | 218 | * Returns the number of bytes as integer from a strings like `128K` | `128M` | `2G` | `1T` | `1P` |
| 219 | 219 | * |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | -if (! function_exists('format_bytes')) { |
|
| 228 | +if (!function_exists('format_bytes')) { |
|
| 229 | 229 | /** |
| 230 | 230 | * Output a formatted size like '128M' from bytes. |
| 231 | 231 | * |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | -if (! function_exists('truthy')) { |
|
| 241 | +if (!function_exists('truthy')) { |
|
| 242 | 242 | /** |
| 243 | 243 | * Php if statement handles truthy and falsey string conversions by default e.g. evaluating a '0' string to false |
| 244 | 244 | * however a string of 'false' is evaluated as true. This function resolves that difference. This should be used |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | -if (! function_exists('env')) { |
|
| 257 | +if (!function_exists('env')) { |
|
| 258 | 258 | /** |
| 259 | 259 | * Gets the value of an environment variable. |
| 260 | 260 | * Interprets 'true', 'false', 'empty' and 'null' strings appropriately |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | -if (! function_exists('neon_secret')) { |
|
| 292 | +if (!function_exists('neon_secret')) { |
|
| 293 | 293 | /** |
| 294 | 294 | * Gets the value of NEON_SECRET creating it if missing |
| 295 | 295 | * @return string |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | -if (! function_exists('neon_encryption_key')) { |
|
| 302 | +if (!function_exists('neon_encryption_key')) { |
|
| 303 | 303 | /** |
| 304 | 304 | * Gets the value of NEON_SECRET creating it if missing |
| 305 | 305 | * @return string |
@@ -309,7 +309,7 @@ discard block |
||
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | -if (! function_exists('value')) { |
|
| 312 | +if (!function_exists('value')) { |
|
| 313 | 313 | /** |
| 314 | 314 | * Return the value of the given value. |
| 315 | 315 | * If the $value is a Closure, it will first be executed then its result returned |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | -if (! function_exists('collect')) { |
|
| 326 | +if (!function_exists('collect')) { |
|
| 327 | 327 | /** |
| 328 | 328 | * Create a collection from the given value. |
| 329 | 329 | * |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -if (! function_exists('now')) { |
|
| 339 | +if (!function_exists('now')) { |
|
| 340 | 340 | /** |
| 341 | 341 | * Create a new Carbon instance for the current time. |
| 342 | 342 | * |
@@ -349,27 +349,27 @@ discard block |
||
| 349 | 349 | } |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | -if (! function_exists('profile_begin')) { |
|
| 352 | +if (!function_exists('profile_begin')) { |
|
| 353 | 353 | /** |
| 354 | 354 | * @param string $name |
| 355 | 355 | */ |
| 356 | - function profile_begin($name, $category='neon') |
|
| 356 | + function profile_begin($name, $category = 'neon') |
|
| 357 | 357 | { |
| 358 | 358 | \Neon::beginProfile($name, $category); |
| 359 | 359 | } |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | -if (! function_exists('profile_end')) { |
|
| 362 | +if (!function_exists('profile_end')) { |
|
| 363 | 363 | /** |
| 364 | 364 | * @param string $name |
| 365 | 365 | */ |
| 366 | - function profile_end($name=null, $category='neon') |
|
| 366 | + function profile_end($name = null, $category = 'neon') |
|
| 367 | 367 | { |
| 368 | 368 | \Neon::endProfile($name, $category); |
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | -if (! function_exists('encrypt')) { |
|
| 372 | +if (!function_exists('encrypt')) { |
|
| 373 | 373 | /** |
| 374 | 374 | * @param string $data |
| 375 | 375 | * @return string - encrypted data |
@@ -380,7 +380,7 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | } |
| 382 | 382 | |
| 383 | -if (! function_exists('decrypt')) { |
|
| 383 | +if (!function_exists('decrypt')) { |
|
| 384 | 384 | /** |
| 385 | 385 | * @param string $data |
| 386 | 386 | * @return string - encrypted data |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | -if (! function_exists('get_alias')) { |
|
| 394 | +if (!function_exists('get_alias')) { |
|
| 395 | 395 | /** |
| 396 | 396 | * @param string $path |
| 397 | 397 | * @return string - resolved path |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | } |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | -if (! function_exists('on_url')) { |
|
| 405 | +if (!function_exists('on_url')) { |
|
| 406 | 406 | /** |
| 407 | 407 | * This function is useful for checking if links should be active, |
| 408 | 408 | * |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | return \neon\core\helpers\Url::isUrl(...$urls); |
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | -if (! function_exists('_t')) { |
|
| 425 | +if (!function_exists('_t')) { |
|
| 426 | 426 | /** |
| 427 | 427 | * Translates a message to the target language |
| 428 | 428 | * This function is a wrapper to the \Neon::t method |
@@ -442,12 +442,12 @@ discard block |
||
| 442 | 442 | * @param string $category if provided will save the text to that category. Defaults to 'neon' |
| 443 | 443 | * @return string the translated message. |
| 444 | 444 | */ |
| 445 | - function _t($text, $params=[], $category='neon') |
|
| 445 | + function _t($text, $params = [], $category = 'neon') |
|
| 446 | 446 | { |
| 447 | 447 | return \Neon::t($category, $text, $params); |
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | -if (! function_exists('faker')) { |
|
| 450 | +if (!function_exists('faker')) { |
|
| 451 | 451 | /** |
| 452 | 452 | * Generate a faker object |
| 453 | 453 | * @return \Faker\Generator; |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | return $faker; |
| 461 | 461 | } |
| 462 | 462 | } |
| 463 | -if (! function_exists('user_is')) { |
|
| 463 | +if (!function_exists('user_is')) { |
|
| 464 | 464 | /** |
| 465 | 465 | * @return boolean whether the user is/has a particular role |
| 466 | 466 | */ |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | -if (! function_exists('user_can')) { |
|
| 473 | +if (!function_exists('user_can')) { |
|
| 474 | 474 | /** |
| 475 | 475 | * Whether the user can perform a permission |
| 476 | 476 | * @param $permission |
@@ -481,18 +481,18 @@ discard block |
||
| 481 | 481 | return neon()->user->can($permission); |
| 482 | 482 | } |
| 483 | 483 | } |
| 484 | -if (! function_exists('uuid')) { |
|
| 484 | +if (!function_exists('uuid')) { |
|
| 485 | 485 | /** |
| 486 | 486 | * Generate a universally unique id |
| 487 | 487 | * @param string $separator - default '-' |
| 488 | 488 | * @return bool |
| 489 | 489 | */ |
| 490 | - function uuid($separator='-') |
|
| 490 | + function uuid($separator = '-') |
|
| 491 | 491 | { |
| 492 | 492 | return \neon\core\helpers\Hash::uuid($separator); |
| 493 | 493 | } |
| 494 | 494 | } |
| 495 | -if (! function_exists('uuid64')) { |
|
| 495 | +if (!function_exists('uuid64')) { |
|
| 496 | 496 | /** |
| 497 | 497 | * Generate a universally unique id in base64 |
| 498 | 498 | * @return bool |
@@ -502,7 +502,7 @@ discard block |
||
| 502 | 502 | return \neon\core\helpers\Hash::uuid64(); |
| 503 | 503 | } |
| 504 | 504 | } |
| 505 | -if (! function_exists('id')) { |
|
| 505 | +if (!function_exists('id')) { |
|
| 506 | 506 | /** |
| 507 | 507 | * Generate a html friendly UUID64 |
| 508 | 508 | * @return string |
@@ -512,7 +512,7 @@ discard block |
||
| 512 | 512 | return \neon\core\helpers\Hash::id(); |
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | -if (! function_exists('is_route')) { |
|
| 515 | +if (!function_exists('is_route')) { |
|
| 516 | 516 | /** |
| 517 | 517 | * Test whether the current application is on a particular route |
| 518 | 518 | * This is url rewrite safe! However you must reference the module/controller/action and not the url directly |
@@ -523,12 +523,12 @@ discard block |
||
| 523 | 523 | * @param array $params |
| 524 | 524 | * @return boolean - whether on the route |
| 525 | 525 | */ |
| 526 | - function is_route($pattern, $params=[]) |
|
| 526 | + function is_route($pattern, $params = []) |
|
| 527 | 527 | { |
| 528 | 528 | return neon()->request->isRoute($pattern, $params); |
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | -if (! function_exists('abort')) { |
|
| 531 | +if (!function_exists('abort')) { |
|
| 532 | 532 | /** |
| 533 | 533 | * Throw a HttpException with the given data. |
| 534 | 534 | * |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | } |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | -if (! function_exists('abort_if')) { |
|
| 547 | +if (!function_exists('abort_if')) { |
|
| 548 | 548 | /** |
| 549 | 549 | * Throw a HttpException with the given data if the given condition is true. |
| 550 | 550 | * |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | } |
| 563 | 563 | } |
| 564 | 564 | } |
| 565 | -if (! function_exists('request')) { |
|
| 565 | +if (!function_exists('request')) { |
|
| 566 | 566 | /** |
| 567 | 567 | * Get an instance of the current request or an input item from the request. |
| 568 | 568 | * |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | return is_null($value) ? value($default) : $value; |
| 582 | 582 | } |
| 583 | 583 | } |
| 584 | -if (! function_exists('object_get')) { |
|
| 584 | +if (!function_exists('object_get')) { |
|
| 585 | 585 | /** |
| 586 | 586 | * Get an item from an object using "dot" notation. |
| 587 | 587 | * |
@@ -597,7 +597,7 @@ discard block |
||
| 597 | 597 | } |
| 598 | 598 | |
| 599 | 599 | foreach (explode('.', $key) as $segment) { |
| 600 | - if (! is_object($object) || ! isset($object->{$segment})) { |
|
| 600 | + if (!is_object($object) || !isset($object->{$segment})) { |
|
| 601 | 601 | return value($default); |
| 602 | 602 | } |
| 603 | 603 | |