From 0c6267f38ec3d09173cad2594ed7631ac2d1d3ce Mon Sep 17 00:00:00 2001 From: kato Date: Tue, 19 Apr 2022 13:32:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix=20#1817=20[=E3=83=90=E3=82=B0]=E3=80=80?= =?UTF-8?q?SSL=E9=80=9A=E4=BF=A1=E6=99=82=E3=81=ABBcBaser->getLink()?= =?UTF-8?q?=E3=81=A7=E3=83=AB=E3=83=BC=E3=83=88=E3=83=91=E3=82=B9=E3=81=A7?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E3=81=97=E3=81=A6=E3=81=84=E3=81=9FURL?= =?UTF-8?q?=E3=81=8C=E5=8B=9D=E6=89=8B=E3=81=AB=E7=B5=B6=E5=AF=BE=E3=83=91?= =?UTF-8?q?=E3=82=B9=E3=81=AB=E6=9B=B8=E3=81=8D=E5=A4=89=E3=81=88=E3=82=89?= =?UTF-8?q?=E3=82=8C=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E5=95=8F=E9=A1=8C?= =?UTF-8?q?=E3=82=92=E8=A7=A3=E6=B1=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Baser/View/Helper/BcBaserHelper.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/Baser/View/Helper/BcBaserHelper.php b/lib/Baser/View/Helper/BcBaserHelper.php index 1eaa9468c5..38ec8fcb74 100755 --- a/lib/Baser/View/Helper/BcBaserHelper.php +++ b/lib/Baser/View/Helper/BcBaserHelper.php @@ -1042,6 +1042,7 @@ public function link($title, $url = null, $htmlAttributes = [], $confirmMessage * - `prefix` : URLにプレフィックスをつけるかどうか(初期値 : false) * - `forceTitle` : 許可されていないURLの際にタイトルを強制的に出力するかどうか(初期値 : false) * - `ssl` : SSL用のURLをして出力するかどうか(初期値 : false) + * - `fullUrl` : サイト内リンクのときに、絶対パスで返すかどうか(初期値 : true ※後方互換のため) * ※ その他のパラメータについては、HtmlHelper::image() を参照。 * @param bool $confirmMessage 確認メッセージ(初期値 : false) * リンクをクリックした際に確認メッセージが表示され、はいをクリックした場合のみ遷移する @@ -1059,7 +1060,8 @@ public function getLink($title, $url = null, $options = [], $confirmMessage = fa 'escape' => false, 'prefix' => false, 'forceTitle' => false, - 'ssl' => $this->isSSL() + 'ssl' => $this->isSSL(), + 'fullUrl' => true ], $options); /*** beforeGetLink ***/ @@ -1145,11 +1147,21 @@ public function getLink($title, $url = null, $options = [], $confirmMessage = fa $_url = 'index.php/' . $_url; } if (!$ssl && !$admin) { - $url = Configure::read('BcEnv.siteUrl') . $_url; + if ($options['fullUrl']) { // フルパスで取得 + $url = Configure::read('BcEnv.siteUrl') . $_url; + } else { // baserCMSの設置パスも含めたルートパスで取得 + $passArray = explode($_SERVER["HTTP_HOST"], Configure::read('BcEnv.siteUrl')); + $url = isset($passArray[1]) ? $passArray[1]. $_url : '/'. $_url; + } } else { $sslUrl = Configure::read('BcEnv.sslUrl'); if ($sslUrl) { - $url = $sslUrl . $_url; + if ($options['fullUrl']) { // フルパスで取得 + $url = $sslUrl . $_url; + } else { // baserCMSの設置パスも含めたルートパスで取得 + $passArray = explode($_SERVER["HTTP_HOST"], $sslUrl); + $url = isset($passArray[1]) ? $passArray[1]. $_url : '/'. $_url; + } } else { $url = '/' . $_url; } From 9dc8945bcac22f6d1114df2501f82a071e2cf205 Mon Sep 17 00:00:00 2001 From: kato Date: Tue, 19 Apr 2022 13:44:44 +0900 Subject: [PATCH 2/2] =?UTF-8?q?$options['fullUrl']=E3=81=8C=E6=AE=8B?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E3=81=97=E3=81=BE=E3=81=86=E3=81=AE=E3=81=A7?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/Baser/View/Helper/BcBaserHelper.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Baser/View/Helper/BcBaserHelper.php b/lib/Baser/View/Helper/BcBaserHelper.php index 38ec8fcb74..35b0ca0e25 100755 --- a/lib/Baser/View/Helper/BcBaserHelper.php +++ b/lib/Baser/View/Helper/BcBaserHelper.php @@ -1082,10 +1082,12 @@ public function getLink($title, $url = null, $options = [], $confirmMessage = fa } $forceTitle = $options['forceTitle']; $ssl = $options['ssl']; + $fullUrl = $options['fullUrl']; unset($options['prefix']); unset($options['forceTitle']); unset($options['ssl']); + unset($options['fullUrl']); // 管理システムメニュー対策 // プレフィックスが変更された場合も正常動作させる為 @@ -1147,7 +1149,7 @@ public function getLink($title, $url = null, $options = [], $confirmMessage = fa $_url = 'index.php/' . $_url; } if (!$ssl && !$admin) { - if ($options['fullUrl']) { // フルパスで取得 + if ($fullUrl) { // フルパスで取得 $url = Configure::read('BcEnv.siteUrl') . $_url; } else { // baserCMSの設置パスも含めたルートパスで取得 $passArray = explode($_SERVER["HTTP_HOST"], Configure::read('BcEnv.siteUrl')); @@ -1156,7 +1158,7 @@ public function getLink($title, $url = null, $options = [], $confirmMessage = fa } else { $sslUrl = Configure::read('BcEnv.sslUrl'); if ($sslUrl) { - if ($options['fullUrl']) { // フルパスで取得 + if ($fullUrl) { // フルパスで取得 $url = $sslUrl . $_url; } else { // baserCMSの設置パスも含めたルートパスで取得 $passArray = explode($_SERVER["HTTP_HOST"], $sslUrl);