当前位置: 首页>>代码示例>>PHP>>正文


PHP AphrontPagerView::setCount方法代码示例

本文整理汇总了PHP中AphrontPagerView::setCount方法的典型用法代码示例。如果您正苦于以下问题:PHP AphrontPagerView::setCount方法的具体用法?PHP AphrontPagerView::setCount怎么用?PHP AphrontPagerView::setCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AphrontPagerView的用法示例。


在下文中一共展示了AphrontPagerView::setCount方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $macro_table = new PhabricatorFileImageMacro();
     $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     // Get an exact count since the size here is reasonably going to be a few
     // thousand at most in any reasonable case.
     $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName());
     $count = $count['N'];
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $rows = array();
     foreach ($macros as $macro) {
         $src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID());
         $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), phutil_render_tag('a', array('href' => $src, 'target' => '_blank'), phutil_render_tag('img', array('src' => $src))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Name', 'Image', ''));
     $table->setColumnClasses(array('pri', 'wide thumb', 'action'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader('Image Macros');
     $panel->setCreateButton('New Image Macro', '/file/macro/edit/');
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse($panel, array('title' => 'Image Macros', 'tab' => 'macros'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:28,代码来源:PhabricatorFileMacroListController.php

示例2: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:53,代码来源:PhabricatorPeopleListController.php

示例3: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $macro_table = new PhabricatorFileImageMacro();
     if ($request->getStr('name') !== null) {
         $macros = $macro_table->loadAllWhere('name LIKE %~', $request->getStr('name'));
     } else {
         $pager = new AphrontPagerView();
         $pager->setOffset($request->getInt('page'));
         $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
         // Get an exact count since the size here is reasonably going to be a few
         // thousand at most in any reasonable case.
         $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName());
         $count = $count['N'];
         $pager->setCount($count);
         $pager->setURI($request->getRequestURI(), 'page');
     }
     $file_phids = mpull($macros, 'getFilePHID');
     $files = array();
     if ($file_phids) {
         $files = id(new PhabricatorFile())->loadAllWhere("phid IN (%Ls)", $file_phids);
         $author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
         $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles();
     }
     $files_map = mpull($files, null, 'getPHID');
     $rows = array();
     foreach ($macros as $macro) {
         $file_phid = $macro->getFilePHID();
         $file = idx($files_map, $file_phid);
         $author_link = isset($author_phids[$file_phid]) ? $handles[$author_phids[$file_phid]]->renderLink() : null;
         $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), $author_link, phutil_render_tag('a', array('href' => $file ? $file->getBestURI() : null, 'target' => '_blank'), phutil_render_tag('img', array('src' => $file ? $file->getBestURI() : null))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Name', 'Author', 'Image', ''));
     $table->setColumnClasses(array('pri', '', 'wide thumb', 'action'));
     $filter_form = id(new AphrontFormView())->setMethod('GET')->setAction('/file/macro/')->setUser($request->getUser())->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel('Name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Image Macros'));
     $filter_view = new AphrontListFilterView();
     $filter_view->appendChild($filter_form);
     $filter_view->addButton(phutil_render_tag('a', array('href' => '/file/macro/edit/', 'class' => 'green button'), 'New Image Macro'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader('Image Macros');
     if ($request->getStr('name') === null) {
         $panel->appendChild($pager);
     }
     $side_nav = new PhabricatorFileSideNavView();
     $side_nav->setSelectedFilter('all_macros');
     $side_nav->appendChild($filter_view);
     $side_nav->appendChild($panel);
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Image Macros'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:51,代码来源:PhabricatorFileMacroListController.php

示例4: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorUser())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
     $rows = array();
     foreach ($users as $user) {
         $status = '';
         if ($user->getIsDisabled()) {
             $status = 'Disabled';
         } else {
             if ($user->getIsAdmin()) {
                 $status = 'Admin';
             } else {
                 $status = '-';
             }
         }
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Status', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
     }
     return $this->buildStandardPageResponse($panel, array('title' => 'People', 'tab' => 'directory'));
 }
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:40,代码来源:PhabricatorPeopleListController.php

示例5: renderExample

 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(pht('Item #%d', $ii + 1));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Item'));
     $panel = new PHUIObjectBoxView();
     $panel->setHeaderText(pht('Example'));
     $panel->appendChild($table);
     $panel->appendChild(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('Use %s to render a pager element.', phutil_tag('tt', array(), 'AphrontPagerView'))));
     $pager = new AphrontPagerView();
     $pager->setPageSize($page_size);
     $pager->setOffset($offset);
     $pager->setCount($item_count);
     $pager->setURI($request->getRequestURI(), 'offset');
     $panel->appendChild($pager);
     $panel->appendChild(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('You can show more or fewer pages of surrounding context.')));
     $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(hsprintf('<p class="phabricator-ui-example-note">%s</p>', pht('When it is prohibitively expensive or complex to attain a complete ' . 'count of the items, you can select one extra item and set ' . '%s if it exists, creating an inexact pager.', phutil_tag('tt', array(), 'hasMorePages(true)'))));
     $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;
 }
开发者ID:hrb518,项目名称:phabricator,代码行数:39,代码来源:PhabricatorPagerUIExample.php

示例6: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         // Redirect to GET so URIs can be copy/pasted.
         $user_phids = $request->getArr('set_users');
         $proj_phids = $request->getArr('set_projects');
         $task_ids = $request->getStr('set_tasks');
         $user_phids = implode(',', $user_phids);
         $proj_phids = implode(',', $proj_phids);
         $user_phids = nonempty($user_phids, null);
         $proj_phids = nonempty($proj_phids, null);
         $task_ids = nonempty($task_ids, null);
         $uri = $request->getRequestURI()->alter('users', $user_phids)->alter('projects', $proj_phids)->alter('tasks', $task_ids);
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/maniphest/view/'));
     $nav->addLabel('User Tasks');
     $nav->addFilter('action', 'Assigned');
     $nav->addFilter('created', 'Created');
     $nav->addFilter('subscribed', 'Subscribed');
     $nav->addFilter('triage', 'Need Triage');
     $nav->addSpacer();
     $nav->addLabel('All Tasks');
     $nav->addFilter('alltriage', 'Need Triage');
     $nav->addFilter('all', 'All Tasks');
     $nav->addSpacer();
     $nav->addFilter('custom', 'Custom');
     $this->view = $nav->selectFilter($this->view, 'action');
     $has_filter = array('action' => true, 'created' => true, 'subscribed' => true, 'triage' => true);
     list($status_map, $status_links) = $this->renderStatusLinks();
     list($grouping, $group_links) = $this->renderGroupLinks();
     list($order, $order_links) = $this->renderOrderLinks();
     $user_phids = $request->getStr('users');
     if (strlen($user_phids)) {
         $user_phids = explode(',', $user_phids);
     } else {
         $user_phids = array($user->getPHID());
     }
     $project_phids = $request->getStr('projects');
     if (strlen($project_phids)) {
         $project_phids = explode(',', $project_phids);
     } else {
         $project_phids = array();
     }
     $task_ids = $request->getStrList('tasks');
     $page = $request->getInt('page');
     $page_size = self::DEFAULT_PAGE_SIZE;
     list($tasks, $handles, $total_count) = $this->loadTasks($user_phids, $project_phids, $task_ids, array('status' => $status_map, 'group' => $grouping, 'order' => $order, 'offset' => $page, 'limit' => $page_size));
     $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI());
     if (isset($has_filter[$this->view])) {
         $tokens = array();
         foreach ($user_phids as $phid) {
             $tokens[$phid] = $handles[$phid]->getFullName();
         }
         $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/searchowner/')->setName('set_users')->setLabel('Users')->setValue($tokens));
     }
     if ($this->view == 'custom') {
         $form->appendChild(id(new AphrontFormTextControl())->setName('set_tasks')->setLabel('Task IDs')->setValue(join(',', $task_ids)));
     }
     $tokens = array();
     foreach ($project_phids as $phid) {
         $tokens[$phid] = $handles[$phid]->getFullName();
     }
     $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/projects/')->setName('set_projects')->setLabel('Projects')->setValue($tokens));
     $form->appendChild(id(new AphrontFormToggleButtonsControl())->setLabel('Status')->setValue($status_links))->appendChild(id(new AphrontFormToggleButtonsControl())->setLabel('Group')->setValue($group_links))->appendChild(id(new AphrontFormToggleButtonsControl())->setLabel('Order')->setValue($order_links));
     $form->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Tasks'));
     $create_uri = new PhutilURI('/maniphest/task/create/');
     if ($project_phids) {
         // If we have project filters selected, use them as defaults for task
         // creation.
         $create_uri->setQueryParam('projects', implode(';', $project_phids));
     }
     $filter = new AphrontListFilterView();
     $filter->addButton(phutil_render_tag('a', array('href' => (string) $create_uri, 'class' => 'green button'), 'Create New Task'));
     $filter->appendChild($form);
     $nav->appendChild($filter);
     $have_tasks = false;
     foreach ($tasks as $group => $list) {
         if (count($list)) {
             $have_tasks = true;
             break;
         }
     }
     require_celerity_resource('maniphest-task-summary-css');
     if (!$have_tasks) {
         $nav->appendChild('<h1 class="maniphest-task-group-header">' . 'No matching tasks.' . '</h1>');
     } else {
         $pager = new AphrontPagerView();
         $pager->setURI($request->getRequestURI(), 'page');
         $pager->setPageSize($page_size);
         $pager->setOffset($page);
         $pager->setCount($total_count);
         $cur = $pager->getOffset() + 1;
         $max = min($pager->getOffset() + $page_size, $total_count);
         $tot = $total_count;
         $cur = number_format($cur);
         $max = number_format($max);
//.........这里部分代码省略.........
开发者ID:netcomtec,项目名称:phabricator,代码行数:101,代码来源:ManiphestTaskListController.php

示例7: processRequest


//.........这里部分代码省略.........
     foreach ($project_phids as $phid) {
         $tokens[$phid] = $handles[$phid]->getFullName();
     }
     if ($this->view != 'projectall' && $this->view != 'projecttriage') {
         $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/searchproject/')->setName('set_projects')->setLabel('Projects')->setValue($tokens));
     }
     if ($this->view == 'custom') {
         $tokens = array();
         foreach ($exclude_project_phids as $phid) {
             $tokens[$phid] = $handles[$phid]->getFullName();
         }
         $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/projects/')->setName('set_xprojects')->setLabel('Exclude Projects')->setValue($tokens));
         $priority = ManiphestTaskPriority::getLowestPriority();
         if ($low_priority) {
             $priority = $low_priority;
         }
         $form->appendChild(id(new AphrontFormSelectControl())->setLabel('Min Priority')->setName('set_lpriority')->setValue($priority)->setOptions(array_reverse(ManiphestTaskPriority::getTaskPriorityMap(), true)));
         $priority = ManiphestTaskPriority::getHighestPriority();
         if ($high_priority) {
             $priority = $high_priority;
         }
         $form->appendChild(id(new AphrontFormSelectControl())->setLabel('Max Priority')->setName('set_hpriority')->setValue($priority)->setOptions(ManiphestTaskPriority::getTaskPriorityMap()));
     }
     $form->appendChild($this->renderStatusControl($q_status))->appendChild($this->renderGroupControl($q_group))->appendChild($this->renderOrderControl($q_order));
     $submit = id(new AphrontFormSubmitControl())->setValue('Filter Tasks');
     // Only show "Save..." for novel queries which have some kind of query
     // parameters set.
     if ($this->view === 'custom' && empty($key) && $request->getRequestURI()->getQueryParams()) {
         $submit->addCancelButton('/maniphest/custom/edit/?key=' . $query->getQueryKey(), 'Save Custom Query...');
     }
     $form->appendChild($submit);
     $create_uri = new PhutilURI('/maniphest/task/create/');
     if ($project_phids) {
         // If we have project filters selected, use them as defaults for task
         // creation.
         $create_uri->setQueryParam('projects', implode(';', $project_phids));
     }
     $filter = new AphrontListFilterView();
     $filter->addButton(phutil_render_tag('a', array('href' => (string) $create_uri, 'class' => 'green button'), 'Create New Task'));
     if (empty($key)) {
         $filter->appendChild($form);
     }
     $nav->appendChild($filter);
     $have_tasks = false;
     foreach ($tasks as $group => $list) {
         if (count($list)) {
             $have_tasks = true;
             break;
         }
     }
     require_celerity_resource('maniphest-task-summary-css');
     $list_container = new AphrontNullView();
     $list_container->appendChild('<div class="maniphest-list-container">');
     if (!$have_tasks) {
         $list_container->appendChild('<h1 class="maniphest-task-group-header">' . 'No matching tasks.' . '</h1>');
     } else {
         $pager = new AphrontPagerView();
         $pager->setURI($request->getRequestURI(), 'offset');
         $pager->setPageSize($page_size);
         $pager->setOffset($page);
         $pager->setCount($total_count);
         $cur = $pager->getOffset() + 1;
         $max = min($pager->getOffset() + $page_size, $total_count);
         $tot = $total_count;
         $cur = number_format($cur);
         $max = number_format($max);
         $tot = number_format($tot);
         $list_container->appendChild('<div class="maniphest-total-result-count">' . "Displaying tasks {$cur} - {$max} of {$tot}." . '</div>');
         $selector = new AphrontNullView();
         $group = $query->getParameter('group');
         $order = $query->getParameter('order');
         $is_draggable = $group == 'priority' || $group == 'none' && $order == 'priority';
         $lists = new AphrontNullView();
         $lists->appendChild('<div class="maniphest-group-container">');
         foreach ($tasks as $group => $list) {
             $task_list = new ManiphestTaskListView();
             $task_list->setShowBatchControls(true);
             if ($is_draggable) {
                 $task_list->setShowSubpriorityControls(true);
             }
             $task_list->setUser($user);
             $task_list->setTasks($list);
             $task_list->setHandles($handles);
             $count = number_format(count($list));
             $lists->appendChild(javelin_render_tag('h1', array('class' => 'maniphest-task-group-header', 'sigil' => 'task-group', 'meta' => array('priority' => head($list)->getPriority())), phutil_escape_html($group) . ' (' . $count . ')'));
             $lists->appendChild($task_list);
         }
         $lists->appendChild('</div>');
         $selector->appendChild($lists);
         $selector->appendChild($this->renderBatchEditor($query));
         $form_id = celerity_generate_unique_node_id();
         $selector = phabricator_render_form($user, array('method' => 'POST', 'action' => '/maniphest/batch/', 'id' => $form_id), $selector->render());
         $list_container->appendChild($selector);
         $list_container->appendChild($pager);
         Javelin::initBehavior('maniphest-subpriority-editor', array('root' => $form_id, 'uri' => '/maniphest/subpriority/'));
     }
     $list_container->appendChild('</div>');
     $nav->appendChild($list_container);
     return $this->buildStandardPageResponse($nav, array('title' => 'Task List'));
 }
