コード例 #1
0
ファイル: default.php プロジェクト: abdullah929/bulletin
<?php

/**
 * @version		$Id$
 * @package		Joomla.Administrator
 * @subpackage	JoomDOC
 * @author      ARTIO s.r.o., info@artio.net, http:://www.artio.net
 * @copyright	Copyright (C) 2011 Artio s.r.o.. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
/* @var $this JoomDOCViewFile */
jimport('joomla.html.pagination');
JHtml::_('behavior.modal');
$config = JoomDOCConfig::getInstance();
$showDownload = JoomDOCAccessFileSystem::download($this->document ? $this->document->id : null, $this->filter->path);
// texts translations
$download = JText::_('JOOMDOC_DOWNLOAD_FILE');
$content = JText::_('JOOMDOC_FILE_CONTENT');
$trashed = JText::_('JTRASHED');
//var_dump($this->filter->state);
echo '<form name="adminForm" id="adminForm" action="' . JURI::getInstance()->toString() . '" method="post">';
//Joomla 3.0 display sidemenu manually
if (JOOMDOC_ISJ3) {
    $options = array();
    $options[0] = JText::_('JOOMDOC_FILE_PUBLISHED_TRASHED');
    $options[JOOMDOC_STATE_PUBLISHED] = JText::_('JOOMDOC_FILE_PUBLISHED');
    $options[JOOMDOC_STATE_TRASHED] = JText::_('JOOMDOC_FILE_TRASHED');
    JHtmlSidebar::addFilter(JText::_('JOPTION_SELECT_PUBLISHED'), 'state', JHtml::_('select.options', $options, 'value', 'text', $this->filter->state, true));
    echo '<div id="j-sidebar-nav" class="span2">';
    //render sidebar
コード例 #2
0
ファイル: filesystem.php プロジェクト: abdullah929/bulletin
 /**
  * Download file by request param path (relative path from doc root).
  *
  * @param booelan $saveHits if true increment file download counter
  * @return void
  */
 public static function download($saveHits = true)
 {
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $modelDocument = JModelLegacy::getInstance(JOOMDOC_DOCUMENT, JOOMDOC_MODEL_PREFIX);
     /* @var $modelDocument JoomDOCModelDocument */
     $modelFile = JModelLegacy::getInstance(JOOMDOC_FILE, JOOMDOC_MODEL_PREFIX);
     /* @var $modelFile JoomDOCModelFile */
     $config = JoomDOCConfig::getInstance();
     $user = JFactory::getUser();
     // get file path from request
     $path = JoomDOCRequest::getPath();
     $version = null;
     // control user access to download file
     if ($config->documentAccess == 1 && !JoomDOCAccessFileSystem::download(false, $path)) {
         jexit(JText::_('JOOMDOC_DOWNLOAD_NOT_ALLOWED'));
     }
     // get document by file relative path
     $document = $modelDocument->getItemByPath($path);
     if ($config->documentAccess == 2 && ($user->id != $document->access || !$document->download)) {
         jexit(JText::_('JOOMDOC_DOWNLOAD_NOT_ALLOWED'));
     }
     $file = $modelFile->getItem($path, $version);
     $fullPath = JoomDOCFileSystem::getFullPath($path);
     // open file to reading
     $content = JFile::read($fullPath);
     // control file access
     $fileNotAvailable = !$file || is_null($file->id) || $file->state == JOOMDOC_STATE_TRASHED;
     $documentUnpublished = $document && $document->id && $document->published == JOOMDOC_STATE_UNPUBLISHED;
     if ($mainframe->isSite() && $documentUnpublished || !JFile::exists($fullPath) || $content === false || $fileNotAvailable) {
         // file document unpublish or file doesn't exists or cannot read
         JError::raiseWarning(404, JText::_('JOOMDOC_FILE_NO_AVAILABLE'));
         $mainframe->redirect(JoomDOCRoute::viewDocuments());
         return;
     }
     if ($saveHits) {
         // save file downloading
         $modelFile->saveHits($path, 1);
     }
     // clean output
     ob_clean();
     // prepare packet head
     if (function_exists('mime_content_type')) {
         header('Content-Type: ' . mime_content_type($fullPath) . '; charset=UTF-8');
     } else {
         $ext = JFile::getExt($fullPath);
         // Open mime types
         $mimemap['pdf'] = 'application/pdf';
         // MS Office mime types
         $mimemap['doc'] = 'application/msword';
         $mimemap['xls'] = 'application/vnd.ms-excel';
         $mimemap['ppt'] = 'application/vnd.ms-powerpoint';
         // MS Office mime types XML
         $mimemap['docx'] = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
         $mimemap['xlsx'] = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
         $mimemap['pptx'] = 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
         // Archives
         $mimemap['zip'] = 'application/zip';
         $mimemap['tar'] = 'application/x-tar';
         // Open Office
         $mimemap['odb'] = 'application/vnd.oasis.opendocument.database';
         $mimemap['odc'] = 'application/vnd.oasis.opendocument.chart';
         $mimemap['odf'] = 'application/vnd.oasis.opendocument.formula';
         $mimemap['odg'] = 'application/vnd.oasis.opendocument.graphics';
         $mimemap['odi'] = 'application/vnd.oasis.opendocument.image';
         $mimemap['odm'] = 'application/vnd.oasis.opendocument.text-master';
         $mimemap['odp'] = 'application/vnd.oasis.opendocument.presentation';
         $mimemap['ods'] = 'application/vnd.oasis.opendocument.spreadsheet';
         $mimemap['odt'] = 'application/vnd.oasis.opendocument.text';
         $mimemap['otg'] = 'application/vnd.oasis.opendocument.graphics-template';
         $mimemap['oth'] = 'application/vnd.oasis.opendocument.text-web';
         $mimemap['otp'] = 'application/vnd.oasis.opendocument.presentation-template';
         $mimemap['ots'] = 'application/vnd.oasis.opendocument.spreadsheet-template';
         $mimemap['ott'] = 'application/vnd.oasis.opendocument.text-template';
         if (isset($mimemap[$ext])) {
             header('Content-Type: ' . $mimemap[$ext] . '; charset=UTF-8');
         }
     }
     header('Content-Transfer-Encoding: 8bit');
     header('Content-Disposition: attachment; filename="' . JFile::getName($fullPath) . '";');
     $fileSize = @filesize($fullPath);
     if ($fileSize) {
         header('Content-Length: ' . $fileSize);
     }
     // flush file
     die($content);
 }
コード例 #3
0
ファイル: helper.php プロジェクト: abdullah929/bulletin
 public function __construct(&$item)
 {
     $config = JoomDOCConfig::getInstance();
     /* @var $config JoomDOCConfig */
     $mainframe = JFactory::getApplication();
     /* @var $mainframe JApplication */
     $user = JFactory::getUser();
     $this->isFile = JoomDOCFileSystem::isFile($item);
     $this->isFolder = JoomDOCFileSystem::isFolder($item);
     $isFileSystemItem = $this->isFile || $this->isFolder;
     $this->docid = $isFileSystemItem ? JoomDOCHelper::getDocumentID($item) : $item->id;
     if (isset($item->document)) {
         $document = new JObject();
         $document->setProperties($item->document);
     } elseif (!$isFileSystemItem) {
         if ($item instanceof JObject) {
             $document = $item;
         } else {
             $document = new JObject($item);
             $document->setProperties($item);
         }
     } else {
         $document = new JObject();
     }
     $this->isTrashed = $isFileSystemItem ? @$item->file_state == JOOMDOC_STATE_TRASHED : $document->get('file_state') == JOOMDOC_STATE_TRASHED;
     if ($mainframe->isSite() && $document->get('state') == JOOMDOC_STATE_TRASHED) {
         $this->docid = null;
     }
     $this->relativePath = $isFileSystemItem ? $item->getRelativePath() : $item->path;
     $this->absolutePath = $isFileSystemItem ? $item->getAbsolutePath() : JoomDOCFileSystem::getFullPath($this->relativePath);
     $this->inRoot = $this->absolutePath == $config->path;
     $this->name = $isFileSystemItem ? $item->getFileName() : JFile::getName($this->relativePath);
     $this->alias = JoomDOCHelper::getDocumentAlias($item);
     $this->isChecked = JoomDOCHelper::isChecked($item);
     $this->isLocked = false;
     $this->fileType = JoomDOCHelper::getFileType($this->name);
     $this->canViewFileInfo = JoomDOCAccessFileSystem::viewFileInfo($this->docid, $this->relativePath);
     $this->fileVersion = JoomDOCHelper::getMaxVersion($this->relativePath);
     $this->canRename = JoomDOCAccessFileSystem::rename($this->docid, $this->relativePath);
     $this->canWebDav = JoomDOCAccessFileSystem::editWebDav($this->docid, $this->relativePath);
     $this->canEdit = $this->docid && JoomDOCAccessDocument::canEdit($document);
     $this->canCreate = !$this->docid && JoomDOCAccessDocument::create($this->relativePath);
     if ($config->documentAccess == 2 && $mainframe->isSite()) {
         $this->canDownload = $this->isFile && $document && $user->id == $document->get('access') && $document->get('download');
     } else {
         $this->canDownload = $this->isFile && JoomDOCAccessFileSystem::download($this->docid, $this->relativePath);
     }
     $this->canEnterFolder = JoomDOCAccessFileSystem::enterFolder($this->docid, $this->relativePath);
     $this->canOpenFolder = $this->isFolder && $this->canEnterFolder;
     $this->canOpenFile = $this->isFile;
     $this->canEditStates = JoomDOCAccessDocument::editState($this->docid, $document->get('checked_out'));
     $this->canEditState = $this->docid && JoomDOCAccessDocument::editState($this->docid, $document->get('checked_out'));
     if ($mainframe->isAdmin()) {
         $this->canEditState = JoomDOCAccessDocument::editState();
     }
     $this->canCopyMove = JoomDOCAccessFileSystem::copyMove($this->docid, $this->relativePath);
     $this->canDeleteDocs = JoomDOCAccessDocument::delete($this->docid);
     $this->canDeleteDoc = $this->docid && JoomDOCAccessDocument::delete($this->docid);
     $this->canDeleteFile = JoomDOCAccessFileSystem::deleteFile($this->docid, $this->relativePath);
     $this->canUpload = JoomDOCAccessFileSystem::uploadFile($this->docid, $this->relativePath);
     $this->canCreateFolder = JoomDOCAccessFileSystem::newFolder($this->docid, $this->relativePath);
     $this->canViewVersions = JoomDOCAccessDocument::viewVersions($this->docid);
     $this->canShowFileDates = $config->showCreated || $config->showModified;
     $this->canShowFileInfo = $config->showFilesize || $config->showHits;
     $this->canShowAllDesc = $config->showFolderDesc && $config->showFileDesc;
     $this->isFavorite = $document->get('favorite') == 1;
     $this->canDisplayFavorite = $this->isFavorite && $config->displayFavorite;
     $this->canAnyEditOp = $config->accessHandling && ($this->canEdit || $this->canWebDav || $this->canEditState || $this->canCreate || $this->canDeleteFile || $this->canDeleteDoc);
     if (!$this->docid || !$document->get('license_id')) {
         $license = JoomDOCHelper::license($this->relativePath);
         if ($license) {
             $this->licenseID = $license->id;
             $this->licenseAlias = $license->alias;
             $this->licenseTitle = $license->title;
         }
     } elseif ($document->get('license_state') == JOOMDOC_STATE_PUBLISHED) {
         $this->licenseID = $document->get('license_id');
         $this->licenseAlias = $document->get('license_alias');
         $this->licenseTitle = $document->get('license_title');
     }
     $this->canManageVersions = false;
     $this->canUntrash = JoomDOCAccessFileSystem::untrash($this->docid, $this->relativePath);
 }