@@ -90,7 +90,7 @@ |
||
90 | 90 | _t(__CLASS__ . '.ReplaceToggle', 'Replace with ... (optional - make a backup first!)'), |
91 | 91 | [ |
92 | 92 | (new CheckboxField('ApplyReplace', 'Run replace (please make sure to make a backup first!)', $this->applyReplace)) |
93 | - ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'), |
|
93 | + ->setDescription('Check this to replace the searched value set above with its replacement value. Note that searches ignore uppercase / lowercase, but replace actions will only search and replace values with the same upper / lowercase.'), |
|
94 | 94 | (new TextField('ReplaceWith', 'Replace (optional - careful!)', $this->replace ?? '')) |
95 | 95 | ->setAttribute('placeholder', 'e.g. contract - make sure to also tick checkbox below'), |
96 | 96 | ] |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | |
57 | 57 | protected function init() |
58 | 58 | { |
59 | - if($this->request->param('Action')) { |
|
60 | - if(empty($this->request->postVars())) { |
|
59 | + if ($this->request->param('Action')) { |
|
60 | + if (empty($this->request->postVars())) { |
|
61 | 61 | $this->redirect('/admin/find'); |
62 | 62 | } |
63 | 63 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | if (!$this->getRequest()->requestVar('Keywords')) { |
112 | 112 | $lastResults = $this->lastSearchResults(); |
113 | - if($lastResults) { |
|
113 | + if ($lastResults) { |
|
114 | 114 | $resultsTitle = 'Last Results'; |
115 | 115 | } else { |
116 | 116 | $resultsTitle = 'Last Edited'; |
@@ -180,9 +180,9 @@ discard block |
||
180 | 180 | Environment::increaseTimeLimitTo(300); |
181 | 181 | Environment::setMemoryLimitMax(-1); |
182 | 182 | Environment::increaseMemoryLimitTo(-1); |
183 | - if(empty($this->rawData)) { |
|
183 | + if (empty($this->rawData)) { |
|
184 | 184 | $lastResults = $this->lastSearchResults(); |
185 | - if($lastResults) { |
|
185 | + if ($lastResults) { |
|
186 | 186 | return $lastResults; |
187 | 187 | } |
188 | 188 | } |
@@ -208,14 +208,14 @@ discard block |
||
208 | 208 | ->setWordsAsString($this->keywords) |
209 | 209 | ->getLinks() |
210 | 210 | ; |
211 | - if($results->count() === 1) { |
|
211 | + if ($results->count() === 1) { |
|
212 | 212 | $result = $results->first(); |
213 | 213 | $this->redirect($result->CMSEditLink); |
214 | 214 | return null; |
215 | 215 | } |
216 | 216 | // Accessing the session |
217 | 217 | $session = $this->getRequest()->getSession(); |
218 | - if($session) { |
|
218 | + if ($session) { |
|
219 | 219 | $session->set('QuickSearchLastResults', serialize($results->toArray())); |
220 | 220 | } |
221 | 221 | return $results; |
@@ -246,16 +246,16 @@ discard block |
||
246 | 246 | { |
247 | 247 | // Accessing the session |
248 | 248 | $session = $this->getRequest()->getSession(); |
249 | - if($this->quickSearchType) { |
|
249 | + if ($this->quickSearchType) { |
|
250 | 250 | $session->set('QuickSearchType', $this->quickSearchType); |
251 | - } elseif($session) { |
|
251 | + } elseif ($session) { |
|
252 | 252 | $this->quickSearchType = $session->get('QuickSearchType'); |
253 | - if(isset($_GET['flush'])) { |
|
253 | + if (isset($_GET['flush'])) { |
|
254 | 254 | $this->quickSearchType = ''; |
255 | 255 | $session->set('QuickSearchType', ''); |
256 | 256 | } |
257 | 257 | } |
258 | - if(!$this->quickSearchType) { |
|
258 | + if (!$this->quickSearchType) { |
|
259 | 259 | $this->quickSearchType = $this->Config()->get('default_quick_search_type'); |
260 | 260 | } |
261 | 261 | return (string) $this->quickSearchType; |
@@ -265,15 +265,15 @@ discard block |
||
265 | 265 | { |
266 | 266 | // Accessing the session |
267 | 267 | $session = $this->getRequest()->getSession(); |
268 | - if($session) { |
|
269 | - if(isset($_GET['flush'])) { |
|
268 | + if ($session) { |
|
269 | + if (isset($_GET['flush'])) { |
|
270 | 270 | $session->clear('QuickSearchLastResults'); |
271 | 271 | } else { |
272 | 272 | $data = $session->get('QuickSearchLastResults'); |
273 | - if($data) { |
|
273 | + if ($data) { |
|
274 | 274 | $array = unserialize($data); |
275 | 275 | $al = ArrayList::create(); |
276 | - foreach($array as $item) { |
|
276 | + foreach ($array as $item) { |
|
277 | 277 | $al->push($item); |
278 | 278 | } |
279 | 279 | return $al; |
@@ -52,10 +52,10 @@ |
||
52 | 52 | 'limited' => 'Limited search', |
53 | 53 | ]; |
54 | 54 | $availableSearchClasses = self::available_quick_searches(); |
55 | - if(!empty($availableSearchClasses) > 0) { |
|
56 | - foreach($availableSearchClasses as $availableSearchClass) { |
|
55 | + if (!empty($availableSearchClasses) > 0) { |
|
56 | + foreach ($availableSearchClasses as $availableSearchClass) { |
|
57 | 57 | $singleton = Injector::inst()->get($availableSearchClass); |
58 | - if($singleton->isEnabled()) { |
|
58 | + if ($singleton->isEnabled()) { |
|
59 | 59 | $array[$availableSearchClass] = $singleton->getTitle(); |
60 | 60 | } |
61 | 61 | } |
@@ -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 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | { |
253 | 253 | $this->initCache(); |
254 | 254 | $count = 0; |
255 | - if($word) { |
|
255 | + if ($word) { |
|
256 | 256 | $this->buildCache($word); |
257 | 257 | $replace = $this->securityCheckInput($replace); |
258 | 258 | foreach ($this->objects as $item) { |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | if ($item->canEdit()) { |
261 | 261 | $fields = $this->getAllValidFields($className); |
262 | 262 | foreach ($fields as $field) { |
263 | - if(!$this->includeFieldTest($className, $field)) { |
|
263 | + if (!$this->includeFieldTest($className, $field)) { |
|
264 | 264 | continue; |
265 | 265 | } |
266 | 266 | $new = str_replace($word, $replace, $item->{$field}); |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $this->workOutInclusionsAndExclusions(); |
326 | 326 | |
327 | 327 | // important to do this first |
328 | - if($word) { |
|
328 | + if ($word) { |
|
329 | 329 | $this->setWordsAsString($word); |
330 | 330 | } |
331 | 331 | $this->workOutWordsForSearching(); |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | if (count($this->words)) { |
339 | 339 | foreach ($this->getAllDataObjects() as $className) { |
340 | 340 | |
341 | - if(!$this->includeClassTest($className)) { |
|
341 | + if (!$this->includeClassTest($className)) { |
|
342 | 342 | continue; |
343 | 343 | } |
344 | 344 | |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | $fields = $this->getAllValidFields($className); |
347 | 347 | $filterAny = []; |
348 | 348 | foreach ($fields as $field) { |
349 | - if(!$this->includeFieldTest($className, $field)) { |
|
349 | + if (!$this->includeFieldTest($className, $field)) { |
|
350 | 350 | continue; |
351 | 351 | } |
352 | 352 | $filterAny[$field . ':PartialMatch'] = $this->words; |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | DB::alteration_message(' ... Filter: ' . implode(', ', array_keys($filterAny))); |
361 | 361 | } |
362 | 362 | $defaultList = $this->getDefaultList($className); |
363 | - if(empty($defaultList)) { |
|
363 | + if (empty($defaultList)) { |
|
364 | 364 | $array[$className] = $className::get(); |
365 | 365 | } |
366 | 366 | $array[$className] = $array[$className]->filter(['ClassName' => $className]); |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | $array = []; |
404 | 404 | $classNames = $this->getAllDataObjects(); |
405 | 405 | foreach ($classNames as $className) { |
406 | - if($this->includeClassTest($className)) { |
|
406 | + if ($this->includeClassTest($className)) { |
|
407 | 407 | $array[$className] = $className::get() |
408 | 408 | ->filter('LastEdited:GreaterThan', date('Y-m-d H:i:s', $threshold)) |
409 | 409 | ->sort(['LastEdited' => 'DESC']) |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | ->limit($limit) |
451 | 451 | ; |
452 | 452 | foreach ($items as $item) { |
453 | - if(isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
453 | + if (isset($fullListCheck[$item->ClassName][$item->ID])) { |
|
454 | 454 | continue; |
455 | 455 | } |
456 | 456 | if ($item->canView()) { |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | $items = $this->turnArrayIntoObjects($matches); |
485 | 485 | foreach ($items as $item) { |
486 | 486 | $link = $finder->getLink($item, $this->excludedClasses); |
487 | - if($item->canView()) { |
|
487 | + if ($item->canView()) { |
|
488 | 488 | $cmsEditLink = $item->canEdit() ? $finder->getCMSEditLink($item) : ''; |
489 | 489 | $list->push( |
490 | 490 | ArrayData::create( |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | } |
507 | 507 | $finder->saveCache(); |
508 | 508 | |
509 | - if(!empty($this->sortOverride)) { |
|
509 | + if (!empty($this->sortOverride)) { |
|
510 | 510 | return $list->sort($this->sortOverride); |
511 | 511 | } else { |
512 | 512 | return $list->sort(['SiteWideSearchSortValue' => 'ASC']); |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | |
660 | 660 | protected function includeClassTest(string $className): bool |
661 | 661 | { |
662 | - if(count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
662 | + if (count($this->includedClassesWithSubClassess) && !in_array($className, $this->includedClassesWithSubClassess, true)) { |
|
663 | 663 | if ($this->debug) { |
664 | 664 | DB::alteration_message(' ... Skipping as not included ' . $className); |
665 | 665 | } |
666 | 666 | return false; |
667 | 667 | } |
668 | - if(count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
668 | + if (count($this->excludedClassesWithSubClassess) && in_array($className, $this->excludedClassesWithSubClassess, true)) { |
|
669 | 669 | if ($this->debug) { |
670 | 670 | DB::alteration_message(' ... Skipping as excluded ' . $className); |
671 | 671 | } |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | |
681 | 681 | protected function includeFieldTest(string $className, string $field): bool |
682 | 682 | { |
683 | - if(isset($this->includedClassFieldCombos[$className][$field])) { |
|
683 | + if (isset($this->includedClassFieldCombos[$className][$field])) { |
|
684 | 684 | return true; |
685 | - } elseif(count($this->includedFields)) { |
|
685 | + } elseif (count($this->includedFields)) { |
|
686 | 686 | return in_array($field, $this->includedFields, true); |
687 | 687 | } elseif (count($this->excludedFields)) { |
688 | 688 | return in_array($field, $this->includedFields, true) ? false : true; |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | protected function includeSubClasses(array $classes): array |
695 | 695 | { |
696 | 696 | $toAdd = []; |
697 | - foreach($classes as $class) { |
|
697 | + foreach ($classes as $class) { |
|
698 | 698 | $toAdd = array_merge($toAdd, ClassInfo::subclassesFor($class, false)); |
699 | 699 | } |
700 | 700 | return array_unique(array_merge($classes, $toAdd)); |