* finish task #2674.
This commit is contained in:
+30
-2
@@ -519,7 +519,7 @@ class doc extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function allLibs($type, $extra = '', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
public function allLibs($type, $extra = '', $recTotal = 0, $recPerPage = 21, $pageID = 1)
|
||||
{
|
||||
$libName = isset($this->lang->doc->systemLibs[$type]) ? $this->lang->doc->systemLibs[$type] : $this->lang->doc->custom;
|
||||
$this->doc->setMenu(array($libName), 0, $type);
|
||||
@@ -533,7 +533,7 @@ class doc extends control
|
||||
|
||||
$libs = $this->doc->getAllLibs($type, $pager, $extra);
|
||||
$subLibs = array();
|
||||
if($type == 'product' or $type == 'project') $subLibs = $this->doc->getSubLibGroups($type, array_keys($libs), $limit = 0);
|
||||
if($type == 'product' or $type == 'project') $subLibs = $this->doc->getSubLibGroups($type, array_keys($libs));
|
||||
|
||||
$this->view->type = $type;
|
||||
$this->view->libs = $libs;
|
||||
@@ -564,4 +564,32 @@ class doc extends control
|
||||
$this->view->libs = $this->doc->getLibsByObject($type, $objectID);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show files for product or project.
|
||||
*
|
||||
* @param int $type
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function showFiles($type, $objectID)
|
||||
{
|
||||
$uri = $this->app->getURI(true);
|
||||
$this->app->session->set('taskList', $uri);
|
||||
$this->app->session->set('storyList', $uri);
|
||||
$this->app->session->set('docList', $uri);
|
||||
|
||||
$table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT;
|
||||
$object = $this->dao->select('id,name')->from($table)->where('id')->eq($objectID)->fetch();
|
||||
$this->doc->setMenu(array($this->lang->doclib->files), 0, $type);
|
||||
|
||||
$this->view->title = $object->name;
|
||||
$this->view->position[] = $object->name;
|
||||
|
||||
$this->view->type = $type;
|
||||
$this->view->object = $object;
|
||||
$this->view->files = $this->doc->getLibFiles($type, $objectID);
|
||||
$this->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.card a.file{display:block; text-align:center;}
|
||||
.card a.file i.icon{display:block; font-size:61px; margin:10px}
|
||||
@@ -30,6 +30,7 @@ $lang->doc->editedBy = '由谁编辑';
|
||||
$lang->doc->editedDate = '编辑时间';
|
||||
$lang->doc->basicInfo = '基本信息';
|
||||
$lang->doc->deleted = '已删除';
|
||||
$lang->doc->fileObject = '所属对象';
|
||||
|
||||
$lang->doc->moduleDoc = '按模块浏览';
|
||||
$lang->doc->searchDoc = '搜索';
|
||||
@@ -82,3 +83,4 @@ $lang->doclib->name = '文档库名称';
|
||||
$lang->doclib->acl = '文档库权限';
|
||||
$lang->doclib->group = '分组';
|
||||
$lang->doclib->user = '用户';
|
||||
$lang->doclib->files = '附件库';
|
||||
|
||||
+42
-3
@@ -560,7 +560,8 @@ class docModel extends model
|
||||
$buildGroups = array();
|
||||
foreach($libGroups as $objectID => $libs)
|
||||
{
|
||||
$i = 1;
|
||||
$i = common::hasPriv('doc', 'showFiles') ? 2 : 1;
|
||||
if($type == 'product' and isset($hasProject[$objectID]) and common::hasPriv('doc', 'allLibs')) $i += 1;
|
||||
foreach($libs as $lib)
|
||||
{
|
||||
if($limit and $i > $limit) break;
|
||||
@@ -570,7 +571,8 @@ class docModel extends model
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if($type == 'product' and isset($hasProject[$objectID])) $buildGroups[$objectID]['project'] = $this->lang->doc->systemLibs['project'];
|
||||
if($type == 'product' and isset($hasProject[$objectID]) and common::hasPriv('doc', 'allLibs')) $buildGroups[$objectID]['project'] = $this->lang->doc->systemLibs['project'];
|
||||
if(common::hasPriv('doc', 'showFiles')) $buildGroups[$objectID]['files'] = $this->lang->doclib->files;
|
||||
}
|
||||
|
||||
return $buildGroups;
|
||||
@@ -600,8 +602,45 @@ class docModel extends model
|
||||
{
|
||||
if($this->checkPriv($lib)) $libs[$lib->id] = $lib->name;
|
||||
}
|
||||
if($type == 'product' and isset($hasProject[$objectID])) $libs['project'] = $this->lang->doc->systemLibs['project'];
|
||||
if($type == 'product' and isset($hasProject[$objectID]) and common::hasPriv('doc', 'allLibs')) $libs['project'] = $this->lang->doc->systemLibs['project'];
|
||||
if(common::hasPriv('doc', 'showFiles')) $libs['files'] = $this->lang->doclib->files;
|
||||
|
||||
return $libs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lib files.
|
||||
*
|
||||
* @param string $type
|
||||
* @param int $objectID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getLibFiles($type, $objectID)
|
||||
{
|
||||
$this->loadModel('file');
|
||||
$joinTable = $type == 'project' ? TABLE_TASK : TABLE_STORY;
|
||||
$objectType = $type == 'project' ? 'task' : 'story';
|
||||
$files = $this->dao->select('t1.*')->from(TABLE_FILE)->alias('t1')
|
||||
->leftJoin($joinTable)->alias('t2')->on('t1.objectID=t2.id')
|
||||
->where("t2.$type")->eq($objectID)
|
||||
->andWhere('t1.objectType')->eq($objectType)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetchAll('id');
|
||||
|
||||
$docFiles = $this->dao->select('t1.*')->from(TABLE_FILE)->alias('t1')
|
||||
->leftJoin(TABLE_DOC)->alias('t2')->on('t1.objectID=t2.id')
|
||||
->where("t2.$type")->eq($objectID)
|
||||
->andWhere('t1.objectType')->eq('doc')
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetchAll('id');
|
||||
foreach($docFiles as $fileID => $file) $files[$fileID] = $file;
|
||||
foreach($files as $fileID => $file)
|
||||
{
|
||||
$file->realPath = $this->file->savePath . $file->pathname;
|
||||
$file->webPath = $this->file->webPath . $file->pathname;
|
||||
}
|
||||
|
||||
return $files;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
{
|
||||
echo html::a(inlink('allLibs', "type=project&extra=product=$lib->id"), $subLibName);
|
||||
}
|
||||
elseif($subLibID == 'files')
|
||||
{
|
||||
echo html::a(inlink('showFiles', "type=$type&objectID=$lib->id"), $subLibName);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::a(inlink('browse', "libID=$subLibID"), $subLibName);
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
{
|
||||
echo html::a(inlink('allLibs', "type=project&extra=product=$product->id"), $libName);
|
||||
}
|
||||
elseif($libID == 'files')
|
||||
{
|
||||
echo html::a(inlink('showFiles', "type=product&objectID=$product->id"), $libName);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::a(inlink('browse', "libID=$libID"), $libName);
|
||||
@@ -66,7 +70,18 @@
|
||||
<?php if(isset($subLibs['project'][$project->id])):?>
|
||||
<?php foreach($subLibs['project'][$project->id] as $libID => $libName):?>
|
||||
<div class='col-md-4'>
|
||||
<div class='lib' title='<?php echo $libName?>'><?php echo html::a(inlink('browse', "libID=$libID"), $libName);?></div>
|
||||
<div class='lib' title='<?php echo $libName?>'>
|
||||
<?php
|
||||
if($libID == 'files')
|
||||
{
|
||||
echo html::a(inlink('showFiles', "type=project&objectID=$project->id"), $libName);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::a(inlink('browse', "libID=$libID"), $libName);
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach?>
|
||||
<?php endif?>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* The showFiles view file of doc module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2015 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Yidong Wang <yidong@cnezsoft.com>
|
||||
* @package doc
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<div class='panel'>
|
||||
<div class='panel-heading'>
|
||||
<strong><?php echo $object->name?></strong>
|
||||
</div>
|
||||
<div class='panel-body cards'>
|
||||
<?php foreach($files as $file):?>
|
||||
<div class='col-md-3'>
|
||||
<div class='card' title='<?php echo $file->title . '.' . $file->extension?>'>
|
||||
<?php
|
||||
$downloadLink = $this->createLink('file', 'download', "fileID=$file->id&mouse=left");
|
||||
if(in_array($file->extension, $config->file->imageExtensions))
|
||||
{
|
||||
echo html::a($downloadLink, "<img src='$file->webPath' />", '_blank', "class='file'");
|
||||
}
|
||||
else
|
||||
{
|
||||
$iconClass = 'icon-file';
|
||||
if(strpos('zip,tar,gz,bz2,rar', $file->extension) !== false) $iconClass = 'icon-file-archive';
|
||||
if(strpos('csv,xls,xlsx', $file->extension) !== false) $iconClass = 'icon-file-excel';
|
||||
if(strpos('doc,docx', $file->extension) !== false) $iconClass = 'icon-file-word';
|
||||
if(strpos('ppt,pptx', $file->extension) !== false) $iconClass = 'icon-file-powerpoint';
|
||||
if(strpos('pdf', $file->extension) !== false) $iconClass = 'icon-file-pdf';
|
||||
echo html::a($downloadLink, "<i class='icon $iconClass'></i>", '_blank', "class='file'");
|
||||
}
|
||||
?>
|
||||
<div class="card-heading"><strong><?php echo html::a($this->createLink($file->objectType, 'view', "objectID=$file->objectID"), $lang->doc->fileObject . ' ' . strtoupper($file->objectType) . ' #' . $file->objectID)?></strong></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach;?>
|
||||
</div>
|
||||
</div>
|
||||
<?php js::set('type', $type);?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -24,6 +24,10 @@
|
||||
{
|
||||
echo html::a(inlink('allLibs', "type=project&extra=product=$object->id"), $libName);
|
||||
}
|
||||
elseif($libID == 'files')
|
||||
{
|
||||
echo html::a(inlink('showFiles', "type=$type&objectID=$object->id"), $libName);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo html::a(inlink('browse', "libID=$libID"), $libName);
|
||||
|
||||
Reference in New Issue
Block a user