private function renderSettingsWidgetPaneContent()
 {
     $viewer = $this->getViewer();
     $conpherence = $this->getConpherence();
     $participant = $conpherence->getParticipantIfExists($viewer->getPHID());
     if (!$participant) {
         $can_join = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_JOIN);
         if ($can_join) {
             $text = pht('Notification settings are available after joining the room.');
         } else {
             if ($viewer->isLoggedIn()) {
                 $text = pht('Notification settings not applicable to rooms you can not join.');
             } else {
                 $text = pht('Notification settings are available after logging in and joining ' . 'the room.');
             }
         }
         return phutil_tag('div', array('class' => 'no-settings'), $text);
     }
     $notification_key = PhabricatorConpherenceNotificationsSetting::SETTINGKEY;
     $notification_default = $viewer->getUserSetting($notification_key);
     $settings = $participant->getSettings();
     $notifications = idx($settings, 'notifications', $notification_default);
     $options = id(new AphrontFormRadioButtonControl())->addButton(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL, PhabricatorConpherenceNotificationsSetting::getSettingLabel(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_EMAIL), '')->addButton(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY, PhabricatorConpherenceNotificationsSetting::getSettingLabel(PhabricatorConpherenceNotificationsSetting::VALUE_CONPHERENCE_NOTIFY), '')->setName('notifications')->setValue($notifications);
     $layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
     return phabricator_form($viewer, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
 }
 public function render()
 {
     if (!$this->uri) {
         throw new PhutilInvalidStateException('setSubmitURI');
     }
     $viewer = $this->getViewer();
     $content = phabricator_form($viewer, array('action' => $this->uri, 'method' => 'POST', 'sigil' => 'inline-edit-form'), array($this->renderInputs(), $this->renderBody()));
     return $content;
 }
 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_form($this->user, array('action' => $this->uri, 'method' => 'POST', 'sigil' => 'inline-edit-form'), array($this->renderInputs(), $this->renderBody()));
     return phutil_tag('table', array(), phutil_tag('tr', array('class' => 'inline-comment-splint'), array(phutil_tag('th', array()), phutil_tag('td', array('class' => 'left'), $this->onRight ? null : $content), phutil_tag('th', array()), phutil_tag('td', array('colspan' => 3, 'class' => 'right3'), $this->onRight ? $content : null))));
 }
 public function buildSearchForm()
 {
     $viewer = $this->getViewer();
     $conpherence = $this->conpherence;
     $name = $conpherence->getTitle();
     $bar = javelin_tag('input', array('type' => 'text', 'id' => 'conpherence-search-input', 'name' => 'fulltext', 'class' => 'conpherence-search-input', 'sigil' => 'conpherence-search-input', 'placeholder' => pht('Search %s...', $name)));
     $id = $conpherence->getID();
     $form = phabricator_form($viewer, array('method' => 'POST', 'action' => '/conpherence/threadsearch/' . $id . '/', 'sigil' => 'conpherence-search-form', 'class' => 'conpherence-search-form', 'id' => 'conpherence-search-form'), array($bar));
     $form_view = phutil_tag('div', array('class' => 'conpherence-search-form-view'), $form);
     $results = phutil_tag('div', array('id' => 'conpherence-search-results', 'class' => 'conpherence-search-results'));
     $view = phutil_tag('div', array('class' => 'conpherence-search-window'), array($form_view, $results));
     return $view;
 }
 public function render()
 {
     $user = $this->user;
     $target_id = celerity_generate_unique_node_id();
     $search_id = $this->getID();
     $button_id = celerity_generate_unique_node_id();
     $input = phutil_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off'));
     $target = javelin_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), '');
     $search_datasource = new PhabricatorSearchDatasource();
     Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'button' => $button_id, 'src' => $search_datasource->getDatasourceURI(), 'limit' => 10, 'placeholder' => pht('Search')));
     $primary_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'search:primary', 'value' => 'true'));
     $form = phabricator_form($user, array('action' => '/search/', 'method' => 'POST'), phutil_tag_div('phabricator-main-menu-search-container', array($input, phutil_tag('button', array('id' => $button_id), pht('Search')), $primary_input, $target)));
     return $form;
 }
 private function renderOptionButton(array $option)
 {
     $viewer = $this->getViewer();
     $icon = idx($option, 'icon');
     if ($icon) {
         $preview_class = null;
         $preview_content = id(new PHUIIconView())->setIcon($icon, 'lightbluetext');
     } else {
         $preview_class = 'phui-workboard-' . $option['key'];
         $preview_content = null;
     }
     $preview = phutil_tag('div', array('class' => 'phui-workboard-color-preview ' . $preview_class), $preview_content);
     $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $option['name'], 'size' => 300)), $preview);
     $input = phutil_tag('input', array('type' => 'hidden', 'name' => 'backgroundKey', 'value' => $option['key']));
     return phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($button, $input));
 }
 private function renderSettingsWidgetPaneContent()
 {
     $user = $this->getRequest()->getUser();
     $conpherence = $this->getConpherence();
     $participants = $conpherence->getParticipants();
     $participant = $participants[$user->getPHID()];
     $default = ConpherenceSettings::EMAIL_ALWAYS;
     $preference = $this->getUserPreferences();
     if ($preference) {
         $default = $preference->getPreference(PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS, ConpherenceSettings::EMAIL_ALWAYS);
     }
     $settings = $participant->getSettings();
     $notifications = idx($settings, 'notifications', $default);
     $options = id(new AphrontFormRadioButtonControl())->addButton(ConpherenceSettings::EMAIL_ALWAYS, ConpherenceSettings::getHumanString(ConpherenceSettings::EMAIL_ALWAYS), '')->addButton(ConpherenceSettings::NOTIFICATIONS_ONLY, ConpherenceSettings::getHumanString(ConpherenceSettings::NOTIFICATIONS_ONLY), '')->setName('notifications')->setValue($notifications);
     $layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
     return phabricator_form($user, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
 }
 public function render()
 {
     $user = $this->user;
     $target_id = celerity_generate_unique_node_id();
     $search_id = $this->getID();
     $button_id = celerity_generate_unique_node_id();
     $selector_id = celerity_generate_unique_node_id();
     $application_id = celerity_generate_unique_node_id();
     $input = phutil_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off'));
     $target = javelin_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), '');
     $search_datasource = new PhabricatorSearchDatasource();
     $scope_key = PhabricatorUserPreferences::PREFERENCE_SEARCH_SCOPE;
     Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'button' => $button_id, 'selectorID' => $selector_id, 'applicationID' => $application_id, 'defaultApplicationIcon' => self::DEFAULT_APPLICATION_ICON, 'appScope' => PhabricatorSearchController::SCOPE_CURRENT_APPLICATION, 'src' => $search_datasource->getDatasourceURI(), 'limit' => 10, 'placeholder' => pht('Search'), 'scopeUpdateURI' => '/settings/adjust/?key=' . $scope_key));
     $primary_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'search:primary', 'value' => 'true'));
     $search_text = javelin_tag('span', array('aural' => true), pht('Search'));
     $selector = $this->buildModeSelector($selector_id, $application_id);
     $form = phabricator_form($user, array('action' => '/search/', 'method' => 'POST'), phutil_tag_div('phabricator-main-menu-search-container', array($input, phutil_tag('button', array('id' => $button_id, 'class' => 'phui-icon-view phui-font-fa fa-search'), $search_text), $selector, $primary_input, $target)));
     return $form;
 }
 protected function renderLoginForm(AphrontRequest $request, $mode)
 {
     $viewer = $request->getUser();
     if ($mode == 'link') {
         $button_text = pht('Link External Account');
     } else {
         if ($mode == 'refresh') {
             $button_text = pht('Refresh Account Link');
         } else {
             if ($this->shouldAllowRegistration()) {
                 $button_text = pht('Login or Register');
             } else {
                 $button_text = pht('Login');
             }
         }
     }
     $icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getLoginIcon());
     $button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($button_text)->setSubtext($this->getProviderName());
     $content = array($button);
     $uri = $this->getLoginURI();
     return phabricator_form($viewer, array('method' => 'GET', 'action' => (string) $uri), $content);
 }
 private function renderBatchEditor(PhabricatorSavedQuery $saved_query)
 {
     $user = $this->getUser();
     if (!$this->canBatchEdit) {
         return null;
     }
     if (!$user->isLoggedIn()) {
         // Don't show the batch editor or excel export for logged-out users.
         // Technically we //could// let them export, but ehh.
         return null;
     }
     Javelin::initBehavior('maniphest-batch-selector', array('selectAll' => 'batch-select-all', 'selectNone' => 'batch-select-none', 'submit' => 'batch-select-submit', 'status' => 'batch-select-status-cell', 'idContainer' => 'batch-select-id-container', 'formID' => 'batch-select-form'));
     $select_all = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-all'), pht('Select All'));
     $select_none = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'class' => 'grey button', 'id' => 'batch-select-none'), pht('Clear Selection'));
     $submit = phutil_tag('button', array('id' => 'batch-select-submit', 'disabled' => 'disabled', 'class' => 'disabled'), pht("Batch Edit Selected »"));
     $export = javelin_tag('a', array('href' => '/maniphest/export/' . $saved_query->getQueryKey() . '/', 'class' => 'grey button'), pht('Export to Excel'));
     $hidden = phutil_tag('div', array('id' => 'batch-select-id-container'), '');
     $editor = hsprintf('<table class="maniphest-batch-editor-layout">' . '<tr>' . '<td>%s%s</td>' . '<td>%s</td>' . '<td id="batch-select-status-cell">%s</td>' . '<td class="batch-select-submit-cell">%s%s</td>' . '</tr>' . '</table>', $select_all, $select_none, $export, '', $submit, $hidden);
     $editor = phabricator_form($user, array('method' => 'POST', 'action' => '/maniphest/batch/', 'id' => 'batch-select-form'), $editor);
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Batch Task Editor'))->appendChild($editor);
     $content = phutil_tag_div('maniphest-batch-editor', $box);
     return $content;
 }
 public function render()
 {
     $this->requireResource('differential-core-view-css');
     $this->requireResource('differential-revision-history-css');
     $data = array(array('name' => 'Base', 'id' => null, 'desc' => 'Base', 'age' => null, 'obj' => null));
     $seq = 0;
     foreach ($this->diffs as $diff) {
         $data[] = array('name' => 'Diff ' . ++$seq, 'id' => $diff->getID(), 'desc' => $diff->getDescription(), 'age' => $diff->getDateCreated(), 'obj' => $diff);
     }
     $max_id = $diff->getID();
     $idx = 0;
     $rows = array();
     $disable = false;
     $radios = array();
     $last_base = null;
     $rowc = array();
     foreach ($data as $row) {
         $diff = $row['obj'];
         $name = $row['name'];
         $id = $row['id'];
         $old_class = false;
         $new_class = false;
         if ($id) {
             $new_checked = $this->selectedDiffID == $id;
             $new = javelin_tag('input', array('type' => 'radio', 'name' => 'id', 'value' => $id, 'checked' => $new_checked ? 'checked' : null, 'sigil' => 'differential-new-radio'));
             if ($new_checked) {
                 $new_class = true;
                 $disable = true;
             }
             $new = phutil_tag('div', array('class' => 'differential-update-history-radio'), $new);
         } else {
             $new = null;
         }
         if ($max_id != $id) {
             $uniq = celerity_generate_unique_node_id();
             $old_checked = $this->selectedVersusDiffID == $id;
             $old = phutil_tag('input', array('type' => 'radio', 'name' => 'vs', 'value' => $id, 'id' => $uniq, 'checked' => $old_checked ? 'checked' : null, 'disabled' => $disable ? 'disabled' : null));
             $radios[] = $uniq;
             if ($old_checked) {
                 $old_class = true;
             }
             $old = phutil_tag('div', array('class' => 'differential-update-history-radio'), $old);
         } else {
             $old = null;
         }
         $desc = $row['desc'];
         if ($row['age']) {
             $age = phabricator_datetime($row['age'], $this->getUser());
         } else {
             $age = null;
         }
         if ($diff) {
             $lint = self::renderDiffLintStar($row['obj']);
             $lint = phutil_tag('div', array('class' => 'lintunit-star', 'title' => self::getDiffLintMessage($diff)), $lint);
             $unit = self::renderDiffUnitStar($row['obj']);
             $unit = phutil_tag('div', array('class' => 'lintunit-star', 'title' => self::getDiffUnitMessage($diff)), $unit);
             $base = $this->renderBaseRevision($diff);
         } else {
             $lint = null;
             $unit = null;
             $base = null;
         }
         if ($last_base !== null && $base !== $last_base) {
             // TODO: Render some kind of notice about rebases.
         }
         $last_base = $base;
         $id_link = phutil_tag('a', array('href' => '/differential/diff/' . $id . '/'), $id);
         $rows[] = array($name, $id_link, $base, $desc, $age, $lint, $unit, $old, $new);
         $classes = array();
         if ($old_class) {
             $classes[] = 'differential-update-history-old-now';
         }
         if ($new_class) {
             $classes[] = 'differential-update-history-new-now';
         }
         $rowc[] = nonempty(implode(' ', $classes), null);
     }
     Javelin::initBehavior('differential-diff-radios', array('radios' => $radios));
     $options = array(DifferentialChangesetParser::WHITESPACE_IGNORE_FORCE => 'Ignore All', DifferentialChangesetParser::WHITESPACE_IGNORE_ALL => 'Ignore Most', DifferentialChangesetParser::WHITESPACE_IGNORE_TRAILING => 'Ignore Trailing', DifferentialChangesetParser::WHITESPACE_SHOW_ALL => 'Show All');
     foreach ($options as $value => $label) {
         $options[$value] = phutil_tag('option', array('value' => $value, 'selected' => $value == $this->selectedWhitespace ? 'selected' : null), $label);
     }
     $select = phutil_tag('select', array('name' => 'whitespace'), $options);
     $table = id(new AphrontTableView($rows));
     $table->setHeaders(array(pht('Diff'), pht('ID'), pht('Base'), pht('Description'), pht('Created'), pht('Lint'), pht('Unit'), '', ''));
     $table->setColumnClasses(array('pri', '', '', 'wide', 'date', 'center', 'center', 'center differential-update-history-old', 'center differential-update-history-new'));
     $table->setRowClasses($rowc);
     $table->setDeviceVisibility(array(true, true, false, true, false, false, false, true, true));
     $show_diff = phutil_tag('div', array('class' => 'differential-update-history-footer'), array(phutil_tag('label', array(), array(pht('Whitespace Changes:'), $select)), phutil_tag('button', array(), pht('Show Diff'))));
     $content = phabricator_form($this->getUser(), array('action' => '#toc'), array($table, $show_diff));
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Revision Update History'))->setFlush(true)->appendChild($content);
 }
 /**
  * Render a standard login/register button element.
  *
  * The `$attributes` parameter takes these keys:
  *
  *   - `uri`: URI the button should take the user to when clicked.
  *   - `method`: Optional HTTP method the button should use, defaults to GET.
  *
  * @param   AphrontRequest  HTTP request.
  * @param   string          Request mode string.
  * @param   map             Additional parameters, see above.
  * @return  wild            Login button.
  */
 protected function renderStandardLoginButton(AphrontRequest $request, $mode, array $attributes = array())
 {
     PhutilTypeSpec::checkMap($attributes, array('method' => 'optional string', 'uri' => 'string', 'sigil' => 'optional string'));
     $viewer = $request->getUser();
     $adapter = $this->getAdapter();
     if ($mode == 'link') {
         $button_text = pht('Link External Account');
     } else {
         if ($mode == 'refresh') {
             $button_text = pht('Refresh Account Link');
         } else {
             if ($mode == 'invite') {
                 $button_text = pht('Register Account');
             } else {
                 if ($this->shouldAllowRegistration()) {
                     $button_text = pht('Login or Register');
                 } else {
                     $button_text = pht('Login');
                 }
             }
         }
     }
     $icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getLoginIcon());
     $button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($button_text)->setSubtext($this->getProviderName());
     $uri = $attributes['uri'];
     $uri = new PhutilURI($uri);
     $params = $uri->getQueryParams();
     $uri->setQueryParams(array());
     $content = array($button);
     foreach ($params as $key => $value) {
         $content[] = phutil_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     return phabricator_form($viewer, array('method' => idx($attributes, 'method', 'GET'), 'action' => (string) $uri, 'sigil' => idx($attributes, 'sigil')), $content);
 }
 public function render()
 {
     $icon = null;
     if ($this->icon) {
         $color = '';
         if ($this->disabled) {
             $color = ' grey';
         }
         $icon = id(new PHUIIconView())->addClass('phabricator-action-view-icon')->setIcon($this->icon . $color);
     }
     if ($this->href) {
         $sigils = array();
         if ($this->workflow) {
             $sigils[] = 'workflow';
         }
         if ($this->download) {
             $sigils[] = 'download';
         }
         if ($this->sigils) {
             $sigils = array_merge($sigils, $this->sigils);
         }
         $sigils = $sigils ? implode(' ', $sigils) : null;
         if ($this->renderAsForm) {
             if (!$this->user) {
                 throw new Exception(pht('Call %s when rendering an action as a form.', 'setUser()'));
             }
             $item = javelin_tag('button', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
             $item = phabricator_form($this->user, array('action' => $this->getHref(), 'method' => 'POST', 'sigil' => $sigils, 'meta' => $this->metadata), $item);
         } else {
             if ($this->getOpenInNewWindow()) {
                 $target = '_blank';
             } else {
                 $target = null;
             }
             $item = javelin_tag('a', array('href' => $this->getHref(), 'class' => 'phabricator-action-view-item', 'target' => $target, 'sigil' => $sigils, 'meta' => $this->metadata), array($icon, $this->name));
         }
     } else {
         $item = phutil_tag('span', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
     }
     $classes = array();
     $classes[] = 'phabricator-action-view';
     if ($this->disabled) {
         $classes[] = 'phabricator-action-view-disabled';
     }
     if ($this->label) {
         $classes[] = 'phabricator-action-view-label';
     }
     if ($this->selected) {
         $classes[] = 'phabricator-action-view-selected';
     }
     return phutil_tag('li', array('class' => implode(' ', $classes)), $item);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getApplicationURI('edit/' . $project->getID() . '/');
     $view_uri = $this->getApplicationURI('view/' . $project->getID() . '/');
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new project picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xformer = new PhabricatorImageTransformer();
                 $xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)->setNewValue($new_value);
             $editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($project, $xactions);
             return id(new AphrontRedirectResponse())->setURI($edit_uri);
         }
     }
     $title = pht('Edit Project Picture');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($project->getName(), $view_uri);
     $crumbs->addTextCrumb(pht('Edit'), $edit_uri);
     $crumbs->addTextCrumb(pht('Picture'));
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'project.png');
     $images = array();
     $current = $project->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $launch_id = celerity_generate_unique_node_id();
     $input_id = celerity_generate_unique_node_id();
     Javelin::initBehavior('launch-icon-composer', array('launchID' => $launch_id, 'inputID' => $input_id));
     $compose_button = javelin_tag('button', array('class' => 'grey', 'id' => $launch_id, 'sigil' => 'icon-composer'), pht('Choose Icon and Color...'));
     $compose_input = javelin_tag('input', array('type' => 'hidden', 'id' => $input_id, 'name' => 'phid'));
     $compose_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($compose_input, $compose_button));
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Quick Create'))->setValue($compose_form));
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($edit_uri)->setValue(pht('Upload Picture')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
     return $this->buildApplicationPage(array($crumbs, $form_box, $upload_box), array('title' => $title));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $conpherence = id(new ConpherenceThreadQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$conpherence) {
         return new Aphront404Response();
     }
     $monogram = $conpherence->getMonogram();
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new room picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $xformed->attachToObject($conpherence->getPHID());
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($new_value);
             $editor = id(new ConpherenceEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($conpherence, $xactions);
             return id(new AphrontRedirectResponse())->setURI('/' . $monogram);
         }
     }
     $title = pht('Edit Room Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
     $images = array();
     $current = $conpherence->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->executeOne();
         if ($file) {
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/' . $monogram)->setValue(pht('Upload Picture')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($conpherence->getTitle(), '/' . $monogram);
     $crumbs->addTextCrumb(pht('Room Picture'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Room Picture'))->setHeaderIcon('fa-camera');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $upload_box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($view));
 }
 public function render()
 {
     $caret_id = celerity_generate_unique_node_id();
     $icon = null;
     if ($this->icon) {
         $color = '';
         if ($this->disabled) {
             $color = ' grey';
         }
         $icon = id(new PHUIIconView())->addClass('phabricator-action-view-icon')->setIcon($this->icon . $color);
     }
     if ($this->href) {
         $sigils = array();
         if ($this->workflow) {
             $sigils[] = 'workflow';
         }
         if ($this->download) {
             $sigils[] = 'download';
         }
         if ($this->sigils) {
             $sigils = array_merge($sigils, $this->sigils);
         }
         $sigils = $sigils ? implode(' ', $sigils) : null;
         if ($this->renderAsForm) {
             if (!$this->hasViewer()) {
                 throw new Exception(pht('Call %s when rendering an action as a form.', 'setViewer()'));
             }
             $item = javelin_tag('button', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
             $item = phabricator_form($this->getViewer(), array('action' => $this->getHref(), 'method' => 'POST', 'sigil' => $sigils, 'meta' => $this->metadata), $item);
         } else {
             if ($this->getOpenInNewWindow()) {
                 $target = '_blank';
             } else {
                 $target = null;
             }
             if ($this->submenu) {
                 $caret = javelin_tag('span', array('class' => 'caret-right', 'id' => $caret_id), '');
             } else {
                 $caret = null;
             }
             $item = javelin_tag('a', array('href' => $this->getHref(), 'class' => 'phabricator-action-view-item', 'target' => $target, 'sigil' => $sigils, 'meta' => $this->metadata), array($icon, $this->name, $caret));
         }
     } else {
         $item = phutil_tag('span', array('class' => 'phabricator-action-view-item'), array($icon, $this->name));
     }
     $classes = array();
     $classes[] = 'phabricator-action-view';
     if ($this->disabled) {
         $classes[] = 'phabricator-action-view-disabled';
     }
     if ($this->label) {
         $classes[] = 'phabricator-action-view-label';
     }
     if ($this->selected) {
         $classes[] = 'phabricator-action-view-selected';
     }
     if ($this->submenu) {
         $classes[] = 'phabricator-action-view-submenu';
     }
     $style = array();
     if ($this->hidden) {
         $style[] = 'display: none;';
     }
     if ($this->depth) {
         $indent = $this->depth * 16;
         $style[] = "margin-left: {$indent}px;";
     }
     $sigil = null;
     $meta = null;
     if ($this->submenu) {
         Javelin::initBehavior('phui-submenu');
         $sigil = 'phui-submenu';
         $item_ids = array();
         foreach ($this->submenu as $subitem) {
             $item_ids[] = $subitem->getID();
         }
         $meta = array('itemIDs' => $item_ids, 'caretID' => $caret_id);
     }
     return javelin_tag('li', array('id' => $this->getID(), 'class' => implode(' ', $classes), 'style' => implode(' ', $style), 'sigil' => $sigil, 'meta' => $meta), $item);
 }
 protected function willRenderPage()
 {
     parent::willRenderPage();
     if (!$this->getRequest()) {
         throw new Exception(pht('You must set the %s to render a %s.', 'Request', __CLASS__));
     }
     $console = $this->getConsole();
     require_celerity_resource('phabricator-core-css');
     require_celerity_resource('phabricator-zindex-css');
     require_celerity_resource('phui-button-css');
     require_celerity_resource('phui-spacing-css');
     require_celerity_resource('phui-form-css');
     require_celerity_resource('phabricator-standard-page-view');
     require_celerity_resource('conpherence-durable-column-view');
     require_celerity_resource('font-lato');
     require_celerity_resource('font-roboto-slab');
     Javelin::initBehavior('workflow', array());
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
     }
     if ($user) {
         $default_img_uri = celerity_get_resource_uri('rsrc/image/icon/fatcow/document_black.png');
         $download_form = phabricator_form($user, array('action' => '#', 'method' => 'POST', 'class' => 'lightbox-download-form', 'sigil' => 'download'), phutil_tag('button', array(), pht('Download')));
         Javelin::initBehavior('lightbox-attachments', array('defaultImageUri' => $default_img_uri, 'downloadForm' => $download_form));
     }
     Javelin::initBehavior('aphront-form-disable-on-submit');
     Javelin::initBehavior('toggle-class', array());
     Javelin::initBehavior('history-install');
     Javelin::initBehavior('phabricator-gesture');
     $current_token = null;
     if ($user) {
         $current_token = $user->getCSRFToken();
     }
     Javelin::initBehavior('refresh-csrf', array('tokenName' => AphrontRequest::getCSRFTokenName(), 'header' => AphrontRequest::getCSRFHeaderName(), 'current' => $current_token));
     Javelin::initBehavior('device');
     Javelin::initBehavior('high-security-warning', $this->getHighSecurityWarningConfig());
     if ($console) {
         require_celerity_resource('aphront-dark-console-css');
         $headers = array();
         if (DarkConsoleXHProfPluginAPI::isProfilerStarted()) {
             $headers[DarkConsoleXHProfPluginAPI::getProfilerHeader()] = 'page';
         }
         if (DarkConsoleServicesPlugin::isQueryAnalyzerRequested()) {
             $headers[DarkConsoleServicesPlugin::getQueryAnalyzerHeader()] = true;
         }
         Javelin::initBehavior('dark-console', $this->getConsoleConfig());
         // Change this to initBehavior when there is some behavior to initialize
         require_celerity_resource('javelin-behavior-error-log');
     }
     if ($user) {
         $viewer = $user;
     } else {
         $viewer = new PhabricatorUser();
     }
     $menu = id(new PhabricatorMainMenuView())->setUser($viewer);
     if ($this->getController()) {
         $menu->setController($this->getController());
     }
     if ($this->getApplicationMenu()) {
         $menu->setApplicationMenu($this->getApplicationMenu());
     }
     $this->menuContent = $menu->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $profile_uri = '/p/' . $user->getUsername() . '/';
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new profile picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xformer = new PhabricatorImageTransformer();
                 $xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $user->setProfileImagePHID(null);
             } else {
                 $user->setProfileImagePHID($xformed->getPHID());
                 $xformed->attachToObject($user->getPHID());
             }
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($profile_uri);
         }
     }
     $title = pht('Edit Profile Picture');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($user->getUsername(), $profile_uri);
     $crumbs->addTextCrumb($title);
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
     $images = array();
     $current = $user->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     // Try to add external account images for any associated external accounts.
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($user->getPHID()))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     foreach ($accounts as $account) {
         $file = $account->getProfileImageFile();
         if ($account->getProfileImagePHID() != $file->getPHID()) {
             // This is a default image, just skip it.
             continue;
         }
         $provider = PhabricatorAuthProvider::getEnabledProviderByKey($account->getProviderKey());
         if ($provider) {
             $tip = pht('Picture From %s', $provider->getProviderName());
         } else {
             $tip = pht('Picture From External Account');
         }
         if ($file->isTransformableImage()) {
             $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => $tip);
         }
     }
     // Try to add Gravatar images for any email addresses associated with the
     // account.
     if (PhabricatorEnv::getEnvConfig('security.allow-outbound-http')) {
         $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
         $futures = array();
         foreach ($emails as $email_object) {
             $email = $email_object->getAddress();
             $hash = md5(strtolower(trim($email)));
             $uri = id(new PhutilURI("https://secure.gravatar.com/avatar/{$hash}"))->setQueryParams(array('size' => 200, 'default' => '404', 'rating' => 'x'));
             $futures[$email] = new HTTPSFuture($uri);
         }
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         foreach (Futures($futures) as $email => $future) {
             try {
                 list($body) = $future->resolvex();
                 $file = PhabricatorFile::newFromFileData($body, array('name' => 'profile-gravatar', 'ttl' => 60 * 60 * 4));
                 if ($file->isTransformableImage()) {
                     $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => pht('Gravatar for %s', $email));
                 }
             } catch (Exception $ex) {
                 // Just continue.
             }
         }
         unset($unguarded);
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($profile_uri)->setValue(pht('Upload Picture')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
     return $this->buildApplicationPage(array($crumbs, $form_box, $upload_box), array('title' => $title));
 }
 protected function willRenderPage()
 {
     parent::willRenderPage();
     if (!$this->getRequest()) {
         throw new Exception(pht('You must set the %s to render a %s.', 'Request', __CLASS__));
     }
     $console = $this->getConsole();
     require_celerity_resource('phabricator-core-css');
     require_celerity_resource('phabricator-zindex-css');
     require_celerity_resource('phui-button-css');
     require_celerity_resource('phui-spacing-css');
     require_celerity_resource('phui-form-css');
     require_celerity_resource('phabricator-standard-page-view');
     require_celerity_resource('conpherence-durable-column-view');
     require_celerity_resource('font-lato');
     require_celerity_resource('font-aleo');
     Javelin::initBehavior('workflow', array());
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
     }
     if ($user) {
         if ($user->isUserActivated()) {
             $offset = $user->getTimeZoneOffset();
             $ignore_key = PhabricatorTimezoneIgnoreOffsetSetting::SETTINGKEY;
             $ignore = $user->getUserSetting($ignore_key);
             Javelin::initBehavior('detect-timezone', array('offset' => $offset, 'uri' => '/settings/timezone/', 'message' => pht('Your browser timezone setting differs from the timezone ' . 'setting in your profile, click to reconcile.'), 'ignoreKey' => $ignore_key, 'ignore' => $ignore));
             if ($user->getIsAdmin()) {
                 $server_https = $request->isHTTPS();
                 $server_protocol = $server_https ? 'HTTPS' : 'HTTP';
                 $client_protocol = $server_https ? 'HTTP' : 'HTTPS';
                 $doc_name = 'Configuring a Preamble Script';
                 $doc_href = PhabricatorEnv::getDoclink($doc_name);
                 Javelin::initBehavior('setup-check-https', array('server_https' => $server_https, 'doc_name' => pht('See Documentation'), 'doc_href' => $doc_href, 'message' => pht('Phabricator thinks you are using %s, but your ' . 'client is conviced that it is using %s. This is a serious ' . 'misconfiguration with subtle, but significant, consequences.', $server_protocol, $client_protocol)));
             }
         }
         $default_img_uri = celerity_get_resource_uri('rsrc/image/icon/fatcow/document_black.png');
         $download_form = phabricator_form($user, array('action' => '#', 'method' => 'POST', 'class' => 'lightbox-download-form', 'sigil' => 'download'), phutil_tag('button', array(), pht('Download')));
         Javelin::initBehavior('lightbox-attachments', array('defaultImageUri' => $default_img_uri, 'downloadForm' => $download_form));
     }
     Javelin::initBehavior('aphront-form-disable-on-submit');
     Javelin::initBehavior('toggle-class', array());
     Javelin::initBehavior('history-install');
     Javelin::initBehavior('phabricator-gesture');
     $current_token = null;
     if ($user) {
         $current_token = $user->getCSRFToken();
     }
     Javelin::initBehavior('refresh-csrf', array('tokenName' => AphrontRequest::getCSRFTokenName(), 'header' => AphrontRequest::getCSRFHeaderName(), 'viaHeader' => AphrontRequest::getViaHeaderName(), 'current' => $current_token));
     Javelin::initBehavior('device');
     Javelin::initBehavior('high-security-warning', $this->getHighSecurityWarningConfig());
     if (PhabricatorEnv::isReadOnly()) {
         Javelin::initBehavior('read-only-warning', array('message' => PhabricatorEnv::getReadOnlyMessage(), 'uri' => PhabricatorEnv::getReadOnlyURI()));
     }
     if ($console) {
         require_celerity_resource('aphront-dark-console-css');
         $headers = array();
         if (DarkConsoleXHProfPluginAPI::isProfilerStarted()) {
             $headers[DarkConsoleXHProfPluginAPI::getProfilerHeader()] = 'page';
         }
         if (DarkConsoleServicesPlugin::isQueryAnalyzerRequested()) {
             $headers[DarkConsoleServicesPlugin::getQueryAnalyzerHeader()] = true;
         }
         Javelin::initBehavior('dark-console', $this->getConsoleConfig());
         // Change this to initBehavior when there is some behavior to initialize
         require_celerity_resource('javelin-behavior-error-log');
     }
     if ($user) {
         $viewer = $user;
     } else {
         $viewer = new PhabricatorUser();
     }
     $menu = id(new PhabricatorMainMenuView())->setUser($viewer);
     if ($this->getController()) {
         $menu->setController($this->getController());
     }
     $application_menu = $this->getApplicationMenu();
     if ($application_menu) {
         if ($application_menu instanceof PHUIApplicationMenuView) {
             $crumbs = $this->getCrumbs();
             if ($crumbs) {
                 $application_menu->setCrumbs($crumbs);
             }
             $application_menu = $application_menu->buildListView();
         }
         $menu->setApplicationMenu($application_menu);
     }
     $this->menuContent = $menu->render();
 }
