2012-12-14 07:53:13 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2021-07-08 12:18:49 +00:00
|
|
|
* Implementation of DropFolderChooser view
|
2012-12-14 07:53:13 +00:00
|
|
|
*
|
|
|
|
* @category DMS
|
2013-02-14 11:10:53 +00:00
|
|
|
* @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
|
|
|
|
*/
|
2021-04-15 13:36:32 +00:00
|
|
|
//require_once("class.Bootstrap.php");
|
2012-12-14 07:53:13 +00:00
|
|
|
|
|
|
|
/**
|
2021-07-08 12:18:49 +00:00
|
|
|
* Class which outputs the html page for DropFolderChooser view
|
2012-12-14 07:53:13 +00:00
|
|
|
*
|
|
|
|
* @category DMS
|
2013-02-14 11:10:53 +00:00
|
|
|
* @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@
|
|
|
|
*/
|
2021-04-15 13:36:32 +00:00
|
|
|
class SeedDMS_View_DropFolderChooser extends SeedDMS_Theme_Style {
|
2012-12-14 07:53:13 +00:00
|
|
|
|
2015-12-14 14:16:32 +00:00
|
|
|
function js() { /* {{{ */
|
2021-03-10 14:58:22 +00:00
|
|
|
header('Content-Type: application/javascript; charset=UTF-8');
|
2015-12-14 14:16:32 +00:00
|
|
|
?>
|
2016-03-16 08:29:37 +00:00
|
|
|
$('.fileselect').click(function(ev) {
|
2019-07-30 04:33:18 +00:00
|
|
|
attr_filename = $(ev.currentTarget).data('filename');
|
|
|
|
attr_form = $(ev.currentTarget).data('form');
|
|
|
|
fileSelected(attr_filename, attr_form);
|
2015-12-14 14:16:32 +00:00
|
|
|
});
|
2016-05-24 05:55:04 +00:00
|
|
|
$('.folderselect').click(function(ev) {
|
2019-07-30 04:33:18 +00:00
|
|
|
attr_foldername = $(ev.currentTarget).data('foldername');
|
|
|
|
attr_form = $(ev.currentTarget).data('form');
|
|
|
|
folderSelected(attr_foldername, attr_form);
|
2016-03-08 17:34:34 +00:00
|
|
|
});
|
2015-12-14 14:16:32 +00:00
|
|
|
<?php
|
|
|
|
} /* }}} */
|
|
|
|
|
2023-10-12 14:02:50 +00:00
|
|
|
private function getFiles($path, $recursive=false) {
|
|
|
|
if($recursive)
|
|
|
|
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
|
|
|
else
|
|
|
|
$rii = new DirectoryIterator($path);
|
|
|
|
|
|
|
|
$files = array();
|
2023-10-31 17:49:54 +00:00
|
|
|
foreach ($rii as $file) {
|
2023-10-12 14:02:50 +00:00
|
|
|
if (!$file->isDir())
|
|
|
|
$files[] = [substr($file->getPath(), strlen($path)+1), $file->getFilename()];
|
2023-10-31 17:49:54 +00:00
|
|
|
if(count($files) > 20)
|
|
|
|
return $files;
|
|
|
|
}
|
2023-10-12 14:02:50 +00:00
|
|
|
|
|
|
|
return $files;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function getFolders($path, $recursive=false) {
|
|
|
|
if($recursive)
|
|
|
|
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
|
|
|
|
else
|
|
|
|
$rii = new DirectoryIterator($path);
|
|
|
|
|
|
|
|
$files = array();
|
2023-10-31 17:49:54 +00:00
|
|
|
foreach ($rii as $file) {
|
2023-10-12 14:02:50 +00:00
|
|
|
if ($file->isDir()) {
|
|
|
|
if(($t = substr($file->getPath(), strlen($path)+1)) && ($file->getFilename() == '.'))
|
|
|
|
$files[] = $t;
|
|
|
|
}
|
2023-10-31 17:49:54 +00:00
|
|
|
if(count($files) > 20)
|
|
|
|
return $files;
|
|
|
|
}
|
2023-10-12 14:02:50 +00:00
|
|
|
|
|
|
|
return $files;
|
|
|
|
}
|
|
|
|
|
2017-07-31 18:30:59 +00:00
|
|
|
public function menuList() { /* {{{ */
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
2021-07-06 04:13:57 +00:00
|
|
|
$settings = $this->params['settings'];
|
2017-07-31 18:30:59 +00:00
|
|
|
$dropfolderdir = $this->params['dropfolderdir'];
|
2017-08-01 05:57:16 +00:00
|
|
|
$showfolders = $this->params['showfolders'];
|
2023-10-12 14:02:50 +00:00
|
|
|
$recursive = $this->params['recursive'];
|
2017-07-31 18:30:59 +00:00
|
|
|
$cachedir = $this->params['cachedir'];
|
2023-04-13 10:56:59 +00:00
|
|
|
$conversionmgr = $this->params['conversionmgr'];
|
2017-09-20 07:20:56 +00:00
|
|
|
$previewwidth = $this->params['previewWidthMenuList'];
|
2023-04-13 10:56:59 +00:00
|
|
|
$previewconverters = $this->params['previewConverters'];
|
2017-07-31 18:30:59 +00:00
|
|
|
$timeout = $this->params['timeout'];
|
2019-01-18 12:07:39 +00:00
|
|
|
$xsendfile = $this->params['xsendfile'];
|
2020-11-24 16:13:36 +00:00
|
|
|
$folder = $this->params['folder'];
|
2017-07-31 18:30:59 +00:00
|
|
|
|
2019-01-18 12:07:39 +00:00
|
|
|
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout, $xsendfile);
|
2023-04-13 10:56:59 +00:00
|
|
|
if($conversionmgr)
|
|
|
|
$previewer->setConversionMgr($conversionmgr);
|
|
|
|
else
|
|
|
|
$previewer->setConverters($previewconverters);
|
2017-07-31 18:30:59 +00:00
|
|
|
|
2017-08-01 07:03:58 +00:00
|
|
|
$c = 0; // count files
|
2021-04-18 05:08:00 +00:00
|
|
|
$menuitems['dropfolder'] = array('label'=>'', 'children'=>array());
|
2023-04-13 10:56:59 +00:00
|
|
|
$dir = rtrim($dropfolderdir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$user->getLogin();
|
2023-10-12 14:02:50 +00:00
|
|
|
|
2017-07-31 18:30:59 +00:00
|
|
|
/* Check if we are still looking in the configured directory and
|
|
|
|
* not somewhere else, e.g. if the login was '../test'
|
|
|
|
*/
|
|
|
|
if(dirname($dir) == $dropfolderdir) {
|
|
|
|
if(is_dir($dir)) {
|
2023-10-12 14:02:50 +00:00
|
|
|
$files = $this->getFiles($dir, $recursive);
|
2017-07-31 18:30:59 +00:00
|
|
|
|
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
2023-10-12 14:02:50 +00:00
|
|
|
foreach($files as $file) {
|
|
|
|
$entry = $file[1];
|
|
|
|
$path = $file[0];
|
|
|
|
$c++;
|
|
|
|
$subitem = array('label'=>'', 'attributes'=>array(array('title', getMLText('menu_upload_from_dropfolder'))));
|
|
|
|
if($folder)
|
|
|
|
$subitem['link'] = $settings->_httpRoot.'out/out.AddDocument.php?folderid='.$folder->getId()."&dropfolderfileform1=".urldecode($path.DIRECTORY_SEPARATOR.$entry);
|
|
|
|
$mimetype = finfo_file($finfo, $dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry);
|
|
|
|
if($previewwidth) {
|
|
|
|
$previewer->createRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR, $mimetype);
|
|
|
|
if($previewer->hasRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR)) {
|
|
|
|
$subitem['label'] .= "<div class=\"dropfolder-menu-img\" style=\"display: none; overflow:hidden; position: absolute; left:-".($previewwidth+10)."px; border: 1px solid #888;background: white;\"><img filename=\"".htmlspecialchars($entry)."\" width=\"".$previewwidth."\" src=\"".$settings->_httpRoot."op/op.DropFolderPreview.php?filename=".urlencode($path.DIRECTORY_SEPARATOR.$entry)."&width=".$previewwidth."\" title=\"".htmlspecialchars($mimetype)."\"></div>";
|
2017-07-31 18:30:59 +00:00
|
|
|
}
|
|
|
|
}
|
2023-10-12 14:02:50 +00:00
|
|
|
$subitem['label'] .= "<div class=\"dropfolder-menu-text\" style=\"margin-left:10px; margin-right: 10px; display:inline-block;\">".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."<br /><span style=\"font-size: 85%;\">".SeedDMS_Core_File::format_filesize(filesize($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry)).", ".date('Y-m-d H:i:s', filectime($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."</span></div>";
|
|
|
|
$menuitems['dropfolder']['children'][] = $subitem;
|
2017-07-31 18:30:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-08-01 07:03:58 +00:00
|
|
|
if($c) {
|
2021-04-18 05:08:00 +00:00
|
|
|
$menuitems['dropfolder']['label'] = getMLText('menu_dropfolder')." (".$c.")";
|
|
|
|
self::showNavigationBar($menuitems, array('id'=>'main-menu-dropfolderlist', 'right'=>true));
|
2017-08-01 07:03:58 +00:00
|
|
|
}
|
2017-07-31 18:30:59 +00:00
|
|
|
} /* }}} */
|
|
|
|
|
2012-12-14 07:53:13 +00:00
|
|
|
function show() { /* {{{ */
|
|
|
|
$dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
|
|
|
$dropfolderfile = $this->params['dropfolderfile'];
|
|
|
|
$form = $this->params['form'];
|
|
|
|
$dropfolderdir = $this->params['dropfolderdir'];
|
2015-09-03 13:16:20 +00:00
|
|
|
$cachedir = $this->params['cachedir'];
|
2023-04-21 11:00:05 +00:00
|
|
|
$conversionmgr = $this->params['conversionmgr'];
|
2015-09-03 13:16:20 +00:00
|
|
|
$previewwidth = $this->params['previewWidthList'];
|
2023-04-21 11:00:05 +00:00
|
|
|
$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'];
|
2016-03-08 17:34:34 +00:00
|
|
|
$showfolders = $this->params['showfolders'];
|
2023-10-12 14:02:50 +00:00
|
|
|
$recursive = $this->params['recursive'];
|
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);
|
2023-04-21 11:00:05 +00:00
|
|
|
if($conversionmgr)
|
|
|
|
$previewer->setConversionMgr($conversionmgr);
|
|
|
|
else
|
|
|
|
$previewer->setConverters($previewconverters);
|
2015-09-03 13:16:20 +00:00
|
|
|
|
2012-12-14 07:53:13 +00:00
|
|
|
$dir = $dropfolderdir.'/'.$user->getLogin();
|
2013-02-08 15:03:53 +00:00
|
|
|
/* Check if we are still looking in the configured directory and
|
|
|
|
* not somewhere else, e.g. if the login was '../test'
|
|
|
|
*/
|
|
|
|
if(dirname($dir) == $dropfolderdir) {
|
|
|
|
if(is_dir($dir)) {
|
2015-09-03 13:16:20 +00:00
|
|
|
echo "<table class=\"table table-condensed\">\n";
|
|
|
|
echo "<thead>\n";
|
2024-10-02 12:57:43 +00:00
|
|
|
echo "<tr><th></th><th>".getMLText('name')."</th><th align=\"right\">".getMLText('filesize')."</th><th>".getMLText('date')."</th></tr>\n";
|
2015-09-03 13:16:20 +00:00
|
|
|
echo "</thead>\n";
|
|
|
|
echo "<tbody>\n";
|
|
|
|
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
2023-10-12 14:02:50 +00:00
|
|
|
if($showfolders) {
|
|
|
|
$folders = $this->getFolders($dir, $recursive);
|
|
|
|
foreach($folders as $entry) {
|
|
|
|
echo "<tr>";
|
|
|
|
echo '<td><img draggable="false" src="/views/bootstrap4/images/folder.svg" width="24" height="24" border="0"></td>';
|
|
|
|
echo "<td><span style=\"cursor: pointer;\" class=\"folderselect\" data-foldername=\"".$entry."\" data-form=\"".$form."\">".$entry."</span></td><td align=\"right\"></td><td></td>";
|
|
|
|
echo "</tr>\n";
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$files = $this->getFiles($dir, $recursive);
|
|
|
|
foreach($files as $file) {
|
|
|
|
$entry = $file[1];
|
|
|
|
$path = $file[0];
|
|
|
|
$mimetype = finfo_file($finfo, $dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry);
|
|
|
|
if($previewwidth) {
|
|
|
|
$previewer->createRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR, $mimetype);
|
|
|
|
echo "<tr><td style=\"min-width: ".$previewwidth."px;\">";
|
|
|
|
if($previewer->hasRawPreview($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry, 'dropfolder'.DIRECTORY_SEPARATOR)) {
|
|
|
|
echo "<img style=\"cursor: pointer;\" class=\"fileselect mimeicon\" data-filename=\"".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."\" data-form=\"".$form."\" width=\"".$previewwidth."\" src=\"../op/op.DropFolderPreview.php?filename=".urlencode($path.DIRECTORY_SEPARATOR.$entry)."&width=".$previewwidth."\" title=\"".htmlspecialchars($mimetype)."\">";
|
|
|
|
}
|
|
|
|
echo "</td><td><span style=\"cursor: pointer;\" class=\"fileselect\" data-filename=\"".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."\" data-form=\"".$form."\">".htmlspecialchars($path.DIRECTORY_SEPARATOR.$entry)."</span></td><td align=\"right\">".SeedDMS_Core_File::format_filesize(filesize($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."</td><td>".date('Y-m-d H:i:s', filectime($dir.DIRECTORY_SEPARATOR.$path.DIRECTORY_SEPARATOR.$entry))."</td></tr>\n";
|
2013-02-08 15:03:53 +00:00
|
|
|
}
|
2012-12-14 07:53:13 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-03 13:16:20 +00:00
|
|
|
echo "</tbody>\n";
|
2013-02-08 15:03:53 +00:00
|
|
|
echo "</table>\n";
|
2016-03-08 17:34:34 +00:00
|
|
|
echo '<script src="../out/out.DropFolderChooser.php?action=js&'.$_SERVER['QUERY_STRING'].'"></script>'."\n";
|
2016-11-07 07:54:56 +00:00
|
|
|
} else {
|
2021-07-08 12:18:49 +00:00
|
|
|
echo $this->errorMsg(getMLText('invalid_dropfolder_folder'));
|
2012-12-14 07:53:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} /* }}} */
|
|
|
|
}
|
|
|
|
?>
|