@@ -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 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | |
| 225 | 225 | public function buildCache(?string $word = ''): SearchApi |
| 226 | 226 | { |
| 227 | - if($this->cacheHasBeenBuilt !== $word) { |
|
| 227 | + if ($this->cacheHasBeenBuilt !== $word) { |
|
| 228 | 228 | $this->getLinksInner($word); |
| 229 | 229 | $this->cacheHasBeenBuilt = $word; |
| 230 | 230 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | public function doReplacement(string $word, string $replace): int |
| 256 | 256 | { |
| 257 | 257 | $count = 0; |
| 258 | - if($word) { |
|
| 258 | + if ($word) { |
|
| 259 | 259 | $this->buildCache($word); |
| 260 | 260 | $replace = $this->securityCheckInput($replace); |
| 261 | 261 | foreach ($this->objects as $item) { |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | if ($item->canEdit()) { |
| 264 | 264 | $fields = $this->getAllValidFields($className); |
| 265 | 265 | foreach ($fields as $field) { |
| 266 | - if(!$this->includeFieldTest($className, $field)) { |
|
| 266 | + if (!$this->includeFieldTest($className, $field)) { |
|
| 267 | 267 | continue; |
| 268 | 268 | } |
| 269 | 269 | $new = str_replace($word, $replace, $item->{$field}); |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | $this->workOutInclusionsAndExclusions(); |
| 329 | 329 | |
| 330 | 330 | // important to do this first |
| 331 | - if($word) { |
|
| 331 | + if ($word) { |
|
| 332 | 332 | $this->setWordsAsString($word); |
| 333 | 333 | } |
| 334 | 334 | $this->workOutWordsForSearching(); |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | if (count($this->words)) { |
| 342 | 342 | foreach ($this->getAllDataObjects() as $className) { |
| 343 | 343 | |
| 344 | - if(!$this->includeClassTest($className)) { |
|
| 344 | + if (!$this->includeClassTest($className)) { |
|
| 345 | 345 | continue; |
| 346 | 346 | } |
| 347 | 347 | |
@@ -349,7 +349,7 @@ discard block |
||
| 349 | 349 | $fields = $this->getAllValidFields($className); |
| 350 | 350 | $filterAny = []; |
| 351 | 351 | foreach ($fields as $field) { |
| 352 | - if(!$this->includeFieldTest($className, $field)) { |
|
| 352 | + if (!$this->includeFieldTest($className, $field)) { |
|
| 353 | 353 | continue; |
| 354 | 354 | } |
| 355 | 355 | $filterAny[$field . ':PartialMatch'] = $this->words; |
@@ -363,7 +363,7 @@ discard block |
||
| 363 | 363 | DB::alteration_message(' ... Filter: ' . implode(', ', array_keys($filterAny))); |
| 364 | 364 | } |
| 365 | 365 | $defaultList = $this->getDefaultList($className); |
| 366 | - if(empty($defaultList)) { |
|
| 366 | + if (empty($defaultList)) { |
|
| 367 | 367 | $array[$className] = $className::get(); |
| 368 | 368 | } |
| 369 | 369 | $array[$className] = $array[$className]->filter(['ClassName' => $className]); |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | $array = []; |
| 407 | 407 | $classNames = $this->getAllDataObjects(); |
| 408 | 408 | foreach ($classNames as $className) { |
| 409 | - if($this->includeClassTest($className)) { |
|
| 409 | + if ($this->includeClassTest($className)) { |
|
| 410 | 410 | $array[$className] = $className::get() |
| 411 | 411 | ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold)) |
| 412 | 412 | ->sort(['LastEdited' => 'DESC']) |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | ->limit($limit) |
| 455 | 455 | ; |
| 456 | 456 | foreach ($items as $item) { |
| 457 | - if(isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
| 457 | + if (isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
| 458 | 458 | continue; |
| 459 | 459 | } |
| 460 | 460 | if ($item->canView()) { |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $items = $this->turnArrayIntoObjects($matches); |
| 489 | 489 | foreach ($items as $item) { |
| 490 | 490 | $link = $finder->getLink($item, $this->excludedClasses); |
| 491 | - if($item->canView()) { |
|
| 491 | + if ($item->canView()) { |
|
| 492 | 492 | $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : ''; |
| 493 | 493 | $list->push( |
| 494 | 494 | ArrayData::create( |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | } |
| 511 | 511 | $finder->saveCache(); |
| 512 | 512 | |
| 513 | - if(!empty($this->sortOverride)) { |
|
| 513 | + if (!empty($this->sortOverride)) { |
|
| 514 | 514 | return $list->sort($this->sortOverride); |
| 515 | 515 | } else { |
| 516 | 516 | return $list->sort(['SiteWideSearchSortValue' => 'ASC']); |
@@ -663,13 +663,13 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | protected function includeClassTest(string $className): bool |
| 665 | 665 | { |
| 666 | - if(count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
| 666 | + if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
| 667 | 667 | if ($this->debug) { |
| 668 | 668 | DB::alteration_message(' ... Skipping as not included ' . $className); |
| 669 | 669 | } |
| 670 | 670 | return false; |
| 671 | 671 | } |
| 672 | - if(count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
| 672 | + if (count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
| 673 | 673 | if ($this->debug) { |
| 674 | 674 | DB::alteration_message(' ... Skipping as excluded ' . $className); |
| 675 | 675 | } |
@@ -684,9 +684,9 @@ discard block |
||
| 684 | 684 | |
| 685 | 685 | protected function includeFieldTest(string $className, string $field): bool |
| 686 | 686 | { |
| 687 | - if(isset($this->includedClassFieldCombos[$className][$field])) { |
|
| 687 | + if (isset($this->includedClassFieldCombos[$className][$field])) { |
|
| 688 | 688 | return true; |
| 689 | - } elseif(count($this->includedFields)) { |
|
| 689 | + } elseif (count($this->includedFields)) { |
|
| 690 | 690 | return in_array($field, $this->includedFields, true); |
| 691 | 691 | } elseif (count($this->excludedFields)) { |
| 692 | 692 | return in_array($field, $this->includedFields, true) ? false : true; |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | protected function includeSubClasses(array $classes): array |
| 699 | 699 | { |
| 700 | 700 | $toAdd = []; |
| 701 | - foreach($classes as $class) { |
|
| 701 | + foreach ($classes as $class) { |
|
| 702 | 702 | $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false)); |
| 703 | 703 | } |
| 704 | 704 | return array_unique(array_merge($classes, $toAdd)); |