Commit 35dfa714 authored by Patrick Barroca's avatar Patrick Barroca 🐧

dev #69826 refacto absoluteUrl and siteUrl

parent 19e9937a
Pipeline #3468 failed with stage
in 11 minutes and 13 seconds
......@@ -224,8 +224,9 @@ class Class_Newsletter extends Storm_Model_Abstract {
public function getUnsubscribeUrl() {
return Class_Url::siteUrl()
. '/newsletter/unsubscribe/newsletter/' . $this->getId()
return Class_Url::absolute(['controller' => 'newsletter',
'action' => 'unsubscribe',
'newsletter' => $this->getId()], null, true)
. (($profil = Class_AdminVar::get('NEWSLETTER_ID_PROFIL')) ? '/id_profil/' . $profil : '')
. '/user/%user.id%/hash/%hash%';
}
......
......@@ -76,9 +76,9 @@ class Class_Notice_MailRenderer {
protected function _urlWithoutRouter($record) {
return sprintf('%s/recherche/viewnotice/id/%d',
Class_Url::siteUrl(),
$record->getId());
return Class_Url::absolute(['controller' => 'recherche',
'action' => 'viewnotice',
'id' => $record->getId()]);
}
......
......@@ -680,7 +680,7 @@ class Class_Profil extends Storm_Model_Abstract {
public function getUrl() {
return Class_Url::siteUrl() . Class_Url::assemble($this->getUrlParts(), null, true);
return Class_Url::absolute($this->getUrlParts(), null, true);
}
......
......@@ -87,7 +87,7 @@ class Class_Systeme_Report_Headers extends Class_Systeme_Report_Abstract {
class Class_Systeme_Report_Portal extends Class_Systeme_Report_Abstract {
public function acceptVisitor($visitor) {
$visitor->visitData('url', $this->_('URL principale'), Class_Url::siteUrl());
$visitor->visitData('url', $this->_('URL principale'), Class_Url::absolute());
$visitor->visitData('label', $this->_('Libellé principal'), Class_Profil::getPortail()->getLibelle());
$visitor->visitDataArray('skins', $this->_('Thèmes utilisés'), $this->_profilSkins());
$visitor->visitDataArray('tags', $this->_('Tags'), $this->_fetchTags());
......
......@@ -43,14 +43,6 @@ class Class_Url {
}
public static function siteUrl() {
if (!$url = Class_AdminVar::get('NOM_DOMAINE'))
$url = self::rootUrl() . self::baseUrl();
return self::getProtocol() . preg_replace("(^https?://)", "", $url);
}
public static function getParam($needle) {
if (!$request = Zend_Controller_Front::getInstance()->getRequest())
return null;
......@@ -166,12 +158,45 @@ class Class_Url {
public function absoluteUrl($url_array_or_string = [], $name = null, $reset = false, $encode = true) {
$url = $this->prepare($url_array_or_string, $name, $reset, $encode);
if (preg_match('/http[s]?:\/\//', $url))
return $url;
$url = static::prependBaseUrl($url);
return ($url = $this->_urlForCli($url))
? $url
: $this->_urlForWeb($url);
}
protected function _urlForCli($url) {
if(!$this->_isCliMode())
return '';
if(!$domain = Class_AdminVar::get('NOM_DOMAINE'))
throw new RunTimeException('
Bokeh Error : adminVar "NOM_DOMAINE" is empty. Bokeh in php cli mode is unable to generate site URL.
');
return
static::getProtocol()
. preg_replace("(^https?://)", "", $domain)
. $url;
}
protected function _urlForWeb($url) {
return static::rootUrl() . static::prependBaseUrl($url);
}
protected function _isCliMode() {
return 'cli' == php_sapi_name();
}
return static::rootUrl() . $url;
protected function _siteUrl() {
}
......
......@@ -51,7 +51,9 @@ class Class_WebService_OAI extends Class_WebService_Abstract {
public static function baseURL() {
return Class_Url::siteUrl() . '/opac/oai/request';
return Class_Url::absolute(['module' => 'opac',
'controller' => 'oai',
'action' => 'request'], null, true);
}
......
......@@ -24,7 +24,7 @@ class ZendAfi_Controller_Plugin_SetupDomain extends Zend_Controller_Plugin_Abstr
if (Class_Adminvar::get('NOM_DOMAINE'))
return;
$site_url = Class_Url::siteUrl();
$site_url = Class_Url::absolute();
if(!self::isAllowedDomain(Class_Url::getForbidenUrls(), $site_url))
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment