コード例 #1
0
 public function render()
 {
     $content = $this->renderChildren();
     if (!$content) {
         return null;
     }
     require_celerity_resource('aphront-list-filter-view-css');
     $content = phutil_tag('div', array('class' => 'aphront-list-filter-view-content'), $content);
     $classes = array();
     $classes[] = 'aphront-list-filter-view';
     if ($this->showAction !== null) {
         $classes[] = 'aphront-list-filter-view-collapsible';
         Javelin::initBehavior('phabricator-reveal-content');
         $hide_action_id = celerity_generate_unique_node_id();
         $show_action_id = celerity_generate_unique_node_id();
         $content_id = celerity_generate_unique_node_id();
         $hide_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'id' => $hide_action_id, 'href' => $this->showHideHref, 'meta' => array('hideIDs' => array($hide_action_id), 'showIDs' => array($content_id, $show_action_id))), $this->showAction);
         $content_description = phutil_tag('div', array('class' => 'aphront-list-filter-description'), $this->showHideDescription);
         $show_action = javelin_tag('a', array('class' => 'button grey', 'sigil' => 'reveal-content', 'style' => 'display: none;', 'href' => '#', 'id' => $show_action_id, 'meta' => array('hideIDs' => array($content_id, $show_action_id), 'showIDs' => array($hide_action_id))), $this->hideAction);
         $reveal_block = phutil_tag('div', array('class' => 'aphront-list-filter-reveal'), array($content_description, $hide_action, $show_action));
         $content = array($reveal_block, phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), $content));
     }
     $content = phutil_tag('div', array('class' => implode(' ', $classes)), $content);
     return phutil_tag('div', array('class' => 'aphront-list-filter-wrap'), $content);
 }
 public function getTokensForTask($task)
 {
     $tokens_given = id(new PhabricatorTokenGivenQuery())->setViewer($this->viewer)->withObjectPHIDs(array($task->getPHID()))->execute();
     if (!$tokens_given) {
         return null;
     }
     $tokens = id(new PhabricatorTokenQuery())->setViewer($this->viewer)->withPHIDs(mpull($tokens_given, 'getTokenPHID'))->execute();
     $tokens = mpull($tokens, null, 'getPHID');
     $author_phids = mpull($tokens_given, 'getAuthorPHID');
     $handles = id(new PhabricatorHandleQuery())->setViewer($this->viewer)->withPHIDs($author_phids)->execute();
     Javelin::initBehavior('phabricator-tooltips');
     $list = array();
     foreach ($tokens_given as $token_given) {
         if (!idx($tokens, $token_given->getTokenPHID())) {
             continue;
         }
         $token = $tokens[$token_given->getTokenPHID()];
         $aural = javelin_tag('span', array('aural' => true), pht('"%s" token, awarded by %s.', $token->getName(), $handles[$token_given->getAuthorPHID()]->getName()));
         $tokenslabel = 'Tokens:';
         $tokensvalue = phutil_tag('dd', array('class' => 'phui-card-list-value'), array($token->renderIcon(), ' '));
         $tokenskey = phutil_tag('dt', array('class' => 'phui-card-list-key'), array($tokenslabel, ' '));
         $list[] = javelin_tag('dl', array('sigil' => 'has-tooltip', 'class' => 'token-icon', 'meta' => array('tip' => $handles[$token_given->getAuthorPHID()]->getName())), array($aural, $tokenskey, $tokensvalue));
     }
     return $list;
 }
コード例 #3
0
ファイル: markup.php プロジェクト: pugong/phabricator
function phabricator_form(PhabricatorUser $user, $attributes, $content)
{
    $body = array();
    $http_method = idx($attributes, 'method');
    $is_post = strcasecmp($http_method, 'POST') === 0;
    $http_action = idx($attributes, 'action');
    $is_absolute_uri = preg_match('#^(https?:|//)#', $http_action);
    if ($is_post) {
        // NOTE: We only include CSRF tokens if a URI is a local URI on the same
        // domain. This is an important security feature and prevents forms which
        // submit to foreign sites from leaking CSRF tokens.
        // In some cases, we may construct a fully-qualified local URI. For example,
        // we can construct these for download links, depending on configuration.
        // These forms do not receive CSRF tokens, even though they safely could.
        // This can be confusing, if you're developing for Phabricator and
        // manage to construct a local form with a fully-qualified URI, since it
        // won't get CSRF tokens and you'll get an exception at the other end of
        // the request which is a bit disconnected from the actual root cause.
        // However, this is rare, and there are reasonable cases where this
        // construction occurs legitimately, and the simplest fix is to omit CSRF
        // tokens for these URIs in all cases. The error message you receive also
        // gives you some hints as to this potential source of error.
        if (!$is_absolute_uri) {
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken()));
            $body[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true));
        }
    }
    if (is_array($content)) {
        $body = array_merge($body, $content);
    } else {
        $body[] = $content;
    }
    return javelin_tag('form', $attributes, $body);
}
コード例 #4
0
 public function render()
 {
     $rows = array();
     $any_hidden = false;
     foreach ($this->rows as $row) {
         $style = idx($row, 'style');
         switch ($style) {
             case 'section':
                 $cells = phutil_tag('th', array('colspan' => 2), idx($row, 'name'));
                 break;
             default:
                 $name = phutil_tag('th', array(), idx($row, 'name'));
                 $value = phutil_tag('td', array(), idx($row, 'value'));
                 $cells = array($name, $value);
                 break;
         }
         $show = idx($row, 'show');
         $rows[] = javelin_tag('tr', array('style' => $show ? null : 'display: none', 'sigil' => $show ? null : 'differential-results-row-toggle', 'class' => 'differential-results-row-' . $style), $cells);
         if (!$show) {
             $any_hidden = true;
         }
     }
     if ($any_hidden) {
         $show_more = javelin_tag('a', array('href' => '#', 'mustcapture' => true), $this->showMoreString);
         $hide_more = javelin_tag('a', array('href' => '#', 'mustcapture' => true), 'Hide');
         $rows[] = javelin_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-show'), phutil_tag('th', array('colspan' => 2), $show_more));
         $rows[] = javelin_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-hide', 'style' => 'display: none'), phutil_tag('th', array('colspan' => 2), $hide_more));
         $this->initBehavior('differential-show-field-details');
     }
     $this->requireResource('differential-results-table-css');
     return javelin_tag('table', array('class' => 'differential-results-table', 'sigil' => 'differential-results-table'), $rows);
 }
