From 185550fcf40c1e36be6b5f7289151cb184c06db0 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 11 Apr 2023 16:11:55 +0800 Subject: [PATCH] * Code for task #90779. --- module/block/control.php | 1 + module/block/view/docstatisticblock.html.php | 65 ++++++++++++++++++++ module/doc/lang/de.php | 5 ++ module/doc/lang/en.php | 5 ++ module/doc/lang/fr.php | 5 ++ module/doc/lang/zh-cn.php | 11 +++- module/doc/model.php | 22 ++----- 7 files changed, 95 insertions(+), 19 deletions(-) diff --git a/module/block/control.php b/module/block/control.php index 76415e75ec..e1438b6578 100755 --- a/module/block/control.php +++ b/module/block/control.php @@ -2042,6 +2042,7 @@ class block extends control */ public function printDocStatisticBlock() { + $this->view->statistic = $this->loadModel('doc')->getStatisticInfo(); } /** diff --git a/module/block/view/docstatisticblock.html.php b/module/block/view/docstatisticblock.html.php index e69de29bb2..27b0706732 100644 --- a/module/block/view/docstatisticblock.html.php +++ b/module/block/view/docstatisticblock.html.php @@ -0,0 +1,65 @@ + + * @package block + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+

doc->docStatistic;?>

+
+
+
totalDocs;?>
+
doc->allDoc;?>
+
+
+
todayEditedDocs;?>
+
doc->todayEdited;?>
+
+
+
+
+

doc->openedByMe;?>

+
+
+
myDocs;?>
+
doc->docCreated;?>
+
+
+
myDoc->docViews;?>
+
doc->docViews;?>
+
+
+
myDoc->docCollects;?>
+
doc->docCollects;?>
+
+
+
+
+

doc->editedByMe;?>

