@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | /** |
5 | 5 | * Alter the query or add to it, perhaps for example adding aggregation |
6 | 6 | * @param Elastic\Query &$query query object from Elastica |
7 | - * @return [type] [description] |
|
7 | + * @return void [description] |
|
8 | 8 | */ |
9 | 9 | public function augmentQuery(&$query); |
10 | 10 | |
@@ -12,6 +12,7 @@ discard block |
||
12 | 12 | * Update filters, perhaps remaps them, prior to performing a search. |
13 | 13 | * This allows for aggregation values to be updated prior to rendering. |
14 | 14 | * @param array &$filters array of key/value pairs for query filtering |
15 | + * @return void |
|
15 | 16 | */ |
16 | 17 | public function updateFilters(&$filters); |
17 | 18 | |
@@ -19,7 +20,7 @@ discard block |
||
19 | 20 | * Manipulate the array of aggregations post search butprior to rendering |
20 | 21 | * them in a template. |
21 | 22 | * @param [type] &$aggs [description] |
22 | - * @return [type] [description] |
|
23 | + * @return void [description] |
|
23 | 24 | */ |
24 | 25 | public function updateAggregation(&$aggs); |
25 | 26 |
@@ -62,6 +62,9 @@ discard block |
||
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | + /** |
|
66 | + * @param boolean $newShowResultsForEmptyQuery |
|
67 | + */ |
|
65 | 68 | public function setShowResultsForEmptyQuery($newShowResultsForEmptyQuery) { |
66 | 69 | $this->showResultsForEmptyQuery = $newShowResultsForEmptyQuery; |
67 | 70 | } |
@@ -72,11 +75,17 @@ discard block |
||
72 | 75 | } |
73 | 76 | |
74 | 77 | |
78 | + /** |
|
79 | + * @param integer $newPageLength |
|
80 | + */ |
|
75 | 81 | public function setPageLength($newPageLength) { |
76 | 82 | $this->pageLength = $newPageLength; |
77 | 83 | } |
78 | 84 | |
79 | 85 | |
86 | + /** |
|
87 | + * @param integer $newStart |
|
88 | + */ |
|
80 | 89 | public function setStart($newStart) { |
81 | 90 | $this->start = $newStart; |
82 | 91 | } |
@@ -317,6 +326,9 @@ discard block |
||
317 | 326 | } |
318 | 327 | |
319 | 328 | |
329 | + /** |
|
330 | + * @param Query $query |
|
331 | + */ |
|
320 | 332 | private function addAggregation(&$query) { |
321 | 333 | // aggregation (optional) |
322 | 334 | if ($this->manipulatorInstance) { |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | 'size' => 10, |
210 | 210 | 'query' => array( |
211 | 211 | 'match' => array( |
212 | - $field.'.autocomplete' => array( |
|
212 | + $field . '.autocomplete' => array( |
|
213 | 213 | 'query' => $this->queryText, |
214 | 214 | 'operator' => 'and' |
215 | 215 | ) |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | foreach ($this->selectedFilters as $key => $value) { |
269 | 269 | if (!in_array($key, $rangeFilterKeys)) { |
270 | 270 | $filter = new Term(); |
271 | - $filter->setTerm($key,$value); |
|
271 | + $filter->setTerm($key, $value); |
|
272 | 272 | $elFilters[] = $filter; |
273 | 273 | } else { |
274 | 274 | // get the selected range filter |
@@ -407,20 +407,20 @@ discard block |
||
407 | 407 | */ |
408 | 408 | public function convertWeightedFieldsForElastica($fields) { |
409 | 409 | $result = array(); |
410 | - $nameToType = self::getSearchFieldsMappingForClasses($this->classes,$fields); |
|
410 | + $nameToType = self::getSearchFieldsMappingForClasses($this->classes, $fields); |
|
411 | 411 | |
412 | 412 | if (sizeof($fields) != 0) { |
413 | 413 | foreach ($fields as $fieldName => $weight) { |
414 | 414 | $fieldCfg = "$fieldName"; |
415 | 415 | if ($weight != 1) { |
416 | - $fieldCfg .= '^'.$weight; |
|
416 | + $fieldCfg .= '^' . $weight; |
|
417 | 417 | } |
418 | 418 | array_push($result, $fieldCfg); |
419 | 419 | if (isset($nameToType[$fieldName])) { |
420 | 420 | if ($nameToType[$fieldName] == 'string') { |
421 | 421 | $fieldCfg = "{$fieldName}.*"; |
422 | 422 | if ($weight != 1) { |
423 | - $fieldCfg .= '^'.$weight; |
|
423 | + $fieldCfg .= '^' . $weight; |
|
424 | 424 | } |
425 | 425 | array_push($result, $fieldCfg); |
426 | 426 | } |
@@ -447,16 +447,16 @@ discard block |
||
447 | 447 | $cache = QueryGenerator::getCache(); |
448 | 448 | $csvClasses = $classes; |
449 | 449 | if (is_array($classes)) { |
450 | - $csvClasses = implode(',',$classes); |
|
450 | + $csvClasses = implode(',', $classes); |
|
451 | 451 | } |
452 | 452 | |
453 | 453 | error_log("CSV CLASSES: $csvClasses"); |
454 | 454 | |
455 | - $key ='SEARCHABLE_FIELDS_'.str_replace(',', '_', $csvClasses); |
|
455 | + $key = 'SEARCHABLE_FIELDS_' . str_replace(',', '_', $csvClasses); |
|
456 | 456 | |
457 | 457 | if ($fieldsAllowed) { |
458 | 458 | $fieldsAllowedCSV = self::convertToQuotedCSV(array_keys($fieldsAllowed)); |
459 | - $key .= '_' . str_replace(',', '_', str_replace("'", '_',$fieldsAllowedCSV)); |
|
459 | + $key .= '_' . str_replace(',', '_', str_replace("'", '_', $fieldsAllowedCSV)); |
|
460 | 460 | $key = str_replace('.', '_', $key); |
461 | 461 | $key = str_replace(' ', '_', $key); |
462 | 462 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | if (!$csvClasses) { |
469 | 469 | |
470 | 470 | $sql = "SELECT DISTINCT Name from SearchableClass where InSiteTree = 1 order by Name"; |
471 | - error_log('T1 - sql = '.$sql); |
|
471 | + error_log('T1 - sql = ' . $sql); |
|
472 | 472 | |
473 | 473 | $records = \DB::query($sql); |
474 | 474 | foreach ($records as $record) { |
@@ -492,7 +492,7 @@ discard block |
||
492 | 492 | } |
493 | 493 | } |
494 | 494 | |
495 | - error_log('T2 - sql = '.$sql); |
|
495 | + error_log('T2 - sql = ' . $sql); |
|
496 | 496 | |
497 | 497 | |
498 | 498 | $records = \DB::query($sql); |
@@ -510,11 +510,11 @@ discard block |
||
510 | 510 | $result[$name] = $type; |
511 | 511 | } |
512 | 512 | } |
513 | - $cache->save(json_encode($result),$key); |
|
514 | - } else { |
|
513 | + $cache->save(json_encode($result), $key); |
|
514 | + } else { |
|
515 | 515 | // true is necessary here to decode the array hash back to an array and not a struct |
516 | 516 | self::$cacheHitCtr++; |
517 | - $result = json_decode($result,true); |
|
517 | + $result = json_decode($result, true); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | return $result; |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | $quoted = array(); |
547 | 547 | foreach ($asArray as $value) { |
548 | 548 | if (strlen($value) > 0) { |
549 | - $item = "'".$value."'"; |
|
549 | + $item = "'" . $value . "'"; |
|
550 | 550 | array_push($quoted, $item); |
551 | 551 | } |
552 | 552 | |
553 | 553 | } |
554 | - return implode(',', $quoted);; |
|
554 | + return implode(',', $quoted); ; |
|
555 | 555 | } |
556 | 556 | } |
@@ -511,7 +511,7 @@ |
||
511 | 511 | } |
512 | 512 | } |
513 | 513 | $cache->save(json_encode($result),$key); |
514 | - } else { |
|
514 | + } else { |
|
515 | 515 | // true is necessary here to decode the array hash back to an array and not a struct |
516 | 516 | self::$cacheHitCtr++; |
517 | 517 | $result = json_decode($result,true); |
@@ -250,6 +250,9 @@ |
||
250 | 250 | } |
251 | 251 | |
252 | 252 | |
253 | + /** |
|
254 | + * @return integer |
|
255 | + */ |
|
253 | 256 | public function getTotalItems() { |
254 | 257 | $this->getResults(); |
255 | 258 | return $this->TotalItems; |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class ResultList extends \ViewableData implements \SS_Limitable, \SS_List { |
14 | 14 | |
15 | - /** |
|
16 | - * @var \Elastica\Index |
|
17 | - */ |
|
18 | - private $service; |
|
19 | - |
|
20 | - /** |
|
21 | - * @var \Elastica\Query |
|
22 | - */ |
|
15 | + /** |
|
16 | + * @var \Elastica\Index |
|
17 | + */ |
|
18 | + private $service; |
|
19 | + |
|
20 | + /** |
|
21 | + * @var \Elastica\Query |
|
22 | + */ |
|
23 | 23 | private $query; |
24 | 24 | |
25 | 25 | /** |
@@ -312,51 +312,51 @@ discard block |
||
312 | 312 | // Safeguards against indexed items which might no longer be in the DB |
313 | 313 | if(array_key_exists($item->getId(), $retrieved[$item->getType()])) { |
314 | 314 | |
315 | - $data_object = $retrieved[$item->getType()][$item->getId()]; |
|
316 | - $data_object->setElasticaResult($item); |
|
317 | - $highlights = $item->getHighlights(); |
|
315 | + $data_object = $retrieved[$item->getType()][$item->getId()]; |
|
316 | + $data_object->setElasticaResult($item); |
|
317 | + $highlights = $item->getHighlights(); |
|
318 | 318 | |
319 | - //$snippets will contain the highlights shown in the body of the search result |
|
320 | - //$namedSnippets will be used to add highlights to the Link and Title |
|
321 | - $snippets = new \ArrayList(); |
|
322 | - $namedSnippets = new \ArrayList(); |
|
319 | + //$snippets will contain the highlights shown in the body of the search result |
|
320 | + //$namedSnippets will be used to add highlights to the Link and Title |
|
321 | + $snippets = new \ArrayList(); |
|
322 | + $namedSnippets = new \ArrayList(); |
|
323 | 323 | |
324 | - foreach (array_keys($highlights) as $fieldName) { |
|
325 | - $fieldSnippets = new \ArrayList(); |
|
324 | + foreach (array_keys($highlights) as $fieldName) { |
|
325 | + $fieldSnippets = new \ArrayList(); |
|
326 | 326 | |
327 | - foreach ($highlights[$fieldName] as $snippet) { |
|
328 | - $do = new \DataObject(); |
|
329 | - $do->Snippet = $snippet; |
|
327 | + foreach ($highlights[$fieldName] as $snippet) { |
|
328 | + $do = new \DataObject(); |
|
329 | + $do->Snippet = $snippet; |
|
330 | 330 | |
331 | - // skip title and link in the summary of highlights |
|
332 | - if (!in_array($fieldName, $ignore)) { |
|
333 | - $snippets->push($do); |
|
334 | - } |
|
331 | + // skip title and link in the summary of highlights |
|
332 | + if (!in_array($fieldName, $ignore)) { |
|
333 | + $snippets->push($do); |
|
334 | + } |
|
335 | 335 | |
336 | - $fieldSnippets->push($do); |
|
337 | - } |
|
336 | + $fieldSnippets->push($do); |
|
337 | + } |
|
338 | 338 | |
339 | - if ($fieldSnippets->count() > 0) { |
|
340 | - //Fields may have a dot in their name, e.g. Title.standard - take this into account |
|
341 | - //As dots are an issue with template syntax, store as Title_standard |
|
342 | - $splits = explode('.', $fieldName); |
|
343 | - if (sizeof($splits) == 1) { |
|
344 | - $namedSnippets->$fieldName = $fieldSnippets; |
|
345 | - } else { |
|
346 | - // The Title.standard case, for example |
|
347 | - $splits = explode('.', $fieldName); |
|
348 | - $compositeFielddName = $splits[0].'_'.$splits[1]; |
|
349 | - $namedSnippets->$compositeFielddName = $fieldSnippets; |
|
350 | - } |
|
339 | + if ($fieldSnippets->count() > 0) { |
|
340 | + //Fields may have a dot in their name, e.g. Title.standard - take this into account |
|
341 | + //As dots are an issue with template syntax, store as Title_standard |
|
342 | + $splits = explode('.', $fieldName); |
|
343 | + if (sizeof($splits) == 1) { |
|
344 | + $namedSnippets->$fieldName = $fieldSnippets; |
|
345 | + } else { |
|
346 | + // The Title.standard case, for example |
|
347 | + $splits = explode('.', $fieldName); |
|
348 | + $compositeFielddName = $splits[0].'_'.$splits[1]; |
|
349 | + $namedSnippets->$compositeFielddName = $fieldSnippets; |
|
350 | + } |
|
351 | 351 | |
352 | - } |
|
352 | + } |
|
353 | 353 | |
354 | 354 | |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | 357 | |
358 | - $data_object->SearchHighlights = $snippets; |
|
359 | - $data_object->SearchHighlightsByField = $namedSnippets; |
|
358 | + $data_object->SearchHighlights = $snippets; |
|
359 | + $data_object->SearchHighlightsByField = $namedSnippets; |
|
360 | 360 | |
361 | 361 | $result[] = $data_object; |
362 | 362 |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function getResults() { |
104 | 104 | if (!isset($this->_cachedResults)) { |
105 | - $ers = $this->service->search($this->query,$this->types); |
|
105 | + $ers = $this->service->search($this->query, $this->types); |
|
106 | 106 | |
107 | 107 | if (isset($ers->MoreLikeThisTerms)) { |
108 | 108 | $this->MoreLikeThisTerms = $ers->MoreLikeThisTerms; |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | // get the base URL for the current facets selected |
153 | - $baseURL = \Controller::curr()->Link().'?'; |
|
153 | + $baseURL = \Controller::curr()->Link() . '?'; |
|
154 | 154 | $prefixAmp = false; |
155 | 155 | if ($q !== '') { |
156 | - $baseURL .= 'q='.urlencode($q); |
|
156 | + $baseURL .= 'q=' . urlencode($q); |
|
157 | 157 | $prefixAmp = true; |
158 | 158 | } |
159 | 159 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } else { |
165 | 165 | $prefixAmp = true; |
166 | 166 | } |
167 | - $baseURL .= $key.'='.urlencode($value); |
|
167 | + $baseURL .= $key . '=' . urlencode($value); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | foreach (array_keys($aggs) as $key) { |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | $ct->DocumentCount = $value['doc_count']; |
188 | 188 | $query[$key] = $value; |
189 | 189 | if ($prefixAmp) { |
190 | - $url = $baseURL.'&'; |
|
190 | + $url = $baseURL . '&'; |
|
191 | 191 | } else { |
192 | 192 | $url = $baseURL; |
193 | 193 | $prefixAmp = true; |
@@ -203,24 +203,24 @@ discard block |
||
203 | 203 | // of the display of the facet can be done via the template. |
204 | 204 | $aggDO->IsSelected = true; |
205 | 205 | |
206 | - $urlParam = $key.'='.urlencode($this->filters[$key]); |
|
206 | + $urlParam = $key . '=' . urlencode($this->filters[$key]); |
|
207 | 207 | |
208 | 208 | //echo " - URL PARAM : $urlParam \n"; |
209 | 209 | |
210 | 210 | // possible ampersand combos to remove |
211 | - $v2 = '&'.$urlParam; |
|
212 | - $v3 = $urlParam.'&'; |
|
211 | + $v2 = '&' . $urlParam; |
|
212 | + $v3 = $urlParam . '&'; |
|
213 | 213 | $url = str_replace($v2, '', $url); |
214 | 214 | $url = str_replace($v3, '', $url); |
215 | 215 | $url = str_replace($urlParam, '', $url); |
216 | 216 | $ct->URL = $url; |
217 | 217 | } |
218 | 218 | } else { |
219 | - $url .= $key .'='.urlencode($value['key']); |
|
219 | + $url .= $key . '=' . urlencode($value['key']); |
|
220 | 220 | $prefixAmp = true; |
221 | 221 | } |
222 | 222 | |
223 | - $url = rtrim($url,'&'); |
|
223 | + $url = rtrim($url, '&'); |
|
224 | 224 | |
225 | 225 | $ct->URL = $url; |
226 | 226 | $bucketsAL->push($ct); |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | foreach ($found as $item) { |
312 | 312 | // Safeguards against indexed items which might no longer be in the DB |
313 | - if(array_key_exists($item->getId(), $retrieved[$item->getType()])) { |
|
313 | + if (array_key_exists($item->getId(), $retrieved[$item->getType()])) { |
|
314 | 314 | |
315 | 315 | $data_object = $retrieved[$item->getType()][$item->getId()]; |
316 | 316 | $data_object->setElasticaResult($item); |
@@ -345,7 +345,7 @@ discard block |
||
345 | 345 | } else { |
346 | 346 | // The Title.standard case, for example |
347 | 347 | $splits = explode('.', $fieldName); |
348 | - $compositeFielddName = $splits[0].'_'.$splits[1]; |
|
348 | + $compositeFielddName = $splits[0] . '_' . $splits[1]; |
|
349 | 349 | $namedSnippets->$compositeFielddName = $fieldSnippets; |
350 | 350 | } |
351 | 351 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | public function column($col = 'ID') { |
399 | - if($col == 'ID') { |
|
399 | + if ($col == 'ID') { |
|
400 | 400 | $ids = array(); |
401 | 401 | |
402 | 402 | foreach ($this->getResults() as $result) { |
@@ -1036,6 +1036,7 @@ |
||
1036 | 1036 | /** |
1037 | 1037 | * Test searching |
1038 | 1038 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
1039 | + * @param string $queryText |
|
1039 | 1040 | */ |
1040 | 1041 | private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
1041 | 1042 | $filters = array()) { |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | $resultList = $this->search(''); |
484 | 484 | |
485 | 485 | //assert there are actually some results |
486 | - $this->assertGreaterThan(0,$resultList->getTotalItems()); |
|
486 | + $this->assertGreaterThan(0, $resultList->getTotalItems()); |
|
487 | 487 | $aggregations = $resultList->getAggregations()->toArray(); |
488 | 488 | |
489 | 489 | /* |
@@ -502,49 +502,49 @@ discard block |
||
502 | 502 | //Asserting aggregate of ISO, 64 has count 5 |
503 | 503 | $this->assertEquals("64", $buckets[0]->Key); |
504 | 504 | $this->assertEquals(5, $buckets[0]->DocumentCount); |
505 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); |
|
505 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); |
|
506 | 506 | $bucketSum += $buckets[0]->DocumentCount; |
507 | 507 | |
508 | 508 | //Asserting aggregate of ISO, 100 has count 11 |
509 | 509 | $this->assertEquals("100", $buckets[1]->Key); |
510 | 510 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
511 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); |
|
511 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); |
|
512 | 512 | $bucketSum += $buckets[1]->DocumentCount; |
513 | 513 | |
514 | 514 | //Asserting aggregate of ISO, 200 has count 12 |
515 | 515 | $this->assertEquals("200", $buckets[2]->Key); |
516 | 516 | $this->assertEquals(12, $buckets[2]->DocumentCount); |
517 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); |
|
517 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); |
|
518 | 518 | $bucketSum += $buckets[2]->DocumentCount; |
519 | 519 | |
520 | 520 | //Asserting aggregate of ISO, 400 has count 13 |
521 | 521 | $this->assertEquals("400", $buckets[3]->Key); |
522 | 522 | $this->assertEquals(13, $buckets[3]->DocumentCount); |
523 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); |
|
523 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); |
|
524 | 524 | $bucketSum += $buckets[3]->DocumentCount; |
525 | 525 | |
526 | 526 | //Asserting aggregate of ISO, 800 has count 16 |
527 | 527 | $this->assertEquals("800", $buckets[4]->Key); |
528 | 528 | $this->assertEquals(16, $buckets[4]->DocumentCount); |
529 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); |
|
529 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); |
|
530 | 530 | $bucketSum += $buckets[4]->DocumentCount; |
531 | 531 | |
532 | 532 | //Asserting aggregate of ISO, 1600 has count 13 |
533 | 533 | $this->assertEquals("1600", $buckets[5]->Key); |
534 | 534 | $this->assertEquals(13, $buckets[5]->DocumentCount); |
535 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); |
|
535 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); |
|
536 | 536 | $bucketSum += $buckets[5]->DocumentCount; |
537 | 537 | |
538 | 538 | //Asserting aggregate of ISO, 2000 has count 11 |
539 | 539 | $this->assertEquals("2000", $buckets[6]->Key); |
540 | 540 | $this->assertEquals(11, $buckets[6]->DocumentCount); |
541 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); |
|
541 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); |
|
542 | 542 | $bucketSum += $buckets[6]->DocumentCount; |
543 | 543 | |
544 | 544 | //Asserting aggregate of ISO, 3200 has count 19 |
545 | 545 | $this->assertEquals("3200", $buckets[7]->Key); |
546 | 546 | $this->assertEquals(19, $buckets[7]->DocumentCount); |
547 | - $this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); |
|
547 | + $this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); |
|
548 | 548 | $bucketSum += $buckets[7]->DocumentCount; |
549 | 549 | $this->assertEquals(100, $bucketSum); |
550 | 550 | |
@@ -557,43 +557,43 @@ discard block |
||
557 | 557 | //Asserting aggregate of Focal Length, 24 has count 12 |
558 | 558 | $this->assertEquals("24", $buckets[0]->Key); |
559 | 559 | $this->assertEquals(12, $buckets[0]->DocumentCount); |
560 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); |
|
560 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); |
|
561 | 561 | $bucketSum += $buckets[0]->DocumentCount; |
562 | 562 | |
563 | 563 | //Asserting aggregate of Focal Length, 50 has count 11 |
564 | 564 | $this->assertEquals("50", $buckets[1]->Key); |
565 | 565 | $this->assertEquals(11, $buckets[1]->DocumentCount); |
566 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); |
|
566 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); |
|
567 | 567 | $bucketSum += $buckets[1]->DocumentCount; |
568 | 568 | |
569 | 569 | //Asserting aggregate of Focal Length, 80 has count 11 |
570 | 570 | $this->assertEquals("80", $buckets[2]->Key); |
571 | 571 | $this->assertEquals(11, $buckets[2]->DocumentCount); |
572 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); |
|
572 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); |
|
573 | 573 | $bucketSum += $buckets[2]->DocumentCount; |
574 | 574 | |
575 | 575 | //Asserting aggregate of Focal Length, 90 has count 20 |
576 | 576 | $this->assertEquals("90", $buckets[3]->Key); |
577 | 577 | $this->assertEquals(20, $buckets[3]->DocumentCount); |
578 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); |
|
578 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); |
|
579 | 579 | $bucketSum += $buckets[3]->DocumentCount; |
580 | 580 | |
581 | 581 | //Asserting aggregate of Focal Length, 120 has count 12 |
582 | 582 | $this->assertEquals("120", $buckets[4]->Key); |
583 | 583 | $this->assertEquals(12, $buckets[4]->DocumentCount); |
584 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); |
|
584 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); |
|
585 | 585 | $bucketSum += $buckets[4]->DocumentCount; |
586 | 586 | |
587 | 587 | //Asserting aggregate of Focal Length, 150 has count 17 |
588 | 588 | $this->assertEquals("150", $buckets[5]->Key); |
589 | 589 | $this->assertEquals(17, $buckets[5]->DocumentCount); |
590 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); |
|
590 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); |
|
591 | 591 | $bucketSum += $buckets[5]->DocumentCount; |
592 | 592 | |
593 | 593 | //Asserting aggregate of Focal Length, 200 has count 17 |
594 | 594 | $this->assertEquals("200", $buckets[6]->Key); |
595 | 595 | $this->assertEquals(17, $buckets[6]->DocumentCount); |
596 | - $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); |
|
596 | + $this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); |
|
597 | 597 | $bucketSum += $buckets[6]->DocumentCount; |
598 | 598 | $this->assertEquals(100, $bucketSum); |
599 | 599 | |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | $originalAggregations = $resultList->getAggregations()->toArray(); |
888 | 888 | |
889 | 889 | $filters = array('ISO' => 3200); |
890 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
890 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
891 | 891 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
892 | 892 | |
893 | 893 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -899,8 +899,8 @@ discard block |
||
899 | 899 | $resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); |
900 | 900 | $originalAggregations = $resultList->getAggregations()->toArray(); |
901 | 901 | |
902 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); |
|
903 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
902 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical'); |
|
903 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
904 | 904 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
905 | 905 | |
906 | 906 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | 'Aspect' => 'Vertical')); |
917 | 917 | $originalAggregations = $resultList->getAggregations()->toArray(); |
918 | 918 | |
919 | - $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); |
|
920 | - $resultListFiltered = $this->search('New Zealand', $fields,$filters); |
|
919 | + $filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); |
|
920 | + $resultListFiltered = $this->search('New Zealand', $fields, $filters); |
|
921 | 921 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray(); |
922 | 922 | |
923 | 923 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations); |
@@ -1018,7 +1018,7 @@ discard block |
||
1018 | 1018 | |
1019 | 1019 | //Add filters |
1020 | 1020 | foreach ($filters as $key => $value) { |
1021 | - $es->addFilter($key,$value); |
|
1021 | + $es->addFilter($key, $value); |
|
1022 | 1022 | } |
1023 | 1023 | |
1024 | 1024 | $es->showResultsForEmptySearch(); |
@@ -1037,7 +1037,7 @@ discard block |
||
1037 | 1037 | * Test searching |
1038 | 1038 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming |
1039 | 1039 | */ |
1040 | - private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), |
|
1040 | + private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), |
|
1041 | 1041 | $filters = array()) { |
1042 | 1042 | $es = new ElasticSearcher(); |
1043 | 1043 | $es->setStart(0); |
@@ -1049,7 +1049,7 @@ discard block |
||
1049 | 1049 | //Add filters |
1050 | 1050 | foreach ($filters as $key => $value) { |
1051 | 1051 | echo "ADDING FILTER:$key => $value\n"; |
1052 | - $es->addFilter($key,$value); |
|
1052 | + $es->addFilter($key, $value); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | 1055 | $es->showResultsForEmptySearch(); |
@@ -1060,10 +1060,10 @@ discard block |
||
1060 | 1060 | echo "{$resultList->count()} items found searching for '$queryText'\n\n"; |
1061 | 1061 | foreach ($resultList as $result) { |
1062 | 1062 | $ctr++; |
1063 | - echo("($ctr) ".$result->Title."\n"); |
|
1063 | + echo("($ctr) " . $result->Title . "\n"); |
|
1064 | 1064 | if ($result->SearchHighlightsByField->Content) { |
1065 | 1065 | foreach ($result->SearchHighlightsByField->Content as $highlight) { |
1066 | - echo("- ".$highlight->Snippet); |
|
1066 | + echo("- " . $highlight->Snippet); |
|
1067 | 1067 | } |
1068 | 1068 | } |
1069 | 1069 | } |
@@ -153,6 +153,9 @@ |
||
153 | 153 | |
154 | 154 | /** |
155 | 155 | * Simulate a call to Elastica to get suggestions for a given phrase |
156 | + * @param string $phrase |
|
157 | + * @param string $suggestion |
|
158 | + * @param string $highlightedSuggestion |
|
156 | 159 | * @return [type] [description] |
157 | 160 | */ |
158 | 161 | private function getSuggestionArray($phrase, $suggestion, $highlightedSuggestion) { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * Note: characters are stripped from the content; make sure that your assertions take this into account. |
103 | 103 | * |
104 | 104 | * @param string $selector A basic CSS selector, e.g. 'li.jobs h3' |
105 | - * @param array|string $expectedMatches The content of at least one of the matched tags |
|
105 | + * @param integer $index |
|
106 | 106 | * @throws PHPUnit_Framework_AssertionFailedError |
107 | 107 | * @return boolean |
108 | 108 | */ |
@@ -133,6 +133,12 @@ discard block |
||
133 | 133 | /* |
134 | 134 | Check all the nodes matching the selector for attribute name = expected value |
135 | 135 | */ |
136 | + |
|
137 | + /** |
|
138 | + * @param string $selector |
|
139 | + * @param string $attributeName |
|
140 | + * @param string $expectedValue |
|
141 | + */ |
|
136 | 142 | public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { |
137 | 143 | $items = $this->cssParser()->getBySelector($selector); |
138 | 144 | foreach ($items as $item) { |
@@ -141,6 +147,9 @@ discard block |
||
141 | 147 | } |
142 | 148 | |
143 | 149 | |
150 | + /** |
|
151 | + * @param string $selector |
|
152 | + */ |
|
144 | 153 | public function assertAttributesHaveExactValues($selector, $expectedValues) { |
145 | 154 | $attributeNames = array_keys($expectedValues); |
146 | 155 | $items = $this->cssParser()->getBySelector($selector); |
@@ -154,6 +163,10 @@ discard block |
||
154 | 163 | } |
155 | 164 | |
156 | 165 | |
166 | + /** |
|
167 | + * @param string $selector |
|
168 | + * @param integer $expectedAmount |
|
169 | + */ |
|
157 | 170 | public function assertNumberOfNodes($selector, $expectedAmount) { |
158 | 171 | $items = $this->cssParser()->getBySelector($selector); |
159 | 172 | foreach ($items as $item) { |
@@ -8,8 +8,8 @@ discard block |
||
8 | 8 | public static $ignoreFixtureFileFor = array(); |
9 | 9 | |
10 | 10 | protected $extraDataObjects = array( |
11 | - 'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO', |
|
12 | - 'SearchableTestFatherPage','SearchableTestGrandFatherPage' |
|
11 | + 'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO', |
|
12 | + 'SearchableTestFatherPage', 'SearchableTestGrandFatherPage' |
|
13 | 13 | ); |
14 | 14 | |
15 | 15 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | // this needs to be called in order to create the list of searchable |
31 | 31 | // classes and fields that are available. Simulates part of a build |
32 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
32 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
33 | 33 | 'FlickrTagTO', 'FlickrAuthorTO'); |
34 | 34 | $this->requireDefaultRecordsFrom = $classes; |
35 | 35 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | print_r(static::$ignoreFixtureFileFor); |
61 | 61 | |
62 | 62 | foreach (static::$ignoreFixtureFileFor as $testPattern) { |
63 | - $pattern = '/'.$testPattern.'/'; |
|
64 | - echo "GREP: $pattern against ".$this->getName()."\n"; |
|
63 | + $pattern = '/' . $testPattern . '/'; |
|
64 | + echo "GREP: $pattern against " . $this->getName() . "\n"; |
|
65 | 65 | if (preg_match($pattern, $this->getName())) { |
66 | 66 | static::$fixture_file = null; |
67 | 67 | } |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | // temporarily disable Elasticsearch indexing, it will be done in a batch |
89 | 89 | $page->IndexingOff = true; |
90 | 90 | |
91 | - echo "Publishing ".$page->Title."\n"; |
|
92 | - $page->publish('Stage','Live'); |
|
91 | + echo "Publishing " . $page->Title . "\n"; |
|
92 | + $page->publish('Stage', 'Live'); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $text = strip_tags($item); |
116 | 116 | $escaped = str_replace("'", "\'", $text); |
117 | 117 | echo "SELECTED:\$this->assertSelectorStartsWithOrEquals('{$selector}', $ctr, '$escaped');\n"; |
118 | - echo "ITEM:".$item."\n"; |
|
118 | + echo "ITEM:" . $item . "\n"; |
|
119 | 119 | $ctr++; |
120 | 120 | } |
121 | 121 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $result = array(); |
172 | 172 | foreach ($items as $item) { |
173 | 173 | $attr = $item->attributes()->id; |
174 | - array_push($result, $attr.""); |
|
174 | + array_push($result, $attr . ""); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $result; |
@@ -106,6 +106,10 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | |
109 | + /** |
|
110 | + * @param string $fieldName |
|
111 | + * @param string $message |
|
112 | + */ |
|
109 | 113 | private function checkForError($fieldName, $badValue, $message) { |
110 | 114 | $this->ElasticSearchPage->$fieldName = $badValue; |
111 | 115 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | parent::setup(); |
9 | 9 | $this->ElasticSearchPage = $this->objFromFixture('ElasticSearchPage', 'search'); |
10 | 10 | |
11 | - $this->ElasticSearchPage->SimilarityStopWords = 'a,the,which'; |
|
11 | + $this->ElasticSearchPage->SimilarityStopWords = 'a,the,which'; |
|
12 | 12 | $this->ElasticSearchPage->write(); |
13 | 13 | |
14 | 14 | $this->Validator = $this->ElasticSearchPage->getCMSValidator(); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | 'AutoCompleteFieldID' => null, |
35 | 35 | 'AutoCompleteFunctionID' => null, |
36 | 36 | 'SearchHelper' => null, |
37 | - 'SimilarityStopWords' => array('a', 'an', 'the', ), |
|
37 | + 'SimilarityStopWords' => array('a', 'an', 'the',), |
|
38 | 38 | 'MinTermFreq' => 2, |
39 | 39 | 'MaxTermFreq' => 25, |
40 | 40 | 'MinDocFreq' => 2, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $esp->Identifier = 'THISWILLBECOPIED'; |
103 | 103 | $esp->write(); |
104 | 104 | $this->checkForError('Identifier', 'THISWILLBECOPIED', |
105 | - 'The identifier THISWILLBECOPIED already exists' ); |
|
105 | + 'The identifier THISWILLBECOPIED already exists'); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | |
127 | 127 | foreach ($errors as $error) { |
128 | 128 | echo "Checking error\n"; |
129 | - echo " - " . $error['fieldName'].' => '.$error['message']."\n"; |
|
130 | - echo "\tT1:".($error['message'] == $message); |
|
131 | - echo "\n\tT2:".($error['fieldName'] == $fieldName); |
|
129 | + echo " - " . $error['fieldName'] . ' => ' . $error['message'] . "\n"; |
|
130 | + echo "\tT1:" . ($error['message'] == $message); |
|
131 | + echo "\n\tT2:" . ($error['fieldName'] == $fieldName); |
|
132 | 132 | |
133 | 133 | if ($error['message'] == $message && $error['fieldName'] == $fieldName) { |
134 | 134 | $found = true; |
@@ -132,6 +132,10 @@ discard block |
||
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | + /** |
|
136 | + * @param integer $depth |
|
137 | + * @param string $parentKey |
|
138 | + */ |
|
135 | 139 | private function recurseArrayAssertion($toAssert, $depth, $parentKey) { |
136 | 140 | $prefix = str_repeat("\t",$depth); |
137 | 141 | echo "\t{$prefix}'$parentKey' => array(\n"; |
@@ -160,6 +164,10 @@ discard block |
||
160 | 164 | /* |
161 | 165 | Helper methods for testing CMS fields |
162 | 166 | */ |
167 | + |
|
168 | + /** |
|
169 | + * @param string $tabName |
|
170 | + */ |
|
163 | 171 | public function checkTabExists($fields, $tabName) { |
164 | 172 | echo "Searching for tab $tabName\n"; |
165 | 173 | $tab = $fields->findOrMakeTab("Root.{$tabName}"); |
@@ -184,6 +192,9 @@ discard block |
||
184 | 192 | } |
185 | 193 | |
186 | 194 | |
195 | + /** |
|
196 | + * @param string $fieldName |
|
197 | + */ |
|
187 | 198 | public function checkFieldExists($tab,$fieldName) { |
188 | 199 | $fields = $tab->Fields(); |
189 | 200 | echo "TAB:{$tab->Name}\n"; |
@@ -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 |
@@ -9,8 +9,8 @@ discard block |
||
9 | 9 | public static $ignoreFixtureFileFor = array(); |
10 | 10 | |
11 | 11 | protected $extraDataObjects = array( |
12 | - 'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO', |
|
13 | - 'SearchableTestFatherPage','SearchableTestGrandFatherPage','AutoCompleteOption' |
|
12 | + 'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO', |
|
13 | + 'SearchableTestFatherPage', 'SearchableTestGrandFatherPage', 'AutoCompleteOption' |
|
14 | 14 | ); |
15 | 15 | |
16 | 16 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | // this needs to be called in order to create the list of searchable |
41 | 41 | // classes and fields that are available. Simulates part of a build |
42 | - $classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', |
|
42 | + $classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', |
|
43 | 43 | 'FlickrTagTO', 'FlickrAuthorTO'); |
44 | 44 | $this->requireDefaultRecordsFrom = $classes; |
45 | 45 | |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | $orig_fixture_file = static::$fixture_file; |
62 | 62 | |
63 | 63 | foreach (static::$ignoreFixtureFileFor as $testPattern) { |
64 | - $pattern = '/'.$testPattern.'/'; |
|
64 | + $pattern = '/' . $testPattern . '/'; |
|
65 | 65 | if (preg_match($pattern, $this->getName())) { |
66 | 66 | static::$fixture_file = null; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - echo "\n\n\n\nEXECUTING TEST {$this->getName()}, FIXTURES=".static::$fixture_file."\n"; |
|
70 | + echo "\n\n\n\nEXECUTING TEST {$this->getName()}, FIXTURES=" . static::$fixture_file . "\n"; |
|
71 | 71 | |
72 | 72 | parent::setUp(); |
73 | 73 | static::$fixture_file = $orig_fixture_file; |
@@ -97,53 +97,53 @@ discard block |
||
97 | 97 | // temporarily disable Elasticsearch indexing, it will be done in a batch |
98 | 98 | $page->IndexingOff = true; |
99 | 99 | |
100 | - echo "Publishing ".$page->Title."\n"; |
|
101 | - $page->publish('Stage','Live'); |
|
100 | + echo "Publishing " . $page->Title . "\n"; |
|
101 | + $page->publish('Stage', 'Live'); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | 105 | |
106 | 106 | public function generateAssertionsFromArray($toAssert) { |
107 | - echo '$expected = array('."\n"; |
|
107 | + echo '$expected = array(' . "\n"; |
|
108 | 108 | foreach ($toAssert as $key => $value) { |
109 | 109 | $escValue = str_replace("'", '\\\'', $value); |
110 | 110 | echo "'$key' => '$escValue',\n"; |
111 | 111 | } |
112 | 112 | echo ");\n"; |
113 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
113 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function generateAssertionsFromArray1D($toAssert) { |
118 | - echo '$expected = array('."\n"; |
|
118 | + echo '$expected = array(' . "\n"; |
|
119 | 119 | foreach ($toAssert as $key => $value) { |
120 | 120 | $escValue = str_replace("'", '\\\'', $value); |
121 | 121 | echo "'$escValue',"; |
122 | 122 | } |
123 | 123 | echo ");\n"; |
124 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
124 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | |
128 | 128 | public function generateAssertionsFromArrayRecurse($toAssert) { |
129 | 129 | echo '$expected = '; |
130 | - $this->recurseArrayAssertion($toAssert,1, 'FIXME'); |
|
131 | - echo '$this->assertEquals($expected, $somevar);'."\n"; |
|
130 | + $this->recurseArrayAssertion($toAssert, 1, 'FIXME'); |
|
131 | + echo '$this->assertEquals($expected, $somevar);' . "\n"; |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | 135 | private function recurseArrayAssertion($toAssert, $depth, $parentKey) { |
136 | - $prefix = str_repeat("\t",$depth); |
|
136 | + $prefix = str_repeat("\t", $depth); |
|
137 | 137 | echo "\t{$prefix}'$parentKey' => array(\n"; |
138 | 138 | $ctr = 0; |
139 | 139 | $len = sizeof(array_keys($toAssert)); |
140 | 140 | foreach ($toAssert as $key => $value) { |
141 | 141 | if (is_array($value)) { |
142 | - $this->recurseArrayAssertion($value, $depth+1, $key); |
|
142 | + $this->recurseArrayAssertion($value, $depth + 1, $key); |
|
143 | 143 | } else { |
144 | 144 | $escValue = str_replace("'", '\\\'', $value); |
145 | 145 | $comma = ','; |
146 | - if ($ctr == $len-1) { |
|
146 | + if ($ctr == $len - 1) { |
|
147 | 147 | $comma = ''; |
148 | 148 | } |
149 | 149 | echo "\t\t$prefix'$key' => '$escValue'$comma\n"; |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | } |
185 | 185 | |
186 | 186 | |
187 | - public function checkFieldExists($tab,$fieldName) { |
|
187 | + public function checkFieldExists($tab, $fieldName) { |
|
188 | 188 | $fields = $tab->Fields(); |
189 | 189 | echo "TAB:{$tab->Name}\n"; |
190 | 190 | foreach ($fields as $fi) { |
191 | - echo "NAME:".$fi->Name."\n"; |
|
191 | + echo "NAME:" . $fi->Name . "\n"; |
|
192 | 192 | } |
193 | 193 | $field = $tab->fieldByName($fieldName); |
194 | 194 | $this->assertTrue($field != null); |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs']; |
226 | 226 | } |
227 | 227 | |
228 | - $this->assertEquals($expectedAmount,$numberDocsInIndex); |
|
228 | + $this->assertEquals($expectedAmount, $numberDocsInIndex); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /* |
@@ -282,7 +282,6 @@ discard block |
||
282 | 282 | * to "auto-filter" all SELECT queries by this language. |
283 | 283 | * See {@link disable_locale_filter()} on how to override this behaviour temporarily. |
284 | 284 | * |
285 | - * @param string $lang New reading language. |
|
286 | 285 | */ |
287 | 286 | static function set_current_locale($locale) { |
288 | 287 | self::$current_locale = $locale; |
@@ -373,7 +372,7 @@ discard block |
||
373 | 372 | * Check if a given SQLQuery filters on the Locale field |
374 | 373 | * |
375 | 374 | * @param SQLQuery $query |
376 | - * @return boolean |
|
375 | + * @return boolean|null |
|
377 | 376 | */ |
378 | 377 | protected function filtersOnLocale($query) { |
379 | 378 | foreach($query->getWhere() as $condition) { |
@@ -536,7 +535,7 @@ discard block |
||
536 | 535 | * This ID might equal the record ID, but doesn't have to - |
537 | 536 | * it just points to one "original" record in the list. |
538 | 537 | * |
539 | - * @return int Numeric ID of the translationgroup in the <classname>_translationgroup table |
|
538 | + * @return false|string Numeric ID of the translationgroup in the <classname>_translationgroup table |
|
540 | 539 | */ |
541 | 540 | public function getTranslationGroup() { |
542 | 541 | if(!$this->owner->exists()) return false; |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | parent::setOwner($owner, $ownerBaseClass); |
345 | 345 | |
346 | 346 | // setting translatable fields by inspecting owner - this should really be done in the constructor |
347 | - if($this->owner && $this->translatableFields === null) { |
|
347 | + if ($this->owner && $this->translatableFields === null) { |
|
348 | 348 | $this->translatableFields = array_merge( |
349 | 349 | array_keys($this->owner->db()), |
350 | 350 | array_keys($this->owner->has_many()), |
351 | 351 | array_keys($this->owner->many_many()) |
352 | 352 | ); |
353 | 353 | foreach (array_keys($this->owner->has_one()) as $fieldname) { |
354 | - $this->translatableFields[] = $fieldname.'ID'; |
|
354 | + $this->translatableFields[] = $fieldname . 'ID'; |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | } |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @return boolean |
377 | 377 | */ |
378 | 378 | protected function filtersOnLocale($query) { |
379 | - foreach($query->getWhere() as $condition) { |
|
380 | - if(preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) return true; |
|
379 | + foreach ($query->getWhere() as $condition) { |
|
380 | + if (preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) return true; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
@@ -389,18 +389,18 @@ discard block |
||
389 | 389 | * |
390 | 390 | * Use {@link disable_locale_filter()} to temporarily disable this "auto-filtering". |
391 | 391 | */ |
392 | - public function augmentSQL(SQLQuery &$query, DataQuery $dataQuery = null) { |
|
392 | + public function augmentSQL(SQLQuery & $query, DataQuery $dataQuery = null) { |
|
393 | 393 | // If the record is saved (and not a singleton), and has a locale, |
394 | 394 | // limit the current call to its locale. This fixes a lot of problems |
395 | 395 | // with other extensions like Versioned |
396 | - if($this->owner->ID && !empty($this->owner->Locale)) { |
|
396 | + if ($this->owner->ID && !empty($this->owner->Locale)) { |
|
397 | 397 | $locale = $this->owner->Locale; |
398 | 398 | } else { |
399 | 399 | $locale = Translatable::get_current_locale(); |
400 | 400 | } |
401 | 401 | |
402 | 402 | $baseTable = ClassInfo::baseDataClass($this->owner->class); |
403 | - if( |
|
403 | + if ( |
|
404 | 404 | $locale |
405 | 405 | // unless the filter has been temporarily disabled |
406 | 406 | && self::locale_filter_enabled() |
@@ -415,13 +415,13 @@ discard block |
||
415 | 415 | // call or through custom SQL filters) |
416 | 416 | && !$this->filtersOnLocale($query) |
417 | 417 | //&& !$query->filtersOnFK() |
418 | - ) { |
|
418 | + ) { |
|
419 | 419 | $qry = sprintf('"%s"."Locale" = \'%s\'', $baseTable, Convert::raw2sql($locale)); |
420 | 420 | $query->addWhere($qry); |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - function augmentDataQueryCreation(SQLQuery &$sqlQuery, DataQuery &$dataQuery) { |
|
424 | + function augmentDataQueryCreation(SQLQuery & $sqlQuery, DataQuery & $dataQuery) { |
|
425 | 425 | $enabled = self::locale_filter_enabled(); |
426 | 426 | $dataQuery->setQueryParam(self::QUERY_LOCALE_FILTER_ENABLED, $enabled); |
427 | 427 | } |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | // FIXME - NO TEST COVERAGE BUT REQUIRED |
430 | 430 | function augmentDatabase() { |
431 | 431 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
432 | - if($this->owner->class != $baseDataClass) return; |
|
432 | + if ($this->owner->class != $baseDataClass) return; |
|
433 | 433 | |
434 | 434 | $fields = array( |
435 | 435 | 'OriginalID' => 'Int', |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | |
446 | 446 | // Remove 2.2 style tables |
447 | 447 | DB::dontRequireTable("{$baseDataClass}_lang"); |
448 | - if($this->owner->hasExtension('Versioned')) { |
|
448 | + if ($this->owner->hasExtension('Versioned')) { |
|
449 | 449 | DB::dontRequireTable("{$baseDataClass}_lang_Live"); |
450 | 450 | DB::dontRequireTable("{$baseDataClass}_lang_versions"); |
451 | 451 | } |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | */ |
457 | 457 | public function requireDefaultRecords() { |
458 | 458 | // @todo This relies on the Locale attribute being on the base data class, and not any subclasses |
459 | - if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false; |
|
459 | + if ($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false; |
|
460 | 460 | |
461 | 461 | // Permissions: If a group doesn't have any specific TRANSLATE_<locale> edit rights, |
462 | 462 | // but has CMS_ACCESS_CMSMain (general CMS access), then assign TRANSLATE_ALL permissions as a default. |
@@ -468,14 +468,14 @@ discard block |
||
468 | 468 | 'CMS_ACCESS_LeftAndMain', |
469 | 469 | 'ADMIN' |
470 | 470 | )); |
471 | - if($groups) foreach($groups as $group) { |
|
471 | + if ($groups) foreach ($groups as $group) { |
|
472 | 472 | $codes = $group->Permissions()->column('Code'); |
473 | 473 | $hasTranslationCode = false; |
474 | - foreach($codes as $code) { |
|
475 | - if(preg_match('/^TRANSLATE_/', $code)) $hasTranslationCode = true; |
|
474 | + foreach ($codes as $code) { |
|
475 | + if (preg_match('/^TRANSLATE_/', $code)) $hasTranslationCode = true; |
|
476 | 476 | } |
477 | 477 | // Only add the code if no more restrictive code exists |
478 | - if(!$hasTranslationCode) Permission::grant($group->ID, 'TRANSLATE_ALL'); |
|
478 | + if (!$hasTranslationCode) Permission::grant($group->ID, 'TRANSLATE_ALL'); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | // If the Translatable extension was added after the first records were already |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | 'SELECT "ID" FROM "%s" WHERE "Locale" IS NULL OR "Locale" = \'\'', |
486 | 486 | ClassInfo::baseDataClass($this->owner->class) |
487 | 487 | ))->column(); |
488 | - if(!$idsWithoutLocale) return; |
|
488 | + if (!$idsWithoutLocale) return; |
|
489 | 489 | |
490 | 490 | |
491 | 491 | |
@@ -502,13 +502,13 @@ discard block |
||
502 | 502 | * @param boolean $overwrite |
503 | 503 | */ |
504 | 504 | public function addTranslationGroup($originalID, $overwrite = false) { |
505 | - if(!$this->owner->exists()) return false; |
|
505 | + if (!$this->owner->exists()) return false; |
|
506 | 506 | |
507 | 507 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
508 | 508 | $existingGroupID = $this->getTranslationGroup($originalID); |
509 | 509 | |
510 | 510 | // Remove any existing groups if overwrite flag is set |
511 | - if($existingGroupID && $overwrite) { |
|
511 | + if ($existingGroupID && $overwrite) { |
|
512 | 512 | $sql = sprintf( |
513 | 513 | 'DELETE FROM "%s_translationgroups" WHERE "TranslationGroupID" = %d AND "OriginalID" = %d', |
514 | 514 | $baseDataClass, |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | } |
521 | 521 | |
522 | 522 | // Add to group (only if not in existing group or $overwrite flag is set) |
523 | - if(!$existingGroupID) { |
|
523 | + if (!$existingGroupID) { |
|
524 | 524 | $sql = sprintf( |
525 | 525 | 'INSERT INTO "%s_translationgroups" ("TranslationGroupID","OriginalID") VALUES (%d,%d)', |
526 | 526 | $baseDataClass, |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @return int Numeric ID of the translationgroup in the <classname>_translationgroup table |
540 | 540 | */ |
541 | 541 | public function getTranslationGroup() { |
542 | - if(!$this->owner->exists()) return false; |
|
542 | + if (!$this->owner->exists()) return false; |
|
543 | 543 | |
544 | 544 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
545 | 545 | return DB::query( |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | // of the content, as a "single language" website might be expanded |
588 | 588 | // later on. See {@link requireDefaultRecords()} for batch setting |
589 | 589 | // of empty Locale columns on each dev/build call. |
590 | - if(!$this->owner->Locale) { |
|
590 | + if (!$this->owner->Locale) { |
|
591 | 591 | $this->owner->Locale = Translatable::get_current_locale(); |
592 | 592 | } |
593 | 593 | |
@@ -597,12 +597,12 @@ discard block |
||
597 | 597 | // Caution: This logic is very sensitve to infinite loops when translation status isn't determined properly |
598 | 598 | // If a parent for the newly written translation was existing before this |
599 | 599 | // onBeforeWrite() call, it will already have been linked correctly through createTranslation() |
600 | - if( |
|
600 | + if ( |
|
601 | 601 | class_exists('SiteTree') |
602 | 602 | && $this->owner->hasField('ParentID') |
603 | 603 | && $this->owner instanceof SiteTree |
604 | 604 | ) { |
605 | - if( |
|
605 | + if ( |
|
606 | 606 | !$this->owner->ID |
607 | 607 | && $this->owner->ParentID |
608 | 608 | && !$this->owner->Parent()->hasTranslation($this->owner->Locale) |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | |
615 | 615 | // Has to be limited to the default locale, the assumption is that the "page type" |
616 | 616 | // dropdown is readonly on all translations. |
617 | - if($this->owner->ID && $this->owner->Locale == Translatable::default_locale()) { |
|
617 | + if ($this->owner->ID && $this->owner->Locale == Translatable::default_locale()) { |
|
618 | 618 | $changedFields = $this->owner->getChangedFields(); |
619 | 619 | $changed = isset($changedFields['ClassName']); |
620 | 620 | |
@@ -642,11 +642,11 @@ discard block |
||
642 | 642 | } |
643 | 643 | } |
644 | 644 | |
645 | - if($changed) { |
|
645 | + if ($changed) { |
|
646 | 646 | $this->owner->ClassName = $changedFields['ClassName']['before']; |
647 | 647 | $translations = $this->owner->getTranslations(); |
648 | 648 | $this->owner->ClassName = $changedFields['ClassName']['after']; |
649 | - if($translations) foreach($translations as $translation) { |
|
649 | + if ($translations) foreach ($translations as $translation) { |
|
650 | 650 | $translation->setClassName($this->owner->ClassName); |
651 | 651 | $translation = $translation->newClassInstance($translation->ClassName); |
652 | 652 | $translation->populateDefaults(); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | } |
658 | 658 | |
659 | 659 | // see onAfterWrite() |
660 | - if(!$this->owner->ID) { |
|
660 | + if (!$this->owner->ID) { |
|
661 | 661 | $this->owner->_TranslatableIsNewRecord = true; |
662 | 662 | } |
663 | 663 | } |
@@ -665,12 +665,12 @@ discard block |
||
665 | 665 | function onAfterWrite() { |
666 | 666 | // hacky way to determine if the record was created in the database, |
667 | 667 | // or just updated |
668 | - if($this->owner->_TranslatableIsNewRecord) { |
|
668 | + if ($this->owner->_TranslatableIsNewRecord) { |
|
669 | 669 | // this would kick in for all new records which are NOT |
670 | 670 | // created through createTranslation(), meaning they don't |
671 | 671 | // have the translation group automatically set. |
672 | 672 | $translationGroupID = $this->getTranslationGroup(); |
673 | - if(!$translationGroupID) { |
|
673 | + if (!$translationGroupID) { |
|
674 | 674 | $this->addTranslationGroup( |
675 | 675 | $this->owner->_TranslationGroupID ? $this->owner->_TranslationGroupID : $this->owner->ID |
676 | 676 | ); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | |
706 | 706 | // Find the locale language-independent of the page |
707 | 707 | self::disable_locale_filter(); |
708 | - $default = SiteTree::get()->where(sprintf ( |
|
708 | + $default = SiteTree::get()->where(sprintf( |
|
709 | 709 | '"URLSegment" = \'%s\'%s', |
710 | 710 | Convert::raw2sql($URLSegment), |
711 | 711 | (is_int($parentID) ? " AND \"ParentID\" = $parentID" : null) |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function updateRelativeLink(&$base, &$action) { |
722 | 722 | // Prevent home pages for non-default locales having their urlsegments |
723 | 723 | // reduced to the site root. |
724 | - if($base === null && $this->owner->Locale != self::default_locale()){ |
|
724 | + if ($base === null && $this->owner->Locale != self::default_locale()) { |
|
725 | 725 | $base = $this->owner->URLSegment; |
726 | 726 | } |
727 | 727 | } |
@@ -745,14 +745,14 @@ discard block |
||
745 | 745 | * @return DataObjectSet |
746 | 746 | */ |
747 | 747 | function getTranslations($locale = null, $stage = null) { |
748 | - if(!$this->owner->exists()) return new ArrayList(); |
|
748 | + if (!$this->owner->exists()) return new ArrayList(); |
|
749 | 749 | |
750 | 750 | // HACK need to disable language filtering in augmentSQL(), |
751 | 751 | // as we purposely want to get different language |
752 | 752 | // also save state of locale-filter, revert to this state at the |
753 | 753 | // end of this method |
754 | 754 | $localeFilterEnabled = false; |
755 | - if(self::locale_filter_enabled()) { |
|
755 | + if (self::locale_filter_enabled()) { |
|
756 | 756 | self::disable_locale_filter(); |
757 | 757 | $localeFilterEnabled = true; |
758 | 758 | } |
@@ -761,7 +761,7 @@ discard block |
||
761 | 761 | |
762 | 762 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
763 | 763 | $filter = sprintf('"%s_translationgroups"."TranslationGroupID" = %d', $baseDataClass, $translationGroupID); |
764 | - if($locale) { |
|
764 | + if ($locale) { |
|
765 | 765 | $filter .= sprintf(' AND "%s"."Locale" = \'%s\'', $baseDataClass, Convert::raw2sql($locale)); |
766 | 766 | } else { |
767 | 767 | // exclude the language of the current owner |
@@ -769,15 +769,15 @@ discard block |
||
769 | 769 | } |
770 | 770 | $currentStage = Versioned::current_stage(); |
771 | 771 | $joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass); |
772 | - if($this->owner->hasExtension("Versioned")) { |
|
773 | - if($stage) Versioned::reading_stage($stage); |
|
772 | + if ($this->owner->hasExtension("Versioned")) { |
|
773 | + if ($stage) Versioned::reading_stage($stage); |
|
774 | 774 | $translations = Versioned::get_by_stage( |
775 | 775 | $baseDataClass, |
776 | 776 | Versioned::current_stage(), |
777 | 777 | $filter, |
778 | 778 | null |
779 | 779 | )->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause); |
780 | - if($stage) Versioned::reading_stage($currentStage); |
|
780 | + if ($stage) Versioned::reading_stage($currentStage); |
|
781 | 781 | } else { |
782 | 782 | $class = $this->owner->class; |
783 | 783 | $translations = $baseDataClass::get() |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | } |
787 | 787 | |
788 | 788 | // only re-enable locale-filter if it was enabled at the beginning of this method |
789 | - if($localeFilterEnabled) { |
|
789 | + if ($localeFilterEnabled) { |
|
790 | 790 | self::enable_locale_filter(); |
791 | 791 | } |
792 | 792 | |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | */ |
828 | 828 | static function get_existing_content_languages($className = 'SiteTree', $where = '') { |
829 | 829 | $baseTable = ClassInfo::baseDataClass($className); |
830 | - $query = new SQLQuery("Distinct \"Locale\"","\"$baseTable\"",$where, '', "\"Locale\""); |
|
830 | + $query = new SQLQuery("Distinct \"Locale\"", "\"$baseTable\"", $where, '', "\"Locale\""); |
|
831 | 831 | $dbLangs = $query->execute()->column(); |
832 | 832 | $langlist = array_merge((array)Translatable::default_locale(), (array)$dbLangs); |
833 | 833 | $returnMap = array(); |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | Config::inst()->get('i18n', 'common_locales') |
837 | 837 | ); |
838 | 838 | foreach ($langlist as $langCode) { |
839 | - if($langCode && isset($allCodes[$langCode])) { |
|
840 | - if(is_array($allCodes[$langCode])) { |
|
839 | + if ($langCode && isset($allCodes[$langCode])) { |
|
840 | + if (is_array($allCodes[$langCode])) { |
|
841 | 841 | $returnMap[$langCode] = $allCodes[$langCode]['name']; |
842 | 842 | } else { |
843 | 843 | $returnMap[$langCode] = $allCodes[$langCode]; |
@@ -860,8 +860,8 @@ discard block |
||
860 | 860 | $original = SiteTree::get_by_link(RootURLController::config()->default_homepage_link); |
861 | 861 | self::set_current_locale($originalLocale); |
862 | 862 | |
863 | - if($original) { |
|
864 | - if($translation = $original->getTranslation($locale)) return trim($translation->RelativeLink(true), '/'); |
|
863 | + if ($original) { |
|
864 | + if ($translation = $original->getTranslation($locale)) return trim($translation->RelativeLink(true), '/'); |
|
865 | 865 | } |
866 | 866 | } |
867 | 867 | |
@@ -870,7 +870,7 @@ discard block |
||
870 | 870 | * @deprecated 2.4 Use {@link Translatable::get_homepage_link_by_locale()} |
871 | 871 | */ |
872 | 872 | static function get_homepage_urlsegment_by_locale($locale) { |
873 | - user_error ( |
|
873 | + user_error( |
|
874 | 874 | 'Translatable::get_homepage_urlsegment_by_locale() is deprecated, please use get_homepage_link_by_locale()', |
875 | 875 | E_USER_NOTICE |
876 | 876 | ); |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * Return a piece of text to keep DataObject cache keys appropriately specific |
885 | 885 | */ |
886 | 886 | function cacheKeyComponent() { |
887 | - return 'locale-'.self::get_current_locale(); |
|
887 | + return 'locale-' . self::get_current_locale(); |
|
888 | 888 | } |
889 | 889 | |
890 | 890 | /** |
@@ -895,18 +895,18 @@ discard block |
||
895 | 895 | */ |
896 | 896 | public function augmentValidURLSegment() { |
897 | 897 | $reEnableFilter = false; |
898 | - if(!Config::inst()->get('Translatable', 'enforce_global_unique_urls')) { |
|
898 | + if (!Config::inst()->get('Translatable', 'enforce_global_unique_urls')) { |
|
899 | 899 | self::enable_locale_filter(); |
900 | - } elseif(self::locale_filter_enabled()) { |
|
900 | + } elseif (self::locale_filter_enabled()) { |
|
901 | 901 | self::disable_locale_filter(); |
902 | 902 | $reEnableFilter = true; |
903 | 903 | } |
904 | 904 | |
905 | - $IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" : null; |
|
905 | + $IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" : null; |
|
906 | 906 | $parentFilter = null; |
907 | 907 | |
908 | 908 | if (Config::inst()->get('SiteTree', 'nested_urls')) { |
909 | - if($this->owner->ParentID) { |
|
909 | + if ($this->owner->ParentID) { |
|
910 | 910 | $parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->owner->ParentID}"; |
911 | 911 | } else { |
912 | 912 | $parentFilter = ' AND "SiteTree"."ParentID" = 0'; |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | $existingPage = SiteTree::get() |
917 | 917 | // disable get_one cache, as this otherwise may pick up results from when locale_filter was on |
918 | 918 | ->where("\"URLSegment\" = '{$this->owner->URLSegment}' $IDFilter $parentFilter")->First(); |
919 | - if($reEnableFilter) self::enable_locale_filter(); |
|
919 | + if ($reEnableFilter) self::enable_locale_filter(); |
|
920 | 920 | |
921 | 921 | // By returning TRUE or FALSE, we overrule the base SiteTree->validateURLSegment() logic |
922 | 922 | return !$existingPage; |
@@ -377,7 +377,9 @@ discard block |
||
377 | 377 | */ |
378 | 378 | protected function filtersOnLocale($query) { |
379 | 379 | foreach($query->getWhere() as $condition) { |
380 | - if(preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) return true; |
|
380 | + if(preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) { |
|
381 | + return true; |
|
382 | + } |
|
381 | 383 | } |
382 | 384 | } |
383 | 385 | |
@@ -429,7 +431,9 @@ discard block |
||
429 | 431 | // FIXME - NO TEST COVERAGE BUT REQUIRED |
430 | 432 | function augmentDatabase() { |
431 | 433 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
432 | - if($this->owner->class != $baseDataClass) return; |
|
434 | + if($this->owner->class != $baseDataClass) { |
|
435 | + return; |
|
436 | + } |
|
433 | 437 | |
434 | 438 | $fields = array( |
435 | 439 | 'OriginalID' => 'Int', |
@@ -456,7 +460,9 @@ discard block |
||
456 | 460 | */ |
457 | 461 | public function requireDefaultRecords() { |
458 | 462 | // @todo This relies on the Locale attribute being on the base data class, and not any subclasses |
459 | - if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false; |
|
463 | + if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) { |
|
464 | + return false; |
|
465 | + } |
|
460 | 466 | |
461 | 467 | // Permissions: If a group doesn't have any specific TRANSLATE_<locale> edit rights, |
462 | 468 | // but has CMS_ACCESS_CMSMain (general CMS access), then assign TRANSLATE_ALL permissions as a default. |
@@ -468,14 +474,20 @@ discard block |
||
468 | 474 | 'CMS_ACCESS_LeftAndMain', |
469 | 475 | 'ADMIN' |
470 | 476 | )); |
471 | - if($groups) foreach($groups as $group) { |
|
477 | + if($groups) { |
|
478 | + foreach($groups as $group) { |
|
472 | 479 | $codes = $group->Permissions()->column('Code'); |
480 | + } |
|
473 | 481 | $hasTranslationCode = false; |
474 | 482 | foreach($codes as $code) { |
475 | - if(preg_match('/^TRANSLATE_/', $code)) $hasTranslationCode = true; |
|
483 | + if(preg_match('/^TRANSLATE_/', $code)) { |
|
484 | + $hasTranslationCode = true; |
|
485 | + } |
|
476 | 486 | } |
477 | 487 | // Only add the code if no more restrictive code exists |
478 | - if(!$hasTranslationCode) Permission::grant($group->ID, 'TRANSLATE_ALL'); |
|
488 | + if(!$hasTranslationCode) { |
|
489 | + Permission::grant($group->ID, 'TRANSLATE_ALL'); |
|
490 | + } |
|
479 | 491 | } |
480 | 492 | |
481 | 493 | // If the Translatable extension was added after the first records were already |
@@ -485,7 +497,9 @@ discard block |
||
485 | 497 | 'SELECT "ID" FROM "%s" WHERE "Locale" IS NULL OR "Locale" = \'\'', |
486 | 498 | ClassInfo::baseDataClass($this->owner->class) |
487 | 499 | ))->column(); |
488 | - if(!$idsWithoutLocale) return; |
|
500 | + if(!$idsWithoutLocale) { |
|
501 | + return; |
|
502 | + } |
|
489 | 503 | |
490 | 504 | |
491 | 505 | |
@@ -502,7 +516,9 @@ discard block |
||
502 | 516 | * @param boolean $overwrite |
503 | 517 | */ |
504 | 518 | public function addTranslationGroup($originalID, $overwrite = false) { |
505 | - if(!$this->owner->exists()) return false; |
|
519 | + if(!$this->owner->exists()) { |
|
520 | + return false; |
|
521 | + } |
|
506 | 522 | |
507 | 523 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
508 | 524 | $existingGroupID = $this->getTranslationGroup($originalID); |
@@ -539,7 +555,9 @@ discard block |
||
539 | 555 | * @return int Numeric ID of the translationgroup in the <classname>_translationgroup table |
540 | 556 | */ |
541 | 557 | public function getTranslationGroup() { |
542 | - if(!$this->owner->exists()) return false; |
|
558 | + if(!$this->owner->exists()) { |
|
559 | + return false; |
|
560 | + } |
|
543 | 561 | |
544 | 562 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class); |
545 | 563 | return DB::query( |
@@ -646,8 +664,10 @@ discard block |
||
646 | 664 | $this->owner->ClassName = $changedFields['ClassName']['before']; |
647 | 665 | $translations = $this->owner->getTranslations(); |
648 | 666 | $this->owner->ClassName = $changedFields['ClassName']['after']; |
649 | - if($translations) foreach($translations as $translation) { |
|
667 | + if($translations) { |
|
668 | + foreach($translations as $translation) { |
|
650 | 669 | $translation->setClassName($this->owner->ClassName); |
670 | + } |
|
651 | 671 | $translation = $translation->newClassInstance($translation->ClassName); |
652 | 672 | $translation->populateDefaults(); |
653 | 673 | $translation->forceChange(); |
@@ -745,7 +765,9 @@ discard block |
||
745 | 765 | * @return DataObjectSet |
746 | 766 | */ |
747 | 767 | function getTranslations($locale = null, $stage = null) { |
748 | - if(!$this->owner->exists()) return new ArrayList(); |
|
768 | + if(!$this->owner->exists()) { |
|
769 | + return new ArrayList(); |
|
770 | + } |
|
749 | 771 | |
750 | 772 | // HACK need to disable language filtering in augmentSQL(), |
751 | 773 | // as we purposely want to get different language |
@@ -770,14 +792,18 @@ discard block |
||
770 | 792 | $currentStage = Versioned::current_stage(); |
771 | 793 | $joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass); |
772 | 794 | if($this->owner->hasExtension("Versioned")) { |
773 | - if($stage) Versioned::reading_stage($stage); |
|
795 | + if($stage) { |
|
796 | + Versioned::reading_stage($stage); |
|
797 | + } |
|
774 | 798 | $translations = Versioned::get_by_stage( |
775 | 799 | $baseDataClass, |
776 | 800 | Versioned::current_stage(), |
777 | 801 | $filter, |
778 | 802 | null |
779 | 803 | )->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause); |
780 | - if($stage) Versioned::reading_stage($currentStage); |
|
804 | + if($stage) { |
|
805 | + Versioned::reading_stage($currentStage); |
|
806 | + } |
|
781 | 807 | } else { |
782 | 808 | $class = $this->owner->class; |
783 | 809 | $translations = $baseDataClass::get() |
@@ -861,7 +887,9 @@ discard block |
||
861 | 887 | self::set_current_locale($originalLocale); |
862 | 888 | |
863 | 889 | if($original) { |
864 | - if($translation = $original->getTranslation($locale)) return trim($translation->RelativeLink(true), '/'); |
|
890 | + if($translation = $original->getTranslation($locale)) { |
|
891 | + return trim($translation->RelativeLink(true), '/'); |
|
892 | + } |
|
865 | 893 | } |
866 | 894 | } |
867 | 895 | |
@@ -916,7 +944,9 @@ discard block |
||
916 | 944 | $existingPage = SiteTree::get() |
917 | 945 | // disable get_one cache, as this otherwise may pick up results from when locale_filter was on |
918 | 946 | ->where("\"URLSegment\" = '{$this->owner->URLSegment}' $IDFilter $parentFilter")->First(); |
919 | - if($reEnableFilter) self::enable_locale_filter(); |
|
947 | + if($reEnableFilter) { |
|
948 | + self::enable_locale_filter(); |
|
949 | + } |
|
920 | 950 | |
921 | 951 | // By returning TRUE or FALSE, we overrule the base SiteTree->validateURLSegment() logic |
922 | 952 | return !$existingPage; |
@@ -1,156 +1,156 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The Translatable decorator allows your DataObjects to have versions in different languages, |
|
4 | - * defining which fields are can be translated. Translatable can be applied |
|
5 | - * to any {@link DataObject} subclass, but is mostly used with {@link SiteTree}. |
|
6 | - * Translatable is compatible with the {@link Versioned} extension. |
|
7 | - * To avoid cluttering up the database-schema of the 99% of sites without multiple languages, |
|
8 | - * the translation-feature is disabled by default. |
|
9 | - * |
|
10 | - * Locales (e.g. 'en_US') are used in Translatable for identifying a record by language, |
|
11 | - * see section "Locales and Language Tags". |
|
12 | - * |
|
13 | - * <h2>Configuration</h2> |
|
14 | - * |
|
15 | - * The extension is automatically enabled for SiteTree and SiteConfig records, |
|
16 | - * if they can be found. Add the following to your config.yml in order to |
|
17 | - * register a custom class: |
|
18 | - * |
|
19 | - * <code> |
|
20 | - * MyClass: |
|
21 | - * extensions: |
|
22 | - * Translatable |
|
23 | - * </code> |
|
24 | - * |
|
25 | - * Make sure to rebuild the database through /dev/build after enabling translatable. |
|
26 | - * Use the correct {@link set_default_locale()} before building the database |
|
27 | - * for the first time, as this locale will be written on all new records. |
|
28 | - * |
|
29 | - * <h3>"Default" locales</h3> |
|
30 | - * |
|
31 | - * Important: If the "default language" of your site is not US-English (en_US), |
|
32 | - * please ensure to set the appropriate default language for |
|
33 | - * your content before building the database with Translatable enabled: |
|
34 | - * <code> |
|
35 | - * Translatable::set_default_locale(<locale>); // e.g. 'de_DE' or 'fr_FR' |
|
36 | - * </code> |
|
37 | - * |
|
38 | - * For the Translatable class, a "locale" consists of a language code plus a region |
|
39 | - * code separated by an underscore, |
|
40 | - * for example "de_AT" for German language ("de") in the region Austria ("AT"). |
|
41 | - * See http://www.w3.org/International/articles/language-tags/ for a detailed description. |
|
42 | - * |
|
43 | - * <h2>Usage</h2> |
|
44 | - * |
|
45 | - * Getting a translation for an existing instance: |
|
46 | - * <code> |
|
47 | - * $translatedObj = Translatable::get_one_by_locale('MyObject', 'de_DE'); |
|
48 | - * </code> |
|
49 | - * |
|
50 | - * Getting a translation for an existing instance: |
|
51 | - * <code> |
|
52 | - * $obj = DataObject::get_by_id('MyObject', 99); // original language |
|
53 | - * $translatedObj = $obj->getTranslation('de_DE'); |
|
54 | - * </code> |
|
55 | - * |
|
56 | - * Getting translations through {@link Translatable::set_current_locale()}. |
|
57 | - * This is *not* a recommended approach, but sometimes inavoidable (e.g. for {@link Versioned} methods). |
|
58 | - * <code> |
|
59 | - * $origLocale = Translatable::get_current_locale(); |
|
60 | - * Translatable::set_current_locale('de_DE'); |
|
61 | - * $obj = Versioned::get_one_by_stage('MyObject', "ID = 99"); |
|
62 | - * Translatable::set_current_locale($origLocale); |
|
63 | - * </code> |
|
64 | - * |
|
65 | - * Creating a translation: |
|
66 | - * <code> |
|
67 | - * $obj = new MyObject(); |
|
68 | - * $translatedObj = $obj->createTranslation('de_DE'); |
|
69 | - * </code> |
|
70 | - * |
|
71 | - * <h2>Usage for SiteTree</h2> |
|
72 | - * |
|
73 | - * Translatable can be used for subclasses of {@link SiteTree}, |
|
74 | - * it is automatically configured if this class is foun. |
|
75 | - * |
|
76 | - * If a child page translation is requested without the parent |
|
77 | - * page already having a translation in this language, the extension |
|
78 | - * will recursively create translations up the tree. |
|
79 | - * Caution: The "URLSegment" property is enforced to be unique across |
|
80 | - * languages by auto-appending the language code at the end. |
|
81 | - * You'll need to ensure that the appropriate "reading language" is set |
|
82 | - * before showing links to other pages on a website through $_GET['locale']. |
|
83 | - * Pages in different languages can have different publication states |
|
84 | - * through the {@link Versioned} extension. |
|
85 | - * |
|
86 | - * Note: You can't get Children() for a parent page in a different language |
|
87 | - * through set_current_locale(). Get the translated parent first. |
|
88 | - * |
|
89 | - * <code> |
|
90 | - * // wrong |
|
91 | - * Translatable::set_current_locale('de_DE'); |
|
92 | - * $englishParent->Children(); |
|
93 | - * // right |
|
94 | - * $germanParent = $englishParent->getTranslation('de_DE'); |
|
95 | - * $germanParent->Children(); |
|
96 | - * </code> |
|
97 | - * |
|
98 | - * <h2>Translation groups</h2> |
|
99 | - * |
|
100 | - * Each translation can have one or more related pages in other languages. |
|
101 | - * This relation is optional, meaning you can |
|
102 | - * create translations which have no representation in the "default language". |
|
103 | - * This means you can have a french translation with a german original, |
|
104 | - * without either of them having a representation |
|
105 | - * in the default english language tree. |
|
106 | - * Caution: There is no versioning for translation groups, |
|
107 | - * meaning associating an object with a group will affect both stage and live records. |
|
108 | - * |
|
109 | - * SiteTree database table (abbreviated) |
|
110 | - * ^ ID ^ URLSegment ^ Title ^ Locale ^ |
|
111 | - * | 1 | about-us | About us | en_US | |
|
112 | - * | 2 | ueber-uns | Über uns | de_DE | |
|
113 | - * | 3 | contact | Contact | en_US | |
|
114 | - * |
|
115 | - * SiteTree_translationgroups database table |
|
116 | - * ^ TranslationGroupID ^ OriginalID ^ |
|
117 | - * | 99 | 1 | |
|
118 | - * | 99 | 2 | |
|
119 | - * | 199 | 3 | |
|
120 | - * |
|
121 | - * <h2>Character Sets</h2> |
|
122 | - * |
|
123 | - * Caution: Does not apply any character-set conversion, it is assumed that all content |
|
124 | - * is stored and represented in UTF-8 (Unicode). Please make sure your database and |
|
125 | - * HTML-templates adjust to this. |
|
126 | - * |
|
127 | - * <h2>Permissions</h2> |
|
128 | - * |
|
129 | - * Authors without administrative access need special permissions to edit locales other than |
|
130 | - * the default locale. |
|
131 | - * |
|
132 | - * - TRANSLATE_ALL: Translate into all locales |
|
133 | - * - Translate_<locale>: Translate a specific locale. Only available for all locales set in |
|
134 | - * `Translatable::set_allowed_locales()`. |
|
135 | - * |
|
136 | - * Note: If user-specific view permissions are required, please overload `SiteTree->canView()`. |
|
137 | - * |
|
138 | - * <h2>Uninstalling/Disabling</h2> |
|
139 | - * |
|
140 | - * Disabling Translatable after creating translations will lead to all |
|
141 | - * pages being shown in the default sitetree regardless of their language. |
|
142 | - * It is advised to start with a new database after uninstalling Translatable, |
|
143 | - * or manually filter out translated objects through their "Locale" property |
|
144 | - * in the database. |
|
145 | - * |
|
146 | - * @see http://doc.silverstripe.org/doku.php?id=multilingualcontent |
|
147 | - * |
|
148 | - * @author Ingo Schommer <ingo (at) silverstripe (dot) com> |
|
149 | - * @author Michael Gall <michael (at) wakeless (dot) net> |
|
150 | - * @author Bernat Foj Capell <[email protected]> |
|
151 | - * |
|
152 | - * @package translatable |
|
153 | - */ |
|
3 | + * The Translatable decorator allows your DataObjects to have versions in different languages, |
|
4 | + * defining which fields are can be translated. Translatable can be applied |
|
5 | + * to any {@link DataObject} subclass, but is mostly used with {@link SiteTree}. |
|
6 | + * Translatable is compatible with the {@link Versioned} extension. |
|
7 | + * To avoid cluttering up the database-schema of the 99% of sites without multiple languages, |
|
8 | + * the translation-feature is disabled by default. |
|
9 | + * |
|
10 | + * Locales (e.g. 'en_US') are used in Translatable for identifying a record by language, |
|
11 | + * see section "Locales and Language Tags". |
|
12 | + * |
|
13 | + * <h2>Configuration</h2> |
|
14 | + * |
|
15 | + * The extension is automatically enabled for SiteTree and SiteConfig records, |
|
16 | + * if they can be found. Add the following to your config.yml in order to |
|
17 | + * register a custom class: |
|
18 | + * |
|
19 | + * <code> |
|
20 | + * MyClass: |
|
21 | + * extensions: |
|
22 | + * Translatable |
|
23 | + * </code> |
|
24 | + * |
|
25 | + * Make sure to rebuild the database through /dev/build after enabling translatable. |
|
26 | + * Use the correct {@link set_default_locale()} before building the database |
|
27 | + * for the first time, as this locale will be written on all new records. |
|
28 | + * |
|
29 | + * <h3>"Default" locales</h3> |
|
30 | + * |
|
31 | + * Important: If the "default language" of your site is not US-English (en_US), |
|
32 | + * please ensure to set the appropriate default language for |
|
33 | + * your content before building the database with Translatable enabled: |
|
34 | + * <code> |
|
35 | + * Translatable::set_default_locale(<locale>); // e.g. 'de_DE' or 'fr_FR' |
|
36 | + * </code> |
|
37 | + * |
|
38 | + * For the Translatable class, a "locale" consists of a language code plus a region |
|
39 | + * code separated by an underscore, |
|
40 | + * for example "de_AT" for German language ("de") in the region Austria ("AT"). |
|
41 | + * See http://www.w3.org/International/articles/language-tags/ for a detailed description. |
|
42 | + * |
|
43 | + * <h2>Usage</h2> |
|
44 | + * |
|
45 | + * Getting a translation for an existing instance: |
|
46 | + * <code> |
|
47 | + * $translatedObj = Translatable::get_one_by_locale('MyObject', 'de_DE'); |
|
48 | + * </code> |
|
49 | + * |
|
50 | + * Getting a translation for an existing instance: |
|
51 | + * <code> |
|
52 | + * $obj = DataObject::get_by_id('MyObject', 99); // original language |
|
53 | + * $translatedObj = $obj->getTranslation('de_DE'); |
|
54 | + * </code> |
|
55 | + * |
|
56 | + * Getting translations through {@link Translatable::set_current_locale()}. |
|
57 | + * This is *not* a recommended approach, but sometimes inavoidable (e.g. for {@link Versioned} methods). |
|
58 | + * <code> |
|
59 | + * $origLocale = Translatable::get_current_locale(); |
|
60 | + * Translatable::set_current_locale('de_DE'); |
|
61 | + * $obj = Versioned::get_one_by_stage('MyObject', "ID = 99"); |
|
62 | + * Translatable::set_current_locale($origLocale); |
|
63 | + * </code> |
|
64 | + * |
|
65 | + * Creating a translation: |
|
66 | + * <code> |
|
67 | + * $obj = new MyObject(); |
|
68 | + * $translatedObj = $obj->createTranslation('de_DE'); |
|
69 | + * </code> |
|
70 | + * |
|
71 | + * <h2>Usage for SiteTree</h2> |
|
72 | + * |
|
73 | + * Translatable can be used for subclasses of {@link SiteTree}, |
|
74 | + * it is automatically configured if this class is foun. |
|
75 | + * |
|
76 | + * If a child page translation is requested without the parent |
|
77 | + * page already having a translation in this language, the extension |
|
78 | + * will recursively create translations up the tree. |
|
79 | + * Caution: The "URLSegment" property is enforced to be unique across |
|
80 | + * languages by auto-appending the language code at the end. |
|
81 | + * You'll need to ensure that the appropriate "reading language" is set |
|
82 | + * before showing links to other pages on a website through $_GET['locale']. |
|
83 | + * Pages in different languages can have different publication states |
|
84 | + * through the {@link Versioned} extension. |
|
85 | + * |
|
86 | + * Note: You can't get Children() for a parent page in a different language |
|
87 | + * through set_current_locale(). Get the translated parent first. |
|
88 | + * |
|
89 | + * <code> |
|
90 | + * // wrong |
|
91 | + * Translatable::set_current_locale('de_DE'); |
|
92 | + * $englishParent->Children(); |
|
93 | + * // right |
|
94 | + * $germanParent = $englishParent->getTranslation('de_DE'); |
|
95 | + * $germanParent->Children(); |
|
96 | + * </code> |
|
97 | + * |
|
98 | + * <h2>Translation groups</h2> |
|
99 | + * |
|
100 | + * Each translation can have one or more related pages in other languages. |
|
101 | + * This relation is optional, meaning you can |
|
102 | + * create translations which have no representation in the "default language". |
|
103 | + * This means you can have a french translation with a german original, |
|
104 | + * without either of them having a representation |
|
105 | + * in the default english language tree. |
|
106 | + * Caution: There is no versioning for translation groups, |
|
107 | + * meaning associating an object with a group will affect both stage and live records. |
|
108 | + * |
|
109 | + * SiteTree database table (abbreviated) |
|
110 | + * ^ ID ^ URLSegment ^ Title ^ Locale ^ |
|
111 | + * | 1 | about-us | About us | en_US | |
|
112 | + * | 2 | ueber-uns | Über uns | de_DE | |
|
113 | + * | 3 | contact | Contact | en_US | |
|
114 | + * |
|
115 | + * SiteTree_translationgroups database table |
|
116 | + * ^ TranslationGroupID ^ OriginalID ^ |
|
117 | + * | 99 | 1 | |
|
118 | + * | 99 | 2 | |
|
119 | + * | 199 | 3 | |
|
120 | + * |
|
121 | + * <h2>Character Sets</h2> |
|
122 | + * |
|
123 | + * Caution: Does not apply any character-set conversion, it is assumed that all content |
|
124 | + * is stored and represented in UTF-8 (Unicode). Please make sure your database and |
|
125 | + * HTML-templates adjust to this. |
|
126 | + * |
|
127 | + * <h2>Permissions</h2> |
|
128 | + * |
|
129 | + * Authors without administrative access need special permissions to edit locales other than |
|
130 | + * the default locale. |
|
131 | + * |
|
132 | + * - TRANSLATE_ALL: Translate into all locales |
|
133 | + * - Translate_<locale>: Translate a specific locale. Only available for all locales set in |
|
134 | + * `Translatable::set_allowed_locales()`. |
|
135 | + * |
|
136 | + * Note: If user-specific view permissions are required, please overload `SiteTree->canView()`. |
|
137 | + * |
|
138 | + * <h2>Uninstalling/Disabling</h2> |
|
139 | + * |
|
140 | + * Disabling Translatable after creating translations will lead to all |
|
141 | + * pages being shown in the default sitetree regardless of their language. |
|
142 | + * It is advised to start with a new database after uninstalling Translatable, |
|
143 | + * or manually filter out translated objects through their "Locale" property |
|
144 | + * in the database. |
|
145 | + * |
|
146 | + * @see http://doc.silverstripe.org/doku.php?id=multilingualcontent |
|
147 | + * |
|
148 | + * @author Ingo Schommer <ingo (at) silverstripe (dot) com> |
|
149 | + * @author Michael Gall <michael (at) wakeless (dot) net> |
|
150 | + * @author Bernat Foj Capell <[email protected]> |
|
151 | + * |
|
152 | + * @package translatable |
|
153 | + */ |
|
154 | 154 | class Translatable extends DataExtension implements TestOnly { |
155 | 155 | |
156 | 156 | const QUERY_LOCALE_FILTER_ENABLED = 'Translatable.LocaleFilterEnabled'; |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * to Translatable |
893 | 893 | * |
894 | 894 | * @return bool |
895 | - */ |
|
895 | + */ |
|
896 | 896 | public function augmentValidURLSegment() { |
897 | 897 | $reEnableFilter = false; |
898 | 898 | if(!Config::inst()->get('Translatable', 'enforce_global_unique_urls')) { |