コード例 #5
0
 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() . '/');
     require_celerity_resource('project-icon-css');
     Javelin::initBehavior('phabricator-tooltips');
     $project_icons = PhabricatorProjectIcon::getIconMap();
     if ($request->isFormPost()) {
         $v_icon = $request->getStr('icon');
         return id(new AphrontAjaxResponse())->setContent(array('value' => $v_icon, 'display' => PhabricatorProjectIcon::renderIconForChooser($v_icon)));
     }
     $ii = 0;
     $buttons = array();
     foreach ($project_icons as $icon => $label) {
         $view = id(new PHUIIconView())->setIconFont($icon);
         $aural = javelin_tag('span', array('aural' => true), pht('Choose "%s" Icon', $label));
         if ($icon == $project->getIcon()) {
             $class_extra = ' selected';
         } else {
             $class_extra = null;
         }
         $buttons[] = javelin_tag('button', array('class' => 'icon-button' . $class_extra, 'name' => 'icon', 'value' => $icon, 'type' => 'submit', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $label)), array($aural, $view));
         if (++$ii % 4 == 0) {
             $buttons[] = phutil_tag('br');
         }
     }
     $buttons = phutil_tag('div', array('class' => 'icon-grid'), $buttons);
     return $this->newDialog()->setTitle(pht('Choose Project Icon'))->appendChild($buttons)->addCancelButton($edit_uri);
 }
コード例 #6
0
 public function render()
 {
     $classes = array('phui-crumb-view');
     $aural = null;
     if ($this->aural !== null) {
         $aural = javelin_tag('span', array('aural' => true), $this->aural);
     }
     $icon = null;
     if ($this->icon) {
         $classes[] = 'phui-crumb-has-icon';
         $icon = id(new PHUIIconView())->setIcon($this->icon);
     }
     // Surround the crumb name with spaces so that double clicking it only
     // selects the crumb itself.
     $name = array(' ', $this->name, ' ');
     $name = phutil_tag('span', array('class' => 'phui-crumb-name'), $name);
     $divider = null;
     if (!$this->isLastCrumb) {
         $divider = id(new PHUIIconView())->setIcon('fa-angle-right')->addClass('phui-crumb-divider')->addClass('phui-crumb-view');
     } else {
         $classes[] = 'phabricator-last-crumb';
     }
     $tag = javelin_tag($this->href ? 'a' : 'span', array('sigil' => $this->workflow ? 'workflow' : null, 'href' => $this->href, 'class' => implode(' ', $classes)), array($aural, $icon, $name));
     return array($tag, $divider);
 }
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $preferences = $this->getPreferences();
     $notifications_key = PhabricatorDesktopNotificationsSetting::SETTINGKEY;
     $notifications_value = $preferences->getSettingValue($notifications_key);
     if ($request->isFormPost()) {
         $this->writeSetting($preferences, $notifications_key, $request->getInt($notifications_key));
         return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
     }
     $title = pht('Desktop Notifications');
     $control_id = celerity_generate_unique_node_id();
     $status_id = celerity_generate_unique_node_id();
     $browser_status_id = celerity_generate_unique_node_id();
     $cancel_ask = pht('The dialog asking for permission to send desktop notifications was ' . 'closed without granting permission. Only application notifications ' . 'will be sent.');
     $accept_ask = pht('Click "Save Preference" to persist these changes.');
     $reject_ask = pht('Permission for desktop notifications was denied. Only application ' . 'notifications will be sent.');
     $no_support = pht('This web browser does not support desktop notifications. Only ' . 'application notifications will be sent for this browser regardless of ' . 'this preference.');
     $default_status = phutil_tag('span', array(), array(pht('This browser has not yet granted permission to send desktop ' . 'notifications for this Phabricator instance.'), phutil_tag('br'), phutil_tag('br'), javelin_tag('button', array('sigil' => 'desktop-notifications-permission-button', 'class' => 'green'), pht('Grant Permission'))));
     $granted_status = phutil_tag('span', array(), pht('This browser has been granted permission to send desktop ' . 'notifications for this Phabricator instance.'));
     $denied_status = phutil_tag('span', array(), pht('This browser has denied permission to send desktop notifications ' . 'for this Phabricator instance. Consult your browser settings / ' . 'documentation to figure out how to clear this setting, do so, ' . 'and then re-visit this page to grant permission.'));
     $status_box = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setID($status_id)->setIsHidden(true)->appendChild($accept_ask);
     $control_config = array('controlID' => $control_id, 'statusID' => $status_id, 'browserStatusID' => $browser_status_id, 'defaultMode' => 0, 'desktopMode' => 1, 'cancelAsk' => $cancel_ask, 'grantedAsk' => $accept_ask, 'deniedAsk' => $reject_ask, 'defaultStatus' => $default_status, 'deniedStatus' => $denied_status, 'grantedStatus' => $granted_status, 'noSupport' => $no_support);
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormSelectControl())->setLabel($title)->setControlID($control_id)->setName($notifications_key)->setValue($notifications_value)->setOptions(array(1 => pht('Send Desktop Notifications Too'), 0 => pht('Send Application Notifications Only')))->setCaption(pht('Should Phabricator send desktop notifications? These are sent ' . 'in addition to the notifications within the Phabricator ' . 'application.'))->initBehavior('desktop-notifications-control', $control_config))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Preference')));
     $test_button = id(new PHUIButtonView())->setTag('a')->setWorkflow(true)->setText(pht('Send Test Notification'))->setHref('/notification/test/')->setIcon('fa-exclamation-triangle');
     $form_box = id(new PHUIObjectBoxView())->setHeader(id(new PHUIHeaderView())->setHeader(pht('Desktop Notifications'))->addActionLink($test_button))->setForm($form)->setInfoView($status_box)->setFormSaved($request->getBool('saved'));
     $browser_status_box = id(new PHUIInfoView())->setID($browser_status_id)->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setIsHidden(true)->appendChild($default_status);
     return array($form_box, $browser_status_box);
 }
コード例 #8
0
 public function renderPropertyViewValue(array $handles)
 {
     $requested_object = $this->getObject()->getRequestedObject();
     if (!$requested_object instanceof DifferentialRevision) {
         return null;
     }
     $diff_rev = $requested_object;
     $diffs = $diff_rev->loadRelatives(new DifferentialDiff(), 'revisionID', 'getID', 'creationMethod <> "commit"');
     $all_changesets = array();
     $most_recent_changesets = null;
     foreach ($diffs as $diff) {
         $changesets = $diff->loadRelatives(new DifferentialChangeset(), 'diffID');
         $all_changesets += $changesets;
         $most_recent_changesets = $changesets;
     }
     // The score is based on all changesets for all versions of this diff
     $all_changes = $this->countLinesAndPaths($all_changesets);
     $points = self::LINES_WEIGHT * $all_changes['code']['lines'] + self::PATHS_WEIGHT * count($all_changes['code']['paths']);
     // The blurb is just based on the most recent version of the diff
     $mr_changes = $this->countLinesAndPaths($most_recent_changesets);
     $test_tag = '';
     if ($mr_changes['tests']['paths']) {
         Javelin::initBehavior('phabricator-tooltips');
         require_celerity_resource('aphront-tooltip-css');
         $test_blurb = pht('%d line(s)', $mr_changes['tests']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['tests']['paths'])) . " contain changes to test code:\n";
         foreach ($mr_changes['tests']['paths'] as $mr_test_path) {
             $test_blurb .= pht("%s\n", $mr_test_path);
         }
         $test_tag = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $test_blurb, 'align' => 'E', 'size' => 'auto'), 'style' => ''), ' + tests');
     }
     $blurb = hsprintf('%s%s.', pht('%d line(s)', $mr_changes['code']['lines']) . ' and ' . pht('%d path(s)', count($mr_changes['code']['paths'])) . ' over ' . pht('%d diff(s)', count($diffs)), $test_tag);
     return id(new AphrontProgressBarView())->setValue($points)->setMax(self::MAX_POINTS)->setCaption($blurb)->render();
 }
