type == 'url')
+ if($doc->type == 'url' and $showPageDetails)
{
$url = $doc->content;
if(!preg_match('/^https?:\/\//', $doc->content)) $url = 'http://' . $url;
From 8cd3b4eb9f1c112e17b6165240b64095ef2ae173 Mon Sep 17 00:00:00 2001
From: hufangzhou
Date: Sat, 2 Apr 2022 15:58:22 +0800
Subject: [PATCH 3/4] * 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;
+ }
}
From 4eeaa81691d634347f7cb3e631508fb27241850d Mon Sep 17 00:00:00 2001
From: hufangzhou
Date: Sat, 2 Apr 2022 16:05:19 +0800
Subject: [PATCH 4/4] * Rename the method name.
---
module/doc/control.php | 50 ++++++++++++++++----------------
module/doc/model.php | 10 +++----
module/doc/view/content.html.php | 2 +-
module/doc/view/view.html.php | 2 +-
4 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/module/doc/control.php b/module/doc/control.php
index b515f492bf..1430bf7696 100644
--- a/module/doc/control.php
+++ b/module/doc/control.php
@@ -537,15 +537,15 @@ class doc extends control
$this->view->position[] = html::a($this->createLink('doc', 'browse', "libID=$doc->lib"), $lib->name);
$this->view->position[] = $this->lang->doc->view;
- $this->view->doc = $doc;
- $this->view->lib = $lib;
- $this->view->type = $type;
- $this->view->version = $version ? $version : $doc->version;
- $this->view->actions = $this->action->getList('doc', $docID);
- $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 = $this->doc->checkShowPageDetails($doc);
+ $this->view->doc = $doc;
+ $this->view->lib = $lib;
+ $this->view->type = $type;
+ $this->view->version = $version ? $version : $doc->version;
+ $this->view->actions = $this->action->getList('doc', $docID);
+ $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->autoloadPage = $this->doc->checkAutoloadPage($doc);
$this->display();
}
@@ -1052,22 +1052,22 @@ class doc extends control
$this->view->title = ($type == 'book' or $type == 'custom') ? $this->lang->doc->customAB : $object->name;
$this->view->position[] = ($type == 'book' or $type == 'custom') ? $this->lang->doc->customAB : $object->name;
- $this->view->docID = $docID;
- $this->view->doc = $docID ? $doc : '';
- $this->view->type = $type;
- $this->view->version = $version;
- $this->view->object = $object;
- $this->view->objectID = $objectID;
- $this->view->objectType = $type;
- $this->view->libID = $libID;
- $this->view->lib = isset($libs[$libID]) ? $libs[$libID] : new stdclass();
- $this->view->libs = $this->doc->getLibsByObject($type, $objectID);
- $this->view->moduleTree = $moduleTree;
- $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable.
- $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 = $this->doc->checkShowPageDetails($doc);
+ $this->view->docID = $docID;
+ $this->view->doc = $docID ? $doc : '';
+ $this->view->type = $type;
+ $this->view->version = $version;
+ $this->view->object = $object;
+ $this->view->objectID = $objectID;
+ $this->view->objectType = $type;
+ $this->view->libID = $libID;
+ $this->view->lib = isset($libs[$libID]) ? $libs[$libID] : new stdclass();
+ $this->view->libs = $this->doc->getLibsByObject($type, $objectID);
+ $this->view->moduleTree = $moduleTree;
+ $this->view->canBeChanged = common::canModify($type, $object); // Determines whether an object is editable.
+ $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->autoloadPage = $this->doc->checkAutoloadPage($doc);
$this->display();
}
diff --git a/module/doc/model.php b/module/doc/model.php
index 25c0cc126e..7485ba1b99 100644
--- a/module/doc/model.php
+++ b/module/doc/model.php
@@ -2653,23 +2653,23 @@ EOT;
}
/**
- * Whether the url of link type documents needs to be displayed.
+ * Whether the url of link type documents needs to be autoloaded.
*
* @param object $doc
* @access public
* @return bool
*/
- public function checkShowPageDetails($doc)
+ public function checkAutoloadPage($doc)
{
- $showPageDetails = true;
+ $autoloadPage = 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;
+ if($urlDomain == $_SERVER['HTTP_HOST']) $autoloadPage = false;
}
- return $showPageDetails;
+ return $autoloadPage;
}
}
diff --git a/module/doc/view/content.html.php b/module/doc/view/content.html.php
index b6e6acb525..21f3cbdbd3 100644
--- a/module/doc/view/content.html.php
+++ b/module/doc/view/content.html.php
@@ -74,7 +74,7 @@ $sessionString .= session_name() . '=' . session_id();
type == 'url' and $showPageDetails)
+ if($doc->type == 'url' and $autoloadPage)
{
$url = $doc->content;
if(!preg_match('/^https?:\/\//', $doc->content)) $url = 'http://' . $url;
diff --git a/module/doc/view/view.html.php b/module/doc/view/view.html.php
index 14b3598aa6..f8d97c7da2 100644
--- a/module/doc/view/view.html.php
+++ b/module/doc/view/view.html.php
@@ -89,7 +89,7 @@ js::set('docID', $doc->id);
type == 'url' and $showPageDetails)
+ if($doc->type == 'url' and $autoloadPage)
{
$url = $doc->content;
if(!preg_match('/^https?:\/\//', $doc->content)) $url = 'http://' . $url;