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
37e22e57
Commit
37e22e57
authored
Dec 18, 2013
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paginiation and Sort can now create absolute URLs
parent
157b1ffd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
4 deletions
+21
-4
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
Pagination.php
framework/yii/data/Pagination.php
+13
-2
Sort.php
framework/yii/data/Sort.php
+7
-2
No files found.
framework/CHANGELOG.md
View file @
37e22e57
...
...
@@ -21,6 +21,7 @@ Yii Framework 2 Change Log
-
Enh: Added
`favicon.ico`
and
`robots.txt`
to defauly application templates (samdark)
-
Enh: Added
`Widget::autoIdPrefix`
to support prefixing automatically generated widget IDs (qiangxue)
-
Enh: Support for file aliases in console command 'message' (omnilight)
-
Enh: Sort and Paginiation can now create absolute URLs (cebe)
-
Chg: Renamed yii
\j
ui
\W
idget::clientEventsMap to clientEventMap (qiangxue)
-
New #1438:
[
MongoDB integration
](
https://github.com/yiisoft/yii2-mongodb
)
ActiveRecord and Query (klimov-paul)
-
New #1393:
[
Codeception testing framework integration
](
https://github.com/yiisoft/yii2-codeception
)
(
Ragazzo
)
...
...
framework/yii/data/Pagination.php
View file @
37e22e57
...
...
@@ -91,6 +91,11 @@ class Pagination extends Object
*/
public
$params
;
/**
* @var \yii\web\UrlManager the URL manager used for creating pagination URLs. If not set,
* the "urlManager" application component will be used.
*/
public
$urlManager
;
/**
* @var boolean whether to check if [[page]] is within valid range.
* When this property is true, the value of [[page]] will always be between 0 and ([[pageCount]]-1).
* Because [[pageCount]] relies on the correct value of [[totalCount]] which may not be available
...
...
@@ -167,11 +172,12 @@ class Pagination extends Object
* Creates the URL suitable for pagination with the specified page number.
* This method is mainly called by pagers when creating URLs used to perform pagination.
* @param integer $page the zero-based page number that the URL should point to.
* @param boolean $absolute whether to create an absolute URL. Defaults to `false`.
* @return string the created URL
* @see params
* @see forcePageVar
*/
public
function
createUrl
(
$page
)
public
function
createUrl
(
$page
,
$absolute
=
false
)
{
if
((
$params
=
$this
->
params
)
===
null
)
{
$request
=
Yii
::
$app
->
getRequest
();
...
...
@@ -183,7 +189,12 @@ class Pagination extends Object
unset
(
$params
[
$this
->
pageVar
]);
}
$route
=
$this
->
route
===
null
?
Yii
::
$app
->
controller
->
getRoute
()
:
$this
->
route
;
return
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
$route
,
$params
);
$urlManager
=
$this
->
urlManager
===
null
?
Yii
::
$app
->
getUrlManager
()
:
$this
->
urlManager
;
if
(
$absolute
)
{
return
$urlManager
->
createAbsoluteUrl
(
$route
,
$params
);
}
else
{
return
$urlManager
->
createUrl
(
$route
,
$params
);
}
}
/**
...
...
framework/yii/data/Sort.php
View file @
37e22e57
...
...
@@ -329,12 +329,13 @@ class Sort extends Object
* For example, if the current page already sorts the data by the specified attribute in ascending order,
* then the URL created will lead to a page that sorts the data by the specified attribute in descending order.
* @param string $attribute the attribute name
* @param boolean $absolute whether to create an absolute URL. Defaults to `false`.
* @return string the URL for sorting. False if the attribute is invalid.
* @throws InvalidConfigException if the attribute is unknown
* @see attributeOrders
* @see params
*/
public
function
createUrl
(
$attribute
)
public
function
createUrl
(
$attribute
,
$absolute
=
false
)
{
if
((
$params
=
$this
->
params
)
===
null
)
{
$request
=
Yii
::
$app
->
getRequest
();
...
...
@@ -343,7 +344,11 @@ class Sort extends Object
$params
[
$this
->
sortVar
]
=
$this
->
createSortVar
(
$attribute
);
$route
=
$this
->
route
===
null
?
Yii
::
$app
->
controller
->
getRoute
()
:
$this
->
route
;
$urlManager
=
$this
->
urlManager
===
null
?
Yii
::
$app
->
getUrlManager
()
:
$this
->
urlManager
;
return
$urlManager
->
createUrl
(
$route
,
$params
);
if
(
$absolute
)
{
return
$urlManager
->
createAbsoluteUrl
(
$route
,
$params
);
}
else
{
return
$urlManager
->
createUrl
(
$route
,
$params
);
}
}
/**
...
...
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