コード例 #9
0
 public function render()
 {
     $question = $this->question;
     $viewer = $this->user;
     $authors = mpull($question->getAnswers(), null, 'getAuthorPHID');
     if (isset($authors[$viewer->getPHID()])) {
         return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->setTitle(pht('Already Answered'))->appendChild(pht('You have already answered this question. You can not answer ' . 'twice, but you can edit your existing answer.'));
     }
     $info_panel = null;
     if ($question->getStatus() != PonderQuestionStatus::STATUS_OPEN) {
         $info_panel = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NOTICE)->appendChild(pht('This question has been marked as closed,
          but you can still leave a new answer.'));
     }
     $box_style = null;
     $own_question = null;
     $hide_action_id = celerity_generate_unique_node_id();
     $show_action_id = celerity_generate_unique_node_id();
     if ($question->getAuthorPHID() == $viewer->getPHID()) {
         $box_style = 'display: none;';
         $open_link = javelin_tag('a', array('sigil' => 'reveal-content', 'class' => 'mml', 'id' => $hide_action_id, 'href' => '#', 'meta' => array('showIDs' => array($show_action_id), 'hideIDs' => array($hide_action_id))), pht('Add an answer.'));
         $own_question = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_WARNING)->setID($hide_action_id)->appendChild(pht('This is your own question. You are welcome to provide
         an answer if you have found a resolution.'))->appendChild($open_link);
     }
     $header = id(new PHUIHeaderView())->setHeader(pht('Add Answer'));
     $form = new AphrontFormView();
     $form->setUser($this->user)->setAction($this->actionURI)->setWorkflow(true)->addHiddenInput('question_id', $question->getID())->appendChild(id(new PhabricatorRemarkupControl())->setName('answer')->setLabel(pht('Answer'))->setError(true)->setID('answer-content')->setUser($this->user))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Add Answer')));
     $box = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($form);
     if ($info_panel) {
         $box->setInfoView($info_panel);
     }
     $box = phutil_tag('div', array('style' => $box_style, 'class' => 'mlt', 'id' => $show_action_id), $box);
     return array($own_question, $box);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $engine = new PhabricatorSetupEngine();
     $response = $engine->execute();
     if ($response) {
         return $response;
     }
     $issues = $engine->getIssues();
     $unresolved_count = count($engine->getUnresolvedIssues());
     if ($issues) {
         require_celerity_resource('phabricator-notification-menu-css');
         $items = array();
         foreach ($issues as $issue) {
             $classes = array();
             $classes[] = 'phabricator-notification';
             if ($issue->getIsIgnored()) {
                 $classes[] = 'phabricator-notification-read';
             } else {
                 $classes[] = 'phabricator-notification-unread';
             }
             $uri = '/config/issue/' . $issue->getIssueKey() . '/';
             $title = $issue->getName();
             $summary = $issue->getSummary();
             $items[] = javelin_tag('div', array('class' => implode(' ', $classes), 'sigil' => 'notification', 'meta' => array('href' => $uri)), $title);
         }
         $content = phutil_tag_div('setup-issue-menu', $items);
     } else {
         $content = phutil_tag_div('phabricator-notification no-notifications', pht('You have no unresolved setup issues.'));
     }
     $content = hsprintf('<div class="phabricator-notification-header">%s</div>' . '%s', phutil_tag('a', array('href' => '/config/issue/'), pht('Unresolved Setup Issues')), $content);
     $json = array('content' => $content, 'number' => (int) $unresolved_count);
     return id(new AphrontAjaxResponse())->setContent($json);
 }
コード例 #11
0
 public function render()
 {
     $conpherence = $this->getConpherence();
     $widget_data = $conpherence->getWidgetData();
     $viewer = $this->getUser();
     $participants = $conpherence->getParticipants();
     $handles = $conpherence->getHandles();
     $head_handles = array_select_keys($handles, array($viewer->getPHID()));
     $handle_list = mpull($handles, 'getName');
     natcasesort($handle_list);
     $handles = mpull($handles, null, 'getName');
     $handles = array_select_keys($handles, $handle_list);
     $head_handles = mpull($head_handles, null, 'getName');
     $handles = $head_handles + $handles;
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
     $body = array();
     foreach ($handles as $handle) {
         $user_phid = $handle->getPHID();
         if ($user_phid == $viewer->getPHID() || $can_edit) {
             $icon = id(new PHUIIconView())->setIcon('fa-times lightbluetext');
             $remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon);
         } else {
             $remove_html = null;
         }
         $body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html));
     }
     return $body;
 }
コード例 #12
0
 public function render()
 {
     $conpherence = $this->conpherence;
     $viewer = $this->getViewer();
     $participants = $conpherence->getParticipants();
     $count = new PhutilNumber(count($participants));
     $handles = $conpherence->getHandles();
     $handles = array_intersect_key($handles, $participants);
     $head_handles = array_select_keys($handles, array($viewer->getPHID()));
     $handle_list = mpull($handles, 'getName');
     natcasesort($handle_list);
     $handles = mpull($handles, null, 'getName');
     $handles = array_select_keys($handles, $handle_list);
     $head_handles = mpull($head_handles, null, 'getName');
     $handles = $head_handles + $handles;
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT);
     $body = array();
     foreach ($handles as $handle) {
         $user_phid = $handle->getPHID();
         if ($user_phid == $viewer->getPHID() || $can_edit) {
             $icon = id(new PHUIIconView())->setIcon('fa-times')->addClass('lightbluetext');
             $remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon);
         } else {
             $remove_html = null;
         }
         $body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html));
     }
     $new_icon = id(new PHUIIconView())->setIcon('fa-plus-square')->setHref($this->updateURI)->setMetadata(array('widget' => null))->addSigil('conpherence-widget-adder');
     $header = id(new PHUIHeaderView())->setHeader(pht('Participants (%d)', $count))->addClass('widgets-header')->addActionItem($new_icon);
     $content = javelin_tag('div', array('class' => 'widgets-body', 'id' => 'widgets-people', 'sigil' => 'widgets-people'), array($header, $body));
     return $content;
 }
