107 lines
4.1 KiB
PHP
107 lines
4.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
/**
|
|
* The app view file of doc module of ZenTaoPMS.
|
|
* @copyright Copyright 2024 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
|
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
|
* @author Sun Hao<sunhao@easycorp.ltd>
|
|
* @package doc
|
|
* @link https://www.zentao.net
|
|
*/
|
|
namespace zin;
|
|
|
|
jsVar('type', $type);
|
|
$libTypes = array();
|
|
if($type === 'project')
|
|
{
|
|
$libTypes[] = array('type' => 'project', 'name' => $lang->projectCommon, 'icon' => 'project');
|
|
$libTypes[] = array('type' => 'execution', 'name' => $lang->execution->common, 'icon' => 'run');
|
|
}
|
|
|
|
$privs = array();
|
|
$privs['create'] = hasPriv('doc', 'create');
|
|
$privs['edit'] = hasPriv('doc', 'edit');
|
|
$privs['delete'] = hasPriv('doc', 'delete');
|
|
$privs['moveDoc'] = hasPriv('doc', 'moveDoc');
|
|
$privs['collect'] = hasPriv('doc', 'collect');
|
|
$privs['createLib'] = hasPriv('doc', 'createLib');
|
|
$privs['editLib'] = hasPriv('doc', 'editLib');
|
|
$privs['moveLib'] = hasPriv('doc', 'moveLib');
|
|
$privs['deleteLib'] = hasPriv('doc', 'deleteLib');
|
|
$privs['sortDocLib'] = hasPriv('doc', 'sortDocLib');
|
|
$privs['exportFiles'] = hasPriv('doc', 'exportFiles');
|
|
$privs['createSpace'] = hasPriv('doc', 'createSpace');
|
|
$privs['editSpace'] = hasPriv('doc', 'editLib');
|
|
$privs['addModule'] = hasPriv('doc', 'addCatalog');
|
|
$privs['deleteModule'] = hasPriv('doc', 'deleteCatalog');
|
|
$privs['editModule'] = hasPriv('doc', 'editCatalog');
|
|
$privs['sortModule'] = hasPriv('doc', 'sortCatalog');
|
|
|
|
$sessionStr = session_name() . '=' . session_id();
|
|
$fileUrl = createLink('file', 'download', 'fileID={id}');
|
|
$fileUrl .= strpos($fileUrl, '?') === false ? '?' : '&';
|
|
$fileUrl .= $sessionStr;
|
|
|
|
$langData = new stdclass();
|
|
$langData->filePreview = $lang->file->preview;
|
|
$langData->fileDownload = $lang->file->download;
|
|
$langData->fileDelete = $lang->file->delete;
|
|
$langData->fileRename = $lang->file->edit;
|
|
$langData->fileConfirmDelete = $lang->file->confirmDelete;
|
|
|
|
zui::docApp
|
|
(
|
|
set::_class('shadow rounded ring canvas'),
|
|
set::_style(array('height' => 'calc(100vh - 72px)')),
|
|
set::_id('docApp'),
|
|
set::spaceType($type),
|
|
set::spaceID($spaceID),
|
|
set::libID($libID),
|
|
set::libTypes($libTypes),
|
|
set::moduleID($moduleID),
|
|
set::docID($docID),
|
|
set::docMode($docMode),
|
|
set::fetcher(createLink('doc', 'ajaxGetSpaceData', 'type={spaceType}&spaceID={spaceID}&picks={picks}')),
|
|
set::docFetcher(createLink('doc', 'ajaxGetDoc', 'docID={docID}&version={version}')),
|
|
set::filesFetcher(createLink('doc', 'ajaxGetFiles', 'type={objectType}&objectID={objectID}')),
|
|
set::width('100%'),
|
|
set::height('100%'),
|
|
set::userMap($users),
|
|
set::currentUser($this->app->user->account),
|
|
set::privs($privs),
|
|
set::fileUrl($fileUrl),
|
|
set::lang($langData),
|
|
set::uploadUrl(createLink('file', 'ajaxUpload', 'uid={uid}&objectType={objectType}&objectID={objectID}&extra={extra}&field={field}&api={api}&onlyImage=0')),
|
|
set::downloadUrl(createLink('file', 'ajaxQuery', 'fileID={id}&objectType={objectType}&objectID={objectID}&title={title}&extra={extra}&stream=0')),
|
|
set::sessionStr(session_name() . '=' . session_id()),
|
|
set('$options', jsRaw('window.setDocAppOptions'))
|
|
);
|
|
|
|
btn
|
|
(
|
|
setClass('absolute right-1.5 bottom-1.5 size-sm z-10'),
|
|
set::type('special-pale'),
|
|
set::icon('back'),
|
|
on::click()->call('goToOldDocPage'),
|
|
'切换回旧版界面',
|
|
css('#mainContent {position: relative}')
|
|
);
|
|
|
|
/* Modify navbar. 修改二级导航。 */
|
|
query('#navbar nav')->each(function($node) use ($type)
|
|
{
|
|
$items = $node->prop('items');
|
|
$idTypeMap = array('my' => 'mine', 'team' => 'custom', 'project' => 'project', 'product' => 'product');
|
|
|
|
foreach($items as &$item)
|
|
{
|
|
if(empty($item['data-id']) || empty($idTypeMap[$item['data-id']])) continue;
|
|
|
|
$itemType = $idTypeMap[$item['data-id']];
|
|
$item['active'] = $type === $itemType;
|
|
$item['url'] = createLink('doc', 'app', 'type=' . $itemType);
|
|
}
|
|
|
|
$node->setProp('items', $items);
|
|
});
|