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')); }
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')); }
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')); }
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')); }
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; }
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); $tot = number_format($tot); $nav->appendChild('<div class="maniphest-total-result-count">' . "Displaying tasks {$cur} - {$max} of {$tot}." . '</div>'); foreach ($tasks as $group => $list) { $task_list = new ManiphestTaskListView(); $task_list->setUser($user); $task_list->setTasks($list); $task_list->setHandles($handles); $count = number_format(count($list)); $nav->appendChild('<h1 class="maniphest-task-group-header">' . phutil_escape_html($group) . ' (' . $count . ')' . '</h1>'); $nav->appendChild($task_list); } $nav->appendChild($pager); } return $this->buildStandardPageResponse($nav, array('title' => 'Task List')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($request->isFormPost()) { // Redirect to GET so URIs can be copy/pasted. $task_ids = $request->getStr('set_tasks'); $task_ids = nonempty($task_ids, null); $search_text = $request->getStr('set_search'); $search_text = nonempty($search_text, null); $min_priority = $request->getInt('set_lpriority'); $min_priority = nonempty($min_priority, null); $max_priority = $request->getInt('set_hpriority'); $max_priority = nonempty($max_priority, null); $uri = $request->getRequestURI()->alter('users', $this->getArrToStrList('set_users'))->alter('projects', $this->getArrToStrList('set_projects'))->alter('xprojects', $this->getArrToStrList('set_xprojects'))->alter('owners', $this->getArrToStrList('set_owners'))->alter('authors', $this->getArrToStrList('set_authors'))->alter('lpriority', $min_priority)->alter('hpriority', $max_priority)->alter('tasks', $task_ids)->alter('search', $search_text); return id(new AphrontRedirectResponse())->setURI($uri); } $nav = $this->buildBaseSideNav(); $has_filter = array('action' => true, 'created' => true, 'subscribed' => true, 'triage' => true, 'projecttriage' => true, 'projectall' => true); $query = null; $key = $request->getStr('key'); if (!$key && !$this->view) { if ($this->getDefaultQuery()) { $key = $this->getDefaultQuery()->getQueryKey(); } } if ($key) { $query = id(new PhabricatorSearchQuery())->loadOneWhere('queryKey = %s', $key); } // If the user is running a saved query, load query parameters from that // query. Otherwise, build a new query object from the HTTP request. if ($query) { $nav->selectFilter('Q:' . $query->getQueryKey(), 'custom'); $this->view = 'custom'; } else { $this->view = $nav->selectFilter($this->view, 'action'); $query = $this->buildQueryFromRequest(); } // Execute the query. list($tasks, $handles, $total_count) = self::loadTasks($query); // Extract information we need to render the filters from the query. $search_text = $query->getParameter('fullTextSearch'); $user_phids = $query->getParameter('userPHIDs', array()); $task_ids = $query->getParameter('taskIDs', array()); $owner_phids = $query->getParameter('ownerPHIDs', array()); $author_phids = $query->getParameter('authorPHIDs', array()); $project_phids = $query->getParameter('projectPHIDs', array()); $exclude_project_phids = $query->getParameter('excludeProjectPHIDs', array()); $low_priority = $query->getParameter('lowPriority'); $high_priority = $query->getParameter('highPriority'); $page_size = $query->getParameter('limit'); $page = $query->getParameter('offset'); $q_status = $query->getParameter('status'); $q_group = $query->getParameter('group'); $q_order = $query->getParameter('order'); $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->alter('key', null)->alter($this->getStatusRequestKey(), $this->getStatusRequestValue($q_status))->alter($this->getOrderRequestKey(), $this->getOrderRequestValue($q_order))->alter($this->getGroupRequestKey(), $this->getGroupRequestValue($q_group))); 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_search')->setLabel('Search')->setValue($search_text)); $form->appendChild(id(new AphrontFormTextControl())->setName('set_tasks')->setLabel('Task IDs')->setValue(join(',', $task_ids))); $tokens = array(); foreach ($owner_phids as $phid) { $tokens[$phid] = $handles[$phid]->getFullName(); } $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/searchowner/')->setName('set_owners')->setLabel('Owners')->setValue($tokens)); $tokens = array(); foreach ($author_phids as $phid) { $tokens[$phid] = $handles[$phid]->getFullName(); } $form->appendChild(id(new AphrontFormTokenizerControl())->setDatasource('/typeahead/common/users/')->setName('set_authors')->setLabel('Authors')->setValue($tokens)); } $tokens = array(); 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')); }
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')); }