コード例 #13
0
 private function buildPropertyView(PhameBlog $blog)
 {
     $viewer = $this->getViewer();
     require_celerity_resource('aphront-tooltip-css');
     Javelin::initBehavior('phabricator-tooltips');
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog);
     $domain = $blog->getDomain();
     if (!$domain) {
         $domain = phutil_tag('em', array(), pht('No external domain'));
     }
     $properties->addProperty(pht('Domain'), $domain);
     $feed_uri = PhabricatorEnv::getProductionURI($this->getApplicationURI('blog/feed/' . $blog->getID() . '/'));
     $properties->addProperty(pht('Atom URI'), javelin_tag('a', array('href' => $feed_uri, 'sigil' => 'has-tooltip', 'meta' => array('tip' => pht('Atom URI does not support custom domains.'), 'size' => 320)), $feed_uri));
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $blog);
     $properties->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
     $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer)->addObject($blog, PhameBlog::MARKUP_FIELD_DESCRIPTION)->process();
     $properties->invokeWillRenderEvent();
     $description = $blog->getDescription();
     if (strlen($description)) {
         $description = new PHUIRemarkupView($viewer, $description);
         $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent($description);
     }
     return $properties;
 }
コード例 #14
0
 protected function processDiffusionRequest(AphrontRequest $request)
 {
     $user = $request->getUser();
     $drequest = $this->getDiffusionRequest();
     $callsign = $drequest->getRepository()->getCallsign();
     $repository = $drequest->getRepository();
     $commit = $drequest->loadCommit();
     $data = $commit->loadCommitData();
     $page_title = pht('Edit Diffusion Commit');
     if (!$commit) {
         return new Aphront404Response();
     }
     $commit_phid = $commit->getPHID();
     $edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST;
     $current_proj_phids = PhabricatorEdgeQuery::loadDestinationPHIDs($commit_phid, $edge_type);
     if ($request->isFormPost()) {
         $xactions = array();
         $proj_phids = $request->getArr('projects');
         $xactions[] = id(new PhabricatorAuditTransaction())->setTransactionType(PhabricatorTransactions::TYPE_EDGE)->setMetadataValue('edge:type', $edge_type)->setNewValue(array('=' => array_fuse($proj_phids)));
         $editor = id(new PhabricatorAuditEditor())->setActor($user)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
         $xactions = $editor->applyTransactions($commit, $xactions);
         return id(new AphrontRedirectResponse())->setURI('/r' . $callsign . $commit->getCommitIdentifier());
     }
     $tokenizer_id = celerity_generate_unique_node_id();
     $form = id(new AphrontFormView())->setUser($user)->setAction($request->getRequestURI()->getPath())->appendControl(id(new AphrontFormTokenizerControl())->setLabel(pht('Projects'))->setName('projects')->setValue($current_proj_phids)->setID($tokenizer_id)->setCaption(javelin_tag('a', array('href' => '/project/create/', 'mustcapture' => true, 'sigil' => 'project-create'), pht('Create New Project')))->setDatasource(new PhabricatorProjectDatasource()));
     $reason = $data->getCommitDetail('autocloseReason', false);
     $reason = PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED;
     if ($reason !== false) {
         switch ($reason) {
             case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING:
                 $desc = pht('No, Repository Importing');
                 break;
             case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED:
                 $desc = pht('No, Autoclose Disabled');
                 break;
             case PhabricatorRepository::BECAUSE_NOT_ON_AUTOCLOSE_BRANCH:
                 $desc = pht('No, Not On Autoclose Branch');
                 break;
             case PhabricatorRepository::BECAUSE_AUTOCLOSE_FORCED:
                 $desc = pht('Yes, Forced Via bin/repository CLI Tool.');
                 break;
             case null:
                 $desc = pht('Yes');
                 break;
             default:
                 $desc = pht('Unknown');
                 break;
         }
         $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose');
         $doc_link = phutil_tag('a', array('href' => $doc_href, 'target' => '_blank'), pht('Learn More'));
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Autoclose?'))->setValue(array($desc, " · ", $doc_link)));
     }
     Javelin::initBehavior('project-create', array('tokenizerID' => $tokenizer_id));
     $submit = id(new AphrontFormSubmitControl())->setValue(pht('Save'))->addCancelButton('/r' . $callsign . $commit->getCommitIdentifier());
     $form->appendChild($submit);
     $crumbs = $this->buildCrumbs(array('commit' => true));
     $crumbs->addTextCrumb(pht('Edit'));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($page_title)->setForm($form);
     return $this->buildApplicationPage(array($crumbs, $form_box), array('title' => $page_title));
 }
コード例 #15
0
 public function render()
 {
     require_celerity_resource('sprite-docs-css');
     $conpherence = $this->getConpherence();
     $widget_data = $conpherence->getWidgetData();
     $files = $widget_data['files'];
     $files_authors = $widget_data['files_authors'];
     $files_html = array();
     foreach ($files as $file) {
         $icon_class = $file->getDisplayIconForMimeType();
         $icon_view = phutil_tag('div', array('class' => 'file-icon sprite-docs ' . $icon_class), '');
         $file_view = id(new PhabricatorFileLinkView())->setFilePHID($file->getPHID())->setFileName(id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(28)->truncateString($file->getName()))->setFileViewable($file->isViewableImage())->setFileViewURI($file->getBestURI())->setCustomClass('file-title');
         $who_done_it_text = '';
         // system generated files don't have authors
         if ($file->getAuthorPHID()) {
             $who_done_it_text = pht('By %s ', $files_authors[$file->getPHID()]->renderLink());
         }
         $date_text = phabricator_relative_date($file->getDateCreated(), $this->getUser());
         $who_done_it = phutil_tag('div', array('class' => 'file-uploaded-by'), pht('%s%s.', $who_done_it_text, $date_text));
         $files_html[] = phutil_tag('div', array('class' => 'file-entry'), array($icon_view, $file_view, $who_done_it));
     }
     if (empty($files)) {
         $files_html[] = javelin_tag('div', array('class' => 'no-files', 'sigil' => 'no-files'), pht('No files.'));
     }
     return phutil_tag('div', array('class' => 'file-list'), $files_html);
 }
