Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
92b38179
Commit
92b38179
authored
Mar 10, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted Url helper methods
parent
73b7e03e
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
76 additions
and
75 deletions
+76
-75
SideNavWidget.php
extensions/apidoc/templates/bootstrap/SideNavWidget.php
+1
-1
Choice.php
extensions/authclient/widgets/Choice.php
+1
-1
toolbar.php
extensions/debug/views/default/toolbar.php
+1
-1
view.php
extensions/debug/views/default/view.php
+1
-1
DebugPanel.php
extensions/elasticsearch/DebugPanel.php
+1
-1
Tabs.php
extensions/jui/Tabs.php
+1
-1
CHANGELOG.md
framework/CHANGELOG.md
+1
-1
Captcha.php
framework/captcha/Captcha.php
+1
-1
GridView.php
framework/grid/GridView.php
+1
-1
BaseHtml.php
framework/helpers/BaseHtml.php
+5
-5
BaseUrl.php
framework/helpers/BaseUrl.php
+58
-57
Controller.php
framework/web/Controller.php
+1
-1
Response.php
framework/web/Response.php
+1
-1
ActiveForm.php
framework/widgets/ActiveForm.php
+1
-1
Menu.php
framework/widgets/Menu.php
+1
-1
No files found.
extensions/apidoc/templates/bootstrap/SideNavWidget.php
View file @
92b38179
...
...
@@ -136,7 +136,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
$label
=
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
];
// $options = ArrayHelper::getValue($item, 'options', []);
$items
=
ArrayHelper
::
getValue
(
$item
,
'items'
);
$url
=
Url
::
crea
te
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$url
=
Url
::
toRou
te
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$linkOptions
=
ArrayHelper
::
getValue
(
$item
,
'linkOptions'
,
[]);
Html
::
addCssClass
(
$linkOptions
,
'list-group-item'
);
...
...
extensions/authclient/widgets/Choice.php
View file @
92b38179
...
...
@@ -196,7 +196,7 @@ class Choice extends Widget
$this
->
autoRender
=
false
;
$url
=
$this
->
getBaseAuthUrl
();
$url
[
$this
->
clientIdGetParamName
]
=
$provider
->
getId
();
return
Url
::
crea
te
(
$url
);
return
Url
::
toRou
te
(
$url
);
}
/**
...
...
extensions/debug/views/default/toolbar.php
View file @
92b38179
...
...
@@ -28,7 +28,7 @@ $url = $firstPanel->getUrl();
?>
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-
<?=
$position
?>
"
>
<div
class=
"yii-debug-toolbar-block title"
>
<a
href=
"
<?=
Url
::
crea
te
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
toRou
te
([
'index'
])
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
Yii Debugger
</a>
...
...
extensions/debug/views/default/view.php
View file @
92b38179
...
...
@@ -20,7 +20,7 @@ $this->title = 'Yii Debugger';
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-top"
>
<div
class=
"yii-debug-toolbar-block title"
>
<a
href=
"
<?=
Url
::
crea
te
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
toRou
te
([
'index'
])
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
Yii Debugger
</a>
...
...
extensions/elasticsearch/DebugPanel.php
View file @
92b38179
...
...
@@ -84,7 +84,7 @@ EOD;
},
]);
}
$ajaxUrl
=
Url
::
crea
te
([
'elasticsearch-query'
,
'logId'
=>
$logId
,
'tag'
=>
$this
->
tag
]);
$ajaxUrl
=
Url
::
toRou
te
([
'elasticsearch-query'
,
'logId'
=>
$logId
,
'tag'
=>
$this
->
tag
]);
\Yii
::
$app
->
view
->
registerJs
(
<<<JS
$('#elastic-link-$i').on('click', function() {
var result = $('#elastic-result-$i');
...
...
extensions/jui/Tabs.php
View file @
92b38179
...
...
@@ -121,7 +121,7 @@ class Tabs extends Widget
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
}
if
(
isset
(
$item
[
'url'
]))
{
$url
=
Url
::
crea
te
(
$item
[
'url'
]);
$url
=
Url
::
toRou
te
(
$item
[
'url'
]);
}
else
{
if
(
!
isset
(
$item
[
'content'
]))
{
throw
new
InvalidConfigException
(
"The 'content' or 'url' option is required."
);
...
...
framework/CHANGELOG.md
View file @
92b38179
...
...
@@ -191,7 +191,7 @@ Yii Framework 2 Change Log
-
Chg #2544: Changed
`DetailView`
's
`name:format:label`
to
`attribute:format:label`
to match
`GridView`
(samdark)
-
Chg #2603:
`yii\base\ErrorException`
now extends
`\ErrorException`
(samdark)
-
Chg #2629:
`Module::controllerPath`
is now read only, and all controller classes must be namespaced under
`Module::controllerNamespace`
. (qiangxue)
-
Chg #2630:
`yii\heplers\Html::url`
moved to new
`yii\helpers\Url::create`
(samdark)
-
Chg #2630:
`yii\heplers\Html::url`
removed
(samdark)
-
Chg: Renamed
`yii\jui\Widget::clientEventsMap`
to
`clientEventMap`
(qiangxue)
-
Chg: Renamed
`ActiveRecord::getPopulatedRelations()`
to
`getRelatedRecords()`
(qiangxue)
-
Chg: Renamed
`attributeName`
and
`className`
to
`targetAttribute`
and
`targetClass`
for
`UniqueValidator`
and
`ExistValidator`
(qiangxue)
...
...
framework/captcha/Captcha.php
View file @
92b38179
...
...
@@ -107,7 +107,7 @@ class Captcha extends InputWidget
protected
function
getClientOptions
()
{
$options
=
[
'refreshUrl'
=>
Url
::
crea
te
([
'/'
.
$this
->
captchaAction
,
CaptchaAction
::
REFRESH_GET_VAR
=>
1
]),
'refreshUrl'
=>
Url
::
toRou
te
([
'/'
.
$this
->
captchaAction
,
CaptchaAction
::
REFRESH_GET_VAR
=>
1
]),
'hashKey'
=>
"yiiCaptcha/
{
$this
->
captchaAction
}
"
,
];
return
$options
;
...
...
framework/grid/GridView.php
View file @
92b38179
...
...
@@ -219,7 +219,7 @@ class GridView extends BaseListView
}
return
[
'filterUrl'
=>
Url
::
crea
te
(
$filterUrl
),
'filterUrl'
=>
Url
::
toRou
te
(
$filterUrl
),
'filterSelector'
=>
$filterSelector
,
];
}
...
...
framework/helpers/BaseHtml.php
View file @
92b38179
...
...
@@ -205,7 +205,7 @@ class BaseHtml
if
(
!
isset
(
$options
[
'rel'
]))
{
$options
[
'rel'
]
=
'stylesheet'
;
}
$options
[
'href'
]
=
Url
::
crea
te
(
$url
);
$options
[
'href'
]
=
Url
::
toRou
te
(
$url
);
return
static
::
tag
(
'link'
,
''
,
$options
);
}
...
...
@@ -221,7 +221,7 @@ class BaseHtml
*/
public
static
function
jsFile
(
$url
,
$options
=
[])
{
$options
[
'src'
]
=
Url
::
crea
te
(
$url
);
$options
[
'src'
]
=
Url
::
toRou
te
(
$url
);
return
static
::
tag
(
'script'
,
''
,
$options
);
}
...
...
@@ -241,7 +241,7 @@ class BaseHtml
*/
public
static
function
beginForm
(
$action
=
''
,
$method
=
'post'
,
$options
=
[])
{
$action
=
Url
::
crea
te
(
$action
);
$action
=
Url
::
toRou
te
(
$action
);
$hiddenInputs
=
[];
...
...
@@ -311,7 +311,7 @@ class BaseHtml
public
static
function
a
(
$text
,
$url
=
null
,
$options
=
[])
{
if
(
$url
!==
null
)
{
$options
[
'href'
]
=
Url
::
crea
te
(
$url
);
$options
[
'href'
]
=
Url
::
toRou
te
(
$url
);
}
return
static
::
tag
(
'a'
,
$text
,
$options
);
}
...
...
@@ -346,7 +346,7 @@ class BaseHtml
*/
public
static
function
img
(
$src
,
$options
=
[])
{
$options
[
'src'
]
=
Url
::
crea
te
(
$src
);
$options
[
'src'
]
=
Url
::
toRou
te
(
$src
);
if
(
!
isset
(
$options
[
'alt'
]))
{
$options
[
'alt'
]
=
''
;
}
...
...
framework/helpers/BaseUrl.php
View file @
92b38179
...
...
@@ -21,92 +21,90 @@ use Yii;
class
BaseUrl
{
/**
*
Normalizes the input parameter to be a valid URL
.
*
Returns URL for a route
.
*
*
If the input parameter
*
@param array|string $route parametrized route or empty string for current URL:
*
* - is an empty string: the currently requested URL will be returned;
* - is a non-empty string: it will first be processed by [[Yii::getAlias()]]. If the result
* is an absolute URL, it will be returned without any change further; Otherwise, the result
* will be prefixed with [[\yii\web\Request::baseUrl]] and returned.
* - is an array: the first array element is considered a route, while the rest of the name-value
* - an empty string: the currently requested URL will be returned;
* - an array: the first array element is considered a route, while the rest of the name-value
* pairs are treated as the parameters to be used for URL creation using [[\yii\web\Controller::createUrl()]].
* For example: `['post/index', 'page' => 2]`, `['index']`.
* In case there is no controller, [[\yii\web\UrlManager::createUrl()]] will be used.
*
* @param array|string $params the parameter to be used to generate a valid URL
* @param boolean $absolute if absolute URL should be created
* @return string the normalized URL
* @throws InvalidParamException if the parameter is invalid.
*/
public
static
function
create
(
$params
,
$absolute
=
false
)
public
static
function
toRoute
(
$route
,
$absolute
=
false
)
{
if
(
is_array
(
$params
))
{
if
(
isset
(
$params
[
0
]))
{
if
(
Yii
::
$app
->
controller
instanceof
\yii\web\Controller
)
{
return
$absolute
?
Yii
::
$app
->
controller
->
createAbsoluteUrl
(
$params
)
:
Yii
::
$app
->
controller
->
createUrl
(
$params
);
}
else
{
return
$absolute
?
Yii
::
$app
->
getUrlManager
()
->
createAbsoluteUrl
(
$params
)
:
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$params
);
}
}
else
{
throw
new
InvalidParamException
(
'The array specifying a URL must contain at least one element.'
);
}
}
elseif
(
$params
===
''
)
{
if
(
$route
===
''
)
{
return
$absolute
?
Yii
::
$app
->
getRequest
()
->
getAbsoluteUrl
()
:
Yii
::
$app
->
getRequest
()
->
getUrl
();
}
if
(
!
is_array
(
$route
)
||
!
isset
(
$route
[
0
]))
{
throw
new
InvalidParamException
(
'$route should be either empty string or array containing at least one element.'
);
}
if
(
Yii
::
$app
->
controller
instanceof
\yii\web\Controller
)
{
return
$absolute
?
Yii
::
$app
->
controller
->
createAbsoluteUrl
(
$route
)
:
Yii
::
$app
->
controller
->
createUrl
(
$route
);
}
else
{
$params
=
Yii
::
getAlias
(
$params
);
if
(
$params
!==
''
&&
(
$params
[
0
]
===
'/'
||
$params
[
0
]
===
'#'
||
strpos
(
$params
,
'://'
)
||
!
strncmp
(
$params
,
'./'
,
2
)))
{
return
$params
;
}
else
{
return
static
::
base
(
$params
);
}
return
$absolute
?
Yii
::
$app
->
getUrlManager
()
->
createAbsoluteUrl
(
$route
)
:
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$route
);
}
}
/**
* Normalizes the input parameter to be a valid absolute URL.
*
* If the input parameter
* Returns URL to asset located under webroot
*
* - is an empty string: the currently requested URL will be returned;
* - is a non-empty string: it will first be processed by [[Yii::getAlias()]]. If the result
* is an absolute URL, it will be returned without any change further; Otherwise, the result
* will be prefixed with [[\yii\web\Request::baseUrl]] and returned.
* - is an array: the first array element is considered a route, while the rest of the name-value
* pairs are treated as the parameters to be used for URL creation using [[\yii\web\Controller::createUrl()]].
* For example: `['post/index', 'page' => 2]`, `['index']`.
* In case there is no controller, [[\yii\web\UrlManager::createUrl()]] will be used.
*
* @param array|string $params the parameter to be used to generate a valid URL
* @return string the normalized URL
* @throws InvalidParamException if the parameter is invalid.
* @param string $asset will first be processed by [[Yii::getAlias()]]. If the result is an absolute URL, it will be
* returned without any change further; Otherwise, the result will be prefixed with [[\yii\web\Request::baseUrl]] and returned.
* @param boolean $absolute if URL should be absolute
* @return string
*/
public
static
function
createAbsolute
(
$params
)
public
function
toAsset
(
$asset
=
null
,
$absolute
=
false
)
{
return
static
::
create
(
$params
,
true
);
$route
=
Yii
::
getAlias
(
$asset
);
if
(
$route
!==
''
&&
(
$route
[
0
]
===
'/'
||
$route
[
0
]
===
'#'
||
strpos
(
$route
,
'://'
)
||
!
strncmp
(
$route
,
'./'
,
2
)))
{
return
$route
;
}
else
{
$result
=
$absolute
?
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
:
''
;
$result
.=
Yii
::
$app
->
getRequest
()
->
getBaseUrl
();
if
(
$asset
!==
null
)
{
$result
.=
'/'
.
$asset
;
}
return
$result
;
}
}
/**
*
Prefixes relative URL with base URL
*
Remembers URL passed
*
* @param string $url
relative URL
* @
return string absolute URL
* @param string $url
URL to remember. Default is current URL.
* @
param string $name Name to use to remember URL. Defaults to `yii\web\User::returnUrlParam`.
*/
public
function
base
(
$url
=
null
)
public
function
remember
(
$url
=
null
,
$name
=
null
)
{
$result
=
Yii
::
$app
->
getRequest
()
->
getBaseUrl
();
if
(
$url
!==
null
)
{
$result
.=
'/'
.
$url
;
if
(
$url
===
null
)
{
$url
=
Yii
::
$app
->
getRequest
()
->
getUrl
();
}
if
(
$name
===
null
)
{
Yii
::
$app
->
user
->
setReturnUrl
(
$url
);
}
else
{
Yii
::
$app
->
session
->
set
(
$name
,
$url
);
}
return
$result
;
}
/**
* Sets current URL as return URL
* Returns URL previously saved with remember method
*
* @param string $name Name used to remember URL. Defaults to `yii\web\User::returnUrlParam`.
* @return string URL
*/
public
function
rememberReturn
(
)
public
function
previous
(
$name
=
null
)
{
Yii
::
$app
->
user
->
setReturnUrl
(
Yii
::
$app
->
getRequest
()
->
getUrl
());
if
(
$name
===
null
)
{
return
Yii
::
$app
->
user
->
getReturnUrl
();
}
else
{
return
Yii
::
$app
->
session
->
get
(
$name
);
}
}
/**
...
...
@@ -114,7 +112,7 @@ class BaseUrl
*
* @return string canonical URL
*/
public
function
getC
anonical
()
public
function
c
anonical
()
{
return
Yii
::
$app
->
controller
->
getCanonicalUrl
();
}
...
...
@@ -122,11 +120,13 @@ class BaseUrl
/**
* Returns home URL
*
* @param boolean $absolute if absolute URL should be returned
* @return string home URL
*/
public
function
getHome
(
)
public
function
home
(
$absolute
=
false
)
{
return
Yii
::
$app
->
getHomeUrl
();
$result
=
$absolute
?
Yii
::
$app
->
request
->
getHostInfo
()
:
''
;
return
$result
.
Yii
::
$app
->
getHomeUrl
();
}
}
\ No newline at end of file
framework/web/Controller.php
View file @
92b38179
...
...
@@ -241,7 +241,7 @@ class Controller extends \yii\base\Controller
*/
public
function
redirect
(
$url
,
$statusCode
=
302
)
{
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Url
::
crea
te
(
$url
),
$statusCode
);
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Url
::
toRou
te
(
$url
),
$statusCode
);
}
/**
...
...
framework/web/Response.php
View file @
92b38179
...
...
@@ -673,7 +673,7 @@ class Response extends \yii\base\Response
// ensure the route is absolute
$url
[
0
]
=
'/'
.
ltrim
(
$url
[
0
],
'/'
);
}
$url
=
Url
::
crea
te
(
$url
);
$url
=
Url
::
toRou
te
(
$url
);
if
(
strpos
(
$url
,
'/'
)
===
0
&&
strpos
(
$url
,
'//'
)
!==
0
)
{
$url
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
.
$url
;
}
...
...
framework/widgets/ActiveForm.php
View file @
92b38179
...
...
@@ -195,7 +195,7 @@ class ActiveForm extends Widget
'ajaxDataType'
=>
$this
->
ajaxDataType
,
];
if
(
$this
->
validationUrl
!==
null
)
{
$options
[
'validationUrl'
]
=
Url
::
crea
te
(
$this
->
validationUrl
);
$options
[
'validationUrl'
]
=
Url
::
toRou
te
(
$this
->
validationUrl
);
}
foreach
([
'beforeSubmit'
,
'beforeValidate'
,
'afterValidate'
]
as
$name
)
{
if
((
$value
=
$this
->
$name
)
!==
null
)
{
...
...
framework/widgets/Menu.php
View file @
92b38179
...
...
@@ -219,7 +219,7 @@ class Menu extends Widget
if
(
isset
(
$item
[
'url'
]))
{
$template
=
ArrayHelper
::
getValue
(
$item
,
'template'
,
$this
->
linkTemplate
);
return
strtr
(
$template
,
[
'{url}'
=>
Url
::
crea
te
(
$item
[
'url'
]),
'{url}'
=>
Url
::
toRou
te
(
$item
[
'url'
]),
'{label}'
=>
$item
[
'label'
],
]);
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment