Completed
Push — dev2 ( 88484c...a481f8 )
by Gordon
17:23
created
code/ElasticaUtil.php 3 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -92,26 +92,26 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
tests/ElasticsearchTestBase.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -208,11 +208,11 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 	public static $ignoreFixtureFileFor = array();
9 9
 
10 10
 	protected $extraDataObjects = array(
11
-		'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO',
12
-		'SearchableTestFatherPage','SearchableTestGrandFatherPage','AutoCompleteOption'
11
+		'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO',
12
+		'SearchableTestFatherPage', 'SearchableTestGrandFatherPage', 'AutoCompleteOption'
13 13
 	);
14 14
 
15 15
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 
41 41
 		// this needs to be called in order to create the list of searchable
42 42
 		// classes and fields that are available.  Simulates part of a build
43
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
43
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
44 44
 			'FlickrTagTO', 'FlickrAuthorTO');
45 45
 		$this->requireDefaultRecordsFrom = $classes;
46 46
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		$this->service->setTestMode(true);
51 51
 
52 52
 		// A previous test may have deleted the index and then failed, so check for this
53
-		if (!$this->service->getIndex()->exists()) {
53
+		if(!$this->service->getIndex()->exists()) {
54 54
 			$this->service->getIndex()->create();
55 55
 		}
56 56
 		$this->service->reset();
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
 		$orig_fixture_file = static::$fixture_file;
63 63
 
64
-		foreach (static::$ignoreFixtureFileFor as $testPattern) {
65
-			$pattern = '/'.$testPattern.'/';
66
-			if (preg_match($pattern, $this->getName())) {
64
+		foreach(static::$ignoreFixtureFileFor as $testPattern) {
65
+			$pattern = '/' . $testPattern . '/';
66
+			if(preg_match($pattern, $this->getName())) {
67 67
 				static::$fixture_file = null;
68 68
 			}
69 69
 		}
@@ -92,55 +92,55 @@  discard block
 block discarded – undo
92 92
 
93 93
 
94 94
 	private function publishSiteTree() {
95
-		foreach (SiteTree::get()->getIterator() as $page) {
95
+		foreach(SiteTree::get()->getIterator() as $page) {
96 96
 			// temporarily disable Elasticsearch indexing, it will be done in a batch
97 97
 			$page->IndexingOff = true;
98
-			$page->publish('Stage','Live');
98
+			$page->publish('Stage', 'Live');
99 99
 		}
100 100
 	}
101 101
 
102 102
 
103 103
 	public function generateAssertionsFromArray($toAssert) {
104
-		echo '$expected = array('."\n";
105
-		foreach ($toAssert as $key => $value) {
104
+		echo '$expected = array(' . "\n";
105
+		foreach($toAssert as $key => $value) {
106 106
 			$escValue = str_replace("'", '\\\'', $value);
107 107
 			echo "'$key' => '$escValue',\n";
108 108
 		}
109 109
 		echo ");\n";
110
-		echo '$this->assertEquals($expected, $somevar);'."\n";
110
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
111 111
 	}
112 112
 
113 113
 
114 114
 	public function generateAssertionsFromArray1D($toAssert) {
115
-		echo '$expected = array('."\n";
116
-		foreach ($toAssert as $key => $value) {
115
+		echo '$expected = array(' . "\n";
116
+		foreach($toAssert as $key => $value) {
117 117
 			$escValue = str_replace("'", '\\\'', $value);
118 118
 			echo "'$escValue',";
119 119
 		}
120 120
 		echo ");\n";
121
-		echo '$this->assertEquals($expected, $somevar);'."\n";
121
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
122 122
 	}
123 123
 
124 124
 
125 125
 	public function generateAssertionsFromArrayRecurse($toAssert) {
126 126
 		echo '$expected = ';
127
-			$this->recurseArrayAssertion($toAssert,1, 'FIXME');
128
-		echo '$this->assertEquals($expected, $somevar);'."\n";
127
+			$this->recurseArrayAssertion($toAssert, 1, 'FIXME');
128
+		echo '$this->assertEquals($expected, $somevar);' . "\n";
129 129
 	}
130 130
 
131 131
 
132 132
 	private function recurseArrayAssertion($toAssert, $depth, $parentKey) {
133
-		$prefix = str_repeat("\t",$depth);
133
+		$prefix = str_repeat("\t", $depth);
134 134
 		echo "\t{$prefix}'$parentKey' => array(\n";
135 135
 		$ctr = 0;
136 136
 		$len = sizeof(array_keys($toAssert));
137
-		foreach ($toAssert as $key => $value) {
138
-			if (is_array($value)) {
139
-				$this->recurseArrayAssertion($value, $depth+1, $key);
137
+		foreach($toAssert as $key => $value) {
138
+			if(is_array($value)) {
139
+				$this->recurseArrayAssertion($value, $depth + 1, $key);
140 140
 			} else {
141 141
 				$escValue = str_replace("'", '\\\'', $value);
142 142
 				$comma = ',';
143
-				if ($ctr == $len-1) {
143
+				if($ctr == $len - 1) {
144 144
 					$comma = '';
145 145
 				}
146 146
 				echo "\t\t$prefix'$key' => '$escValue'$comma\n";
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$size = sizeof($splits);
165 165
 		$nameToCheck = end($splits);
166 166
 		$this->assertEquals($actualTabName, $nameToCheck);
167
-		if ($size == 1) {
167
+		if($size == 1) {
168 168
 			$this->assertEquals("Root_${tabName}", $tab->id());
169 169
 		} else {
170 170
 			$expected = "Root_{$splits[0]}_set_{$splits[1]}";
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	}
176 176
 
177 177
 
178
-	public function checkFieldExists($tab,$fieldName) {
178
+	public function checkFieldExists($tab, $fieldName) {
179 179
 		$fields = $tab->Fields();
180 180
 		$field = $tab->fieldByName($fieldName);
181 181
 		$this->assertTrue($field != null);
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 		$status = $index->getStatus()->getData();
209 209
 
210 210
 		$numberDocsInIndex = -1; // flag value for not yet indexed
211
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
211
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
212 212
 			error_log('CHECKING NUMBER OF INDEXED DOCUMENTS, SHOULD BE ' . $expectedAmount);
213
-			error_log(print_r($status,1));
213
+			error_log(print_r($status, 1));
214 214
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
215
-			error_log('DOCUMENTS FOUND:'.$numberDocsInIndex)
215
+			error_log('DOCUMENTS FOUND:' . $numberDocsInIndex)
216 216
 		}
217 217
 
218
-		$this->assertEquals($expectedAmount,$numberDocsInIndex);
218
+		$this->assertEquals($expectedAmount, $numberDocsInIndex);
219 219
 	}
220 220
 
221 221
 	/*
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		$status = $index->getStatus()->getData();
227 227
 
228 228
 		$numberDocsInIndex = -1; // flag value for not yet indexed
229
-		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
229
+		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) {
230 230
 			$numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];
231 231
 		}
232 232
 
Please login to merge, or discard this patch.
tests/AutoCompleteOptionTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@
 block discarded – undo
31 31
 	public function testRequireDefaultRecords() {
32 32
 		$this->AutoCompleteOption->requireDefaultRecords();
33 33
 
34
-		$similar = AutoCompleteOption::get()->filter('Name','Similar')->first();
34
+		$similar = AutoCompleteOption::get()->filter('Name', 'Similar')->first();
35 35
 		$this->assertEquals(1, $similar->ID);
36 36
 
37
-		$search = AutoCompleteOption::get()->filter('Name','Search')->first();
37
+		$search = AutoCompleteOption::get()->filter('Name', 'Search')->first();
38 38
 		$this->assertEquals(2, $search->ID);
39 39
 
40
-		$goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first();
40
+		$goto = AutoCompleteOption::get()->filter('Name', 'GoToRecord')->first();
41 41
 		$this->assertEquals(3, $goto->ID);
42 42
 
43 43
 	}
Please login to merge, or discard this patch.
tests/SearchableClassTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 		$fields = $sc->getCMSFields();
16 16
 
17
-		$tab = $this->checkTabExists($fields,'Main');
17
+		$tab = $this->checkTabExists($fields, 'Main');
18 18
 
19 19
 		//Check fields
20 20
 		$nf = $this->checkFieldExists($tab, 'Name');
Please login to merge, or discard this patch.
tests/IndexSettingsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 	public function setUp() {
10 10
 		// this needs to be called in order to create the list of searchable
11 11
 		// classes and fields that are available.  Simulates part of a build
12
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
12
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
13 13
 			'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO');
14 14
 		$this->requireDefaultRecordsFrom = $classes;
15 15
 
Please login to merge, or discard this patch.
tests/models/FlickrModels.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -139,37 +139,37 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
  * @subpackage tests
7 7
  */
8 8
 class FlickrPhotoTO extends DataObject implements TestOnly {
9
-	private static $searchable_fields = array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'FirstViewed',
10
-		'Aperture','ShutterSpeed','FocalLength35mm','ISO','AspectRatio', 'TestMethod', 'TestMethodHTML');
9
+	private static $searchable_fields = array('Title', 'FlickrID', 'Description', 'TakenAt', 'TakenAtDT', 'FirstViewed',
10
+		'Aperture', 'ShutterSpeed', 'FocalLength35mm', 'ISO', 'AspectRatio', 'TestMethod', 'TestMethodHTML');
11 11
 
12 12
 	private static $searchable_relationships = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs');
13 13
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  * @subpackage tests
89 89
  */
90 90
 class FlickrSetTO extends DataObject implements TestOnly {
91
-	private static $searchable_fields = array('Title','FlickrID','Description');
91
+	private static $searchable_fields = array('Title', 'FlickrID', 'Description');
92 92
 
93 93
 	private static $db = array(
94 94
 		'Title' => 'Varchar(255)',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
 
135 135
 
136
-class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface,TestOnly {
136
+class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface, TestOnly {
137 137
 
138 138
 	/**
139 139
 	 * Add a mapping for the location of the photograph
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     	// add a location with geo point
147 147
     	$precision1cm = array('format' => 'compressed', 'precision' => '1cm');
148
-    	$properties['location'] =  array(
148
+    	$properties['location'] = array(
149 149
     		'type' => 'geo_point',
150 150
     		'fielddata' => $precision1cm,
151 151
     	);
@@ -181,27 +181,27 @@  discard block
 block discarded – undo
181 181
 	{
182 182
 	//	self::$ctr++;
183 183
 
184
-		if ($this->owner->Lat != null && $this->owner->Lon != null) {
184
+		if($this->owner->Lat != null && $this->owner->Lon != null) {
185 185
 			$coors = array('lat' => $this->owner->Lat, 'lon' => $this->owner->Lon);
186
-			$document->set('location',$coors);
186
+			$document->set('location', $coors);
187 187
 		}
188 188
 
189 189
 		$sortable = $this->owner->ShutterSpeed;
190 190
 		$sortable = explode('/', $sortable);
191
-		if (sizeof($sortable) == 1) {
191
+		if(sizeof($sortable) == 1) {
192 192
 			$sortable = trim($sortable[0]);
193 193
 
194
-			if ($this->owner->ShutterSpeed == null) {
194
+			if($this->owner->ShutterSpeed == null) {
195 195
 				$sortable = null;
196 196
 			}
197 197
 
198
-			if ($sortable == 1) {
198
+			if($sortable == 1) {
199 199
 				$sortable = '1.000000';
200 200
 			}
201 201
 
202
-		} else if (sizeof($sortable) == 2) {
203
-			$sortable = floatval($sortable[0])/intval($sortable[1]);
204
-			$sortable = round($sortable,6);
202
+		} else if(sizeof($sortable) == 2) {
203
+			$sortable = floatval($sortable[0]) / intval($sortable[1]);
204
+			$sortable = round($sortable, 6);
205 205
 		}
206 206
 		$sortable = $sortable . '|' . $this->owner->ShutterSpeed;
207 207
 		$document->set('ShutterSpeed', $sortable);
Please login to merge, or discard this patch.
tests/models/SearchableTestPage.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
  * @subpackage tests
6 6
  */
7 7
 class SearchableTestPage extends Page implements TestOnly {
8
-	private static $searchable_fields = array('Country','PageDate');
8
+	private static $searchable_fields = array('Country', 'PageDate');
9 9
 
10 10
 	private static $db = array(
11 11
 		'Country' => 'Varchar',
Please login to merge, or discard this patch.
tests/models/FlickrPhotoElasticaSearchHelper.php 2 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 		/*
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 use SilverStripe\Elastica\RangedAggregation;
7 7
 
8 8
 
9
-class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface,TestOnly {
9
+class FlickrPhotoTOElasticaSearchHelper implements ElasticaSearchHelperInterface, TestOnly {
10 10
 
11 11
 	public function __construct() {
12 12
 		$aspectAgg = new RangedAggregation('Aspect', 'AspectRatio');
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 			'query_string' => array('query' => '*')
37 37
 		);
38 38
 
39
-		if ($query->OriginalQueryText == '') {
39
+		if($query->OriginalQueryText == '') {
40 40
 			$query->setSort(array('TakenAt'=> 'desc'));
41 41
 		}
42 42
 
@@ -104,27 +104,27 @@  discard block
 block discarded – undo
104 104
 		// shutter speed is stored as decimal to 6 decimal places, then a
105 105
 		// vertical bar followed by the displayed speed as a fraction or a
106 106
 		// whole number.  This puts the decimal back for matching purposes
107
-		if (isset($filters['ShutterSpeed'])) {
107
+		if(isset($filters['ShutterSpeed'])) {
108 108
 
109 109
 			$sortable = $filters['ShutterSpeed'];
110 110
 
111 111
 			echo "SORTABLE:$sortable\n";
112 112
 
113 113
 			$sortable = explode('/', $sortable);
114
-			if (sizeof($sortable) == 1) {
114
+			if(sizeof($sortable) == 1) {
115 115
 				$sortable = trim($sortable[0]);
116 116
 
117
-				if ($sortable === '1') {
117
+				if($sortable === '1') {
118 118
 					$sortable = '1.000000|1';
119 119
 				}
120 120
 
121
-			} else if (sizeof($sortable) == 2) {
122
-				if ($sortable[0] === '' || $sortable[1] === '') {
121
+			} else if(sizeof($sortable) == 2) {
122
+				if($sortable[0] === '' || $sortable[1] === '') {
123 123
 					$sortable = '';
124 124
 
125 125
 				} else {
126
-					$sortable = floatval($sortable[0])/intval($sortable[1]);
127
-					$sortable = round($sortable,6);
126
+					$sortable = floatval($sortable[0]) / intval($sortable[1]);
127
+					$sortable = round($sortable, 6);
128 128
 					$sortable = $sortable . '|' . $filters['ShutterSpeed'];
129 129
 				}
130 130
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 		// the shutter speeds are of the form decimal number | fraction, keep the latter half
148 148
 		$shutterSpeeds = $aggs['ShutterSpeed']['buckets'];
149 149
 		$ctr = 0;
150
-		foreach ($shutterSpeeds as $bucket) {
150
+		foreach($shutterSpeeds as $bucket) {
151 151
 			$key = $bucket['key'];
152 152
 			$splits = explode('|', $key);
153 153
 			$shutterSpeeds[$ctr]['key'] = end($splits);
Please login to merge, or discard this patch.
tests/TermVectorTest.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,8 +17,8 @@
 block discarded – undo
17 17
 		sort($terms);
18 18
 		$expected = array('Description', 'Description.shingles', 'Description.standard',
19 19
 			'ShutterSpeed',
20
-			'TestMethod','TestMethod.shingles','TestMethod.standard',
21
-			'TestMethodHTML','TestMethodHTML.shingles','TestMethodHTML.standard',
20
+			'TestMethod', 'TestMethod.shingles', 'TestMethod.standard',
21
+			'TestMethodHTML', 'TestMethodHTML.shingles', 'TestMethodHTML.standard',
22 22
 			'Title', 'Title.autocomplete', 'Title.shingles', 'Title.standard');
23 23
 		$this->assertEquals($expected, $terms);
24 24
 
Please login to merge, or discard this patch.