コード例 #16
0
 public function processRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $tokens = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($viewer)->withObjectPHIDs(array($viewer->getPHID()))->execute();
     $rows = array();
     foreach ($tokens as $token) {
         if ($token->isRevocable()) {
             $button = javelin_tag('a', array('href' => '/auth/token/revoke/' . $token->getID() . '/', 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Revoke'));
         } else {
             $button = javelin_tag('a', array('class' => 'small grey button disabled'), pht('Revoke'));
         }
         if ($token->getTokenExpires() >= time()) {
             $expiry = phabricator_datetime($token->getTokenExpires(), $viewer);
         } else {
             $expiry = pht('Expired');
         }
         $rows[] = array($token->getTokenReadableTypeName(), $expiry, $button);
     }
     $table = new AphrontTableView($rows);
     $table->setNoDataString(pht("You don't have any active tokens."));
     $table->setHeaders(array(pht('Type'), pht('Expires'), pht('')));
     $table->setColumnClasses(array('wide', 'right', 'action'));
     $terminate_button = id(new PHUIButtonView())->setText(pht('Revoke All'))->setHref('/auth/token/revoke/all/')->setTag('a')->setWorkflow(true)->setIcon('fa-exclamation-triangle');
     $header = id(new PHUIHeaderView())->setHeader(pht('Temporary Tokens'))->addActionLink($terminate_button);
     $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
     return $panel;
 }
コード例 #17
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $query = id(new PhabricatorNotificationQuery())->setViewer($user)->withUserPHIDs(array($user->getPHID()))->setLimit(15);
     $stories = $query->execute();
     $clear_ui_class = 'phabricator-notification-clear-all';
     $clear_uri = id(new PhutilURI('/notification/clear/'));
     if ($stories) {
         $builder = new PhabricatorNotificationBuilder($stories);
         $notifications_view = $builder->buildView();
         $content = $notifications_view->render();
         $clear_uri->setQueryParam('chronoKey', head($stories)->getChronologicalKey());
     } else {
         $content = phutil_tag_div('phabricator-notification no-notifications', pht('You have no notifications.'));
         $clear_ui_class .= ' disabled';
     }
     $clear_ui = javelin_tag('a', array('sigil' => 'workflow', 'href' => (string) $clear_uri, 'class' => $clear_ui_class), pht('Mark All Read'));
     $notifications_link = phutil_tag('a', array('href' => '/notification/'), pht('Notifications'));
     if (PhabricatorEnv::getEnvConfig('notification.enabled')) {
         $connection_status = new PhabricatorNotificationStatusView();
     } else {
         $connection_status = phutil_tag('a', array('href' => PhabricatorEnv::getDoclink('Notifications User Guide: Setup and Configuration')), pht('Notification Server not enabled.'));
     }
     $connection_ui = phutil_tag('div', array('class' => 'phabricator-notification-footer'), $connection_status);
     $header = phutil_tag('div', array('class' => 'phabricator-notification-header'), array($notifications_link, $clear_ui));
     $content = hsprintf('%s%s%s', $header, $content, $connection_ui);
     $unread_count = id(new PhabricatorFeedStoryNotification())->countUnread($user);
     $json = array('content' => $content, 'number' => (int) $unread_count);
     return id(new AphrontAjaxResponse())->setContent($json);
 }
コード例 #18
0
 public function render()
 {
     $this->requireResource('differential-core-view-css');
     $this->requireResource('differential-table-of-contents-css');
     $this->requireResource('phui-text-css');
     Javelin::initBehavior('phabricator-tooltips');
     $items = $this->items;
     $rows = array();
     foreach ($items as $item) {
         $item->setUser($this->getUser());
         $rows[] = $item->render();
     }
     // Check if any item has content in these columns. If no item does, we'll
     // just hide them.
     $any_coverage = false;
     $any_context = false;
     $any_package = false;
     foreach ($items as $item) {
         if ($item->getContext() !== null) {
             $any_context = true;
         }
         if (strlen($item->getCoverage())) {
             $any_coverage = true;
         }
         if ($item->getPackage() !== null) {
             $any_package = true;
         }
     }
     $reveal_link = javelin_tag('a', array('sigil' => 'differential-reveal-all', 'mustcapture' => true, 'class' => 'button differential-toc-reveal-all'), pht('Show All Context'));
     $buttons = phutil_tag('div', array('class' => 'differential-toc-buttons grouped'), $reveal_link);
     $table = id(new AphrontTableView($rows))->setHeaders(array(null, null, null, null, pht('Path'), pht('Coverage (All)'), pht('Coverage (Touched)'), null))->setColumnClasses(array('center', 'differential-toc-char center', 'differential-toc-prop center', 'differential-toc-ftype center', 'differential-toc-file wide', 'differential-toc-cov', 'differential-toc-cov', 'center'))->setColumnVisibility(array($any_context, true, true, true, true, $any_coverage, $any_coverage, $any_package))->setDeviceVisibility(array(true, true, true, true, true, false, false, true));
     $anchor = id(new PhabricatorAnchorView())->setAnchorName('toc')->setNavigationMarker(true);
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Table of Contents'))->setTable($table)->appendChild($anchor)->appendChild($buttons);
 }
コード例 #19
0
 public function render()
 {
     require_celerity_resource('aphront-tokenizer-control-css');
     $id = $this->id;
     $name = $this->getName();
     $tokens = nonempty($this->getValue(), array());
     $input = javelin_tag('input', array('mustcapture' => true, 'name' => $name, 'class' => 'jx-tokenizer-input', 'sigil' => 'tokenizer-input', 'style' => 'width: 0px;', 'disabled' => 'disabled', 'type' => 'text'));
     $content = $tokens;
     $content[] = $input;
     $content[] = phutil_tag('div', array('style' => 'clear: both;'), '');
     $container = javelin_tag('div', array('id' => $id, 'class' => 'jx-tokenizer-container', 'sigil' => 'tokenizer-container'), $content);
     $icon = id(new PHUIIconView())->setIcon('fa-search');
     $browse = id(new PHUIButtonView())->setTag('a')->setIcon($icon)->addClass('tokenizer-browse-button')->setColor(PHUIButtonView::GREY)->addSigil('tokenizer-browse');
     $classes = array();
     $classes[] = 'jx-tokenizer-frame';
     if ($this->browseURI) {
         $classes[] = 'has-browse';
     }
     $initial = array();
     $initial_value = $this->getInitialValue();
     if ($initial_value) {
         foreach ($this->getInitialValue() as $value) {
             $initial[] = phutil_tag('input', array('type' => 'hidden', 'name' => $name . '.initial[]', 'value' => $value));
         }
     }
     $frame = javelin_tag('div', array('class' => implode(' ', $classes), 'sigil' => 'tokenizer-frame'), array($container, $browse, $initial));
     return $frame;
 }
