protected function compile() { $arrOptions = $this->objWidget->options; $blnShowGroupLabel = true; $strOptionTemplate = $this->strTemplate . '_option'; $strOptGroupTemplate = $this->strTemplate . '_optgroup'; try { $strCustomTemplate = $strOptionTemplate . '_' . $this->objWidget->name; \Controller::getTemplate($strCustomTemplate); $strOptionTemplate = $strCustomTemplate; } catch (\Exception $e) { } try { $strCustomTemplate = $strOptGroupTemplate . '_' . $this->objWidget->name; \Controller::getTemplate($strCustomTemplate); $strOptGroupTemplate = $strCustomTemplate; } catch (\Exception $e) { } $arrCustomOptions = array(); $arrDisableGroups = $this->getSetting(BOOTSTRAPPER_OPTION_DISABLEOPTGROUPS); foreach ($arrOptions as $strKey => $arrOption) { if (isset($arrOption['value'])) { $arrCustomOptions[] = $this->parseOption($arrOption, $strKey, $strOptionTemplate); } else { $arrOptgroups = array(); foreach ($arrOption as $arrOptgroup) { $arrOptgroups[] = $this->parseOption($arrOptgroup, $strKey, $strOptionTemplate); } $arrCustomOptions[] = $this->parseOptGroup($strKey, $arrOptgroups, $strOptGroupTemplate, $arrDisableGroups); } } // for multiple select menu set blankOption as title attribute, required by bootstrap-select for example if ($this->arrDca['eval']['includeBlankOption'] && $this->arrDca['eval']['multiple']) { $strLabel = isset($this->arrDca['eval']['blankOptionLabel']) ? $this->arrDca['eval']['blankOptionLabel'] : '-'; $this->objWidget->addAttribute('title', $strLabel); } if ($this->arrDca['eval']['size']) { $this->objWidget->addAttribute('size', $this->arrDca['eval']['size']); } $this->Template->options = implode('', $arrCustomOptions); $this->Template->groupID = sprintf("%s_%s", $this->objWidget->type, $this->objWidget->id); $this->Template->name = $this->objWidget->name; if ($this->objWidget->multiple) { $this->Template->name .= '[]'; $this->addCssClass('multiselect'); } }
protected function compile() { $strOptions = ''; $arrOptions = $this->objWidget->options; $blnShowGroupLabel = true; if ($this->arrDca !== null && !isset($this->arrDca['options']) && !isset($this->arrDca['options_callback']) && !isset($this->arrDca['foreignKey'])) { // do not use description for single checkboxes in frontend $arrOptions[0]['label'] = $this->objWidget->label; $blnShowGroupLabel = false; } if ($this->blnUseAwesomeInputs) { $this->strTemplate .= '_awesome'; } $strOptionTemplate = $this->strTemplate . '_option'; try { $strCustomTemplate = $strOptionTemplate . '_' . $this->objWidget->name; \Controller::getTemplate($strCustomTemplate); $strOptionTemplate = $strCustomTemplate; } catch (\Exception $e) { } foreach ($arrOptions as $strKey => $arrOption) { $strOptions .= $this->parseOption($arrOption, $strKey, $strOptionTemplate); } $this->Template->options = $strOptions; $this->Template->groupID = sprintf("%s_%s", $this->objWidget->type, $this->objWidget->id); $this->Template->groupLabel = $this->objWidget->groupLabel ?: $this->objWidget->label; $this->Template->explanation = $this->objWidget->explanation; $this->Template->invisible = $this->objWidget->invisible; $this->Template->multiple = $this->objWidget->multiple; if (!$this->getSetting(BOOTSTRAPPER_OPTION_HIDELABEL) && $blnShowGroupLabel || $this->getSetting(BOOTSTRAPPER_OPTION_SHOWGROUPLABEL)) { $this->Template->showGroupLabel = true; } if ($this->getSetting(BOOTSTRAPPER_OPTION_SINGLESELECT)) { $this->addCssClass('checkbox-single-select'); } }
public function __construct(\Widget $objWidget) { // parse and generate methods append [] for multiple element widgets $objWidget->name = str_replace('[]', '', $objWidget->name); $this->objWidget = $objWidget; $this->arrDca = $GLOBALS['TL_DCA'][$objWidget->strTable]['fields'][$objWidget->strField]; global $objPage; $this->blnIsXhtml = $objPage->outputFormat == 'xhtml'; $this->blnUseAwesomeInputs = \Config::get('useAwesomeInputs'); // use custom field template, named by type and widget name try { $strCustomTemplate = $this->strTemplate . '_' . $objWidget->name; \Controller::getTemplate($strCustomTemplate); $this->strTemplate = $strCustomTemplate; } catch (\Exception $e) { } }
/** * Find a particular template file and return its path * * @param string $strTemplate The name of the template * @param string $strFormat The file extension * @param boolean $blnDefault If true, the default template path is returned * * @return string The path to the template file */ protected function getTemplatePath($strTemplate, $strFormat = 'html5', $blnDefault = false) { if ($blnDefault) { return \TemplateLoader::getDefaultPath($strTemplate, $strFormat); } return \Controller::getTemplate($strTemplate, $strFormat); }
if (empty($_POST['login'])) { $error[] = 'NO_LOGIN'; } else { $login = htmlspecialchars($_POST['login']); } if (empty($_POST['password'])) { $error[] = 'NO_PASSWORD'; } else { $password = md5($_POST['password']); } if (empty($error)) { $user = DB::getAll("SELECT * FROM `user` WHERE `login` = ? AND `password` = ? LIMIT 1", array($login, $password))->fetch(); if ($user) { $hash = setAutologin($user['id']); $upd = DB::update("UPDATE `user` SET `hash` = ? WHERE `id` = ?", array($hash, $user['id'])); setcookie('login', $login, 0, '/'); setcookie('hash', $hash, 0, '/'); header("Location: /cabinet/"); die; } else { $error[] = "Вы ошиблись при заполнении полей!"; } } } if (!empty($error)) { foreach ($error as $err) { echo Controller::getMess($err) . '<br>'; } } Controller::getTemplate();
require "includes/common/forms.php"; $controller = new Controller(); if ($_REQUEST['mod'] == 'index.php') { $controller->redirect(APP_ROOT . "/dashboard"); } if ($_REQUEST['mod'] != 'login' && (!isset($_SESSION['user']) || empty($_SESSION['user']['admin_id']))) { $controller->redirect(APP_ROOT . "/login"); } $controller->module = isset($_REQUEST['mod']) && $_REQUEST['mod'] != "" && $_REQUEST['mod'] != "index.php" ? $_REQUEST['mod'] : "dashboard"; $controller->parseFile(); $action = $controller->getAction(); $breadcrumb = $controller->getBreadcrumb(); if ($action) { include $action; $page = $controller->getPage(); if ($page) { if (!is_object($view)) { $view = new View(); } $view->page = $page; if (!$controller->isAjax()) { header("Content-type: text/html; charset=UTF-8"); $template = $controller->getTemplate(); include $template; } else { include $view->page; } } exit; } $controller->redirect("notFound");
/** * Do the generating of the map. * * @param MapModel $model Map model. * @param Filter|null $filter Optional request filter. * @param string $elementId Optional element id. If none given the mapId or alias is used. * @param string $template The template being used for generating. * @param string $style Optional style attributes. * * @return string * * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @SuppressWarnings(PHPMD.UnusedLocalVariable) */ protected function doGenerate($model, $filter, $elementId, $template, $style) { $definition = $this->getDefinition($model, $filter, $elementId); $template = \Controller::getTemplate($template); // @codingStandardsIgnoreStart - Set for the template. $javascript = $this->leaflet->build($definition, $this->assets); $mapId = $definition->getId(); // @codingStandardsIgnoreEnd ob_start(); include $template; $content = ob_get_contents(); ob_end_clean(); $event = new GetJavascriptEvent($definition, $content); $this->eventDispatcher->dispatch($event::NAME, $event); $buffer = $event->getJavascript(); return $buffer; }