+
+
+
myEditedDocs;?>
+
doc->docEdited;?>
+
+
+
+
diff --git a/module/doc/lang/de.php b/module/doc/lang/de.php index 96b543a40d..d5dda417a7 100644 --- a/module/doc/lang/de.php +++ b/module/doc/lang/de.php @@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Catalog'; $lang->doc->addCatalog = 'Add Catalog'; $lang->doc->editCatalog = 'Edit Catalog'; $lang->doc->deleteCatalog = 'Delete Catalog'; +$lang->doc->docStatistic = 'Statistic'; +$lang->doc->docCreated = 'Created Documents'; +$lang->doc->docEdited = 'Edited Documents'; +$lang->doc->docViews = 'Page Views'; +$lang->doc->docCollects = 'Collection'; /* Methods list */ $lang->doc->index = 'Dashboard'; diff --git a/module/doc/lang/en.php b/module/doc/lang/en.php index 8f37a1dcf2..a7f3f06ada 100644 --- a/module/doc/lang/en.php +++ b/module/doc/lang/en.php @@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Directory'; $lang->doc->addCatalog = 'Add Catalog'; $lang->doc->editCatalog = 'Edit Catalog'; $lang->doc->deleteCatalog = 'Delete Catalog'; +$lang->doc->docStatistic = 'Statistic'; +$lang->doc->docCreated = 'Created Documents'; +$lang->doc->docEdited = 'Edited Documents'; +$lang->doc->docViews = 'Page Views'; +$lang->doc->docCollects = 'Collection'; /* Methods list */ $lang->doc->index = 'Dashboard'; diff --git a/module/doc/lang/fr.php b/module/doc/lang/fr.php index c6b8a3e9c5..9ec7cd6fa0 100644 --- a/module/doc/lang/fr.php +++ b/module/doc/lang/fr.php @@ -145,6 +145,11 @@ $lang->doc->tableContents = 'Catalog'; $lang->doc->addCatalog = 'Add Catalog'; $lang->doc->editCatalog = 'Edit Catalog'; $lang->doc->deleteCatalog = 'Delete Catalog'; +$lang->doc->docStatistic = 'Statistic'; +$lang->doc->docCreated = 'Created Documents'; +$lang->doc->docEdited = 'Edited Documents'; +$lang->doc->docViews = 'Page Views'; +$lang->doc->docCollects = 'Collection'; /* Methods list */ $lang->doc->index = 'Dashboard'; diff --git a/module/doc/lang/zh-cn.php b/module/doc/lang/zh-cn.php index 5d6130f3a2..dd2261c845 100644 --- a/module/doc/lang/zh-cn.php +++ b/module/doc/lang/zh-cn.php @@ -128,9 +128,9 @@ $lang->doc->team = '团队'; $lang->doc->moduleDoc = '按模块浏览'; $lang->doc->searchDoc = '搜索'; $lang->doc->fast = '快速访问'; -$lang->doc->allDoc = '所有文档'; -$lang->doc->openedByMe = '由我创建'; -$lang->doc->editedByMe = '由我编辑'; +$lang->doc->allDoc = '全部文档'; +$lang->doc->openedByMe = '我的创建'; +$lang->doc->editedByMe = '我的编辑'; $lang->doc->orderByOpen = '最近添加'; $lang->doc->orderByEdit = '最近更新'; $lang->doc->orderByVisit = '最近访问'; @@ -145,6 +145,11 @@ $lang->doc->tableContents = '目录'; $lang->doc->addCatalog = '添加目录'; $lang->doc->editCatalog = '编辑目录'; $lang->doc->deleteCatalog = '删除目录'; +$lang->doc->docStatistic = '文档统计'; +$lang->doc->docCreated = '创建的文档'; +$lang->doc->docEdited = '编辑的文档'; +$lang->doc->docViews = '被浏览量'; +$lang->doc->docCollects = '被收藏量'; /* 方法列表。*/ $lang->doc->index = '仪表盘'; diff --git a/module/doc/model.php b/module/doc/model.php index a6a9266f73..63a5ed9384 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2145,29 +2145,19 @@ class docModel extends model { $allLibs = array_keys($this->getLibs('all')); $docIdList = $this->getPrivDocs($allLibs); + $myDocList = $this->dao->select('id')->from(TABLE_DOC)->where('addedBy')->eq($this->app->user->account)->fetchPairs('id'); - $today = date('Y-m-d'); - $lately = date('Y-m-d', strtotime('-3 day')); - $statisticInfo = $this->dao->select("count(id) as totalDocs, count(IF(editedDate like '{$today}%', 1, null)) as todayEditedDocs, - count(IF(editedDate > '{$lately}', 1, null)) as lastEditedDocs, count(IF(addedDate > '{$lately}', 1, null)) as lastAddedDocs, - count(IF(addedBy = '{$this->app->user->account}', 1, null)) as myDocs")->from(TABLE_DOC) + $today = date('Y-m-d'); + $statistic = $this->dao->select("count(id) as totalDocs, count(IF(editedDate like '{$today}%', 1, null)) as todayEditedDocs, + count(IF(editedBy = '{$this->app->user->account}', 1, null)) as myEditedDocs, count(IF(addedBy = '{$this->app->user->account}', 1, null)) as myDocs")->from(TABLE_DOC) ->where('deleted')->eq(0) ->andWhere('vision')->eq($this->config->vision) ->andWhere('id')->in($docIdList) ->fetch(); - $statisticInfo->myCollection = $this->dao->select('count(*) as count')->from(TABLE_DOCACTION) - ->where('doc')->in($docIdList) - ->andWhere('action')->eq('collect') - ->andWhere('actor')->eq($this->app->user->account) - ->fetch('count'); - $statisticInfo->pastEditedDocs = $statisticInfo->totalDocs - $statisticInfo->todayEditedDocs; - $statisticInfo->lastEditedProgress = $statisticInfo->totalDocs ? round($statisticInfo->lastEditedDocs / $statisticInfo->totalDocs, 2) * 100 : 0; - $statisticInfo->lastAddedProgress = $statisticInfo->totalDocs ? round($statisticInfo->lastAddedDocs / $statisticInfo->totalDocs, 2) * 100 : 0; - $statisticInfo->myCollectionProgress = $statisticInfo->totalDocs ? round($statisticInfo->myCollection / $statisticInfo->totalDocs, 2) * 100 : 0; - $statisticInfo->myDocsProgress = $statisticInfo->totalDocs ? round($statisticInfo->myDocs / $statisticInfo->totalDocs, 2) * 100 : 0; + $statistic->myDoc = $this->dao->select("count(IF(`action` = 'view', 1, null)) as docViews, count(IF(`action` = 'collect', 1, null)) as docCollects")->from(TABLE_DOCACTION)->where('doc')->in($myDocList)->fetch(); - return $statisticInfo; + return $statistic; } /**