コード例 #20
0
 protected function renderInput()
 {
     Javelin::initBehavior('choose-control');
     $set = $this->getIconSet();
     $input_id = celerity_generate_unique_node_id();
     $display_id = celerity_generate_unique_node_id();
     $is_disabled = $this->getDisabled();
     $classes = array();
     $classes[] = 'button';
     $classes[] = 'grey';
     if ($is_disabled) {
         $classes[] = 'disabled';
     }
     $button = javelin_tag('a', array('href' => '#', 'class' => implode(' ', $classes), 'sigil' => 'phui-form-iconset-button'), $set->getChooseButtonText());
     $icon = $set->getIcon($this->getValue());
     if ($icon) {
         $display = $set->renderIconForControl($icon);
     } else {
         $display = null;
     }
     $display_cell = phutil_tag('td', array('class' => 'phui-form-iconset-display-cell', 'id' => $display_id), $display);
     $button_cell = phutil_tag('td', array('class' => 'phui-form-iconset-button-cell'), $button);
     $row = phutil_tag('tr', array(), array($display_cell, $button_cell));
     $layout = javelin_tag('table', array('class' => 'phui-form-iconset-table', 'sigil' => 'phui-form-iconset', 'meta' => array('uri' => $set->getSelectURI(), 'inputID' => $input_id, 'displayID' => $display_id)), $row);
     $hidden_input = phutil_tag('input', array('type' => 'hidden', 'disabled' => $is_disabled ? 'disabled' : null, 'name' => $this->getName(), 'value' => $this->getValue(), 'id' => $input_id));
     return array($hidden_input, $layout);
 }
コード例 #21
0
 public function render()
 {
     $this->requireResource('differential-core-view-css');
     $this->requireResource('differential-table-of-contents-css');
     Javelin::initBehavior('phabricator-tooltips');
     if ($this->getAuthorityPackages()) {
         $authority = mpull($this->getAuthorityPackages(), null, 'getPHID');
     } else {
         $authority = array();
     }
     $items = $this->items;
     $rows = array();
     $rowc = array();
     foreach ($items as $item) {
         $item->setUser($this->getUser());
         $rows[] = $item->render();
         $have_authority = false;
         $packages = $item->getPackages();
         if ($packages) {
             if (array_intersect_key($packages, $authority)) {
                 $have_authority = true;
             }
         }
         if ($have_authority) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = null;
         }
     }
     // Check if any item has content in these columns. If no item does, we'll
     // just hide them.
     $any_coverage = false;
     $any_context = false;
     $any_packages = false;
     foreach ($items as $item) {
         if ($item->getContext() !== null) {
             $any_context = true;
         }
         if (strlen($item->getCoverage())) {
             $any_coverage = true;
         }
         if ($item->getPackages() !== null) {
             $any_packages = true;
         }
     }
     $reveal_link = javelin_tag('a', array('sigil' => 'differential-reveal-all', 'mustcapture' => true, 'class' => 'button differential-toc-reveal-all'), pht('Show All Context'));
     $buttons = phutil_tag('div', array('class' => 'differential-toc-buttons grouped'), $reveal_link);
     $table = id(new AphrontTableView($rows))->setRowClasses($rowc)->setHeaders(array(null, null, null, null, pht('Path'), pht('Coverage (All)'), pht('Coverage (Touched)'), pht('Packages')))->setColumnClasses(array(null, 'differential-toc-char center', 'differential-toc-prop center', 'differential-toc-ftype center', 'differential-toc-file wide', 'differential-toc-cov', 'differential-toc-cov', null))->setColumnVisibility(array($any_context, true, true, true, true, $any_coverage, $any_coverage, $any_packages))->setDeviceVisibility(array(true, true, true, true, true, false, false, true));
     $anchor = id(new PhabricatorAnchorView())->setAnchorName('toc')->setNavigationMarker(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Table of Contents'));
     if ($this->header) {
         $header = $this->header;
     }
     $box = id(new PHUIObjectBoxView())->setHeader($header)->setBackground($this->background)->setTable($table)->appendChild($anchor)->appendChild($buttons);
     if ($this->infoView) {
         $box->setInfoView($this->infoView);
     }
     return $box;
 }
コード例 #22
0
 public function renderExample()
 {
     require_celerity_resource('phabricator-notification-css');
     Javelin::initBehavior('phabricator-notification-example');
     $content = javelin_tag('a', array('sigil' => 'notification-example', 'class' => 'button green'), 'Show Notification');
     $content = hsprintf('<div style="padding: 1em 3em;">%s</div>', $content);
     return $content;
 }
 private function renderPersistentOption()
 {
     $viewer = $this->getViewer();
     $column_key = PhabricatorConpherenceColumnVisibleSetting::SETTINGKEY;
     $show = (bool) $viewer->getUserSetting($column_key, false);
     $view = phutil_tag('div', array('class' => 'persistent-option'), array(javelin_tag('input', array('type' => 'checkbox', 'checked' => $show ? 'checked' : null, 'value' => !$show, 'sigil' => 'conpherence-persist-column')), phutil_tag('span', array(), pht('Persistent Chat'))));
     return $view;
 }
