@@ -29,20 +29,20 @@ discard block |
||
| 29 | 29 | $config->removeComponent($config->getComponentByType('GridFieldDeleteAction')); |
| 30 | 30 | |
| 31 | 31 | $config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array( |
| 32 | - 'Name' => 'Name', |
|
| 33 | - 'Weight' => 'Weighting', |
|
| 34 | - 'Searchable' => 'Search this field?' |
|
| 35 | - )); |
|
| 32 | + 'Name' => 'Name', |
|
| 33 | + 'Weight' => 'Weighting', |
|
| 34 | + 'Searchable' => 'Search this field?' |
|
| 35 | + )); |
|
| 36 | 36 | |
| 37 | 37 | |
| 38 | - $gridField = new GridField( |
|
| 39 | - 'SearchableField', // Field name |
|
| 40 | - 'Field Name', // Field title |
|
| 41 | - SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
| 42 | - $config |
|
| 43 | - ); |
|
| 38 | + $gridField = new GridField( |
|
| 39 | + 'SearchableField', // Field name |
|
| 40 | + 'Field Name', // Field title |
|
| 41 | + SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'), |
|
| 42 | + $config |
|
| 43 | + ); |
|
| 44 | 44 | |
| 45 | - $fields->addFieldToTab('Root.Main', $gridField); |
|
| 45 | + $fields->addFieldToTab('Root.Main', $gridField); |
|
| 46 | 46 | |
| 47 | 47 | /* |
| 48 | 48 | $fields = new FieldList(); |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | */ |
| 53 | - return $fields; |
|
| 53 | + return $fields; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | |
@@ -92,26 +92,26 @@ discard block |
||
| 92 | 92 | //Need to check capitalisation of terms suggested that are different |
| 93 | 93 | |
| 94 | 94 | $chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8"); |
| 95 | - if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
| 96 | - $upperLowercaseWord = $lowercaseWord; |
|
| 97 | - $upperLowercaseWord[0] = $chr; |
|
| 95 | + if (mb_strtolower($chr, "UTF-8") != $chr) { |
|
| 96 | + $upperLowercaseWord = $lowercaseWord; |
|
| 97 | + $upperLowercaseWord[0] = $chr; |
|
| 98 | 98 | |
| 99 | - //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
| 100 | - $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
| 99 | + //$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted); |
|
| 100 | + $withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted); |
|
| 101 | 101 | |
| 102 | - $lowercaseWord[0] = $chr; |
|
| 102 | + $lowercaseWord[0] = $chr; |
|
| 103 | 103 | |
| 104 | - //str_replace(search, replace, subject) |
|
| 104 | + //str_replace(search, replace, subject) |
|
| 105 | 105 | |
| 106 | - array_push($plain, $lowercaseWord); |
|
| 107 | - array_push($highlighted, $withHighlights); |
|
| 108 | - } else { |
|
| 109 | - //No need to capitalise, so add suggested word |
|
| 110 | - array_push($plain, $lowercaseWord); |
|
| 106 | + array_push($plain, $lowercaseWord); |
|
| 107 | + array_push($highlighted, $withHighlights); |
|
| 108 | + } else { |
|
| 109 | + //No need to capitalise, so add suggested word |
|
| 110 | + array_push($plain, $lowercaseWord); |
|
| 111 | 111 | |
| 112 | - //No need to capitalise, so add suggested highlighted word |
|
| 113 | - array_push($highlighted, $possiblyUppercaseHighlighted); |
|
| 114 | - } |
|
| 112 | + //No need to capitalise, so add suggested highlighted word |
|
| 113 | + array_push($highlighted, $possiblyUppercaseHighlighted); |
|
| 114 | + } |
|
| 115 | 115 | } |
| 116 | 116 | } |
| 117 | 117 | |
@@ -144,37 +144,37 @@ discard block |
||
| 144 | 144 | |
| 145 | 145 | $explanation = explode('-ConstantScore', $explanation)[0]; |
| 146 | 146 | |
| 147 | - $bracketPos = strpos($explanation, ')~'); |
|
| 147 | + $bracketPos = strpos($explanation, ')~'); |
|
| 148 | 148 | |
| 149 | - if (substr($explanation, 0,2) == '((') { |
|
| 150 | - $explanation = substr($explanation, 2, $bracketPos-2); |
|
| 151 | - } elseif (substr($explanation, 0,1) == '(') { |
|
| 152 | - $explanation = substr($explanation, 1, $bracketPos-2); |
|
| 153 | - } |
|
| 149 | + if (substr($explanation, 0,2) == '((') { |
|
| 150 | + $explanation = substr($explanation, 2, $bracketPos-2); |
|
| 151 | + } elseif (substr($explanation, 0,1) == '(') { |
|
| 152 | + $explanation = substr($explanation, 1, $bracketPos-2); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - $terms = array(); |
|
| 155 | + $terms = array(); |
|
| 156 | 156 | |
| 157 | - //Field name(s) => terms |
|
| 158 | - $splits = explode(' ', $explanation); |
|
| 157 | + //Field name(s) => terms |
|
| 158 | + $splits = explode(' ', $explanation); |
|
| 159 | 159 | |
| 160 | - foreach ($splits as $fieldAndTerm) { |
|
| 161 | - $splits = explode(':', $fieldAndTerm); |
|
| 160 | + foreach ($splits as $fieldAndTerm) { |
|
| 161 | + $splits = explode(':', $fieldAndTerm); |
|
| 162 | 162 | |
| 163 | - // This is the no terms case |
|
| 164 | - if (sizeof($splits) < 2) { |
|
| 165 | - break; |
|
| 166 | - } |
|
| 163 | + // This is the no terms case |
|
| 164 | + if (sizeof($splits) < 2) { |
|
| 165 | + break; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - $fieldname = $splits[0]; |
|
| 169 | - $term = $splits[1]; |
|
| 168 | + $fieldname = $splits[0]; |
|
| 169 | + $term = $splits[1]; |
|
| 170 | 170 | |
| 171 | - if (!isset($terms[$fieldname])) { |
|
| 172 | - $terms[$fieldname] = array(); |
|
| 173 | - } |
|
| 171 | + if (!isset($terms[$fieldname])) { |
|
| 172 | + $terms[$fieldname] = array(); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - array_push($terms[$fieldname], $term); |
|
| 176 | - } |
|
| 175 | + array_push($terms[$fieldname], $term); |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - return $terms; |
|
| 178 | + return $terms; |
|
| 179 | 179 | } |
| 180 | 180 | } |
@@ -208,11 +208,11 @@ |
||
| 208 | 208 | */ |
| 209 | 209 | public function invokeMethod(&$object, $methodName, array $parameters = array()) |
| 210 | 210 | { |
| 211 | - $reflection = new \ReflectionClass(get_class($object)); |
|
| 212 | - $method = $reflection->getMethod($methodName); |
|
| 213 | - $method->setAccessible(true); |
|
| 211 | + $reflection = new \ReflectionClass(get_class($object)); |
|
| 212 | + $method = $reflection->getMethod($methodName); |
|
| 213 | + $method->setAccessible(true); |
|
| 214 | 214 | |
| 215 | - return $method->invokeArgs($object, $parameters); |
|
| 215 | + return $method->invokeArgs($object, $parameters); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | |
@@ -139,37 +139,37 @@ discard block |
||
| 139 | 139 | * Add a mapping for the location of the photograph |
| 140 | 140 | */ |
| 141 | 141 | public function updateElasticsearchMapping(\Elastica\Type\Mapping $mapping) |
| 142 | - { |
|
| 143 | - // get the properties of the individual fields as an array |
|
| 144 | - $properties = $mapping->getProperties(); |
|
| 145 | - |
|
| 146 | - // add a location with geo point |
|
| 147 | - $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
| 148 | - $properties['location'] = array( |
|
| 149 | - 'type' => 'geo_point', |
|
| 150 | - 'fielddata' => $precision1cm, |
|
| 151 | - ); |
|
| 152 | - |
|
| 153 | - $properties['ShutterSpeed'] = array( |
|
| 154 | - 'type' => 'string', |
|
| 155 | - 'index' => 'not_analyzed' |
|
| 142 | + { |
|
| 143 | + // get the properties of the individual fields as an array |
|
| 144 | + $properties = $mapping->getProperties(); |
|
| 145 | + |
|
| 146 | + // add a location with geo point |
|
| 147 | + $precision1cm = array('format' => 'compressed', 'precision' => '1cm'); |
|
| 148 | + $properties['location'] = array( |
|
| 149 | + 'type' => 'geo_point', |
|
| 150 | + 'fielddata' => $precision1cm, |
|
| 156 | 151 | ); |
| 157 | 152 | |
| 158 | - $properties['Aperture'] = array( |
|
| 159 | - // do not use float as the rounding makes facets impossible |
|
| 160 | - 'type' => 'double' |
|
| 161 | - ); |
|
| 153 | + $properties['ShutterSpeed'] = array( |
|
| 154 | + 'type' => 'string', |
|
| 155 | + 'index' => 'not_analyzed' |
|
| 156 | + ); |
|
| 162 | 157 | |
| 163 | - $properties['FlickrID'] = array('type' => 'integer'); |
|
| 158 | + $properties['Aperture'] = array( |
|
| 159 | + // do not use float as the rounding makes facets impossible |
|
| 160 | + 'type' => 'double' |
|
| 161 | + ); |
|
| 164 | 162 | |
| 165 | - // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
| 166 | - //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
| 163 | + $properties['FlickrID'] = array('type' => 'integer'); |
|
| 167 | 164 | |
| 168 | - // set the new properties on the mapping |
|
| 169 | - $mapping->setProperties($properties); |
|
| 165 | + // by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s |
|
| 166 | + //$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s'); |
|
| 170 | 167 | |
| 171 | - return $mapping; |
|
| 172 | - } |
|
| 168 | + // set the new properties on the mapping |
|
| 169 | + $mapping->setProperties($properties); |
|
| 170 | + |
|
| 171 | + return $mapping; |
|
| 172 | + } |
|
| 173 | 173 | |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | $sortable = $sortable . '|' . $this->owner->ShutterSpeed; |
| 207 | 207 | $document->set('ShutterSpeed', $sortable); |
| 208 | - return $document; |
|
| 208 | + return $document; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | public function __construct() { |
| 12 | 12 | $aspectAgg = new RangedAggregation('Aspect', 'AspectRatio'); |
| 13 | - $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
| 14 | - $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
| 15 | - $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
| 16 | - $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
| 17 | - $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
| 13 | + $aspectAgg->addRange(0.0000001, 0.3, 'Panoramic'); |
|
| 14 | + $aspectAgg->addRange(0.3, 0.9, 'Horizontal'); |
|
| 15 | + $aspectAgg->addRange(0.9, 1.2, 'Square'); |
|
| 16 | + $aspectAgg->addRange(1.2, 1.79, 'Vertical'); |
|
| 17 | + $aspectAgg->addRange(1.79, 1e7, 'Tallest'); |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | private static $titleFieldMapping = array( |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | |
| 75 | 75 | $aspectRangedAgg = RangedAggregation::getByTitle('Aspect'); |
| 76 | - $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
| 76 | + $query->addAggregation($aspectRangedAgg->getRangeAgg()); |
|
| 77 | 77 | |
| 78 | 78 | // leave this out for the moment as way too many terms being returned slowing things down |
| 79 | 79 | /* |
@@ -140,7 +140,7 @@ |
||
| 140 | 140 | |
| 141 | 141 | public function testEach() { |
| 142 | 142 | $callback = function($fp) { |
| 143 | - $this->assertTrue(true, 'Callback reached'); |
|
| 143 | + $this->assertTrue(true, 'Callback reached'); |
|
| 144 | 144 | }; |
| 145 | 145 | $resultList = $this->getResultsFor('New Zealand',10); |
| 146 | 146 | $resultList->each($callback); |
@@ -434,11 +434,11 @@ discard block |
||
| 434 | 434 | |
| 435 | 435 | |
| 436 | 436 | |
| 437 | - $query = new Query(); |
|
| 438 | - $query->setParams(array('query' => array('more_like_this' => $mlt))); |
|
| 437 | + $query = new Query(); |
|
| 438 | + $query->setParams(array('query' => array('more_like_this' => $mlt))); |
|
| 439 | 439 | |
| 440 | 440 | |
| 441 | - $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService'); |
|
| 441 | + $elasticService = \Injector::inst()->create('SilverStripe\Elastica\ElasticaService'); |
|
| 442 | 442 | $elasticService->setLocale($this->locale); |
| 443 | 443 | if ($testMode) { |
| 444 | 444 | $elasticService->setTestMode(true); |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | $query->setFrom($this->start); |
| 451 | 451 | |
| 452 | 452 | $resultList = new ResultList($elasticService, $query, null); |
| 453 | - // at this point ResultList object, not yet executed search query |
|
| 453 | + // at this point ResultList object, not yet executed search query |
|
| 454 | 454 | $paginated = new \PaginatedList( |
| 455 | 455 | $resultList |
| 456 | 456 | ); |
@@ -38,8 +38,8 @@ |
||
| 38 | 38 | $to = $range['to']; |
| 39 | 39 | } |
| 40 | 40 | $rangeFilter = array('gte' => (string)$from, 'lt' => (string)$to); |
| 41 | - $filter = new \Elastica\Filter\Range('AspectRatio', $rangeFilter); |
|
| 42 | - $result = $filter; |
|
| 41 | + $filter = new \Elastica\Filter\Range('AspectRatio', $rangeFilter); |
|
| 42 | + $result = $filter; |
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
@@ -214,7 +214,7 @@ |
||
| 214 | 214 | $analyzers['folded'] = $analyzerFolded; |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | - //Store bigrams in the index, namely pairs of words |
|
| 217 | + //Store bigrams in the index, namely pairs of words |
|
| 218 | 218 | $this->addFilter('filter_shingle', array( |
| 219 | 219 | 'type' => 'shingle', |
| 220 | 220 | 'min_shingle_size' => 2, |