예제 #1
0
 public function render()
 {
     $icon = null;
     if ($this->icon) {
         $icon = phutil_render_tag('span', array('class' => 'phabricator-action-view-icon autosprite ' . 'action-' . $this->icon), '');
     }
     if ($this->href) {
         if ($this->renderAsForm) {
             if (!$this->user) {
                 throw new Exception('Call setUser() when rendering an action as a form.');
             }
             $item = javelin_render_tag('button', array('class' => 'phabricator-action-view-item'), phutil_escape_html($this->name));
             $item = phabricator_render_form($this->user, array('action' => $this->href, 'method' => 'POST', 'sigil' => $this->workflow ? 'workflow' : null), $item);
         } else {
             $item = javelin_render_tag('a', array('href' => $this->href, 'class' => 'phabricator-action-view-item', 'sigil' => $this->workflow ? 'workflow' : null), phutil_escape_html($this->name));
         }
     } else {
         $item = phutil_render_tag('span', array('class' => 'phabricator-action-view-item'), phutil_escape_html($this->name));
     }
     $classes = array();
     $classes[] = 'phabricator-action-view';
     if ($this->disabled) {
         $classes[] = 'phabricator-action-view-disabled';
     }
     return phutil_render_tag('li', array('class' => implode(' ', $classes)), $icon . $item);
 }