コード例 #24
0
 protected function buildAlmanacPropertiesTable(AlmanacPropertyInterface $object)
 {
     $viewer = $this->getViewer();
     $properties = $object->getAlmanacProperties();
     $this->requireResource('almanac-css');
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_EDIT);
     $field_list = PhabricatorCustomField::getObjectFields($object, PhabricatorCustomField::ROLE_DEFAULT);
     // Before reading values from the object, read defaults.
     $defaults = mpull($field_list->getFields(), 'getValueForStorage', 'getFieldKey');
     $field_list->setViewer($viewer)->readFieldsFromStorage($object);
     Javelin::initBehavior('phabricator-tooltips', array());
     $icon_builtin = id(new PHUIIconView())->setIcon('fa-circle')->addSigil('has-tooltip')->setMetadata(array('tip' => pht('Builtin Property'), 'align' => 'E'));
     $icon_custom = id(new PHUIIconView())->setIcon('fa-circle-o grey')->addSigil('has-tooltip')->setMetadata(array('tip' => pht('Custom Property'), 'align' => 'E'));
     $builtins = $object->getAlmanacPropertyFieldSpecifications();
     // Sort fields so builtin fields appear first, then fields are ordered
     // alphabetically.
     $fields = $field_list->getFields();
     $fields = msort($fields, 'getFieldKey');
     $head = array();
     $tail = array();
     foreach ($fields as $field) {
         $key = $field->getFieldKey();
         if (isset($builtins[$key])) {
             $head[$key] = $field;
         } else {
             $tail[$key] = $field;
         }
     }
     $fields = $head + $tail;
     $rows = array();
     foreach ($fields as $key => $field) {
         $value = $field->getValueForStorage();
         $is_builtin = isset($builtins[$key]);
         $delete_uri = $this->getApplicationURI('property/delete/');
         $delete_uri = id(new PhutilURI($delete_uri))->setQueryParams(array('objectPHID' => $object->getPHID(), 'key' => $key));
         $edit_uri = $this->getApplicationURI('property/edit/');
         $edit_uri = id(new PhutilURI($edit_uri))->setQueryParams(array('objectPHID' => $object->getPHID(), 'key' => $key));
         $delete = javelin_tag('a', array('class' => $can_edit ? 'button grey small' : 'button grey small disabled', 'sigil' => 'workflow', 'href' => $delete_uri), $is_builtin ? pht('Reset') : pht('Delete'));
         $default = idx($defaults, $key);
         $is_default = $default !== null && $default === $value;
         $display_value = PhabricatorConfigJSON::prettyPrintJSON($value);
         if ($is_default) {
             $display_value = phutil_tag('span', array('class' => 'almanac-default-property-value'), $display_value);
         }
         $display_key = $key;
         if ($can_edit) {
             $display_key = javelin_tag('a', array('href' => $edit_uri, 'sigil' => 'workflow'), $display_key);
         }
         $rows[] = array($is_builtin ? $icon_builtin : $icon_custom, $display_key, $display_value, $delete);
     }
     $table = id(new AphrontTableView($rows))->setNoDataString(pht('No properties.'))->setHeaders(array(null, pht('Name'), pht('Value'), null))->setColumnClasses(array(null, null, 'wide', 'action'));
     $phid = $object->getPHID();
     $add_uri = $this->getApplicationURI("property/edit/?objectPHID={$phid}");
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $object, PhabricatorPolicyCapability::CAN_EDIT);
     $add_button = id(new PHUIButtonView())->setTag('a')->setHref($add_uri)->setWorkflow(true)->setDisabled(!$can_edit)->setText(pht('Add Property'))->setIcon('fa-plus');
     $header = id(new PHUIHeaderView())->setHeader(pht('Properties'))->addActionLink($add_button);
     return id(new PHUIObjectBoxView())->setHeader($header)->setTable($table);
 }
コード例 #25
0
 protected function getTagContent()
 {
     $application = $this->application;
     require_celerity_resource('phabricator-application-launch-view-css');
     require_celerity_resource('sprite-apps-large-css');
     $content = array();
     $icon = null;
     if ($application) {
         $content[] = phutil_tag('span', array('class' => 'phabricator-application-launch-name'), $application->getName());
         if ($application->isBeta()) {
             $content[] = javelin_tag('span', array('aural' => false, 'class' => 'phabricator-application-beta'), "β");
         }
         $content[] = phutil_tag('span', array('class' => 'phabricator-application-launch-description'), $application->getShortDescription());
         $counts = array();
         $text = array();
         if ($this->status) {
             foreach ($this->status as $status) {
                 $type = $status->getType();
                 $counts[$type] = idx($counts, $type, 0) + $status->getCount();
                 if ($status->getCount()) {
                     $text[] = $status->getText();
                 }
             }
         }
         $attention = PhabricatorApplicationStatusView::TYPE_NEEDS_ATTENTION;
         $warning = PhabricatorApplicationStatusView::TYPE_WARNING;
         if (!empty($counts[$attention]) || !empty($counts[$warning])) {
             $count = idx($counts, $attention, 0);
             $count1 = $count2 = '';
             if ($count > 0) {
                 $count1 = phutil_tag('span', array('class' => 'phabricator-application-attention-count'), $count);
             }
             if (!empty($counts[$warning])) {
                 $count2 = phutil_tag('span', array('class' => 'phabricator-application-warning-count'), $counts[$warning]);
             }
             if (nonempty($count1) && nonempty($count2)) {
                 $numbers = array($count1, ' / ', $count2);
             } else {
                 $numbers = array($count1, $count2);
             }
             Javelin::initBehavior('phabricator-tooltips');
             $content[] = javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => implode("\n", $text), 'size' => 240), 'class' => 'phabricator-application-launch-attention'), $numbers);
         }
         $classes = array();
         $classes[] = 'phabricator-application-launch-icon';
         $styles = array();
         if ($application->getIconURI()) {
             $styles[] = 'background-image: url(' . $application->getIconURI() . ')';
         } else {
             $icon = $application->getIconName();
             $classes[] = 'sprite-apps-large';
             $classes[] = 'apps-' . $icon . '-dark-large';
         }
         $icon = phutil_tag('span', array('class' => implode(' ', $classes), 'style' => nonempty(implode('; ', $styles), null)), '');
     }
     return array($icon, $content);
 }
コード例 #26
0
 public function render()
 {
     $marker = null;
     if ($this->navigationMarker) {
         $marker = javelin_tag('legend', array('class' => 'phabricator-anchor-navigation-marker', 'sigil' => 'marker', 'meta' => array('anchor' => $this->anchorName)), '');
     }
     $anchor = phutil_tag('a', array('name' => $this->anchorName, 'id' => $this->anchorName, 'class' => 'phabricator-anchor-view'), '');
     return array($marker, $anchor);
 }
