public function processRequest()
 {
     $classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->setConcreteOnly(true)->selectAndLoadSymbols();
     $classes = ipull($classes, 'name', 'name');
     foreach ($classes as $class => $ignored) {
         $classes[$class] = newv($class, array());
     }
     $classes = msort($classes, 'getName');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
     foreach ($classes as $class => $obj) {
         $name = $obj->getName();
         $nav->addFilter($class, $name);
     }
     $selected = $nav->selectFilter($this->class, head_key($classes));
     require_celerity_resource('phabricator-ui-example-css');
     $example = $classes[$selected];
     $example->setRequest($this->getRequest());
     $result = $example->renderExample();
     if ($result instanceof AphrontResponse) {
         // This allows examples to generate dialogs, etc., for demonstration.
         return $result;
     }
     $nav->appendChild('<div class="phabricator-ui-example-header">' . '<h1 class="phabricator-ui-example-name">' . phutil_escape_html($example->getName()) . ' (' . get_class($example) . ')' . '</h1>' . '<p class="phabricator-ui-example-description">' . $example->getDescription() . '</p>' . '</div>');
     $nav->appendChild($result);
     return $this->buildApplicationPage($nav, array('title' => 'UI Example', 'device' => true));
 }
 public function buildStandardPageResponse($view, array $data)
 {
     $page = $this->buildStandardPageView();
     $page->setApplicationName('Herald');
     $page->setBaseURI('/herald/');
     $page->setTitle(idx($data, 'title'));
     $page->setGlyph("☿");
     $doclink = PhabricatorEnv::getDoclink('article/Herald_User_Guide.html');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/herald/'))->addLabel('Rules')->addFilter('new', 'Create Rule');
     $rules_map = HeraldContentTypeConfig::getContentTypeMap();
     $first_filter = null;
     foreach ($rules_map as $key => $value) {
         $nav->addFilter('view/' . $key, $value);
         if (!$first_filter) {
             $first_filter = 'view/' . $key;
         }
     }
     $nav->addSpacer()->addLabel('Utilities')->addFilter('test', 'Test Console')->addFilter('transcript', 'Transcripts');
     $user = $this->getRequest()->getUser();
     if ($user->getIsAdmin()) {
         $nav->addSpacer()->addLabel('Admin');
         $view_PHID = nonempty($this->getRequest()->getStr('phid'), null);
         foreach ($rules_map as $key => $value) {
             $nav->addFilter('all/view/' . $key, $value);
         }
     }
     $nav->selectFilter($this->getFilter(), $first_filter);
     $nav->appendChild($view);
     $page->appendChild($nav);
     $tabs = array('help' => array('href' => $doclink, 'name' => 'Help'));
     $page->setTabs($tabs, null);
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }
 public function buildStandardPageResponse($view, array $data)
 {
     $user = $this->getRequest()->getUser();
     $page = $this->buildStandardPageView();
     $page->setApplicationName('OAuth Server');
     $page->setBaseURI('/oauthserver/');
     $page->setTitle(idx($data, 'title'));
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/oauthserver/'));
     $nav->addLabel('Client Authorizations');
     $nav->addFilter('clientauthorization', 'My Authorizations');
     $nav->addSpacer();
     $nav->addLabel('Clients');
     $nav->addFilter('client/create', 'Create Client');
     foreach ($this->getExtraClientFilters() as $filter) {
         $nav->addFilter($filter['url'], $filter['label']);
     }
     $nav->addFilter('client', 'My Clients');
     $nav->selectFilter($this->getFilter(), 'clientauthorization');
     $nav->appendChild($view);
     $page->appendChild($nav);
     $doc_href = PhabricatorEnv::getDoclink('article/Using_the_Phabricator_OAuth_Server.html');
     $page->setTabs(array('help' => array('name' => 'Help', 'href' => $doc_href)), null);
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }
 public function buildStandardPageResponse($view, array $data)
 {
     $page = $this->buildStandardPageView();
     $page->setApplicationName('Conduit');
     $page->setBaseURI('/conduit/');
     $page->setTitle(idx($data, 'title'));
     $page->setGlyph("⇵");
     if ($this->showSideNav()) {
         $nav = new AphrontSideNavFilterView();
         $nav->setBaseURI(new PhutilURI('/conduit/'));
         $method_filters = $this->getMethodFilters();
         foreach ($method_filters as $group => $methods) {
             $nav->addLabel($group);
             foreach ($methods as $method) {
                 $method_name = $method['full_name'];
                 $display_name = $method_name;
                 switch ($method['status']) {
                     case ConduitAPIMethod::METHOD_STATUS_DEPRECATED:
                         $display_name = '(' . $display_name . ')';
                         break;
                 }
                 $nav->addFilter('method/' . $method_name, $display_name);
             }
             $nav->addSpacer();
         }
         $nav->selectFilter($this->getFilter());
         $nav->appendChild($view);
         $body = $nav;
     } else {
         $body = $view;
     }
     $page->appendChild($body);
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }
 public function handleRequest(AphrontRequest $request)
 {
     $id = $request->getURIData('class');
     $classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->loadObjects();
     $classes = msort($classes, 'getName');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
     foreach ($classes as $class => $obj) {
         $name = $obj->getName();
         $nav->addFilter($class, $name);
     }
     $selected = $nav->selectFilter($id, head_key($classes));
     $example = $classes[$selected];
     $example->setRequest($this->getRequest());
     $result = $example->renderExample();
     if ($result instanceof AphrontResponse) {
         // This allows examples to generate dialogs, etc., for demonstration.
         return $result;
     }
     require_celerity_resource('phabricator-ui-example-css');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($example->getName());
     $note = id(new PHUIInfoView())->setTitle(pht('%s (%s)', $example->getName(), get_class($example)))->appendChild($example->getDescription())->setSeverity(PHUIInfoView::SEVERITY_NODATA);
     $nav->appendChild(array($crumbs, $note, $result));
     return $this->buildApplicationPage($nav, array('title' => $example->getName()));
 }
 public function processRequest()
 {
     $classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->loadObjects();
     $classes = msort($classes, 'getName');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
     foreach ($classes as $class => $obj) {
         $name = $obj->getName();
         $nav->addFilter($class, $name);
     }
     $selected = $nav->selectFilter($this->class, head_key($classes));
     $example = $classes[$selected];
     $example->setRequest($this->getRequest());
     $result = $example->renderExample();
     if ($result instanceof AphrontResponse) {
         // This allows examples to generate dialogs, etc., for demonstration.
         return $result;
     }
     require_celerity_resource('phabricator-ui-example-css');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($example->getName());
     $header = id(new PHUIHeaderView())->setHeader(pht('%s (%s)', $example->getName(), get_class($example)))->setSubheader($example->getDescription())->setNoBackground(true);
     $nav->appendChild(array($crumbs, $header, phutil_tag('br'), $result));
     return $this->buildApplicationPage($nav, array('title' => $example->getName()));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         $phid_arr = $request->getArr('view_user');
         $view_target = head($phid_arr);
         return id(new AphrontRedirectResponse())->setURI($request->getRequestURI()->alter('phid', $view_target));
     }
     $params = array_filter(array('phid' => $request->getStr('phid')));
     // Fill in the defaults we'll actually use for calculations if any
     // parameters are missing.
     $params += array('phid' => $user->getPHID());
     $side_nav = new AphrontSideNavFilterView();
     $side_nav->setBaseURI(id(new PhutilURI('/differential/stats/'))->alter('phid', $params['phid']));
     foreach (array(DifferentialAction::ACTION_CLOSE, DifferentialAction::ACTION_ACCEPT, DifferentialAction::ACTION_REJECT, DifferentialAction::ACTION_UPDATE, DifferentialAction::ACTION_COMMENT) as $action) {
         $verb = ucfirst(DifferentialAction::getActionPastTenseVerb($action));
         $side_nav->addFilter($action, $verb);
     }
     $this->filter = $side_nav->selectFilter($this->filter, DifferentialAction::ACTION_CLOSE);
     $panels = array();
     $handles = $this->loadViewerHandles(array($params['phid']));
     $filter_form = id(new AphrontFormView())->setAction('/differential/stats/' . $this->filter . '/')->setUser($user);
     $filter_form->appendChild($this->renderControl($params['phid'], $handles));
     $filter_form->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Revisions'));
     $side_nav->appendChild($filter_form);
     $comments = $this->loadComments($params['phid']);
     $revisions = $this->loadRevisions($params['phid']);
     $diffs = $this->loadDiffs($revisions);
     $panel = new AphrontPanelView();
     $panel->setHeader('Differential rate analysis');
     $panel->appendChild(id(new DifferentialRevisionStatsView())->setComments($comments)->setFilter($this->filter)->setRevisions($revisions)->setDiffs($diffs)->setUser($user));
     $panels[] = $panel;
     foreach ($panels as $panel) {
         $side_nav->appendChild($panel);
     }
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Differential statistics'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/notification/'));
     $nav->addFilter('all', 'All Notifications');
     $nav->addFilter('unread', 'Unread Notifications');
     $filter = $nav->selectFilter($this->filter, 'all');
     $pager = new AphrontPagerView();
     $pager->setURI($request->getRequestURI(), 'offset');
     $pager->setOffset($request->getInt('offset'));
     $query = new PhabricatorNotificationQuery();
     $query->setUserPHID($user->getPHID());
     switch ($filter) {
         case 'unread':
             $query->withUnread(true);
             $header = pht('Unread Notifications');
             $no_data = pht('You have no unread notifications.');
             break;
         default:
             $header = pht('Notifications');
             $no_data = pht('You have no notifications.');
             break;
     }
     $notifications = $query->executeWithOffsetPager($pager);
     if ($notifications) {
         $builder = new PhabricatorNotificationBuilder($notifications);
         $view = $builder->buildView();
     } else {
         $view = '<div class="phabricator-notification no-notifications">' . $no_data . '</div>';
     }
     $view = array('<div class="phabricator-notification-list">', $view, '</div>');
     $panel = new AphrontPanelView();
     $panel->setHeader($header);
     $panel->setWidth(AphrontPanelView::WIDTH_FORM);
     $panel->addButton(javelin_render_tag('a', array('href' => '/notification/clear/', 'class' => 'button', 'sigil' => 'workflow'), 'Mark All Read'));
     $panel->appendChild($view);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Notifications'));
 }
 public function buildStandardPageResponse($view, array $data)
 {
     $user = $this->getRequest()->getUser();
     $page = $this->buildStandardPageView();
     $page->setApplicationName(pht('OAuth Server'));
     $page->setBaseURI('/oauthserver/');
     $page->setTitle(idx($data, 'title'));
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/oauthserver/'));
     $nav->addLabel(pht('Clients'));
     $nav->addFilter('client/create', pht('Create Client'));
     foreach ($this->getExtraClientFilters() as $filter) {
         $nav->addFilter($filter['url'], $filter['label']);
     }
     $nav->addFilter('client', pht('My Clients'));
     $nav->selectFilter($this->getFilter(), 'clientauthorization');
     $nav->appendChild($view);
     $page->appendChild($nav);
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/flag/view/'));
     $nav->addFilter('all', 'Flags');
     $nav->selectFilter('all', 'all');
     $query = new PhabricatorFlagQuery();
     $query->withOwnerPHIDs(array($user->getPHID()));
     $query->needHandles(true);
     $flags = $query->execute();
     $view = new PhabricatorFlagListView();
     $view->setFlags($flags);
     $view->setUser($user);
     $panel = new AphrontPanelView();
     $panel->setHeader('Flags');
     $panel->appendChild($view);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Flags'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($request->isFormPost()) {
         $uri = $request->getRequestURI();
         $project = head($request->getArr('set_project'));
         $project = nonempty($project, null);
         $uri = $uri->alter('project', $project);
         $window = $request->getStr('set_window');
         $uri = $uri->alter('window', $window);
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $base_nav = $this->buildBaseSideNav();
     $base_nav->selectFilter('report', 'report');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/maniphest/report/'));
     $nav->addLabel('Open Tasks');
     $nav->addFilter('user', 'By User');
     $nav->addFilter('project', 'By Project');
     $nav->addSpacer();
     $nav->addLabel('Burnup');
     $nav->addFilter('burn', 'Burnup Rate');
     $this->view = $nav->selectFilter($this->view, 'user');
     require_celerity_resource('maniphest-report-css');
     switch ($this->view) {
         case 'burn':
             $core = $this->renderBurn();
             break;
         case 'user':
         case 'project':
             $core = $this->renderOpenTasks();
             break;
         default:
             return new Aphront404Response();
     }
     $nav->appendChild($core);
     $base_nav->appendChild($nav);
     return $this->buildStandardPageResponse($base_nav, array('title' => 'Maniphest Reports'));
 }
 public function buildStandardPageResponse($view, array $data)
 {
     $doclink = PhabricatorEnv::getDoclink('article/Conduit_Technical_Documentation.html');
     $page = $this->buildStandardPageView();
     $page->setApplicationName('Conduit');
     $page->setBaseURI('/conduit/');
     $page->setTitle(idx($data, 'title'));
     $page->setGlyph("⇵");
     $page->setTabs(array('help' => array('href' => $doclink, 'name' => 'Help')), null);
     if ($this->showSideNav()) {
         $nav = new AphrontSideNavFilterView();
         $nav->setBaseURI(new PhutilURI('/conduit/'));
         $first_filter = null;
         $method_filters = $this->getMethodFilters();
         foreach ($method_filters as $group => $methods) {
             $nav->addLabel($group);
             foreach ($methods as $method) {
                 $method_name = $method['full_name'];
                 $nav->addFilter('method/' . $method_name, $method_name);
                 if (!$first_filter) {
                     $first_filter = 'method/' . $method_name;
                 }
             }
             $nav->addSpacer();
         }
         $nav->addLabel('Utilities');
         $nav->addFilter('log', 'Logs');
         $nav->addFilter('token', 'Token');
         $nav->selectFilter($this->getFilter(), $first_filter);
         $nav->appendChild($view);
         $body = $nav;
     } else {
         $body = $view;
     }
     $page->appendChild($body);
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $this->view = $request->getURIData('view');
     if ($request->isFormPost()) {
         $uri = $request->getRequestURI();
         $project = head($request->getArr('set_project'));
         $project = nonempty($project, null);
         $uri = $uri->alter('project', $project);
         $window = $request->getStr('set_window');
         $uri = $uri->alter('window', $window);
         return id(new AphrontRedirectResponse())->setURI($uri);
     }
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/maniphest/report/'));
     $nav->addLabel(pht('Open Tasks'));
     $nav->addFilter('user', pht('By User'));
     $nav->addFilter('project', pht('By Project'));
     $nav->addLabel(pht('Burnup'));
     $nav->addFilter('burn', pht('Burnup Rate'));
     $this->view = $nav->selectFilter($this->view, 'user');
     require_celerity_resource('maniphest-report-css');
     switch ($this->view) {
         case 'burn':
             $core = $this->renderBurn();
             break;
         case 'user':
         case 'project':
             $core = $this->renderOpenTasks();
             break;
         default:
             return new Aphront404Response();
     }
     $crumbs = $this->buildApplicationCrumbs()->addTextCrumb(pht('Reports'));
     $nav->appendChild($core);
     $title = pht('Maniphest Reports');
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->setNavigation($nav);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $admin = $request->getUser();
     if ($this->id) {
         $user = id(new PhabricatorUser())->load($this->id);
         if (!$user) {
             return new Aphront404Response();
         }
         $base_uri = '/people/edit/' . $user->getID() . '/';
     } else {
         $user = new PhabricatorUser();
         $base_uri = '/people/edit/';
     }
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI($base_uri));
     $nav->addLabel('User Information');
     $nav->addFilter('basic', 'Basic Information');
     $nav->addFilter('role', 'Edit Roles');
     $nav->addFilter('cert', 'Conduit Certificate');
     $nav->addFilter('profile', 'View Profile', '/p/' . $user->getUsername() . '/');
     $nav->addSpacer();
     $nav->addLabel('Special');
     $nav->addFilter('rename', 'Change Username');
     $nav->addFilter('delete', 'Delete User');
     if (!$user->getID()) {
         $this->view = 'basic';
     }
     $view = $nav->selectFilter($this->view, 'basic');
     $content = array();
     if ($request->getStr('saved')) {
         $notice = new AphrontErrorView();
         $notice->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
         $notice->setTitle('Changes Saved');
         $notice->appendChild('<p>Your changes were saved.</p>');
         $content[] = $notice;
     }
     switch ($view) {
         case 'basic':
             $response = $this->processBasicRequest($user);
             break;
         case 'role':
             $response = $this->processRoleRequest($user);
             break;
         case 'cert':
             $response = $this->processCertificateRequest($user);
             break;
         case 'rename':
             $response = $this->processRenameRequest($user);
             break;
         case 'delete':
             $response = $this->processDeleteRequest($user);
             break;
         default:
             return new Aphront404Response();
     }
     if ($response instanceof AphrontResponse) {
         return $response;
     }
     $content[] = $response;
     if ($user->getID()) {
         $nav->appendChild($content);
     } else {
         $nav = $this->buildSideNavView();
         $nav->selectFilter('edit');
         $nav->appendChild($content);
     }
     return $this->buildApplicationPage($nav, array('title' => 'Edit User'));
 }
 public function buildApplicationPage($view, array $options)
 {
     $page = $this->buildStandardPageView();
     $title = PhabricatorEnv::getEnvConfig('phabricator.serious-business') ? 'Phabricator' : pht('Bacon Ice Cream for Breakfast');
     $application = $this->getCurrentApplication();
     $page->setTitle(idx($options, 'title', $title));
     if ($application) {
         $page->setApplicationName($application->getName());
         if ($application->getTitleGlyph()) {
             $page->setGlyph($application->getTitleGlyph());
         }
     }
     if (idx($options, 'class')) {
         $page->addClass($options['class']);
     }
     if (!$view instanceof AphrontSideNavFilterView) {
         $nav = new AphrontSideNavFilterView();
         $nav->appendChild($view);
         $view = $nav;
     }
     $user = $this->getRequest()->getUser();
     $view->setUser($user);
     $page->appendChild($view);
     $object_phids = idx($options, 'pageObjects', array());
     if ($object_phids) {
         $page->appendPageObjects($object_phids);
         foreach ($object_phids as $object_phid) {
             PhabricatorFeedStoryNotification::updateObjectNotificationViews($user, $object_phid);
         }
     }
     if (idx($options, 'device', true)) {
         $page->setDeviceReady(true);
     }
     $page->setShowFooter(idx($options, 'showFooter', true));
     $page->setShowChrome(idx($options, 'chrome', true));
     $application_menu = $this->buildApplicationMenu();
     if ($application_menu) {
         $page->setApplicationMenu($application_menu);
     }
     return $this->buildPageResponse($page);
 }
 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 buildAppsResponse(AphrontSideNavFilterView $nav)
 {
     $user = $this->getRequest()->getUser();
     $apps = array(array('/repository/', 'Repositories', 'Configure tracked source code repositories.'), array('/herald/', 'Herald', 'Create notification rules. Watch for danger!'), array('/file/', 'Files', 'Upload and download files. Blob store for Pokemon pictures.'), array('/project/', 'Projects', 'Group stuff into big piles.'), array('/vote/', 'Slowvote', 'Create polls. Design by committee.'), array('/countdown/', 'Countdown', 'Count down to events. Utilize the full capabilities of your ALU.'), array('/people/', 'People', 'User directory. Sort of a social utility.'), array('/owners/', 'Owners', 'Keep track of who owns code. Adopt today!'), array('/conduit/', 'Conduit API Console', 'Web console for Conduit API.'), array('/daemon/', 'Daemon Console', 'Offline process management.'), array('/mail/', 'MetaMTA', 'Manage mail delivery. Yo dawg, we heard you like MTAs.', array('admin' => true)), array('/phid/', 'PHID Manager', 'Debugging tool for PHIDs.'), array('/xhpast/', 'XHPAST', 'Web interface to PHP AST tool. Lex XHP AST & CTS FYI, LOL.'), array('http://www.phabricator.com/docs/phabricator/', 'Phabricator Ducks', 'Oops, that should say "Docs".', array('new' => true)), array('http://www.phabricator.com/docs/arcanist/', 'Arcanist Docs', 'Words have never been so finely crafted.', array('new' => true)), array('http://www.phabricator.com/docs/libphutil/', 'libphutil Docs', 'Soothing prose; seductive poetry.', array('new' => true)), array('http://www.phabricator.com/docs/javelin/', 'Javelin Docs', 'O, what noble scribe hath penned these words?', array('new' => true)), array('/uiexample/', 'UI Examples', 'Phabricator UI elements. A gallery of modern art.', array('new' => true)));
     $out = array();
     foreach ($apps as $app) {
         if (empty($app[3])) {
             $app[3] = array();
         }
         $app[3] += array('admin' => false, 'new' => false);
         list($href, $name, $desc, $options) = $app;
         if ($options['admin'] && !$user->getIsAdmin()) {
             continue;
         }
         $link = phutil_render_tag('a', array('href' => $href, 'target' => $options['new'] ? '_blank' : null), phutil_escape_html($name));
         $out[] = '<div class="aphront-directory-item">' . '<h1>' . $link . '</h1>' . '<p>' . phutil_escape_html($desc) . '</p>' . '</div>';
     }
     require_celerity_resource('phabricator-directory-css');
     $out = '<div class="aphront-directory-list">' . implode("\n", $out) . '</div>';
     $nav->appendChild($out);
     return $this->buildStandardPageResponse($nav, array('title' => 'More Stuff'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $project = id(new PhabricatorProject())->load($this->id);
     if (!$project) {
         return new Aphront404Response();
     }
     $profile = $project->loadProfile();
     if (!$profile) {
         $profile = new PhabricatorProjectProfile();
     }
     $src_phid = $profile->getProfileImagePHID();
     if (!$src_phid) {
         $src_phid = $user->getProfileImagePHID();
     }
     $picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
     $nav_view = new AphrontSideNavFilterView();
     $uri = new PhutilURI('/project/view/' . $project->getID() . '/');
     $nav_view->setBaseURI($uri);
     $external_arrow = "↗";
     $tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID();
     $slug = PhrictionDocument::normalizeSlug($project->getName());
     $phriction_uri = '/w/projects/' . $slug . '/';
     $edit_uri = '/project/edit/' . $project->getID() . '/';
     $nav_view->addFilter('dashboard', 'Dashboard');
     $nav_view->addSpacer();
     $nav_view->addFilter('feed', 'Feed');
     $nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri);
     $nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri);
     $nav_view->addFilter('people', 'People');
     $nav_view->addFilter('about', 'About');
     $nav_view->addSpacer();
     $nav_view->addFilter(null, "Edit Project…", $edit_uri);
     $this->page = $nav_view->selectFilter($this->page, 'dashboard');
     require_celerity_resource('phabricator-profile-css');
     switch ($this->page) {
         case 'dashboard':
             $content = $this->renderTasksPage($project, $profile);
             $query = new PhabricatorFeedQuery();
             $query->setFilterPHIDs(array($project->getPHID()));
             $stories = $query->execute();
             $content .= $this->renderStories($stories);
             break;
         case 'about':
             $content = $this->renderAboutPage($project, $profile);
             break;
         case 'people':
             $content = $this->renderPeoplePage($project, $profile);
             break;
         case 'feed':
             $content = $this->renderFeedPage($project, $profile);
             break;
         default:
             throw new Exception("Unimplemented filter '{$this->page}'.");
     }
     $content = '<div style="padding: 1em;">' . $content . '</div>';
     $nav_view->appendChild($content);
     $header = new PhabricatorProfileHeaderView();
     $header->setName($project->getName());
     $header->setDescription(phutil_utf8_shorten($profile->getBlurb(), 1024));
     $header->setProfilePicture($picture);
     $header->appendChild($nav_view);
     return $this->buildStandardPageResponse($header, array('title' => $project->getName() . ' Project'));
 }
 /**
  * DEPRECATED. Use @{method:newPage}.
  */
 public function buildApplicationPage($view, array $options)
 {
     $page = $this->newPage();
     $title = PhabricatorEnv::getEnvConfig('phabricator.serious-business') ? 'Phabricator' : pht('Bacon Ice Cream for Breakfast');
     $page->setTitle(idx($options, 'title', $title));
     if (idx($options, 'class')) {
         $page->addClass($options['class']);
     }
     if (!$view instanceof AphrontSideNavFilterView) {
         $nav = new AphrontSideNavFilterView();
         $nav->appendChild($view);
         $view = $nav;
     }
     $page->appendChild($view);
     $object_phids = idx($options, 'pageObjects', array());
     if ($object_phids) {
         $page->setPageObjectPHIDs($object_phids);
     }
     if (!idx($options, 'device', true)) {
         $page->setDeviceReady(false);
     }
     $page->setShowFooter(idx($options, 'showFooter', true));
     $page->setShowChrome(idx($options, 'chrome', true));
     return $page->produceAphrontResponse();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $project = id(new PhabricatorProject())->load($this->id);
     if (!$project) {
         return new Aphront404Response();
     }
     $profile = $project->loadProfile();
     if (!$profile) {
         $profile = new PhabricatorProjectProfile();
     }
     $src_phid = $profile->getProfileImagePHID();
     if (!$src_phid) {
         $src_phid = $user->getProfileImagePHID();
     }
     $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $src_phid);
     if ($file) {
         $picture = $file->getBestURI();
     } else {
         $picture = null;
     }
     $members = mpull($project->loadAffiliations(), null, 'getUserPHID');
     $nav_view = new AphrontSideNavFilterView();
     $uri = new PhutilURI('/project/view/' . $project->getID() . '/');
     $nav_view->setBaseURI($uri);
     $external_arrow = "↗";
     $tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID();
     $slug = PhabricatorSlug::normalize($project->getName());
     $phriction_uri = '/w/projects/' . $slug;
     $edit_uri = '/project/edit/' . $project->getID() . '/';
     $nav_view->addFilter('dashboard', 'Dashboard');
     $nav_view->addSpacer();
     $nav_view->addFilter('feed', 'Feed');
     $nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri);
     $nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri);
     $nav_view->addFilter('people', 'People');
     $nav_view->addFilter('about', 'About');
     $nav_view->addSpacer();
     $nav_view->addFilter(null, "Edit Project…", $edit_uri);
     $this->page = $nav_view->selectFilter($this->page, 'dashboard');
     require_celerity_resource('phabricator-profile-css');
     switch ($this->page) {
         case 'dashboard':
             $content = $this->renderTasksPage($project, $profile);
             $query = new PhabricatorFeedQuery();
             $query->setFilterPHIDs(array($project->getPHID()));
             $stories = $query->execute();
             $content .= $this->renderStories($stories);
             break;
         case 'about':
             $content = $this->renderAboutPage($project, $profile);
             break;
         case 'people':
             $content = $this->renderPeoplePage($project, $profile);
             break;
         case 'feed':
             $content = $this->renderFeedPage($project, $profile);
             break;
         default:
             throw new Exception("Unimplemented filter '{$this->page}'.");
     }
     $content = '<div style="padding: 1em;">' . $content . '</div>';
     $nav_view->appendChild($content);
     $header = new PhabricatorProfileHeaderView();
     $header->setName($project->getName());
     $header->setDescription(phutil_utf8_shorten($profile->getBlurb(), 1024));
     $header->setProfilePicture($picture);
     $action = null;
     if (empty($members[$user->getPHID()])) {
         $action = phabricator_render_form($user, array('action' => '/project/update/' . $project->getID() . '/join/', 'method' => 'post'), phutil_render_tag('button', array('class' => 'green'), 'Join Project'));
     } else {
         $action = javelin_render_tag('a', array('href' => '/project/update/' . $project->getID() . '/leave/', 'sigil' => 'workflow', 'class' => 'grey button'), 'Leave Project...');
     }
     $header->addAction($action);
     $header->appendChild($nav_view);
     return $this->buildStandardPageResponse($header, array('title' => $project->getName() . ' Project'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI('/project/filter/'))->addLabel('User')->addFilter('active', 'Active')->addFilter('owned', 'Owned')->addSpacer()->addLabel('All')->addFilter('all', 'All Projects');
     $this->filter = $nav->selectFilter($this->filter, 'active');
     $pager = new AphrontPagerView();
     $pager->setPageSize(250);
     $pager->setURI($request->getRequestURI(), 'page');
     $pager->setOffset($request->getInt('page'));
     $query = new PhabricatorProjectQuery();
     $query->setOffset($pager->getOffset());
     $query->setLimit($pager->getPageSize() + 1);
     $view_phid = $request->getUser()->getPHID();
     switch ($this->filter) {
         case 'active':
             $table_header = 'Active Projects';
             $query->setMembers(array($view_phid));
             break;
         case 'owned':
             $table_header = 'Owned Projects';
             $query->setOwners(array($view_phid));
             break;
         case 'all':
             $table_header = 'All Projects';
             break;
     }
     $projects = $query->execute();
     $projects = $pager->sliceResults($projects);
     $project_phids = mpull($projects, 'getPHID');
     $profiles = array();
     if ($projects) {
         $profiles = id(new PhabricatorProjectProfile())->loadAllWhere('projectPHID in (%Ls)', $project_phids);
         $profiles = mpull($profiles, null, 'getProjectPHID');
     }
     $affil_groups = array();
     if ($projects) {
         $affil_groups = PhabricatorProjectAffiliation::loadAllForProjectPHIDs($project_phids);
     }
     $tasks = array();
     $groups = array();
     if ($project_phids) {
         $query = id(new ManiphestTaskQuery())->withProjects($project_phids)->withAnyProject(true)->withStatus(ManiphestTaskQuery::STATUS_OPEN)->setLimit(PHP_INT_MAX);
         $tasks = $query->execute();
         foreach ($tasks as $task) {
             foreach ($task->getProjectPHIDs() as $phid) {
                 $groups[$phid][] = $task;
             }
         }
     }
     $rows = array();
     foreach ($projects as $project) {
         $phid = $project->getPHID();
         $profile = $profiles[$phid];
         $affiliations = $affil_groups[$phid];
         $group = idx($groups, $phid, array());
         $task_count = count($group);
         $population = count($affiliations);
         $blurb = $profile->getBlurb();
         $blurb = phutil_utf8_shorten($blurb, 64);
         $rows[] = array(phutil_render_tag('a', array('href' => '/project/view/' . $project->getID() . '/'), phutil_escape_html($project->getName())), phutil_escape_html($blurb), phutil_escape_html($population), phutil_render_tag('a', array('href' => '/maniphest/view/all/?projects=' . $phid), phutil_escape_html($task_count)));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Project', 'Description', 'Population', 'Open Tasks'));
     $table->setColumnClasses(array('pri', 'wide', '', ''));
     $panel = new AphrontPanelView();
     $panel->setHeader($table_header);
     $panel->setCreateButton('Create New Project', '/project/create/');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Projects'));
 }
 public function buildApplicationPage($view, array $options)
 {
     $page = $this->buildStandardPageView();
     $application = $this->getCurrentApplication();
     if ($application) {
         $page->setApplicationName($application->getName());
         $page->setTitle(idx($options, 'title'));
         if ($application->getTitleGlyph()) {
             $page->setGlyph($application->getTitleGlyph());
         }
     }
     if (!$view instanceof AphrontSideNavFilterView) {
         $nav = new AphrontSideNavFilterView();
         $nav->appendChild($view);
         $view = $nav;
     }
     if ($application) {
         $view->setCurrentApplication($application);
     }
     $view->setUser($this->getRequest()->getUser());
     $view->setFlexNav(true);
     $view->setShowApplicationMenu(true);
     $page->appendChild($view);
     if (idx($options, 'device')) {
         $page->setDeviceReady(true);
         $view->appendChild($page->renderFooter());
     }
     $response = new AphrontWebpageResponse();
     return $response->setContent($page->render());
 }