@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | /** |
| 199 | - * @return function print content to either web browser or command line. Can be optionally supressed |
|
| 199 | + * @return \Closure print content to either web browser or command line. Can be optionally supressed |
|
| 200 | 200 | */ |
| 201 | 201 | public static function getPrinter() { |
| 202 | 202 | return function ($content) { |
@@ -211,6 +211,7 @@ discard block |
||
| 211 | 211 | * Set to true to show output on the command line or browser, false to not |
| 212 | 212 | * |
| 213 | 213 | * @param $newcli_printer_output true to show output, false to hide it |
| 214 | + * @param boolean $new_cli_printer_output |
|
| 214 | 215 | */ |
| 215 | 216 | public static function setPrinterOutput($new_cli_printer_output) { |
| 216 | 217 | self::$cli_printer_output = $new_cli_printer_output; |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | * @var string $content Text to display when in command line mode |
| 29 | 29 | */ |
| 30 | 30 | public static function message($content) { |
| 31 | - if (\Director::is_cli() && self::$cli_printer_output == true) { |
|
| 31 | + if(\Director::is_cli() && self::$cli_printer_output == true) { |
|
| 32 | 32 | echo "$content\n"; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $options = $alternativeQuerySuggestions[0]['options']; |
| 54 | 54 | |
| 55 | 55 | $resultArray = null; |
| 56 | - if (sizeof($options) > 0) { |
|
| 56 | + if(sizeof($options) > 0) { |
|
| 57 | 57 | //take the first suggestion |
| 58 | 58 | $suggestedPhrase = $options[0]['text']; |
| 59 | 59 | $suggestedPhraseHighlighted = $options[0]['highlighted']; |
@@ -62,10 +62,10 @@ discard block |
||
| 62 | 62 | $originalParts = explode(' ', $originalQuery); |
| 63 | 63 | $suggestedParts = explode(' ', $suggestedPhrase); |
| 64 | 64 | |
| 65 | - $markedHighlightedParts = ' '.$suggestedPhraseHighlighted.' '; |
|
| 66 | - $markedHighlightedParts = str_replace(' '.$preTags, ' '.self::$pre_marker, $markedHighlightedParts); |
|
| 65 | + $markedHighlightedParts = ' ' . $suggestedPhraseHighlighted . ' '; |
|
| 66 | + $markedHighlightedParts = str_replace(' ' . $preTags, ' ' . self::$pre_marker, $markedHighlightedParts); |
|
| 67 | 67 | |
| 68 | - $markedHighlightedParts = str_replace($postTags.' ', self::$post_marker, $markedHighlightedParts); |
|
| 68 | + $markedHighlightedParts = str_replace($postTags . ' ', self::$post_marker, $markedHighlightedParts); |
|
| 69 | 69 | |
| 70 | 70 | $markedHighlightedParts = trim($markedHighlightedParts); |
| 71 | 71 | $markedHighlightedParts = trim($markedHighlightedParts); |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $lowerToUpper = array(); |
| 77 | 77 | $lowerToHighlighted = array(); |
| 78 | 78 | $ctr = 0; |
| 79 | - foreach ($suggestedParts as $lowercaseWord) { |
|
| 79 | + foreach($suggestedParts as $lowercaseWord) { |
|
| 80 | 80 | $lowerToUpper[$lowercaseWord] = $originalParts[$ctr]; |
| 81 | 81 | $lowerToHighlighted[$lowercaseWord] = $highlightedParts[$ctr]; |
| 82 | 82 | $ctr++; |
@@ -84,19 +84,19 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | $plain = array(); |
| 86 | 86 | $highlighted = array(); |
| 87 | - foreach ($suggestedParts as $lowercaseWord) { |
|
| 87 | + foreach($suggestedParts as $lowercaseWord) { |
|
| 88 | 88 | $possiblyUppercase = $lowerToUpper[$lowercaseWord]; |
| 89 | 89 | $possiblyUppercaseHighlighted = $lowerToHighlighted[$lowercaseWord]; |
| 90 | 90 | |
| 91 | 91 | //If the terms are identical other than case, e.g. new => New, then simply swap |
| 92 | - if (strtolower($possiblyUppercase) == $lowercaseWord) { |
|
| 92 | + if(strtolower($possiblyUppercase) == $lowercaseWord) { |
|
| 93 | 93 | array_push($plain, $possiblyUppercase); |
| 94 | 94 | array_push($highlighted, $possiblyUppercase); |
| 95 | 95 | } else { |
| 96 | 96 | //Need to check capitalisation of terms suggested that are different |
| 97 | 97 | |
| 98 | - $chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8"); |
|
| 99 | - if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
| 98 | + $chr = mb_substr($possiblyUppercase, 0, 1, "UTF-8"); |
|
| 99 | + if(mb_strtolower($chr, "UTF-8") != $chr) { |
|
| 100 | 100 | $upperLowercaseWord = $lowercaseWord; |
| 101 | 101 | $upperLowercaseWord[0] = $chr; |
| 102 | 102 | |
@@ -119,9 +119,9 @@ discard block |
||
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $highlighted = ' '.implode(' ', $highlighted).' '; |
|
| 123 | - $highlighted = str_replace(self::$pre_marker, ' '.$preTags, $highlighted); |
|
| 124 | - $highlighted = str_replace(self::$post_marker, $postTags.' ', $highlighted); |
|
| 122 | + $highlighted = ' ' . implode(' ', $highlighted) . ' '; |
|
| 123 | + $highlighted = str_replace(self::$pre_marker, ' ' . $preTags, $highlighted); |
|
| 124 | + $highlighted = str_replace(self::$post_marker, $postTags . ' ', $highlighted); |
|
| 125 | 125 | |
| 126 | 126 | $resultArray['suggestedQuery'] = implode(' ', $plain); |
| 127 | 127 | $resultArray['suggestedQueryHighlighted'] = trim($highlighted); |
@@ -150,10 +150,10 @@ discard block |
||
| 150 | 150 | |
| 151 | 151 | $bracketPos = strpos($explanation, ')~'); |
| 152 | 152 | |
| 153 | - if (substr($explanation, 0,2) == '((') { |
|
| 154 | - $explanation = substr($explanation, 2, $bracketPos-2); |
|
| 155 | - } elseif (substr($explanation, 0,1) == '(') { |
|
| 156 | - $explanation = substr($explanation, 1, $bracketPos-2); |
|
| 153 | + if(substr($explanation, 0, 2) == '((') { |
|
| 154 | + $explanation = substr($explanation, 2, $bracketPos - 2); |
|
| 155 | + } elseif(substr($explanation, 0, 1) == '(') { |
|
| 156 | + $explanation = substr($explanation, 1, $bracketPos - 2); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $terms = array(); |
@@ -161,18 +161,18 @@ discard block |
||
| 161 | 161 | //Field name(s) => terms |
| 162 | 162 | $splits = explode(' ', $explanation); |
| 163 | 163 | |
| 164 | - foreach ($splits as $fieldAndTerm) { |
|
| 164 | + foreach($splits as $fieldAndTerm) { |
|
| 165 | 165 | $splits = explode(':', $fieldAndTerm); |
| 166 | 166 | |
| 167 | 167 | // This is the no terms case |
| 168 | - if (sizeof($splits) < 2) { |
|
| 168 | + if(sizeof($splits) < 2) { |
|
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | $fieldname = $splits[0]; |
| 173 | 173 | $term = $splits[1]; |
| 174 | 174 | |
| 175 | - if (!isset($terms[$fieldname])) { |
|
| 175 | + if(!isset($terms[$fieldname])) { |
|
| 176 | 176 | $terms[$fieldname] = array(); |
| 177 | 177 | } |
| 178 | 178 | |
@@ -199,8 +199,8 @@ discard block |
||
| 199 | 199 | * @return function print content to either web browser or command line. Can be optionally supressed |
| 200 | 200 | */ |
| 201 | 201 | public static function getPrinter() { |
| 202 | - return function ($content) { |
|
| 203 | - if (self::$cli_printer_output == true) { |
|
| 202 | + return function($content) { |
|
| 203 | + if(self::$cli_printer_output == true) { |
|
| 204 | 204 | print(\Director::is_cli() ? "T1 $content\n" : "T2 <p>$content</p>"); |
| 205 | 205 | } |
| 206 | 206 | |
@@ -35,9 +35,9 @@ discard block |
||
| 35 | 35 | sort($aggregations); |
| 36 | 36 | |
| 37 | 37 | error_log('AGGS'); |
| 38 | - foreach ($aggregations as $agg) { |
|
| 38 | + foreach($aggregations as $agg) { |
|
| 39 | 39 | error_log($agg->Name); |
| 40 | - foreach ($agg->Buckets() as $value => $count) { |
|
| 40 | + foreach($agg->Buckets() as $value => $count) { |
|
| 41 | 41 | error_log("\t$value -> $count"); |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | $resultList = $this->search(''); |
| 432 | 432 | |
| 433 | 433 | //assert there are actually some results |
| 434 | - $this->assertGreaterThan(0,$resultList->getTotalItems()); |
|
| 434 | + $this->assertGreaterThan(0, $resultList->getTotalItems()); |
|
| 435 | 435 | $aggregations = $resultList->getAggregations()->toArray(); |
| 436 | 436 | |
| 437 | 437 | /* |
@@ -450,49 +450,49 @@ discard block |
||
| 450 | 450 | //Asserting aggregate of ISO, 64 has count 5 |
| 451 | 451 | $this->assertEquals("64", $buckets[0]->Key); |
| 452 | 452 | $this->assertEquals(5, $buckets[0]->DocumentCount); |
| 453 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); |
|
| 453 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); |
|
| 454 | 454 | $bucketSum += $buckets[0]->DocumentCount; |
| 455 | 455 | |
| 456 | 456 | //Asserting aggregate of ISO, 100 has count 11 |
| 457 | 457 | $this->assertEquals("100", $buckets[1]->Key); |
| 458 | 458 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
| 459 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); |
|
| 459 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); |
|
| 460 | 460 | $bucketSum += $buckets[1]->DocumentCount; |
| 461 | 461 | |
| 462 | 462 | //Asserting aggregate of ISO, 200 has count 12 |
| 463 | 463 | $this->assertEquals("200", $buckets[2]->Key); |
| 464 | 464 | $this->assertEquals(12, $buckets[2]->DocumentCount); |
| 465 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); |
|
| 465 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); |
|
| 466 | 466 | $bucketSum += $buckets[2]->DocumentCount; |
| 467 | 467 | |
| 468 | 468 | //Asserting aggregate of ISO, 400 has count 13 |
| 469 | 469 | $this->assertEquals("400", $buckets[3]->Key); |
| 470 | 470 | $this->assertEquals(13, $buckets[3]->DocumentCount); |
| 471 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); |
|
| 471 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); |
|
| 472 | 472 | $bucketSum += $buckets[3]->DocumentCount; |
| 473 | 473 | |
| 474 | 474 | //Asserting aggregate of ISO, 800 has count 16 |
| 475 | 475 | $this->assertEquals("800", $buckets[4]->Key); |
| 476 | 476 | $this->assertEquals(16, $buckets[4]->DocumentCount); |
| 477 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); |
|
| 477 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); |
|
| 478 | 478 | $bucketSum += $buckets[4]->DocumentCount; |
| 479 | 479 | |
| 480 | 480 | //Asserting aggregate of ISO, 1600 has count 13 |
| 481 | 481 | $this->assertEquals("1600", $buckets[5]->Key); |
| 482 | 482 | $this->assertEquals(13, $buckets[5]->DocumentCount); |
| 483 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); |
|
| 483 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); |
|
| 484 | 484 | $bucketSum += $buckets[5]->DocumentCount; |
| 485 | 485 | |
| 486 | 486 | //Asserting aggregate of ISO, 2000 has count 11 |
| 487 | 487 | $this->assertEquals("2000", $buckets[6]->Key); |
| 488 | 488 | $this->assertEquals(11, $buckets[6]->DocumentCount); |
| 489 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); |
|
| 489 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); |
|
| 490 | 490 | $bucketSum += $buckets[6]->DocumentCount; |
| 491 | 491 | |
| 492 | 492 | //Asserting aggregate of ISO, 3200 has count 19 |
| 493 | 493 | $this->assertEquals("3200", $buckets[7]->Key); |
| 494 | 494 | $this->assertEquals(19, $buckets[7]->DocumentCount); |
| 495 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); |
|
| 495 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); |
|
| 496 | 496 | $bucketSum += $buckets[7]->DocumentCount; |
| 497 | 497 | $this->assertEquals(100, $bucketSum); |
| 498 | 498 | |
@@ -505,43 +505,43 @@ discard block |
||
| 505 | 505 | //Asserting aggregate of Focal Length, 24 has count 12 |
| 506 | 506 | $this->assertEquals("24", $buckets[0]->Key); |
| 507 | 507 | $this->assertEquals(12, $buckets[0]->DocumentCount); |
| 508 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); |
|
| 508 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); |
|
| 509 | 509 | $bucketSum += $buckets[0]->DocumentCount; |
| 510 | 510 | |
| 511 | 511 | //Asserting aggregate of Focal Length, 50 has count 11 |
| 512 | 512 | $this->assertEquals("50", $buckets[1]->Key); |
| 513 | 513 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
| 514 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); |
|
| 514 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); |
|
| 515 | 515 | $bucketSum += $buckets[1]->DocumentCount; |
| 516 | 516 | |
| 517 | 517 | //Asserting aggregate of Focal Length, 80 has count 11 |
| 518 | 518 | $this->assertEquals("80", $buckets[2]->Key); |
| 519 | 519 | $this->assertEquals(11, $buckets[2]->DocumentCount); |
| 520 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); |
|
| 520 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); |
|
| 521 | 521 | $bucketSum += $buckets[2]->DocumentCount; |
| 522 | 522 | |
| 523 | 523 | //Asserting aggregate of Focal Length, 90 has count 20 |
| 524 | 524 | $this->assertEquals("90", $buckets[3]->Key); |
| 525 | 525 | $this->assertEquals(20, $buckets[3]->DocumentCount); |
| 526 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); |
|
| 526 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); |
|
| 527 | 527 | $bucketSum += $buckets[3]->DocumentCount; |
| 528 | 528 | |
| 529 | 529 | //Asserting aggregate of Focal Length, 120 has count 12 |
| 530 | 530 | $this->assertEquals("120", $buckets[4]->Key); |
| 531 | 531 | $this->assertEquals(12, $buckets[4]->DocumentCount); |
| 532 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); |
|
| 532 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); |
|
| 533 | 533 | $bucketSum += $buckets[4]->DocumentCount; |
| 534 | 534 | |
| 535 | 535 | //Asserting aggregate of Focal Length, 150 has count 17 |
| 536 | 536 | $this->assertEquals("150", $buckets[5]->Key); |
| 537 | 537 | $this->assertEquals(17, $buckets[5]->DocumentCount); |
| 538 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); |
|
| 538 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); |
|
| 539 | 539 | $bucketSum += $buckets[5]->DocumentCount; |
| 540 | 540 | |
| 541 | 541 | //Asserting aggregate of Focal Length, 200 has count 17 |
| 542 | 542 | $this->assertEquals("200", $buckets[6]->Key); |
| 543 | 543 | $this->assertEquals(17, $buckets[6]->DocumentCount); |
| 544 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); |
|
| 544 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); |
|
| 545 | 545 | $bucketSum += $buckets[6]->DocumentCount; |
| 546 | 546 | $this->assertEquals(100, $bucketSum); |
| 547 | 547 | |
@@ -829,7 +829,7 @@ discard block |
||
| 829 | 829 | $originalAggregations = $resultList->getAggregations()->toArray(); |
| 830 | 830 | |
| 831 | 831 | $filters = array('ISO' => 3200); |
| 832 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
| 832 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
| 833 | 833 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
| 834 | 834 | |
| 835 | 835 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -841,8 +841,8 @@ discard block |
||
| 841 | 841 | $resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); |
| 842 | 842 | $originalAggregations = $resultList->getAggregations()->toArray(); |
| 843 | 843 | |
| 844 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); |
|
| 845 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
| 844 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical'); |
|
| 845 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
| 846 | 846 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
| 847 | 847 | |
| 848 | 848 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -857,8 +857,8 @@ discard block |
||
| 857 | 857 | 'Aspect' => 'Vertical')); |
| 858 | 858 | $originalAggregations = $resultList->getAggregations()->toArray(); |
| 859 | 859 | |
| 860 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); |
|
| 861 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
| 860 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); |
|
| 861 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
| 862 | 862 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
| 863 | 863 | |
| 864 | 864 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) { |
| 899 | 899 | $aggCtr = 0; |
| 900 | 900 | |
| 901 | - foreach ($filteredAggregations as $filteredAgg) { |
|
| 901 | + foreach($filteredAggregations as $filteredAgg) { |
|
| 902 | 902 | $origAgg = $originalAggregations[$aggCtr]; |
| 903 | 903 | $bucketCtr = 0; |
| 904 | 904 | $origBuckets = $origAgg->Buckets->toArray(); |
@@ -907,17 +907,17 @@ discard block |
||
| 907 | 907 | $origCounts = array(); |
| 908 | 908 | $filteredCounts = array(); |
| 909 | 909 | |
| 910 | - foreach ($origBuckets as $bucket) { |
|
| 910 | + foreach($origBuckets as $bucket) { |
|
| 911 | 911 | $origCounts[$bucket->Key] = $bucket->DocumentCount; |
| 912 | 912 | } |
| 913 | 913 | |
| 914 | - foreach ($filteredBuckets as $bucket) { |
|
| 914 | + foreach($filteredBuckets as $bucket) { |
|
| 915 | 915 | $filteredCounts[$bucket->Key] = $bucket->DocumentCount; |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | $akf = array_keys($filteredCounts); |
| 919 | 919 | |
| 920 | - foreach ($akf as $aggregateKey) { |
|
| 920 | + foreach($akf as $aggregateKey) { |
|
| 921 | 921 | $this->assertGreaterThanOrEqual( |
| 922 | 922 | $filteredCounts[$aggregateKey], $origCounts[$aggregateKey] |
| 923 | 923 | ); |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
| 954 | 954 | |
| 955 | 955 | //Add filters |
| 956 | - foreach ($filters as $key => $value) { |
|
| 957 | - $es->addFilter($key,$value); |
|
| 956 | + foreach($filters as $key => $value) { |
|
| 957 | + $es->addFilter($key, $value); |
|
| 958 | 958 | } |
| 959 | 959 | |
| 960 | 960 | $es->showResultsForEmptySearch(); |
@@ -973,7 +973,7 @@ discard block |
||
| 973 | 973 | * Test searching |
| 974 | 974 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
| 975 | 975 | */ |
| 976 | - private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
|
| 976 | + private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), |
|
| 977 | 977 | $filters = array()) { |
| 978 | 978 | $es = new ElasticSearcher(); |
| 979 | 979 | $es->setStart(0); |
@@ -982,8 +982,8 @@ discard block |
||
| 982 | 982 | $es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); |
| 983 | 983 | |
| 984 | 984 | //Add filters |
| 985 | - foreach ($filters as $key => $value) { |
|
| 986 | - $es->addFilter($key,$value); |
|
| 985 | + foreach($filters as $key => $value) { |
|
| 986 | + $es->addFilter($key, $value); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | $es->showResultsForEmptySearch(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | $locales = array(); |
| 33 | 33 | if(class_exists('Translatable') && singleton('SiteTree')->hasExtension('Translatable')) { |
| 34 | - foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 34 | + foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 35 | 35 | array_push($locales, $code); |
| 36 | 36 | } |
| 37 | 37 | } else { |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | // now iterate all the locales indexing each locale in turn using it's owner index settings |
| 42 | - foreach ($locales as $locale) { |
|
| 42 | + foreach($locales as $locale) { |
|
| 43 | 43 | Searchable::$index_ctr = 0; |
| 44 | - $message('Indexing locale '.$locale); |
|
| 44 | + $message('Indexing locale ' . $locale); |
|
| 45 | 45 | |
| 46 | - if (class_exists('Translatable')) { |
|
| 46 | + if(class_exists('Translatable')) { |
|
| 47 | 47 | \Translatable::set_current_locale($locale); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -60,10 +60,10 @@ discard block |
||
| 60 | 60 | $this->service->refresh(); |
| 61 | 61 | // display indexing speed stats |
| 62 | 62 | $endTime = microtime(true); |
| 63 | - $elapsed = $endTime-$startTime; |
|
| 63 | + $elapsed = $endTime - $startTime; |
|
| 64 | 64 | $perSecond = Searchable::$index_ctr / $elapsed; |
| 65 | - $info = "\nReindexing $locale completed \n ".Searchable::$index_ctr." docs in ".round($elapsed,2)." seconds "; |
|
| 66 | - $info .= "at ".round($perSecond,2)." documents per second\n\n"; |
|
| 65 | + $info = "\nReindexing $locale completed \n " . Searchable::$index_ctr . " docs in " . round($elapsed, 2) . " seconds "; |
|
| 66 | + $info .= "at " . round($perSecond, 2) . " documents per second\n\n"; |
|
| 67 | 67 | $message($info); |
| 68 | 68 | } |
| 69 | 69 | |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | $locales = array(); |
| 27 | 27 | |
| 28 | - if ($this->locale == null) { |
|
| 29 | - if (class_exists('Translatable') && \SiteTree::has_extension('Translatable')) { |
|
| 28 | + if($this->locale == null) { |
|
| 29 | + if(class_exists('Translatable') && \SiteTree::has_extension('Translatable')) { |
|
| 30 | 30 | $this->locale = \Translatable::get_current_locale(); |
| 31 | 31 | } else { |
| 32 | - foreach (\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 32 | + foreach(\Translatable::get_existing_content_languages('SiteTree') as $code => $val) { |
|
| 33 | 33 | array_push($locales, $code); |
| 34 | 34 | } |
| 35 | 35 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | $es->setPageLength(20); |
| 43 | 43 | $es->addFilter('IsInSiteTree', true); |
| 44 | 44 | $results = $es->search($query); |
| 45 | - foreach ($results as $result) { |
|
| 46 | - $title = '['.$result->ClassName.', '.$result->ID.'] '; |
|
| 45 | + foreach($results as $result) { |
|
| 46 | + $title = '[' . $result->ClassName . ', ' . $result->ID . '] '; |
|
| 47 | 47 | $title .= $result->Title; |
| 48 | 48 | $message($title); |
| 49 | - if ($result->SearchHighlightsByField->Content) { |
|
| 50 | - foreach ($result->SearchHighlightsByField->Content as $highlight) { |
|
| 51 | - $message("- ".$highlight->Snippet); |
|
| 49 | + if($result->SearchHighlightsByField->Content) { |
|
| 50 | + foreach($result->SearchHighlightsByField->Content as $highlight) { |
|
| 51 | + $message("- " . $highlight->Snippet); |
|
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |