Exemplo n.º 1
0
 public function editAction()
 {
     // check acl
     if (!Knowledgeroot_Acl::iAmAllowed('content_' . $this->_getParam('id'), 'edit')) {
         $this->_redirect('page/' . $this->_getParam('content_page'));
     }
     if ($this->getRequest()->getMethod() == 'POST') {
         if ($this->_getParam('button') == 'close') {
             $this->_redirect('page/' . $this->_getParam('content_page'));
         }
         $content = new Knowledgeroot_Content($this->_getParam('id'));
         $content->setName($this->_getParam('content_title'));
         $content->setContent($this->_getParam('content'));
         $content->setParent($this->_getParam('content_page'));
         $content->setAcl(json_decode($this->_getParam('acl')));
         $content->save();
         // delete existing tags
         $content->deleteTags();
         // save tags
         if ($this->_getParam('content_tags') != '') {
             $tags = explode(",", $this->_getParam('content_tags'));
             foreach ($tags as $tag) {
                 if (trim($tag) != '') {
                     $newTag = new Knowledgeroot_Tag();
                     $newTag->setName(trim($tag));
                     $newTag->save();
                     $content->addTag($newTag);
                 }
             }
         }
         if ($this->_getParam('button') == 'save') {
             $this->_redirect('content/edit/' . $content->getId());
         } else {
             $this->_redirect('page/' . $this->_getParam('content_page') . '#content' . $content->getId());
         }
     } else {
         $this->view->action = 'edit';
         $this->view->id = $this->_getParam('id');
         $content = new Knowledgeroot_Content($this->_getParam('id'));
         $rte = Knowledgeroot_Registry::get('rte');
         $rte->setName('content');
         $rte->setContent($content->getContent(true));
         $this->view->editor = $rte;
         $this->view->title = $content->getName();
         $this->view->tags = $content->getTags();
         $this->view->page = $content->getParent();
         $parent = new Knowledgeroot_Page($content->getParent());
         $this->view->pagename = $parent->getName();
         $this->view->created_by = $content->getCreatedBy()->getLogin();
         $this->view->create_date = $content->getCreateDate()->getUserDate();
         $this->view->versions = $content->getVersions();
         $this->renderScript("content/content.phtml");
     }
 }
Exemplo n.º 2
0
 /**
  * delete tag from content
  *
  * @param Knowledgeroot_Tag $tag
  */
 public function deleteTag(Knowledgeroot_Tag $tag)
 {
     $tagMember = new Knowledgeroot_Db_Tag_Content();
     $tagMember->delete(array('tag_id' => $tag->getId(), 'content_id' => $this->id));
 }