diff --git a/module/doc/control.php b/module/doc/control.php index bfd82f5997..2768945fd4 100755 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -389,30 +389,24 @@ class doc extends control $lib = $this->doc->getLibByID($libID); $objects = array(); + if($objectType == 'project') + { + $objects = $this->loadModel('project')->getPairs(); + $this->view->executions = array(0 => '') + $this->loadModel('execution')->getPairs($objectID, 'all', 'multiple,leaf,noprefix'); + } + elseif($objectType == 'execution') + { + $execution = $this->loadModel('execution')->getById($objectID); + $objects = $this->execution->getPairs($execution->project, 'all', "multiple,leaf,noprefix"); + } + elseif($objectType == 'product') + { + $objects = $this->loadModel('product')->getPairs(); + } + $moduleOptionMenu = $this->doc->getLibsOptionMenu($libs); + $moduleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastDocModule; - if($docType == 'html') - { - if($objectType == 'project') - { - $objects = $this->loadModel('project')->getPairs(); - $this->view->executions = array(0 => '') + $this->loadModel('execution')->getPairs($objectID, 'all', 'multiple,leaf,noprefix'); - } - elseif($objectType == 'execution') - { - $execution = $this->loadModel('execution')->getById($objectID); - $objects = $this->execution->getPairs($execution->project, 'all', "multiple,leaf,noprefix"); - } - elseif($objectType == 'product') - { - $objects = $this->loadModel('product')->getPairs(); - } - $moduleOptionMenu = $this->doc->getLibsOptionMenu($libs); - $moduleID = $libID . '_' . $moduleID; - } - else - { - $moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); - } + $moduleID = $libID . '_' . $moduleID; $this->view->title = zget($lib, 'name', '', $lib->name . $this->lang->colon) . $this->lang->doc->create; $this->view->linkType = $linkType; @@ -525,8 +519,9 @@ class doc extends control if($doc->contentType == 'markdown') $this->config->doc->markdown->edit = array('id' => 'content', 'tools' => 'toolbar'); - $lib = $this->doc->getLibByID($libID); - $type = $lib->type; + $lib = $this->doc->getLibByID($libID); + $objectType = $lib->type; + $objectID = zget($lib, $objectType, 0); /* Set menus. */ if($this->app->tab == 'product') @@ -553,6 +548,23 @@ class doc extends control $this->app->rawMethod = $objectType == 'execution' ? 'project' : $objectType; } + $libs = $this->doc->getLibs($objectType, 'withObject', $libID, $objectID); + $objects = array(); + if($objectType == 'project') + { + $objects = $this->loadModel('project')->getPairs(); + } + elseif($objectType == 'execution') + { + $execution = $this->loadModel('execution')->getById($objectID); + $objects = $this->execution->getPairs($execution->project, 'all', "multiple,leaf,noprefix"); + } + elseif($objectType == 'product') + { + $objects = $this->loadModel('product')->getPairs(); + } + $moduleOptionMenu = $this->doc->getLibsOptionMenu($libs); + $this->config->showMainMenu = strpos(',html,markdown,text,', ",{$doc->type},") === false; $this->view->title = $lib->name . $this->lang->colon . $this->lang->doc->edit; @@ -560,15 +572,16 @@ class doc extends control $this->view->position[] = $this->lang->doc->edit; $this->view->doc = $doc; - $this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); - $this->view->type = $type; - $this->view->libs = $this->doc->getLibs('all', 'withObject', $libID, $objectID, 'book'); + $this->view->moduleOptionMenu = $moduleOptionMenu; + $this->view->type = $objectType; + $this->view->libs = $libs; + $this->view->objects = $objects; $this->view->lib = $lib; $this->view->groups = $this->loadModel('group')->getPairs(); $this->view->users = $this->user->getPairs('noletter|noclosed|nodeleted', $doc->users); $this->view->from = $from; $this->view->files = $this->loadModel('file')->getByObject('doc', $docID); - $this->view->objectID = zget($lib, $type, 0); + $this->view->objectID = $objectID; $this->display(); } diff --git a/module/doc/css/create.css b/module/doc/css/create.css index 292d9abdc6..1cca647104 100644 --- a/module/doc/css/create.css +++ b/module/doc/css/create.css @@ -1,6 +1,3 @@ -#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;} @@ -14,7 +11,7 @@ #contentBox {padding: 0; width: 100%;} #contentBox .ke-container {overflow: visible;} -#contentBox .ke-container,#contentBox .contenthtml {border: unset; background: #efefef;} +#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)} diff --git a/module/doc/css/edit.css b/module/doc/css/edit.css index 0863577432..8c7f6a87c8 100644 --- a/module/doc/css/edit.css +++ b/module/doc/css/edit.css @@ -1,3 +1,41 @@ +.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;} +.contenthtml.required:after {right:3px;} +#headerBox {border-bottom: 1px solid #e3e3e3;} +#headerBox td:last-child {padding-right: 24px;} +#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;} + +.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;} +#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;} + #whiteListBox .input-group:last-child {margin-top: 10px;} #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;} diff --git a/module/doc/js/edit.js b/module/doc/js/edit.js index c5c0f24b49..2949390f81 100644 --- a/module/doc/js/edit.js +++ b/module/doc/js/edit.js @@ -1,5 +1,31 @@ $(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'); + + setSavePath(); + $('#modalBasicInfo').on('hide.zui.modal', function(){setSavePath();}); + + $('#saveDraft').click(function() + { + if($('#editorTitle').val() == '') + { + bootbox.alert(titleNotEmpty); + return false; + } + + $('#status').val('draft'); + submit(this); + }); + $('#saveRelease').click(function() + { + $('#status').val('normal'); + submit(this); + }); + setTimeout(function() { if(needUpdateContent && confirm(confirmUpdateContent)) @@ -16,21 +42,6 @@ $(function() $(this).addClass('disabled'); $('form').submit(); }) - toggleAcl($('input[name="acl"]:checked').val(), 'doc'); - $('input[name="type"]').change(function() - { - var type = $(this).val(); - if(type == 'text') - { - $('#contentBox').removeClass('hidden'); - $('#urlBox').addClass('hidden'); - } - else if(type == 'url') - { - $('#contentBox').addClass('hidden'); - $('#urlBox').removeClass('hidden'); - } - }); $('#subNavbar li[data-id="doc"]').addClass('active'); @@ -149,28 +160,25 @@ function loadWhitelist(libID) $.post(userLink, function(users) { - if(users == 'private') + if(users != 'private') { - $('#aclopen').parent('.radio-inline').addClass('hidden'); - $('#aclcustom').parent('.radio-inline').addClass('hidden'); - $('#whiteListBox').addClass('hidden'); - $('#aclprivate').prop('checked', true); - } - else if(users == 'project') - { - $('#aclprivate').parent('.radio-inline').addClass('hidden'); - $('#aclcustom').parent('.radio-inline').addClass('hidden'); - $('#whiteListBox').addClass('hidden'); - $('#aclopen').prop('checked', true); - } - else - { - $('#aclopen').parent('.radio-inline').removeClass('hidden'); - $('#aclcustom').parent('.radio-inline').removeClass('hidden'); - $('#users').replaceWith(users); $('#users').next('.picker').remove(); $('#users').picker(); } }); } + +/** + * Submit form. + * + * @param object $object + * @access public + * @return void + */ +function submit(object) +{ + $(object).attr('type', 'submit'); + $('#dataform').submit(); + setTimeout(function(){$(object).attr('type', 'button').removeAttr('disabled')}, 1000); +} diff --git a/module/doc/model.php b/module/doc/model.php index 1d7e95d0eb..68525ae45a 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -752,6 +752,7 @@ class docModel extends model */ public function create() { + if(!isset($_POST['lib']) and strpos($_POST['module'], '_') !== false) list($_POST['lib'], $_POST['module']) = explode('_', $_POST['module']); $now = helper::now(); $doc = fixer::input('post') ->callFunc('title', 'trim') @@ -763,7 +764,7 @@ class docModel extends model ->add('version', 1) ->setDefault('product,execution,module', 0) ->stripTags($this->config->doc->editor->create['id'], $this->config->allowedTags) - ->cleanInt('product,execution') + ->cleanInt('product,execution,module,lib') ->join('groups', ',') ->join('users', ',') ->join('mailto', ',') @@ -843,6 +844,7 @@ class docModel extends model return false; } + if(!isset($_POST['lib']) and strpos($_POST['module'], '_') !== false) list($_POST['lib'], $_POST['module']) = explode('_', $_POST['module']); $doc = fixer::input('post')->setDefault('module', 0) ->callFunc('title', 'trim') ->stripTags($this->config->doc->editor->edit['id'], $this->config->allowedTags) @@ -853,13 +855,14 @@ class docModel extends model ->setDefault('mailto', '') ->add('editedBy', $this->app->user->account) ->add('editedDate', helper::now()) - ->cleanInt('module') + ->cleanInt('project,product,execution,lib,module') ->join('groups', ',') ->join('users', ',') ->join('mailto', ',') ->remove('comment,files,labels,uid,contactListMenu') ->get(); + if($doc->acl == 'open') $doc->users = $doc->groups = ''; if($doc->type == 'chapter' and $doc->parent) { $parentDoc = $this->dao->select('*')->from(TABLE_DOC)->where('id')->eq((int)$doc->parent)->fetch(); @@ -870,8 +873,6 @@ class docModel extends model } } - if(!empty($doc->acl) and $doc->acl == 'private') $doc->users = $oldDoc->addedBy; - $oldDocContent = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->eq($docID)->andWhere('version')->eq($oldDoc->version)->fetch(); if($oldDocContent) { @@ -891,8 +892,13 @@ class docModel extends model $doc->execution = $lib->execution; } - if(isset($doc->type) and $doc->type == 'url') $doc->content = $doc->url; - unset($doc->url); + $requiredFields = $this->config->doc->edit->requiredFields; + if($doc->status == 'draft') $requiredFields = ''; + if(strpos(",$requiredFields,", ',content,') !== false) + { + $requiredFields = trim(str_replace(',content,', ',', ",$requiredFields,"), ','); + if(isset($doc->content) and empty($doc->content)) return dao::$errors['content'] = sprintf($this->lang->error->notempty, $this->lang->doc->content); + } $files = $this->file->saveUpload('doc', $docID); $changes = common::createChanges($oldDoc, $doc); @@ -903,28 +909,26 @@ class docModel extends model if($change['field'] == 'content' or $change['field'] == 'title') $changed = true; } - $requiredFields = $this->config->doc->edit->requiredFields; - $checkContent = strpos(",$requiredFields,", ',content,') !== false; - if($checkContent) - { - $requiredFields = trim(str_replace(',content,', ',', ",$requiredFields,"), ','); - if(isset($doc->content) and empty($doc->content)) return dao::$errors['content'] = sprintf($this->lang->error->notempty, $this->lang->doc->content); - } - if($changed) { - $doc->version = $oldDoc->version + 1; $docContent = new stdclass(); - $docContent->doc = $docID; $docContent->title = $doc->title; $docContent->content = isset($doc->content) ? $doc->content : ''; - $docContent->version = $doc->version; - $docContent->type = $oldDocContent->type; $docContent->files = $oldDocContent->files; - if(isset($doc->digest)) $docContent->digest = $doc->digest; if($files) $docContent->files .= ',' . join(',', array_keys($files)); $docContent->files = trim($docContent->files, ','); - $this->dao->replace(TABLE_DOCCONTENT)->data($docContent)->exec(); + if(isset($doc->digest)) $docContent->digest = $doc->digest; + if($doc->status == 'draft') + { + $this->dao->update(TABLE_DOCCONTENT)->data($docContent)->where('id')->eq($oldDocContent->id)->exec(); + } + else + { + $doc->version = $oldDoc->version + 1; + $docContent->version = $doc->version; + $docContent->type = $oldDocContent->type; + $this->dao->replace(TABLE_DOCCONTENT)->data($docContent)->exec(); + } } unset($doc->contentType); diff --git a/module/doc/view/createtexttype.html.php b/module/doc/view/createtexttype.html.php index 8a41d5f0cd..8352b10ded 100644 --- a/module/doc/view/createtexttype.html.php +++ b/module/doc/view/createtexttype.html.php @@ -13,6 +13,11 @@ + ' . $lang->doc->createLib, '', 'class="iframe hidden createCustomLib"');?> @@ -22,7 +27,7 @@
| ' . $lang->goback, '', "class='btn btn-secondary' id='backBtn'");?> | +" . $lang->goback, '', "id='backBtn' class='btn btn-secondary'");?> | doc->titlePlaceholder}' id='editorTitle' class='form-control' required");?> | @@ -83,11 +88,11 @@ | ||||||
| doc->libAndModule?> | -+ | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| doc->keywords;?> | -doc->keywordsTips}'");?> | +'>doc->keywordsTips}'");?> | |||||||
| doc->files;?> | diff --git a/module/doc/view/edittexttype.html.php b/module/doc/view/edittexttype.html.php index e7d28b44c4..15f976944d 100644 --- a/module/doc/view/edittexttype.html.php +++ b/module/doc/view/edittexttype.html.php @@ -13,48 +13,10 @@ contentType == 'html') include '../../common/view/kindeditor.html.php';?> contentType == 'markdown') include '../../common/view/markdown.html.php';?> -content != $doc->draft);?> -doc->confirmUpdateContent);?> -id);?> -draft);?> -doc->placeholder);?> - session->docList ? $app->session->docList : $this->createLink('doc', 'objectlibs', "type=$type&objectID=$objectID&libID={$lib->id}&docID={$doc->id}") . "#app={$this->app->tab}";?>|||||||||
| " . $lang->goback, '', "id='backBtn' class='btn btn-secondary'");?> | -title, "placeholder='{$lang->doc->titlePlaceholder}' class='form-control' required");?> | -- + | title, "placeholder='{$lang->doc->titlePlaceholder}'' id='editorTitle' class='form-control' required");?> | ++ status == 'draft'):?> + + doc->saveDraft, "id='saveDraft'", "btn btn-secondary");?> + release->common, "id='saveRelease'", "btn btn-primary");?> + + release->common, "", "btn btn-primary");?> + " . $lang->settings, '', "data-toggle='modal' id='basicInfoLink' class='btn'");?> | |||||