/** * Delete document's (move to trash). * Method expected array cid in request with document's id's. * On end redirect to document's list view. * * @return void */ public function delete() { //parent::delete(); why it was here? JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); $mainframe = JFactory::getApplication(); /* @var $mainframe JAdministrator */ $cid = JRequest::getVar('cid', array(), '', 'array'); if (!is_array($cid) || !count($cid)) { JError::raiseWarning(500, JText::_('COM_JOOMDOC_ERROR_NO_ITEMS_SELECTED')); } else { $model = $this->getModel(); /* @var $model JoomDOCModelDocument */ JArrayHelper::toInteger($cid); foreach ($cid as $id) { JoomDOCAccessDocument::delete($id) ? $canDelete[] = $id : ($cannotDelete[] = $id); } if (isset($cannotDelete)) { $mainframe->enqueueMessage(JText::sprintf('JOOMDOC_UNABLE_DELETE_DOCUMENTS', implode(',', $cannotDelete)), 'error'); } if (isset($canDelete)) { $mainframe->enqueueMessage(JText::sprintf('COM_JOOMDOC_N_ITEMS_DELETED', $model->trash($canDelete))); } } $this->setRedirect(JoomDOCRoute::viewDocuments()); }
/** * Create new subfolder in current parent folder. * * @return void */ public function newFolder() { $app = JFactory::getApplication(); $success = JoomDOCFileSystem::newFolder(); if ($success && JRequest::getInt('doccreate')) { $this->setRedirect(JoomDOCRoute::addDocument($app->getUserState('com_joomdoc.new.folder'))); } else { $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false)); } }
/** * Untrash selected File. Search for latest version and publish it. * Others versions leave trashed. * * @return void */ public function untrash() { $path = JoomDOCRequest::getPath(); if (JoomDOCAccessFileSystem::untrash(null, $path)) { $model = $this->getModel(); $result = $model->untrash($path); if ($result) { $this->setRedirect(JoomDOCRoute::viewDocuments(), JText::sprintf('JOOMDOC_SUCCESS_UNTRASH', $path)); } else { $this->setRedirect(JoomDOCRoute::viewDocuments(), JText::sprintf('JOOMDOC_UNSUCCESS_UNTRASH', $path), 'error'); } } else { $this->setRedirect(JoomDOCRoute::viewDocuments(), JText::sprintf('JOOMDOC_UNTRASH_DISALLOW', $path), 'notice'); } }
/** * Rename file/folder. */ public function rename() { $renamePath = JString::trim(JRequest::getString('renamePath')); if (JoomDOCAccessFileSystem::rename(false, $renamePath)) { if ($success = JoomDOCFileSystem::rename($renamePath, JString::trim($newName = JRequest::getString('newName')))) { //if renamed directory, do refresh, else it will appear empty $newPath = ($parentPath = JoomDOCFileSystem::getParentPath($renamePath)) ? $parentPath . DIRECTORY_SEPARATOR . JRequest::getString('newName') : $newName; if (JFolder::exists(JoomDOCFileSystem::getFullPath($newPath))) { $mainfrane = JFactory::getApplication(); $mainfrane->enqueueMessage(JText::sprintf('JOOMDOC_REFRESHED', JoomDOCFileSystem::refresh())); } } $this->setRedirect(JoomDOCRoute::viewDocuments(), JText::_($success ? 'JOOMDOC_RENAME_SUCCESS' : 'JOOMDOC_RENAME_FAILED'), $success ? 'message' : 'error'); } else { JError::raiseError(403, JText::_('JOOMDOC_UNABLE_RENAME')); } }
/** * Set component submenu. * * @param string $view opened view page * @return void */ public static function setSubmenu($view = JOOMDOC_JOOMDOC, $asJ3Sidebar = false) { if ($asJ3Sidebar and JOOMDOC_ISJ3) { //J3: if we want to add own things to sidebar, we need to set up own html grid-12, so build own left submenu, which we will display $object = 'JHtmlSidebar'; } else { //else (if j3), its added to default submenu which is displayed as left sidebar automatically $object = 'JSubMenuHelper'; } $object::addEntry(JText::_('JOOMDOC_CONTROL_PANEL'), JoomDOCRoute::viewJoomDOC(), $view == JOOMDOC_JOOMDOC); $object::addEntry(JText::_('JOOMDOC_DOCUMENTS'), JoomDOCRoute::viewDocuments(), $view == JOOMDOC_DOCUMENTS); $object::addEntry(JText::_('JOOMDOC_LICENSES'), JoomDOCRoute::viewLicenses(), $view == JOOMDOC_LICENSES); if (JFactory::getUser()->authorise('core.managafields', 'com_joomdoc')) { $object::addEntry(JText::_('JOOMDOC_FIELDS'), JoomDOCRoute::viewFields(), $view == JOOMDOC_FIELDS); } $object::addEntry(JText::_('JOOMDOC_UPGRADE'), JoomDOCRoute::viewUpgrade(), $view == JOOMDOC_UPGRADE); $object::addEntry(JText::_('JOOMDOC_MIGRATION'), JoomDOCRoute::viewMigration(), $view == JOOMDOC_MIGRATION); }
function getObjectInfo($id, $language = null) { $info = new JCommentsObjectInfo(); $routerHelper = JPATH_ROOT . '/administrator/components/com_joomdoc/libraries/joomdoc/application/route.php'; if (is_file($routerHelper)) { require_once JPATH_ROOT . '/administrator/components/com_joomdoc/defines.php'; require_once $routerHelper; $db = JFactory::getDBO(); $query = $db->getQuery(true); $query->select('a.id, a.title, a.alias, a.access, a.created_by, a.path'); $query->from('#__joomdoc AS a'); $query->where('a.id = ' . (int) $id); $db->setQuery($query); $row = $db->loadObject(); if (!empty($row)) { $slug = $row->alias ? $row->id . ':' . $row->alias : $row->id; $info->title = $row->title; $info->access = $row->access; $info->userid = $row->created_by; $info->link = JRoute::_(JoomDOCRoute::viewDocuments($row->path, false)); } } return $info; }
echo '<script type="text/javascript"> $$(".dblc").addEvent("click", function() { return false;}).addEvent("dblclick", function() { window.location = this.href; return false;}) $("MooTree").setStyle("margin-right", "30px"); </script>'; $name = $access->isTrashed ? JText::sprintf('JOOMDOC_TRASHED_ITEM', $access->name) : $access->name; if ($access->isFolder) { $size = $access->isFolder ? '-' : $item->getFileSize(); $update = isset($item->upload) ? JoomDOCHelper::uploaded($item->upload, false) : ''; $of = JText::_('JOOMDOC_DOCUMENTS_OPEN_FOLDER'); if ($access->canEnterFolder && !$access->isTrashed) { echo '<a onclick="JoomDOC.checkCheckBox(cb' . $i . ');JoomDOC.check(cb' . $i . ',' . $i . ');" style="display: block; width: 140px; height: 90px; text-align: center;" class="hasTip folder-big dblc" href="' . JRoute::_(JoomDOCRoute::viewDocuments($access->relativePath)) . '" title="' . $this->getTooltip($access->relativePath, $of . '<br />' . $update . '/' . $size) . '"><span style="float: left; clear: both; display: inline-block; margin-top: 53px; width: 100%;">' . $access->name . '</span></a>'; } else { echo '<a class="folder noLink" href="javascript:void(0)" title="">' . $name . '</a>'; } } else { if ($access->canDownload && !$access->isTrashed) { $size = $access->isFolder ? '-' : $item->getFileSize(); $update = isset($item->upload) ? JoomDOCHelper::uploaded($item->upload, false) : ''; $of = JText::_('JOOMDOC_DOWNLOAD_FILE'); echo '<a onclick="JoomDOC.checkCheckBox(cb' . $i . ');JoomDOC.check(cb' . $i . ',' . $i . ');" style="display: block; width: 140px; height: 90px; padding: 0px; text-align: center;" href="' . JRoute::_(JoomDOCRoute::download($access->relativePath)) . '" class="hasTip dblc file ico-big-' . $access->fileType . '" title="' . $this->getTooltip($access->relativePath, $of . '<br />' . $update . '/' . $size) . '"><span style="float: left; clear: both; display: inline-block; margin-top: 53px; width: 100%;">' . $access->name . '</span></a>'; } else { echo '<a href="javascript:void(0)" class="file noLink" title="">' . $name . '</a>'; } } /*if ($access->canRename && !$access->isTrashed) { echo '<div class="rename blind" style="width: 302px; padding: 5px 5px 0px; background: none repeat scroll 0px 0px rgb(255, 255, 255);">';
* @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 JoomDOCViewJoomDOC */ $data = array_change_key_case(JApplicationHelper::parseXMLInstallFile(JOOMDOC_MANIFEST), CASE_LOWER); $xml = simplexml_load_file(JOOMDOC_MANIFEST); //all xml stuff is removed/deprecated in J3.0 echo '<div class="doc-width-60 fltlft">'; echo '<div id="cpanel">'; require_once JOOMDOC_ADMINISTRATOR . '/libraries/joomdoc/html/joomdoc.php'; echo JHtmlJoomDOC::startTabs('doc-cpanel-tabs', 'documents'); echo JHtmlJoomDOC::addTab('COM_DOC_JOOMDOC_CONFIGURATION', 'documents', 'doc-cpanel-tabs'); echo '<div class="icon-wrapper">'; echo '<div class="hasTip icon" title="' . $this->getTooltip('JOOMDOC_DOCUMENTS') . '">'; echo '<a href="' . JRoute::_(JoomDOCRoute::viewDocuments()) . '" title="" >'; echo '<img src="' . JOOMDOC_IMAGES . 'icon-48-documents.png" alt="" />'; echo '<span>' . JText::_('JOOMDOC_DOCUMENTS') . '</span>'; echo '</a>'; echo '</div>'; echo '<div class="hasTip icon" title="' . $this->getTooltip('JOOMDOC_LICENSES') . '">'; echo '<a href="' . JRoute::_(JoomDOCRoute::viewLicenses()) . '" title="" >'; echo '<img src="' . JOOMDOC_IMAGES . 'icon-48-license.png" alt="" />'; echo '<span>' . JText::_('JOOMDOC_LICENSES') . '</span>'; echo '</a>'; echo '</div>'; echo '<div class="hasTip icon" title="' . $this->getTooltip('JOOMDOC_CUSTOM_FIELDS') . '">'; echo '<a href="' . JRoute::_(JoomDOCRoute::viewFields()) . '" title="" >'; echo '<img src="' . JOOMDOC_IMAGES . 'icon-48-field.png" alt="" />'; echo '<span>' . JText::_('JOOMDOC_CUSTOM_FIELDS') . '</span>'; echo '</a>';
$prefix = '/administrator/'; $prefixLength = JString::strlen($prefix); $this->root->initIteration(); $i = 0; while ($this->root->hasNext()) { $item = $this->root->getNext(); $access = new JoomDOCAccessHelper($item); if ($access->docid && $item->document->published == JOOMDOC_STATE_UNPUBLISHED && !$access->canAnyEditOp) { continue; } echo '<tr class="row' . $i % 2 . '">'; echo '<td style="padding: 5px;">'; // backspashes doing bad in js pass $id = str_replace(DIRECTORY_SEPARATOR, '/', $this->escape($access->relativePath)); $title = $this->escape($access->docid ? $item->document->title : str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath)); $url = JRoute::_($linkType == JOOMDOC_LINK_TYPE_DOWNLOAD && $access->isFile ? JoomDOCRoute::download($access->relativePath, $access->alias) : JoomDOCRoute::viewDocuments($access->relativePath, $access->alias)); if (JString::strpos($url, $prefix) === 0) { $url = JString::substr($url, $prefixLength); } echo '<a href="javascript:window.parent.jSelectJoomdocDocument(\'' . addslashes(JoomDOCString::dsEncode($id)) . '\', \'' . addslashes($title) . '\', \'' . addslashes($url) . '\')" class="hasTip addDocument" title="' . $this->getTooltip('JOOMDOC_SET_DOCUMENT') . '"></a>'; if ($access->isFolder) { echo '<a class="hasTip folder" href="' . JURI::root(true) . JoomDOCRoute::modalDocuments($access->relativePath, $useLinkType, $addSymLink, $symLinkSource) . '" title="' . $this->getTooltip($access->relativePath, 'JOOMDOC_DOCUMENTS_OPEN_FOLDER') . '">' . $this->escape($access->name) . '</a>'; } else { echo '<span class="file">' . $this->escape($access->name) . '</span>'; } echo '</td>'; echo '<td style="padding: 5px;">' . ($access->docid ? $this->escape($item->document->title) : '-') . '</td>'; echo '</tr>'; $i++; } echo '</tbody>';
/** * @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; ?> <div id="joomdocSearch" class="<?php echo htmlspecialchars($params->get('moduleclass_sfx')); ?> "> <form name="mod_joomdoc_search_form" method="post" action="<?php echo JRoute::_(JoomDOCRoute::viewDocuments()); ?> " onsubmit="JoomDOCSearch.submit()"> <div class="input-append"> <input type="text" name="mod_joomdoc_search" id="mod_joomdoc_search" value="" class="input-small" /> <button class="btn btn-primary"><?php echo JText::_('JOOMDOC_SEARCH_SUBMIT'); ?> </button> </div> <input type="hidden" name="joomdoc_search" value="1" /> <?php foreach ($fields as $field) { ?> <input type="hidden" name="<?php echo $field;
/** * Filter folder list for frontend (published, ACL etc) * * @param JoomDOCFolder $root * @param string $parent * @return array */ public static function folders($root, $parent) { $folders = array(); $root->initIteration(); $parents = array(JoomDOCFileSystem::getRelativePath($parent)); while ($root->hasNext()) { $item = $root->getNext(); $access = new JoomDOCAccessHelper($item); $itemParent = JoomDOCFileSystem::getParentPath($access->relativePath); if (!(empty($itemParent) || in_array($itemParent, $parents))) { // parent has to be visible continue; } if ($access->docid && $item->document->published == JOOMDOC_STATE_UNPUBLISHED) { // item has to published continue; } $folder = new JObject(); // prepare data for MooTree $folder->set('ident', $access->relativePath); $folder->set('route', JoomDOCRoute::viewDocuments($access->relativePath, $access->alias)); $folder->set('title', $access->docid ? $item->document->title : $item->getFileName()); $folder->set('entry', $access->canEnterFolder); $folders[] = $folder; $parents[] = $access->relativePath; // save into visible parents } return $folders; }
public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { if (!JString::trim($text) || is_array($areas) && !array_intersect($areas, array_keys(plgSearchJoomDOC::onContentSearchAreas()))) { return array(); } // import component JoomDOC framework $jdcAdm = JPATH_ADMINISTRATOR . '/components/com_joomdoc/'; $jdcSit = JPATH_SITE . '/components/com_joomdoc/'; $jdcLib = $jdcAdm . 'libraries/joomdoc/'; $includes['JoomDOCRoute'] = $jdcLib . 'application/route.php'; $includes['JoomDOCMenu'] = $jdcLib . 'application/menu.php'; $includes['JoomDOCConfig'] = $jdcLib . 'application/config.php'; $includes['JoomDOCFileSystem'] = $jdcLib . 'filesystem/filesystem.php'; $includes['JoomDOCString'] = $jdcLib . 'utilities/string.php'; $includes['JoomDOCHelper'] = $jdcLib . 'utilities/helper.php'; $includes['JoomDOCModelList'] = $jdcLib . 'application/component/modellist.php'; $includes[] = $jdcAdm . 'defines.php'; foreach ($includes as $classname => $include) { $include = JPath::clean($include); if (!JFile::exists($include)) { // JoomDOC is propably uninstalled or corupted return array(); } is_string($classname) ? JLoader::register($classname, $include) : (include_once $include); } JModelLegacy::addIncludePath(JPath::clean($jdcAdm . 'models')); JTable::addIncludePath(JPath::clean($jdcAdm . 'tables')); $db = JFactory::getDbo(); $nullDate = $db->getNullDate(); // prepare SQL WHERE criteria $wheres = array(); // according to type of searching switch ($phrase) { case 'exact': // exactly phrase $keywords = $db->q('%' . JString::strtolower(JString::trim($text)) . '%'); $items[] = 'LOWER(`document`.`title`) LIKE ' . $keywords; $items[] = 'LOWER(`document`.`description`) LIKE ' . $keywords; $items[] = 'LOWER(`document`.`path`) LIKE ' . $keywords; $items[] = 'LOWER(`document`.`content`) LIKE ' . $keywords; $where[] = '(' . implode(') OR (', $items) . ') '; break; case 'all': case 'any': default: // all words or any word or default $keywords = explode(' ', $text); // split to words $wheres = array(); // search for each word foreach ($keywords as $keyword) { $keyword = JString::trim($keyword); if ($keyword) { $keyword = $db->q('%' . JString::strtolower($keyword) . '%'); $items[] = 'LOWER(`document`.`title`) LIKE ' . $keyword; $items[] = 'LOWER(`document`.`description`) LIKE ' . $keyword; $items[] = 'LOWER(`document`.`path`) LIKE ' . $keyword; $items[] = 'LOWER(`document`.`content`) LIKE ' . $keyword; $parts[] = implode(' OR ', $items); } } if (isset($parts)) { if ($phrase == 'all') { $where[] = '(' . implode(') AND (', $parts) . ') '; } else { $where[] = '(' . implode(') OR (', $parts) . ') '; } } break; } $where[] = '(' . JoomDOCModelList::getDocumentPublished() . ')'; $where = ' WHERE ' . implode(' AND ', $where) . ' '; // prepare SQL ORDER BY criteria switch ($ordering) { case 'oldest': // oldest items first (oldest documents created or oldest file uploaded) $order = ' ORDER BY `document`.`created` ASC, `document`.`upload` ASC '; break; case 'popular': // most hits items first $order = ' ORDER BY `document`.`hits` DESC, `document`.`title` ASC, `document`.`path` ASC '; break; case 'alpha': // alphabetically (document title or file name) $order = ' ORDER BY `document`.`title` ASC, `document`.`path` ASC '; break; case 'category': // by parent folder (parent folder name or document title) $order = ' ORDER BY `parent`.`title` ASC, `parent`.`path` ASC '; break; case 'newest': default: // newest items first (newest documents created or file uploaded) $order = ' ORDER BY `document`.`created` DESC, `document`.`upload` DESC '; break; } $query = 'SELECT `document`.`title`,`document`.`path`, '; $query .= '`document`.`description`, `document`.`content`, '; $query .= '`document`.`created`,`document`.`upload`, '; $query .= '`parent`.`title` AS `ptitle`, '; // document folder title $query .= '`document`.`full_alias` '; $query .= 'FROM `#__joomdoc_flat` AS `document` '; $query .= 'LEFT JOIN `#__joomdoc_flat` AS `parent` ON `document`.`parent_path` = `parent`.`path` '; // document folder $query .= $where . ' GROUP BY `document`.`path` ' . $order; $rows = $db->setQuery($query)->loadObjectList(); foreach ($rows as $row) { $GLOBALS['joomDOCPath'] = $row->path; $row->title = JString::trim($row->title) ? $row->title : JFile::getName($row->path); $row->text = JString::trim($row->description) ? $row->description : $row->content; $row->created = $row->created == $nullDate ? $row->upload : $row->created; $row->section = JString::trim($row->ptitle) ? $row->ptitle : JoomDOCFileSystem::getParentPath($row->path); if ($this->params->get('document_link', 1) == 1) { $row->href = JRoute::_(JoomDOCRoute::viewDocuments($row->path, empty($row->full_alias) ? $row->path : $row->full_alias)); } else { $row->href = JRoute::_(JoomDOCRoute::download($row->path, empty($row->full_alias) ? $row->path : $row->full_alias)); } $row->browsernav = 2; // open document title in the same window } unset($GLOBALS['joomDOCPath']); return $rows; }
* @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 JoomDOCViewDocuments */ JHtml::_('behavior.modal'); $config = JoomDOCConfig::getInstance(); if ($this->access->docid) { $this->root->document->description = JoomDOCHelper::applyContentPlugins($this->root->document->description, $this->root->getRelativePath(), $config->edocsDetail); } echo '<form action="' . JRoute::_(JoomDOCRoute::viewDocuments($this->access->relativePath, $this->access->alias)) . '" method="post" name="adminForm" id="adminForm">'; echo '<div id="document"' . ($this->access->isFavorite ? 'class="favorite"' : '') . '>'; if (!$this->access->inRoot && $this->access->relativePath) { echo '<a class="back" href="' . JRoute::_(JoomDOCRoute::viewDocuments(JoomDOCFileSystem::getParentPath($this->access->relativePath), $this->root->parent ? $this->root->parent->full_alias : null)) . '" title="">' . JText::_('JOOMDOC_BACK') . '</a>'; } echo '<h1>'; if ($this->access->canDownload) { if ($this->access->licenseID) { echo '<a class="modal download" rel="{handler: \'iframe\', size: {x: ' . JOOMDOC_LIGHTBOX_WIDTH . ', y: ' . JOOMDOC_LIGHTBOX_HEIGHT . '}, onClose: function() {}}" href="' . JRoute::_(JoomDOCRoute::viewLicense($this->access->licenseID, $this->access->licenseAlias, $this->access->relativePath, $this->access->alias)) . '">'; } else { echo '<a class="download" href="' . JRoute::_(JoomDOCRoute::download($this->access->relativePath, $this->access->alias)) . '" title="">'; } } //display document title only if published for current user. echo ($this->access->docid and $this->root->document->published == JOOMDOC_STATE_PUBLISHED) ? $this->root->document->title : $this->root->getFileName(); if ($this->access->canDownload) { echo '</a>'; } echo '</h1>';
public function setPathway($path) { $pieces = explode(DIRECTORY_SEPARATOR, $path); foreach ($pieces as $offset => $piece) { $crumbs[] = implode(DIRECTORY_SEPARATOR, array_slice($pieces, 0, $offset + 1)); } if (!empty($crumbs)) { $crumbs = $this->getDbo()->setQuery('SELECT path, title, full_alias FROM #__joomdoc_flat WHERE path IN (' . implode(', ', array_map(array($this->getDBO(), 'quote'), $crumbs)) . ')')->loadObjectList(); $pathway = JFactory::getApplication()->getPathway(); foreach ($crumbs as $crumb) { $pathway->addItem($crumb->title ? $crumb->title : JFile::getName($crumb->path), JoomDOCRoute::viewDocuments($crumb->path), $crumb->full_alias); } } }
if ($access->isFolder && !$config->showSubfolders) { continue; } // no display files without doc if (!$filesWithouDoc && !$access->docid && $access->isFile) { continue; } // document is unpublish and user cannot edit document or document is trashed if ($access->docid && $item->document->published == JOOMDOC_STATE_UNPUBLISHED && !$access->canAnyEditOp) { continue; } if ($config->showFileicon) { $class = JoomDOCHelper::getFileIconClass($access->isFile ? $access->relativePath : 'folder'); } // url to open item detail $viewDocuments = JRoute::_(JoomDOCRoute::viewDocuments($access->relativePath, $access->alias)); echo '<div class="document' . ($access->isFavorite ? ' favorite' : '') . '">'; echo '<h2 ' . ($class ? 'class="icon ' . $class . '"' : '') . '>'; if ($access->canOpenFile || $access->canOpenFolder) { // link to open file/subfolder echo '<a href="' . $viewDocuments . '" title="">'; } // as item title use document title or file name. use title only if published. (that means that owner will see it even if unpublished) echo ($access->docid and $item->document->published == JOOMDOC_STATE_PUBLISHED) ? $item->document->title : $item->getFileName(); if ($access->canOpenFile || $access->canOpenFolder) { echo '</a>'; } if ($this->access->canCopyMove) { echo '<input type="checkbox" name="paths[]" id="cbb' . $i . '" value="' . $this->escape($access->relativePath) . '" class="blind" />'; echo '<input type="checkbox" name="cid[]" id="cb' . $i . '" value="' . $access->docid . '" onclick="Joomla.isChecked(this.checked);JoomDOC.check(this,' . $i . ')" class="pull-right" />'; }
/** * 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); }
/** * Reset operation from clipboard. */ public function reset() { JoomDOCFileSystem::resetOperation(); $this->setRedirect(JoomDOCRoute::viewDocuments(JoomDOCRequest::getPath(), false)); }
/** * Reset operation from clipboard. */ public function reset() { JoomDOCFileSystem::resetOperation(); $this->setRedirect(JoomDOCRoute::viewDocuments()); }
echo '<tfoot><tr><td colspan="20">' . $this->pagination->getListFooter() . '</td></tr></tfoot>'; echo '<tbody>'; $prefix = JURI::base(true) . '/'; // should remove path, not only '/administrator/' $prefixLength = JString::strlen($prefix); $this->root->initIteration(); $i = 0; while ($this->root->hasNext()) { $item = $this->root->getNext(); $access = new JoomDOCAccessHelper($item); echo '<tr class="row' . $i % 2 . '">'; echo '<td>'; // backspashes doing bad in js pass $id = str_replace(DIRECTORY_SEPARATOR, '/', $this->escape($access->relativePath)); $title = $this->escape($access->docid ? $item->document->title : str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath)); $url = JRoute::_($linkType == JOOMDOC_LINK_TYPE_DOWNLOAD && $access->isFile ? JoomDOCRoute::download(str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath), $access->alias) : JoomDOCRoute::viewDocuments(str_replace(DIRECTORY_SEPARATOR, '/', $access->relativePath), $access->alias)); if (JString::strpos($url, $prefix) === 0) { $url = JString::substr($url, $prefixLength); } echo '<a href="javascript:window.parent.jSelectJoomdocDocument(\'' . addslashes(JoomDOCString::dsEncode($id)) . '\', \'' . addslashes($title) . '\', \'' . addslashes($url) . '\')" class="hasTip addDocument" title="' . $this->getTooltip('JOOMDOC_SET_DOCUMENT') . '"></a>'; if ($access->isFolder) { echo '<a class="hasTip folder" href="' . JRoute::_(JoomDOCRoute::modalDocuments($access->relativePath, $useLinkType, $addSymLink, $symLinkSource)) . '" title="' . $this->getTooltip($access->relativePath, 'JOOMDOC_DOCUMENTS_OPEN_FOLDER') . '">' . $this->escape($access->name) . '</a>'; } else { echo '<span class="file">' . $this->escape($access->name) . '</span>'; } echo '</td>'; echo '<td>' . ($access->docid ? $this->escape($item->document->title) : '-') . '</td>'; echo '</tr>'; $i++; } if ($i === 0) {
$root->initIteration(); while ($root->hasNext()) { $item = $root->getNext(); $access = new JoomDOCAccessHelper($item); if ($access->docid && $item->document->published == JOOMDOC_STATE_UNPUBLISHED) { // Document is unpublished continue; } $class = ''; if ($moduleConfig->show_icons) { // File mime type icon. $class = JoomDOCHelper::getFileIconClass($access->isFile ? $access->relativePath : 'folder', null, 16); } echo '<li' . ($class ? ' class="icon ' . $class . '"' : '') . '>'; if ($moduleConfig->link_type == 'detail') { $url = JoomDOCRoute::viewDocuments($access->relativePath, $access->alias); } elseif ($moduleConfig->link_type == 'download' && $access->canDownload) { // download link is displayed only if file can be download in ACL setting $url = JoomDOCRoute::download($access->relativePath, $access->alias); } else { $url = null; } if ($url) { echo '<a href="' . JRoute::_($url) . '" title="">' . ($access->docid ? $item->document->title : $item->getFileName()) . '</a>'; } else { // Name is displayed as document title or file path. echo $access->docid ? $item->document->title : $item->getFileName(); } if ($moduleConfig->show_filesize) { echo '<strong>' . JText::sprintf('JOOMDOC_MODULE_FILESIZE', JoomDOCFileSystem::getFileSize($access->absolutePath)) . '</strong>'; }
/** * Add page main toolbar. * * @return void */ protected function addToolbar() { JToolBarHelper::title(JText::sprintf('JOOMDOC_FILE_PATH', $this->filter->path), 'file'); if ($this->access->canManageVersions) { JToolBarHelper::deleteList('JOOMDOC_ARE_YOU_SURE_TRASH_VERSION', JoomDOCHelper::getTask(JOOMDOC_FILE, JOOMDOC_TASK_TRASH), 'JTOOLBAR_TRASH'); JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_FILE, JOOMDOC_TASK_RESTORE), JOOMDOC_ISJ3 ? 'refresh' : JOOMDOC_TASK_RESTORE, JOOMDOC_TASK_RESTORE, JText::_('JTOOLBAR_RESTORE')); JToolBarHelper::divider(); JToolBarHelper::custom(JoomDOCHelper::getTask(JOOMDOC_FILE, JOOMDOC_TASK_REVERT), JOOMDOC_ISJ3 ? 'redo' : JOOMDOC_TASK_REVERT, JOOMDOC_TASK_REVERT, JText::_('JTOOLBAR_REVERT')); JToolBarHelper::divider(); } if (JOOMDOC_ISJ3) { //has icon in J3 JToolBarHelper::cancel(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_CANCEL), 'JTOOLBAR_CLOSE'); } else { JToolBarHelper::back('Back', JRoute::_(JoomDOCRoute::viewDocuments())); } }