Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F109949642
PhabricatorUIPagerExample.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Apr 24, 02:33
Size
2 KB
Mime Type
text/x-php
Expires
Sat, Apr 26, 02:33 (2 d)
Engine
blob
Format
Raw Data
Handle
25743843
Attached To
rPH Phabricator
PhabricatorUIPagerExample.php
View Options
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class
PhabricatorUIPagerExample
extends
PhabricatorUIExample
{
public
function
getName
()
{
return
'Pager'
;
}
public
function
getDescription
()
{
return
'Use <tt>AphrontPagerView</tt> to create a control which allows '
.
'users to paginate through large amounts of content.'
;
}
public
function
renderExample
()
{
$request
=
$this
->
getRequest
();
$offset
=
(
int
)
$request
->
getInt
(
'offset'
);
$page_size
=
20
;
$item_count
=
173
;
$rows
=
array
();
for
(
$ii
=
$offset
;
$ii
<
min
(
$item_count
,
$offset
+
$page_size
);
$ii
++)
{
$rows
[]
=
array
(
'Item #'
.(
$ii
+
1
),
);
}
$table
=
new
AphrontTableView
(
$rows
);
$table
->
setHeaders
(
array
(
'Item'
,
));
$panel
=
new
AphrontPanelView
();
$panel
->
appendChild
(
$table
);
$panel
->
appendChild
(
'<p class="phabricator-ui-example-note">'
.
'Use <tt>AphrontPagerView</tt> to render a pager element.'
.
'</p>'
);
$pager
=
new
AphrontPagerView
();
$pager
->
setPageSize
(
$page_size
);
$pager
->
setOffset
(
$offset
);
$pager
->
setCount
(
$item_count
);
$pager
->
setURI
(
$request
->
getRequestURI
(),
'offset'
);
$panel
->
appendChild
(
$pager
);
$panel
->
appendChild
(
'<p class="phabricator-ui-example-note">'
.
'You can show more or fewer pages of surrounding context.'
.
'</p>'
);
$many_pages_pager
=
new
AphrontPagerView
();
$many_pages_pager
->
setPageSize
(
$page_size
);
$many_pages_pager
->
setOffset
(
$offset
);
$many_pages_pager
->
setCount
(
$item_count
);
$many_pages_pager
->
setURI
(
$request
->
getRequestURI
(),
'offset'
);
$many_pages_pager
->
setSurroundingPages
(
7
);
$panel
->
appendChild
(
$many_pages_pager
);
$panel
->
appendChild
(
'<p class="phabricator-ui-example-note">'
.
'When it is prohibitively expensive or complex to attain a complete '
.
'count of the items, you can select one extra item and set '
.
'<tt>hasMorePages(true)</tt> if it exists, creating an inexact pager.'
.
'</p>'
);
$inexact_pager
=
new
AphrontPagerView
();
$inexact_pager
->
setPageSize
(
$page_size
);
$inexact_pager
->
setOffset
(
$offset
);
$inexact_pager
->
setHasMorePages
(
$offset
<
(
$item_count
-
$page_size
));
$inexact_pager
->
setURI
(
$request
->
getRequestURI
(),
'offset'
);
$panel
->
appendChild
(
$inexact_pager
);
return
$panel
;
}
}
Event Timeline
Log In to Comment