public function deleteAction() { $file = new Knowledgeroot_File($this->_getParam('id')); // check acl if (!Knowledgeroot_Acl::iAmAllowed('content_' . $file->getParent(), 'delete')) { $this->_redirect(''); } $content = new Knowledgeroot_Content($file->getParent()); $file->delete(); $this->redirect('./page/' . $content->getParent() . '#content' . $content->getId()); }
public function listAction() { // load contents for page try { $page = new Knowledgeroot_Page($this->_getParam('id')); } catch (Exception $e) { // redirect to homepage on error $this->_redirect(''); } $contents = Knowledgeroot_Content::getContents($page); $files = array(); // get files for each content foreach ($contents as $value) { $files[$value->getId()] = Knowledgeroot_File::getFiles(new Knowledgeroot_Content($value->getId())); } // set page for view $this->view->id = $page->getId(); $this->view->title = $page->getName(); $this->view->subtitle = $page->getSubtitle(); $this->view->description = $page->getDescription(); $this->view->contentcollapse = $page->getContentCollapse(); $this->view->showpagedescription = $page->getShowContentDescription(); $this->view->showtableofcontent = $page->getShowTableOfContent(); // set contents for view $this->view->contents = $contents; // set files for view $this->view->files = $files; }
/** * restore content version */ public function restore() { if ($this->version === null) { return; } $content = new Knowledgeroot_Content($this->getId()); // restore contents $content->setName($this->getName()); $content->setContent($this->getContent(true)); // save $content->save(); }
public function restoreAction() { // acl checks if (!Knowledgeroot_Acl::iAmAllowed('content_' . $this->_getParam('id'), 'edit')) { $this->_redirect(''); } // get content and restore version $content = new Knowledgeroot_Content($this->_getParam('id'), $this->_getParam('version')); $content->restore(); $parent = $content->getParent(); // show success message Knowledgeroot_Message::success("Content restored", "Content was restored to version " . $this->_getParam('version')); // redirect to page $this->_redirect('page/' . $parent); }
public static function getFiles(Knowledgeroot_Content $content = null) { $ret = array(); $file = new Knowledgeroot_Db_File(); $select = $file->select(); $select->where('parent = ?', $content->getId()); $select->where('deleted = ' . Knowledgeroot_Db::false()); $rows = $file->fetchAll($select); foreach ($rows as $value) { $ret[] = new Knowledgeroot_File($value->id); } return $ret; }