コード例 #27
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $package = id(new PhabricatorOwnersPackageQuery())->setViewer($viewer)->withIDs(array($request->getURIData('id')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->needPaths(true)->executeOne();
     if (!$package) {
         return new Aphront404Response();
     }
     if ($request->isFormPost()) {
         $paths = $request->getArr('path');
         $repos = $request->getArr('repo');
         $excludes = $request->getArr('exclude');
         $path_refs = array();
         foreach ($paths as $key => $path) {
             if (!isset($repos[$key])) {
                 throw new Exception(pht('No repository PHID for path "%s"!', $key));
             }
             if (!isset($excludes[$key])) {
                 throw new Exception(pht('No exclusion value for path "%s"!', $key));
             }
             $path_refs[] = array('repositoryPHID' => $repos[$key], 'path' => $path, 'excluded' => (int) $excludes[$key]);
         }
         $type_paths = PhabricatorOwnersPackageTransaction::TYPE_PATHS;
         $xactions = array();
         $xactions[] = id(new PhabricatorOwnersPackageTransaction())->setTransactionType($type_paths)->setNewValue($path_refs);
         $editor = id(new PhabricatorOwnersPackageTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnNoEffect(true)->setContinueOnMissingFields(true);
         $editor->applyTransactions($package, $xactions);
         return id(new AphrontRedirectResponse())->setURI($package->getURI());
     } else {
         $paths = $package->getPaths();
         $path_refs = mpull($paths, 'getRef');
     }
     $repos = id(new PhabricatorRepositoryQuery())->setViewer($viewer)->execute();
     $default_paths = array();
     foreach ($repos as $repo) {
         $default_path = $repo->getDetail('default-owners-path');
         if ($default_path) {
             $default_paths[$repo->getPHID()] = $default_path;
         }
     }
     $repos = mpull($repos, 'getDisplayName', 'getPHID');
     asort($repos);
     $template = new AphrontTypeaheadTemplateView();
     $template = $template->render();
     Javelin::initBehavior('owners-path-editor', array('root' => 'path-editor', 'table' => 'paths', 'add_button' => 'addpath', 'repositories' => $repos, 'input_template' => $template, 'pathRefs' => $path_refs, 'completeURI' => '/diffusion/services/path/complete/', 'validateURI' => '/diffusion/services/path/validate/', 'repositoryDefaultPaths' => $default_paths));
     require_celerity_resource('owners-path-editor-css');
     $cancel_uri = $package->getURI();
     $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new PHUIFormInsetView())->setTitle(pht('Paths'))->addDivAttributes(array('id' => 'path-editor'))->setRightButton(javelin_tag('a', array('href' => '#', 'class' => 'button green', 'sigil' => 'addpath', 'mustcapture' => true), pht('Add New Path')))->setDescription(pht('Specify the files and directories which comprise ' . 'this package.'))->setContent(javelin_tag('table', array('class' => 'owners-path-editor-table', 'sigil' => 'paths'), '')))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($cancel_uri)->setValue(pht('Save Paths')));
     $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Paths'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($package->getName(), $this->getApplicationURI('package/' . $package->getID() . '/'));
     $crumbs->addTextCrumb(pht('Edit Paths'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Paths: %s', $package->getName()))->setHeaderIcon('fa-pencil');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($box);
     $title = array($package->getName(), pht('Edit Paths'));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
コード例 #28
0
 private function renderBody()
 {
     $buttons = array();
     $buttons[] = phutil_tag('button', array(), pht('Ready'));
     $buttons[] = javelin_tag('button', array('sigil' => 'inline-edit-cancel', 'class' => 'grey'), pht('Cancel'));
     $title = phutil_tag('div', array('class' => 'differential-inline-comment-edit-title'), $this->title);
     $body = phutil_tag('div', array('class' => 'differential-inline-comment-edit-body'), $this->renderChildren());
     $edit = phutil_tag('div', array('class' => 'differential-inline-comment-edit-buttons'), array($buttons, phutil_tag('div', array('style' => 'clear: both'), '')));
     return javelin_tag('div', array('class' => 'differential-inline-comment-edit', 'sigil' => 'differential-inline-comment', 'meta' => array('on_right' => $this->onRight, 'number' => $this->number, 'length' => $this->length)), array($title, $body, $edit));
 }
コード例 #29
0
 public static final function renderName($name)
 {
     $email = new PhutilEmailAddress($name);
     if ($email->getDisplayName() && $email->getDomainName()) {
         Javelin::initBehavior('phabricator-tooltips', array());
         require_celerity_resource('aphront-tooltip-css');
         return javelin_tag('span', array('sigil' => 'has-tooltip', 'meta' => array('tip' => $email->getAddress(), 'align' => 'E', 'size' => 'auto')), $email->getDisplayName());
     }
     return hsprintf('%s', $name);
 }
コード例 #30
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $color_map = PhabricatorFilesComposeIconBuiltinFile::getAllColors();
     $icon_map = $this->getIconMap();
     if ($request->isFormPost()) {
         $project_phid = $request->getStr('projectPHID');
         if ($project_phid) {
             $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withPHIDs(array($project_phid))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
             if (!$project) {
                 return new Aphront404Response();
             }
         }
         $icon = $request->getStr('icon');
         $color = $request->getStr('color');
         $composer = id(new PhabricatorFilesComposeIconBuiltinFile())->setIcon($icon)->setColor($color);
         $data = $composer->loadBuiltinFileData();
         $file = PhabricatorFile::buildFromFileDataOrHash($data, array('name' => $composer->getBuiltinDisplayName(), 'profile' => true, 'canCDN' => true));
         if ($project_phid) {
             $edit_uri = '/project/history/' . $project->getID() . '/';
             $xactions = array();
             $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)->setNewValue($file->getPHID());
             $editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($project, $xactions);
             return id(new AphrontRedirectResponse())->setURI($edit_uri);
         } else {
             $content = array('phid' => $file->getPHID());
             return id(new AphrontAjaxResponse())->setContent($content);
         }
     }
     $value_color = head_key($color_map);
     $value_icon = head_key($icon_map);
     require_celerity_resource('people-profile-css');
     $buttons = array();
     foreach ($color_map as $color => $info) {
         $quip = idx($info, 'quip');
         $buttons[] = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip compose-select-color', 'style' => 'margin: 0 8px 8px 0', 'meta' => array('color' => $color, 'tip' => $quip)), id(new PHUIIconView())->addClass('compose-background-' . $color));
     }
     $icons = array();
     foreach ($icon_map as $icon => $spec) {
         $quip = idx($spec, 'quip');
         $icons[] = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip compose-select-icon', 'style' => 'margin: 0 8px 8px 0', 'meta' => array('icon' => $icon, 'tip' => $quip)), id(new PHUIIconView())->setIconFont($icon)->addClass('compose-icon-bg'));
     }
     $dialog_id = celerity_generate_unique_node_id();
     $color_input_id = celerity_generate_unique_node_id();
     $icon_input_id = celerity_generate_unique_node_id();
     $preview_id = celerity_generate_unique_node_id();
     $preview = id(new PHUIIconView())->setID($preview_id)->addClass('compose-background-' . $value_color)->setIconFont($value_icon)->addClass('compose-icon-bg');
     $color_input = javelin_tag('input', array('type' => 'hidden', 'name' => 'color', 'value' => $value_color, 'id' => $color_input_id));
     $icon_input = javelin_tag('input', array('type' => 'hidden', 'name' => 'icon', 'value' => $value_icon, 'id' => $icon_input_id));
     Javelin::initBehavior('phabricator-tooltips');
     Javelin::initBehavior('icon-composer', array('dialogID' => $dialog_id, 'colorInputID' => $color_input_id, 'iconInputID' => $icon_input_id, 'previewID' => $preview_id, 'defaultColor' => $value_color, 'defaultIcon' => $value_icon));
     $dialog = id(new AphrontDialogView())->setUser($viewer)->setFormID($dialog_id)->setClass('compose-dialog')->setTitle(pht('Compose Image'))->appendChild(phutil_tag('div', array('class' => 'compose-header'), pht('Choose Background Color')))->appendChild($buttons)->appendChild(phutil_tag('div', array('class' => 'compose-header'), pht('Choose Icon')))->appendChild($icons)->appendChild(phutil_tag('div', array('class' => 'compose-header'), pht('Preview')))->appendChild($preview)->appendChild($color_input)->appendChild($icon_input)->addCancelButton('/')->addSubmitButton(pht('Save Image'));
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }