public function init() { $this->fix_fluent_menu(); $this->fix_subsite_dropdown(); SubsiteProfile::enable(); }
function updateCMSFields(FieldList $fields) { $subsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain"); $subsitesMap = array(); if ($subsites && $subsites->Count()) { $subsitesMap = $subsites->map('ID', 'Title'); unset($subsitesMap[$this->owner->SubsiteID]); } if (Subsite::currentSubsiteID()) { $fields->removeByName('SubsiteID'); $fields->addFieldToTab('Root.Main', new CheckboxField('HideOnMainSite', _t('SubsitesExtra.HideOnMainSite', 'Hide on main site'))); } else { $field = $fields->dataFieldByName('SubsiteID'); if (!$field) { $fields->addFieldToTab('Root.Subsite', new DropdownField('SubsiteID', _t('SubsitesExtra.Subsite', 'Subsite'), $subsitesMap)); } } // Profile integration SubsiteProfile::applyToFields($this->owner, $fields); }
public function updateCMSFields(FieldList $fields) { $subsites = Subsite::accessible_sites(self::accessiblePermissions()); $subsitesMap = array(); if ($subsites && $subsites->Count()) { $subsitesMap = $subsites->map('ID', 'Title'); } if (!isset($subsitesMap[$this->owner->SubsiteID])) { $subsitesMap[$this->owner->SubsiteID] = $this->owner->Subsite()->Title; } if (Subsite::currentSubsiteID()) { $fields->removeByName('SubsiteID'); $fields->push(new HiddenField('SubsiteID', null, Subsite::currentSubsiteID())); $fields->addFieldToTab('Root.Main', new CheckboxField('HideOnMainSite', _t('SubsitesExtra.HideOnMainSite', 'Hide on main site'))); } else { $fields->removeByName('SubsiteID'); $fields->addFieldToTab('Root.Subsite', new DropdownField('SubsiteID', _t('SubsitesExtra.Subsite', 'Subsite'), $subsitesMap)); $fields->addFieldToTab('Root.Subsite', new CheckboxField('HideOnMainSite', _t('SubsitesExtra.HideOnMainSite', 'Hide on main site'))); } // Profile integration SubsiteProfile::applyToFields($this->owner, $fields); }
public static function enable($force_profile = null) { if ($force_profile) { self::$_current_profile = $force_profile; $force_profile::enable_custom_translations(); $force_profile::enable_custom_code(); return; } if (self::$_current_profile) { return; } if (!class_exists('Subsite')) { return; } if (!Subsite::currentSubsiteID()) { return; } $profile = Subsite::currentSubsite()->Profile; if (!$profile) { return; } self::$_current_profile = $profile; $profile::enable_custom_translations(); $profile::enable_custom_code(); }
public function updateCMSFields(FieldList $fields) { if (!$this->owner->ID) { return; } $accessibleSubsites = Subsite::accessible_sites("CMS_ACCESS_CMSMain"); $accessibleSubsitesMap = array(); if ($accessibleSubsites && $accessibleSubsites->Count()) { $accessibleSubsitesMap = $accessibleSubsites->map('ID', 'Title'); unset($accessibleSubsitesMap[$this->owner->SubsiteID]); } $fields->removeByName('SubsiteList'); if (Subsite::currentSubsiteID()) { $fields->removeByName('Subsites'); } else { $currentSubsites = $this->owner->Subsites(); $fields->removeByName('Subsites'); $conf = new GridFieldConfig_RecordViewer(); if (!Permission::check('ADMIN')) { $conf->removeComponentsByType('GridFieldAddNewButton'); } $grid = new GridField('Subsites', 'Subsites', $currentSubsites, $conf); $fields->addFieldToTab('Root.Subsites', $grid); $fields->addFieldToTab('Root.Subsites', new ReadonlyField('SubsiteList')); } // Profile integration SubsiteProfile::applyToFields($this->owner, $fields); }