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
3400eb52
Commit
3400eb52
authored
Mar 09, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#2630: `yii\heplers\Html::url` moved to new `yii\helpers\Url::create`
parent
c4b8f4b6
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
118 additions
and
66 deletions
+118
-66
SideNavWidget.php
extensions/apidoc/templates/bootstrap/SideNavWidget.php
+2
-1
Choice.php
extensions/authclient/widgets/Choice.php
+2
-1
toolbar.php
extensions/debug/views/default/toolbar.php
+2
-2
view.php
extensions/debug/views/default/view.php
+2
-1
DebugPanel.php
extensions/elasticsearch/DebugPanel.php
+2
-1
Tabs.php
extensions/jui/Tabs.php
+2
-1
ViewRenderer.php
extensions/smarty/ViewRenderer.php
+1
-2
ViewRenderer.php
extensions/twig/ViewRenderer.php
+1
-2
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Captcha.php
framework/captcha/Captcha.php
+2
-1
GridView.php
framework/grid/GridView.php
+2
-1
BaseHtml.php
framework/helpers/BaseHtml.php
+5
-47
BaseUrl.php
framework/helpers/BaseUrl.php
+66
-0
Url.php
framework/helpers/Url.php
+20
-0
Controller.php
framework/web/Controller.php
+2
-2
Response.php
framework/web/Response.php
+2
-2
ActiveForm.php
framework/widgets/ActiveForm.php
+2
-1
Menu.php
framework/widgets/Menu.php
+2
-1
No files found.
extensions/apidoc/templates/bootstrap/SideNavWidget.php
View file @
3400eb52
...
@@ -11,6 +11,7 @@ use Yii;
...
@@ -11,6 +11,7 @@ use Yii;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\bootstrap\BootstrapAsset
;
use
yii\bootstrap\BootstrapAsset
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
/**
/**
...
@@ -135,7 +136,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
...
@@ -135,7 +136,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
$label
=
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
];
$label
=
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
];
// $options = ArrayHelper::getValue($item, 'options', []);
// $options = ArrayHelper::getValue($item, 'options', []);
$items
=
ArrayHelper
::
getValue
(
$item
,
'items'
);
$items
=
ArrayHelper
::
getValue
(
$item
,
'items'
);
$url
=
Html
::
url
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$url
=
Url
::
create
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$linkOptions
=
ArrayHelper
::
getValue
(
$item
,
'linkOptions'
,
[]);
$linkOptions
=
ArrayHelper
::
getValue
(
$item
,
'linkOptions'
,
[]);
Html
::
addCssClass
(
$linkOptions
,
'list-group-item'
);
Html
::
addCssClass
(
$linkOptions
,
'list-group-item'
);
...
...
extensions/authclient/widgets/Choice.php
View file @
3400eb52
...
@@ -9,6 +9,7 @@ namespace yii\authclient\widgets;
...
@@ -9,6 +9,7 @@ namespace yii\authclient\widgets;
use
yii\base\Widget
;
use
yii\base\Widget
;
use
Yii
;
use
Yii
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\authclient\ClientInterface
;
use
yii\authclient\ClientInterface
;
...
@@ -195,7 +196,7 @@ class Choice extends Widget
...
@@ -195,7 +196,7 @@ class Choice extends Widget
$this
->
autoRender
=
false
;
$this
->
autoRender
=
false
;
$url
=
$this
->
getBaseAuthUrl
();
$url
=
$this
->
getBaseAuthUrl
();
$url
[
$this
->
clientIdGetParamName
]
=
$provider
->
getId
();
$url
[
$this
->
clientIdGetParamName
]
=
$provider
->
getId
();
return
Html
::
url
(
$url
);
return
Url
::
create
(
$url
);
}
}
/**
/**
...
...
extensions/debug/views/default/toolbar.php
View file @
3400eb52
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* @var string $tag
* @var string $tag
* @var string $position
* @var string $position
*/
*/
use
yii\helpers\
Htm
l
;
use
yii\helpers\
Ur
l
;
$minJs
=
<<<EOD
$minJs
=
<<<EOD
document.getElementById('yii-debug-toolbar').style.display = 'none';
document.getElementById('yii-debug-toolbar').style.display = 'none';
...
@@ -28,7 +28,7 @@ $url = $firstPanel->getUrl();
...
@@ -28,7 +28,7 @@ $url = $firstPanel->getUrl();
?>
?>
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-
<?=
$position
?>
"
>
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-
<?=
$position
?>
"
>
<div
class=
"yii-debug-toolbar-block title"
>
<div
class=
"yii-debug-toolbar-block title"
>
<a
href=
"
<?=
Html
::
url
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
create
([
'index'
])
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
Yii Debugger
Yii Debugger
</a>
</a>
...
...
extensions/debug/views/default/view.php
View file @
3400eb52
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
use
yii\bootstrap\ButtonDropdown
;
use
yii\bootstrap\ButtonDropdown
;
use
yii\bootstrap\ButtonGroup
;
use
yii\bootstrap\ButtonGroup
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
/**
/**
...
@@ -19,7 +20,7 @@ $this->title = 'Yii Debugger';
...
@@ -19,7 +20,7 @@ $this->title = 'Yii Debugger';
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-top"
>
<div
id=
"yii-debug-toolbar"
class=
"yii-debug-toolbar-top"
>
<div
class=
"yii-debug-toolbar-block title"
>
<div
class=
"yii-debug-toolbar-block title"
>
<a
href=
"
<?=
Html
::
url
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
create
([
'index'
])
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
<img
width=
"29"
height=
"30"
alt=
""
src=
"
<?=
\yii\debug\Module
::
getYiiLogo
()
?>
"
>
Yii Debugger
Yii Debugger
</a>
</a>
...
...
extensions/elasticsearch/DebugPanel.php
View file @
3400eb52
...
@@ -9,6 +9,7 @@ namespace yii\elasticsearch;
...
@@ -9,6 +9,7 @@ namespace yii\elasticsearch;
use
yii\debug\Panel
;
use
yii\debug\Panel
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Url
;
use
yii\log\Logger
;
use
yii\log\Logger
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\web\View
;
use
yii\web\View
;
...
@@ -83,7 +84,7 @@ EOD;
...
@@ -83,7 +84,7 @@ EOD;
},
},
]);
]);
}
}
$ajaxUrl
=
Html
::
url
([
'elasticsearch-query'
,
'logId'
=>
$logId
,
'tag'
=>
$this
->
tag
]);
$ajaxUrl
=
Url
::
create
([
'elasticsearch-query'
,
'logId'
=>
$logId
,
'tag'
=>
$this
->
tag
]);
\Yii
::
$app
->
view
->
registerJs
(
<<<JS
\Yii
::
$app
->
view
->
registerJs
(
<<<JS
$('#elastic-link-$i').on('click', function() {
$('#elastic-link-$i').on('click', function() {
var result = $('#elastic-result-$i');
var result = $('#elastic-result-$i');
...
...
extensions/jui/Tabs.php
View file @
3400eb52
...
@@ -9,6 +9,7 @@ namespace yii\jui;
...
@@ -9,6 +9,7 @@ namespace yii\jui;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
/**
/**
...
@@ -120,7 +121,7 @@ class Tabs extends Widget
...
@@ -120,7 +121,7 @@ class Tabs extends Widget
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
throw
new
InvalidConfigException
(
"The 'label' option is required."
);
}
}
if
(
isset
(
$item
[
'url'
]))
{
if
(
isset
(
$item
[
'url'
]))
{
$url
=
Html
::
url
(
$item
[
'url'
]);
$url
=
Url
::
create
(
$item
[
'url'
]);
}
else
{
}
else
{
if
(
!
isset
(
$item
[
'content'
]))
{
if
(
!
isset
(
$item
[
'content'
]))
{
throw
new
InvalidConfigException
(
"The 'content' or 'url' option is required."
);
throw
new
InvalidConfigException
(
"The 'content' or 'url' option is required."
);
...
...
extensions/smarty/ViewRenderer.php
View file @
3400eb52
...
@@ -12,7 +12,6 @@ namespace yii\smarty;
...
@@ -12,7 +12,6 @@ namespace yii\smarty;
use
Yii
;
use
Yii
;
use
Smarty
;
use
Smarty
;
use
yii\base\View
;
use
yii\base\View
;
use
yii\helpers\Html
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
/**
/**
...
@@ -70,7 +69,7 @@ class ViewRenderer extends BaseViewRenderer
...
@@ -70,7 +69,7 @@ class ViewRenderer extends BaseViewRenderer
array_unshift
(
$params
,
$params
[
'route'
])
;
array_unshift
(
$params
,
$params
[
'route'
])
;
unset
(
$params
[
'route'
]);
unset
(
$params
[
'route'
]);
return
Html
::
url
(
$params
);
return
BaseViewRenderer
::
url
(
$params
);
}
}
/**
/**
...
...
extensions/twig/ViewRenderer.php
View file @
3400eb52
...
@@ -12,7 +12,6 @@ namespace yii\twig;
...
@@ -12,7 +12,6 @@ namespace yii\twig;
use
Yii
;
use
Yii
;
use
yii\base\View
;
use
yii\base\View
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
use
yii\helpers\Html
;
/**
/**
* TwigViewRenderer allows you to use Twig templates in views.
* TwigViewRenderer allows you to use Twig templates in views.
...
@@ -122,7 +121,7 @@ class ViewRenderer extends BaseViewRenderer
...
@@ -122,7 +121,7 @@ class ViewRenderer extends BaseViewRenderer
}));
}));
$this
->
twig
->
addFunction
(
'path'
,
new
\Twig_Function_Function
(
function
(
$path
,
$args
=
[])
{
$this
->
twig
->
addFunction
(
'path'
,
new
\Twig_Function_Function
(
function
(
$path
,
$args
=
[])
{
return
Html
::
url
(
array_merge
([
$path
],
$args
));
return
BaseViewRenderer
::
url
(
array_merge
([
$path
],
$args
));
}));
}));
$this
->
twig
->
addGlobal
(
'app'
,
\Yii
::
$app
);
$this
->
twig
->
addGlobal
(
'app'
,
\Yii
::
$app
);
...
...
framework/CHANGELOG.md
View file @
3400eb52
...
@@ -191,6 +191,7 @@ Yii Framework 2 Change Log
...
@@ -191,6 +191,7 @@ Yii Framework 2 Change Log
-
Chg #2544: Changed
`DetailView`
's
`name:format:label`
to
`attribute:format:label`
to match
`GridView`
(samdark)
-
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 #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 #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: Renamed
`yii\jui\Widget::clientEventsMap`
to
`clientEventMap`
(qiangxue)
-
Chg: Renamed
`yii\jui\Widget::clientEventsMap`
to
`clientEventMap`
(qiangxue)
-
Chg: Renamed
`ActiveRecord::getPopulatedRelations()`
to
`getRelatedRecords()`
(qiangxue)
-
Chg: Renamed
`ActiveRecord::getPopulatedRelations()`
to
`getRelatedRecords()`
(qiangxue)
-
Chg: Renamed
`attributeName`
and
`className`
to
`targetAttribute`
and
`targetClass`
for
`UniqueValidator`
and
`ExistValidator`
(qiangxue)
-
Chg: Renamed
`attributeName`
and
`className`
to
`targetAttribute`
and
`targetClass`
for
`UniqueValidator`
and
`ExistValidator`
(qiangxue)
...
...
framework/captcha/Captcha.php
View file @
3400eb52
...
@@ -9,6 +9,7 @@ namespace yii\captcha;
...
@@ -9,6 +9,7 @@ namespace yii\captcha;
use
Yii
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
use
yii\widgets\InputWidget
;
use
yii\widgets\InputWidget
;
...
@@ -106,7 +107,7 @@ class Captcha extends InputWidget
...
@@ -106,7 +107,7 @@ class Captcha extends InputWidget
protected
function
getClientOptions
()
protected
function
getClientOptions
()
{
{
$options
=
[
$options
=
[
'refreshUrl'
=>
Html
::
url
([
'/'
.
$this
->
captchaAction
,
CaptchaAction
::
REFRESH_GET_VAR
=>
1
]),
'refreshUrl'
=>
Url
::
create
([
'/'
.
$this
->
captchaAction
,
CaptchaAction
::
REFRESH_GET_VAR
=>
1
]),
'hashKey'
=>
"yiiCaptcha/
{
$this
->
captchaAction
}
"
,
'hashKey'
=>
"yiiCaptcha/
{
$this
->
captchaAction
}
"
,
];
];
return
$options
;
return
$options
;
...
...
framework/grid/GridView.php
View file @
3400eb52
...
@@ -11,6 +11,7 @@ use Yii;
...
@@ -11,6 +11,7 @@ use Yii;
use
Closure
;
use
Closure
;
use
yii\base\Formatter
;
use
yii\base\Formatter
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
use
yii\widgets\BaseListView
;
use
yii\widgets\BaseListView
;
...
@@ -218,7 +219,7 @@ class GridView extends BaseListView
...
@@ -218,7 +219,7 @@ class GridView extends BaseListView
}
}
return
[
return
[
'filterUrl'
=>
Html
::
url
(
$filterUrl
),
'filterUrl'
=>
Url
::
create
(
$filterUrl
),
'filterSelector'
=>
$filterSelector
,
'filterSelector'
=>
$filterSelector
,
];
];
}
}
...
...
framework/helpers/BaseHtml.php
View file @
3400eb52
...
@@ -205,7 +205,7 @@ class BaseHtml
...
@@ -205,7 +205,7 @@ class BaseHtml
if
(
!
isset
(
$options
[
'rel'
]))
{
if
(
!
isset
(
$options
[
'rel'
]))
{
$options
[
'rel'
]
=
'stylesheet'
;
$options
[
'rel'
]
=
'stylesheet'
;
}
}
$options
[
'href'
]
=
static
::
url
(
$url
);
$options
[
'href'
]
=
Url
::
create
(
$url
);
return
static
::
tag
(
'link'
,
''
,
$options
);
return
static
::
tag
(
'link'
,
''
,
$options
);
}
}
...
@@ -221,7 +221,7 @@ class BaseHtml
...
@@ -221,7 +221,7 @@ class BaseHtml
*/
*/
public
static
function
jsFile
(
$url
,
$options
=
[])
public
static
function
jsFile
(
$url
,
$options
=
[])
{
{
$options
[
'src'
]
=
static
::
url
(
$url
);
$options
[
'src'
]
=
Url
::
create
(
$url
);
return
static
::
tag
(
'script'
,
''
,
$options
);
return
static
::
tag
(
'script'
,
''
,
$options
);
}
}
...
@@ -241,7 +241,7 @@ class BaseHtml
...
@@ -241,7 +241,7 @@ class BaseHtml
*/
*/
public
static
function
beginForm
(
$action
=
''
,
$method
=
'post'
,
$options
=
[])
public
static
function
beginForm
(
$action
=
''
,
$method
=
'post'
,
$options
=
[])
{
{
$action
=
static
::
url
(
$action
);
$action
=
Url
::
create
(
$action
);
$hiddenInputs
=
[];
$hiddenInputs
=
[];
...
@@ -311,7 +311,7 @@ class BaseHtml
...
@@ -311,7 +311,7 @@ class BaseHtml
public
static
function
a
(
$text
,
$url
=
null
,
$options
=
[])
public
static
function
a
(
$text
,
$url
=
null
,
$options
=
[])
{
{
if
(
$url
!==
null
)
{
if
(
$url
!==
null
)
{
$options
[
'href'
]
=
static
::
url
(
$url
);
$options
[
'href'
]
=
Url
::
create
(
$url
);
}
}
return
static
::
tag
(
'a'
,
$text
,
$options
);
return
static
::
tag
(
'a'
,
$text
,
$options
);
}
}
...
@@ -346,7 +346,7 @@ class BaseHtml
...
@@ -346,7 +346,7 @@ class BaseHtml
*/
*/
public
static
function
img
(
$src
,
$options
=
[])
public
static
function
img
(
$src
,
$options
=
[])
{
{
$options
[
'src'
]
=
static
::
url
(
$src
);
$options
[
'src'
]
=
Url
::
create
(
$src
);
if
(
!
isset
(
$options
[
'alt'
]))
{
if
(
!
isset
(
$options
[
'alt'
]))
{
$options
[
'alt'
]
=
''
;
$options
[
'alt'
]
=
''
;
}
}
...
@@ -1528,48 +1528,6 @@ class BaseHtml
...
@@ -1528,48 +1528,6 @@ class BaseHtml
}
}
/**
/**
* Normalizes the input parameter to be a valid URL.
*
* If the input parameter
*
* - 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 $url the parameter to be used to generate a valid URL
* @return string the normalized URL
* @throws InvalidParamException if the parameter is invalid.
*/
public
static
function
url
(
$url
)
{
if
(
is_array
(
$url
))
{
if
(
isset
(
$url
[
0
]))
{
if
(
Yii
::
$app
->
controller
instanceof
\yii\web\Controller
)
{
return
Yii
::
$app
->
controller
->
createUrl
(
$url
);
}
else
{
return
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$url
);
}
}
else
{
throw
new
InvalidParamException
(
'The array specifying a URL must contain at least one element.'
);
}
}
elseif
(
$url
===
''
)
{
return
Yii
::
$app
->
getRequest
()
->
getUrl
();
}
else
{
$url
=
Yii
::
getAlias
(
$url
);
if
(
$url
!==
''
&&
(
$url
[
0
]
===
'/'
||
$url
[
0
]
===
'#'
||
strpos
(
$url
,
'://'
)
||
!
strncmp
(
$url
,
'./'
,
2
)))
{
return
$url
;
}
else
{
return
Yii
::
$app
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$url
;
}
}
}
/**
* Adds a CSS class to the specified options.
* Adds a CSS class to the specified options.
* If the CSS class is already in the options, it will not be added again.
* If the CSS class is already in the options, it will not be added again.
* @param array $options the options to be modified.
* @param array $options the options to be modified.
...
...
framework/helpers/BaseUrl.php
0 → 100644
View file @
3400eb52
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\helpers
;
use
yii\base\InvalidParamException
;
use
Yii
;
/**
* BaseUrl provides concrete implementation for [[Url]].
*
* Do not use BaseUrl. Use [[Url]] instead.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class
BaseUrl
{
/**
* Normalizes the input parameter to be a valid URL.
*
* If the input parameter
*
* - 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 $url the parameter to be used to generate a valid URL
* @return string the normalized URL
* @throws InvalidParamException if the parameter is invalid.
*/
public
static
function
create
(
$url
)
{
if
(
is_array
(
$url
))
{
if
(
isset
(
$url
[
0
]))
{
if
(
Yii
::
$app
->
controller
instanceof
\yii\web\Controller
)
{
return
Yii
::
$app
->
controller
->
createUrl
(
$url
);
}
else
{
return
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$url
);
}
}
else
{
throw
new
InvalidParamException
(
'The array specifying a URL must contain at least one element.'
);
}
}
elseif
(
$url
===
''
)
{
return
Yii
::
$app
->
getRequest
()
->
getUrl
();
}
else
{
$url
=
Yii
::
getAlias
(
$url
);
if
(
$url
!==
''
&&
(
$url
[
0
]
===
'/'
||
$url
[
0
]
===
'#'
||
strpos
(
$url
,
'://'
)
||
!
strncmp
(
$url
,
'./'
,
2
)))
{
return
$url
;
}
else
{
return
Yii
::
$app
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$url
;
}
}
}
}
\ No newline at end of file
framework/helpers/Url.php
0 → 100644
View file @
3400eb52
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\helpers
;
/**
* Url provides a set of static methods for managing URLs.
*
* @author Alexander Makarov <sam@rmcreative.ru>
* @since 2.0
*/
class
Url
extends
BaseUrl
{
}
\ No newline at end of file
framework/web/Controller.php
View file @
3400eb52
...
@@ -9,7 +9,7 @@ namespace yii\web;
...
@@ -9,7 +9,7 @@ namespace yii\web;
use
Yii
;
use
Yii
;
use
yii\base\InlineAction
;
use
yii\base\InlineAction
;
use
yii\helpers\
Htm
l
;
use
yii\helpers\
Ur
l
;
/**
/**
* Controller is the base class of web controllers.
* Controller is the base class of web controllers.
...
@@ -241,7 +241,7 @@ class Controller extends \yii\base\Controller
...
@@ -241,7 +241,7 @@ class Controller extends \yii\base\Controller
*/
*/
public
function
redirect
(
$url
,
$statusCode
=
302
)
public
function
redirect
(
$url
,
$statusCode
=
302
)
{
{
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Html
::
url
(
$url
),
$statusCode
);
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Url
::
create
(
$url
),
$statusCode
);
}
}
/**
/**
...
...
framework/web/Response.php
View file @
3400eb52
...
@@ -10,8 +10,8 @@ namespace yii\web;
...
@@ -10,8 +10,8 @@ namespace yii\web;
use
Yii
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidParamException
;
use
yii\base\InvalidParamException
;
use
yii\helpers\Url
;
use
yii\helpers\FileHelper
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
use
yii\helpers\Security
;
use
yii\helpers\Security
;
use
yii\helpers\StringHelper
;
use
yii\helpers\StringHelper
;
...
@@ -673,7 +673,7 @@ class Response extends \yii\base\Response
...
@@ -673,7 +673,7 @@ class Response extends \yii\base\Response
// ensure the route is absolute
// ensure the route is absolute
$url
[
0
]
=
'/'
.
ltrim
(
$url
[
0
],
'/'
);
$url
[
0
]
=
'/'
.
ltrim
(
$url
[
0
],
'/'
);
}
}
$url
=
Html
::
url
(
$url
);
$url
=
Url
::
create
(
$url
);
if
(
strpos
(
$url
,
'/'
)
===
0
&&
strpos
(
$url
,
'//'
)
!==
0
)
{
if
(
strpos
(
$url
,
'/'
)
===
0
&&
strpos
(
$url
,
'//'
)
!==
0
)
{
$url
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
.
$url
;
$url
=
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
.
$url
;
}
}
...
...
framework/widgets/ActiveForm.php
View file @
3400eb52
...
@@ -10,6 +10,7 @@ namespace yii\widgets;
...
@@ -10,6 +10,7 @@ namespace yii\widgets;
use
Yii
;
use
Yii
;
use
yii\base\Widget
;
use
yii\base\Widget
;
use
yii\base\Model
;
use
yii\base\Model
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\helpers\Json
;
use
yii\web\JsExpression
;
use
yii\web\JsExpression
;
...
@@ -194,7 +195,7 @@ class ActiveForm extends Widget
...
@@ -194,7 +195,7 @@ class ActiveForm extends Widget
'ajaxDataType'
=>
$this
->
ajaxDataType
,
'ajaxDataType'
=>
$this
->
ajaxDataType
,
];
];
if
(
$this
->
validationUrl
!==
null
)
{
if
(
$this
->
validationUrl
!==
null
)
{
$options
[
'validationUrl'
]
=
Html
::
url
(
$this
->
validationUrl
);
$options
[
'validationUrl'
]
=
Url
::
create
(
$this
->
validationUrl
);
}
}
foreach
([
'beforeSubmit'
,
'beforeValidate'
,
'afterValidate'
]
as
$name
)
{
foreach
([
'beforeSubmit'
,
'beforeValidate'
,
'afterValidate'
]
as
$name
)
{
if
((
$value
=
$this
->
$name
)
!==
null
)
{
if
((
$value
=
$this
->
$name
)
!==
null
)
{
...
...
framework/widgets/Menu.php
View file @
3400eb52
...
@@ -10,6 +10,7 @@ namespace yii\widgets;
...
@@ -10,6 +10,7 @@ namespace yii\widgets;
use
Yii
;
use
Yii
;
use
yii\base\Widget
;
use
yii\base\Widget
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Url
;
use
yii\helpers\Html
;
use
yii\helpers\Html
;
/**
/**
...
@@ -218,7 +219,7 @@ class Menu extends Widget
...
@@ -218,7 +219,7 @@ class Menu extends Widget
if
(
isset
(
$item
[
'url'
]))
{
if
(
isset
(
$item
[
'url'
]))
{
$template
=
ArrayHelper
::
getValue
(
$item
,
'template'
,
$this
->
linkTemplate
);
$template
=
ArrayHelper
::
getValue
(
$item
,
'template'
,
$this
->
linkTemplate
);
return
strtr
(
$template
,
[
return
strtr
(
$template
,
[
'{url}'
=>
Html
::
url
(
$item
[
'url'
]),
'{url}'
=>
Url
::
create
(
$item
[
'url'
]),
'{label}'
=>
$item
[
'label'
],
'{label}'
=>
$item
[
'label'
],
]);
]);
}
else
{
}
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