Beispiel #1
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);
 }
Beispiel #2
0
 /**
  * Méthode de pré-traitement du formulaire avant envoi à la vue (parsing des libellés, des types de balises, définition des js/css requis)
  * @return void
  */
 public function prepareToView()
 {
     $this->cleanData();
     if (isset($this->post)) {
         $this->injectValues($this->post);
     }
     Autoload::addScript("Form");
     $this->countMendatory = 0;
     foreach ($this->data as $name => &$data) {
         switch ($data["tag"]) {
             case self::TAG_RICHEDITOR:
                 /** @ todo **/
                 trace("you must handle richeditor");
                 Autoload::addScript("ckeditor/ckeditor.js");
                 break;
             case self::TAG_UPLOAD:
                 Autoload::addComponent("Uploader");
                 Autoload::addScript("M4Tween");
                 $this->hasUpload = true;
                 break;
             case self::TAG_INPUT:
                 if (isset($data["attributes"]["type"]) && $data["attributes"]["type"] == "checkbox") {
                     unset($data["attributes"]["valueOff"]);
                 }
                 if (isset($data["autoComplete"])) {
                     Autoload::addComponent('Autocomplete');
                 }
                 if (isset($data["attributes"]["type"]) && $data["attributes"]["type"] == "file") {
                     Autoload::addComponent("Uploader");
                     Autoload::addScript("M4Tween");
                     $this->hasUpload = true;
                 } else {
                     if (isset($data["attributes"]["type"]) && $data["attributes"]["type"] == "submit" && Application::getInstance()->multiLanguage) {
                         $data["attributes"]["value"] = Dictionary::term($data["attributes"]["value"]);
                     }
                 }
                 break;
             case self::TAG_DATEPICKER:
                 Autoload::addComponent("Pikaday");
                 $this->hasDatePicker = true;
                 break;
             case self::TAG_COLORPICKER:
                 Autoload::addScript("jscolor/jscolor.js");
                 $this->hasColorPicker = true;
                 break;
             case self::TAG_RADIOGROUP:
             case self::TAG_CHECKBOXGROUP:
             case self::TAG_SELECT:
                 if (isset($data["fromModel"]) && is_array($data["fromModel"])) {
                     $condition = null;
                     $fm = $data["fromModel"];
                     if (isset($fm["condition"]) && is_array($fm["condition"])) {
                         $condition = Query::condition();
                         foreach ($fm["condition"] as $method => $parameters) {
                             call_user_func_array(array($condition, $method), $parameters);
                         }
                     }
                     $model = method_exists($fm["model"], "getInstance") ? $fm["model"]::getInstance() : new $fm["model"]();
                     $datas = $model->{$fm}["method"]($condition);
                     $options = array();
                     $defaultChecked = isset($data["attributes"]["checked"]) && !isset($this->post);
                     foreach ($datas as $donnees) {
                         if (is_object($donnees)) {
                             $donnees_name = $donnees->{$fm}["name"];
                             $donnees_value = $donnees->{$fm}["value"];
                         } else {
                             $donnees_name = isset($donnees[$fm['name']]) ? $donnees[$fm["name"]] : '';
                             $donnees_value = isset($donnees[$fm['value']]) ? $donnees[$fm["value"]] : '';
                         }
                         $options[] = array("name" => $donnees_name, "label" => $donnees_name, "value" => $donnees_value, "checked" => $defaultChecked);
                     }
                     if (!isset($data["options"])) {
                         $data["options"] = $options;
                     } else {
                         $data["options"] = array_merge($data["options"], $options);
                     }
                 }
                 if (isset($data["chosen"]) && $data["chosen"] == true) {
                     Autoload::addScript("chosen/chosen.min.js");
                     /** @todo componentify this */
                     Autoload::addStyle(Core::$path_to_components . "/chosen/style/chosen.css");
                 }
                 break;
         }
         if ($data["require"]) {
             $this->countMendatory++;
         }
         if (isset($data["attributes"]["valueGet"])) {
             if (isset($_GET[$data["attributes"]["valueGet"]])) {
                 $data["attributes"]["value"] = $_GET[$data["attributes"]["valueGet"]];
                 unset($this->data[$name]["attributes"]["valueGet"]);
             } else {
                 if (isset($data["attributes"]["type"]) && $data["attributes"]["type"] == "hidden") {
                     unset($this->data[$name]);
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * @static
  * @return void
  */
 public static function prepare()
 {
     Autoload::addComponent("Debugger");
 }