$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>'; } if ($moduleConfig->show_listfields) { echo '<table class="fields"><tbody>'; foreach ($listFields as $field) {
$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);">'; echo '<input class="pull-left" style="position: relative; width: 165px;" type="text" name="rename" value="' . $this->escape($access->name) . '" />'; //echo '<div class="btn-group pull-left">'; echo '<button class="btn" style="position: relative;" onclick="return JoomDOC.rename(this, \'' . addslashes(JoomDOCHelper::getTask(JOOMDOC_DOCUMENT, JOOMDOC_TASK_RENAME)) . '\', \'' . addslashes($access->name) . '\', \'' . addslashes($access->relativePath) . '\',\'' . JText::_('JOOMDOC_RENAME_SAME_NAME', true) . '\',\'' . JText::_('JOOMDOC_RENAME_EMPTY_NAME', true) . '\', \'' . JText::_('JOOMDOC_RENAME_FILE_EXISTS', true) . '\', \'' . JText::_('JOOMDOC_RENAME_DIR_EXISTS', true) . '\')">' . JText::_('JOOMDOC_RENAME_SAVE') . '</button>'; echo '<button class="btn" style="position: relative;" onclick="return JoomDOC.closeRename(this, \'' . addslashes($access->name) . '\')">' . JText::_('JOOMDOC_RENAME_CLOSE') . '</button>'; //echo '</div>'; echo '</div>'; }*/ /*if ($access->isTrashed && $access->canUntrash) {
echo '<th>' . JHtml::_('grid.sort', 'JOOMDOC_UPLOADER', 'name', $this->filter->listDirn, $this->filter->listOrder) . '</th>'; echo '<th>' . JHtml::_('grid.sort', 'JOOMDOC_HITS', 'hits', $this->filter->listDirn, $this->filter->listOrder) . '</th>'; echo '</tr>'; echo '</thead>'; echo '<tbody>'; foreach ($this->data as $i => $item) { echo '<tr class="row' . $i % 2 . '">'; if ($this->access->canManageVersions) { //echo $i.' | '.$item->id.' | '.$item->version.' | '.$this->maxVersion; echo '<td>' . JHtml::_('grid.id', ++$i, $item->id, $item->version == $this->maxVersion) . '</td>'; } echo '<td>' . $item->version . '</td>'; if ($showDownload) { echo '<td>'; if ($item->state == JOOMDOC_STATE_PUBLISHED) { echo '<a href="' . JRoute::_(JoomDOCRoute::download($item->path, null, $item->version)) . '" title="" target="_blank">'; echo $download; echo '</a>'; } elseif ($item->state == JOOMDOC_STATE_TRASHED) { echo $trashed; } echo '</td>'; } echo '<td nowrap="nowrap">' . JoomDOCFileSystem::getFileSize(JoomDOCFileSystem::getFullPath($item->path)) . '</td>'; echo '<td nowrap="nowrap">' . JoomDOCHelper::uploaded($item->upload, false) . '</td>'; echo '<td nowrap="nowrap">' . $item->name . '</td>'; echo '<td class="center" nowrap="nowrap">' . JoomDOCHelper::number($item->hits) . '</td>'; echo '</tr>'; } echo '</tbody>'; echo '<tfoot>';
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) {
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; }
<?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 JoomDOCViewLicense */ // test if property realy exist in request $path = JRequest::getVar('path', false) !== false ? JoomDOCRequest::getPath() : null; echo '<h1>' . $this->license->title . '</h1>'; if ($path) { echo '<h2>' . JText::_('JOOMDOC_MUST_CONFIRM') . '</h2>'; } echo JoomDOCHelper::applyContentPlugins($this->license->text); if ($path) { echo '<div class="confirm">'; echo '<input type="checkbox" name="confirm" id="confirm" value="1" onclick="JoomDOC.confirmLicense(this)" />'; echo '<label for="confirm">' . JText::_('JOOMDOC_CONFIRM') . '</label>'; echo '<a id="download" class="blind" href="' . JRoute::_(JoomDOCRoute::download($path)) . '" title="">' . JText::_('JOOMDOC_DOWNLOAD_FILE') . '</a>'; echo '</div>'; }
echo '</tbody>'; echo '</table>'; if ($this->access->docid && ($description = JString::trim($this->root->document->description))) { echo '<p>' . $description . '</p>'; } if ($this->access->licenseID) { echo '<a class="modal license" rel="{handler: \'iframe\', size: {x: ' . JOOMDOC_LIGHTBOX_WIDTH . ', y: ' . JOOMDOC_LIGHTBOX_HEIGHT . '}, onClose: function() {}}" href="' . JRoute::_(JoomDOCRoute::viewLicense($this->access->licenseID, $this->access->licenseAlias)) . '">' . JText::sprintf('JOOMDOC_ITEM_LICENSE', $this->access->licenseTitle) . '</a>'; } if (!$this->access->isFolder) { if ($this->access->canDownload || $this->access->canWebDav || $this->access->canEdit || $this->access->canDeleteDoc || $this->access->canCreate || $this->access->canDeleteFile || $this->access->canEditState) { echo '<div class="toolbar">'; 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)) . '">' . JText::_('JOOMDOC_DOWNLOAD_FILE') . '</a>'; } else { echo '<a class="download" href="' . JRoute::_(JoomDOCRoute::download($this->access->relativePath, $this->access->alias)) . '" title="">' . JText::_('JOOMDOC_DOWNLOAD_FILE') . '</a>'; } } if ($this->access->canCreate) { echo '<a class="add" href="' . JRoute::_(JoomDOCRoute::add($this->access->relativePath, $this->access->alias)) . '" title="">' . JText::_('JOOMDOC_ADD_DOCUMENT') . '</a>'; } if ($this->access->canEdit) { echo '<a class="edit" href="' . JRoute::_(JoomDOCRoute::edit($this->access->relativePath, $this->access->alias)) . '" title="">' . JText::_('JOOMDOC_EDIT_DOC') . '</a>'; } if ($this->access->canEditState) { if ($this->root->document->state == JOOMDOC_STATE_UNPUBLISHED) { echo '<a class="publish" href="' . JRoute::_(JoomDOCRoute::publish($this->access->relativePath, $this->access->alias)) . '" title="">' . JText::_('JOOMDOC_PUBLISH') . '</a>'; } elseif ($this->root->document->state == JOOMDOC_STATE_PUBLISHED) { echo '<a class="unpublish" href="' . JRoute::_(JoomDOCRoute::unpublish($this->access->relativePath, $this->access->alias)) . '" title="">' . JText::_('JOOMDOC_UNPUBLISH') . '</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>';