* Code for story #43645,43646.

This commit is contained in:
tianshujie
2023-04-13 11:19:28 +08:00
parent 40e2ae98d5
commit 22f4b33a66
3 changed files with 72 additions and 73 deletions
+33 -51
View File
@@ -386,11 +386,6 @@ class docModel extends model
$allLibIDList = array_keys($allLibs);
$hasPrivDocIdList = $this->getPrivDocs(0, $moduleID);
$files = $this->dao->select('*')->from(TABLE_FILE)
->where('objectType')->eq('doc')
->andWhere('objectID')->in($hasPrivDocIdList)
->fetchGroup('objectID');
if($browseType == "all")
{
$docs = $this->getDocs(0, 0, $browseType, $sort, $pager);
@@ -422,13 +417,14 @@ class docModel extends model
->andWhere('actor')->eq($this->app->user->account)
->andWhere('action')->eq('edited')
->fetchAll('objectID');
$docs = $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
$docs = $this->dao->select('t1.*, t2.name as libName, t2.type as objectType')->from(TABLE_DOC)->alias('t1')
->leftJoin(TABLE_DOCLIB)->alias('t2')->on("t1.lib=t2.id")
->where('t1.deleted')->eq(0)
->andWhere($query)
->andWhere('lib')->in($allLibIDList)
->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi()
->andWhere('addedBy', 1)->eq($this->app->user->account)
->orWhere('id')->in(array_keys($docIDList))
->andWhere('t1.lib')->in($allLibIDList)
->beginIF($this->config->doc->notArticleType)->andWhere('t1.type')->notIN($this->config->doc->notArticleType)->fi()
->andWhere('t1.addedBy', 1)->eq($this->app->user->account)
->orWhere('t1.id')->in(array_keys($docIDList))
->markRight(1)
->orderBy($sort)
->page($pager)
@@ -436,12 +432,13 @@ class docModel extends model
}
elseif($browseType == "openedbyme")
{
$docs = $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
->andWhere('lib')->in($allLibIDList)
->andWhere('id')->in($hasPrivDocIdList)
->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi()
->andWhere('addedBy')->eq($this->app->user->account)
$docs = $this->dao->select('t1.*, t2.name as libName, t2.type as objectType')->from(TABLE_DOC)->alias('t1')
->leftJoin(TABLE_DOCLIB)->alias('t2')->on("t1.lib=t2.id")
->where('t1.deleted')->eq(0)
->andWhere('t1.lib')->in($allLibIDList)
->andWhere('t1.id')->in($hasPrivDocIdList)
->beginIF($this->config->doc->notArticleType)->andWhere('t1.type')->notIN($this->config->doc->notArticleType)->fi()
->andWhere('t1.addedBy')->eq($this->app->user->account)
->orderBy($sort)
->page($pager)
->fetchAll('id');
@@ -454,11 +451,13 @@ class docModel extends model
->andWhere('objectID')->in($hasPrivDocIdList)
->andWhere('action')->eq('edited')
->fetchAll('objectID');
$docs = $this->dao->select('*')->from(TABLE_DOC)
->where('deleted')->eq(0)
->andWhere('id')->in(array_keys($docIDList))
->andWhere('lib')->in($allLibIDList)
->beginIF($this->config->doc->notArticleType)->andWhere('type')->notIN($this->config->doc->notArticleType)->fi()
$docs = $this->dao->select('t1.*, t2.name as libName, t2.type as objectType')->from(TABLE_DOC)->alias('t1')
->leftJoin(TABLE_DOCLIB)->alias('t2')->on("t1.lib=t2.id")
->where('t1.deleted')->eq(0)
->andWhere('t1.id')->in(array_keys($docIDList))
->andWhere('t1.lib')->in($allLibIDList)
->beginIF($this->config->doc->notArticleType)->andWhere('t1.type')->notIN($this->config->doc->notArticleType)->fi()
->orderBy($sort)
->page($pager)
->fetchAll('id');
@@ -490,44 +489,27 @@ class docModel extends model
if(empty($docs)) return array();
/* Get projects, executions and products by docIdList. */
$docContents = $this->dao->select('*')->from(TABLE_DOCCONTENT)->where('doc')->in(array_keys($docs))->orderBy('version,doc')->fetchAll('doc');
foreach($docs as $index => $doc)
if(in_array($browseType, array('bySearch', 'openedbyme', 'editedbyme')))
{
$docs[$index]->fileSize = 0;
if(isset($files[$index]))
$objects = array();
list($objects['project'], $objects['execution'], $objects['product']) = $this->getObjectsByDoc(array_keys($docs));
foreach($docs as $docID => $doc)
{
$docContent = $docContents[$index];
$fileSize = 0;
foreach($files[$index] as $file)
$doc->objectID = zget($doc, $doc->objectType, 0);
$doc->objectName = '';
if(isset($objects[$doc->objectType]))
{
if(strpos(",{$docContent->files},", ",{$file->id},") === false) continue;
$fileSize += $file->size;
}
if($fileSize < 1024)
{
$fileSize .= 'B';
}
elseif($fileSize < 1024 * 1024)
{
$fileSize = round($fileSize / 1024, 2) . 'KB';
}
elseif($fileSize < 1024 * 1024 * 1024)
{
$fileSize = round($fileSize / 1024 / 1024, 2) . 'MB';
$doc->objectName = $objects[$doc->objectType][$doc->objectID];
}
else
{
$fileSize = round($fileSize / 1024 / 1024 / 1024, 2) . 'G';
if($doc->objectType == 'mine') $doc->objectName = $this->lang->doc->person;
if($doc->objectType == 'custom') $doc->objectName = $this->lang->doc->team;
}
$docs[$index]->fileSize = $fileSize;
}
}
$docs = $this->processCollector($docs);
return $docs;
return $this->processCollector($docs);
}
/**
@@ -1092,7 +1074,7 @@ class docModel extends model
$products = $this->product->getPairs();
$this->config->doc->search['params']['project']['values'] = array('' => '') + $this->loadModel('project')->getPairsByProgram('', 'all', false, 'order_asc', 'kanban') + array('all' => $this->lang->doc->allProjects);
$this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs(0, 'sprint,stage', 'multiple,leaf,noprefix') + array('all' => $this->lang->doc->allExecutions);
$this->config->doc->search['params']['execution']['values'] = array('' => '') + $this->loadModel('execution')->getPairs(0, 'sprint,stage', 'multiple,leaf,noprefix,withobject') + array('all' => $this->lang->doc->allExecutions);
$this->config->doc->search['params']['lib']['values'] = array('' => '') + $this->loadModel('doc')->getLibs('all', 'withObject') + array('all' => $this->lang->doclib->all);
$this->config->doc->search['params']['product']['values'] = array('' => '') + $products + array('all' => $this->lang->doc->allProduct);
+10 -1
View File
@@ -1,2 +1,11 @@
body {margin-bottom: 25px;}
.fullscreen-close {top: 8px !important;}
.btn.ajaxCollect > img {width: 20px;}
#docList.table .c-name > .ajaxCollect {float: right; position: relative; right: 10px; top: 0px;}
#docList th.c-id {width: 72px;}
#docList th.c-user {width: 80px;}
#docList th.c-actions {width: 84px; padding-left: 15px;}
#docList .c-object {width: 120px; overflow: hidden; white-space: nowrap; text-overflow: clip;}
#docList.table .c-name > .doc-title {display: inline-block; max-width: calc(100% - 80px); overflow: hidden; background: transparent; padding-right:0px;}
#docList.table .c-name > span.doc-title {line-height: 0; vertical-align: inherit;}
#docList.table .c-name > .draft {background-color:rgba(129, 102, 238, 0.12); color:#8166EE;}
#docList .btn {padding: 0 2px;}
+29 -21
View File
@@ -34,23 +34,22 @@
</div>
<?php else:?>
<div class="cell<?php if($type == 'bySearch') echo ' show';?>" id="queryBox" data-module=<?php echo 'contributeDoc';?>></div>
<form id='projectForm' class="main-table" method='post' data-ride='table' data-checkable='false'>
<form id='docForm' class="main-table" method='post' data-ride='table'>
<table class='table table-fixed' id='docList'>
<thead>
<tr>
<th class="c-id"><?php echo $lang->doc->id;?></th>
<th class="c-name"><?php echo $lang->doc->title;?></th>
<th class="c-name c-object"><?php echo $lang->doc->object;?></th>
<th class="c-num"><?php echo $lang->doc->size;?></th>
<th class="c-object"><?php echo $lang->doc->object;?></th>
<?php if($type != 'openedbyme'):?>
<th class="c-user"><?php echo $lang->doc->addedByAB;?></th>
<?php endif;?>
<th class="c-datetime"><?php echo $lang->doc->addedDate;?></th>
<th class="c-date"><?php echo $lang->doc->addedDate;?></th>
<?php if($type == 'openedbyme'):?>
<th class="c-user"><?php echo $lang->doc->lastEditedBy;?></th>
<th class="c-user"><?php echo $lang->doc->editedBy;?></th>
<?php endif;?>
<th class="c-datetime"><?php echo $lang->doc->editedDate;?></th>
<th class="c-actions-3 text-center"><?php echo $lang->actions;?></th>
<th class="c-date"><?php echo $lang->doc->editedDate;?></th>
<th class="c-actions"><?php echo $lang->actions;?></th>
</tr>
</thead>
<tbody id='docTableList'>
@@ -59,29 +58,38 @@
<?php $collectTitle = strpos($doc->collector, ',' . $this->app->user->account . ',') !== false ? $lang->doc->cancelCollection : $lang->doc->collect;?>
<tr>
<td class="c-id"><?php echo $doc->id;?></td>
<td class="c-name"><?php echo html::a($this->createLink('doc', 'view', "docID=$doc->id&version=0&from={$lang->navGroup->doc}", '', true), "<i class='icon icon-file-text text-muted'></i> &nbsp;" . $doc->title, '', "title='{$doc->title}' class='iframe' data-width='90%'");?></td>
<td class='c-name'>
<?php if(!empty($doc->objectType)):?>
<?php echo $lang->{$doc->objectType}->common . ' : ';?>
<a title='<?php echo $doc->objectName;?>' href='<?php echo $this->createLink($doc->objectType, 'view', "objectID=$doc->objectID");?>' data-app="<?php echo $doc->objectType;?>">
<?php echo $doc->objectName;?>
</a>
<?php endif;?>
<td class="c-name" title='<?php echo $doc->title;?>'>
<?php
$docType = $doc->type == 'text' ? 'wiki-file' : $doc->type;
$icon = html::image("static/svg/{$docType}.svg", "class='file-icon'");
if(common::hasPriv('doc', 'view'))
{
echo html::a($this->createLink('doc', 'view', "docID=$doc->id"), $icon . $doc->title, '', "title='{$doc->title}' class='doc-title' data-app='doc'");
}
else
{
echo "<span class='doc-title'>$icon {$doc->title}</span>";
}
?>
<?php if($doc->status == 'draft') echo "<span class='label label-badge draft'>{$lang->doc->draft}</span>";?>
<?php if(common::canBeChanged('doc', $doc) and common::hasPriv('doc', 'collect')):?>
<a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$doc->id&objectType=doc");?>" title="<?php echo $collectTitle;?>" class='btn btn-link ajaxCollect'><?php echo html::image("static/svg/{$star}.svg", "class='$star'");?></a>
<?php endif;?>
</td>
<td class="c-object" title='<?php echo $doc->objectName;?>'>
<?php $objectIcon = zget($config->doc->objectIconList, $doc->objectType);?>
<?php echo "<i class='icon $objectIcon'></i> " . $doc->objectName;?>
</td>
<td class="c-num"><?php echo $doc->fileSize ? $doc->fileSize : '-';?></td>
<?php if($type != 'openedbyme'):?>
<td class="c-user"><?php echo zget($users, $doc->addedBy);?></td>
<?php endif;?>
<td class="c-datetime"><?php echo formatTime($doc->addedDate, 'y-m-d');?></td>
<td class="c-date"><?php echo formatTime($doc->addedDate, 'Y-m-d');?></td>
<?php if($type == 'openedbyme'):?>
<td class="c-user"><?php echo zget($users, $doc->editedBy);?></td>
<?php endif;?>
<td class="c-datetime"><?php echo formatTime($doc->editedDate, 'y-m-d');?></td>
<td class="c-date"><?php echo formatTime($doc->editedDate, 'Y-m-d');?></td>
<td class="c-actions">
<?php if(common::canBeChanged('doc', $doc)):?>
<?php if(common::hasPriv('doc', 'collect')):?>
<a data-url="<?php echo $this->createLink('doc', 'collect', "objectID=$doc->id&objectType=doc");?>" title="<?php echo $collectTitle;?>" class='btn btn-link ajaxCollect'><?php echo html::image("static/svg/{$star}.svg");?></a>
<?php endif;?>
<?php common::printLink('doc', 'edit', "docID=$doc->id&comment=false&from={$lang->navGroup->doc}", "<i class='icon icon-edit'></i>", '', "title='{$lang->edit}' class='btn btn-link' data-app='doc'", true, false)?>
<?php common::printLink('doc', 'delete', "docID=$doc->id&confirm=no&from={$lang->navGroup->doc}", "<i class='icon icon-trash'></i>", 'hiddenwin', "title='{$lang->delete}' class='btn btn-link'")?>
<?php endif;?>