1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-23 02:38:48 +02:00
phorge-phorge/src/applications/uiexample/examples/PhabricatorUIPagerExample.php
vrana ef85f49adc Delete license headers from files
Summary:
This commit doesn't change license of any file. It just makes the license implicit (inherited from LICENSE file in the root directory).

We are removing the headers for these reasons:

- It wastes space in editors, less code is visible in editor upon opening a file.
- It brings noise to diff of the first change of any file every year.
- It confuses Git file copy detection when creating small files.
- We don't have an explicit license header in other files (JS, CSS, images, documentation).
- Using license header in every file is not obligatory: http://www.apache.org/dev/apply-license.html#new.

This change is approved by Alma Chao (Lead Open Source and IP Counsel at Facebook).

Test Plan: Verified that the license survived only in LICENSE file and that it didn't modify externals.

Reviewers: epriestley, davidrecordon

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2035

Differential Revision: https://secure.phabricator.com/D3886
2012-11-05 11:16:51 -08:00

78 lines
2.3 KiB
PHP

<?php
final 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;
}
}