public function index() { if (!empty(AuthenticationHandler::$data)) { Go::to('a'); } $f = new Form('search'); $this->addForm('search', $f); $this->setTitle('Savely.co'); $this->addScript('Dabox'); $this->addScript('Request'); $this->addScript('StageChart'); $form_register = new Form('register'); if ($form_register->isValid()) { $values = $form_register->getValues(); } $this->addForm('register', $form_register); $form = new Form('login'); if ($form->isValid()) { $values = $form->getValues(); if (AuthenticationHandler::setUserSession($values['login'], $values['password'])) { Go::to('a'); } else { $this->addContent('login_error', Dictionary::term('login.error.unknown_user')); } } $m = new ModelLink(); $all = $m->retrieveLinksHome(); $this->addContent('products', $all); $this->addForm('login', $form); }
/** * Méthode public de rendu de la page en cours * @param bool $pDisplay * @return string */ public function render($pDisplay = true) { $smarty = new Smarty(); Core::setupSmarty($smarty); if (!$smarty->template_exists($this->template)) { if (Core::debug()) { trigger_error("Le template <b>" . $this->template . "</b> est introuvable", E_USER_ERROR); } else { Go::to404(); } } $conf = get_class_vars('core\\application\\Configuration'); $terms = Dictionary::terms(); $globalVars = $this->getGlobalVars(); $smarty->assign_by_ref("configuration", $conf); $smarty->assign_by_ref("request_async", Core::$request_async); $smarty->assign_by_ref("dictionary", $terms); foreach ($this->forms as $n => &$form) { $smarty->register_object("form_" . $n, $form, array("display", "name", "getValue", "getLabel", "getOptions", "isChecked")); } foreach ($globalVars as $n => &$v) { $smarty->assign_by_ref($n, $v); } if (!Core::debug()) { $smarty->load_filter('output', 'gzip'); } return $smarty->fetch($this->template, null, null, $pDisplay); }
function smarty_function_getPagination($params, &$smarty) { $test = false; $info = array(); $noPage = 0; extract($params); if (empty($info) || $info["nbPages"] < 2) { return; } if (isset($info["noPage"])) { $noPage = $info["noPage"]; } if (isset($_GET["page"])) { $test = true; } $_GET["page"] = $info["currentPage"] - 1; echo '<div class="pagination"><div class="previous">'; echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button ' . ($info["currentPage"] == 1 ? 'disabled' : '') . '">' . Dictionary::term("global.pagination.previous") . '</a> '; echo '</div><div class="pages">'; if ($noPage) { echo $info["currentPage"] . " / " . $info["nbPages"]; } else { for ($i = 1; $i <= $info["nbPages"]; ++$i) { if ($i == 1 || $i == $info["currentPage"] || $i == $info["currentPage"] + 1 || $i == $info["currentPage"] - 1 || $i == $info["nbPages"]) { $_GET["page"] = $i; if ($i > 1) { echo ' - '; } if ($i == $info["currentPage"]) { echo '<span class="current_page">' . $i . '</span>'; } else { echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button">' . $i . '</a>'; } } if (($i == $info["currentPage"] + 2 || $i == $info["currentPage"] - 2) && ($i != 1 && $i != $info["nbPages"])) { echo " - ... "; } } } echo '</div>'; $_GET["page"] = $info["currentPage"] + 1; echo '<div class="next">'; echo '<a href="' . Core::rewriteURL(Core::$controller, Core::$action, $_GET) . '" class="button ' . ($info["currentPage"] == $info["nbPages"] || !$info["nbPages"] ? 'disabled' : '') . '">' . Dictionary::term("global.pagination.next") . '</a>'; echo "</div></div>"; if (!$test) { unset($_GET["page"]); } }
private static function input($pName, $pId, $pData, $pRequire = "") { $label = $selectValue = $textareaValue = $extra = ""; $inline = isset($pData["inline"]) && $pData["inline"]; if ($inline) { $pRequire = ""; } if (!empty($pData["label"])) { $label = $pData["label"] . $pRequire; } $input = self::getLabel($label, $pId, !$inline); if ($pData["tag"] == Form::TAG_SELECT && isset($pData["attributes"]["multiple"]) && $pData["attributes"]["multiple"] == "multiple") { $pName .= "[]"; } if (isset($pData["autoComplete"]) && isset($pData["attributes"]["type"]) && $pData["attributes"]["type"] == "text") { $pData["attributes"]["data-ac_minQueryLength"] = "3"; $pData["attributes"]["data-ac_resultsLocator"] = "responses"; $pData["attributes"]["data-ac_source"] = "statique/autocomplete/application:" . Core::$application . "/module:" . Core::$module . "/form_name:" . $pData["form_name"] . "/input_name:" . $pData["field_name"] . "/q:{query}/"; } $component = '<' . $pData["tag"] . ' name="' . $pName . '" id="' . $pId . '"'; foreach ($pData["attributes"] as $prop => $value) { $value = str_replace('"', """, $value); if ($prop == "id" || $prop == "name") { continue; } if ($prop != "value") { $component .= ' ' . $prop . '="' . $value . '"'; } else { switch ($pData["tag"]) { case Form::TAG_INPUT: if ($pData["attributes"]["type"] == "checkbox" || $pData["attributes"]["type"] == "hidden" || $pData["attributes"]["type"] == "text" || $pData["attributes"]["type"] == "email" || $pData["attributes"]["type"] == "submit" || $pData["attributes"]["type"] == "button") { $component .= ' ' . $prop . '="' . $value . '"'; } break; case Form::TAG_SELECT: $selectValue = $value; break; case Form::TAG_TEXTAREA: $textareaValue = $value; break; default: $component .= ' ' . $prop . '="' . $value . '"'; break; } } } switch ($pData["tag"]) { case "input": $component .= "/>"; if (isset($pData["autoFill"]) && isset($pData["attributes"]["type"]) && $pData["attributes"]["type"] == "text") { $extra .= self::script("AutoFillPlugin.applyTo(document.getElementById('" . $pId . "'), '" . $pData["autoFill"] . "');", "", true); } if (isset($pData["autoComplete"]) && isset($pData["attributes"]["type"]) && $pData["attributes"]["type"] == "text") { $extra .= self::script("Autocomplete.applyTo('#" . $pId . "');"); } break; case "select": if (isset($pData["chosen"]) && $pData["chosen"] == true) { $no_result = Dictionary::term("global.forms.chosen.no_result_text"); $default_text = Dictionary::term("global.forms.chosen.default_text"); if (isset($pData["parameters"]["no_result_text"])) { $no_result = $pData["parameters"]["no_result_text"]; } if (isset($pData["parameters"]["default_text"])) { $default_text = $pData["parameters"]["default_text"]; } $component .= ' data-placeholder="' . $default_text . '"'; $extra .= self::script(' if($("' . $pId . '__chosen")){$("' . $pId . '__chosen").parentNode.removeChild($("' . $pId . '_chosen"));} new Chosen($("' . $pId . '"),{no_results_text: "' . $no_result . '", allow_single_deselect: ' . ($pData["require"] ? 'false' : 'true') . '}); ', "", true); } $options = ""; if (!isset($pData["options"])) { $pData["options"] = array(); } if (!$pData["require"] && !(isset($pData["attributes"]["multiple"]) || $pData["attributes"]["multiple"] == "multiple")) { $d = array("value" => "", "name" => ""); array_unshift($pData["options"], $d); } foreach ($pData["options"] as $opt) { $value = $opt["value"]; $display = $opt["name"]; if (is_array($display)) { $options .= "<optgroup label='" . $value . "'>"; foreach ($display as $v => $l) { $options .= self::comboBoxOptions($l, $v, $selectValue); } $options .= "</optgroup>"; continue; } $options .= self::comboBoxOptions($display, $value, $selectValue); } $component .= ">" . $options . "</select>"; break; case "textarea": $component .= ">" . $textareaValue . "</textarea>"; break; } if ($inline) { $input = self::getComponent($component . $extra) . $input; } else { $input .= self::getComponent($component . $extra); } return $input; }
/** * Méthode permettant de définir le dictionnaire en fonction d'un fichier de langue * @return void */ public static function setDictionary() { $dictionary_path = self::$path_to_application . "/localization/" . Application::getInstance()->currentLanguage . ".json"; try { $data = SimpleJSON::import($dictionary_path); } catch (Exception $e) { if (self::debug()) { trigger_error('Fichier de langue "<b>' . $dictionary_path . '</b>" introuvable', E_USER_ERROR); } else { Application::getInstance()->currentLanguage = Application::getInstance()->defaultLanguage; Go::to404(); } } $seo = array(); $terms = array(); $alias = array(); if (isset($data["terms"]) && is_array($data["terms"])) { $terms = $data["terms"]; } if (isset($data["seo"]) && is_array($data["seo"])) { $seo = $data["seo"]; } if (isset($data["alias"]) && is_array($data["alias"])) { $alias = $data["alias"]; } Dictionary::defineLanguage(Application::getInstance()->currentLanguage, $terms, $seo, $alias); }
/** * @param string $pName * @return mixed */ public function get($pName) { return sprintf(Dictionary::term('backoffice.' . $this->id . '.' . $pName), $this->className); }