/** * Construct this form * @param string $action url where this form will point to * @param joppa\model\Theme $theme the theme for which a region has to be selected * @param string $region optional name of a region to preselect * @return null */ public function __construct($action, Theme $theme, $region = null) { parent::__construct($action, self::NAME); $regions = array(); $themeRegions = $theme->getRegions(); foreach ($themeRegions as $name => $themeRegion) { $regions[$name] = $themeRegion->getName(); } $factory = FieldFactory::getInstance(); $field = $factory->createField(FieldFactory::TYPE_LIST, self::FIELD_REGION, $region); $field->setAttribute('onchange', 'this.form.submit()'); $field->setOptions($regions); $field->addEmpty('---', ''); $this->addField($field); }
/** * Get the options for the theme field * @param joppa\model\Node $node * @return array array with a list of themes */ protected function getThemeOptions(Node $node) { $translator = I18n::getInstance()->getTranslator(); $themes = Theme::getThemes(); $inheritedNodeSettings = $node->settings->getInheritedNodeSettings(); if (!$inheritedNodeSettings) { return $themes; } $inheritThemeSuffix = $this->getThemeInheritSuffix($inheritedNodeSettings); $inheritTheme = array('' => $translator->translate(self::TRANSLATION_INHERIT) . $inheritThemeSuffix); return $inheritTheme + $themes; }