Author: Damian Mooyman (damian.mooyman@gmail.com)
Inheritance: extends DataExtension
 public function updateCMSFields(FieldList $fields)
 {
     parent::updateCMSFields($fields);
     // Fix URLSegment field issue for root pages
     if (!SiteTree::config()->nested_urls || empty($this->owner->ParentID)) {
         $baseLink = Director::absoluteURL(Controller::join_links(Director::baseURL(), Fluent::alias(Fluent::current_locale()), '/'));
         $urlsegment = $fields->dataFieldByName('URLSegment');
         $urlsegment->setURLPrefix($baseLink);
     }
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     // Ensure that Fluent doesn't interfere with scaffolding records from FluentTest.yml
     Config::nest();
     $this->setDefaultConfig();
     FluentExtension::set_enable_write_augmentation(false);
     parent::setUp();
     FluentExtension::set_enable_write_augmentation(true);
     // Reset fluent locale and domain mode
     Config::inst()->update('Fluent', 'force_domain', false);
     Fluent::set_persist_locale('fr_CA');
 }
 /**
  * Get all database fields to translate
  *
  * @param string $class Class name
  * @return array List of translated fields
  */
 public function getTranslatedFields($class)
 {
     if (isset($this->translatedFields[$class])) {
         return $this->translatedFields[$class];
     }
     $fields = array();
     $hierarchy = ClassInfo::ancestry($class);
     foreach ($hierarchy as $class) {
         // Skip classes without tables
         if (!DataObject::has_own_table($class)) {
             continue;
         }
         // Check translated fields for this class
         $translatedFields = FluentExtension::translated_fields_for($class);
         if (empty($translatedFields)) {
             continue;
         }
         // Save fields
         $fields = array_merge($fields, array_keys($translatedFields));
     }
     $this->translatedFields[$class] = $fields;
     return $fields;
 }
 public static function set_enable_write_augmentation($enabled)
 {
     self::$_enable_write_augmentation = $enabled;
 }
 public function augmentSearch(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     // Skip non-search queries
     if (!($searchFilter = $this->getSearchFilter($query))) {
         return;
     }
     // Check translated columns on the searched class, making sure it's in the allowed search list
     $class = $this->getClass($query);
     if (empty($class) || !isset(self::$keyword_patterns[$class])) {
         return;
     }
     // Extract keywords
     $this->getSearchParameters($class, $searchFilter, $keywords, $keywordsHTML, $booleanMode);
     if (empty($keywords)) {
         return;
     }
     // Augment selected columns
     $translatedColumns = array_keys(FluentExtension::translated_fields_for($class));
     $this->augmentSelect($class, $translatedColumns, $query, $keywords, $keywordsHTML);
     // Augment filter columns
     $this->augmentFilter($class, $translatedColumns, $query, $keywords, $keywordsHTML, $booleanMode);
 }