Esempio n. 20
0
 public function render()
 {
     require_celerity_resource('aphront-dialog-view-css');
     $buttons = array();
     if ($this->submitButton) {
         $meta = array();
         if ($this->disableWorkflowOnSubmit) {
             $meta['disableWorkflow'] = true;
         }
         $buttons[] = javelin_tag('button', array('name' => '__submit__', 'sigil' => '__default__', 'type' => 'submit', 'meta' => $meta), $this->submitButton);
     }
     if ($this->cancelURI) {
         $meta = array();
         if ($this->disableWorkflowOnCancel) {
             $meta['disableWorkflow'] = true;
         }
         $buttons[] = javelin_tag('a', array('href' => $this->cancelURI, 'class' => 'button grey', 'name' => '__cancel__', 'sigil' => 'jx-workflow-button', 'meta' => $meta), $this->cancelText);
     }
     if (!$this->user) {
         throw new Exception(pht('You must call %s when rendering an %s.', 'setUser()', __CLASS__));
     }
     $more = $this->class;
     if ($this->flush) {
         $more .= ' aphront-dialog-flush';
     }
     switch ($this->width) {
         case self::WIDTH_FORM:
         case self::WIDTH_FULL:
             $more .= ' aphront-dialog-view-width-' . $this->width;
             break;
         case self::WIDTH_DEFAULT:
             break;
         default:
             throw new Exception(pht("Unknown dialog width '%s'!", $this->width));
     }
     if ($this->isStandalone) {
         $more .= ' aphront-dialog-view-standalone';
     }
     $attributes = array('class' => 'aphront-dialog-view ' . $more, 'sigil' => 'jx-dialog');
     $form_attributes = array('action' => $this->submitURI, 'method' => $this->method, 'id' => $this->formID);
     $hidden_inputs = array();
     $hidden_inputs[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__dialog__', 'value' => '1'));
     foreach ($this->hidden as $desc) {
         list($key, $value) = $desc;
         $hidden_inputs[] = javelin_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value, 'sigil' => 'aphront-dialog-application-input'));
     }
     if (!$this->renderAsForm) {
         $buttons = array(phabricator_form($this->user, $form_attributes, array_merge($hidden_inputs, $buttons)));
     }
     $children = $this->renderChildren();
     $errors = $this->errors;
     $ex = $this->validationException;
     $exception_errors = null;
     if ($ex) {
         foreach ($ex->getErrors() as $error) {
             $errors[] = $error->getMessage();
         }
     }
     if ($errors) {
         $children = array(id(new PHUIInfoView())->setErrors($errors), $children);
     }
     $header = new PHUIHeaderView();
     $header->setHeader($this->title);
     $footer = null;
     if ($this->footers) {
         $footer = phutil_tag('div', array('class' => 'aphront-dialog-foot'), $this->footers);
     }
     $tail = null;
     if ($buttons || $footer) {
         $tail = phutil_tag('div', array('class' => 'aphront-dialog-tail grouped'), array($buttons, $footer));
     }
     $content = array(phutil_tag('div', array('class' => 'aphront-dialog-head'), $header), phutil_tag('div', array('class' => 'aphront-dialog-body phabricator-remarkup grouped'), $children), $tail);
     if ($this->renderAsForm) {
         return phabricator_form($this->user, $form_attributes + $attributes, array($hidden_inputs, $content));
     } else {
         return javelin_tag('div', $attributes, $content);
     }
 }
 private function renderSettingsWidgetPaneContent()
 {
     $viewer = $this->getViewer();
     $conpherence = $this->getConpherence();
     $participant = $conpherence->getParticipantIfExists($viewer->getPHID());
     if (!$participant) {
         $can_join = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_JOIN);
         if ($can_join) {
             $text = pht('Settings are available after joining the room.');
         } else {
             if ($viewer->isLoggedIn()) {
                 $text = pht('Settings not applicable to rooms you can not join.');
             } else {
                 $text = pht('Settings are available after logging in and joining the room.');
             }
         }
         return phutil_tag('div', array('class' => 'no-settings'), $text);
     }
     $default = ConpherenceSettings::EMAIL_ALWAYS;
     $preference = $this->getUserPreferences();
     if ($preference) {
         $default = $preference->getPreference(PhabricatorUserPreferences::PREFERENCE_CONPH_NOTIFICATIONS, ConpherenceSettings::EMAIL_ALWAYS);
     }
     $settings = $participant->getSettings();
     $notifications = idx($settings, 'notifications', $default);
     $options = id(new AphrontFormRadioButtonControl())->addButton(ConpherenceSettings::EMAIL_ALWAYS, ConpherenceSettings::getHumanString(ConpherenceSettings::EMAIL_ALWAYS), '')->addButton(ConpherenceSettings::NOTIFICATIONS_ONLY, ConpherenceSettings::getHumanString(ConpherenceSettings::NOTIFICATIONS_ONLY), '')->setName('notifications')->setValue($notifications);
     $layout = array($options, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => 'notifications')), phutil_tag('button', array('type' => 'submit', 'class' => 'notifications-update'), pht('Save')));
     return phabricator_form($viewer, array('method' => 'POST', 'action' => $this->getWidgetURI(), 'sigil' => 'notifications-update'), $layout);
 }
