Beispiel #1
0
 public function edit($id = NULL)
 {
     $id = (int) $id;
     if (!$id) {
         $this->redirect('admin');
     }
     $statuses = array("publish", "draft");
     if ($this->data) {
         if (isset($this->data['cancelar'])) {
             $this->redirect("admin/");
         } else {
             $P = new post();
             $P->find($id);
             if (!preg_match("/\\S+/", $this->data['title']) or $this->data['title'] == "") {
                 $this->data['title'] = "Untitled";
             }
             if (!preg_match("/\\S+/", $this->data['urlfriendly']) or $this->data['urlfriendly'] == "") {
                 $this->data['urlfriendly'] = $this->data['title'];
             }
             $this->data['urlfriendly'] = $P->buildUrl($this->data['urlfriendly'], $id);
             $P->updateTags($id, $this->data['tags']);
             unset($this->data['tags']);
             $P->prepareFromArray($this->data);
             $P->save();
             $this->session->flash('Información guardada correctamente.');
             $this->redirect("admin/edit/{$id}");
         }
     }
     $P = new post();
     $post = $P->find($id);
     $post['title'] = utils::convert2HTML($P['title']);
     $post['content'] = utils::convert2HTML($P['content']);
     $post['tags'] = $P->getTags($id, 'string');
     $this->title_for_layout($this->l10n->__("Editar post - Codice CMS"));
     $this->view->id = $id;
     $this->view->post = $post;
     $this->view->statuses = $statuses;
     $this->view->setLayout("admin");
     $this->render();
 }