@@ -131,32 +131,32 @@ discard block |
||
131 | 131 | $fields = $this->getAllSearchableFields(); |
132 | 132 | $result = array(); |
133 | 133 | |
134 | - foreach ($fields as $name => $params) { |
|
134 | + foreach($fields as $name => $params) { |
|
135 | 135 | $spec = array(); |
136 | 136 | $name = str_replace('()', '', $name); |
137 | 137 | |
138 | - if (array_key_exists($name, $db)) { |
|
138 | + if(array_key_exists($name, $db)) { |
|
139 | 139 | $class = $db[$name]; |
140 | 140 | |
141 | - if (($pos = strpos($class, '('))) { |
|
141 | + if(($pos = strpos($class, '('))) { |
|
142 | 142 | // Valid in the case of Varchar(255) |
143 | 143 | $class = substr($class, 0, $pos); |
144 | 144 | } |
145 | 145 | |
146 | - if (array_key_exists($class, self::$mappings)) { |
|
146 | + if(array_key_exists($class, self::$mappings)) { |
|
147 | 147 | $spec['type'] = self::$mappings[$class]; |
148 | - if ($spec['type'] === 'date') { |
|
149 | - if ($class == 'Date') { |
|
148 | + if($spec['type'] === 'date') { |
|
149 | + if($class == 'Date') { |
|
150 | 150 | $spec['format'] = 'y-M-d'; |
151 | - } elseif ($class == 'SS_Datetime') { |
|
151 | + } elseif($class == 'SS_Datetime') { |
|
152 | 152 | $spec['format'] = 'y-M-d H:m:s'; |
153 | - } elseif ($class == 'Datetime') { |
|
153 | + } elseif($class == 'Datetime') { |
|
154 | 154 | $spec['format'] = 'y-M-d H:m:s'; |
155 | - } elseif ($class == 'Time') { |
|
155 | + } elseif($class == 'Time') { |
|
156 | 156 | $spec['format'] = 'H:m:s'; |
157 | 157 | } |
158 | 158 | } |
159 | - if ($class === 'HTMLText' || $class === 'HTMLVarchar') { |
|
159 | + if($class === 'HTMLText' || $class === 'HTMLVarchar') { |
|
160 | 160 | array_push($this->html_fields, $name); |
161 | 161 | } |
162 | 162 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | $has_ones = $this->owner->has_one(); |
168 | 168 | |
169 | 169 | // check has_many and many_many relations |
170 | - if (isset($has_lists[$name])) { |
|
170 | + if(isset($has_lists[$name])) { |
|
171 | 171 | // FIX ME how to do nested mapping |
172 | 172 | // See https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-array-type.html |
173 | 173 | |
@@ -178,13 +178,13 @@ discard block |
||
178 | 178 | $resultTypeMapping = array(); |
179 | 179 | |
180 | 180 | // get the fields for the result type, but do not recurse |
181 | - if ($recurse) { |
|
181 | + if($recurse) { |
|
182 | 182 | $resultTypeMapping = $resultTypeInstance->getElasticaFields($storeMethodName, false); |
183 | 183 | } |
184 | 184 | |
185 | 185 | $resultTypeMapping['ID'] = array('type' => 'integer'); |
186 | 186 | |
187 | - if ($storeMethodName) { |
|
187 | + if($storeMethodName) { |
|
188 | 188 | $resultTypeMapping['__method'] = $name; |
189 | 189 | } |
190 | 190 | |
@@ -193,20 +193,20 @@ discard block |
||
193 | 193 | |
194 | 194 | // we now change the name to the result type, not the method name |
195 | 195 | $name = $resultType; |
196 | - } else if (isset($has_ones[$name])) { |
|
196 | + } else if(isset($has_ones[$name])) { |
|
197 | 197 | $resultType = $has_ones[$name]; |
198 | 198 | $resultTypeInstance = \Injector::inst()->create($resultType); |
199 | 199 | |
200 | 200 | $resultTypeMapping = array(); |
201 | 201 | |
202 | 202 | // get the fields for the result type, but do not recurse |
203 | - if ($recurse) { |
|
203 | + if($recurse) { |
|
204 | 204 | $resultTypeMapping = $resultTypeInstance->getElasticaFields($storeMethodName, false); |
205 | 205 | } |
206 | 206 | |
207 | 207 | $resultTypeMapping['ID'] = array('type' => 'integer'); |
208 | 208 | |
209 | - if ($storeMethodName) { |
|
209 | + if($storeMethodName) { |
|
210 | 210 | $resultTypeMapping['__method'] = $name; |
211 | 211 | } |
212 | 212 | $spec = array('properties' => $resultTypeMapping); |
@@ -220,8 +220,8 @@ discard block |
||
220 | 220 | } |
221 | 221 | |
222 | 222 | // in the case of a relationship type will not be set |
223 | - if (isset($spec['type'])) { |
|
224 | - if ($spec['type'] == 'string') { |
|
223 | + if(isset($spec['type'])) { |
|
224 | + if($spec['type'] == 'string') { |
|
225 | 225 | $unstemmed = array(); |
226 | 226 | $unstemmed['type'] = "string"; |
227 | 227 | $unstemmed['analyzer'] = "unstemmed"; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | //Add autocomplete field if so required |
238 | 238 | $autocomplete = \Config::inst()->get($this->owner->ClassName, 'searchable_autocomplete'); |
239 | 239 | |
240 | - if (isset($autocomplete) && in_array($name, $autocomplete)) { |
|
240 | + if(isset($autocomplete) && in_array($name, $autocomplete)) { |
|
241 | 241 | $autocompleteField = array(); |
242 | 242 | $autocompleteField['type'] = "string"; |
243 | 243 | $autocompleteField['index_analyzer'] = "autocomplete_index_analyzer"; |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | $result[$name] = $spec; |
257 | 257 | } |
258 | 258 | |
259 | - if ($this->owner->hasMethod('updateElasticHTMLFields')) { |
|
259 | + if($this->owner->hasMethod('updateElasticHTMLFields')) { |
|
260 | 260 | $this->html_fields = $this->owner->updateElasticHTMLFields($this->html_fields); |
261 | 261 | } |
262 | 262 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | $localeMapping = array(); |
278 | 278 | |
279 | - if ($this->owner->hasField('Locale')) { |
|
279 | + if($this->owner->hasField('Locale')) { |
|
280 | 280 | $localeMapping['type'] = 'string'; |
281 | 281 | // we wish the locale to be stored as is |
282 | 282 | $localeMapping['index'] = 'not_analyzed'; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | //_all field picks up all possible suggestions |
296 | 296 | $mapping->enableAllField(); |
297 | 297 | |
298 | - if ($this->owner->hasMethod('updateElasticsearchMapping')) { |
|
298 | + if($this->owner->hasMethod('updateElasticsearchMapping')) { |
|
299 | 299 | $mapping = $this->owner->updateElasticsearchMapping($mapping); |
300 | 300 | } |
301 | 301 | return $mapping; |
@@ -311,20 +311,20 @@ discard block |
||
311 | 311 | self::$index_ctr++; |
312 | 312 | $fields = $this->getFieldValuesAsArray(); |
313 | 313 | |
314 | - if (isset($_GET['progress'])) { |
|
314 | + if(isset($_GET['progress'])) { |
|
315 | 315 | $progress = $_GET['progress']; |
316 | - self::$progressInterval = (int) $progress; |
|
316 | + self::$progressInterval = (int)$progress; |
|
317 | 317 | } |
318 | 318 | |
319 | - if (self::$progressInterval > 0) { |
|
320 | - if (self::$index_ctr % self::$progressInterval === 0) { |
|
321 | - ElasticaUtil::message("\t".$this->owner->ClassName." - Prepared ".self::$index_ctr." for indexing..."); |
|
319 | + if(self::$progressInterval > 0) { |
|
320 | + if(self::$index_ctr % self::$progressInterval === 0) { |
|
321 | + ElasticaUtil::message("\t" . $this->owner->ClassName . " - Prepared " . self::$index_ctr . " for indexing..."); |
|
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | // Optionally update the document |
326 | 326 | $document = new Document($this->owner->ID, $fields); |
327 | - if ($this->owner->hasMethod('updateElasticsearchDocument')) { |
|
327 | + if($this->owner->hasMethod('updateElasticsearchDocument')) { |
|
328 | 328 | $document = $this->owner->updateElasticsearchDocument($document); |
329 | 329 | } |
330 | 330 | |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | |
336 | 336 | $document->set('IsInSiteTree', $inSiteTree); |
337 | 337 | |
338 | - if ($inSiteTree) { |
|
338 | + if($inSiteTree) { |
|
339 | 339 | $document->set('Link', $this->owner->AbsoluteLink()); |
340 | 340 | } |
341 | 341 | |
342 | - if (isset($this->owner->Locale)) { |
|
342 | + if(isset($this->owner->Locale)) { |
|
343 | 343 | $document->set('Locale', $this->owner->Locale); |
344 | 344 | } |
345 | 345 | |
@@ -351,10 +351,10 @@ discard block |
||
351 | 351 | $fields = array(); |
352 | 352 | $has_ones = $this->owner->has_one(); |
353 | 353 | |
354 | - foreach ($this->getElasticaFields($recurse) as $field => $config) { |
|
355 | - if (null === $this->owner->$field && is_callable(get_class($this->owner) . "::" . $field)) { |
|
354 | + foreach($this->getElasticaFields($recurse) as $field => $config) { |
|
355 | + if(null === $this->owner->$field && is_callable(get_class($this->owner) . "::" . $field)) { |
|
356 | 356 | // call a method to get a field value |
357 | - if (in_array($field, $this->html_fields)) { |
|
357 | + if(in_array($field, $this->html_fields)) { |
|
358 | 358 | // Parse short codes in HTML, and then convert to text |
359 | 359 | $fields[$field] = $this->owner->$field; |
360 | 360 | $html = ShortcodeParser::get_active()->parse($this->owner->$field()); |
@@ -366,30 +366,30 @@ discard block |
||
366 | 366 | } |
367 | 367 | |
368 | 368 | } else { |
369 | - if (in_array($field, $this->html_fields)) { |
|
369 | + if(in_array($field, $this->html_fields)) { |
|
370 | 370 | $fields[$field] = $this->owner->$field; |
371 | - if (gettype($this->owner->$field) !== 'NULL') { |
|
371 | + if(gettype($this->owner->$field) !== 'NULL') { |
|
372 | 372 | $html = ShortcodeParser::get_active()->parse($this->owner->$field); |
373 | 373 | $txt = \Convert::html2raw($html); |
374 | 374 | $fields[$field] = $txt; |
375 | 375 | } |
376 | 376 | } else { |
377 | - if (isset($config['properties']['__method'])) { |
|
377 | + if(isset($config['properties']['__method'])) { |
|
378 | 378 | $methodName = $config['properties']['__method']; |
379 | 379 | $data = $this->owner->$methodName(); |
380 | 380 | $relArray = array(); |
381 | 381 | |
382 | 382 | // get the fields of a has_one relational object |
383 | - if (isset($has_ones[$methodName])) { |
|
384 | - if ($data->ID > 0) { |
|
383 | + if(isset($has_ones[$methodName])) { |
|
384 | + if($data->ID > 0) { |
|
385 | 385 | $item = $data->getFieldValuesAsArray(false); |
386 | 386 | $relArray = $item; |
387 | 387 | } |
388 | 388 | |
389 | 389 | // get the fields for a has_many or many_many relational list |
390 | 390 | } else { |
391 | - foreach ($data->getIterator() as $item) { |
|
392 | - if ($recurse) { |
|
391 | + foreach($data->getIterator() as $item) { |
|
392 | + if($recurse) { |
|
393 | 393 | // populate the subitem but do not recurse any further if more relationships |
394 | 394 | $itemDoc = $item->getFieldValuesAsArray(false); |
395 | 395 | array_push($relArray, $itemDoc); |
@@ -426,8 +426,8 @@ discard block |
||
426 | 426 | * Delete the record from the search index if ShowInSearch is deactivated (non-SiteTree). |
427 | 427 | */ |
428 | 428 | public function onBeforeWrite() { |
429 | - if (($this->owner instanceof \SiteTree)) { |
|
430 | - if ($this->owner->hasField('ShowInSearch') && |
|
429 | + if(($this->owner instanceof \SiteTree)) { |
|
430 | + if($this->owner->hasField('ShowInSearch') && |
|
431 | 431 | $this->owner->isChanged('ShowInSearch', 2) && false == $this->owner->ShowInSearch) { |
432 | 432 | $this->doDeleteDocument(); |
433 | 433 | } |
@@ -439,11 +439,11 @@ discard block |
||
439 | 439 | * Delete the record from the search index if ShowInSearch is deactivated (SiteTree). |
440 | 440 | */ |
441 | 441 | public function onBeforePublish() { |
442 | - if (false == $this->owner->ShowInSearch) { |
|
443 | - if ($this->owner->isPublished()) { |
|
442 | + if(false == $this->owner->ShowInSearch) { |
|
443 | + if($this->owner->isPublished()) { |
|
444 | 444 | $liveRecord = \Versioned::get_by_stage(get_class($this->owner), 'Live')-> |
445 | 445 | byID($this->owner->ID); |
446 | - if ($liveRecord->ShowInSearch != $this->owner->ShowInSearch) { |
|
446 | + if($liveRecord->ShowInSearch != $this->owner->ShowInSearch) { |
|
447 | 447 | $this->doDeleteDocument(); |
448 | 448 | } |
449 | 449 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * Updates the record in the search index. |
472 | 472 | */ |
473 | 473 | protected function doIndexDocument() { |
474 | - if ($this->showRecordInSearch()) { |
|
475 | - if (!$this->owner->IndexingOff) { |
|
474 | + if($this->showRecordInSearch()) { |
|
475 | + if(!$this->owner->IndexingOff) { |
|
476 | 476 | $this->service->index($this->owner); |
477 | 477 | } |
478 | 478 | } |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | * Removes the record from the search index if the "ShowInSearch" attribute is set to true. |
500 | 500 | */ |
501 | 501 | protected function doDeleteDocumentIfInSearch() { |
502 | - if ($this->showRecordInSearch()) { |
|
502 | + if($this->showRecordInSearch()) { |
|
503 | 503 | $this->doDeleteDocument(); |
504 | 504 | } |
505 | 505 | } |
@@ -509,14 +509,14 @@ discard block |
||
509 | 509 | * Removes the record from the search index. |
510 | 510 | */ |
511 | 511 | protected function doDeleteDocument() { |
512 | - try{ |
|
513 | - if (!$this->owner->IndexingOff) { |
|
512 | + try { |
|
513 | + if(!$this->owner->IndexingOff) { |
|
514 | 514 | // this goes to elastica service |
515 | 515 | $this->service->remove($this->owner); |
516 | 516 | } |
517 | 517 | } |
518 | - catch(\Elastica\Exception\NotFoundException $e) { |
|
519 | - trigger_error("Deleted document ".$this->owner->ClassName." (".$this->owner->ID. |
|
518 | + catch (\Elastica\Exception\NotFoundException $e) { |
|
519 | + trigger_error("Deleted document " . $this->owner->ClassName . " (" . $this->owner->ID . |
|
520 | 520 | ") not found in search index.", E_USER_NOTICE); |
521 | 521 | } |
522 | 522 | |
@@ -533,42 +533,42 @@ discard block |
||
533 | 533 | $fields = \Config::inst()->get(get_class($this->owner), 'searchable_fields'); |
534 | 534 | |
535 | 535 | // fallback to default method |
536 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$this->owner->ClassName); |
|
536 | + if(!$fields) user_error('The field $searchable_fields must be set for the class ' . $this->owner->ClassName); |
|
537 | 537 | |
538 | 538 | // get the values of these fields |
539 | 539 | $elasticaMapping = $this->fieldsToElasticaConfig($fields); |
540 | 540 | |
541 | - if ($recurse) { |
|
541 | + if($recurse) { |
|
542 | 542 | // now for the associated methods and their results |
543 | 543 | $methodDescs = \Config::inst()->get(get_class($this->owner), 'searchable_relationships'); |
544 | 544 | $has_ones = $this->owner->has_one(); |
545 | 545 | $has_lists = $this->getListRelationshipMethods(); |
546 | 546 | |
547 | - if (isset($methodDescs) && is_array($methodDescs)) { |
|
548 | - foreach ($methodDescs as $methodDesc) { |
|
547 | + if(isset($methodDescs) && is_array($methodDescs)) { |
|
548 | + foreach($methodDescs as $methodDesc) { |
|
549 | 549 | // split before the brackets which can optionally list which fields to index |
550 | 550 | $splits = explode('(', $methodDesc); |
551 | 551 | $methodName = $splits[0]; |
552 | 552 | |
553 | - if (isset($has_lists[$methodName])) { |
|
553 | + if(isset($has_lists[$methodName])) { |
|
554 | 554 | |
555 | 555 | $relClass = $has_lists[$methodName]; |
556 | 556 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
557 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
557 | + if(!$fields) user_error('The field $searchable_fields must be set for the class ' . $relClass); |
|
558 | 558 | $rewrite = $this->fieldsToElasticaConfig($fields); |
559 | 559 | |
560 | 560 | // mark as a method, the resultant fields are correct |
561 | - $elasticaMapping[$methodName.'()'] = $rewrite; |
|
562 | - } else if (isset($has_ones[$methodName])) { |
|
561 | + $elasticaMapping[$methodName . '()'] = $rewrite; |
|
562 | + } else if(isset($has_ones[$methodName])) { |
|
563 | 563 | $relClass = $has_ones[$methodName]; |
564 | 564 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
565 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
565 | + if(!$fields) user_error('The field $searchable_fields must be set for the class ' . $relClass); |
|
566 | 566 | $rewrite = $this->fieldsToElasticaConfig($fields); |
567 | 567 | |
568 | 568 | // mark as a method, the resultant fields are correct |
569 | - $elasticaMapping[$methodName.'()'] = $rewrite; |
|
569 | + $elasticaMapping[$methodName . '()'] = $rewrite; |
|
570 | 570 | } else { |
571 | - user_error('The method '.$methodName.' not found in class '.$this->owner->ClassName. |
|
571 | + user_error('The method ' . $methodName . ' not found in class ' . $this->owner->ClassName . |
|
572 | 572 | ', please check configuration'); |
573 | 573 | } |
574 | 574 | } |
@@ -604,11 +604,11 @@ discard block |
||
604 | 604 | public function requireDefaultRecords() { |
605 | 605 | parent::requireDefaultRecords(); |
606 | 606 | |
607 | - $searchableFields = $this->getElasticaFields(true,true); |
|
607 | + $searchableFields = $this->getElasticaFields(true, true); |
|
608 | 608 | |
609 | 609 | |
610 | 610 | $doSC = \SearchableClass::get()->filter(array('Name' => $this->owner->ClassName))->first(); |
611 | - if (!$doSC) { |
|
611 | + if(!$doSC) { |
|
612 | 612 | $doSC = new \SearchableClass(); |
613 | 613 | $doSC->Name = $this->owner->ClassName; |
614 | 614 | |
@@ -618,9 +618,9 @@ discard block |
||
618 | 618 | $doSC->write(); |
619 | 619 | } |
620 | 620 | |
621 | - foreach ($searchableFields as $name => $searchableField) { |
|
621 | + foreach($searchableFields as $name => $searchableField) { |
|
622 | 622 | // check for existence of methods and if they exist use that as the name |
623 | - if (!isset($searchableField['type'])) { |
|
623 | + if(!isset($searchableField['type'])) { |
|
624 | 624 | $name = $searchableField['properties']['__method']; |
625 | 625 | } |
626 | 626 | |
@@ -628,25 +628,25 @@ discard block |
||
628 | 628 | $doSF = \SearchableField::get()->filter($filter)->first(); |
629 | 629 | |
630 | 630 | |
631 | - if (!$doSF) { |
|
631 | + if(!$doSF) { |
|
632 | 632 | $doSF = new \SearchableField(); |
633 | 633 | $doSF->ClazzName = $this->owner->ClassName; |
634 | 634 | $doSF->Name = $name; |
635 | 635 | |
636 | - if (isset($searchableField['type'])) { |
|
636 | + if(isset($searchableField['type'])) { |
|
637 | 637 | $doSF->Type = $searchableField['type']; |
638 | - } else { |
|
638 | + } else { |
|
639 | 639 | $doSF->Name = $searchableField['properties']['__method']; |
640 | 640 | $doSF->Type = 'relationship'; |
641 | 641 | } |
642 | 642 | $doSF->SearchableClassID = $doSC->ID; |
643 | 643 | |
644 | - if (isset($searchableField['fields']['autocomplete'])) { |
|
644 | + if(isset($searchableField['fields']['autocomplete'])) { |
|
645 | 645 | $doSF->Autocomplete = true; |
646 | 646 | } |
647 | 647 | |
648 | 648 | $doSF->write(); |
649 | - \DB::alteration_message("Created new searchable editable field ".$name,"changed"); |
|
649 | + \DB::alteration_message("Created new searchable editable field " . $name, "changed"); |
|
650 | 650 | } |
651 | 651 | |
652 | 652 | // FIXME deal with deletions |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | |
661 | 661 | // array of method name to retuned object ClassName for relationships returning lists |
662 | 662 | $has_lists = $has_manys; |
663 | - foreach (array_keys($many_manys) as $key) { |
|
663 | + foreach(array_keys($many_manys) as $key) { |
|
664 | 664 | $has_lists[$key] = $many_manys[$key]; |
665 | 665 | } |
666 | 666 | |
@@ -671,11 +671,11 @@ discard block |
||
671 | 671 | private function isInSiteTree($classname) { |
672 | 672 | $inSiteTree = $classname === 'SiteTree' ? true : false; |
673 | 673 | |
674 | - if (!$inSiteTree) { |
|
674 | + if(!$inSiteTree) { |
|
675 | 675 | $class = new \ReflectionClass($this->owner->ClassName); |
676 | - while ($class = $class->getParentClass()) { |
|
676 | + while($class = $class->getParentClass()) { |
|
677 | 677 | $parentClass = $class->getName(); |
678 | - if ($parentClass == 'SiteTree') { |
|
678 | + if($parentClass == 'SiteTree') { |
|
679 | 679 | $inSiteTree = true; |
680 | 680 | break; |
681 | 681 | } |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | */ |
692 | 692 | public function RenderResult($linkToContainer = '') { |
693 | 693 | $vars = new \ArrayData(array('SearchResult' => $this->owner, 'ContainerLink' => $linkToContainer)); |
694 | - $possibleTemplates = array($this->owner->ClassName.'ElasticSearchResult', 'ElasticSearchResult'); |
|
694 | + $possibleTemplates = array($this->owner->ClassName . 'ElasticSearchResult', 'ElasticSearchResult'); |
|
695 | 695 | return $this->owner->customise($vars)->renderWith($possibleTemplates); |
696 | 696 | } |
697 | 697 | |
@@ -705,10 +705,10 @@ discard block |
||
705 | 705 | public function updateCMSFields(\FieldList $fields) { |
706 | 706 | $isIndexed = false; |
707 | 707 | // SIteTree object must have a live record, ShowInSearch = true |
708 | - if ($this->isInSiteTree($this->owner->ClassName)) { |
|
708 | + if($this->isInSiteTree($this->owner->ClassName)) { |
|
709 | 709 | $liveRecord = \Versioned::get_by_stage(get_class($this->owner), 'Live')-> |
710 | 710 | byID($this->owner->ID); |
711 | - if ($liveRecord->ShowInSearch) { |
|
711 | + if($liveRecord->ShowInSearch) { |
|
712 | 712 | $isIndexed = true; |
713 | 713 | } else { |
714 | 714 | $isIndexed = false; |
@@ -718,27 +718,27 @@ discard block |
||
718 | 718 | $isIndexed = true; |
719 | 719 | } |
720 | 720 | |
721 | - if ($isIndexed) { |
|
721 | + if($isIndexed) { |
|
722 | 722 | $termVectors = $this->getTermVectors(); |
723 | 723 | $termFields = array_keys($termVectors); |
724 | 724 | sort($termFields); |
725 | 725 | |
726 | - foreach ($termFields as $field) { |
|
726 | + foreach($termFields as $field) { |
|
727 | 727 | $terms = new \ArrayList(); |
728 | 728 | |
729 | - foreach (array_keys($termVectors[$field]['terms']) as $term) { |
|
729 | + foreach(array_keys($termVectors[$field]['terms']) as $term) { |
|
730 | 730 | $do = new \DataObject(); |
731 | 731 | $do->Term = $term; |
732 | 732 | $stats = $termVectors[$field]['terms'][$term]; |
733 | - if (isset($stats['ttf'])) { |
|
733 | + if(isset($stats['ttf'])) { |
|
734 | 734 | $do->TTF = $stats['ttf']; |
735 | 735 | } |
736 | 736 | |
737 | - if (isset($stats['doc_freq'])) { |
|
737 | + if(isset($stats['doc_freq'])) { |
|
738 | 738 | $do->DocFreq = $stats['doc_freq']; |
739 | 739 | } |
740 | 740 | |
741 | - if (isset($stats['term_freq'])) { |
|
741 | + if(isset($stats['term_freq'])) { |
|
742 | 742 | $do->TermFreq = $stats['term_freq']; |
743 | 743 | } |
744 | 744 | $terms->push($do); |
@@ -755,12 +755,12 @@ discard block |
||
755 | 755 | $underscored = str_replace('.', '_', $field); |
756 | 756 | |
757 | 757 | $gridField = new \GridField( |
758 | - 'TermsFor'.$underscored, // Field name |
|
759 | - $field.'TITLE'.$field, // Field title |
|
758 | + 'TermsFor' . $underscored, // Field name |
|
759 | + $field . 'TITLE' . $field, // Field title |
|
760 | 760 | $terms, |
761 | 761 | $config |
762 | 762 | ); |
763 | - $fields->addFieldToTab('Root.ElasticaTerms.'.$underscored, $gridField); |
|
763 | + $fields->addFieldToTab('Root.ElasticaTerms.' . $underscored, $gridField); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | } |