Example #1
0
 public function editAction()
 {
     $request = $this->getRequest();
     $tagId = $request->getParam('tag_id');
     $tag = Modules_Tag_Services_Tag::getById($tagId);
     if (null == $tag) {
         Modules_Core_Services_Exception::error('DATA_NOT_FOUND');
     }
     $this->view->tagData = $tag;
     if ($request->isPost()) {
         $tagData = $request->getPost('tag');
         $tagData = Modules_Tag_Services_Tag::validate($tagData);
         if (isset($tagData['messages_error']) && $tagData['messages_error']) {
             $this->view->errorMessages = $tagData['messages'];
             $this->view->tagData = $tagData;
             return;
         }
         if (Modules_Tag_Services_Tag::checkExist($tagData['tag_text'], $tag['tag_id'])) {
             $this->view->tagData = $tagData;
             $this->view->existMessage = true;
             return;
         }
         $tag['tag_text'] = $tagData['tag_text'];
         $tag['slug'] = $tagData['slug'];
         Modules_Tag_Services_Tag::update($tag);
         Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('tag_actions_edit_success'));
         $this->redirect($this->view->url('tag_tag_edit', $tag));
     }
 }