コード例 #1
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $query = new PhabricatorPasteQuery();
     $query->setViewer($user);
     $nav = $this->buildSideNavView();
     $filter = $nav->selectFilter($this->filter, 'my');
     switch ($filter) {
         case 'my':
             $query->withAuthorPHIDs(array($user->getPHID()));
             $title = pht('My Pastes');
             $nodata = pht("You haven't created any Pastes yet.");
             break;
         case 'all':
             $title = pht('All Pastes');
             $nodata = pht("There are no Pastes yet.");
             break;
     }
     $pager = new AphrontCursorPagerView();
     $pager->readFromRequest($request);
     $pastes = $query->executeWithCursorPager($pager);
     $list = $this->buildPasteList($pastes);
     $list->setHeader($title);
     $list->setPager($pager);
     $list->setNoDataString($nodata);
     $nav->appendChild($list);
     return $this->buildApplicationPage($nav, array('title' => $title, 'device' => true));
 }
コード例 #2
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontCursorPagerView();
     $pager->readFromRequest($request);
     $query = new PhabricatorPasteQuery();
     $query->setViewer($user);
     switch ($this->getFilter()) {
         case 'create':
         default:
             // if we successfully create a paste, we redirect to view it
             $created_paste_redirect = $this->processCreateRequest();
             if ($created_paste_redirect) {
                 return $created_paste_redirect;
             }
             $query->setLimit(10);
             $paste_list = $query->execute();
             $pager = null;
             break;
         case 'my':
             $query->withAuthorPHIDs(array($user->getPHID()));
             $paste_list = $query->executeWithCursorPager($pager);
             break;
         case 'all':
             $paste_list = $query->executeWithCursorPager($pager);
             break;
     }
     $side_nav = $this->buildSideNavView();
     $side_nav->selectFilter($this->getFilter());
     if ($this->getErrorView()) {
         $side_nav->appendChild($this->getErrorView());
     }
     switch ($this->getFilter()) {
         case 'create':
         default:
             $side_nav->appendChild($this->renderCreatePaste());
             $see_all = phutil_render_tag('a', array('href' => '/paste/filter/all'), 'See all Pastes');
             $header = "Recent Pastes";
             break;
         case 'my':
             $header = 'Your Pastes';
             break;
         case 'all':
             $header = 'All Pastes';
             break;
     }
     $this->loadHandles(mpull($paste_list, 'getAuthorPHID'));
     $list = $this->buildPasteList($paste_list);
     $list->setHeader($header);
     $list->setPager($pager);
     $side_nav->appendChild($list);
     return $this->buildApplicationPage($side_nav, array('title' => 'Paste', 'device' => true));
 }
コード例 #3
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontIDPagerView();
     $pager->readFromRequest($request);
     $query = new PhabricatorPasteQuery();
     $query->setViewer($user);
     switch ($this->getFilter()) {
         case 'create':
         default:
             // if we successfully create a paste, we redirect to view it
             $created_paste_redirect = $this->processCreateRequest();
             if ($created_paste_redirect) {
                 return $created_paste_redirect;
             }
             $query->setLimit(10);
             $paste_list = $query->execute();
             $pager = null;
             break;
         case 'my':
             $query->withAuthorPHIDs(array($user->getPHID()));
             $paste_list = $query->executeWithPager($pager);
             break;
         case 'all':
             $paste_list = $query->executeWithPager($pager);
             break;
     }
     $filters = array('create' => array('name' => 'Create Paste'), 'my' => array('name' => 'My Pastes'), 'all' => array('name' => 'All Pastes'));
     $side_nav = new AphrontSideNavView();
     foreach ($filters as $filter_key => $filter) {
         $selected = $filter_key == $this->getFilter();
         $side_nav->addNavItem(phutil_render_tag('a', array('href' => '/paste/filter/' . $filter_key . '/', 'class' => $selected ? 'aphront-side-nav-selected' : null), $filter['name']));
     }
     if ($this->getErrorView()) {
         $side_nav->appendChild($this->getErrorView());
     }
     switch ($this->getFilter()) {
         case 'create':
         default:
             $side_nav->appendChild($this->renderCreatePaste());
             $see_all = phutil_render_tag('a', array('href' => '/paste/filter/all'), 'See all Pastes');
             $header = "Recent Pastes · {$see_all}";
             break;
         case 'my':
             $header = 'Your Pastes';
             break;
         case 'all':
             $header = 'All Pastes';
             break;
     }
     $side_nav->appendChild($this->renderPasteList($paste_list, $header, $pager));
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Paste'));
 }