本文整理汇总了PHP中CUrlManager::createUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP CUrlManager::createUrl方法的具体用法?PHP CUrlManager::createUrl怎么用?PHP CUrlManager::createUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUrlManager
的用法示例。
在下文中一共展示了CUrlManager::createUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if (preg_match('/[A-Z]/', $route) !== 0) {
$route = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '-\\1', $route));
}
return parent::createUrl($route, $params, $ampersand);
}
示例2: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
$route = preg_replace_callback('/(?<![A-Z])[A-Z]/', function ($matches) {
return '-' . lcfirst($matches[0]);
}, $route);
return parent::createUrl($route, $params, $ampersand);
}
示例3: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if (isset($params[$this->languageParam])) {
$language = $params[$this->languageParam];
$forceLanguage = true;
unset($params[$this->languageParam]);
} else {
$language = Yii::app()->language;
$forceLanguage = false;
}
$url = parent::createUrl($route, $params, $ampersand);
$request = Yii::app()->request;
if (!$forceLanguage && !$request->redirectDefault && $language === $request->getDefaultLanguage()) {
return $url;
}
$key = array_search($language, $request->languages);
if (is_string($key)) {
$language = $key;
}
if (($baseUrl = $this->getBaseUrl()) === '') {
return '/' . $language . $url;
} else {
return strtr($url, array($baseUrl => $baseUrl . '/' . $language));
}
}
示例4: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
$route = trim($route, '/');
//for admin and admin/*
$parts = explode('/', $route);
//do not mess with gii
if ($parts[0] == 'gii') {
return parent::createUrl($route, $params, $ampersand);
}
// ignore defaultController
if (Yii::app()->hasModule($parts[0]) && isset($parts[1]) && $parts[1] == Yii::app()->getModule($parts[0])->defaultController) {
unset($parts[1]);
$route = implode('/', $parts);
}
if (substr(Yii::app()->getRequest()->pathInfo, 0, 6) == 'admin/' || Yii::app()->getRequest()->pathInfo == 'admin') {
$route = 'admin/' . trim($route, '/');
}
$url = parent::createUrl($route, $params, $ampersand);
if (Settings::get('SEO', 'slugs_enabled')) {
//handle slugs here
if ($slug = Slug::getSlug(preg_replace('/' . trim(Yii::app()->baseUrl, '/') . '/', '', $url, 1))) {
//if (Settings::get('SEO','externalSlug')
$url = $slug;
$url = Yii::app()->baseUrl . '/' . $url;
}
}
return $url;
}
示例5: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if (empty($params['language']) && Yii::app()->language !== 'ru') {
$params['language'] = Yii::app()->language;
}
if (!isset(Yii::app()->controller->module->id)) {
if (!strstr($route, 'register')) {
if (isset($_POST['city'])) {
$cookie = new CHttpCookie('city', $_POST['city']);
Yii::app()->request->cookies['city'] = $cookie;
$cookie->expire = time() + 3600;
$c = City::model()->localized('ru')->findByPk($_POST['city'])->name;
$params['city'] = Settings::toLatin($c);
} elseif (isset(Yii::app()->request->cookies['city'])) {
$c = City::model()->localized('ru')->findByPk(Yii::app()->request->cookies['city']->value)->name;
$params['city'] = Settings::toLatin($c);
} else {
unset($params['city']);
}
} else {
unset($params['city']);
}
}
/*if (!strstr($route,'/')) {
$route = '/cat/'.$route;
}*/
return Yii::app()->request->hostInfo . parent::createUrl($route, $params, $ampersand);
}
示例6: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if (!isset($params['language'])) {
$params['language'] = Yii::app()->language;
}
return parent::createUrl($route, $params, $ampersand);
}
示例7: createLangUrl
public function createLangUrl($language, $ampersand = '&')
{
$route = Yii::app()->controller->route;
$params = $_GET;
unset($params[$this->routeVar]);
$params[$this->langParam] = $language;
return parent::createUrl($route, $params, $ampersand);
}
示例8: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
$url = parent::createUrl($route, $params, $ampersand);
if ($this->getFrontendMode()) {
$baseUrl = $this->getBaseUrl();
return mb_substr($url, mb_strlen($baseUrl));
}
return $url;
}
示例9: createUrl
/**
* @inheritDoc
*/
public function createUrl($route, $params = array(), $ampersand = '&')
{
$oldUrlSuffix = $this->urlSuffix;
if (isset($params['_ext'])) {
$this->urlSuffix = '.' . $params['_ext'];
unset($params['_ext']);
}
$url = parent::createUrl($route, $params, $ampersand);
$this->urlSuffix = $oldUrlSuffix;
return $url;
}
示例10: createUrl
public function createUrl($route,$params=array(),$ampersand='&')
{
if (!isset($params['language'])) {
if (Yii::app()->user->hasState('language'))
Yii::app()->language = Yii::app()->user->getState('language');
else if(isset(Yii::app()->request->cookies['language']))
Yii::app()->language = Yii::app()->request->cookies['language']->value;
$params['language']=Yii::app()->language;
}
return parent::createUrl($route, $params, $ampersand);
}
示例11: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if ($route != 'min/serve' && $route != 'site/uploadimage') {
$langs = Lang::getActiveLangs();
$countLangs = count($langs);
if (!isFree() && empty($params['lang']) && ($countLangs > 1 || $countLangs == 1 && param('useLangPrefixIfOneLang'))) {
$params['lang'] = Yii::app()->language;
}
}
return parent::createUrl($route, $params, $ampersand);
}
示例12: createUrl
/**
* Create url based on current language.
* @param mixed $route
* @param array $params
* @param string $ampersand
* @param boolean $respectLang
* @access public
* @return string
*/
public function createUrl($route, $params = array(), $ampersand = '&', $respectLang = true)
{
$result = parent::createUrl($route, $params, $ampersand);
if ($respectLang === true) {
$langPrefix = Yii::app()->languageManager->getUrlPrefix();
if ($langPrefix) {
$result = '/' . $langPrefix . $result;
}
}
return $result;
}
示例13: createUrl
/**
*
* @see CUrlManager
*
* Constructs a URL.
* @param string the controller and the action (e.g. article/read)
* @param array list of GET parameters (name=>value). Both the name and value will be URL-encoded.
* If the name is '#', the corresponding value will be treated as an anchor
* and will be appended at the end of the URL. This anchor feature has been available since version 1.0.1.
* @param string the token separating name-value pairs in the URL. Defaults to '&'.
* @return string the constructed URL
*/
public function createUrl($route, $params = array(), $ampersand = '&')
{
// We added this by default to all links to show
// Content based on language - Add only when not excplicity set
if (!isset($params['lang'])) {
$params['lang'] = Yii::app()->language;
}
if (isset($params['lang']) && $params['lang'] === false) {
unset($params['lang']);
}
// Use parent to finish url construction
return parent::createUrl($route, $params, $ampersand);
}
示例14: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
$url = parent::createUrl($route, $params, $ampersand);
// If already an absolute URL, return it directly
if (strpos($url, 'http') === 0) {
return $url;
}
// Check if the current protocol matches the expected protocol of the route
// If not, prefix the generated URL with the correct host info.
$secureRoute = $this->isSecureRoute($route);
if (Yii::app()->request->isSecureConnection) {
return $secureRoute ? $url : $this->hostInfo . $url;
} else {
return $secureRoute ? $this->secureHostInfo . $url : $url;
}
}
示例15: createUrl
public function createUrl($route, $params = array(), $ampersand = '&')
{
if ($route !== 'tstranslation') {
if ($this->showLangInUrl) {
if (empty($params['_lang'])) {
$params['_lang'] = Yii::app()->language;
}
} else {
if (isset($params['_lang'])) {
unset($params['_lang']);
}
}
} else {
$params = array();
}
return parent::createUrl($route, $params, $ampersand);
}