public function addAction() { $request = $this->getRequest(); if ($request->isPost()) { $type = strtolower($request->getPost('type')); switch ($type) { case 'ajax': $this->disableLayout(); $this->setNoRender(); $tagText = trim($request->getPost('tag_text')); $tagText = $this->view->STRING->escape($tagText); //$tagText = Gio_Core_String::stripTags($tagText, array('.')); $response = array('status' => 'RESULT_NOT_OK', 'tag_text' => null, 'tag_id' => null); $json = new Services_JSON(); if ($tagText) { if (Modules_Tag_Services_Tag::checkExist($tagText)) { $response['status'] = 'RESULT_EXIST'; } else { $tag = array('tag_text' => $tagText, 'slug' => Gio_Core_String::removeSign($tagText, '-', true), 'created_date' => date('Y-m-d H:i:s')); $tagId = Modules_Tag_Services_Tag::add($tag); $response['status'] = 'RESULT_OK'; $response['tag_text'] = $tagText; $response['tag_id'] = $tagId; } } $this->getResponse()->setBody($json->encodeUnsafe($response)); return; break; default: $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'])) { $this->view->tagData = $tagData; $this->view->existMessage = true; return; } $tag = array('tag_text' => $this->view->STRING->escape($tagData['tag_text']), 'slug' => $tagData['slug'], 'created_date' => date('Y-m-d H:i:s')); $tagId = Modules_Tag_Services_Tag::add($tag); Gio_Core_Messenger::getInstance()->addMessage($this->view->TRANSLATOR->translator('tag_actions_add_success')); $this->redirect($this->view->url('tag_tag_add')); break; } } }