diff --git a/styles/bootstrap/application.js b/styles/bootstrap/application.js index 086d46a6b..d1b5f96df 100644 --- a/styles/bootstrap/application.js +++ b/styles/bootstrap/application.js @@ -545,7 +545,6 @@ function onAddClipboard(ev) { /* {{{ */ } function sendFileToServer(formData,status) { - formData.append('command', 'uploaddocument'); var uploadURL = ajaxurl; //Upload URL var extraData ={}; //Extra Data. var jqXHR=$.ajax({ @@ -641,18 +640,28 @@ function onAddClipboard(ev) { /* {{{ */ } } - SeedDMSUpload.handleFileUpload = function(files,obj) { - var target = obj.data('target'); - if(target) { + SeedDMSUpload.handleFileUpload = function(files,obj,statusbar) { + /* target is set for the quick upload area */ + var target_id = obj.data('target'); + var target_type = 'folder'; + /* droptarget is set for folders and documents in lists */ + var droptarget = obj.data('droptarget'); + if(droptarget) { + target_type = droptarget.split("_")[0]; + target_id = droptarget.split("_")[1]; + } + if(target_type == 'folder' && target_id) { for (var i = 0; i < files.length; i++) { if(files[i].size <= maxFileSize) { var fd = new FormData(); - fd.append('folderid', target); - fd.append('formtoken', obj.data('formtoken')); + fd.append('targettype', target_type); + fd.append('folderid', target_id); + fd.append('formtoken', obj.data('uploadformtoken')); fd.append('userfile', files[i]); + fd.append('command', 'uploaddocument'); // fd.append('path', files[i].webkitRelativePath); - var status = new createStatusbar(obj); + var status = new createStatusbar(statusbar); status.setFileNameSize(files[i].name,files[i].size); sendFileToServer(fd,status); } else { @@ -666,6 +675,32 @@ function onAddClipboard(ev) { /* {{{ */ }); } } + } else if(target_type == 'document' && target_id) { + /* + for (var i = 0; i < files.length; i++) { + if(files[i].size <= maxFileSize) { + var fd = new FormData(); + fd.append('targettype', target_type); + fd.append('documentid', target_id); + fd.append('formtoken', obj.data('uploadformtoken')); + fd.append('userfile', files[i]); + fd.append('command', 'uploaddocument'); + + var status = new createStatusbar(statusbar); + status.setFileNameSize(files[i].name,files[i].size); + sendFileToServer(fd,status); + } else { + noty({ + text: maxFileSizeMsg + '
' + files[i].name + ' (' + files[i].size + ' Bytes)', + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 5000, + }); + } + } + */ } } }( window.SeedDMSUpload = window.SeedDMSUpload || {}, jQuery )); /* }}} */ @@ -690,120 +725,209 @@ $(document).ready(function() { /* {{{ */ var files = e.originalEvent.dataTransfer.files; //We need to send dropped files to Server - SeedDMSUpload.handleFileUpload(files,obj); + SeedDMSUpload.handleFileUpload(files,obj,obj); }); - $(document).on('dragenter', '.table-row-folder', function (e) { + $(document).on('dragenter', '.droptarget', function (e) { e.stopPropagation(); e.preventDefault(); $(e.currentTarget).css('border', '2px dashed #0B85A1'); }); - $(document).on('dragleave', '.table-row-folder', function (e) { + $(document).on('dragleave', '.droptarget', function (e) { e.stopPropagation(); e.preventDefault(); $(e.currentTarget).css('border', '0px solid white'); }); - $(document).on('dragover', '.table-row-folder', function (e) { + $(document).on('dragover', '.droptarget', function (e) { e.stopPropagation(); e.preventDefault(); }); - $(document).on('drop', '.table-row-folder', function (e) { + $(document).on('drop', '.droptarget', function (e) { e.preventDefault(); e.stopPropagation(); $(e.currentTarget).css('border', '0px solid white'); - attr_rel = $(e.currentTarget).attr('rel'); + attr_rel = $(e.currentTarget).data('droptarget'); target_type = attr_rel.split("_")[0]; target_id = attr_rel.split("_")[1]; - console.log(e.originalEvent.dataTransfer.getData("text")); - var source_info = JSON.parse(e.originalEvent.dataTransfer.getData("text")); - source_type = source_info.type; - source_id = source_info.id; - formtoken = source_info.formtoken; -// source_type = e.originalEvent.dataTransfer.getData("type"); -// source_id = e.originalEvent.dataTransfer.getData("id"); -// formtoken = e.originalEvent.dataTransfer.getData("formtoken"); - if(source_type == 'document') { - bootbox.dialog(trans.confirm_move_document, [{ - "label" : " "+trans.move_document, - "class" : "btn-danger", - "callback": function() { - $.get('../op/op.Ajax.php', - { command: 'movedocument', docid: source_id, targetfolderid: target_id, formtoken: formtoken }, - function(data) { - if(data.success) { - $('#table-row-document-'+source_id).hide('slow'); - noty({ - text: data.message, - type: 'success', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 1500, - }); - } else { - noty({ - text: data.message, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 3500, - }); - } - }, - 'json' - ); - } - }, { - "label" : trans.cancel, - "class" : "btn-cancel", - "callback": function() { - } - }]); + if(target_type == 'folder') { + var files = e.originalEvent.dataTransfer.files; + if(files.length > 0) { + console.log('Drop '+files.length+' files on '+target_type+' '+target_id); + SeedDMSUpload.handleFileUpload(files,$(e.currentTarget),$(e.currentTarget).find("span")); + } else { + var source_info = JSON.parse(e.originalEvent.dataTransfer.getData("text")); + source_type = source_info.type; + source_id = source_info.id; + formtoken = source_info.formtoken; + console.log('Drop '+source_type+' '+source_id+' on '+target_type+' '+target_id); + if(source_type == 'document') { + bootbox.dialog(trans.confirm_move_document, [{ + "label" : " "+trans.move_document, + "class" : "btn-danger", + "callback": function() { + $.get('../op/op.Ajax.php', + { command: 'movedocument', docid: source_id, targetfolderid: target_id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-document-'+source_id).hide('slow'); + noty({ + text: data.message, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + "label" : trans.cancel, + "class" : "btn-cancel", + "callback": function() { + } + }]); - url = "../out/out.MoveDocument.php?documentid="+source_id+"&targetid="+target_id; -// document.location = url; - } else if(source_type == 'folder' && source_id != target_id) { - bootbox.dialog(trans.confirm_move_folder, [{ - "label" : " "+trans.move_folder, - "class" : "btn-danger", - "callback": function() { - $.get('../op/op.Ajax.php', - { command: 'movefolder', folderid: source_id, targetfolderid: target_id, formtoken: formtoken }, - function(data) { - if(data.success) { - $('#table-row-folder-'+source_id).hide('slow'); - noty({ - text: data.message, - type: 'success', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 1500, - }); - } else { - noty({ - text: data.message, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 3500, - }); - } - }, - 'json' - ); - } - }, { - "label" : trans.cancel, - "class" : "btn-cancel", - "callback": function() { - } - }]); + url = "../out/out.MoveDocument.php?documentid="+source_id+"&targetid="+target_id; + // document.location = url; + } else if(source_type == 'folder' && source_id != target_id) { + bootbox.dialog(trans.confirm_move_folder, [{ + "label" : " "+trans.move_folder, + "class" : "btn-danger", + "callback": function() { + $.get('../op/op.Ajax.php', + { command: 'movefolder', folderid: source_id, targetfolderid: target_id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-folder-'+source_id).hide('slow'); + noty({ + text: data.message, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + "label" : trans.cancel, + "class" : "btn-cancel", + "callback": function() { + } + }]); - url = "../out/out.MoveFolder.php?folderid="+source_id+"&targetid="+target_id; -// document.location = url; + url = "../out/out.MoveFolder.php?folderid="+source_id+"&targetid="+target_id; + // document.location = url; + } + } + } else if(target_type == 'document') { + var files = e.originalEvent.dataTransfer.files; + if(files.length > 0) { + console.log('Drop '+files.length+' files on '+target_type+' '+target_id); + SeedDMSUpload.handleFileUpload(files,$(e.currentTarget),$(e.currentTarget).find("span")); + } else { + var source_info = JSON.parse(e.originalEvent.dataTransfer.getData("text")); + source_type = source_info.type; + source_id = source_info.id; + formtoken = source_info.formtoken; + console.log('Drop '+source_type+' '+source_id+' on '+target_type+' '+target_id); + if(source_type == 'document') { + bootbox.dialog(trans.confirm_transfer_link_document, [{ + "label" : " "+trans.transfer_content, + "class" : "btn-danger", + "callback": function() { + $.get('../op/op.Ajax.php', + { command: 'transfercontent', docid: source_id, targetdocumentid: target_id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-document-'+source_id).hide('slow'); + noty({ + text: data.message, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + "label" : trans.link_document, + "class" : "btn-danger", + "callback": function() { + $.get('../op/op.Ajax.php', + { command: 'linkdocument', docid: source_id, targetdocumentid: target_id, formtoken: formtoken }, + function(data) { + if(data.success) { + noty({ + text: data.message, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + "label" : trans.cancel, + "class" : "btn-cancel", + "callback": function() { + } + }]); + + url = "../out/out.MoveDocument.php?documentid="+source_id+"&targetid="+target_id; + // document.location = url; + } + } } }); $(document).on('dragstart', '.table-row-folder', function (e) { @@ -816,9 +940,6 @@ $(document).ready(function() { /* {{{ */ formtoken : $(e.target).attr('formtoken') }; e.originalEvent.dataTransfer.setData("text", JSON.stringify(dragStartInfo)); -// e.originalEvent.dataTransfer.setData("id", attr_rel.split("_")[1]); -// e.originalEvent.dataTransfer.setData("type","folder"); -// e.originalEvent.dataTransfer.setData("formtoken", $(e.target).attr('formtoken')); }); $(document).on('dragstart', '.table-row-document', function (e) { @@ -831,9 +952,6 @@ $(document).ready(function() { /* {{{ */ formtoken : $(e.target).attr('formtoken') }; e.originalEvent.dataTransfer.setData("text", JSON.stringify(dragStartInfo)); -// e.originalEvent.dataTransfer.setData("id", attr_rel.split("_")[1]); -// e.originalEvent.dataTransfer.setData("type","document"); -// e.originalEvent.dataTransfer.setData("formtoken", $(e.target).attr('formtoken')); }); /* Dropping item on alert below clipboard */ diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 1644d6de3..792e8960d 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -398,7 +398,7 @@ background-image: linear-gradient(to bottom, #882222, #111111);; for ($i = 0; $i < count($path); $i++) { $txtpath .= "
  • "; if ($i +1 < count($path)) { - $txtpath .= "getID()."&showtree=".showtree()."\" rel=\"folder_".$path[$i]->getID()."\" class=\"table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">". + $txtpath .= "getID()."&showtree=".showtree()."\" data-droptarget=\"folder_".$path[$i]->getID()."\" rel=\"folder_".$path[$i]->getID()."\" class=\"table-row-folder droptarget\" formtoken=\"".createFormKey('movefolder')."\">". htmlspecialchars($path[$i]->getName()).""; } else { @@ -1589,7 +1589,7 @@ $(document).ready(function() { if($path || $expandtree>=$level) { if($path) $pathfolder = array_shift($path); - $subfolders = $folder->getSubFolders($orderby[0], $orderdir); + $subfolders = $folder->getSubFolders(isset($orderby[0]) ? $orderby[0] : '', $orderdir); $subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $user, $accessmode); $children = array(); foreach($subfolders as $subfolder) { @@ -1597,7 +1597,7 @@ $(document).ready(function() { if($expandtree>=$level || $pathfolder->getID() == $subfolder->getID()) { $node['children'] = jqtree($path, $subfolder, $user, $accessmode, $showdocs, $expandtree, $orderby, $level+1); if($showdocs) { - $documents = $subfolder->getDocuments($orderby[0], $orderdir); + $documents = $subfolder->getDocuments(isset($orderby[0]) ? $orderby[0] : '', $orderdir); $documents = SeedDMS_Core_DMS::filterAccess($documents, $user, $accessmode); foreach($documents as $document) { $node2 = array('label'=>$document->getName(), 'id'=>$document->getID(), 'load_on_demand'=>false, 'is_folder'=>false); @@ -1609,7 +1609,7 @@ $(document).ready(function() { } return $children; } else { - $subfolders = $folder->getSubFolders($orderby[0], $orderdir); + $subfolders = $folder->getSubFolders(isset($orderby[0]) ? $orderby[0] : '', $orderdir); $subfolders = SeedDMS_Core_DMS::filterAccess($subfolders, $user, $accessmode); $children = array(); foreach($subfolders as $subfolder) { @@ -1634,7 +1634,7 @@ $(document).ready(function() { } else { $node['children'] = jqtree($path, $folder, $this->params['user'], $accessmode, $showdocs, $expandtree, $orderby, 0); if($showdocs) { - $documents = $folder->getDocuments($orderby[0], $orderdir); + $documents = $folder->getDocuments(isset($orderby[0]) ? $orderby[0] : '', $orderdir); $documents = SeedDMS_Core_DMS::filterAccess($documents, $this->params['user'], $accessmode); foreach($documents as $document) { $node2 = array('label'=>$document->getName(), 'id'=>$document->getID(), 'load_on_demand'=>false, 'is_folder'=>false); @@ -1675,7 +1675,7 @@ $(function() { onCreateLi: function(node, $li) { // Add 'icon' span before title if(node.is_folder) - $li.find('.jqtree-title').before(' ').attr('rel', 'folder_' + node.id).attr('formtoken', ''); + $li.find('.jqtree-title').before(' ').attr('rel', 'folder_' + node.id).attr('formtoken', '').attr('data-uploadformtoken', ''); else $li.find('.jqtree-title').before(' '); } @@ -2174,6 +2174,15 @@ $(document).ready( function() { "; } /* }}} */ + function documentListRowStart($document) { /* {{{ */ + $docID = $document->getID(); + return ""; + } /* }}} */ + + function documentListRowEnd($document) { /* {{{ */ + return "\n"; + } /* }}} */ + /** * Return HTML of a single row in the document list table * @@ -2197,7 +2206,7 @@ $(document).ready( function() { $docID = $document->getID(); if(!$skipcont) - $content .= ""; + $content .= $this->documentListRowStart($document); if($version) { $latestContent = $this->callHook('documentContent', $document, $version); @@ -2303,10 +2312,18 @@ $(document).ready( function() { $content .= ""; } if(!$skipcont) - $content .= "\n"; + $content .= $this->documentListRowEnd($document); return $content; } /* }}} */ + function folderListRowStart($folder) { /* {{{ */ + return "getID()."\" draggable=\"true\" data-droptarget=\"folder_".$folder->getID()."\" rel=\"folder_".$folder->getID()."\" class=\"folder table-row-folder droptarget\" data-uploadformtoken=\"".createFormKey('adddocument')."\" formtoken=\"".createFormKey('movefolder')."\">"; + } /* }}} */ + + function folderListRowEnd($folder) { /* {{{ */ + return "\n"; + } /* }}} */ + function folderListRow($subFolder, $extracontent=array()) { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -2321,9 +2338,9 @@ $(document).ready( function() { if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; $content = ''; - $content .= "getID()."\" draggable=\"true\" rel=\"folder_".$subFolder->getID()."\" class=\"folder table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">"; - $content .= "getID()."\" draggable=\"false\" href=\"../out/out.ViewFolder.php?folderid=".$subFolder->getID()."&showtree=".$showtree."\">getMimeIcon(".folder")."\" width=\"24\" height=\"24\" border=0>\n"; - $content .= "getID()."\" href=\"../out/out.ViewFolder.php?folderid=".$subFolder->getID()."&showtree=".$showtree."\">" . htmlspecialchars($subFolder->getName()) . ""; + $content .= $this->folderListRowStart($subFolder); + $content .= "getID()."&showtree=".$showtree."\">getMimeIcon(".folder")."\" width=\"24\" height=\"24\" border=0>\n"; + $content .= "getID()."&showtree=".$showtree."\">" . htmlspecialchars($subFolder->getName()) . ""; $content .= "
    ".getMLText('owner').": ".htmlspecialchars($owner->getFullName()).", ".getMLText('creation_date').": ".date('Y-m-d', $subFolder->getDate()).""; if($comment) { $content .= "
    ".htmlspecialchars($comment).""; @@ -2378,7 +2395,7 @@ $(document).ready( function() { } $content .= ""; $content .= ""; - $content .= "\n"; + $content .= $this->folderListRowEnd($subFolder); return $content; } /* }}} */ diff --git a/views/bootstrap/class.Clipboard.php b/views/bootstrap/class.Clipboard.php index 34f2f4451..13dafe1fa 100644 --- a/views/bootstrap/class.Clipboard.php +++ b/views/bootstrap/class.Clipboard.php @@ -103,7 +103,8 @@ class SeedDMS_View_Clipboard extends SeedDMS_Bootstrap_Style { $content = ''; $comment = $folder->getComment(); if (strlen($comment) > 150) $comment = substr($comment, 0, 147) . "..."; - $content .= "getID()."\" class=\"folder table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">"; +// $content .= "getID()."\" class=\"folder table-row-folder\" formtoken=\"".createFormKey('movefolder')."\">"; + $content .= $this->folderListRowStart($folder); $content .= "getID()."&showtree=".showtree()."\">getMimeIcon(".folder")."\" width=\"24\" height=\"24\" border=0>\n"; $content .= "getID()."&showtree=".showtree()."\">" . htmlspecialchars($folder->getName()) . ""; if($comment) { @@ -138,7 +139,7 @@ class SeedDMS_View_Clipboard extends SeedDMS_Bootstrap_Style { $version = $latestContent->getVersion(); $status = $latestContent->getStatus(); - $content .= "getID()."\" class=\"table-row-document\" formtoken=\"".createFormKey('movedocument')."\">"; + $content .= $this->documentListRowStart($document); if (file_exists($dms->contentDir . $latestContent->getPath())) { $content .= "getID()."&version=".$version."\">"; diff --git a/views/bootstrap/class.Search.php b/views/bootstrap/class.Search.php index d5b36979f..73415eaea 100644 --- a/views/bootstrap/class.Search.php +++ b/views/bootstrap/class.Search.php @@ -55,7 +55,7 @@ class SeedDMS_View_Search extends SeedDMS_Bootstrap_Style { function js() { /* {{{ */ 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')); + parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder')); $this->printFolderChooserJs("form1"); $this->printDeleteFolderButtonJs(); diff --git a/views/bootstrap/class.ViewFolder.php b/views/bootstrap/class.ViewFolder.php index 8962abeeb..cb9b409f3 100644 --- a/views/bootstrap/class.ViewFolder.php +++ b/views/bootstrap/class.ViewFolder.php @@ -94,7 +94,7 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { $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')); + parent::jsTranslations(array('cancel', 'splash_move_document', 'confirm_move_document', 'move_document', 'confirm_transfer_link_document', 'transfer_content', 'link_document', 'splash_move_folder', 'confirm_move_folder', 'move_folder')); ?> function folderSelected(id, name) { window.location = '../out/out.ViewFolder.php?folderid=' + id; @@ -390,7 +390,7 @@ $('#loadmore').click(function(e) { // $this->addFooterJS("SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");"); // $this->addFooterJS("SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');"); ?> -
    +
    "; echo "";