Esempio n. 22
0
 public function render()
 {
     if (!$this->poll) {
         throw new Exception('Call setPoll() before render()!');
     }
     $poll = $this->poll;
     $phids = array();
     foreach ($poll->getChoices() as $choice) {
         $phids[] = $choice->getAuthorPHID();
     }
     $phids[] = $poll->getAuthorPHID();
     $this->handles = id(new PhabricatorHandleQuery())->setViewer($this->getUser())->withPHIDs($phids)->execute();
     $options = $poll->getOptions();
     if ($poll->getShuffle()) {
         shuffle($options);
     }
     require_celerity_resource('phabricator-slowvote-css');
     require_celerity_resource('javelin-behavior-slowvote-embed');
     $config = array('pollID' => $poll->getID());
     Javelin::initBehavior('slowvote-embed', $config);
     $user_choices = $poll->getViewerChoices($this->getUser());
     $user_choices = mpull($user_choices, 'getOptionID', 'getOptionID');
     $out = array();
     foreach ($options as $option) {
         $is_selected = isset($user_choices[$option->getID()]);
         $out[] = $this->renderLabel($option, $is_selected);
     }
     $link_to_slowvote = phutil_tag('a', array('href' => '/V' . $poll->getID()), $poll->getQuestion());
     if ($this->headless) {
         $header = null;
     } else {
         $header = phutil_tag('div', array('class' => 'slowvote-header'), phutil_tag('div', array('class' => 'slowvote-header-content'), array('V' . $poll->getID(), ' ', $link_to_slowvote)));
         $description = null;
         if ($poll->getDescription()) {
             $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($poll->getDescription()), 'default', $this->getUser());
             $description = phutil_tag('div', array('class' => 'slowvote-description'), $description);
         }
         $header = array($header, $description);
     }
     $vis = $poll->getResponseVisibility();
     if ($this->areResultsVisible()) {
         if ($vis == PhabricatorSlowvotePoll::RESPONSES_OWNER) {
             $quip = pht('Only you can see the results.');
         } else {
             $quip = pht('Voting improves cardiovascular endurance.');
         }
     } else {
         if ($vis == PhabricatorSlowvotePoll::RESPONSES_VOTERS) {
             $quip = pht('You must vote to see the results.');
         } else {
             if ($vis == PhabricatorSlowvotePoll::RESPONSES_OWNER) {
                 $quip = pht('Only the author can see the results.');
             }
         }
     }
     $hint = phutil_tag('span', array('class' => 'slowvote-hint'), $quip);
     if ($poll->getIsClosed()) {
         $submit = null;
     } else {
         $submit = phutil_tag('div', array('class' => 'slowvote-footer'), phutil_tag('div', array('class' => 'slowvote-footer-content'), array($hint, phutil_tag('button', array(), pht('Engage in Deliberations')))));
     }
     $body = phabricator_form($this->getUser(), array('action' => '/vote/' . $poll->getID() . '/', 'method' => 'POST', 'class' => 'slowvote-body'), array(phutil_tag('div', array('class' => 'slowvote-body-content'), $out), $submit));
     return javelin_tag('div', array('class' => 'slowvote-embed', 'sigil' => 'slowvote-embed', 'meta' => array('pollID' => $poll->getID())), array($header, $body));
 }
 protected function willRenderPage()
 {
     parent::willRenderPage();
     if (!$this->getRequest()) {
         throw new Exception(pht('You must set the Request to render a PhabricatorStandardPageView.'));
     }
     $console = $this->getConsole();
     require_celerity_resource('phabricator-core-css');
     require_celerity_resource('phabricator-zindex-css');
     require_celerity_resource('phui-button-css');
     require_celerity_resource('phui-spacing-css');
     require_celerity_resource('phui-form-css');
     require_celerity_resource('sprite-gradient-css');
     require_celerity_resource('phabricator-standard-page-view');
     Javelin::initBehavior('workflow', array());
     $request = $this->getRequest();
     $user = null;
     if ($request) {
         $user = $request->getUser();
     }
     if ($user) {
         $default_img_uri = celerity_get_resource_uri('rsrc/image/icon/fatcow/document_black.png');
         $download_form = phabricator_form($user, array('action' => '#', 'method' => 'POST', 'class' => 'lightbox-download-form', 'sigil' => 'download'), phutil_tag('button', array(), pht('Download')));
         Javelin::initBehavior('lightbox-attachments', array('defaultImageUri' => $default_img_uri, 'downloadForm' => $download_form));
     }
     Javelin::initBehavior('aphront-form-disable-on-submit');
     Javelin::initBehavior('toggle-class', array());
     Javelin::initBehavior('konami', array());
     Javelin::initBehavior('history-install');
     Javelin::initBehavior('phabricator-gesture');
     $current_token = null;
     if ($user) {
         $current_token = $user->getCSRFToken();
     }
     Javelin::initBehavior('refresh-csrf', array('tokenName' => AphrontRequest::getCSRFTokenName(), 'header' => AphrontRequest::getCSRFHeaderName(), 'current' => $current_token));
     Javelin::initBehavior('device');
     if ($user->hasSession()) {
         $hisec = $user->getSession()->getHighSecurityUntil() - time();
         if ($hisec > 0) {
             $remaining_time = phutil_format_relative_time($hisec);
             Javelin::initBehavior('high-security-warning', array('uri' => '/auth/session/downgrade/', 'message' => pht('Your session is in high security mode. When you ' . 'finish using it, click here to leave.', $remaining_time)));
         }
     }
     if ($console) {
         require_celerity_resource('aphront-dark-console-css');
         $headers = array();
         if (DarkConsoleXHProfPluginAPI::isProfilerStarted()) {
             $headers[DarkConsoleXHProfPluginAPI::getProfilerHeader()] = 'page';
         }
         if (DarkConsoleServicesPlugin::isQueryAnalyzerRequested()) {
             $headers[DarkConsoleServicesPlugin::getQueryAnalyzerHeader()] = true;
         }
         Javelin::initBehavior('dark-console', array('uri' => pht('Main Request'), 'selected' => $user ? $user->getConsoleTab() : null, 'visible' => $user ? (int) $user->getConsoleVisible() : true, 'headers' => $headers));
         // Change this to initBehavior when there is some behavior to initialize
         require_celerity_resource('javelin-behavior-error-log');
     }
     if ($user) {
         $viewer = $user;
     } else {
         $viewer = new PhabricatorUser();
     }
     $menu = id(new PhabricatorMainMenuView())->setUser($viewer);
     if ($this->getController()) {
         $menu->setController($this->getController());
     }
     if ($this->getApplicationMenu()) {
         $menu->setApplicationMenu($this->getApplicationMenu());
     }
     $this->menuContent = $menu->render();
 }
 public function renderOneTimePaymentButton(PhortuneAccount $account, PhortuneCart $cart, PhabricatorUser $user)
 {
     require_celerity_resource('phortune-css');
     $icon_uri = $this->getPaymentMethodIcon();
     $description = $this->getPaymentMethodProviderDescription();
     $details = $this->getPaymentMethodDescription();
     $icon = id(new PHUIIconView())->setImage($icon_uri)->addClass('phortune-payment-icon');
     $button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($description)->setSubtext($details);
     $uri = $this->getControllerURI('checkout', array('cartID' => $cart->getID()));
     return phabricator_form($user, array('action' => $uri, 'method' => 'POST'), $button);
 }
 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_tag('option', array('value' => $key, 'selected' => $key == $this->selectedFilter ? 'selected' : null), $label);
     }
     $instructions = null;
     if ($this->instructions) {
         $instructions = phutil_tag('p', array('class' => 'phabricator-object-selector-instructions'), $this->instructions);
     }
     $search_box = phabricator_form($user, array('method' => 'POST', 'action' => $this->submitURI, 'id' => $search_id), phutil_tag('table', array('class' => 'phabricator-object-selector-search'), phutil_tag('tr', array(), array(phutil_tag('td', array('class' => 'phabricator-object-selector-search-filter'), phutil_tag('select', array('id' => $filter_id), $options)), phutil_tag('td', array('class' => 'phabricator-object-selector-search-text'), phutil_tag('input', array('id' => $query_id, 'type' => 'text')))))));
     $result_box = phutil_tag('div', array('class' => 'phabricator-object-selector-results', 'id' => $results_id), '');
     $attached_box = phutil_tag_div('phabricator-object-selector-current', phutil_tag_div('phabricator-object-selector-currently-attached', array(phutil_tag_div('phabricator-object-selector-header', $this->header), phutil_tag('div', array('id' => $current_id)), $instructions)));
     $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;
 }
 public function render()
 {
     require_celerity_resource('phui-form-view-css');
     $layout = $this->buildLayoutView();
     if (!$this->hasViewer()) {
         throw new Exception(pht('You must pass the user to %s.', __CLASS__));
     }
     $sigils = $this->sigils;
     if ($this->workflow) {
         $sigils[] = 'workflow';
     }
     return phabricator_form($this->getViewer(), array('class' => implode(' ', $this->classes), 'action' => $this->action, 'method' => $this->method, 'enctype' => $this->encType, 'sigil' => $sigils ? implode(' ', $sigils) : null, 'meta' => $this->metadata, 'id' => $this->id), $layout->render());
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $this->setUser($user);
     $done_uri = $this->getApplicationURI("manage/{$id}/");
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new profile picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $user->setProfileImagePHID(null);
             } else {
                 $user->setProfileImagePHID($xformed->getPHID());
                 $xformed->attachToObject($user->getPHID());
             }
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($done_uri);
         }
     }
     $title = pht('Edit Profile Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
     $images = array();
     $current = $user->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $builtins = array('user1.png', 'user2.png', 'user3.png', 'user4.png', 'user5.png', 'user6.png', 'user7.png', 'user8.png', 'user9.png');
     foreach ($builtins as $builtin) {
         $file = PhabricatorFile::loadBuiltin($viewer, $builtin);
         $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => pht('Builtin Image'));
     }
     // Try to add external account images for any associated external accounts.
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($user->getPHID()))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     foreach ($accounts as $account) {
         $file = $account->getProfileImageFile();
         if ($account->getProfileImagePHID() != $file->getPHID()) {
             // This is a default image, just skip it.
             continue;
         }
         $provider = PhabricatorAuthProvider::getEnabledProviderByKey($account->getProviderKey());
         if ($provider) {
             $tip = pht('Picture From %s', $provider->getProviderName());
         } else {
             $tip = pht('Picture From External Account');
         }
         if ($file->isTransformableImage()) {
             $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => $tip);
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($done_uri)->setValue(pht('Upload Picture')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Edit Profile Picture'));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($form_box, $upload_box));
 }
 private function buildTextInput()
 {
     $conpherence = $this->getSelectedConpherence();
     if (!$conpherence) {
         return null;
     }
     $draft = $this->getDraft();
     $draft_value = null;
     if ($draft) {
         $draft_value = $draft->getDraft();
     }
     $textarea_id = celerity_generate_unique_node_id();
     $textarea = javelin_tag('textarea', array('id' => $textarea_id, 'name' => 'text', 'class' => 'conpherence-durable-column-textarea', 'sigil' => 'conpherence-durable-column-textarea', 'placeholder' => pht('Send a message...')), $draft_value);
     Javelin::initBehavior('aphront-drag-and-drop-textarea', array('target' => $textarea_id, 'activatedClass' => 'aphront-textarea-drag-and-drop', 'uri' => '/file/dropupload/'));
     $id = $conpherence->getID();
     return phabricator_form($this->getUser(), array('method' => 'POST', 'action' => '/conpherence/update/' . $id . '/', 'sigil' => 'conpherence-message-form'), array($textarea, phutil_tag('input', array('type' => 'hidden', 'name' => 'action', 'value' => ConpherenceUpdateActions::MESSAGE))));
 }
 public function renderOneTimePaymentButton(PhortuneAccount $account, PhortuneCart $cart, PhabricatorUser $user)
 {
     require_celerity_resource('phortune-css');
     $description = $this->getPaymentMethodProviderDescription();
     $details = $this->getPaymentMethodDescription();
     $icon = id(new PHUIIconView())->setSpriteSheet(PHUIIconView::SPRITE_LOGIN)->setSpriteIcon($this->getPaymentMethodIcon());
     $button = id(new PHUIButtonView())->setSize(PHUIButtonView::BIG)->setColor(PHUIButtonView::GREY)->setIcon($icon)->setText($description)->setSubtext($details);
     // NOTE: We generate a local URI to make sure the form picks up CSRF tokens.
     $uri = $this->getControllerURI('checkout', array('cartID' => $cart->getID()), $local = true);
     return phabricator_form($user, array('action' => $uri, 'method' => 'POST'), $button);
 }
 private function renderDefaultForm(PhabricatorProject $project)
 {
     $viewer = $this->getViewer();
     $compose_color = $project->getDisplayIconComposeColor();
     $compose_icon = $project->getDisplayIconComposeIcon();
     $default_builtin = id(new PhabricatorFilesComposeIconBuiltinFile())->setColor($compose_color)->setIcon($compose_icon);
     $file_builtins = PhabricatorFile::loadBuiltins($viewer, array($default_builtin));
     $file_builtin = head($file_builtins);
     $default_button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Use Icon and Color'), 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $file_builtin->getBestURI())));
     $inputs = array('projectPHID' => $project->getPHID(), 'icon' => $compose_icon, 'color' => $compose_color);
     foreach ($inputs as $key => $value) {
         $inputs[$key] = javelin_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     $default_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST', 'action' => '/file/compose/'), array($inputs, $default_button));
     return $default_form;
 }