/**
  * 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];
 }
Example #2
0
 /**
  * @return string
  */
 private function getContent()
 {
     $config = Bootstrap::getConfig();
     switch ($this->bootstrap_modalContentType) {
         case 'article':
             return $this->getArticle($this->bootstrap_article, false, true);
             break;
         case 'form':
             $config->set('runtime.modal-footer', '');
             $content = $this->getForm($this->form);
             $this->formButtons = $config->get('runtime.modal-footer');
             $config->set('runtime.modal-footer', false);
             // render style select if it is used
             // TODO move this to an event or hook
             if ($this->isAjax && $config->get('form.styleSelect.enabled')) {
                 $content .= sprintf('<script>$(\'.%s\').selectpicker(\'render\');</script>', $config->get('form.styleSelect.class'));
             }
             return $content;
             break;
         case 'module':
             return $this->getFrontendModule($this->bootstrap_module);
             break;
         case 'html':
             return TL_MODE == 'FE' ? $this->html : htmlspecialchars($this->bootstrap_html);
             break;
         case 'template':
             ob_start();
             include $this->getTemplate($this->bootstrap_modalTemplate);
             $buffer = ob_get_contents();
             ob_end_clean();
             return $buffer;
             break;
         case 'text':
             return \String::toHtml5($this->bootstrap_text);
             break;
     }
     return '';
 }
Example #3
0
 /**
  * Select an icon set.
  *
  * @return void
  */
 protected function selectIconSet()
 {
     $config = Bootstrap::getConfig();
     $iconSet = Bootstrap::getIconSet();
     $active = $config->get('icons.active');
     $template = $config->get(sprintf('icons.sets.%s.template', $active));
     $path = $config->get(sprintf('icons.sets.%s.path', $active));
     if ($active && $path && file_exists(TL_ROOT . '/' . $path)) {
         $icons = (include TL_ROOT . '/' . $path);
         $iconSet->setIconSetName($active)->setIcons($icons)->setTemplate($template);
     }
     $this->addIconStylesheet();
 }
Example #4
0
 /**
  * Get modal content.
  *
  * @return string
  */
 private function getContent()
 {
     $config = Bootstrap::getConfig();
     switch ($this->bootstrap_modalContentType) {
         case 'article':
             return $this->getArticle($this->bootstrap_article, false, true);
         case 'form':
             return $this->generateForm($config);
         case 'module':
             return $this->getFrontendModule($this->bootstrap_module);
         case 'html':
             return TL_MODE == 'FE' ? $this->html : htmlspecialchars($this->bootstrap_html);
         case 'template':
             ob_start();
             include $this->getTemplate($this->bootstrap_modalTemplate);
             $buffer = ob_get_contents();
             ob_end_clean();
             return $buffer;
         case 'text':
             return \String::toHtml5($this->bootstrap_text);
         default:
             return '';
     }
 }
 /**
  * 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;
 }