Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 public function sign_out()
 {
     /** @var AuthenticationHandler $auth */
     $auth = Application::getInstance()->authenticationHandler;
     $auth::getInstance()->unsetUserSession();
     Go::to();
 }
Exemplo n.º 3
0
 public function update()
 {
     $links = $this->model_link->retrieveLinksByUser(AuthenticationHandler::$data['id_user']);
     foreach ($links as $l) {
         $this->model_link->updateLink($l['url_link']);
     }
     Go::to('a');
 }
Exemplo n.º 4
0
 public function view()
 {
     if (!Core::checkRequiredGetVars("permalink")) {
         Go::to404();
     }
     $m = new ModelPost();
     $post = $m->oneByPermalink($_GET["permalink"]);
     Autoload::addComponent('Dabox');
     $this->setTitle($post['title_post']);
     $this->addContent("post", $post);
 }
Exemplo n.º 5
0
 public function details()
 {
     if (!Core::checkRequiredGetVars('id', 'tab')) {
         Go::to404();
     }
     if (!Core::checkRequiredGetVars('no-async')) {
         Core::deactivateDebug();
     }
     $details = $this->model_link->details($_GET['id']);
     $s = array_reverse($this->model_link->getStatesByLink($_GET['id']));
     $this->addContent('states', str_replace('"', "'", SimpleJSON::encode($s)));
     $this->addContent('details', $details);
     $this->addContent('tab', $_GET['tab']);
 }
Exemplo n.º 6
0
 function __construct()
 {
     AuthenticationHandler::getInstance();
     if (!AuthenticationHandler::$data) {
         Go::to();
     }
     $this->addScript('ShopLater');
     $f = new Form('search');
     $this->addForm('search', $f);
     $f = new Form('addEntry');
     $this->addForm('addUrl', $f);
     $m = new ModelList();
     $this->addContent('user_lists', $m->retrieveByUser(AuthenticationHandler::$data['id_user'], 5));
 }
Exemplo n.º 7
0
 public function redirectToDefaultItem()
 {
     $item = null;
     if (is_array($this->items) && !empty($this->items)) {
         $item = $this->items[0];
     }
     foreach ($this->items as $i) {
         if (isset($i['default']) && $i['default'] == true) {
             $item = $i;
         }
     }
     if ($item === null) {
         trigger_error("[Object Menu] No default item found", E_USER_WARNING);
         return;
     }
     Go::to($item['controller'], $item['action'], $item['parameters']);
 }
Exemplo n.º 8
0
 public function update()
 {
     if (!Core::checkRequiredGetVars('permalink_list', 'prop_list') || !isset($_POST) || empty($_POST) || !isset($_POST['value']) || empty($_POST['value'])) {
         Go::to404();
     }
     $m = new ModelList();
     $list = $m->one(Query::condition()->andWhere('permalink_list', Query::EQUAL, $_GET['permalink_list']));
     if (!$list) {
         Go::to404();
     }
     $name = $_GET['prop_list'];
     if ($m->updateById($list['id_list'], array($name => $_POST['value']))) {
         $response = array("message" => "ok");
     } else {
         $response = array("error", "Unable to perform an update on field '" . $name . "'");
     }
     $response = SimpleJSON::encode($response);
     Core::performResponse($response, 'json');
 }
Exemplo n.º 9
0
 /**
  * @return void
  */
 public function captcha()
 {
     if (!Core::checkRequiredGetVars("form", "input")) {
         Go::to404();
     }
     $form = $_GET["form"];
     $input = $_GET["input"];
     if (isset($_GET["backoffice"]) && $_GET["backoffice"] == 1) {
         Core::$isBackoffice = true;
     }
     $form = new Form($form);
     $captcha = $form->getInput($input);
     if (empty($captcha) || $captcha["tag"] != Form::TAG_CAPTCHA) {
         Go::to404();
     }
     $avaibles = array("backgroundColor", "fontSizeMax", "fontSizeMin", "width", "height", "rotation", "transparent");
     if (!isset($captcha["length"]) || empty($captcha["length"]) || $captcha["length"] == 0) {
         $captcha["length"] = 5;
     }
     $c = new Captcha($captcha["length"], $input);
     if (isset($captcha["fontColors"]) && is_array($captcha["fontColors"])) {
         $a = $captcha["fontColors"];
         for ($i = 0, $max = count($a); $i < $max; $i++) {
             $c->addFontColor($a[$i]);
         }
     }
     if (isset($captcha["fontFace"]) && is_array($captcha["fontFace"])) {
         $a = $captcha["fontFace"];
         for ($i = 0, $max = count($a); $i < $max; $i++) {
             $c->addFontFace($a[$i]);
         }
     }
     for ($i = 0, $max = count($avaibles); $i < $max; $i++) {
         if (isset($captcha[$avaibles[$i]]) && !empty($captcha[$avaibles[$i]])) {
             $c->{$avaibles}[$i] = $captcha[$avaibles[$i]];
         }
     }
     $c->render();
     exit;
 }
Exemplo n.º 10
0
 /**
  * Méthode vérifiant l'existance de la méthode action dans la classe controller précédemment instanciée
  * @return String
  */
 public static function getAction()
 {
     if (!method_exists(self::$instance_controller, self::$action)) {
         Go::to404();
     }
     return self::$action;
 }
Exemplo n.º 11
0
 public function view()
 {
     if (!$this->actions->isEnabled('view')) {
         Go::to404();
     }
     $this->setTitle($this->titles->get('view'));
     $data = $this->model->getTupleById($_GET["id"]);
     if (!$data) {
         Go::to404();
     }
     $this->setTemplate("default", "view");
     $this->addContent("data", $data);
     $this->addContent("h1", $this->h1->get('view'));
 }
Exemplo n.º 12
0
 /**
  * @static
  * @param  $pURL
  * @return bool|string
  */
 public static function extractLanguage(&$pURL)
 {
     if (Application::getInstance()->multiLanguage && !preg_match("/^statique/", $pURL, $matches)) {
         $language = self::shift($pURL, self::REGEXP_LANGUAGE);
         if (!$language) {
             Go::to("", "", array(), Application::getInstance()->defaultLanguage);
         }
         return $language;
     }
     return Application::getInstance()->defaultLanguage;
 }