diff --git a/module/doc/config.php b/module/doc/config.php index 12dbf99352..bd3cd15bda 100644 --- a/module/doc/config.php +++ b/module/doc/config.php @@ -13,11 +13,12 @@ $config->doc->create->requiredFields = 'title'; $config->doc->edit->requiredFields = 'title'; $config->doc->editor = new stdclass(); -$config->doc->editor->create = array('id' => 'content,digest', 'tools' => 'fullTools'); -$config->doc->editor->edit = array('id' => 'content,digest,comment', 'tools' => 'fullTools'); +$config->doc->editor->create = array('id' => 'content', 'tools' => 'fullTools'); +$config->doc->editor->edit = array('id' => 'content', 'tools' => 'fullTools'); +$config->doc->editor->view = array('id' => 'comment,lastComment', 'tools' => 'fullTools'); $config->doc->markdown = new stdclass(); -$config->doc->markdown->create = array('id' => 'contentMarkdown,digestMarkdown'); +$config->doc->markdown->create = array('id' => 'contentMarkdown', 'tools' => 'withchange'); $config->doc->search['module'] = 'doc'; $config->doc->search['fields']['title'] = $lang->doc->title; diff --git a/module/doc/control.php b/module/doc/control.php index c380f4fc6d..21162eede7 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -146,6 +146,7 @@ class doc extends control $this->view->browseType = $browseType; $this->view->param = $param; $this->view->type = $type; + $this->view->crumb = $this->doc->getCrumbs($libID, $moduleID); $this->display(); } @@ -297,7 +298,7 @@ class doc extends control } else { - $this->doc->setMenu($this->libs, $libID); + $this->doc->setMenu($this->libs, $libID, $type); } $libs = $this->libs; @@ -332,21 +333,24 @@ class doc extends control * @access public * @return void */ - public function edit($docID) + public function edit($docID, $comment = false) { if(!empty($_POST)) { - $result = $this->doc->update($docID); - if(dao::isError()) die(js::error(dao::getError())); - $changes = $result['changes']; - $files = $result['files']; + if($comment == false) + { + $result = $this->doc->update($docID); + if(dao::isError()) die(js::error(dao::getError())); + $changes = $result['changes']; + $files = $result['files']; + } if($this->post->comment != '' or !empty($changes) or !empty($files)) { $action = !empty($changes) ? 'Edited' : 'Commented'; $fileAction = ''; if(!empty($files)) $fileAction = $this->lang->addFiles . join(',', $files) . "\n" ; $actionID = $this->action->create('doc', $docID, $action, $fileAction . $this->post->comment); - $this->action->logHistory($actionID, $changes); + if(!empty($changes)) $this->action->logHistory($actionID, $changes); } die(js::locate($this->createLink('doc', 'view', "docID=$docID"), 'parent')); } @@ -355,16 +359,12 @@ class doc extends control $doc = $this->doc->getById($docID); $libID = $doc->lib; - if($doc->type == 'markdown') - { - $this->config->doc->markdown->edit = array('id' => 'content,digest'); - $this->config->doc->editor->edit['id'] = 'comment'; - } + if($doc->contentType == 'markdown') $this->config->doc->markdown->edit = array('id' => 'content', 'tools' => 'toolbar'); $lib = $this->doc->getLibByID($libID); $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); $this->libs = $this->doc->getLibs($type); - $this->doc->setMenu($this->libs, $libID); + $this->doc->setMenu($this->libs, $libID, $type); $this->view->title = $this->libs[$libID] . $this->lang->colon . $this->lang->doc->edit; $this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$libID"), $this->libs[$libID]); @@ -392,7 +392,7 @@ class doc extends control $doc = $this->doc->getById($docID, $version, true); if(!$doc) die(js::error($this->lang->notFound) . js::locate('back')); - if($doc->type == 'markdown') + if($doc->contentType == 'markdown') { $hyperdown = $this->app->loadClass('hyperdown'); $doc->content = $hyperdown->makeHtml($doc->content); @@ -419,6 +419,7 @@ class doc extends control $this->view->users = $this->user->getPairs('noclosed,noletter'); $this->view->preAndNext = $this->loadModel('common')->getPreAndNextObject('doc', $docID); $this->view->keTableCSS = $this->doc->extractKETableCSS($doc->content); + $this->view->crumb = $this->doc->getCrumbs($lib->id, $doc->module, $docID); $this->display(); } @@ -651,7 +652,7 @@ class doc extends control * @access public * @return void */ - public function allLibs($type, $extra = '', $recTotal = 0, $recPerPage = 21, $pageID = 1) + public function allLibs($type, $extra = '', $recTotal = 0, $recPerPage = 30, $pageID = 1) { $libName = isset($this->lang->doc->systemLibs[$type]) ? $this->lang->doc->systemLibs[$type] : $this->lang->doc->custom; $this->doc->setMenu(array($this->lang->doclib->select), 0, $type); diff --git a/module/doc/css/alllibs.css b/module/doc/css/alllibs.css new file mode 100644 index 0000000000..e4ef269299 --- /dev/null +++ b/module/doc/css/alllibs.css @@ -0,0 +1,2 @@ +#libs table td{border-right:1px solid #ddd; width:33%;vertical-align: top; padding:0px; overflow:hidden} +#libs table td.none{border-right:0px} diff --git a/module/doc/css/common.css b/module/doc/css/common.css index 8c4221d2a7..a7ca68c663 100644 --- a/module/doc/css/common.css +++ b/module/doc/css/common.css @@ -1,20 +1,9 @@ -.outer{overflow:auto} -.libs-heading {display: block; margin: 10px 0; background: #f1f1f1; color: #808080; position: relative;} -.libs-heading-text {display: inline-block; padding: 8px 12px; font-weight: bold; color: #2e6dad} -.libs-heading:hover {background-color: #EBF2F9} -.libs-heading:hover .libs-heading-text {background-color: #2e6dad; color: #fff} -.libs-heading > .icon {display: block; right: 0; top: 0; bottom: 0; position: absolute; line-height: 33px; width: 34px; text-align: center; opacity: .6} -.libs-heading:hover > .icon {opacity: 1} -.libs-group-heading {color: #808080; margin: 10px 0} -.libs {margin-bottom: 15px;} -.libs.collapsed .libs-group, -.libs.collapsed .libs-group-heading {display: none} -.libs.collapsed .libs-heading {background: #ddd;} -.libs.collapsed .libs-heading > .icon {opacity: 1} -.libs.collapsed .libs-heading > .icon:before {content: '\e726'} -.lib {float: left; display: block; margin: 0 15px 0 0; padding: 10px 15px; text-align: center; color: #333; border-radius: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;} +.libs-group-heading {color: #808080; border-bottom:1px solid #ddd; padding:8px; text-align:center; background:#DDF3F5} +.libs-group{padding:10px 10px 10px 10px;} +.lib {float: left; display: block; width:80px; padding: 5px; margin:0px 3px; text-align: center; color: #333; overflow: hidden; text-overflow: ellipsis;} +.lib .file-icon{font-size:30px;} +.lib .lib-name{height: 2em; line-height: 14px; overflow: hidden;} .lib:hover, .lib:focus, .lib:active {border-color: #2e6dad; background-color: #EBF2F9; color: #2e6dad} -.col-md-4{overflow:hidden;} #modulemenu .nav > li > .dropdown > a#libType{display:inline-block;} #modulemenu .nav > li > .dropdown.open > a#libType{background:#e5e5e5;} diff --git a/module/doc/css/index.css b/module/doc/css/index.css index 5c6fb03f22..fefdad17d7 100644 --- a/module/doc/css/index.css +++ b/module/doc/css/index.css @@ -1 +1,9 @@ .lib-heading{border-right:1px solid #ddd;} +#libs table td.row{padding:0px;} +#libs table td.lib-more{border-left:1px solid #ddd;} +.table.project,.table.product{border:0px;} +.table.project tbody td,.table.product tbody td{border-right:1px solid #ddd; width:33.3%;vertical-align: top; padding:0px;} +.table.project tbody tr > td:first-child,.table.product tbody tr > td:first-child{padding:0px;} +.table.project tbody tr > td:last-child,.table.product tbody tr > td:last-child{padding:0px;} +.table.project td:last-child,.table.product td:last-child{border-right:0px;} +.table.project tbody > tr:last-child td,.table.product tbody > tr:last-child td{border-bottom:0px;} diff --git a/module/doc/css/showfiles.css b/module/doc/css/showfiles.css index 015c99f131..0aca702f2d 100644 --- a/module/doc/css/showfiles.css +++ b/module/doc/css/showfiles.css @@ -11,6 +11,9 @@ .lib-file .card-heading > .icon-download {opacity: .5; position: relative; top: 2px} .lib-file .card-heading {color: #114f8e} .lib-file .card-heading:hover {background-color: #EBF2F9; color: #2e6dad} +.lib-file .card-heading > .delete {opacity: 0; margin-top:-1px; margin-right:5px} +.lib-file .card-heading > .delete .icon{font-size:16px;} +.lib-file .card-heading:hover > .delete{opacity:1} .lib-file .media-wrapper > .icon-holder {font-size: 105px; opacity: 1; color: rgba(255,255,255,.7); opacity: .6} .lib-file .media-wrapper > .icon-holder.icon-file {background-color: #999} .lib-file .media-wrapper > .icon-holder.icon-file-archive {background-color: #8666B8} diff --git a/module/doc/css/view.css b/module/doc/css/view.css index 4f675fa44a..aed9210f73 100644 --- a/module/doc/css/view.css +++ b/module/doc/css/view.css @@ -1 +1 @@ -#url-content{v:expressio !important} +#titlebar > .heading > strong.crumb > i.icon-angle-right{display:inline;} diff --git a/module/doc/js/create.js b/module/doc/js/create.js index 2fec7a1e24..2d75e6ebaa 100644 --- a/module/doc/js/create.js +++ b/module/doc/js/create.js @@ -1,22 +1,37 @@ $(function() { toggleAcl($('#acl').val()); - window.editor['content'].addListener('focus', function() - { - this.ui.setFullScreen(true); - }); - $('#type').change(function() + $('input[name="type"]').change(function() { var type = $(this).val(); - if(type == 'html') + if(type == 'text') { - $('.contenthtml').removeClass('hidden'); - $('.contentmarkdown').addClass('hidden'); + $('#contentBox').removeClass('hidden'); + $('#urlBox').addClass('hidden'); } - else if(type == 'markdown') + else if(type == 'url') { - $('.contenthtml').addClass('hidden'); - $('.contentmarkdown').removeClass('hidden'); + $('#contentBox').addClass('hidden'); + $('#urlBox').removeClass('hidden'); } }) + window.editor['content'].addListener('ready', function() + { + $('div#content .edui-toolbar').append("
"); + }); }) + +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); +} diff --git a/module/doc/js/edit.js b/module/doc/js/edit.js index 0e1125fd96..fd0b5cb41c 100644 --- a/module/doc/js/edit.js +++ b/module/doc/js/edit.js @@ -1,11 +1,18 @@ $(function() { toggleAcl($('#acl').val()); - if(typeof(window.editor['content']) != 'undefined') + $('input[name="type"]').change(function() { - window.editor['content'].addListener('focus', function() + var type = $(this).val(); + if(type == 'text') { - this.ui.setFullScreen(true); - }); - } + $('#contentBox').removeClass('hidden'); + $('#urlBox').addClass('hidden'); + } + else if(type == 'url') + { + $('#contentBox').addClass('hidden'); + $('#urlBox').removeClass('hidden'); + } + }) }) diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 5809403cf6..4d59882e34 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -73,7 +73,7 @@ $lang->doc->libTypeList['custom'] = 'Custom library'; $lang->doc->systemLibs['product'] = "{$lang->productCommon} doc"; $lang->doc->systemLibs['project'] = "{$lang->projectCommon} doc"; -$lang->doc->aclList['public'] = 'Public'; +$lang->doc->aclList['open'] = 'Public'; $lang->doc->aclList['custom'] = 'Custom'; $lang->doc->aclList['private'] = 'Private'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 2776824f17..5b4eaa9e2b 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -49,6 +49,8 @@ $lang->doc->browse = '文档列表'; $lang->doc->view = '文档详情'; $lang->doc->diff = '对比'; $lang->doc->manageType = '维护分类'; +$lang->doc->editType = '编辑分类'; +$lang->doc->deleteType = '删除分类'; $lang->doc->addType = '增加分类'; $lang->doc->libName = '文档库名称'; @@ -73,7 +75,7 @@ $lang->doc->libTypeList['custom'] = '自定义文档库'; $lang->doc->systemLibs['product'] = $lang->productCommon . '文档库'; $lang->doc->systemLibs['project'] = $lang->projectCommon . '文档库'; -$lang->doc->aclList['public'] = '公开'; +$lang->doc->aclList['open'] = '公开'; $lang->doc->aclList['custom'] = '自定义'; $lang->doc->aclList['private'] = '私有'; diff --git a/module/doc/model.php b/module/doc/model.php index 1bab2e47a9..d73366d0a3 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -84,7 +84,14 @@ class docModel extends model { if($type == 'product' or $type == 'project') { - $stmt = $this->dao->select('*')->from(TABLE_DOCLIB)->where($type)->ne(0)->andWhere('deleted')->eq(0)->orderBy('id desc')->query(); + $table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $stmt = $this->dao->select('t1.*')->from(TABLE_DOCLIB)->alias('t1') + ->leftJoin($table)->alias('t2')->on("t1.$type=t2.id") + ->where("t1.$type")->ne(0) + ->andWhere('t1.deleted')->eq(0) + ->orderBy("t2.order desc, t1.id") + ->query(); + $objects = $this->dao->select('id,name')->from($table)->where('deleted')->eq('0')->fetchPairs('id', 'name'); } else { @@ -94,7 +101,12 @@ class docModel extends model $libPairs = array(); while($lib = $stmt->fetch()) { - if($this->checkPriv($lib)) $libPairs[$lib->id] = $lib->name; + if($this->checkPriv($lib)) + { + $libName = $lib->name; + if(($type == 'product' or $type == 'project') and $lib->main == 0 and isset($objects[$lib->$type])) $libName = $objects[$lib->$type] . ' / ' . $libName; + $libPairs[$lib->id] = $libName; + } } return $libPairs; } @@ -289,10 +301,10 @@ class docModel extends model $this->dao->update(TABLE_DOC)->set('version')->eq($doc->version)->where('id')->eq($doc->id)->exec(); } - $doc->title = isset($docContent->title) ? $docContent->title : ''; - $doc->digest = isset($docContent->digest) ? $docContent->digest : ''; - $doc->content = isset($docContent->content) ? $docContent->content : ''; - $doc->type = isset($docContent->type) ? $docContent->type : ''; + $doc->title = isset($docContent->title) ? $docContent->title : ''; + $doc->digest = isset($docContent->digest) ? $docContent->digest : ''; + $doc->content = isset($docContent->content) ? $docContent->content : ''; + $doc->contentType = isset($docContent->type) ? $docContent->type : ''; if($setImgSize) $doc->content = $this->loadModel('file')->setImgSize($doc->content); $doc->files = $docFiles; @@ -336,23 +348,22 @@ class docModel extends model $doc = $this->loadModel('file')->processEditor($doc, $this->config->doc->editor->create['id'], $this->post->uid); $doc->product = $lib->product; $doc->project = $lib->project; + if($doc->type == 'url') + { + $doc->content = $doc->url; + $doc->contentType = 'html'; + } $docContent = new stdclass(); $docContent->title = $doc->title; - $docContent->digest = $doc->type == 'html' ? $doc->digest : $doc->digestMarkdown; - $docContent->content = $doc->type == 'html' ? $doc->content : $doc->contentMarkdown; - $docContent->type = $doc->type; + $docContent->content = $doc->contentType == 'html' ? $doc->content : $doc->contentMarkdown; + $docContent->type = $doc->contentType; $docContent->version = 1; - if($doc->type == 'markdown') - { - $docContent->content = str_replace('>', '>', $docContent->content); - $docContent->digest = str_replace('>', '>', $docContent->digest); - } - unset($doc->digest); - unset($doc->digestMarkdown); + if($doc->contentType == 'markdown') $docContent->content = str_replace('>', '>', $docContent->content); unset($doc->content); unset($doc->contentMarkdown); - unset($doc->type); + unset($doc->contentType); + unset($doc->url); $this->dao->insert(TABLE_DOC)->data($doc)->autoCheck() ->batchCheck($this->config->doc->create->requiredFields, 'notempty') @@ -392,16 +403,14 @@ class docModel extends model ->remove('comment,files,labels,uid') ->get(); if($doc->acl == 'private') $doc->users = $oldDoc->addedBy; - if($oldDoc->type == 'markdown') - { - $doc->content = str_replace('>', '>', $doc->content); - $doc->digest = str_replace('>', '>', $doc->digest); - } + if($oldDoc->contentType == 'markdown') $doc->content = str_replace('>', '>', $doc->content); $lib = $this->getLibByID($doc->lib); $doc = $this->loadModel('file')->processEditor($doc, $this->config->doc->editor->edit['id'], $this->post->uid); $doc->product = $lib->product; $doc->project = $lib->project; + if($doc->type == 'url') $doc->content = $doc->url; + unset($doc->url); $files = $this->file->saveUpload('doc', $docID); $changes = common::createChanges($oldDoc, $doc); @@ -409,7 +418,7 @@ class docModel extends model if($files) $changed = true; foreach($changes as $change) { - if($change['field'] == 'content' or $change['field'] == 'title' or $change['field'] == 'digest') $changed = true; + if($change['field'] == 'content' or $change['field'] == 'title') $changed = true; } if($changed) @@ -419,7 +428,6 @@ class docModel extends model $docContent = new stdclass(); $docContent->doc = $docID; $docContent->title = $doc->title; - $docContent->digest = $doc->digest; $docContent->content = $doc->content; $docContent->version = $doc->version; $docContent->type = $oldDocContent->type; @@ -428,8 +436,8 @@ class docModel extends model $docContent->files = trim($docContent->files, ','); $this->dao->insert(TABLE_DOCCONTENT)->data($docContent)->exec(); } - unset($doc->digest); unset($doc->content); + unset($doc->contentType); $this->dao->update(TABLE_DOC)->data($doc) ->autoCheck() @@ -582,7 +590,7 @@ class docModel extends model */ public function checkPriv($object) { - if($object->acl == 'public') return true; + if($object->acl == 'open') return true; $account = ',' . $this->app->user->account . ','; if(strpos($this->app->company->admins, $account) !== false) return true; @@ -713,7 +721,7 @@ class docModel extends model */ public function getSubLibGroups($type, $idList) { - $libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('id desc')->fetchGroup($type, 'id'); + $libGroups = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->in($idList)->orderBy('id')->fetchGroup($type, 'id'); if($type == 'product') { $hasProject = $this->dao->select('DISTINCT product')->from(TABLE_PROJECTPRODUCT)->alias('t1') @@ -821,7 +829,7 @@ class docModel extends model $account = ',' . $this->app->user->account . ','; if(strpos($this->app->company->admins, $account) === false) { - $condition .= "{$table}acl='public'"; + $condition .= "{$table}acl='open'"; $condition .= " OR ({$table}acl='private' and {$table}users='{$this->app->user->account}')"; $condition .= " OR ({$table}acl='custom' and ("; foreach($this->app->user->groups as $groupID) $condition .= "(CONCAT(',', {$table}groups, ',') like '%,$groupID,%') OR "; @@ -1065,4 +1073,34 @@ class docModel extends model return array($showNumber, $action, 'number' => $showNumber, 'action' => $action); } + + /** + * Get crumbs. + * + * @param int $libID + * @param int $moduleID + * @param int $docID + * @access public + * @return string + */ + public function getCrumbs($libID, $moduleID = 0, $docID = 0) + { + $lib = $this->getLibById($libID); + $parents = $moduleID ? $this->loadModel('tree')->getParents($moduleID) : array(); + $doc = $docID ? $this->getById($docID) : array(); + $type = $lib->product ? 'product' : ($lib->project ? 'project' : 'custom'); + $objectName = ''; + if($type != 'custom' and empty($lib->main)) + { + $table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $objectName = $this->dao->select('name')->from($table)->where('id')->eq($lib->$type)->fetch('name'); + } + $crumb = ''; + if($objectName) $crumb .= $objectName . $this->lang->arrow; + $crumb .= html::a(helper::createLink('doc', 'browse', "libID=$libID"), $lib->name); + foreach($parents as $module) $crumb .= $this->lang->arrow . html::a(helper::createLink('doc', 'browse', "libID=$libID&browseType=byModule¶m=$module->id"), $module->name); + if($doc) $crumb .= $this->lang->arrow . $doc->title; + + return $crumb; + } } diff --git a/module/doc/view/alllibs.html.php b/module/doc/view/alllibs.html.php index 79e6523ea7..d51d2998b0 100644 --- a/module/doc/view/alllibs.html.php +++ b/module/doc/view/alllibs.html.php @@ -12,15 +12,15 @@ ?>| "?>
-
- '> name?>
+ "?>
+
+ |
- "?>
+ "?>
+ name?>
id] as $subLibID => $subLibName):?>
id");
else $libLink = inlink('browse', "libID=$subLibID");
?>
-
+
+
+
+
-
+ | ";
+ $i++;
+ }
+ echo "";
+ }
+ ?>