21 use \PKP\components\forms\FormComponent;
22 use \PKP\components\forms\FieldSelect;
24 define(
'FORM_THEME',
'theme');
48 if (!empty($context)) {
49 $activeTheme = $context->getData(
'themePluginPath');
50 $contextId = $context->getId();
52 $activeTheme =
\Application::get()->getRequest()->getSite()->getData(
'themePluginPath');
53 $contextId = CONTEXT_ID_NONE;
56 $themes = $themeOptions = [];
58 foreach ($plugins as $plugin) {
60 'value' => $plugin->getDirName(),
61 'label' => $plugin->getDisplayName(),
66 'label' => __(
'manager.setup.theme'),
67 'description' => __(
'manager.setup.theme.description'),
69 'value' => $activeTheme,
73 foreach ($plugins as $plugin) {
81 $themeOptions = $plugin->getOptionsConfig();
82 if (empty($themeOptions)) {
85 $themeOptionValues = $plugin->getOptionValues($contextId);
86 foreach ($themeOptions as $optionName => $optionField) {
87 $optionField->value = isset($themeOptionValues[$optionName]) ? $themeOptionValues[$optionName] :
null;
105 public function addThemeField($theme, $field, $position = []) {
106 if (empty($position)) {
107 if (!isset($this->themeFields[$theme])) {
108 $this->themeFields[$theme] = [];
110 $this->themeFields[$theme][] = $field;
112 $this->themeFields[$theme] = $this->
addToPosition($position[1], $this->themeFields[$theme], $field, $position[0]);
122 $activeThemeField = array_filter($this->fields,
function($field) {
123 return $field->name ===
'themePluginPath';
125 $activeTheme = $activeThemeField[0]->value;
126 if (!empty($this->themeFields[$activeTheme])) {
127 $this->fields = array_merge($this->fields, $this->themeFields[$activeTheme]);
130 $config = parent::getConfig();
133 if (!$this->groups) {
134 $this->
addGroup(array(
'id' =>
'default'));
135 $this->fields = array_map(
function($field) {
136 $field->groupId =
'default';
140 $defaultGroupId = $this->groups[0][
'id'];
141 $config[
'themeFields'] = array_map(
function($themeOptions) use ($defaultGroupId) {
142 return array_map(
function($themeOption) use ($defaultGroupId) {
144 $field[
'groupId'] = $defaultGroupId;