seeddms-code/views/bootstrap/class.ViewFolder.php

519 lines
18 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of ViewFolder view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @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
*/
require_once("class.Bootstrap.php");
/**
* Include class to preview documents
*/
require_once("SeedDMS/Preview.php");
2012-12-14 07:53:13 +00:00
/**
* Class which outputs the html page for ViewFolder view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @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@
*/
class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style {
2012-12-14 07:53:13 +00:00
2013-02-06 13:58:36 +00:00
function getAccessModeText($defMode) { /* {{{ */
switch($defMode) {
case M_NONE:
return getMLText("access_mode_none");
break;
case M_READ:
return getMLText("access_mode_read");
break;
case M_READWRITE:
return getMLText("access_mode_readwrite");
break;
case M_ALL:
return getMLText("access_mode_all");
break;
}
} /* }}} */
function printAccessList($obj) { /* {{{ */
$accessList = $obj->getAccessList();
if (count($accessList["users"]) == 0 && count($accessList["groups"]) == 0)
return;
$content = '';
2013-02-06 13:58:36 +00:00
for ($i = 0; $i < count($accessList["groups"]); $i++)
{
$group = $accessList["groups"][$i]->getGroup();
$accesstext = $this->getAccessModeText($accessList["groups"][$i]->getMode());
$content .= $accesstext.": ".htmlspecialchars($group->getName());
2013-02-06 13:58:36 +00:00
if ($i+1 < count($accessList["groups"]) || count($accessList["users"]) > 0)
$content .= "<br />";
2013-02-06 13:58:36 +00:00
}
for ($i = 0; $i < count($accessList["users"]); $i++)
{
$user = $accessList["users"][$i]->getUser();
$accesstext = $this->getAccessModeText($accessList["users"][$i]->getMode());
$content .= $accesstext.": ".htmlspecialchars($user->getFullName());
2013-02-06 13:58:36 +00:00
if ($i+1 < count($accessList["users"]))
$content .= "<br />";
}
if(count($accessList["groups"]) + count($accessList["users"]) > 3) {
$this->printPopupBox(getMLText('list_access_rights'), $content);
} else {
echo $content;
2013-02-06 13:58:36 +00:00
}
} /* }}} */
function js() { /* {{{ */
$user = $this->params['user'];
$folder = $this->params['folder'];
$orderby = $this->params['orderby'];
$expandFolderTree = $this->params['expandFolderTree'];
$enableDropUpload = $this->params['enableDropUpload'];
$maxItemsPerPage = $this->params['maxItemsPerPage'];
$showtree = $this->params['showtree'];
header('Content-Type: application/javascript; charset=UTF-8');
parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder'));
?>
function folderSelected(id, name) {
window.location = '../out/out.ViewFolder.php?folderid=' + id;
}
<?php if($maxItemsPerPage) { ?>
function loadMoreObjects(element, limit) {
if(!$(element).is(":visible"))
return;
2018-01-23 09:43:51 +00:00
element.text('<?= getMLText('more_objects_loading') ?>');
element.prop("disabled",true);
var folder = element.data('folder')
var offset = element.data('offset')
// var limit = element.data('limit')
url = seeddms_webroot+"out/out.ViewFolder.php?action=entries&folderid="+folder+"&offset="+offset+"&limit="+limit<?= $orderby ? '+"&orderby='.$orderby.'"' : "" ?>;
$.ajax({
type: 'GET',
url: url,
dataType: 'json',
success: function(data){
$('#viewfolder-table').append(data.html);
if(data.count <= 0) {
element.hide();
} else {
var str = '<?= getMLText('x_more_objects') ?>';
element.text(str.replace('[number]', data.count));
element.data('offset', offset+limit);
2018-01-23 09:43:51 +00:00
element.prop("disabled",false);
}
}
});
}
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
loadMoreObjects($('#loadmore'), $('#loadmore').data('limit'));
}
});
$('#loadmore').click(function(e) {
loadMoreObjects($(this), $(this).data('all'));
});
<?php } ?>
<?php
if($showtree == 1)
$this->printNewTreeNavigationJs($folder->getID(), M_READ, 0, '', ($expandFolderTree == 1) ? -1 : 3, $orderby);
2016-01-25 08:36:19 +00:00
if ($enableDropUpload && $folder->getAccessMode($user) >= M_READWRITE) {
echo "SeedDMSUpload.setUrl('../op/op.Ajax.php');";
echo "SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');";
echo "SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');";
echo "SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");";
echo "SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');";
}
$this->printDeleteFolderButtonJs();
$this->printDeleteDocumentButtonJs();
} /* }}} */
function entries() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$orderby = $this->params['orderby'];
$cachedir = $this->params['cachedir'];
$previewwidth = $this->params['previewWidthList'];
$previewconverters = $this->params['previewConverters'];
$timeout = $this->params['timeout'];
2019-01-18 12:07:39 +00:00
$xsendfile = $this->params['xsendfile'];
$offset = $this->params['offset'];
$limit = $this->params['limit'];
header('Content-Type: application/json');
2019-01-18 12:07:39 +00:00
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby);
if($subFolders === null)
$subFolders = $folder->getSubFolders($orderby);
$subFolders = SeedDMS_Core_DMS::filterAccess($subFolders, $user, M_READ);
$documents = $this->callHook('folderGetDocuments', $folder, $orderby);
if($documents === null)
$documents = $folder->getDocuments($orderby);
$documents = SeedDMS_Core_DMS::filterAccess($documents, $user, M_READ);
$content = '';
if ((count($subFolders) > 0)||(count($documents) > 0)){
$i = 0; // counts all entries
$j = 0; // counts only returned entries
foreach($subFolders as $subFolder) {
if($i >= $offset && $j < $limit) {
$txt = $this->callHook('folderListItem', $subFolder, 'viewfolder');
if(is_string($txt))
$content .= $txt;
else {
$content .= $this->folderListRow($subFolder);
}
$j++;
}
$i++;
}
if($subFolders && $documents) {
if(($j && $j < $limit) || ($offset + $limit == $i)) {
$txt = $this->callHook('folderListSeparator', $folder);
if(is_string($txt))
$content .= $txt;
}
}
foreach($documents as $document) {
if($i >= $offset && $j < $limit) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewfolder');
if(is_string($txt))
$content .= $txt;
else {
$content .= $this->documentListRow($document, $previewer);
}
$j++;
}
$i++;
}
echo json_encode(array('error'=>0, 'count'=>$i-($offset+$limit), 'html'=>$content));
}
} /* }}} */
2012-12-14 07:53:13 +00:00
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$orderby = $this->params['orderby'];
$enableFolderTree = $this->params['enableFolderTree'];
$enableClipboard = $this->params['enableclipboard'];
2014-07-11 06:42:57 +00:00
$enableDropUpload = $this->params['enableDropUpload'];
$expandFolderTree = $this->params['expandFolderTree'];
2012-12-14 07:53:13 +00:00
$showtree = $this->params['showtree'];
$cachedir = $this->params['cachedir'];
$workflowmode = $this->params['workflowmode'];
$enableRecursiveCount = $this->params['enableRecursiveCount'];
$maxRecursiveCount = $this->params['maxRecursiveCount'];
$maxItemsPerPage = $this->params['maxItemsPerPage'];
$incItemsPerPage = $this->params['incItemsPerPage'];
2014-03-18 09:55:24 +00:00
$previewwidth = $this->params['previewWidthList'];
$previewconverters = $this->params['previewConverters'];
2016-02-15 09:57:37 +00:00
$timeout = $this->params['timeout'];
2019-01-18 12:07:39 +00:00
$xsendfile = $this->params['xsendfile'];
2012-12-14 07:53:13 +00:00
$folderid = $folder->getId();
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/bootbox/bootbox.min.js"></script>'."\n", 'js');
2013-09-11 16:42:10 +00:00
2017-08-01 07:35:05 +00:00
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/splashscreen/jquery.splashscreen.js"></script>'."\n", 'js');
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/splashscreen/splashscreen.js"></script>'."\n", 'js');
echo $this->callHook('startPage');
2012-12-14 07:53:13 +00:00
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
2013-08-12 05:03:24 +00:00
$txt = $this->callHook('folderMenu', $folder);
if(is_string($txt))
echo $txt;
else {
$this->pageNavigation($this->getFolderPathHTML($folder), "view_folder", $folder);
}
2012-12-14 07:53:13 +00:00
2019-01-18 12:07:39 +00:00
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
$previewer->setConverters($previewconverters);
2015-07-15 05:26:47 +00:00
2013-05-02 16:26:49 +00:00
echo $this->callHook('preContent');
2017-08-01 07:35:05 +00:00
?>
<div style="display: none;" class="splashscreen" data-top="222" data-height="70" data-left="54" data-width="296" data-img="../views/bootstrap/images/empty.png" data-link="index.php?id=236" data-target="body">
<div style="color: #444;">
<h2>Please support SeedDMS development</h2>
<p style="margin-bottom: 20px;">
Before you continue, think about supporting SeedDMS. Running this demo,
steadily developing the software, and giving support takes time and money. If you feel
like SeedDMS makes your live easier, then please help us to keep up the work.
<p>
<p style="margin-bottom: 20px;">
You may also contact us for a personalized demo, exclusively used by yourself
and setup to fit your needs. Contact us at <a href="mailto:info@seeddms.org">info@seeddms.org</a>.
<p>
<form style="display: inline-block;" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_donations">
<input type="hidden" name="business" value="uwe@steinmann.cx">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Development of SeedDMS">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="bn" value="PP-DonationsBF:btn_donateCC_LG.gif:NonHostedGuest">
<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
</div>
</div>
<?php
2012-12-14 07:53:13 +00:00
echo "<div class=\"row-fluid\">\n";
2013-06-17 13:50:00 +00:00
// dynamic columns - left column removed if no content and right column then fills span12.
if (!($enableFolderTree || $enableClipboard)) {
$LeftColumnSpan = 0;
$RightColumnSpan = 12;
} else {
$LeftColumnSpan = 4;
$RightColumnSpan = 8;
}
2013-06-17 13:50:00 +00:00
if ($LeftColumnSpan > 0) {
echo "<div class=\"span".$LeftColumnSpan."\">\n";
if ($enableFolderTree) {
if ($showtree==1){
$this->contentHeading("<a href=\"../out/out.ViewFolder.php?folderid=". $folderid."&showtree=0\"><i class=\"icon-minus-sign\"></i></a>", true);
$this->contentContainerStart();
/*
* access expandFolderTree with $this->params because it can
* be changed by preContent hook.
*/
$this->printNewTreeNavigationHtml($folderid, M_READ, 0, '', ($this->params['expandFolderTree'] == 1) ? -1 : 3, $orderby);
$this->contentContainerEnd();
} else {
$this->contentHeading("<a href=\"../out/out.ViewFolder.php?folderid=". $folderid."&showtree=1\"><i class=\"icon-plus-sign\"></i></a>", true);
}
}
2013-05-28 04:45:13 +00:00
2014-06-04 19:40:50 +00:00
echo $this->callHook('leftContent');
2013-05-28 04:45:13 +00:00
2015-07-15 05:26:47 +00:00
if ($enableClipboard) $this->printClipboard($this->params['session']->getClipboard(), $previewer);
2014-07-11 06:42:57 +00:00
2014-06-04 19:40:50 +00:00
echo "</div>\n";
}
echo "<div class=\"span".$RightColumnSpan."\">\n";
2012-12-14 07:53:13 +00:00
if ($enableDropUpload && $folder->getAccessMode($user) >= M_READWRITE) {
2014-07-11 06:42:57 +00:00
echo "<div class=\"row-fluid\">";
echo "<div class=\"span8\">";
}
$txt = $this->callHook('folderInfo', $folder);
if(is_string($txt))
echo $txt;
else {
2012-12-14 07:53:13 +00:00
$owner = $folder->getOwner();
$this->contentHeading(getMLText("folder_infos"));
$this->contentContainerStart();
echo "<table class=\"table-condensed\">\n";
if($user->isAdmin()) {
echo "<tr>";
echo "<td>".getMLText("id").":</td>\n";
echo "<td>".htmlspecialchars($folder->getID())."</td>\n";
echo "</tr>";
}
echo "<tr>";
echo "<td>".getMLText("owner").":</td>\n";
echo "<td><a href=\"mailto:".htmlspecialchars($owner->getEmail())."\">".htmlspecialchars($owner->getFullName())."</a></td>\n";
echo "</tr>";
2013-02-06 13:58:36 +00:00
echo "<tr>";
echo "<td>".getMLText("creation_date").":</td>";
echo "<td>".getLongReadableDate($folder->getDate())."</td>";
2013-02-06 13:58:36 +00:00
echo "</tr>";
if($folder->getComment()) {
2013-02-06 13:58:36 +00:00
echo "<tr>";
echo "<td>".getMLText("comment").":</td>\n";
echo "<td>".htmlspecialchars($folder->getComment())."</td>\n";
2013-02-06 13:58:36 +00:00
echo "</tr>";
}
if($user->isAdmin()) {
2013-02-06 13:58:36 +00:00
echo "<tr>";
echo "<td>".getMLText('default_access').":</td>";
echo "<td>".$this->getAccessModeText($folder->getDefaultAccess())."</td>";
2013-02-06 13:58:36 +00:00
echo "</tr>";
if($folder->inheritsAccess()) {
echo "<tr>";
echo "<td>".getMLText("access_mode").":</td>\n";
echo "<td>";
echo getMLText("inherited")."<br />";
$this->printAccessList($folder);
echo "</tr>";
} else {
echo "<tr>";
echo "<td>".getMLText('access_mode').":</td>";
echo "<td>";
$this->printAccessList($folder);
echo "</td>";
echo "</tr>";
}
2012-12-14 07:53:13 +00:00
}
$attributes = $folder->getAttributes();
if($attributes) {
foreach($attributes as $attribute) {
$arr = $this->callHook('showFolderAttribute', $folder, $attribute);
if(is_array($arr)) {
echo $txt;
echo "<tr>";
echo "<td>".$arr[0].":</td>";
echo "<td>".$arr[1].":</td>";
echo "</tr>";
} else {
$attrdef = $attribute->getAttributeDefinition();
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php echo htmlspecialchars(implode(', ', $attribute->getValueAsArray())); ?></td>
</tr>
<?php
}
}
}
echo "</table>\n";
$this->contentContainerEnd();
2012-12-14 07:53:13 +00:00
}
if ($enableDropUpload && $folder->getAccessMode($user) >= M_READWRITE) {
2014-07-11 06:42:57 +00:00
echo "</div>";
echo "<div class=\"span4\">";
$this->contentHeading(getMLText("dropupload"), true);
// $this->addFooterJS("SeedDMSUpload.setUrl('../op/op.Ajax.php');");
// $this->addFooterJS("SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');");
// $this->addFooterJS("SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');");
// $this->addFooterJS("SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");");
// $this->addFooterJS("SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');");
2014-07-11 06:42:57 +00:00
?>
<div id="dragandrophandler" class="well alert" data-target="<?php echo $folder->getID(); ?>" data-formtoken="<?php echo createFormKey('adddocument'); ?>"><?php printMLText('drop_files_here'); ?></div>
<?php
echo "</div>";
echo "</div>";
}
2012-12-14 07:53:13 +00:00
2017-03-15 20:53:42 +00:00
$txt = $this->callHook('listHeader', $folder);
if(is_string($txt))
echo $txt;
else
$this->contentHeading(getMLText("folder_contents"));
2012-12-14 07:53:13 +00:00
$subFolders = $this->callHook('folderGetSubFolders', $folder, $orderby);
if($subFolders === null)
$subFolders = $folder->getSubFolders($orderby);
$subFolders = SeedDMS_Core_DMS::filterAccess($subFolders, $user, M_READ);
$documents = $this->callHook('folderGetDocuments', $folder, $orderby);
if($documents === null)
$documents = $folder->getDocuments($orderby);
$documents = SeedDMS_Core_DMS::filterAccess($documents, $user, M_READ);
2012-12-14 07:53:13 +00:00
$txt = $this->callHook('folderListPreContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
$i = 0;
2012-12-14 07:53:13 +00:00
if ((count($subFolders) > 0)||(count($documents) > 0)){
2013-10-08 19:10:08 +00:00
$txt = $this->callHook('folderListHeader', $folder, $orderby);
if(is_string($txt))
echo $txt;
else {
print "<table id=\"viewfolder-table\" class=\"table table-condensed table-hover\">";
2013-10-08 19:10:08 +00:00
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th><a href=\"../out/out.ViewFolder.php?folderid=". $folderid .($orderby=="n"?"&orderby=s":"&orderby=n")."\">".getMLText("name")."</a></th>\n";
2013-10-08 19:10:08 +00:00
// print "<th>".getMLText("owner")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
// print "<th>".getMLText("version")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
}
2012-12-14 07:53:13 +00:00
foreach($subFolders as $subFolder) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$txt = $this->callHook('folderListItem', $subFolder, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->folderListRow($subFolder);
}
}
$i++;
}
2012-12-14 07:53:13 +00:00
if($subFolders && $documents) {
if(!$maxItemsPerPage || $maxItemsPerPage > count($subFolders)) {
$txt = $this->callHook('folderListSeparator', $folder);
if(is_string($txt))
echo $txt;
}
}
2017-03-14 05:38:40 +00:00
foreach($documents as $document) {
if(!$maxItemsPerPage || $i < $maxItemsPerPage) {
$document->verifyLastestContentExpriry();
$txt = $this->callHook('documentListItem', $document, $previewer, false, 'viewfolder');
if(is_string($txt))
echo $txt;
else {
echo $this->documentListRow($document, $previewer);
}
}
$i++;
2012-12-14 07:53:13 +00:00
}
2013-10-08 19:10:08 +00:00
$txt = $this->callHook('folderListFooter', $folder);
if(is_string($txt))
echo $txt;
else
echo "</tbody>\n</table>\n";
if($maxItemsPerPage && $i > $maxItemsPerPage)
echo "<button id=\"loadmore\" style=\"width: 100%; margin-bottom: 20px;\" class=\"btn btn-default\" data-folder=\"".$folder->getId()."\"data-offset=\"".$maxItemsPerPage."\" data-limit=\"".$incItemsPerPage."\" data-all=\"".($i-$maxItemsPerPage)."\">".getMLText('x_more_objects', array('number'=>($i-$maxItemsPerPage)))."</button>";
2013-10-08 19:10:08 +00:00
}
else printMLText("empty_folder_list");
2012-12-14 07:53:13 +00:00
$txt = $this->callHook('folderListPostContent', $folder, $subFolders, $documents);
if(is_string($txt))
echo $txt;
echo "</div>\n"; // End of right column div
echo "</div>\n"; // End of div around left and right column
2012-12-14 07:53:13 +00:00
2013-05-02 16:26:49 +00:00
echo $this->callHook('postContent');
2012-12-14 07:53:13 +00:00
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}
?>