This commit is contained in:
chaideqing
2023-11-02 01:26:33 +00:00
parent 4bda372889
commit d07bb804cb
18 changed files with 711 additions and 18 deletions
+159
View File
@@ -359,6 +359,164 @@ class doc extends control
}
}
/**
* Upload docs.
*
* @param string $objectType product|project|execution|custom
* @param int $objectID
* @param int|string $libID
* @param int $moduleID
* @param string $docType html|word|ppt|excel|attachment
* @param string $from
* @access public
* @return void
*/
public function uploadDocs($objectType, $objectID, $libID, $moduleID = 0, $docType = '', $from = 'doc')
{
$linkType = $objectType;
if($objectType == 'execution' and $this->app->tab != 'execution') $linkType = 'project';
if(!empty($_POST))
{
$doclib = $this->loadModel('doc')->getLibById($libID);
$canVisit = true;
if(!empty($doclib->groups)) $groupAccounts = $this->loadModel('group')->getGroupAccounts(explode(',', $doclib->groups));
switch($objectType)
{
case 'custom':
$account = (string)$this->app->user->account;
if(($doclib->acl == 'custom' or $doclib->acl == 'private') and strpos($doclib->users, $account) === false and $doclib->addedBy !== $account and !(isset($groupAccounts) and in_array($account, $groupAccounts, true))) $canVisit = false;
break;
case 'product':
$canVisit = $this->loadModel('product')->checkPriv($doclib->product);
break;
case 'project':
$canVisit = $this->loadModel('project')->checkPriv($doclib->project);
break;
case 'execution':
$canVisit = $this->loadModel('execution')->checkPriv($doclib->execution);
break;
default:
break;
}
if(!$canVisit) return $this->send(array('result' => 'fail', 'message' => $this->lang->doc->accessDenied));
$libID = $this->post->lib;
$moduleID = $this->post->module;
if(empty($libID) and strpos($this->post->module, '_') !== false) list($libID, $moduleID) = explode('_', $this->post->module);
setcookie('lastDocModule', $moduleID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, false);
if($this->post->uploadFormat == 'combinedDocs')
{
unset($_POST['uploadFormat']);
$docResult = $this->doc->create();
if(!$docResult or dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$docID = $docResult['id'];
$files = zget($docResult, 'files', '');
$fileAction = '';
if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n";
$actionType = 'created';
$this->action->create('doc', $docID, $actionType, $fileAction);
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $docID));
$params = "docID=" . $docResult['id'];
$link = isonlybody() ? 'parent' : $this->createLink('doc', 'view', $params);
}
else
{
$docResult = $this->doc->createSeperateDocs();
if(!$docResult or dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$docsAction = zget($docResult, 'docsAction', '');
if(!empty($docsAction))
{
foreach($docsAction as $docID => $fileTitle)
{
$fileAction = $this->lang->addFiles . $fileTitle->title . "\n";
$actionType = 'created';
$this->action->create('doc', $docID, $actionType, $fileAction);
}
}
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
$link = 'parent';
}
$response = array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $link);
return $this->send($response);
}
unset($_GET['onlybody']);
$this->config->showMainMenu = (strpos($this->config->doc->textTypes, $docType) === false or $from == 'template');
$lib = $libID ? $this->doc->getLibByID($libID) : '';
if(empty($objectID) and $lib) $objectID = zget($lib, $lib->type, 0);
/* Get libs and the default lib id. */
$gobackLink = ($objectID == 0 and $libID == 0) ? $this->createLink('doc', 'tableContents', "type=$linkType") : '';
$unclosed = strpos($this->config->doc->custom->showLibs, 'unclosed') !== false ? 'unclosedProject' : '';
$libs = $this->doc->getLibs($objectType, $extra = "withObject,$unclosed", $libID, $objectID);
if(!$libID and !empty($libs)) $libID = key($libs);
if(empty($lib) and $libID) $lib = $this->doc->getLibByID($libID);
$objects = array();
if($linkType == 'project')
{
$excludedModel = $this->config->vision == 'lite' ? '' : 'kanban';
$objects = $this->project->getPairsByProgram('', 'all', false, 'order_asc', $excludedModel);
$this->view->executions = array();
if($lib->type == 'execution')
{
$execution = $this->loadModel('execution')->getById($lib->execution);
$objectID = $execution->project;
$libs = $this->doc->getLibs('execution', $extra = "withObject,$unclosed", $libID, $lib->execution);
$this->view->execution = $execution;
$this->view->executions = array(0 => '') + $this->execution->getPairs($objectID, 'sprint,stage', 'multiple,leaf,noprefix');
}
}
elseif($linkType == 'execution')
{
$execution = $this->loadModel('execution')->getById($objectID);
$objects = $this->execution->getPairs($execution->project, 'sprint,stage', "multiple,leaf,noprefix");
}
elseif($linkType == 'product')
{
$objects = $this->loadModel('product')->getPairs();
}
elseif($linkType == 'mine')
{
$this->lang->doc->aclList = $this->lang->doclib->mySpaceAclList;
}
$moduleOptionMenu = $this->doc->getLibsOptionMenu($libs);
$moduleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastDocModule;
$moduleID = $libID . '_' . $moduleID;
$this->view->title = empty($lib) ? '' : zget($lib, 'name', '', $lib->name . $this->lang->colon) . $this->lang->doc->create;
$this->view->linkType = $linkType;
$this->view->objectType = $objectType;
$this->view->objectID = empty($lib) ? 0 : zget($lib, $lib->type, 0);
$this->view->libID = $libID;
$this->view->lib = $lib;
$this->view->libs = $libs;
$this->view->objects = $objects;
$this->view->gobackLink = $gobackLink;
$this->view->libName = zget($lib, 'name', '');
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->view->moduleID = $moduleID;
$this->view->docType = $docType;
$this->view->groups = $this->loadModel('group')->getPairs();
$this->view->users = $this->user->getPairs('nocode|noclosed|nodeleted');
$this->view->from = $from;
$this->display();
}
/**
* Create a doc.
*
@@ -1255,6 +1413,7 @@ class doc extends control
$this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('doc', $docID);
$this->view->moduleID = $doc->module;
$this->view->objectDropdown = $objectDropdown;
$this->view->canUploadDoc = common::hasPriv('doc', 'create');
$this->view->canExport = ($this->config->edition != 'open' && common::hasPriv('doc', $type . '2export'));
$this->view->exportMethod = $type . '2export';
$this->view->editors = $this->doc->getEditors($docID);
+1 -1
View File
@@ -39,4 +39,4 @@ body {overflow: hidden;}
#mainContent .main-header h2 {width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
.fullscreen-save, .markdown-fullscreen-save {position: fixed; top: 10px; right: 30px; z-index: 999999;}
.modal-header .fullscreen-save, .markdown-fullscreen-save {top: 5px; right: 60px;}
#dataform .table tr:last-child {position: fixed; top: 47px;}
#headerBox .table tr:last-child {position: fixed; top: 47px;}
+41
View File
@@ -0,0 +1,41 @@
body {overflow: hidden;}
.doc-title input {border: unset; font-size: 18px; font-weight: bold; color: #3c4353; padding-left: 16px;}
.doc-title .form-control:focus {border: unset; box-shadow: unset;}
.doc-title input::-webkit-input-placeholder {color: #D8DBDE;}
.doc-title.required:after {top: 4px; right: 0; left: 12px; display: inline-table;}
#headerBox {border-bottom: 1px solid #e3e3e3;}
#headerBox td:last-child {padding-right: 24px;}
.contentmarkdown.required:after, .contenthtml.required:after {right:3px;}
#editorContent {padding: 0;}
#contentBox {padding: 0; width: 100%;}
#contentBox .ke-container {overflow: visible;}
#contentBox .ke-container, #contentBox .contenthtml {border: unset; background: #efefef;}
#contentBox .ke-container.focus {box-shadow: unset; border-color: unset;}
#contentBox .ke-toolbar {padding-left: 20px; width: 100%; height: 30px;}
#contentBox .ke-edit {border-top: 1px solid rgb(220, 220, 220)}
#contentBox .ke-edit, #contentBox .CodeMirror {margin: 8px 200px 0 200px; background: #fff;}
#contentBox .kindeditor-ph {padding: 20px 20px 0 20px !important;}
#contentBox .editor-toolbar {background: #fff; padding-left: 20px; border-right: unset; border-top: unset; height: 30px;}
#contentBox .CodeMirror {padding: 20px 20px 0 20px;}
#contentBox .CodeMirror.CodeMirror-wrap {border-left: 0; border-right: 0; border-bottom: 0;}
#contentBox .ke-statusbar {display: none;}
#contentBox .contentmarkdown {background: #efefef;}
.article-content {padding: 8px 20px;}
#noticeAcl {margin-left: 10px; vertical-align: middle;}
#basicInfoLink {border: unset;}
#modalBasicInfo .modal-dialog {width:800px;}
#modalBasicInfo .modal-content {padding:0px;}
#modalBasicInfo .modal-body {padding:10px 30px 10px 10px; overflow-x: hidden !important;}
#modalBasicInfo .modal-body .close {position:fixed; right:15px; top:15px}
#basicInfoBox{margin-bottom: 10px;}
#basicInfoBox tfoot td {padding-bottom: 0;}
.aclBox .radio-inline{display:block; padding-bottom:5px;}
.aclBox .radio-inline+.radio-inline {margin-left: 0px !important;}
.fullscreen-save, .markdown-fullscreen-save {position: fixed; top: 10px; right: 30px; z-index: 999999;}
#file-upload .file-input-list {max-height: 230px; overflow: auto}
+222
View File
@@ -0,0 +1,222 @@
$(function()
{
/* Set editor content height. */
var contentHeight = $(document).height() - 92;
setTimeout(function(){$('.ke-edit-iframe, .ke-edit, .ke-edit-textarea').height(contentHeight);}, 100);
setTimeout(function(){$('.CodeMirror').height($(document).height() - 112);}, 100);
$('iframe.ke-edit-iframe').contents().find('.article-content').css('padding', '20px 20px 0 20px');
if(objectType == 'project') loadExecutions($('#project').val());
/* Change for show create error. */
$('#contentBox #content').attr('id', 'contentHTML');
/* Copy doc title to modal title. */
$('#modalBasicInfo').on('show.zui.modal', function()
{
$('#modalBasicInfo #copyTitle').html($('.doc-title #editorTitle').val().replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;"));
});
$('#saveDraft').click(function(event)
{
if($.trim($('#editorTitle').val()) == '')
{
bootbox.alert(titleNotEmpty);
return false;
}
$('#status').val('draft');
event.preventDefault();
submit(this);
});
$('#releaseBtn').click(function(event)
{
event.preventDefault();
submit(this);
});
$('#basicInfoLink').click(function()
{
if($('#editorTitle').val() == '')
{
bootbox.alert(titleNotEmpty);
return false;
}
if(requiredFields.indexOf('content') >= 0)
{
var contentType = $('#contentType').val();
var content = '';
if(contentType == 'html') content = $('#contentHTML').val();
if(contentType == 'markdown')content = $('#contentMarkdown').val();
if(content == '')
{
bootbox.alert(contentNotEmpty);
return false;
}
}
$('#status').val('normal');
});
setTimeout(function(){initPage(docType)}, 50);
if(typeof(window.editor) != 'undefined')
{
$('.ke-toolbar .ke-outline:last').after("<span data-name='unlink' class='ke-outline' title='Markdown' onclick='toggleEditor(\"markdown\")' style='font-size: unset; line-height: unset;'>Markdown</span>");
}
$(document).on("mouseup", 'span[data-name="fullscreen"]', function()
{
if($(this).hasClass('ke-selected'))
{
$('#submit').removeClass('fullscreen-save')
$('.form-actions #submit').addClass('btn-wide')
}
else
{
$('#submit').addClass('fullscreen-save')
$('.form-actions #submit').removeClass('btn-wide')
}
});
$(document).on("mouseup", 'a[title="Fullscreen"],.icon-columns', function()
{
setTimeout(function()
{
if($('a[title="Fullscreen"]').hasClass('active'))
{
$('#submit').addClass('markdown-fullscreen-save')
$('#submit').removeClass('btn-wide')
$('.fullscreen').css('height', '50px');
$('.fullscreen').css('padding-top', '15px');
$('.CodeMirror-fullscreen').css('top', '50px');
$('.editor-preview-side').css('top', '50px');
}
else
{
$('#submit').removeClass('markdown-fullscreen-save')
$('#submit').addClass('btn-wide')
$('.editor-toolbar').css('height', '30px');
$('.editor-toolbar').css('padding-top', '1px');
$('.CodeMirror').css('top', '0');
$('.editor-preview-side').css('top', '30px');
}
}, 200);
});
if($(".createCustomLib").length == 1) $(".createCustomLib").click(); // Fix bug #15139.
addFileUploadMutationObserver();
})
function toggleEditor(type)
{
if(type == 'html')
{
$('.contenthtml').removeClass('hidden');
$('.contentmarkdown').addClass('hidden');
}
else if(type == 'markdown')
{
$('.contenthtml').addClass('hidden');
$('.contentmarkdown').removeClass('hidden');
}
$('#contentType').val(type);
return false;
}
function initPage(type)
{
if(type == 'html' || type == 'markdown')
{
if(type == 'markdown')
{
$('#contentBox .contentmarkdown').removeClass('hidden');
$('#contentBox .contenthtml').addClass('hidden');
$('#contentType').val(type);
}
}
else if(type == 'url')
{
$('#contentBox').addClass('hidden');
$('#urlBox').removeClass('hidden');
}
if(type == 'word' || type == 'ppt' || type == 'excel')
{
$('#contentBox').hide();
$('#urlBox').hide();
}
}
/**
* Load whitelist by libID.
*
* @param int $libID
* @access public
* @return void
*/
function loadWhitelist(libID)
{
var groupLink = createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=group');
var userLink = createLink('doc', 'ajaxGetWhitelist', 'libID=' + libID + '&acl=&control=user');
$.post(groupLink, function(groups)
{
if(groups != 'private')
{
$('#groups').replaceWith(groups);
$('#groups').next('.picker').remove();
$('#groups').picker();
}
});
$.post(userLink, function(users)
{
if(users != 'private')
{
$('#users').replaceWith(users);
$('#users').next('.picker').remove();
$('#users').picker();
}
});
}
/**
* Redirect to edit page when create the doc of text type.
*
* @param int docID
* @param string objectType
* @param int objectID
* @param int libID
* @return void
*/
function redirect2Edit(docID, objectType, objectID, libID)
{
parent.location.href = createLink('doc', 'edit', 'docID=' + docID + '&comment=false&objectType=' + objectType + '&objectID=' + objectID + '&libID=' + libID + '&from=create');
}
function toggleDocTitle(uplloadFormat)
{
if(uplloadFormat == 'combinedDocs')
{
$('#docTitle').show();
}
else
{
$('#docTitle').hide();
}
}
function addFileUploadMutationObserver()
{
var fileUpload = document.querySelector('#file-upload .file-input-list');
observer = new MutationObserver(function(mutationsList, observer)
{
var title = $('#file-upload .file-input-list .file-input:nth-child(1) span').text();
var dotIdx = title.lastIndexOf('.');
if(dotIdx != '-1') title = title.substring(0, dotIdx);
$('#title').val(title);
});
observer.observe(fileUpload, {childList: true, subtree: true});
}
function titleChanged()
{
if(observer) observer.disconnect();
}
+5
View File
@@ -214,10 +214,15 @@ $lang->doc->docSummary = 'Total: <strong>%s</strong>.';
$lang->doc->docCheckedSummary = 'Seleted: <strong>%total%</strong>.';
$lang->doc->showDoc = 'Whether to display documents';
$lang->doc->uploadDoc = 'Upload Document';
$lang->doc->uploadFormat = 'Upload Format';
$lang->doc->fileType = new stdclass();
$lang->doc->fileType->stepResult = 'Case Result';
$lang->doc->uploadFormatList = array();
$lang->doc->uploadFormatList['separateDocs'] = 'Save files as different document';
$lang->doc->uploadFormatList['combinedDocs'] = 'Save files as one document';
global $config;
/* Query condition list. */
$lang->doc->allProduct = 'Alle' . $lang->productCommon;
+5
View File
@@ -214,10 +214,15 @@ $lang->doc->docSummary = 'Total: <strong>%s</strong>.';
$lang->doc->docCheckedSummary = 'Seleted: <strong>%total%</strong>.';
$lang->doc->showDoc = 'Whether to display documents';
$lang->doc->uploadDoc = 'Upload Document';
$lang->doc->uploadFormat = 'Upload Format';
$lang->doc->fileType = new stdclass();
$lang->doc->fileType->stepResult = 'Case Result';
$lang->doc->uploadFormatList = array();
$lang->doc->uploadFormatList['separateDocs'] = 'Save files as different document';
$lang->doc->uploadFormatList['combinedDocs'] = 'Save files as one document';
global $config;
/* Query condition list. */
$lang->doc->allProduct = 'All' . $lang->productCommon . 's';
+5
View File
@@ -214,10 +214,15 @@ $lang->doc->docSummary = 'Total: <strong>%s</strong>.';
$lang->doc->docCheckedSummary = 'Seleted: <strong>%total%</strong>.';
$lang->doc->showDoc = 'Whether to display documents';
$lang->doc->uploadDoc = 'Upload Document';
$lang->doc->uploadFormat = 'Upload Format';
$lang->doc->fileType = new stdclass();
$lang->doc->fileType->stepResult = 'Case Result';
$lang->doc->uploadFormatList = array();
$lang->doc->uploadFormatList['separateDocs'] = 'Save files as different document';
$lang->doc->uploadFormatList['combinedDocs'] = 'Save files as one document';
global $config;
/* Query condition list. */
$lang->doc->allProduct = 'Tous les' . $lang->productCommon . 's';
+5
View File
@@ -214,10 +214,15 @@ $lang->doc->docSummary = '本页共 <strong>%s</strong> 个文档。';
$lang->doc->docCheckedSummary = '共选中 <strong>%total%</strong> 个文档。';
$lang->doc->showDoc = '是否显示文档';
$lang->doc->uploadDoc = '上传文档';
$lang->doc->uploadFormat = '上传格式';
$lang->doc->fileType = new stdclass();
$lang->doc->fileType->stepResult = '测试结果';
$lang->doc->uploadFormatList = array();
$lang->doc->uploadFormatList['separateDocs'] = '每个文件存为不同文档';
$lang->doc->uploadFormatList['combinedDocs'] = '所有文件存为一个文档';
global $config;
/* 查询条件列表 */
$lang->doc->allProduct = '所有' . $lang->productCommon;
+92
View File
@@ -866,6 +866,98 @@ class docModel extends model
}
/**
* Create a seperate docs.
*
* @access public
* @return void
*/
public function createSeperateDocs()
{
if(!isset($_POST['lib']) and strpos($_POST['module'], '_') !== false) list($_POST['lib'], $_POST['module']) = explode('_', $_POST['module']);
$now = helper::now();
$doc = fixer::input('post')
->setDefault('content,template,templateType,chapterType', '')
->add('addedBy', $this->app->user->account)
->add('addedDate', $now)
->add('editedBy', $this->app->user->account)
->add('editedDate', $now)
->add('version', 1)
->setDefault('product,execution,module', 0)
->stripTags($this->config->doc->editor->create['id'], $this->config->allowedTags)
->cleanInt('product,execution,module,lib')
->join('groups', ',')
->join('users', ',')
->join('mailto', ',')
->remove('files,labels,uid,contactListMenu,uploadFormat')
->get();
if($doc->acl == 'open') $doc->users = $doc->groups = '';
if(empty($doc->lib) and strpos($doc->module, '_') !== false) list($doc->lib, $doc->module) = explode('_', $doc->module);
if(empty($doc->lib)) return dao::$errors['lib'] = sprintf($this->lang->error->notempty, $this->lang->doc->lib);
$files = $this->loadModel('file')->getUpload();
if(empty($files)) return dao::$errors['files'] = sprintf($this->lang->error->notempty, $this->lang->doc->files);
/* Fix bug #2929. strip_tags($this->post->contentMarkdown, $this->config->allowedTags)*/
$lib = $this->getLibByID($doc->lib);
$doc = $this->loadModel('file')->processImgURL($doc, $this->config->doc->editor->create['id'], $this->post->uid);
$doc->product = $lib->product;
$doc->project = $lib->project;
$doc->execution = $lib->execution;
$docContent = new stdclass();
$docContent->title = $doc->title;
$docContent->content = '';
$docContent->type = $doc->contentType;
$docContent->digest = '';
$docContent->version = 1;
unset($doc->contentType, $doc->url);
$requiredFields = $this->config->doc->create->requiredFields;
$doc->draft = '';
$doc->vision = $this->config->vision;
$docsAction = array();
foreach($files as $file)
{
$title = $file['title'];
$position = strrpos($title, '.');
if($position !== 'false') $title = substr($title, 0, $position);
$doc->title = $title;
$this->dao->insert(TABLE_DOC)->data($doc, 'content')->autoCheck()
->batchCheck($requiredFields, 'notempty')
->exec();
if(!dao::isError())
{
$docID = $this->dao->lastInsertID();
$this->file->updateObjectID($this->post->uid, $docID, 'doc');
$fileTitle = $this->file->saveAFile($file, 'doc', $docID);
$docsAction[$docID] = $fileTitle;
if(empty($fileTitle)) continue;
if(dao::isError())
{
dao::$errors['message'][] = 'doc#' . ($file->title) . dao::getError(true);
continue;
}
$docContent->doc = $docID;
$docContent->files = ',' . $fileTitle->id;
$docContent->title = $title;
$docContent->content = '';
$docContent->type = 'attachment';
$docContent->digest = '';
$docContent->version = 1;
$this->dao->insert(TABLE_DOCCONTENT)->data($docContent)->exec();
$this->loadModel('score')->create('doc', 'create', $docID);
}
}
return dao::isError() ? false : array('status' => 'new', 'docsAction' => $docsAction, 'docType' => 'attachment', 'libID' => $doc->lib);
}
/**
* Create a doc.
*
+2 -2
View File
@@ -116,7 +116,7 @@
<?php endif;?>
</div>
<div id="diffContain">
<div class="detail-content article-content table-col">
<div class="detail-content article-content table-col" <?php if(strpos('word,ppt,excel,attachment', $doc->type) !== false) echo 'style="max-height: 60px"';?>>
<div class='info'>
<?php $createInfo = $doc->status == 'draft' ? zget($users, $doc->addedBy) . " {$lang->colon} " . substr($doc->addedDate, 0, 10) . (common::checkNotCN() ? ' ' : '') . $lang->doc->createAB : zget($users, $doc->releasedBy) . " {$lang->colon} " . substr($doc->releasedDate, 0, 10) . (common::checkNotCN() ? ' ' : '') . $lang->doc->release;?>
<span class='user-time text-muted'><i class='icon-contacts'></i> <?php echo $createInfo;?></span>
@@ -164,7 +164,7 @@
{
echo "<textarea id='markdownContent'>{$doc->content}</textarea>";
}
else
elseif($doc->type != 'attachment')
{
echo $doc->content;
}
+1 -1
View File
@@ -46,7 +46,7 @@
<th><?php echo $lang->doc->keywords;?></th>
<td colspan='3'><?php echo html::input('keywords', $doc->keywords, "class='form-control' placeholder='{$lang->doc->keywordsTips}'");?></td>
</tr>
<?php if(strpos($config->doc->officeTypes, $doc->type) !== false):?>
<?php if(strpos($config->doc->officeTypes, $doc->type) !== false || $doc->type == 'attachment'):?>
<tr>
<th><?php echo $lang->doc->files;?></th>
<td colspan='3'><?php echo $this->fetch('file', 'buildform');?></td>
+11 -10
View File
@@ -251,14 +251,15 @@ $(function()
function initTree(ele, treeData)
{
var imgObj = {
'annex' : 'annex',
'api' : 'interface',
'lib' : 'wiki',
'execution' : 'wiki-file-lib',
'text' : 'wiki-file',
'word' : 'word',
'ppt' : 'ppt',
'excel' : 'excel'
'annex' : 'annex',
'api' : 'interface',
'lib' : 'wiki',
'execution' : 'wiki-file-lib',
'text' : 'wiki-file',
'word' : 'word',
'ppt' : 'ppt',
'excel' : 'excel',
'attachment' : 'attachment'
};
ele.tree(
@@ -285,7 +286,7 @@ $(function()
$item += '<div class="text h-full w-full flex-start overflow-hidden">';
if((libClass == 'lib' && item.type != 'execution') || (item.type == 'execution' && item.hasAction)) $item += '<i class="before-tree-item icon icon-' + imgObj[item.type] +'-lib"></i>';
if(['text', 'word', 'ppt', 'excel'].indexOf(item.type) !== -1) $item += '<div class="img-lib" style="background-image:url(static/svg/' + imgObj[item.type] + '.svg)"></div>';
if(['text', 'word', 'ppt', 'excel', 'attachment'].indexOf(item.type) !== -1) $item += '<div class="img-lib" style="background-image:url(static/svg/' + imgObj[item.type] + '.svg)"></div>';
$item += '<div class="tree-text">';
$item += item.name;
$item += '</div>';
@@ -489,7 +490,7 @@ $(function()
methodName = 'showFiles';
linkParams = 'type=' + objectType + '&objectID=' + objectID;
}
else if(['text', 'word', 'ppt', 'excel'].indexOf(type) !== -1)
else if(['text', 'word', 'ppt', 'excel', 'attachment'].indexOf(type) !== -1)
{
methodName = 'view';
linkParams = 'docID=' + moduleID;
+2 -2
View File
@@ -33,8 +33,8 @@
<?php
if($canUploadDoc)
{
$uploadLink = $this->createLink('doc', 'uploadDocs', "libID=$libID&moduleID=$moduleID", 'html', true);
echo html::a($uploadLink, "<i class='icon-import muted'> </i>" . $lang->doc->uploadDoc, '', "class='btn btn-link' data-width='480px'");
$uploadLink = $this->createLink('doc', 'uploadDocs', "objectType=mine&objectID=&libID=$libID&moduleID=$moduleID&docType=attachment", 'html', true);
echo html::a($uploadLink, "<i class='icon-import muted'> </i>" . $lang->doc->uploadDoc, '', "class='btn btn-link iframe'");
}
if($canExport)
{
+2 -2
View File
@@ -41,8 +41,8 @@
if($canUploadDoc)
{
$uploadLink = $this->createLink('doc', 'uploadDocs', "libID=$libID&moduleID=$moduleID", 'html', true);
echo html::a($uploadLink, "<i class='icon-import muted'> </i>" . $lang->doc->uploadDoc, '', "class='btn btn-link' data-width='480px'");
$uploadLink = $this->createLink('doc', 'uploadDocs', "objectType=$objectType&objectID=$objectID&libID=$libID&moduleID=$moduleID&docType=attachment", 'html', true);
echo html::a($uploadLink, "<i class='icon-import muted'> </i>" . $lang->doc->uploadDoc, '', "class='btn btn-link iframe'");
}
if($canExport)
+110
View File
@@ -0,0 +1,110 @@
<?php
/**
* The upload docs view of doc module of ZenTaoPMS.
*
* @copyright Copyright 2009-2022 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
* @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
* @author Deqing Chai <chaideqing@easycorp.ltd>
* @package doc
* @version $Id: uploaddocs.html.php 975 2023-10-31 13:49:25Z $
* @link http://www.zentao.net
*/
?>
<?php include '../../common/view/header.lite.html.php';?>
<?php if($objectType == 'custom' and empty($libs)):?>
<?php echo html::a(helper::createLink('doc', 'createLib', "type=custom&objectID=$objectID"), '<i class="icon icon-plus"></i> ' . $lang->doc->createLib, '', 'class="iframe hidden createCustomLib"');?>
<?php endif;?>
<?php $this->app->loadConfig('file');?>
<div id="mainContent" class="main-content">
<div class='center-block'>
<div class='main-header'>
<h2><?php echo $lang->doc->create;?></h2>
</div>
<form class="load-indicator main-form form-ajax" id="dataform" method='post'>
<table class='table table-form'>
<tbody>
<?php if($objectType == 'project'):?>
<tr>
<th><?php echo $lang->doc->project;?></th>
<td colspan='3' class='required'><?php echo html::select('project', $objects, $objectID, "class='form-control picker-select' onchange=loadExecutions(this.value)");?></td>
<?php if($this->app->tab == 'doc'):?>
<th><?php echo $lang->doc->execution?></th>
<td colspan='3' id='executionBox'><?php echo html::select('execution', $executions, '', "class='form-control picker-select' data-placeholder='{$lang->doc->placeholder->execution}' onchange='loadObjectModules(\"execution\", this.value)'")?></td>
<?php endif;?>
</tr>
<?php elseif($objectType == 'execution'):?>
<tr>
<th><?php echo $lang->doc->execution;?></th>
<td colspan='3' class='required'><?php echo html::select('execution', $objects, $objectID, "class='form-control picker-select' onchange='loadObjectModules(\"execution\", this.value)'");?></td>
</tr>
<?php elseif($objectType == 'product'):?>
<tr>
<th><?php echo $lang->doc->product;?></th>
<td colspan='3' class='required'><?php echo html::select('product', $objects, $objectID, "class='form-control picker-select' onchange='loadObjectModules(\"product\", this.value)'");?></td>
</tr>
<?php endif;?>
<tr>
<th class='w-100px'><?php echo $lang->doc->libAndModule?></th>
<td colspan='3' class='required'><span id='moduleBox'><?php echo html::select('module', $moduleOptionMenu, $moduleID, "class='form-control picker-select'");?></span></td>
</tr>
<tr>
<th><?php echo $lang->doclib->control;?></th>
<td colspan='3' <?php if($objectType != 'mine') echo "class='aclBox'";?>>
<?php echo html::radio('acl', $lang->doc->aclList, $objectType == 'mine' ? 'private' : 'open', "onchange='toggleAcl(this.value, \"doc\")'");?>
</td>
</tr>
<tr id='whiteListBox' class='hidden'>
<th><?php echo $lang->doc->whiteList;?></th>
<td colspan='3'>
<div class='input-group'>
<span class='input-group-addon groups-addon'><?php echo $lang->doclib->group?></span>
<?php echo html::select('groups[]', $groups, '', "class='form-control picker-select' multiple data-drop-direction='top'")?>
</div>
<div class='input-group'>
<span class='input-group-addon'><?php echo $lang->doclib->user?></span>
<?php echo html::select('users[]', $users, '', "class='form-control picker-select' multiple data-drop-direction='top'")?>
<?php echo $this->fetch('my', 'buildContactLists', "dropdownName=users");?>
</div>
</td>
</tr>
</tr>
<tr>
<th><?php echo $lang->doc->uploadFormat;?></th>
<td colspan='4'><?php echo html::radio('uploadFormat', $lang->doc->uploadFormatList, 'separateDocs', "onchange='toggleDocTitle(this.value)'");?></td>
</tr>
<tr id='docTitle' style='display: none'>
<th><?php echo $lang->doc->title;?></th>
<td colspan='3'><?php echo html::input('title', '', "class='form-control' required oninput='titleChanged()'"
);?></td>
<tr id='file-upload'>
<th><?php echo $lang->files;?></th>
<td colspan='3'><?php echo $this->fetch('file', 'buildform');?></td>
</tr>
<tr>
<td colspan='4' class='text-center form-actions'>
<?php
echo html::submitButton();
echo html::hidden('status', 'normal');
echo html::hidden('type', $docType);
echo html::hidden('contentType', 'html');
?>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<?php js::set('textType', $config->doc->textTypes);?>
<?php js::set('objectType', $objectType);?>
<?php js::set('docType', $docType);?>
<?php js::set('holders', $lang->doc->placeholder);?>
<script>
function openEditURL(docID, fileID)
{
var editUrl = createLink('file', 'download', "fileID=" + fileID + "&mouse=left&edit=1");
window.open(editUrl);
parent.location.href = createLink('doc', 'view', "docID=" + docID);
}
</script>
<?php include $app->getModuleRoot() . 'common/view/footer.lite.html.php';?>
+5
View File
@@ -31,6 +31,11 @@
<?php if(empty($object->deleted)):?>
<div class="btn-toolbar pull-right">
<?php
if($canUploadDoc)
{
$uploadLink = $this->createLink('doc', 'uploadDocs', "objectType=$objectType&objectID=$objectID&libID=$libID&moduleID=$moduleID&docType=attachment", 'html', true);
echo html::a($uploadLink, "<i class='icon-import muted'> </i>" . $lang->doc->uploadDoc, '', "class='btn btn-link iframe'");
}
if($canExport) echo html::a($this->createLink('doc', $exportMethod, "libID=$libID&moduleID=0&docID=$docID"), "<i class='icon-export muted'> </i>" . $lang->export, 'hiddenwin', "class='btn btn-link' id='docExport'");
if(common::hasPriv('doc', 'createLib')) echo html::a($this->createLink('doc', 'createLib', "type=" . ($objectType ? $objectType : 'nolink') . "&objectID=$objectID"), '<i class="icon icon-plus"></i> ' . $lang->api->createLib, '', 'class="btn btn-secondary iframe" data-width="800px"');
if(common::hasPriv('doc', 'create')) echo $this->doc->printCreateBtn($lib, $moduleID);
+35
View File
@@ -155,6 +155,41 @@ class fileModel extends model
return $fileTitles;
}
/**
* Save a file.
*
* @param object $file
* @param string $objectType
* @param int $objectID
* @param string $extra
* @param string $filesName
* @param string $labelsName
* @access public
* @return array
*/
public function saveAFile($file, $objectType = '', $objectID = 0, $extra = '', $filesName = 'files', $labelsName = 'labels')
{
$fileTitle = new stdclass();
$now = helper::today();
if($file['size'] == 0) return array();
if(!move_uploaded_file($file['tmpname'], $this->savePath . $this->getSaveName($file['pathname']))) return false;
$file = $this->compressImage($file);
$file['objectType'] = $objectType;
$file['objectID'] = $objectID;
$file['addedBy'] = $this->app->user->account;
$file['addedDate'] = $now;
$file['extra'] = $extra;
unset($file['tmpname']);
$this->dao->insert(TABLE_FILE)->data($file)->exec();
$fileTitle->id = $this->dao->lastInsertId();
$fileTitle->title = $file['title'];
return $fileTitle;
}
/**
* Get counts of uploaded files.
*
+8
View File
@@ -0,0 +1,8 @@
<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.09375 1.0957H15.6652C15.9413 1.0957 16.1652 1.31956 16.1652 1.5957V14.4528C16.1652 14.729 15.9413 14.9528 15.6652 14.9528H5.09375C4.81761 14.9528 4.59375 14.729 4.59375 14.4528V1.5957C4.59375 1.31956 4.81761 1.0957 5.09375 1.0957Z" stroke="#D5DBE9"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M13.24 5.49207H6.38281V4.26758H13.24V5.49207ZM13.24 8.55248H6.38281V7.32799H13.24V8.55248ZM6.38281 11.615H13.24V10.3905H6.38281V11.615Z" fill="#E6EAF1"/>
<path d="M0.667969 3.88086C0.667969 3.32857 1.11568 2.88086 1.66797 2.88086H8.81082C9.36311 2.88086 9.81083 3.32857 9.81083 3.88086V14.4523C9.81083 15.0046 9.36311 15.4523 8.81083 15.4523H0.667969V3.88086Z" fill="#9EA3B0"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M5.19057 6C6.05398 6 6.75391 6.69993 6.75391 7.56333L6.75391 11.1367C6.75391 12.0001 6.05398 12.7 5.19057 12.7C4.32717 12.7 3.62724 12.0001 3.62724 11.1367L3.62724 10.0944C3.62724 9.88887 3.79389 9.72222 3.99946 9.72222C4.20503 9.72222 4.37168 9.88887 4.37168 10.0944L4.37168 11.1367C4.37168 11.5889 4.73831 11.9556 5.19057 11.9556C5.64283 11.9556 6.00946 11.5889 6.00946 11.1367L6.00946 7.56333C6.00946 7.11107 5.64283 6.74444 5.19057 6.74444C4.73831 6.74444 4.37168 7.11107 4.37168 7.56333L4.37168 7.86111C4.37168 8.06668 4.20503 8.23333 3.99946 8.23333C3.79389 8.23333 3.62724 8.06668 3.62724 7.86111L3.62724 7.56333C3.62724 6.69993 4.32717 6 5.19057 6Z" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.81806 9.44935C4.81806 9.326 4.71807 9.22601 4.59472 9.22601C4.47138 9.22601 4.37139 9.326 4.37139 9.44935L4.37139 10.3427L3.62694 10.3427L3.62694 9.44935C3.62694 8.91486 4.06023 8.48157 4.59472 8.48157C5.12921 8.48157 5.5625 8.91486 5.5625 9.44935L5.5625 10.3427C5.5625 10.5482 5.39585 10.7149 5.19028 10.7149C4.98471 10.7149 4.81806 10.5482 4.81806 10.3427L4.81806 9.44935Z" fill="white"/>
<path d="M6.38281 2.88086H9.81138V6.30943L8.0971 4.59514L6.38281 2.88086Z" fill="#838487"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB