/** * {@inheritdoc} */ public function buildConfig(Config $config, BootstrapConfigModel $model) { $key = 'icons.sets.' . $model->name; if ($model->delete) { $config->remove($key); return; } $theme = $model->getRelated('pid'); $value = array('label' => $model->name . ($theme ? ' (' . $theme->name . ')' : ''), 'stylesheet' => $this->getStylesheets($model), 'template' => $model->icons_template, 'path' => $model->icons_path); $config->set($key, $value); }
/** * Get the bootstrap config for the form context. * * @param \FormModel|null $formModel The form model to which the widget belongs. * * @return ContextualConfig */ protected static function getConfig($formModel = null) { if (!$formModel) { return Bootstrap::getConfig(); } if (!isset(static::$configs[$formModel->id])) { $collection = BootstrapConfigModel::findMultipleByIds(deserialize($formModel->bootstrap_configs, true)); $config = static::getTypeManager()->buildContextualConfig($collection); static::$configs[$formModel->id] = $config; } return static::$configs[$formModel->id]; }
/** * Get config type options. * * @return array * * @SuppressWarnings(PHPMD.Superglobals) */ public function getConfigTypes() { \Controller::loadLanguageFile('tl_bootstrap_config'); $options = array(); $collection = BootstrapConfigModel::findBy(array('(type = ? OR type=?)'), array('form_widget', 'form'), array('order' => 'name')); if ($collection) { foreach ($collection as $model) { $type = isset($GLOBALS['TL_LANG']['bootstrap_config_type'][$model->type]) ? $GLOBALS['TL_LANG']['bootstrap_config_type'][$model->type] : $model->type; $options[$model->id] = sprintf('%s (%s): %s %s (%s)', $model->getRelated('pid')->name, $model->pid, $type, $model->name, $model->id); } } return $options; }
/** * Load theme configuration from database. * * @param InitializeLayoutEvent $event InitializeLayout event. * * @return void * * @internal param Config $config */ public function loadThemeConfig(InitializeLayoutEvent $event) { $themeId = $event->getLayoutModel()->pid; $collection = BootstrapConfigModel::findPublishedByTheme($themeId); $this->getTypeManager()->buildConfig($collection); }
/** * Import from config. * * @param mixed $value The value. * @param \DataContainer $dataContainer Data container driver. * * @return mixed */ public function importFromConfig($value, \DataContainer $dataContainer) { if (!$this->typeManager->hasType($value)) { return $value; } $type = $this->typeManager->getType($value); if ($dataContainer->activeRecord->override && \Input::get('override')) { if (!$dataContainer->activeRecord->name) { $dataContainer->activeRecord->name = \Input::post('name'); } if (!$type->isMultiple() || $dataContainer->activeRecord->name) { $key = $type->getPath(); if ($type->isMultiple()) { $key .= '.' . $dataContainer->activeRecord->name; } $model = BootstrapConfigModel::findByPk($dataContainer->id); $model->type = $value; $model->name = $dataContainer->activeRecord->name; $type->extractConfig($key, Bootstrap::getConfig(), $model); $model->save(); // unset parameter was only introduced in Contao 3.3 $this->redirect($this->addToUrl('override=', true, array('override'))); } } return $value; }