@@ -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; |
@@ -555,8 +555,7 @@ discard block |
||
555 | 555 | // this goes to elastica service |
556 | 556 | $this->service->remove($this->owner); |
557 | 557 | } |
558 | - } |
|
559 | - catch(\Elastica\Exception\NotFoundException $e) { |
|
558 | + } catch(\Elastica\Exception\NotFoundException $e) { |
|
560 | 559 | trigger_error("Deleted document ".$this->owner->ClassName." (".$this->owner->ID. |
561 | 560 | ") not found in search index.", E_USER_NOTICE); |
562 | 561 | } |
@@ -574,7 +573,9 @@ discard block |
||
574 | 573 | $fields = \Config::inst()->get(get_class($this->owner), 'searchable_fields'); |
575 | 574 | |
576 | 575 | // fallback to default method |
577 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$this->owner->ClassName); |
|
576 | + if(!$fields) { |
|
577 | + user_error('The field $searchable_fields must be set for the class '.$this->owner->ClassName); |
|
578 | + } |
|
578 | 579 | |
579 | 580 | // get the values of these fields |
580 | 581 | $elasticaMapping = $this->fieldsToElasticaConfig($this->owner, $fields); |
@@ -595,7 +596,9 @@ discard block |
||
595 | 596 | |
596 | 597 | $relClass = $has_lists[$methodName]; |
597 | 598 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
598 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
599 | + if(!$fields) { |
|
600 | + user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
601 | + } |
|
599 | 602 | $rewrite = $this->fieldsToElasticaConfig($relClass, $fields); |
600 | 603 | |
601 | 604 | // mark as a method, the resultant fields are correct |
@@ -605,7 +608,9 @@ discard block |
||
605 | 608 | } else if (isset($has_ones[$methodName])) { |
606 | 609 | $relClass = $has_ones[$methodName]; |
607 | 610 | $fields = \Config::inst()->get($relClass, 'searchable_fields'); |
608 | - if(!$fields) user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
611 | + if(!$fields) { |
|
612 | + user_error('The field $searchable_fields must be set for the class '.$relClass); |
|
613 | + } |
|
609 | 614 | $rewrite = $this->fieldsToElasticaConfig($relClass, $fields); |
610 | 615 | $classname = $has_ones[$methodName]; |
611 | 616 | |
@@ -687,7 +692,7 @@ discard block |
||
687 | 692 | |
688 | 693 | if (isset($searchableField['type'])) { |
689 | 694 | $doSF->Type = $searchableField['type']; |
690 | - } else { |
|
695 | + } else { |
|
691 | 696 | $doSF->Name = $searchableField['properties']['__method']; |
692 | 697 | $doSF->Type = 'relationship'; |
693 | 698 | } |
@@ -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); |