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
5d6c314d
Commit
5d6c314d
authored
Mar 10, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjusted URL helper, fixed usage
parent
92b38179
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
48 additions
and
34 deletions
+48
-34
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
ViewRenderer.php
extensions/smarty/ViewRenderer.php
+2
-1
ViewRenderer.php
extensions/twig/ViewRenderer.php
+2
-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
+27
-15
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 @
5d6c314d
...
@@ -136,7 +136,7 @@ class SideNavWidget extends \yii\bootstrap\Widget
...
@@ -136,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
=
Url
::
to
Route
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$url
=
Url
::
to
(
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 @
5d6c314d
...
@@ -196,7 +196,7 @@ class Choice extends Widget
...
@@ -196,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
Url
::
to
Route
(
$url
);
return
Url
::
to
(
$url
);
}
}
/**
/**
...
...
extensions/debug/views/default/toolbar.php
View file @
5d6c314d
...
@@ -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=
"
<?=
Url
::
to
Route
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
to
([
'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 @
5d6c314d
...
@@ -20,7 +20,7 @@ $this->title = 'Yii Debugger';
...
@@ -20,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=
"
<?=
Url
::
to
Route
([
'index'
])
?>
"
>
<a
href=
"
<?=
Url
::
to
([
'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 @
5d6c314d
...
@@ -84,7 +84,7 @@ EOD;
...
@@ -84,7 +84,7 @@ EOD;
},
},
]);
]);
}
}
$ajaxUrl
=
Url
::
to
Route
([
'elasticsearch-query'
,
'logId'
=>
$logId
,
'tag'
=>
$this
->
tag
]);
$ajaxUrl
=
Url
::
to
([
'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 @
5d6c314d
...
@@ -121,7 +121,7 @@ class Tabs extends Widget
...
@@ -121,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
=
Url
::
to
Route
(
$item
[
'url'
]);
$url
=
Url
::
to
(
$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 @
5d6c314d
...
@@ -13,6 +13,7 @@ use Yii;
...
@@ -13,6 +13,7 @@ use Yii;
use
Smarty
;
use
Smarty
;
use
yii\base\View
;
use
yii\base\View
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
use
yii\base\ViewRenderer
as
BaseViewRenderer
;
use
yii\helpers\Url
;
/**
/**
* SmartyViewRenderer allows you to use Smarty templates in views.
* SmartyViewRenderer allows you to use Smarty templates in views.
...
@@ -69,7 +70,7 @@ class ViewRenderer extends BaseViewRenderer
...
@@ -69,7 +70,7 @@ class ViewRenderer extends BaseViewRenderer
array_unshift
(
$params
,
$params
[
'route'
])
;
array_unshift
(
$params
,
$params
[
'route'
])
;
unset
(
$params
[
'route'
]);
unset
(
$params
[
'route'
]);
return
BaseViewRenderer
::
url
(
$params
);
return
Url
::
to
(
$params
);
}
}
/**
/**
...
...
extensions/twig/ViewRenderer.php
View file @
5d6c314d
...
@@ -12,6 +12,7 @@ namespace yii\twig;
...
@@ -12,6 +12,7 @@ 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\Url
;
/**
/**
* TwigViewRenderer allows you to use Twig templates in views.
* TwigViewRenderer allows you to use Twig templates in views.
...
@@ -121,7 +122,7 @@ class ViewRenderer extends BaseViewRenderer
...
@@ -121,7 +122,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
BaseViewRenderer
::
url
(
array_merge
([
$path
],
$args
));
return
Url
::
to
(
array_merge
([
$path
],
$args
));
}));
}));
$this
->
twig
->
addGlobal
(
'app'
,
\Yii
::
$app
);
$this
->
twig
->
addGlobal
(
'app'
,
\Yii
::
$app
);
...
...
framework/captcha/Captcha.php
View file @
5d6c314d
...
@@ -107,7 +107,7 @@ class Captcha extends InputWidget
...
@@ -107,7 +107,7 @@ class Captcha extends InputWidget
protected
function
getClientOptions
()
protected
function
getClientOptions
()
{
{
$options
=
[
$options
=
[
'refreshUrl'
=>
Url
::
to
Route
([
'/'
.
$this
->
captchaAction
,
CaptchaAction
::
REFRESH_GET_VAR
=>
1
]),
'refreshUrl'
=>
Url
::
to
([
'/'
.
$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 @
5d6c314d
...
@@ -219,7 +219,7 @@ class GridView extends BaseListView
...
@@ -219,7 +219,7 @@ class GridView extends BaseListView
}
}
return
[
return
[
'filterUrl'
=>
Url
::
to
Route
(
$filterUrl
),
'filterUrl'
=>
Url
::
to
(
$filterUrl
),
'filterSelector'
=>
$filterSelector
,
'filterSelector'
=>
$filterSelector
,
];
];
}
}
...
...
framework/helpers/BaseHtml.php
View file @
5d6c314d
...
@@ -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'
]
=
Url
::
to
Route
(
$url
);
$options
[
'href'
]
=
Url
::
to
(
$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'
]
=
Url
::
to
Route
(
$url
);
$options
[
'src'
]
=
Url
::
to
(
$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
=
Url
::
to
Route
(
$action
);
$action
=
Url
::
to
(
$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'
]
=
Url
::
to
Route
(
$url
);
$options
[
'href'
]
=
Url
::
to
(
$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'
]
=
Url
::
to
Route
(
$src
);
$options
[
'src'
]
=
Url
::
to
(
$src
);
if
(
!
isset
(
$options
[
'alt'
]))
{
if
(
!
isset
(
$options
[
'alt'
]))
{
$options
[
'alt'
]
=
''
;
$options
[
'alt'
]
=
''
;
}
}
...
...
framework/helpers/BaseUrl.php
View file @
5d6c314d
...
@@ -51,25 +51,36 @@ class BaseUrl
...
@@ -51,25 +51,36 @@ class BaseUrl
}
}
/**
/**
*
Returns URL to asset located under webroot
*
Normalizes the input parameter to be a valid URL.
*
*
* @param string $asset will first be processed by [[Yii::getAlias()]]. If the result is an absolute URL, it will be
* If the input parameter
* returned without any change further; Otherwise, the result will be prefixed with [[\yii\web\Request::baseUrl]] and returned.
*
* - 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
* @param boolean $absolute if URL should be absolute
* @param boolean $absolute if URL should be absolute
* @return string
* @return string the normalized URL
* @throws InvalidParamException if the parameter is invalid.
*/
*/
public
function
toAsset
(
$asset
=
null
,
$absolute
=
false
)
public
static
function
to
(
$url
=
null
,
$absolute
=
false
)
{
{
$route
=
Yii
::
getAlias
(
$asset
);
if
(
is_array
(
$url
)
&&
isset
(
$url
[
0
])
||
$url
===
''
)
{
if
(
$route
!==
''
&&
(
$route
[
0
]
===
'/'
||
$route
[
0
]
===
'#'
||
strpos
(
$route
,
'://'
)
||
!
strncmp
(
$route
,
'./'
,
2
)))
{
return
static
::
to
(
$url
,
$absolute
);
return
$route
;
}
else
{
}
else
{
$result
=
$absolute
?
Yii
::
$app
->
getRequest
()
->
getHostInfo
()
:
''
;
$url
=
Yii
::
getAlias
(
$url
);
$result
.=
Yii
::
$app
->
getRequest
()
->
getBaseUrl
();
if
(
$url
!==
''
&&
(
$url
[
0
]
===
'/'
||
$url
[
0
]
===
'#'
||
strpos
(
$url
,
'://'
)
||
!
strncmp
(
$url
,
'./'
,
2
)))
{
if
(
$asset
!==
null
)
{
return
$url
;
$result
.=
'/'
.
$asset
;
}
else
{
$prefix
=
$absolute
?
Yii
::
$app
->
request
->
getHostInfo
()
:
''
;
return
$prefix
.
Yii
::
$app
->
getRequest
()
->
getBaseUrl
()
.
'/'
.
$url
;
}
}
return
$result
;
}
}
}
}
...
@@ -125,8 +136,8 @@ class BaseUrl
...
@@ -125,8 +136,8 @@ class BaseUrl
*/
*/
public
function
home
(
$absolute
=
false
)
public
function
home
(
$absolute
=
false
)
{
{
$
result
=
$absolute
?
Yii
::
$app
->
request
->
getHostInfo
()
:
''
;
$
prefix
=
$absolute
?
Yii
::
$app
->
request
->
getHostInfo
()
:
''
;
return
$
result
.
Yii
::
$app
->
getHomeUrl
();
return
$
prefix
.
Yii
::
$app
->
getHomeUrl
();
}
}
}
}
\ No newline at end of file
framework/web/Controller.php
View file @
5d6c314d
...
@@ -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
(
Url
::
to
Route
(
$url
),
$statusCode
);
return
Yii
::
$app
->
getResponse
()
->
redirect
(
Url
::
to
(
$url
),
$statusCode
);
}
}
/**
/**
...
...
framework/web/Response.php
View file @
5d6c314d
...
@@ -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
=
Url
::
to
Route
(
$url
);
$url
=
Url
::
to
(
$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 @
5d6c314d
...
@@ -195,7 +195,7 @@ class ActiveForm extends Widget
...
@@ -195,7 +195,7 @@ class ActiveForm extends Widget
'ajaxDataType'
=>
$this
->
ajaxDataType
,
'ajaxDataType'
=>
$this
->
ajaxDataType
,
];
];
if
(
$this
->
validationUrl
!==
null
)
{
if
(
$this
->
validationUrl
!==
null
)
{
$options
[
'validationUrl'
]
=
Url
::
to
Route
(
$this
->
validationUrl
);
$options
[
'validationUrl'
]
=
Url
::
to
(
$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 @
5d6c314d
...
@@ -219,7 +219,7 @@ class Menu extends Widget
...
@@ -219,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}'
=>
Url
::
to
Route
(
$item
[
'url'
]),
'{url}'
=>
Url
::
to
(
$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