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
44aab995
Commit
44aab995
authored
Mar 26, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2891 from johonunu/summaryOptions-emptyTextOptions-BaseListView
Added summaryOptions and emptyTextOptions to BaseListView
parents
435747cf
e480a273
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
+20
-7
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
BaseListView.php
framework/widgets/BaseListView.php
+19
-7
No files found.
framework/CHANGELOG.md
View file @
44aab995
...
...
@@ -178,6 +178,7 @@ Yii Framework 2 Change Log
-
Enh: LinkPager can now register relational link tags in the html header for prev, next, first and last page (cebe)
-
Enh: Added
`yii\web\UrlRuleInterface`
and
`yii\web\CompositeUrlRule`
(qiangxue)
-
Enh: Added
`yii\web\Request::getAuthUser()`
and
`getAuthPassword()`
(qiangxue)
-
Enh: Added summaryOptions and emptyTextOptions to BaseListView (johonunu)
-
Chg #47: Changed Markdown library to cebe/markdown and adjusted Markdown helper API (cebe)
-
Chg #735: Added back
`ActiveField::hiddenInput()`
(qiangxue)
-
Chg #1186: Changed
`Sort`
to use comma to separate multiple sort fields and use negative sign to indicate descending sort (qiangxue)
...
...
framework/widgets/BaseListView.php
View file @
44aab995
...
...
@@ -54,6 +54,12 @@ abstract class BaseListView extends Widget
*/
public
$summary
;
/**
* @var array the HTML attributes for the summary of the list view.
* The "tag" element specifies the tag name of the summary element and defaults to "div".
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public
$summaryOptions
=
[
'class'
=>
'summary'
];
/**
* @var boolean whether to show the list view if [[dataProvider]] returns no data.
*/
public
$showOnEmpty
=
false
;
...
...
@@ -62,6 +68,12 @@ abstract class BaseListView extends Widget
*/
public
$emptyText
;
/**
* @var array the HTML attributes for the emptyText of the list view.
* The "tag" element specifies the tag name of the emptyText element and defaults to "div".
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public
$emptyTextOptions
=
[
'class'
=>
'empty'
];
/**
* @var string the layout that determines how different sections of the list view should be organized.
* The following tokens will be replaced with the corresponding section contents:
*
...
...
@@ -139,7 +151,8 @@ abstract class BaseListView extends Widget
*/
public
function
renderEmpty
()
{
return
'<div class="empty">'
.
(
$this
->
emptyText
===
null
?
Yii
::
t
(
'yii'
,
'No results found.'
)
:
$this
->
emptyText
)
.
'</div>'
;
$tag
=
ArrayHelper
::
remove
(
$this
->
emptyTextOptions
,
'tag'
,
'div'
);
return
Html
::
tag
(
$tag
,
(
$this
->
emptyText
===
null
?
Yii
::
t
(
'yii'
,
'No results found.'
)
:
$this
->
emptyText
),
$this
->
emptyTextOptions
);
}
/**
...
...
@@ -151,6 +164,7 @@ abstract class BaseListView extends Widget
if
(
$count
<=
0
)
{
return
''
;
}
$tag
=
ArrayHelper
::
remove
(
$this
->
summaryOptions
,
'tag'
,
'div'
);
if
((
$pagination
=
$this
->
dataProvider
->
getPagination
())
!==
false
)
{
$totalCount
=
$this
->
dataProvider
->
getTotalCount
();
$begin
=
$pagination
->
getPage
()
*
$pagination
->
pageSize
+
1
;
...
...
@@ -161,29 +175,27 @@ abstract class BaseListView extends Widget
$page
=
$pagination
->
getPage
()
+
1
;
$pageCount
=
$pagination
->
pageCount
;
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
return
'<div class="summary">'
.
Yii
::
t
(
'yii'
,
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'
,
[
return
Html
::
tag
(
$tag
,
Yii
::
t
(
'yii'
,
'Showing <b>{begin, number}-{end, number}</b> of <b>{totalCount, number}</b> {totalCount, plural, one{item} other{items}}.'
,
[
'begin'
=>
$begin
,
'end'
=>
$end
,
'count'
=>
$count
,
'totalCount'
=>
$totalCount
,
'page'
=>
$page
,
'pageCount'
=>
$pageCount
,
])
.
'</div>'
;
]),
$this
->
summaryOptions
);
}
}
else
{
$begin
=
$page
=
$pageCount
=
1
;
$end
=
$totalCount
=
$count
;
if
((
$summaryContent
=
$this
->
summary
)
===
null
)
{
return
'<div class="summary">'
.
Yii
::
t
(
'yii'
,
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.'
,
[
return
Html
::
tag
(
$tag
,
Yii
::
t
(
'yii'
,
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.'
,
[
'begin'
=>
$begin
,
'end'
=>
$end
,
'count'
=>
$count
,
'totalCount'
=>
$totalCount
,
'page'
=>
$page
,
'pageCount'
=>
$pageCount
,
])
.
'</div>'
;
])
,
$this
->
summaryOptions
)
;
}
}
...
...
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