@@ -303,8 +303,8 @@ |
||
| 303 | 303 | */ |
| 304 | 304 | protected function classCanBeIncluded(string $dataObjectClassName): bool |
| 305 | 305 | { |
| 306 | - if(count($this->excludedClasses)) { |
|
| 307 | - if(!class_exists($dataObjectClassName)) { |
|
| 306 | + if (count($this->excludedClasses)) { |
|
| 307 | + if (!class_exists($dataObjectClassName)) { |
|
| 308 | 308 | return false; |
| 309 | 309 | } |
| 310 | 310 | return !in_array($dataObjectClassName, $this->excludedClasses, true); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | public static function inst(string $baseClass) |
| 89 | 89 | { |
| 90 | - if(self::$singleton === null) { |
|
| 90 | + if (self::$singleton === null) { |
|
| 91 | 91 | self::$singleton = Injector::inst()->get(static::class); |
| 92 | 92 | } |
| 93 | 93 | self::$singleton->setBaseClass($baseClass); |
@@ -128,12 +128,12 @@ discard block |
||
| 128 | 128 | foreach ($this->cache['AllValidFields'][$className] as $name => $type) { |
| 129 | 129 | if ($this->isValidFieldType($type, $className, $name)) { |
| 130 | 130 | $array[] = $name; |
| 131 | - } elseif(in_array($name, $includedFields, true)) { |
|
| 131 | + } elseif (in_array($name, $includedFields, true)) { |
|
| 132 | 132 | $array[] = $name; |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | - if(isset($includedClassFieldCombos[$className])) { |
|
| 136 | - foreach($includedClassFieldCombos[$className] as $name) { |
|
| 135 | + if (isset($includedClassFieldCombos[$className])) { |
|
| 136 | + foreach ($includedClassFieldCombos[$className] as $name) { |
|
| 137 | 137 | $array[] = $name; |
| 138 | 138 | } |
| 139 | 139 | } |
@@ -112,13 +112,13 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | public function setQuickSearchType(string $nameOrType): SearchApi |
| 114 | 114 | { |
| 115 | - if($nameOrType === 'all') { |
|
| 115 | + if ($nameOrType === 'all') { |
|
| 116 | 116 | $this->isQuickSearch = false; |
| 117 | 117 | $this->quickSearchType = ''; |
| 118 | - } elseif($nameOrType === 'limited') { |
|
| 118 | + } elseif ($nameOrType === 'limited') { |
|
| 119 | 119 | $this->isQuickSearch = true; |
| 120 | 120 | $this->quickSearchType = ''; |
| 121 | - } elseif(class_exists($nameOrType)) { |
|
| 121 | + } elseif (class_exists($nameOrType)) { |
|
| 122 | 122 | $this->quickSearchType = $nameOrType; |
| 123 | 123 | $object = Injector::inst()->get($nameOrType); |
| 124 | 124 | $this->setIncludedClasses($object->getClassesToSearch()); |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | |
| 150 | 150 | public function setBaseClass(string $class): SearchApi |
| 151 | 151 | { |
| 152 | - if(class_exists($class)) { |
|
| 152 | + if (class_exists($class)) { |
|
| 153 | 153 | $this->baseClass = $class; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | $count = 0; |
| 268 | 268 | // we should have these already. |
| 269 | 269 | $word = $this->securityCheckInput($word); |
| 270 | - if($word) { |
|
| 270 | + if ($word) { |
|
| 271 | 271 | // important to do this first |
| 272 | 272 | foreach ($this->objects as $item) { |
| 273 | 273 | $className = $item->ClassName; |
| 274 | 274 | if ($item->canEdit()) { |
| 275 | 275 | $fields = $this->getAllValidFields($className); |
| 276 | 276 | foreach ($fields as $field) { |
| 277 | - if(!$this->includeFieldTest($className, $field)) { |
|
| 277 | + if (!$this->includeFieldTest($className, $field)) { |
|
| 278 | 278 | continue; |
| 279 | 279 | } |
| 280 | 280 | $new = str_replace($word, $replace, $item->{$field}); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | if (count($this->words)) { |
| 352 | 352 | foreach ($this->getAllDataObjects() as $className) { |
| 353 | 353 | |
| 354 | - if(!$this->includeClassTest($className)) { |
|
| 354 | + if (!$this->includeClassTest($className)) { |
|
| 355 | 355 | continue; |
| 356 | 356 | } |
| 357 | 357 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $fields = $this->getAllValidFields($className); |
| 360 | 360 | $filterAny = []; |
| 361 | 361 | foreach ($fields as $field) { |
| 362 | - if(!$this->includeFieldTest($className, $field)) { |
|
| 362 | + if (!$this->includeFieldTest($className, $field)) { |
|
| 363 | 363 | continue; |
| 364 | 364 | } |
| 365 | 365 | $filterAny[$field . ':PartialMatch'] = $this->words; |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | DB::alteration_message(' ... Filter: ' . implode(', ', array_keys($filterAny))); |
| 374 | 374 | } |
| 375 | 375 | $defaultList = $this->getDefaultList($className); |
| 376 | - if(empty($defaultList)) { |
|
| 376 | + if (empty($defaultList)) { |
|
| 377 | 377 | $array[$className] = $className::get(); |
| 378 | 378 | } |
| 379 | 379 | $array[$className] = $array[$className]->filter(['ClassName' => $className]); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | $array = []; |
| 417 | 417 | $classNames = $this->getAllDataObjects(); |
| 418 | 418 | foreach ($classNames as $className) { |
| 419 | - if($this->includeClassTest($className)) { |
|
| 419 | + if ($this->includeClassTest($className)) { |
|
| 420 | 420 | $array[$className] = $className::get() |
| 421 | 421 | ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold)) |
| 422 | 422 | ->sort(['LastEdited' => 'DESC']) |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | ->limit($limit) |
| 464 | 464 | ; |
| 465 | 465 | foreach ($items as $item) { |
| 466 | - if(isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
| 466 | + if (isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
| 467 | 467 | continue; |
| 468 | 468 | } |
| 469 | 469 | if ($item->canView()) { |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | $items = $this->turnArrayIntoObjects($matches); |
| 498 | 498 | foreach ($items as $item) { |
| 499 | 499 | $link = $finder->getLink($item, $this->excludedClasses); |
| 500 | - if($item->canView()) { |
|
| 500 | + if ($item->canView()) { |
|
| 501 | 501 | $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : ''; |
| 502 | 502 | $list->push( |
| 503 | 503 | ArrayData::create( |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | } |
| 520 | 520 | $finder->saveCache(); |
| 521 | 521 | |
| 522 | - if(!empty($this->sortOverride)) { |
|
| 522 | + if (!empty($this->sortOverride)) { |
|
| 523 | 523 | return $list->sort($this->sortOverride); |
| 524 | 524 | } else { |
| 525 | 525 | return $list->sort(['SiteWideSearchSortValue' => 'ASC']); |
@@ -676,13 +676,13 @@ discard block |
||
| 676 | 676 | |
| 677 | 677 | protected function includeClassTest(string $className): bool |
| 678 | 678 | { |
| 679 | - if(count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
| 679 | + if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
| 680 | 680 | if ($this->debug) { |
| 681 | 681 | DB::alteration_message(' ... Skipping as not included ' . $className); |
| 682 | 682 | } |
| 683 | 683 | return false; |
| 684 | 684 | } |
| 685 | - if(count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
| 685 | + if (count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
| 686 | 686 | if ($this->debug) { |
| 687 | 687 | DB::alteration_message(' ... Skipping as excluded ' . $className); |
| 688 | 688 | } |
@@ -697,9 +697,9 @@ discard block |
||
| 697 | 697 | |
| 698 | 698 | protected function includeFieldTest(string $className, string $field): bool |
| 699 | 699 | { |
| 700 | - if(isset($this->includedClassFieldCombos[$className][$field])) { |
|
| 700 | + if (isset($this->includedClassFieldCombos[$className][$field])) { |
|
| 701 | 701 | return true; |
| 702 | - } elseif(count($this->includedFields)) { |
|
| 702 | + } elseif (count($this->includedFields)) { |
|
| 703 | 703 | return in_array($field, $this->includedFields, true); |
| 704 | 704 | } elseif (count($this->excludedFields)) { |
| 705 | 705 | return in_array($field, $this->includedFields, true) ? false : true; |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | protected function includeSubClasses(array $classes): array |
| 712 | 712 | { |
| 713 | 713 | $toAdd = []; |
| 714 | - foreach($classes as $class) { |
|
| 714 | + foreach ($classes as $class) { |
|
| 715 | 715 | $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false)); |
| 716 | 716 | } |
| 717 | 717 | return array_unique(array_merge($classes, $toAdd)); |