2017-03-10 19:05:15 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of Clipboard view
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
|
|
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
|
|
|
* 2010-2012 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include parent class
|
|
|
|
*/
|
2021-04-15 13:36:32 +00:00
|
|
|
//require_once("class.Bootstrap.php");
|
2017-03-10 19:05:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Include class to preview documents
|
|
|
|
*/
|
|
|
|
require_once("SeedDMS/Preview.php");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which outputs the html page for clipboard view
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
|
|
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
|
|
|
* 2010-2012 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
2021-04-15 13:36:32 +00:00
|
|
|
class SeedDMS_View_Clipboard extends SeedDMS_Theme_Style {
|
2017-03-10 19:05:15 +00:00
|
|
|
/**
|
|
|
|
* Returns the html needed for the clipboard list in the menu
|
|
|
|
*
|
|
|
|
* This function renders the clipboard in a way suitable to be
|
|
|
|
* used as a menu
|
|
|
|
*
|
|
|
|
* @param array $clipboard clipboard containing two arrays for both
|
|
|
|
* documents and folders.
|
|
|
|
* @return string html code
|
|
|
|
*/
|
|
|
|
public function menuClipboard() { /* {{{ */
|
|
|
|
$clipboard = $this->params['session']->getClipboard();
|
|
|
|
if ($this->params['user']->isGuest() || (count($clipboard['docs']) + count($clipboard['folders'])) == 0) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
$content = '';
|
|
|
|
$content .= " <ul id=\"main-menu-clipboard\" class=\"nav pull-right\">\n";
|
|
|
|
$content .= " <li class=\"dropdown add-clipboard-area\">\n";
|
2020-08-27 05:52:52 +00:00
|
|
|
$content .= " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\" class=\"add-clipboard-area\">".getMLText('clipboard')." (".count($clipboard['folders'])."/".count($clipboard['docs']).") <i class=\"fa fa-caret-down\"></i></a>\n";
|
2017-03-10 19:05:15 +00:00
|
|
|
$content .= " <ul class=\"dropdown-menu\" role=\"menu\">\n";
|
|
|
|
foreach($clipboard['folders'] as $folderid) {
|
|
|
|
if($folder = $this->params['dms']->getFolder($folderid))
|
2020-08-27 05:52:52 +00:00
|
|
|
$content .= " <li><a href=\"../out/out.ViewFolder.php?folderid=".$folder->getID()."\" class=\"table-row-folder droptarget\" data-droptarget=\"folder_".$folder->getID()."\" rel=\"folder_".$folder->getID()."\" data-name=\"".htmlspecialchars($folder->getName(), ENT_QUOTES)."\" data-uploadformtoken=\"".createFormKey('')."\" formtoken=\"".createFormKey('')."\"><i class=\"fa fa-folder-o\"></i> ".htmlspecialchars($folder->getName())."</a></li>\n";
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
|
|
|
foreach($clipboard['docs'] as $docid) {
|
|
|
|
if($document = $this->params['dms']->getDocument($docid))
|
2020-08-27 05:52:52 +00:00
|
|
|
$content .= " <li><a href=\"../out/out.ViewDocument.php?documentid=".$document->getID()."\" class=\"table-row-document droptarget\" data-droptarget=\"document_".$document->getID()."\" rel=\"document_".$document->getID()."\" data-name=\"".htmlspecialchars($document->getName(), ENT_QUOTES)."\" formtoken=\"".createFormKey('')."\"><i class=\"fa fa-file\"></i> ".htmlspecialchars($document->getName())."</a></li>\n";
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
|
|
|
$content .= " <li class=\"divider\"></li>\n";
|
|
|
|
if(isset($this->params['folder']) && $this->params['folder']->getAccessMode($this->params['user']) >= M_READWRITE) {
|
2020-05-18 16:30:39 +00:00
|
|
|
$content .= " <li><a href=\"../op/op.MoveClipboard.php?targetid=".$this->params['folder']->getID()."&refferer=".urlencode('../out/out.ViewFolder.php?folderid='.$this->params['folder']->getID())."\">".getMLText("move_clipboard")."</a></li>\n";
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
|
|
|
// $content .= " <li><a href=\"../op/op.ClearClipboard.php?refferer=".urlencode($this->params['refferer'])."\">".getMLText("clear_clipboard")."</a><a class=\"ajax-click\" data-href=\"../op/op.Ajax.php\" data-param1=\"command=clearclipboard\">kkk</a> </li>\n";
|
2018-07-10 13:43:05 +00:00
|
|
|
// $content .= " <li><a class=\"ajax-click\" data-href=\"../op/op.Ajax.php\" data-param1=\"command=clearclipboard\">".getMLText("clear_clipboard")."</a></li>\n";
|
|
|
|
$menuitems = array();
|
|
|
|
$menuitems['clear_clipboard'] = array('label'=>'clear_clipboard', 'attributes'=>array(array('class', 'ajax-click'), array('data-href', '../op/op.Ajax.php'), array('data-param1', 'command=clearclipboard')));
|
|
|
|
if($this->hasHook('clipboardMenuItems'))
|
|
|
|
$menuitems = $this->callHook('clipboardMenuItems', $clipboard, $menuitems);
|
|
|
|
foreach($menuitems as $menuitem) {
|
|
|
|
$content .= "<li>";
|
|
|
|
$content .= "<a";
|
2018-08-08 04:54:59 +00:00
|
|
|
if(!empty($menuitem['link']))
|
2018-07-10 13:43:05 +00:00
|
|
|
$content .= ' href="'.$menuitem['link'].'"';
|
2018-08-08 04:54:59 +00:00
|
|
|
if(!empty($menuitem['attributes']))
|
|
|
|
foreach($menuitem['attributes'] as $attr)
|
|
|
|
$content .= ' '.$attr[0].'="'.$attr[1].'"';
|
2018-07-10 13:43:05 +00:00
|
|
|
$content .= ">";
|
|
|
|
$content .= getMLText($menuitem['label']);
|
|
|
|
$content .= "</a></li>";
|
|
|
|
}
|
2017-03-10 19:05:15 +00:00
|
|
|
$content .= " </ul>\n";
|
|
|
|
$content .= " </li>\n";
|
|
|
|
$content .= " </ul>\n";
|
|
|
|
echo $content;
|
|
|
|
} /* }}} */
|
|
|
|
|
2019-07-04 12:35:05 +00:00
|
|
|
/**
|
|
|
|
* Return row of clipboard for a folder
|
|
|
|
*
|
|
|
|
* @param object $folder
|
|
|
|
* @return string rendered html content
|
|
|
|
*/
|
|
|
|
public function folderClipboardRow($folder) { /* {{{ */
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
|
|
|
|
$content = '';
|
|
|
|
$comment = $folder->getComment();
|
|
|
|
if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "...";
|
2019-07-11 15:18:03 +00:00
|
|
|
// $content .= "<tr draggable=\"true\" rel=\"folder_".$folder->getID()."\" class=\"folder table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">";
|
|
|
|
$content .= $this->folderListRowStart($folder);
|
2019-07-04 12:35:05 +00:00
|
|
|
$content .= "<td><a draggable=\"false\" href=\"out.ViewFolder.php?folderid=".$folder->getID()."&showtree=".showtree()."\"><img draggable=\"false\" src=\"".$this->getMimeIcon(".folder")."\" width=\"24\" height=\"24\" border=0></a></td>\n";
|
|
|
|
$content .= "<td><a draggable=\"false\" href=\"out.ViewFolder.php?folderid=".$folder->getID()."&showtree=".showtree()."\">" . htmlspecialchars($folder->getName()) . "</a>";
|
|
|
|
if($comment) {
|
|
|
|
$content .= "<br /><span style=\"font-size: 85%;\">".htmlspecialchars($comment)."</span>";
|
|
|
|
}
|
|
|
|
$content .= "</td>\n";
|
|
|
|
$content .= "<td>\n";
|
2020-08-27 05:52:52 +00:00
|
|
|
$content .= "<div class=\"list-action\"><a class=\"removefromclipboard\" rel=\"F".$folder->getID()."\" msg=\"".getMLText('splash_removed_from_clipboard')."\" title=\"".getMLText('rm_from_clipboard')."\"><i class=\"fa fa-remove\"></i></a></div>";
|
2019-07-04 12:35:05 +00:00
|
|
|
$content .= "</td>\n";
|
|
|
|
$content .= "</tr>\n";
|
|
|
|
|
|
|
|
return $content;
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return row of clipboard for a document
|
|
|
|
*
|
|
|
|
* @param object $document
|
|
|
|
* @return string rendered html content
|
|
|
|
*/
|
|
|
|
public function documentClipboardRow($document, $previewer) { /* {{{ */
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
|
|
|
|
$content = '';
|
|
|
|
$comment = $document->getComment();
|
|
|
|
if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "...";
|
|
|
|
$latestContent = $this->callHook('documentLatestContent', $document);
|
|
|
|
if($latestContent === null)
|
|
|
|
$latestContent = $document->getLatestContent();
|
|
|
|
if($latestContent) {
|
|
|
|
$previewer->createPreview($latestContent);
|
|
|
|
$version = $latestContent->getVersion();
|
|
|
|
$status = $latestContent->getStatus();
|
|
|
|
|
2019-07-11 15:18:03 +00:00
|
|
|
$content .= $this->documentListRowStart($document);
|
2019-07-04 12:35:05 +00:00
|
|
|
|
|
|
|
if (file_exists($dms->contentDir . $latestContent->getPath())) {
|
|
|
|
$content .= "<td><a draggable=\"false\" href=\"../op/op.Download.php?documentid=".$document->getID()."&version=".$version."\">";
|
|
|
|
if($previewer->hasPreview($latestContent)) {
|
|
|
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" width=\"40\"src=\"../op/op.Preview.php?documentid=".$document->getID()."&version=".$latestContent->getVersion()."&width=40\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
|
|
|
} else {
|
|
|
|
$content .= "<img draggable=\"false\" class=\"mimeicon\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">";
|
|
|
|
}
|
|
|
|
$content .= "</a></td>";
|
|
|
|
} else
|
|
|
|
$content .= "<td><img draggable=\"false\" class=\"mimeicon\" src=\"".$this->getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\"></td>";
|
|
|
|
|
|
|
|
$content .= "<td><a draggable=\"false\" href=\"out.ViewDocument.php?documentid=".$document->getID()."&showtree=".showtree()."\">" . htmlspecialchars($document->getName()) . "</a>";
|
|
|
|
if($comment) {
|
|
|
|
$content .= "<br /><span style=\"font-size: 85%;\">".htmlspecialchars($comment)."</span>";
|
|
|
|
}
|
|
|
|
$content .= "</td>\n";
|
|
|
|
$content .= "<td>\n";
|
2020-08-27 05:52:52 +00:00
|
|
|
$content .= "<div class=\"list-action\"><a class=\"removefromclipboard\" rel=\"D".$document->getID()."\" msg=\"".getMLText('splash_removed_from_clipboard')."\" _href=\"../op/op.RemoveFromClipboard.php?folderid=".(isset($this->params['folder']) ? $this->params['folder']->getID() : '')."&id=".$document->getID()."&type=document\" title=\"".getMLText('rm_from_clipboard')."\"><i class=\"fa fa-remove\"></i></a></div>";
|
2019-07-04 12:35:05 +00:00
|
|
|
$content .= "</td>\n";
|
|
|
|
$content .= "</tr>";
|
|
|
|
}
|
|
|
|
return $content;
|
|
|
|
} /* }}} */
|
|
|
|
|
2017-03-10 19:05:15 +00:00
|
|
|
/**
|
|
|
|
* Return clipboard content rendered as html
|
|
|
|
*
|
|
|
|
* @param array clipboard
|
|
|
|
* @return string rendered html content
|
|
|
|
*/
|
|
|
|
public function mainClipboard() { /* {{{ */
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$clipboard = $this->params['session']->getClipboard();
|
|
|
|
$cachedir = $this->params['cachedir'];
|
|
|
|
$previewwidth = $this->params['previewWidthList'];
|
|
|
|
$timeout = $this->params['timeout'];
|
2019-01-18 12:07:39 +00:00
|
|
|
$xsendfile = $this->params['xsendfile'];
|
2017-03-10 19:05:15 +00:00
|
|
|
|
2019-01-18 12:07:39 +00:00
|
|
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
2017-03-10 19:05:15 +00:00
|
|
|
$content = '';
|
2020-05-13 07:27:16 +00:00
|
|
|
$txt = $this->callHook('preClipboard', $clipboard);
|
|
|
|
if(is_string($txt))
|
|
|
|
$content .= $txt;
|
2017-03-10 19:05:15 +00:00
|
|
|
$foldercount = $doccount = 0;
|
|
|
|
if($clipboard['folders']) {
|
|
|
|
foreach($clipboard['folders'] as $folderid) {
|
|
|
|
/* FIXME: check for access rights, which could have changed after adding the folder to the clipboard */
|
|
|
|
if($folder = $dms->getFolder($folderid)) {
|
2019-07-04 12:35:05 +00:00
|
|
|
$txt = $this->callHook('folderClipboardItem', $folder, 'clipboard');
|
|
|
|
if(is_string($txt))
|
|
|
|
$content .= $txt;
|
|
|
|
else {
|
|
|
|
$content .= $this->folderClipboardRow($folder);
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
2019-07-04 12:35:05 +00:00
|
|
|
|
2017-03-10 19:05:15 +00:00
|
|
|
$foldercount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($clipboard['docs']) {
|
|
|
|
foreach($clipboard['docs'] as $docid) {
|
|
|
|
/* FIXME: check for access rights, which could have changed after adding the document to the clipboard */
|
|
|
|
if($document = $dms->getDocument($docid)) {
|
2019-07-04 12:35:05 +00:00
|
|
|
$document->verifyLastestContentExpriry();
|
|
|
|
$txt = $this->callHook('documentClipboardItem', $document, $previewer, 'clipboard');
|
|
|
|
if(is_string($txt))
|
|
|
|
$content .= $txt;
|
|
|
|
else {
|
|
|
|
$content .= $this->documentClipboardRow($document, $previewer);
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
2019-07-04 12:35:05 +00:00
|
|
|
|
|
|
|
$doccount++;
|
2017-03-10 19:05:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* $foldercount or $doccount will only count objects which are
|
|
|
|
* actually available
|
|
|
|
*/
|
|
|
|
if($foldercount || $doccount) {
|
|
|
|
$content = "<table class=\"table\">".$content;
|
|
|
|
$content .= "</table>";
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
$content .= "<div class=\"alert add-clipboard-area\">".getMLText("drag_icon_here")."</div>";
|
2020-05-13 07:27:16 +00:00
|
|
|
$txt = $this->callHook('postClipboard', $clipboard);
|
|
|
|
if(is_string($txt))
|
|
|
|
$content .= $txt;
|
2017-03-10 19:05:15 +00:00
|
|
|
echo $content;
|
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
}
|