@@ -118,29 +118,29 @@ discard block |
||
118 | 118 | 'Default values are those used by Elastica')); |
119 | 119 | $fields->addFieldToTab("Root.Search.Similarity", $lf); |
120 | 120 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MinTermFreq', |
121 | - 'The minimum term frequency below which the terms will be ignored from the input '. |
|
121 | + 'The minimum term frequency below which the terms will be ignored from the input ' . |
|
122 | 122 | 'document. Defaults to 2.')); |
123 | 123 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxTermFreq', |
124 | - 'The maximum number of query terms that will be selected. Increasing this value gives '. |
|
124 | + 'The maximum number of query terms that will be selected. Increasing this value gives ' . |
|
125 | 125 | 'greater accuracy at the expense of query execution speed. Defaults to 25.')); |
126 | 126 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MinWordLength', |
127 | 127 | 'The minimum word length below which the terms will be ignored. Defaults to 0.')); |
128 | 128 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MinDocFreq', |
129 | - 'The minimum document frequency below which the terms will be ignored from the input '. |
|
129 | + 'The minimum document frequency below which the terms will be ignored from the input ' . |
|
130 | 130 | 'document. Defaults to 5.')); |
131 | 131 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxDocFreq', |
132 | - 'The maximum document frequency above which the terms will be ignored from the input '. |
|
133 | - 'document. This could be useful in order to ignore highly frequent words such as stop '. |
|
132 | + 'The maximum document frequency above which the terms will be ignored from the input ' . |
|
133 | + 'document. This could be useful in order to ignore highly frequent words such as stop ' . |
|
134 | 134 | 'words. Defaults to unbounded (0).')); |
135 | 135 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MinWordLength', |
136 | - 'The minimum word length below which the terms will be ignored. The old name min_'. |
|
136 | + 'The minimum word length below which the terms will be ignored. The old name min_' . |
|
137 | 137 | 'word_len is deprecated. Defaults to 0.')); |
138 | 138 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MaxWordLength', |
139 | - 'The maximum word length above which the terms will be ignored. The old name max_word_'. |
|
139 | + 'The maximum word length above which the terms will be ignored. The old name max_word_' . |
|
140 | 140 | 'len is deprecated. Defaults to unbounded (0).')); |
141 | 141 | $fields->addFieldToTab("Root.Search.Similarity", new TextField('MinShouldMatch', |
142 | - 'This parameter controls the number of terms that must match. This can be either a '. |
|
143 | - 'number or a percentage. See '. |
|
142 | + 'This parameter controls the number of terms that must match. This can be either a ' . |
|
143 | + 'number or a percentage. See ' . |
|
144 | 144 | 'https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html')); |
145 | 145 | |
146 | 146 | // ---- search details tab ---- |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | |
178 | 178 | $html = '<div class="field text" id="SiteTreeOnlyInfo">'; |
179 | 179 | $html .= "<p>Copy the following into the above field to ensure that all SiteTree classes are searched</p>"; |
180 | - $html .= '<p class="message">'.$list; |
|
180 | + $html .= '<p class="message">' . $list; |
|
181 | 181 | $html .= "</p></div>"; |
182 | - $infoField = new LiteralField('InfoField',$html); |
|
182 | + $infoField = new LiteralField('InfoField', $html); |
|
183 | 183 | $fields->addFieldToTab('Root.Search.SearchFor', $infoField); |
184 | 184 | |
185 | 185 | $fields->addFieldToTab('Root.Main', new HTMLEditorField('ContentForEmptySearch')); |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | setSource($ottos); |
197 | 197 | $df->setEmptyString('-- Please select what do do after find as you type has occurred --'); |
198 | 198 | |
199 | - $ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete',1)->Map('ID', 'Name')->toArray(); |
|
199 | + $ottos = $this->ElasticaSearchableFields()->filter('EnableAutocomplete', 1)->Map('ID', 'Name')->toArray(); |
|
200 | 200 | $autoCompleteFieldDF = DropDownField::create('AutoCompleteFieldID', 'Field to use for autocomplete')->setSource($ottos); |
201 | 201 | $autoCompleteFieldDF->setEmptyString('-- Please select which field to use for autocomplete --'); |
202 | 202 | |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | ); |
209 | 209 | |
210 | 210 | // ---- grid of searchable fields ---- |
211 | - $html = '<p id="SearchFieldIntro">'._t('SiteConfig.ELASTICA_SEARCH_INFO', |
|
212 | - "Select a field to edit it's properties").'</p>'; |
|
213 | - $fields->addFieldToTab('Root.Search.Fields', $h1=new LiteralField('SearchInfo', $html)); |
|
211 | + $html = '<p id="SearchFieldIntro">' . _t('SiteConfig.ELASTICA_SEARCH_INFO', |
|
212 | + "Select a field to edit it's properties") . '</p>'; |
|
213 | + $fields->addFieldToTab('Root.Search.Fields', $h1 = new LiteralField('SearchInfo', $html)); |
|
214 | 214 | $searchPicker = new PickerField('ElasticaSearchableFields', 'Searchable Fields', |
215 | 215 | $this->ElasticaSearchableFields()->filter('Active', 1)->sort('Name')); |
216 | 216 | |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | public function validate() { |
284 | 284 | $result = parent::validate(); |
285 | 285 | $mode = Versioned::get_reading_mode(); |
286 | - $suffix = ''; |
|
286 | + $suffix = ''; |
|
287 | 287 | if ($mode == 'Stage.Live') { |
288 | 288 | $suffix = '_Live'; |
289 | 289 | } |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | $result->error('The identifier cannot be blank'); |
293 | 293 | } |
294 | 294 | |
295 | - $where = 'ElasticSearchPage'.$suffix.'.ID != '.$this->ID." AND `Identifier` = '{$this->Identifier}'"; |
|
295 | + $where = 'ElasticSearchPage' . $suffix . '.ID != ' . $this->ID . " AND `Identifier` = '{$this->Identifier}'"; |
|
296 | 296 | $existing = ElasticSearchPage::get()->where($where)->count(); |
297 | 297 | if ($existing > 0) { |
298 | - $result->error('The identifier '.$this->Identifier.' already exists'); |
|
298 | + $result->error('The identifier ' . $this->Identifier . ' already exists'); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | |
302 | - error_log('CTS:'.$this->ClassesToSearch); |
|
302 | + error_log('CTS:' . $this->ClassesToSearch); |
|
303 | 303 | |
304 | 304 | // now check classes to search actually exist, assuming in site tree not set |
305 | - error_log('STO:'.$this->SiteTreeOnly); |
|
305 | + error_log('STO:' . $this->SiteTreeOnly); |
|
306 | 306 | if (!$this->SiteTreeOnly) { |
307 | 307 | if ($this->ClassesToSearch == '') { |
308 | 308 | $result->error('At least one searchable class must be available, or SiteTreeOnly flag set'); |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | try { |
313 | 313 | $instance = Injector::inst()->create($clazz); |
314 | 314 | if (!$instance->hasExtension('SilverStripe\Elastica\Searchable')) { |
315 | - $result->error('The class '.$clazz.' must have the Searchable extension'); |
|
315 | + $result->error('The class ' . $clazz . ' must have the Searchable extension'); |
|
316 | 316 | } |
317 | 317 | } catch (ReflectionException $e) { |
318 | - $result->error('The class '.$clazz.' does not exist'); |
|
318 | + $result->error('The class ' . $clazz . ' does not exist'); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | |
364 | 364 | if ($newSearchableFields->count() > 0) { |
365 | 365 | foreach ($newSearchableFields->getIterator() as $newSearchableField) { |
366 | - error_log('NEW FIELD:'.$newSearchableField->Name); |
|
366 | + error_log('NEW FIELD:' . $newSearchableField->Name); |
|
367 | 367 | $newSearchableField->Active = true; |
368 | 368 | $newSearchableField->Weight = 1; |
369 | 369 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | // Note 1 used instead of true for SQLite3 testing compatibility |
373 | 373 | $sql = "UPDATE ElasticSearchPage_ElasticaSearchableFields SET "; |
374 | - $sql .= 'Active=1, Weight=1 WHERE ElasticSearchPageID = '.$this->ID; |
|
374 | + $sql .= 'Active=1, Weight=1 WHERE ElasticSearchPageID = ' . $this->ID; |
|
375 | 375 | DB::query($sql); |
376 | 376 | } |
377 | 377 | } |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | $qField->setAttribute('data-autocomplete-field', 'Title'); |
419 | 419 | $qField->setAttribute('data-autocomplete-classes', $this->ClassesToSearch); |
420 | 420 | $qField->setAttribute('data-autocomplete-sitetree', $this->SiteTreeOnly); |
421 | - $qField->setAttribute('data-autocomplete-source',$this->Link()); |
|
421 | + $qField->setAttribute('data-autocomplete-source', $this->Link()); |
|
422 | 422 | $qField->setAttribute('data-autocomplete-function', |
423 | 423 | $this->AutocompleteFunction()->Slug); |
424 | 424 | } |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | class ElasticSearchPage_Controller extends Page_Controller { |
442 | 442 | |
443 | - private static $allowed_actions = array('SearchForm', 'submit','index','similar'); |
|
443 | + private static $allowed_actions = array('SearchForm', 'submit', 'index', 'similar'); |
|
444 | 444 | |
445 | 445 | public function init() { |
446 | 446 | parent::init(); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | |
517 | 517 | // Use the standard field for more like this, ie not stemmed |
518 | 518 | foreach ($fieldsToSearch as $field => $value) { |
519 | - $fieldsToSearch[$field.'.standard'] = $value; |
|
519 | + $fieldsToSearch[$field . '.standard'] = $value; |
|
520 | 520 | unset($fieldsToSearch[$field]); |
521 | 521 | } |
522 | 522 | |
@@ -526,7 +526,7 @@ discard block |
||
526 | 526 | throw new Elastica\Exception\Connection\HttpException('Unable to reach search server'); |
527 | 527 | } |
528 | 528 | if (class_exists($class)) { |
529 | - $instance = \DataObject::get_by_id($class,$instanceID); |
|
529 | + $instance = \DataObject::get_by_id($class, $instanceID); |
|
530 | 530 | |
531 | 531 | $paginated = $es->moreLikeThis($instance, $fieldsToSearch); |
532 | 532 | |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | // calculate time |
572 | 572 | $endTime = microtime(true); |
573 | - $elapsed = round(100*($endTime-$startTime))/100; |
|
573 | + $elapsed = round(100 * ($endTime - $startTime)) / 100; |
|
574 | 574 | |
575 | 575 | // store variables for the template to use |
576 | 576 | $data['ElapsedTime'] = $elapsed; |
@@ -624,11 +624,11 @@ discard block |
||
624 | 624 | $testMode = isset($_GET['TestMode']); |
625 | 625 | |
626 | 626 | // filters for aggregations |
627 | - $ignore = array('url', 'start','q','is'); |
|
627 | + $ignore = array('url', 'start', 'q', 'is'); |
|
628 | 628 | $ignore = \Config::inst()->get('Elastica', 'BlackList'); |
629 | 629 | foreach ($this->request->getVars() as $key => $value) { |
630 | 630 | if (!in_array($key, $ignore)) { |
631 | - $es->addFilter($key,$value); |
|
631 | + $es->addFilter($key, $value); |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | $data['SuggestedQuery'] = $es->getSuggestedQuery(); |
678 | 678 | $data['SuggestedQueryHighlighted'] = $es->getSuggestedQueryHighlighted(); |
679 | 679 | //Link for if the user really wants to try their original query |
680 | - $sifLink = rtrim($this->Link(),'/').'?q='.$queryText.'&is=1'; |
|
680 | + $sifLink = rtrim($this->Link(), '/') . '?q=' . $queryText . '&is=1'; |
|
681 | 681 | $data['SearchInsteadForLink'] = $sifLink; |
682 | 682 | $paginated = $es->search($es->getSuggestedQuery(), $fieldsToSearch); |
683 | 683 | |
@@ -685,7 +685,7 @@ discard block |
||
685 | 685 | |
686 | 686 | // calculate time |
687 | 687 | $endTime = microtime(true); |
688 | - $elapsed = round(100*($endTime-$startTime))/100; |
|
688 | + $elapsed = round(100 * ($endTime - $startTime)) / 100; |
|
689 | 689 | |
690 | 690 | // store variables for the template to use |
691 | 691 | $data['ElapsedTime'] = $elapsed; |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | */ |
717 | 717 | public function QueryIsEmpty() { |
718 | 718 | $result = !isset($_GET['q']); |
719 | - if (isset($_GET['q'])) { |
|
719 | + if (isset($_GET['q'])) { |
|
720 | 720 | $queryText = $_GET['q']; |
721 | 721 | if ($queryText == '') { |
722 | 722 | $result = true; |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | $queryText = $data['q']; |
736 | 736 | $url = $this->Link(); |
737 | 737 | $url = rtrim($url, '/'); |
738 | - $link = rtrim($url, '/').'?q='.$queryText.'&sfid='.$data['identifier']; |
|
738 | + $link = rtrim($url, '/') . '?q=' . $queryText . '&sfid=' . $data['identifier']; |
|
739 | 739 | $this->redirect($link); |
740 | 740 | } |
741 | 741 | |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | |
760 | 760 | } |
761 | 761 | |
762 | - if($this->action == 'similar') { |
|
762 | + if ($this->action == 'similar') { |
|
763 | 763 | $queryField->setDisabled(true); |
764 | 764 | $actions = $form->Actions(); |
765 | 765 | foreach ($actions as $field) { |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | $queryField->setAttribute('data-autocomplete-field', 'Title'); |
776 | 776 | $queryField->setAttribute('data-autocomplete-classes', $this->ClassesToSearch); |
777 | 777 | $queryField->setAttribute('data-autocomplete-sitetree', $this->SiteTreeOnly); |
778 | - $queryField->setAttribute('data-autocomplete-source',$this->Link()); |
|
778 | + $queryField->setAttribute('data-autocomplete-source', $this->Link()); |
|
779 | 779 | $queryField->setAttribute('data-autocomplete-function', |
780 | 780 | $this->AutocompleteFunction()->Slug); |
781 | 781 | } |