Skip to content

Commit

Permalink
Fixed issue #08141: Unable to set publicurl
Browse files Browse the repository at this point in the history
Dev: Replace default createAbsoluteUrl to use $config['publicurl'] if this one seems valid
  • Loading branch information
Shnoulle committed Sep 9, 2013
1 parent c50f6e2 commit 08c678b
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions application/core/LSYii_Controller.php
Expand Up @@ -128,13 +128,34 @@ protected function _init()
error_reporting(0);
}

//SET LOCAL TIME
$timeadjust = Yii::app()->getConfig("timeadjust");
if (substr($timeadjust,0,1)!='-' && substr($timeadjust,0,1)!='+') {$timeadjust='+'.$timeadjust;}
if (strpos($timeadjust,'hours')===false && strpos($timeadjust,'minutes')===false && strpos($timeadjust,'days')===false)
{
Yii::app()->setConfig("timeadjust",$timeadjust.' hours');
}
//SET LOCAL TIME
$timeadjust = Yii::app()->getConfig("timeadjust");
if (substr($timeadjust,0,1)!='-' && substr($timeadjust,0,1)!='+') {$timeadjust='+'.$timeadjust;}
if (strpos($timeadjust,'hours')===false && strpos($timeadjust,'minutes')===false && strpos($timeadjust,'days')===false)
{
Yii::app()->setConfig("timeadjust",$timeadjust.' hours');
}

}
}

/**
* Creates an absolute URL based on the given controller and action information.
* @param string $route the URL route. This should be in the format of 'ControllerID/ActionID'.
* @param array $params additional GET parameters (name=>value). Both the name and value will be URL-encoded.
* @param string $schema schema to use (e.g. http, https). If empty, the schema used for the current request will be used.
* @param string $ampersand the token separating name-value pairs in the URL.
* @return string the constructed URL
*/
public function createAbsoluteUrl($route,$params=array(),$schema='',$ampersand='&')
{
$sPublicUrl=Yii::app()->getConfig("publicurl");
// Control if public url are really public : need scheme and host
// If yes: update baseUrl to config without restrictions
$aPublicUrl=parse_url($sPublicUrl);
if(isset($aPublicUrl['scheme']) && isset($aPublicUrl['host']))
{
Yii::app()->getComponent('urlManager')->setBaseUrl($sPublicUrl);
}
return parent::createAbsoluteUrl($route,$params,$schema,$ampersand);
}
}

0 comments on commit 08c678b

Please sign in to comment.