开发者ID:neoxen,项目名称:phabricator,代码行数:101,代码来源:ManiphestTaskListController.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $macro_table = new PhabricatorFileImageMacro();
     $filter = $request->getStr('name');
     if (strlen($filter)) {
         $macros = $macro_table->loadAllWhere('name LIKE %~', $filter);
         $nodata = pht('There are no macros matching the filter "%s".', phutil_escape_html($filter));
     } else {
         $pager = new AphrontPagerView();
         $pager->setOffset($request->getInt('page'));
         $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize());
         // Get an exact count since the size here is reasonably going to be a few
         // thousand at most in any reasonable case.
         $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName());
         $count = $count['N'];
         $pager->setCount($count);
         $pager->setURI($request->getRequestURI(), 'page');
         $nodata = pht('There are no image macros yet.');
     }
     $file_phids = mpull($macros, 'getFilePHID');
     $files = array();
     if ($file_phids) {
         $files = id(new PhabricatorFile())->loadAllWhere("phid IN (%Ls)", $file_phids);
         $author_phids = mpull($files, 'getAuthorPHID', 'getPHID');
         $this->loadHandles($author_phids);
     }
     $files_map = mpull($files, null, 'getPHID');
     $filter_form = id(new AphrontFormView())->setMethod('GET')->setUser($request->getUser())->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel('Name')->setValue($filter))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Image Macros'));
     $filter_view = new AphrontListFilterView();
     $filter_view->appendChild($filter_form);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('/');
     $nav->appendChild($filter_view);
     if ($macros) {
         $pinboard = new PhabricatorPinboardView();
         foreach ($macros as $macro) {
             $file_phid = $macro->getFilePHID();
             $file = idx($files_map, $file_phid);
             $item = new PhabricatorPinboardItemView();
             if ($file) {
                 $item->setImageURI($file->getThumb220x165URI());
                 $item->setImageSize(220, 165);
                 if ($file->getAuthorPHID()) {
                     $author_handle = $this->getHandle($file->getAuthorPHID());
                     $item->appendChild('Created by ' . $author_handle->renderLink());
                 }
                 $datetime = phabricator_date($file->getDateCreated(), $viewer);
                 $item->appendChild(phutil_render_tag('div', array(), 'Created on ' . $datetime));
             }
             $item->setURI($this->getApplicationURI('/edit/' . $macro->getID() . '/'));
             $item->setHeader($macro->getName());
             $pinboard->addItem($item);
         }
         $nav->appendChild($pinboard);
     } else {
         $list = new PhabricatorObjectItemListView();
         $list->setNoDataString($nodata);
         $nav->appendChild($list);
     }
     if ($filter === null) {
         $nav->appendChild($pager);
     }
     return $this->buildApplicationPage($nav, array('device' => true, 'title' => 'Image Macros'));
 }
开发者ID:rudimk,项目名称:phabricator,代码行数:66,代码来源:PhabricatorMacroListController.php


注:本文中的AphrontPagerView::setCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。