@@ -312,12 +312,12 @@ discard block |
||
312 | 312 | |
313 | 313 | if (isset($_GET['progress'])) { |
314 | 314 | $progress = $_GET['progress']; |
315 | - self::$progressInterval = (int) $progress; |
|
315 | + self::$progressInterval = (int)$progress; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | if (self::$progressInterval > 0) { |
319 | 319 | if (self::$index_ctr % self::$progressInterval === 0) { |
320 | - ElasticaUtil::message("\t".$this->owner->ClassName." - Prepared ".self::$index_ctr." for indexing..."); |
|
320 | + ElasticaUtil::message("\t" . $this->owner->ClassName . " - Prepared " . self::$index_ctr . " for indexing..."); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | |
367 | 367 | } else { |
368 | 368 | if (in_array($field, $this->html_fields)) { |
369 | - $fields[$field] = $this->owner->$field;; |
|
369 | + $fields[$field] = $this->owner->$field; ; |
|
370 | 370 | if (gettype($this->owner->$field) !== 'NULL') { |
371 | 371 | $html = ShortcodeParser::get_active()->parse($this->owner->$field); |
372 | 372 | $txt = \Convert::html2raw($html); |
@@ -508,14 +508,14 @@ discard block |
||
508 | 508 | * Removes the record from the search index. |
509 | 509 | */ |
510 | 510 | protected function doDeleteDocument() { |
511 | - try{ |
|
511 | + try { |
|
512 | 512 | if (!$this->owner->IndexingOff) { |
513 | 513 | // this goes to elastica service |
514 | 514 | $this->service->remove($this->owner); |
515 | 515 | } |
516 | 516 | } |
517 | - catch(\Elastica\Exception\NotFoundException $e) { |
|
518 | - trigger_error("Deleted document ".$this->owner->ClassName." (".$this->owner->ID. |
|
517 | + catch (\Elastica\Exception\NotFoundException $e) { |
|
518 | + trigger_error("Deleted document " . $this->owner->ClassName . " (" . $this->owner->ID . |
|
519 | 519 | ") not found in search index.", E_USER_NOTICE); |
520 | 520 | } |
521 | 521 | |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | $fields = \Config::inst()->get(get_class($this->owner), 'searchable_fields'); |
533 | 533 | |
534 | 534 | // fallback to default method |
535 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$this->owner->ClassName); |
|
535 | + if (!$fields) user_error('The field $searchable_fields must be set for the class ' . $this->owner->ClassName); |
|
536 | 536 | |
537 | 537 | // get the values of these fields |
538 | 538 | $elasticaMapping = $this->fieldsToElasticaConfig($this->owner, $fields); |
@@ -553,24 +553,24 @@ discard block |
||
553 | 553 | |
554 | 554 | $relClass = $has_lists[$methodName]; |
555 | 555 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
556 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
556 | + if (!$fields) user_error('The field $searchable_fields must be set for the class ' . $relClass); |
|
557 | 557 | $rewrite = $this->fieldsToElasticaConfig($relClass, $fields); |
558 | 558 | |
559 | 559 | // mark as a method, the resultant fields are correct |
560 | - $elasticaMapping[$methodName.'()'] = $rewrite; |
|
560 | + $elasticaMapping[$methodName . '()'] = $rewrite; |
|
561 | 561 | |
562 | 562 | |
563 | 563 | } else if (isset($has_ones[$methodName])) { |
564 | 564 | $relClass = $has_ones[$methodName]; |
565 | 565 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
566 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
566 | + if (!$fields) user_error('The field $searchable_fields must be set for the class ' . $relClass); |
|
567 | 567 | $rewrite = $this->fieldsToElasticaConfig($relClass, $fields); |
568 | 568 | $classname = $has_ones[$methodName]; |
569 | 569 | |
570 | 570 | // mark as a method, the resultant fields are correct |
571 | - $elasticaMapping[$methodName.'()'] = $rewrite; |
|
571 | + $elasticaMapping[$methodName . '()'] = $rewrite; |
|
572 | 572 | } else { |
573 | - user_error('The method '.$methodName.' not found in class '.$this->owner->ClassName. |
|
573 | + user_error('The method ' . $methodName . ' not found in class ' . $this->owner->ClassName . |
|
574 | 574 | ', please check configuration'); |
575 | 575 | } |
576 | 576 | } |
@@ -587,14 +587,14 @@ discard block |
||
587 | 587 | private function fieldsToElasticaConfig($objectInContext, $fields) { |
588 | 588 | // Copied from DataObject::searchableFields() as there is no separate accessible method |
589 | 589 | $rewrite = array(); |
590 | - foreach($fields as $name => $specOrName) { |
|
590 | + foreach ($fields as $name => $specOrName) { |
|
591 | 591 | $identifer = (is_int($name)) ? $specOrName : $name; |
592 | 592 | $rewrite[$identifer] = array(); |
593 | - if(!isset($rewrite[$identifer]['title'])) { |
|
593 | + if (!isset($rewrite[$identifer]['title'])) { |
|
594 | 594 | $rewrite[$identifer]['title'] = (isset($labels[$identifer])) |
595 | 595 | ? $labels[$identifer] : \FormField::name_to_label($identifer); |
596 | 596 | } |
597 | - if(!isset($rewrite[$identifer]['filter'])) { |
|
597 | + if (!isset($rewrite[$identifer]['filter'])) { |
|
598 | 598 | $rewrite[$identifer]['filter'] = 'PartialMatchFilter'; |
599 | 599 | } |
600 | 600 | } |
@@ -606,7 +606,7 @@ discard block |
||
606 | 606 | public function requireDefaultRecords() { |
607 | 607 | parent::requireDefaultRecords(); |
608 | 608 | |
609 | - $searchableFields = $this->getElasticaFields(true,true); |
|
609 | + $searchableFields = $this->getElasticaFields(true, true); |
|
610 | 610 | |
611 | 611 | |
612 | 612 | $doSC = \SearchableClass::get()->filter(array('Name' => $this->owner->ClassName))->first(); |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | |
640 | 640 | if (isset($searchableField['type'])) { |
641 | 641 | $doSF->Type = $searchableField['type']; |
642 | - } else { |
|
642 | + } else { |
|
643 | 643 | $doSF->Name = $searchableField['properties']['__method']; |
644 | 644 | $doSF->Type = 'relationship'; |
645 | 645 | } |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | } |
651 | 651 | |
652 | 652 | $doSF->write(); |
653 | - \DB::alteration_message("Created new searchable editable field ".$name,"changed"); |
|
653 | + \DB::alteration_message("Created new searchable editable field " . $name, "changed"); |
|
654 | 654 | } |
655 | 655 | |
656 | 656 | // FIXME deal with deletions |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | */ |
696 | 696 | public function RenderResult($linkToContainer = '') { |
697 | 697 | $vars = new \ArrayData(array('SearchResult' => $this->owner, 'ContainerLink' => $linkToContainer)); |
698 | - $possibleTemplates = array($this->owner->ClassName.'ElasticSearchResult', 'ElasticSearchResult'); |
|
698 | + $possibleTemplates = array($this->owner->ClassName . 'ElasticSearchResult', 'ElasticSearchResult'); |
|
699 | 699 | return $this->owner->customise($vars)->renderWith($possibleTemplates); |
700 | 700 | } |
701 | 701 | |
@@ -761,14 +761,14 @@ discard block |
||
761 | 761 | $underscored = str_replace('.', '_', $field); |
762 | 762 | |
763 | 763 | $gridField = new \GridField( |
764 | - 'TermsFor'.$underscored, // Field name |
|
765 | - $field.'TITLE'.$field, // Field title |
|
764 | + 'TermsFor' . $underscored, // Field name |
|
765 | + $field . 'TITLE' . $field, // Field title |
|
766 | 766 | $terms, |
767 | 767 | $config |
768 | 768 | ); |
769 | 769 | |
770 | 770 | // $tab = new \Tab($field, new \TextField('Test'.$field, 'Testing')); |
771 | - $fields->addFieldToTab('Root.ElasticaTerms.'.$underscored, $gridField); |
|
771 | + $fields->addFieldToTab('Root.ElasticaTerms.' . $underscored, $gridField); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | } |