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
111e7b3f
Commit
111e7b3f
authored
Jul 10, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
method renaming.
parent
389c0e2b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
31 additions
and
31 deletions
+31
-31
ActiveDataProvider.php
framework/yii/data/ActiveDataProvider.php
+9
-9
ArrayDataProvider.php
framework/yii/data/ArrayDataProvider.php
+10
-10
DataProvider.php
framework/yii/data/DataProvider.php
+1
-1
IDataProvider.php
framework/yii/data/IDataProvider.php
+4
-4
Pagination.php
framework/yii/data/Pagination.php
+7
-7
No files found.
framework/yii/data/ActiveDataProvider.php
View file @
111e7b3f
...
...
@@ -53,7 +53,7 @@ use yii\db\Connection;
class
ActiveDataProvider
extends
DataProvider
{
/**
* @var Query the query that is used to fetch data items and [[total
Item
Count]]
* @var Query the query that is used to fetch data items and [[totalCount]]
* if it is not explicitly set.
*/
public
$query
;
...
...
@@ -98,29 +98,29 @@ class ActiveDataProvider extends DataProvider
/**
* Returns the number of data items in the current page.
* This is equivalent to `count($provider->items)`.
* When [[pagination]] is false, this is the same as [[total
Item
Count]].
* When [[pagination]] is false, this is the same as [[totalCount]].
* @param boolean $refresh whether to recalculate the item count. If true,
* this will cause re-fetching of [[items]].
* @return integer the number of data items in the current page.
*/
public
function
get
Item
Count
(
$refresh
=
false
)
public
function
getCount
(
$refresh
=
false
)
{
return
count
(
$this
->
getItems
(
$refresh
));
}
/**
* Returns the total number of data items.
* When [[pagination]] is false, this returns the same value as [[
itemC
ount]].
* If [[total
Item
Count]] is not explicitly set, it will be calculated
* When [[pagination]] is false, this returns the same value as [[
c
ount]].
* If [[totalCount]] is not explicitly set, it will be calculated
* using [[query]] with a COUNT query.
* @param boolean $refresh whether to recalculate the item count
* @return integer total number of possible data items.
* @throws InvalidConfigException
*/
public
function
getTotal
Item
Count
(
$refresh
=
false
)
public
function
getTotalCount
(
$refresh
=
false
)
{
if
(
$this
->
getPagination
()
===
false
)
{
return
$this
->
get
Item
Count
(
$refresh
);
return
$this
->
getCount
(
$refresh
);
}
elseif
(
$this
->
_count
===
null
||
$refresh
)
{
if
(
!
$this
->
query
instanceof
Query
)
{
throw
new
InvalidConfigException
(
'The "query" property must be an instance of Query or its subclass.'
);
...
...
@@ -135,7 +135,7 @@ class ActiveDataProvider extends DataProvider
* Sets the total number of data items.
* @param integer $value the total number of data items.
*/
public
function
setTotal
Item
Count
(
$value
)
public
function
setTotalCount
(
$value
)
{
$this
->
_count
=
$value
;
}
...
...
@@ -153,7 +153,7 @@ class ActiveDataProvider extends DataProvider
throw
new
InvalidConfigException
(
'The "query" property must be an instance of Query or its subclass.'
);
}
if
((
$pagination
=
$this
->
getPagination
())
!==
false
)
{
$pagination
->
itemCount
=
$this
->
getTotalItem
Count
();
$pagination
->
totalCount
=
$this
->
getTotal
Count
();
$this
->
query
->
limit
(
$pagination
->
getLimit
())
->
offset
(
$pagination
->
getOffset
());
}
if
((
$sort
=
$this
->
getSort
())
!==
false
)
{
...
...
framework/yii/data/ArrayDataProvider.php
View file @
111e7b3f
...
...
@@ -67,34 +67,34 @@ class ArrayDataProvider extends DataProvider
*/
public
$allItems
;
private
$_
c
ount
;
private
$_
totalC
ount
;
/**
* Returns the total number of data items.
* @return integer total number of possible data items.
* @throws InvalidConfigException
*/
public
function
getTotal
Item
Count
()
public
function
getTotalCount
()
{
if
(
$this
->
getPagination
()
===
false
)
{
return
$this
->
get
Item
Count
();
}
elseif
(
$this
->
_
c
ount
===
null
)
{
return
$this
->
getCount
();
}
elseif
(
$this
->
_
totalC
ount
===
null
)
{
if
(
$this
->
allItems
!==
null
)
{
$this
->
_
c
ount
=
count
(
$this
->
allItems
);
$this
->
_
totalC
ount
=
count
(
$this
->
allItems
);
}
else
{
throw
new
InvalidConfigException
(
'Unable to determine total item count: either "allItems" or "total
Item
Count" must be set.'
);
throw
new
InvalidConfigException
(
'Unable to determine total item count: either "allItems" or "totalCount" must be set.'
);
}
}
return
$this
->
_
c
ount
;
return
$this
->
_
totalC
ount
;
}
/**
* Sets the total number of data items.
* @param integer $value the total number of data items.
*/
public
function
setTotal
Item
Count
(
$value
)
public
function
setTotalCount
(
$value
)
{
$this
->
_
c
ount
=
$value
;
$this
->
_
totalC
ount
=
$value
;
}
private
$_items
;
...
...
@@ -116,7 +116,7 @@ class ArrayDataProvider extends DataProvider
}
if
((
$pagination
=
$this
->
getPagination
())
!==
false
)
{
$pagination
->
itemCount
=
$this
->
getTotalItem
Count
();
$pagination
->
totalCount
=
$this
->
getTotal
Count
();
$items
=
array_slice
(
$items
,
$pagination
->
getOffset
(),
$pagination
->
getLimit
());
}
...
...
framework/yii/data/DataProvider.php
View file @
111e7b3f
...
...
@@ -96,7 +96,7 @@ abstract class DataProvider extends Component implements IDataProvider
* Returns the number of data items in the current page.
* @return integer the number of data items in the current page.
*/
public
function
get
Item
Count
()
public
function
getCount
()
{
return
count
(
$this
->
getItems
());
}
...
...
framework/yii/data/IDataProvider.php
View file @
111e7b3f
...
...
@@ -22,17 +22,17 @@ interface IDataProvider
/**
* Returns the number of data items in the current page.
* This is equivalent to `count($provider->getItems())`.
* When [[pagination]] is false, this is the same as [[total
Item
Count]].
* When [[pagination]] is false, this is the same as [[totalCount]].
* @return integer the number of data items in the current page.
*/
public
function
get
Item
Count
();
public
function
getCount
();
/**
* Returns the total number of data items.
* When [[pagination]] is false, this is the same as [[
itemC
ount]].
* When [[pagination]] is false, this is the same as [[
c
ount]].
* @return integer total number of possible data items.
*/
public
function
getTotal
Item
Count
();
public
function
getTotalCount
();
/**
* Returns the data items in the current page.
...
...
framework/yii/data/Pagination.php
View file @
111e7b3f
...
...
@@ -14,7 +14,7 @@ use yii\base\Object;
* Pagination represents information relevant to pagination of data items.
*
* When data needs to be rendered in multiple pages, Pagination can be used to
* represent information such as [[
item
Count|total item count]], [[pageSize|page size]],
* represent information such as [[
total
Count|total item count]], [[pageSize|page size]],
* [[page|current page]], etc. These information can be passed to [[yii\widgets\Pager|pagers]]
* to render pagination buttons or links.
*
...
...
@@ -28,7 +28,7 @@ use yii\base\Object;
* {
* $query = Article::find()->where(array('status' => 1));
* $countQuery = clone $query;
* $pages = new Pagination(array('
item
Count' => $countQuery->count()));
* $pages = new Pagination(array('
total
Count' => $countQuery->count()));
* $models = $query->offset($pages->offset)
* ->limit($pages->limit)
* ->all();
...
...
@@ -91,7 +91,7 @@ class Pagination extends Object
/**
* @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 [[
item
Count]] which may not be available
* Because [[pageCount]] relies on the correct value of [[
total
Count]] which may not be available
* in some cases (e.g. MongoDB), you may want to set this property to be false to disable the page
* number validation. By doing so, [[page]] will return the value indexed by [[pageVar]] in [[params]].
*/
...
...
@@ -104,7 +104,7 @@ class Pagination extends Object
/**
* @var integer total number of items.
*/
public
$
item
Count
=
0
;
public
$
total
Count
=
0
;
/**
...
...
@@ -113,10 +113,10 @@ class Pagination extends Object
public
function
getPageCount
()
{
if
(
$this
->
pageSize
<
1
)
{
return
$this
->
item
Count
>
0
?
1
:
0
;
return
$this
->
total
Count
>
0
?
1
:
0
;
}
else
{
$
itemCount
=
$this
->
itemCount
<
0
?
0
:
(
int
)
$this
->
item
Count
;
return
(
int
)((
$
item
Count
+
$this
->
pageSize
-
1
)
/
$this
->
pageSize
);
$
totalCount
=
$this
->
totalCount
<
0
?
0
:
(
int
)
$this
->
total
Count
;
return
(
int
)((
$
total
Count
+
$this
->
pageSize
-
1
)
/
$this
->
pageSize
);
}
}
...
...
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