diff --git a/db/zentaopms299.sql b/db/zentaopms299.sql index 4b97b5949c..ff1e0dc27e 100644 --- a/db/zentaopms299.sql +++ b/db/zentaopms299.sql @@ -1,5 +1,6 @@ UPDATE `zt_doc` SET `type` = 'text' WHERE `type` = 'url'; UPDATE `zt_doc` SET `acl` = 'private' WHERE `acl` = 'custom'; +UPDATE `zt_doc` SET `status` = 'normal' WHERE `status` = ''; UPDATE `zt_doclib` SET `acl` = 'private' WHERE `type` = 'custom' and `acl` = 'custom'; UPDATE `zt_doclib` SET `acl` = 'private' WHERE `type` = 'product' AND `acl` = 'custom'; @@ -12,6 +13,7 @@ UPDATE `zt_doclib` SET `acl` = 'default' WHERE `main` = '1'; ALTER TABLE `zt_doclib` ADD `addedBy` varchar(30) NOT NULL AFTER `order`; ALTER TABLE `zt_doclib` ADD `addedDate` datetime NOT NULL AFTER `addedBy`; +ALTER TABLE `zt_doc` CHANGE `status` `status` varchar(30) COLLATE 'utf8_general_ci' NOT NULL DEFAULT 'normal'; /* Update doc lib. */ UPDATE zt_doclib AS t1 diff --git a/module/doc/config.php b/module/doc/config.php index bfa8e35cf5..f16bf98786 100644 --- a/module/doc/config.php +++ b/module/doc/config.php @@ -44,6 +44,7 @@ $config->doc->search['fields']['product'] = $lang->doc->product; if($app->rawMethod == 'contribute') $config->doc->search['fields']['project'] = $lang->doc->project; $config->doc->search['fields']['execution'] = $lang->doc->execution; $config->doc->search['fields']['lib'] = $lang->doc->lib; +$config->doc->search['fields']['status'] = $lang->doc->status; $config->doc->search['fields']['module'] = $lang->doc->module; $config->doc->search['fields']['addedBy'] = $lang->doc->addedByAB; $config->doc->search['fields']['addedDate'] = $lang->doc->addedDate; @@ -54,7 +55,8 @@ $config->doc->search['fields']['version'] = $lang->doc->version; $config->doc->search['params']['title'] = array('operator' => 'include', 'control' => 'input', 'values' => ''); $config->doc->search['params']['product'] = array('operator' => '=', 'control' => 'select', 'values' => ''); -$config->doc->search['params']['lib'] = array('operator' => '=', 'control' => 'select', 'values' => '' ); +$config->doc->search['params']['lib'] = array('operator' => '=', 'control' => 'select', 'values' => ''); +$config->doc->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $lang->doc->statusList); $config->doc->search['params']['module'] = array('operator' => 'belong', 'control' => 'select', 'values' => ''); if($app->rawMethod == 'contribute') $config->doc->search['params']['project'] = array('operator' => '=', 'control' => 'select', 'values' => ''); $config->doc->search['params']['execution'] = array('operator' => '=', 'control' => 'select', 'values' => ''); diff --git a/module/doc/control.php b/module/doc/control.php index 10b0838f06..28e9c05a8a 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -1268,7 +1268,7 @@ class doc extends control * @param int $objectID * @param int $libID * @param int $moduleID - * @param string $browseType + * @param string $browseType all|draft|bysearch * @param string $orderBy * @param int $param * @param int $recTotal @@ -1277,7 +1277,7 @@ class doc extends control * @access public * @return void */ - public function tableContents($type, $objectID = 0, $libID = 0, $moduleID = 0, $browseType = '', $orderBy = 'id_desc', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) + public function tableContents($type, $objectID = 0, $libID = 0, $moduleID = 0, $browseType = 'all', $orderBy = 'status,id_desc', $param = 0, $recTotal = 0, $recPerPage = 20, $pageID = 1) { $this->session->set('createProjectLocate', $this->app->getURI(true), 'doc'); @@ -1324,7 +1324,7 @@ class doc extends control else { $this->session->set('objectName', $this->lang->doc->common, 'admin'); - $this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $orderBy, $pager); + $this->view->docs = $browseType == 'bySearch' ? $this->doc->getDocsBySearch($type, $objectID, $libID, $queryID, $orderBy, $pager) : $this->doc->getDocs($libID, $moduleID, $browseType, $orderBy, $pager); } $apiObjectType = $type == 'product' || $type == 'project' ? $type : ''; diff --git a/module/doc/css/create.css b/module/doc/css/create.css index 6a209b8b9d..292d9abdc6 100644 --- a/module/doc/css/create.css +++ b/module/doc/css/create.css @@ -1,12 +1,13 @@ #main {padding: 0;} .container {padding: 0 !important;} #mainContent {padding: 0;} +.doc-title {width:400px;} .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;} +#savePath {display:inline-block; width:320px; overflow:hidden; white-space: nowrap; height: 19px; padding-top: 4px; padding-right:8px;} .contentmarkdown.required:after, .contenthtml.required:after {right:3px;} -#submit {margin-right: 16px;} #headerBox {border-bottom: 1px solid #e3e3e3;} #headerBox td:last-child {padding-right: 24px;} #editorContent {padding: 0;} @@ -34,7 +35,7 @@ #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:absolute; right:15px; top:15px} +#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;} diff --git a/module/doc/css/tablecontents.css b/module/doc/css/tablecontents.css index 37b04bb8a2..3b55b430cd 100644 --- a/module/doc/css/tablecontents.css +++ b/module/doc/css/tablecontents.css @@ -89,7 +89,8 @@ li.drag-shadow ul {display: none!important;} .createDropdown ul > li {text-align: left;} .createDropdown .btn.btn-info:hover {box-shadow: none;} -.table .c-name > a:first-child {display: inline-block; max-width: 90%; overflow: hidden;} +.table .c-name > .doc-title {display: inline-block; max-width: 90%; overflow: hidden; background: transparent; padding-right:0px;} +.table .c-name > .draft {background-color:rgba(129, 102, 238, 0.12); color:#8166EE;} .table .c-name > .ajaxCollect {float: right; position: relative; right: 10px; top: -3px;} table.table > thead > tr {height: 32px;} diff --git a/module/doc/js/common.js b/module/doc/js/common.js index 86ab2447b4..a461682a68 100644 --- a/module/doc/js/common.js +++ b/module/doc/js/common.js @@ -315,3 +315,34 @@ function locateNewLib(type, objectID, libID) { location.href = createLink('doc', 'tableContents', 'type=' + type + '&objectID=' + objectID + '&libID=' + libID); } + +/** + * Set save path. + * + * @access public + * @return void + */ +function setSavePath() +{ + savePath = defaultSave; + if($('#modalBasicInfo #product').length == 1) + { + savePath += $('#modalBasicInfo #product option:checked').text() + '/'; + } + else if($('#modalBasicInfo #project').length == 1 && $('#modalBasicInfo #execution').length == 0) + { + savePath += $('#modalBasicInfo #project option:checked').text() + '/'; + } + else if($('#modalBasicInfo #project').length == 1 && $('#modalBasicInfo #execution').length == 1) + { + if($('#modalBasicInfo #execution').val() == '') savePath += $('#modalBasicInfo #project option:checked').text() + '/'; + if($('#modalBasicInfo #execution').val() != '') savePath += $('#modalBasicInfo #execution option:checked').text() + '/'; + } + else if($('#modalBasicInfo #execution').length == 1) + { + savePath += $('#modalBasicInfo #execution option:checked').text() + '/'; + } + savePath += $('#modalBasicInfo #module option:checked').text(); + + $('#savePath').html(savePath).attr('title', savePath); +} diff --git a/module/doc/js/create.js b/module/doc/js/create.js index 80b6d8e013..d55329e85b 100644 --- a/module/doc/js/create.js +++ b/module/doc/js/create.js @@ -4,6 +4,9 @@ $(function() 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'); + + setSavePath(); /* Change for show create error. */ $('#contentBox #content').attr('id', 'contentHTML'); @@ -12,8 +15,39 @@ $(function() { $('#modalBasicInfo #copyTitle').html($('.doc-title #editorTitle').val().replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'")); }); + $('#modalBasicInfo').on('hide.zui.modal', function(){setSavePath();}); - $('iframe.ke-edit-iframe').contents().find('.article-content').css('padding', '20px 20px 0 20px'); + $('#saveDraft').click(function() + { + if($('#editorTitle').val() == '') + { + bootbox.alert(titleNotEmpty); + return false; + } + $('#status').val('draft'); + $('#dataform').submit(); + }); + $('#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') diff --git a/module/doc/js/tablecontents.js b/module/doc/js/tablecontents.js index 714612fff5..8b4718fafe 100644 --- a/module/doc/js/tablecontents.js +++ b/module/doc/js/tablecontents.js @@ -1,5 +1,14 @@ $(function() { + $('#docListForm .table .c-name').each(function() + { + var $this = $(this); + if($this.find('.draft').length > 0) + { + $this.find('.doc-title').css('max-width', parseInt($this.width()) - parseInt($this.find('.draft').width()) - parseInt($this.find('.ajaxCollect').width()) - parseInt($this.find('.file-icon').width()) - 24); + } + }); + /** * Render Dropdown dom. * diff --git a/module/doc/lang/de.php b/module/doc/lang/de.php index 535afaa67e..c133b0e0c1 100644 --- a/module/doc/lang/de.php +++ b/module/doc/lang/de.php @@ -71,6 +71,7 @@ $lang->doc->comment = 'Bemerkung'; $lang->doc->type = 'Typ'; $lang->doc->content = 'Text'; $lang->doc->keywords = 'Tags'; +$lang->doc->status = 'Status'; $lang->doc->url = 'URL'; $lang->doc->files = 'Datei'; $lang->doc->addedBy = 'Angelegt von'; @@ -111,6 +112,8 @@ $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; $lang->doc->nextStep = 'Next'; $lang->doc->closed = 'Closed'; +$lang->doc->saveDraft = 'Save Draft'; +$lang->doc->defaultSave = 'Default Save: '; $lang->doc->moduleDoc = 'Nach Modulen'; $lang->doc->searchDoc = 'Suche'; @@ -196,6 +199,10 @@ $lang->doc->libIconList['custom'] = 'icon-folder-o'; $lang->doc->systemLibs['product'] = $lang->productCommon . 'Dok Bibliothek'; $lang->doc->systemLibs['execution'] = $lang->executionCommon . 'Dok Bibliothek'; +$lang->doc->statusList[''] = ""; +$lang->doc->statusList['normal'] = "Released"; +$lang->doc->statusList['draft'] = "Draft"; + $lang->doc->aclList['open'] = "Öffentlich (Access with library permissions)"; $lang->doc->aclList['private'] = "Privat (Only creators and whitelist users can access)"; @@ -307,3 +314,6 @@ $lang->doc->libDropdown['addSameModule'] = 'Add Same Directory'; $lang->doc->libDropdown['addSubModule'] = 'Add Sub Directory'; $lang->doc->libDropdown['editModule'] = 'Edit Directory'; $lang->doc->libDropdown['delModule'] = 'Delete Directory'; + +$lang->doc->featureBar['tableContents']['all'] = 'All'; +$lang->doc->featureBar['tableContents']['draft'] = 'Draft'; diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 79a4187793..c3ed874a10 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -71,6 +71,7 @@ $lang->doc->comment = 'Comment'; $lang->doc->type = 'Type'; $lang->doc->content = 'Text'; $lang->doc->keywords = 'Tags'; +$lang->doc->status = 'Status'; $lang->doc->url = 'URL'; $lang->doc->files = 'Files'; $lang->doc->addedBy = 'Author'; @@ -111,6 +112,8 @@ $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; $lang->doc->nextStep = 'Next'; $lang->doc->closed = 'Closed'; +$lang->doc->saveDraft = 'Save Draft'; +$lang->doc->defaultSave = 'Default Save: '; $lang->doc->moduleDoc = 'By Module'; $lang->doc->searchDoc = 'Search'; @@ -196,6 +199,10 @@ $lang->doc->libIconList['custom'] = 'icon-folder-o'; $lang->doc->systemLibs['product'] = $lang->productCommon; $lang->doc->systemLibs['execution'] = $lang->executionCommon; +$lang->doc->statusList[''] = ""; +$lang->doc->statusList['normal'] = "Released"; +$lang->doc->statusList['draft'] = "Draft"; + $lang->doc->aclList['open'] = "Public (Access with library permissions)"; $lang->doc->aclList['private'] = "Private (Only creators and whitelist users can access)"; @@ -307,3 +314,6 @@ $lang->doc->libDropdown['addSameModule'] = 'Add Same Directory'; $lang->doc->libDropdown['addSubModule'] = 'Add Sub Directory'; $lang->doc->libDropdown['editModule'] = 'Edit Directory'; $lang->doc->libDropdown['delModule'] = 'Delete Directory'; + +$lang->doc->featureBar['tableContents']['all'] = 'All'; +$lang->doc->featureBar['tableContents']['draft'] = 'Draft'; diff --git a/module/doc/lang/fr.php b/module/doc/lang/fr.php index aadd86f0fc..d059af46c0 100644 --- a/module/doc/lang/fr.php +++ b/module/doc/lang/fr.php @@ -71,6 +71,7 @@ $lang->doc->comment = 'Commentaire'; $lang->doc->type = 'Type'; $lang->doc->content = 'Texte'; $lang->doc->keywords = 'Tags'; +$lang->doc->status = 'Status'; $lang->doc->url = 'URL'; $lang->doc->files = 'Fichiers'; $lang->doc->addedBy = 'Auteur'; @@ -111,6 +112,8 @@ $lang->doc->doc = 'Document'; $lang->doc->updateOrder = 'Update Order'; $lang->doc->nextStep = 'Next'; $lang->doc->closed = 'Closed'; +$lang->doc->saveDraft = 'Save Draft'; +$lang->doc->defaultSave = 'Default Save: '; $lang->doc->moduleDoc = 'Par Module'; $lang->doc->searchDoc = 'Rechercher'; @@ -196,6 +199,10 @@ $lang->doc->libIconList['custom'] = 'icon-folder-o'; $lang->doc->systemLibs['product'] = $lang->productCommon; $lang->doc->systemLibs['execution'] = $lang->executionCommon; +$lang->doc->statusList[''] = ""; +$lang->doc->statusList['normal'] = "Released"; +$lang->doc->statusList['draft'] = "Draft"; + $lang->doc->aclList['open'] = "Public (Access with library permissions)"; $lang->doc->aclList['private'] = "Privé (Only creators and whitelist users can access)"; @@ -308,3 +315,6 @@ $lang->doc->libDropdown['addSameModule'] = 'Add Same Directory'; $lang->doc->libDropdown['addSubModule'] = 'Add Sub Directory'; $lang->doc->libDropdown['editModule'] = 'Edit Directory'; $lang->doc->libDropdown['delModule'] = 'Delete Directory'; + +$lang->doc->featureBar['tableContents']['all'] = 'All'; +$lang->doc->featureBar['tableContents']['draft'] = 'Draft'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index b8a3f9c381..222997bc2c 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -71,6 +71,7 @@ $lang->doc->comment = '文档备注'; $lang->doc->type = '文档类型'; $lang->doc->content = '文档正文'; $lang->doc->keywords = '关键字'; +$lang->doc->status = '文档状态'; $lang->doc->url = '文档URL'; $lang->doc->files = '附件'; $lang->doc->addedBy = '由谁添加'; @@ -111,6 +112,8 @@ $lang->doc->doc = '文档'; $lang->doc->updateOrder = '更新排序'; $lang->doc->nextStep = '下一步'; $lang->doc->closed = '已关闭'; +$lang->doc->saveDraft = '存为草稿'; +$lang->doc->defaultSave = '默认存入:'; $lang->doc->moduleDoc = '按模块浏览'; $lang->doc->searchDoc = '搜索'; @@ -196,6 +199,10 @@ $lang->doc->libIconList['custom'] = 'icon-folder-o'; $lang->doc->systemLibs['product'] = $lang->productCommon; $lang->doc->systemLibs['execution'] = $lang->executionCommon; +$lang->doc->statusList[''] = ""; +$lang->doc->statusList['normal'] = "已发布"; +$lang->doc->statusList['draft'] = "草稿"; + $lang->doc->aclList['open'] = "公开(有所属库权限即可访问)"; $lang->doc->aclList['private'] = "私有(仅创建者和白名单用户可访问)"; @@ -307,3 +314,6 @@ $lang->doc->libDropdown['addSameModule'] = '添加同级目录'; $lang->doc->libDropdown['addSubModule'] = '添加子目录'; $lang->doc->libDropdown['editModule'] = '编辑目录'; $lang->doc->libDropdown['delModule'] = '删除目录'; + +$lang->doc->featureBar['tableContents']['all'] = '全部'; +$lang->doc->featureBar['tableContents']['draft'] = '草稿'; diff --git a/module/doc/model.php b/module/doc/model.php index 574d7235a4..00328fb00f 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -367,7 +367,7 @@ class docModel extends model if($browseType == "all") { - $docs = $this->getDocs(0, 0, $sort, $pager); + $docs = $this->getDocs(0, 0, $browseType, $sort, $pager); } elseif($browseType == 'bySearch') { @@ -598,13 +598,15 @@ class docModel extends model * @access public * @return void */ - public function getDocs($libID, $module, $orderBy, $pager = null) + public function getDocs($libID, $module, $browseType, $orderBy, $pager = null) { $docIdList = $this->getPrivDocs($libID, $module); return $this->dao->select('*')->from(TABLE_DOC) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->andWhere('id')->in($docIdList) + ->beginIF($browseType == 'all')->andWhere("(status = 'normal' or (status = 'draft' and addedBy='{$this->app->user->account}'))")->fi() + ->beginIF($browseType == 'draft')->andWhere('status')->eq('draft')->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll('id'); @@ -778,6 +780,7 @@ class docModel extends model unset($doc->contentMarkdown, $doc->contentType, $doc->url); $requiredFields = $this->config->doc->create->requiredFields; + if($doc->status == 'draft') $requiredFields = ''; if(strpos("url|word|ppt|excel", $this->post->type) !== false) $requiredFields = trim(str_replace(",content,", ",", ",{$requiredFields},"), ','); $checkContent = strpos(",$requiredFields,", ',content,') !== false; @@ -930,10 +933,8 @@ class docModel extends model */ public function saveDraft($docID) { - $data = fixer::input('post') - ->stripTags($this->config->doc->editor->edit['id'], $this->config->allowedTags) - ->get(); - $doc = new stdclass(); + $data = fixer::input('post')->stripTags($this->config->doc->editor->edit['id'], $this->config->allowedTags)->get(); + $doc = new stdclass(); $doc->draft = $data->content; $docType = $this->dao->select('type')->from(TABLE_DOCCONTENT)->where('doc')->eq((int)$docID)->orderBy('version_desc')->fetch(); diff --git a/module/doc/view/createtexttype.html.php b/module/doc/view/createtexttype.html.php index 3fbbc04f90..56651209e6 100644 --- a/module/doc/view/createtexttype.html.php +++ b/module/doc/view/createtexttype.html.php @@ -24,7 +24,9 @@