From 8cd3b4eb9f1c112e17b6165240b64095ef2ae173 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Sat, 2 Apr 2022 15:58:22 +0800 Subject: [PATCH] * Packaging method. --- module/doc/control.php | 24 +++--------------------- module/doc/model.php | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index 6ffb99ca6b..b515f492bf 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -1,5 +1,4 @@ digest = commonModel::processMarkdown($doc->digest); } - $showPageDetails = true; - if(!empty($doc) and $doc->type == 'url') - { - $parsedUrl = parse_url($doc->content); - $urlPort = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''; - $urlDomain = $parsedUrl['host'] . $urlPort; - if($urlDomain == $_SERVER['HTTP_HOST']) $showPageDetails = false; - } - /* Check priv when lib is product or project. */ $lib = $this->doc->getLibByID($doc->lib); $type = $lib->type; @@ -555,7 +545,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->showPageDetails = $showPageDetails; + $this->view->showPageDetails = $this->doc->checkShowPageDetails($doc); $this->display(); } @@ -1056,15 +1046,6 @@ class doc extends control } } - $showPageDetails = true; - if(!empty($doc) and $doc->type == 'url') - { - $parsedUrl = parse_url($doc->content); - $urlPort = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''; - $urlDomain = $parsedUrl['host'] . $urlPort; - if($urlDomain == $_SERVER['HTTP_HOST']) $showPageDetails = false; - } - $this->view->customObjectLibs = $customObjectLibs; $this->view->showLibs = $this->config->doc->custom->objectLibs; @@ -1086,7 +1067,8 @@ class doc extends control $this->view->actions = $docID ? $this->action->getList('doc', $docID) : array(); $this->view->users = $this->user->getPairs('noclosed,noletter'); $this->view->preAndNext = $this->doc->getPreAndNextDoc($docID, $libID); - $this->view->showPageDetails = $showPageDetails; + $this->view->showPageDetails = $this->doc->checkShowPageDetails($doc); + $this->display(); } diff --git a/module/doc/model.php b/module/doc/model.php index bc7774264c..25c0cc126e 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2651,4 +2651,25 @@ EOT; return array($libs, $libID, $object, $objectID); } + + /** + * Whether the url of link type documents needs to be displayed. + * + * @param object $doc + * @access public + * @return bool + */ + public function checkShowPageDetails($doc) + { + $showPageDetails = true; + if(!empty($doc) and $doc->type == 'url') + { + $parsedUrl = parse_url($doc->content); + $urlPort = isset($parsedUrl['port']) ? ':' . $parsedUrl['port'] : ''; + $urlDomain = $parsedUrl['host'] . $urlPort; + if($urlDomain == $_SERVER['HTTP_HOST']) $showPageDetails = false; + } + + return $showPageDetails; + } }