예제 #2
0
 public function render()
 {
     require_celerity_resource('aphront-form-view-css');
     Javelin::initBehavior('aphront-form-disable-on-submit');
     $layout = id(new AphrontFormLayoutView())->setBackgroundShading(true)->setPadded(true)->appendChild($this->renderDataInputs())->appendChild($this->renderChildren());
     if (!$this->user) {
         throw new Exception('You must pass the user to AphrontFormView.');
     }
     return phabricator_render_form($this->user, array('action' => $this->action, 'method' => $this->method, 'enctype' => $this->encType, 'sigil' => $this->workflow ? 'workflow' : null, 'id' => $this->id), $layout->render());
 }
 public function render()
 {
     $user = $this->user;
     require_celerity_resource('phabricator-flag-css');
     $rows = array();
     foreach ($this->flags as $flag) {
         $class = PhabricatorFlagColor::getCSSClass($flag->getColor());
         $rows[] = array(phutil_render_tag('div', array('class' => 'phabricator-flag-icon ' . $class), ''), $flag->getHandle()->renderLink(), phutil_escape_html($flag->getNote()), phabricator_datetime($flag->getDateCreated(), $user), phabricator_render_form($user, array('method' => 'POST', 'action' => '/flag/edit/' . $flag->getObjectPHID() . '/', 'sigil' => 'workflow'), phutil_render_tag('button', array('class' => 'small grey'), 'Edit Flag')), phabricator_render_form($user, array('method' => 'POST', 'action' => '/flag/delete/' . $flag->getID() . '/', 'sigil' => 'workflow'), phutil_render_tag('button', array('class' => 'small grey'), 'Remove Flag')));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('', 'Flagged Object', 'Note', 'Flagged On', '', ''));
     $table->setColumnClasses(array('', 'pri', 'wide', '', 'action', 'action'));
     $table->setNoDataString('No flags.');
     return $table->render();
 }
 public function render()
 {
     if (!$this->uri) {
         throw new Exception("Call setSubmitURI() before render()!");
     }
     if (!$this->user) {
         throw new Exception("Call setUser() before render()!");
     }
     $content = phabricator_render_form($this->user, array('action' => $this->uri, 'method' => 'POST', 'sigil' => 'inline-edit-form'), $this->renderInputs() . $this->renderBody());
     if ($this->onRight) {
         $core = '<th></th><td></td><th></th><td colspan="2">' . $content . '</td>';
     } else {
         $core = '<th></th><td>' . $content . '</td><th></th><td colspan="2"></td>';
     }
     return '<table><tr class="inline-comment-splint">' . $core . '</tr></table>';
 }
 public function render()
 {
     $user = $this->user;
     $target_id = celerity_generate_unique_node_id();
     $search_id = $this->getID();
     $input = phutil_render_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off'));
     $scope = $this->scope;
     $target = javelin_render_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), '');
     Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'src' => '/typeahead/common/mainsearch/', 'limit' => 10, 'placeholder' => PhabricatorSearchScope::getScopePlaceholder($scope)));
     $scope_input = phutil_render_tag('input', array('type' => 'hidden', 'name' => 'scope', 'value' => $scope));
     $form = phabricator_render_form($user, array('action' => '/search/', 'method' => 'POST'), '<div class="phabricator-main-menu-search-container">' . $input . '<button>Search</button>' . $scope_input . $target . '</div>');
     $group = new PhabricatorMainMenuGroupView();
     $group->addClass('phabricator-main-menu-search');
     $group->appendChild($form);
     return $group->render();
 }
 public function render()
 {
     if ($this->instant) {
         $button_class = $this->class . ' link';
         return phabricator_render_form($this->user, array('action' => $this->uri, 'method' => 'post', 'style' => 'display: inline'), '<button class="' . $button_class . '">' . phutil_escape_html($this->name) . '</button>');
     }
     if ($this->uri) {
         $tag = 'a';
     } else {
         $tag = 'span';
     }
     $attrs = array('href' => $this->uri, 'class' => $this->class);
     if ($this->workflow) {
         $attrs['sigil'] = 'workflow';
     }
     return javelin_render_tag($tag, $attrs, phutil_escape_html($this->name));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $nav = $this->buildBaseSideNav();
     $queries = id(new ManiphestSavedQuery())->loadAllWhere('userPHID = %s ORDER BY name ASC', $user->getPHID());
     $default = null;
     if ($request->isFormPost()) {
         $new_default = null;
         foreach ($queries as $query) {
             if ($query->getID() == $request->getInt('default')) {
                 $new_default = $query;
             }
         }
         if ($this->getDefaultQuery()) {
             $this->getDefaultQuery()->setIsDefault(0)->save();
         }
         if ($new_default) {
             $new_default->setIsDefault(1)->save();
         }
         return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
     }
     $rows = array();
     foreach ($queries as $query) {
         if ($query->getIsDefault()) {
             $default = $query;
         }
         $rows[] = array(phutil_render_tag('input', array('type' => 'radio', 'name' => 'default', 'value' => $query->getID(), 'checked' => $query->getIsDefault() ? 'checked' : null)), phutil_render_tag('a', array('href' => '/maniphest/view/custom/?key=' . $query->getQueryKey()), phutil_escape_html($query->getName())), phutil_render_tag('a', array('href' => '/maniphest/custom/edit/' . $query->getID() . '/', 'class' => 'grey small button'), 'Edit'), javelin_render_tag('a', array('href' => '/maniphest/custom/delete/' . $query->getID() . '/', 'class' => 'grey small button', 'sigil' => 'workflow'), 'Delete'));
     }
     $rows[] = array(phutil_render_tag('input', array('type' => 'radio', 'name' => 'default', 'value' => 0, 'checked' => $default === null ? 'checked' : null)), '<em>No Default</em>', '', '');
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Default', 'Name', 'Edit', 'Delete'));
     $table->setColumnClasses(array('radio', 'wide pri', 'action', 'action'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Saved Custom Queries');
     $panel->addButton(phutil_render_tag('button', array(), 'Save Default Query'));
     $panel->appendChild($table);
     $form = phabricator_render_form($user, array('method' => 'POST', 'action' => $request->getRequestURI()), $panel->render());
     $nav->selectFilter('saved', 'saved');
     $nav->appendChild($form);
     return $this->buildStandardPageResponse($nav, array('title' => 'Saved Queries'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $email = $user->loadPrimaryEmail();
     if ($email->getIsVerified()) {
         return id(new AphrontRedirectResponse())->setURI('/');
     }
     $email_address = $email->getAddress();
     $sent = null;
     if ($request->isFormPost()) {
         $email->sendVerificationEmail($user);
         $sent = new AphrontErrorView();
         $sent->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
         $sent->setTitle('Email Sent');
         $sent->appendChild('<p>Another verification email was sent to <strong>' . phutil_escape_html($email_address) . '</strong>.</p>');
     }
     $error_view = new AphrontRequestFailureView();
     $error_view->setHeader('Check Your Email');
     $error_view->appendChild('<p>You must verify your email address to login. You should have a new ' . 'email message from Phabricator with verification instructions in your ' . 'inbox (<strong>' . phutil_escape_html($email_address) . '</strong>).</p>');
     $error_view->appendChild('<p>If you did not receive an email, you can click the button below ' . 'to try sending another one.</p>');
     $error_view->appendChild('<div class="aphront-failure-continue">' . phabricator_render_form($user, array('action' => '/login/mustverify/', 'method' => 'POST'), phutil_render_tag('button', array(), 'Send Another Email')) . '</div>');
     return $this->buildStandardPageResponse(array($sent, $error_view), array('title' => 'Must Verify Email'));
 }
 private function renderMemberList(array $handles)
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $list = id(new PhabricatorObjectListView())->setHandles($handles);
     foreach ($handles as $handle) {
         $hidden_input = phutil_render_tag('input', array('type' => 'hidden', 'name' => 'remove', 'value' => $handle->getPHID()), '');
         $button = javelin_render_tag('button', array('class' => 'grey'), pht('Remove'));
         $list->addButton($handle, phabricator_render_form($user, array('method' => 'POST', 'action' => $request->getRequestURI()), $hidden_input . $button));
     }
     return $list;
 }
 protected function getBody()
 {
     $console = $this->getConsole();
     $tabs = array();
     foreach ($this->tabs as $name => $tab) {
         $tab_markup = phutil_render_tag('a', array('href' => idx($tab, 'href')), phutil_escape_html(idx($tab, 'name')));
         $tab_markup = phutil_render_tag('td', array('class' => $name == $this->selectedTab ? 'phabricator-selected-tab' : null), $tab_markup);
         $tabs[] = $tab_markup;
     }
     $tabs = implode('', $tabs);
     $login_stuff = null;
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
         // NOTE: user may not be set here if we caught an exception early
         // in the execution workflow.
         if ($user && $user->getPHID()) {
             $login_stuff = phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUsername())) . ' &middot; ' . '<a href="/settings/">Settings</a>' . ' &middot; ' . phabricator_render_form($user, array('action' => '/search/', 'method' => 'post', 'style' => 'display: inline'), '<input type="text" name="query" id="standard-search-box" />' . ' in ' . AphrontFormSelectControl::renderSelectTag($this->getSearchDefaultScope(), PhabricatorSearchScope::getScopeOptions(), array('name' => 'scope')) . ' ' . '<button>Search</button>');
         }
     }
     $foot_links = array();
     $version = PhabricatorEnv::getEnvConfig('phabricator.version');
     $foot_links[] = phutil_escape_html('Phabricator ' . $version);
     $foot_links[] = '<a href="https://secure.phabricator.com/maniphest/task/create/">' . 'Report a Bug' . '</a>';
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled') && !PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
         if ($console) {
             $link = javelin_render_tag('a', array('href' => '/~/', 'sigil' => 'workflow'), 'Disable DarkConsole');
         } else {
             $link = javelin_render_tag('a', array('href' => '/~/', 'sigil' => 'workflow'), 'Enable DarkConsole');
         }
         $foot_links[] = $link;
     }
     if ($user && $user->getPHID()) {
         // This ends up very early in tab order at the top of the page and there's
         // a bunch of junk up there anyway, just shove it down here.
         $foot_links[] = phabricator_render_form($user, array('action' => '/logout/', 'method' => 'post', 'style' => 'display: inline'), '<button class="link">Logout</button>');
     }
     $foot_links = implode(' &middot; ', $foot_links);
     $admin_class = null;
     if ($this->getIsAdminInterface()) {
         $admin_class = 'phabricator-admin-page-view';
     }
     $custom_logo = null;
     $with_custom = null;
     $custom_conf = PhabricatorEnv::getEnvConfig('phabricator.custom.logo');
     if ($custom_conf) {
         $with_custom = 'phabricator-logo-with-custom';
         $custom_logo = phutil_render_tag('a', array('class' => 'logo-custom', 'href' => $custom_conf), ' ');
     }
     $notification_indicator = '';
     $notification_dropdown = '';
     $notification_container = '';
     if (PhabricatorEnv::getEnvConfig('notification.enabled') && $user && $user->isLoggedIn()) {
         $aphlict_object_id = 'aphlictswfobject';
         $client_uri = PhabricatorEnv::getEnvConfig('notification.client-uri');
         $client_uri = new PhutilURI($client_uri);
         if ($client_uri->getDomain() == 'localhost') {
             $this_host = $this->getRequest()->getHost();
             $this_host = new PhutilURI('http://' . $this_host . '/');
             $client_uri->setDomain($this_host->getDomain());
         }
         $enable_debug = PhabricatorEnv::getEnvConfig('notification.debug');
         Javelin::initBehavior('aphlict-listen', array('id' => $aphlict_object_id, 'server' => $client_uri->getDomain(), 'port' => $client_uri->getPort(), 'debug' => $enable_debug, 'pageObjects' => array_fill_keys($this->pageObjects, true)));
         Javelin::initBehavior('aphlict-dropdown', array());
         $notification_count = id(new PhabricatorFeedStoryNotification())->countUnread($user);
         $indicator_classes = array('phabricator-notification-indicator');
         if ($notification_count) {
             $indicator_classes[] = 'phabricator-notification-indicator-unread';
         }
         $notification_indicator = javelin_render_tag('div', array('id' => 'phabricator-notification-indicator', 'class' => implode(' ', $indicator_classes)), $notification_count);
         $notification_indicator = javelin_render_tag('div', array('id' => 'phabricator-notification-menu', 'class' => 'phabricator-icon-menu icon-menu-notifications', 'sigil' => 'aphlict-indicator'), $notification_indicator);
         $notification_indicator = javelin_render_tag('td', array('class' => 'phabricator-icon-menu-cell'), $notification_indicator);
         $notification_container = '<div id="aphlictswf-container" style="height:0px; width:0px;">' . '</div>';
         $notification_dropdown = javelin_render_tag('div', array('sigil' => 'aphlict-dropdown', 'id' => 'phabricator-notification-dropdown', 'style' => 'display: none'), '');
     }
     $header_chrome = null;
     $footer_chrome = null;
     if ($this->getShowChrome()) {
         $header_chrome = '<table class="phabricator-standard-header">' . '<tr>' . '<td class="phabricator-logo ' . $with_custom . '">' . $custom_logo . '<a class="logo-standard" href="/"> </a>' . '</td>' . $notification_indicator . '<td>' . '<table class="phabricator-primary-navigation">' . '<tr>' . '<th>' . phutil_render_tag('a', array('href' => $this->getBaseURI(), 'class' => 'phabricator-head-appname'), phutil_escape_html($this->getApplicationName())) . '</th>' . $tabs . '</tr>' . '</table>' . '</td>' . '<td class="phabricator-login-details">' . $login_stuff . '</td>' . '</tr>' . '</table>' . $notification_dropdown . $notification_container;
         $footer_chrome = '<div class="phabricator-page-foot">' . $foot_links . '</div>';
     }
     $developer_warning = null;
     if (PhabricatorEnv::getEnvConfig('phabricator.show-error-callout') && DarkConsoleErrorLogPluginAPI::getErrors()) {
         $developer_warning = '<div class="aphront-developer-error-callout">' . 'This page raised PHP errors. Find them in DarkConsole ' . 'or the error log.' . '</div>';
     }
     Javelin::initBehavior('device', array('id' => 'base-page'));
     $agent = idx($_SERVER, 'HTTP_USER_AGENT');
     // Try to guess the device resolution based on UA strings to avoid a flash
     // of incorrectly-styled content.
     $device_guess = 'device-desktop';
     if (preg_match('/iPhone|iPod/', $agent)) {
         $device_guess = 'device-phone';
     } else {
         if (preg_match('/iPad/', $agent)) {
             $device_guess = 'device-tablet';
         }
     }
     $classes = array('phabricator-standard-page', $admin_class, $device_guess);
     $classes = implode(' ', $classes);
     return ($console ? '<darkconsole />' : null) . $developer_warning . phutil_render_tag('div', array('id' => 'base-page', 'class' => $classes), $header_chrome . $this->bodyContent . '<div style="clear: both;"></div>') . $footer_chrome;
 }
 public final function render()
 {
     require_celerity_resource('aphront-dialog-view-css');
     $buttons = array();
     if ($this->submitButton) {
         $buttons[] = javelin_render_tag('button', array('name' => '__submit__', 'sigil' => '__default__'), phutil_escape_html($this->submitButton));
     }
     if ($this->cancelURI) {
         $buttons[] = javelin_render_tag('a', array('href' => $this->cancelURI, 'class' => 'button grey', 'name' => '__cancel__', 'sigil' => 'jx-workflow-button'), phutil_escape_html($this->cancelText));
     }
     $buttons = implode('', $buttons);
     if (!$this->user) {
         throw new Exception("You must call setUser() when rendering an AphrontDialogView.");
     }
     $more = $this->class;
     switch ($this->width) {
         case self::WIDTH_FORM:
             $more .= ' aphront-dialog-view-width-' . $this->width;
             break;
         case self::WIDTH_DEFAULT:
             break;
         default:
             throw new Exception("Unknown dialog width '{$this->width}'!");
     }
     $attributes = array('class' => 'aphront-dialog-view ' . $more, 'sigil' => 'jx-dialog');
     $form_attributes = array('action' => $this->submitURI, 'method' => 'post', 'id' => $this->formID);
     $hidden_inputs = array();
     foreach ($this->hidden as $desc) {
         list($key, $value) = $desc;
         $hidden_inputs[] = javelin_render_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value, 'sigil' => 'aphront-dialog-application-input'));
     }
     $hidden_inputs = implode("\n", $hidden_inputs);
     $hidden_inputs = '<input type="hidden" name="__dialog__" value="1" />' . $hidden_inputs;
     if (!$this->renderAsForm) {
         $buttons = phabricator_render_form($this->user, $form_attributes, $hidden_inputs . $buttons);
     }
     $content = '<div class="aphront-dialog-head">' . phutil_escape_html($this->title) . '</div>' . '<div class="aphront-dialog-body">' . $this->renderChildren() . '</div>' . '<div class="aphront-dialog-tail">' . $buttons . '<div style="clear: both;"></div>' . '</div>';
     if ($this->renderAsForm) {
         return phabricator_render_form($this->user, $form_attributes + $attributes, $hidden_inputs . $content);
     } else {
         return javelin_render_tag('div', $attributes, $content);
     }
 }
 protected function getBody()
 {
     $console = $this->getConsole();
     $tabs = array();
     foreach ($this->tabs as $name => $tab) {
         $tab_markup = phutil_render_tag('a', array('href' => idx($tab, 'href')), phutil_escape_html(idx($tab, 'name')));
         $tab_markup = phutil_render_tag('td', array('class' => $name == $this->selectedTab ? 'phabricator-selected-tab' : null), $tab_markup);
         $tabs[] = $tab_markup;
     }
     $tabs = implode('', $tabs);
     $login_stuff = null;
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
         // NOTE: user may not be set here if we caught an exception early
         // in the execution workflow.
         if ($user && $user->getPHID()) {
             $login_stuff = phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUsername())) . ' &middot; ' . '<a href="/settings/">Settings</a>' . ' &middot; ' . phabricator_render_form($user, array('action' => '/search/', 'method' => 'post', 'style' => 'display: inline'), '<input type="text" name="query" />' . '<button>Search</button>');
         }
     }
     $foot_links = array();
     $version = PhabricatorEnv::getEnvConfig('phabricator.version');
     $foot_links[] = phutil_escape_html('Phabricator ' . $version);
     if (PhabricatorEnv::getEnvConfig('darkconsole.enabled') && !PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
         if ($console) {
             $link = javelin_render_tag('a', array('href' => '/~/', 'sigil' => 'workflow'), 'Disable DarkConsole');
         } else {
             $link = javelin_render_tag('a', array('href' => '/~/', 'sigil' => 'workflow'), 'Enable DarkConsole');
         }
         $foot_links[] = $link;
     }
     if ($user && $user->getPHID()) {
         // This ends up very early in tab order at the top of the page and there's
         // a bunch of junk up there anyway, just shove it down here.
         $foot_links[] = phabricator_render_form($user, array('action' => '/logout/', 'method' => 'post', 'style' => 'display: inline'), '<button class="link">Logout</button>');
     }
     $foot_links = implode(' &middot; ', $foot_links);
     $admin_class = null;
     if ($this->getIsAdminInterface()) {
         $admin_class = 'phabricator-admin-page-view';
     }
     $header_chrome = null;
     $footer_chrome = null;
     if ($this->getShowChrome()) {
         $header_chrome = '<table class="phabricator-standard-header">' . '<tr>' . '<td class="phabricator-logo"><a href="/"> </a></td>' . '<td>' . '<table class="phabricator-primary-navigation">' . '<tr>' . '<th>' . phutil_render_tag('a', array('href' => $this->getBaseURI(), 'class' => 'phabricator-head-appname'), phutil_escape_html($this->getApplicationName())) . '</th>' . $tabs . '</tr>' . '</table>' . '</td>' . '<td class="phabricator-login-details">' . $login_stuff . '</td>' . '</tr>' . '</table>';
         $footer_chrome = '<div class="phabricator-page-foot">' . $foot_links . '</div>';
     }
     $developer_warning = null;
     if (PhabricatorEnv::getEnvConfig('phabricator.show-error-callout') && DarkConsoleErrorLogPluginAPI::getErrors()) {
         $developer_warning = '<div class="aphront-developer-error-callout">' . 'This page raised PHP errors. Find them in DarkConsole ' . 'or the error log.' . '</div>';
     }
     return ($console ? '<darkconsole />' : null) . $developer_warning . '<div class="phabricator-standard-page ' . $admin_class . '">' . $header_chrome . $this->bodyContent . '<div style="clear: both;"></div>' . '</div>' . $footer_chrome;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $query = id(new PhabricatorProjectQuery())->setViewer($user)->withIDs(array($this->id));
     if ($this->page == 'people') {
         $query->needMembers(true);
     }
     $project = $query->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $profile = $project->loadProfile();
     if (!$profile) {
         $profile = new PhabricatorProjectProfile();
     }
     $picture = $profile->loadProfileImageURI();
     $nav_view = $this->buildLocalNavigation($project);
     $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()));
             $query->setLimit(50);
             $query->setViewer($this->getRequest()->getUser());
             $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 (!$project->isUserMember($user->getPHID())) {
         $can_join = PhabricatorPolicyCapability::CAN_JOIN;
         if (PhabricatorPolicyFilter::hasCapability($user, $project, $can_join)) {
             $class = 'green';
         } else {
             $class = 'grey disabled';
         }
         $action = phabricator_render_form($user, array('action' => '/project/update/' . $project->getID() . '/join/', 'method' => 'post'), phutil_render_tag('button', array('class' => $class), '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();
     $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'));
 }
 protected function getBody()
 {
     $console = $this->getConsole();
     $login_stuff = null;
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
         // NOTE: user may not be set here if we caught an exception early
         // in the execution workflow.
         if ($user && $user->getPHID()) {
             $login_stuff = phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUsername())) . ' &middot; ' . '<a href="/settings/">Settings</a>' . ' &middot; ' . phabricator_render_form($user, array('action' => '/search/', 'method' => 'post', 'style' => 'display: inline'), '<div class="menu-section menu-section-search">' . '<div class="menu-search-container">' . '<input type="text" name="query" id="standard-search-box" />' . '<button id="standard-search-button">Search</button>' . '</div>' . '</div>' . ' in ' . AphrontFormSelectControl::renderSelectTag($this->getSearchDefaultScope(), PhabricatorSearchScope::getScopeOptions(), array('name' => 'scope')) . ' ' . '<button>Search</button>');
         }
     }
     $admin_class = null;
     if ($this->getIsAdminInterface()) {
         $admin_class = 'phabricator-admin-page-view';
     }
     $header_chrome = null;
     $footer_chrome = null;
     if ($this->getShowChrome()) {
         $header_chrome = $this->menuContent;
         if (!$this->deviceReady) {
             $footer_chrome = $this->renderFooter();
         }
     }
     $developer_warning = null;
     if (PhabricatorEnv::getEnvConfig('phabricator.show-error-callout') && DarkConsoleErrorLogPluginAPI::getErrors()) {
         $developer_warning = '<div class="aphront-developer-error-callout">' . 'This page raised PHP errors. Find them in DarkConsole ' . 'or the error log.' . '</div>';
     }
     $agent = idx($_SERVER, 'HTTP_USER_AGENT');
     // Try to guess the device resolution based on UA strings to avoid a flash
     // of incorrectly-styled content.
     $device_guess = 'device-desktop';
     if (preg_match('/iPhone|iPod/', $agent)) {
         $device_guess = 'device-phone';
     } else {
         if (preg_match('/iPad/', $agent)) {
             $device_guess = 'device-tablet';
         }
     }
     $classes = array('phabricator-standard-page', $admin_class, $device_guess);
     $classes = implode(' ', $classes);
     return phutil_render_tag('div', array('id' => 'base-page', 'class' => $classes), $header_chrome . '<div class="phabricator-main-menu-spacer"></div>' . '<div class="phabricator-standard-page-body">' . ($console ? '<darkconsole />' : null) . $developer_warning . $this->bodyContent . '<div style="clear: both;"></div>' . '</div>') . $footer_chrome;
 }
 private function buildJumpPanel($query = null)
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $uniq_id = celerity_generate_unique_node_id();
     Javelin::initBehavior('phabricator-autofocus', array('id' => $uniq_id));
     require_celerity_resource('phabricator-jump-nav');
     $doc_href = PhabricatorEnv::getDocLink('article/Jump_Nav_User_Guide.html');
     $doc_link = phutil_render_tag('a', array('href' => $doc_href), 'Jump Nav User Guide');
     $jump_input = phutil_render_tag('input', array('type' => 'text', 'class' => 'phabricator-jump-nav', 'name' => 'jump', 'id' => $uniq_id, 'value' => $query));
     $jump_caption = phutil_render_tag('p', array('class' => 'phabricator-jump-nav-caption'), 'Enter the name of an object like <tt>D123</tt> to quickly jump to ' . 'it. See ' . $doc_link . ' or type <tt>help</tt>.');
     $panel = new AphrontPanelView();
     $panel->addClass('aphront-unpadded-panel-view');
     $panel->appendChild(phabricator_render_form($user, array('action' => '/jump/', 'method' => 'POST', 'class' => 'phabricator-jump-nav-form'), $jump_input . $jump_caption));
     return $panel;
 }
 private function renderViewSelectPanel($selected)
 {
     $request = $this->getRequest();
     $select = AphrontFormSelectControl::renderSelectTag($selected, array('highlighted' => 'View as Highlighted Text', 'blame' => 'View as Highlighted Text with Blame', 'plain' => 'View as Plain Text', 'plainblame' => 'View as Plain Text with Blame', 'raw' => 'View as raw document'), array('name' => 'view'));
     $view_select_panel = new AphrontPanelView();
     $view_select_form = phabricator_render_form($request->getUser(), array('action' => $request->getRequestURI()->alter('view', null), 'method' => 'post', 'class' => 'diffusion-browse-type-form'), $select . ' <button>View</button> ' . $this->renderEditButton());
     $view_select_panel->appendChild($view_select_form);
     $view_select_panel->appendChild('<div style="clear: both;"></div>');
     return $view_select_panel;
 }
 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 buildDialog()
 {
     $user = $this->user;
     $filter_id = celerity_generate_unique_node_id();
     $query_id = celerity_generate_unique_node_id();
     $results_id = celerity_generate_unique_node_id();
     $current_id = celerity_generate_unique_node_id();
     $search_id = celerity_generate_unique_node_id();
     $form_id = celerity_generate_unique_node_id();
     require_celerity_resource('phabricator-object-selector-css');
     $options = array();
     foreach ($this->filters as $key => $label) {
         $options[] = phutil_render_tag('option', array('value' => $key, 'selected' => $key == $this->selectedFilter ? 'selected' : null), $label);
     }
     $options = implode("\n", $options);
     $instructions = null;
     if ($this->instructions) {
         $instructions = '<p class="phabricator-object-selector-instructions">' . $this->instructions . '</p>';
     }
     $search_box = phabricator_render_form($user, array('method' => 'POST', 'action' => $this->submitURI, 'id' => $search_id), '<table class="phabricator-object-selector-search">
     <tr>
       <td class="phabricator-object-selector-search-filter">
         <select id="' . $filter_id . '">' . $options . '</select>
       </td>
       <td class="phabricator-object-selector-search-text">
         <input type="text" id="' . $query_id . '" />
       </td>
     </tr>
   </table>');
     $result_box = '<div class="phabricator-object-selector-results" id="' . $results_id . '">' . '</div>';
     $attached_box = '<div class="phabricator-object-selector-current">' . '<div class="phabricator-object-selector-currently-attached">' . '<div class="phabricator-object-selector-header">' . phutil_escape_html($this->header) . '</div>' . '<div id="' . $current_id . '">' . '</div>' . $instructions . '</div>' . '</div>';
     $dialog = new AphrontDialogView();
     $dialog->setUser($this->user)->setTitle($this->title)->setClass('phabricator-object-selector-dialog')->appendChild($search_box)->appendChild($result_box)->appendChild($attached_box)->setRenderDialogAsDiv()->setFormID($form_id)->addSubmitButton($this->buttonText);
     if ($this->cancelURI) {
         $dialog->addCancelButton($this->cancelURI);
     }
     $handle_views = array();
     foreach ($this->handles as $handle) {
         $phid = $handle->getPHID();
         $view = new PhabricatorHandleObjectSelectorDataView($handle);
         $handle_views[$phid] = $view->renderData();
     }
     $dialog->addHiddenInput('phids', implode(';', array_keys($this->handles)));
     Javelin::initBehavior('phabricator-object-selector', array('filter' => $filter_id, 'query' => $query_id, 'search' => $search_id, 'results' => $results_id, 'current' => $current_id, 'form' => $form_id, 'exclude' => $this->excluded, 'uri' => $this->searchURI, 'handles' => $handle_views));
     return $dialog;
 }