示例#1
0
 public function downloadAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $config = Knowledgeroot_Registry::get('config');
     // action body
     // normal download
     // with x-sendfile
     // @see: http://codeutopia.net/blog/2009/03/06/sending-files-better-apache-mod_xsendfile-and-php/
     // @see: http://redmine.lighttpd.net/projects/1/wiki/X-LIGHTTPD-send-file
     // @see: http://wiki.nginx.org/XSendfile
     $file = new Knowledgeroot_File($this->_getParam('id'));
     // check acl
     if (!Knowledgeroot_Acl::iAmAllowed('content_' . $file->getParent(), 'show')) {
         $this->_redirect('');
     }
     // check for sendfile option
     if ($config->files->xsendfile->enable) {
         header("Content-Disposition: attachment; filename=\"" . $file->getName() . "\";");
         header($config->files->xsendfile->name . ": " . $file->getDatastorePath());
     } else {
         header("Content-Type: " . $file->getType() . "; name=\"" . $file->getName() . "\"");
         header("Content-Disposition: attachment; filename=\"" . $file->getName() . "\";");
         header("Pragma: private");
         header("Expires: 0");
         header("Cache-Control: private, must-revalidate, post-check=0, pre-check=0");
         header("Content-Transfer-Encoding: binary");
         // put file content to screen
         echo $file->getContent();
     }
 }
示例#2
0
 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;
 }