/** * Select the view layout if bootstrap is enabled. * * @param ViewEvent $event The event. * * @return void */ public function setViewLayout(ViewEvent $event) { if (Bootstrap::isEnabled()) { $view = $event->getView(); $view->setLayout('bootstrap'); $view->getAttributes()->addClass('form-group'); } }
/** * Listen to the form field hook. * * @param \Widget $widget The form field hook. * * @return \Widget */ public function loadFormField($widget) { if (Bootstrap::isEnabled()) { // Force table less mode in the form field. Otherwise it is not rendered. if ($widget->type === 'fieldset') { $widget->tableless = true; } // Force table less mode otherwise table html would be created. if ($widget instanceof \MadeYourDay\Contao\Form\AntispamField) { $widget->tableless = true; } } return $widget; }
/** * Parse current template. * * @param string $buffer Parsed template. * @param string $templateName Name of the template. * * @return string */ public function parse($buffer, $templateName) { if (!Bootstrap::isEnabled()) { return $buffer; } foreach ((array) Bootstrap::getConfigVar('templates.parsers') as $config) { if ($config['disabled'] || !$this->isTemplateAffected($templateName, (array) $config['templates'])) { continue; } if ($config['type'] == 'replace') { if (is_callable($config['replace'])) { $value = call_user_func($config['replace'], $buffer, $templateName); } else { $value = $config['replace']; } $buffer = str_replace($config['search'], $value, $buffer); } elseif ($config['type'] == 'callback') { $buffer = call_user_func($config['callback'], $buffer, $templateName); } } return $buffer; }
/** * */ private static function isBootstrapEnabled() { if (class_exists('Netzmacht\\Bootstrap\\Core\\Bootstrap') && \Netzmacht\Bootstrap\Core\Bootstrap::isEnabled()) { return true; } return false; }