コード例 #1
0
 public function renderValueForRevisionView()
 {
     $diff = $this->getDiff();
     $path_changesets = mpull($diff->loadChangesets(), 'getId', 'getFilename');
     $lstar = DifferentialRevisionUpdateHistoryView::renderDiffLintStar($diff);
     $lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff);
     $ldata = $this->getDiffProperty('arc:lint');
     $ltail = null;
     if ($ldata) {
         $ldata = igroup($ldata, 'path');
         $lint_messages = array();
         foreach ($ldata as $path => $messages) {
             $message_markup = array();
             foreach ($messages as $message) {
                 $path = idx($message, 'path');
                 $line = idx($message, 'line');
                 $code = idx($message, 'code');
                 $severity = idx($message, 'severity');
                 $name = idx($message, 'name');
                 $description = idx($message, 'description');
                 $line_link = phutil_escape_html($line);
                 if (isset($path_changesets[$path])) {
                     // TODO: Create standalone links for large diffs. Logic is in
                     // DifferentialDiffTableOfContentsView::renderChangesetLink().
                     $line_link = phutil_render_tag('a', array('href' => '#C' . $path_changesets[$path] . 'NL' . $line), $line_link);
                 }
                 $message_markup[] = hsprintf('<li>' . '<span class="lint-severity-%s">%s</span> (%s) %s ' . 'at line ' . $line_link . '<p>%s</p>' . '</li>', $severity, ucwords($severity), $code, $name, $description);
             }
             $lint_messages[] = '<li class="lint-file-block">' . 'Lint for <strong>' . phutil_escape_html($path) . '</strong>' . '<ul>' . implode("\n", $message_markup) . '</ul>' . '</li>';
         }
         $lexcuse = $this->getLintExcuse();
         $ltail = '<div class="differential-lint-block">' . $lexcuse . '<ul>' . implode("\n", $lint_messages) . '</ul>' . '</div>';
     }
     return $lstar . ' ' . $lmsg . $ltail;
 }
コード例 #2
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $file = PhabricatorFile::initializeNewFile();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $view_policy = $request->getStr('viewPolicy');
         if (!$request->getFileExists('file')) {
             $e_file = pht('Required');
             $errors[] = pht('You must select a file to upload.');
         } else {
             $file = PhabricatorFile::newFromPHPUpload(idx($_FILES, 'file'), array('name' => $request->getStr('name'), 'authorPHID' => $viewer->getPHID(), 'viewPolicy' => $view_policy, 'isExplicitUpload' => true));
         }
         if (!$errors) {
             return id(new AphrontRedirectResponse())->setURI($file->getInfoURI());
         }
         $file->setViewPolicy($view_policy);
     }
     $support_id = celerity_generate_unique_node_id();
     $instructions = id(new AphrontFormMarkupControl())->setControlID($support_id)->setControlStyle('display: none')->setValue(hsprintf('<br /><br /><strong>%s</strong> %s<br /><br />', pht('Drag and Drop:'), pht('You can also upload files by dragging and dropping them from your ' . 'desktop onto this page or the Phabricator home page.')));
     $policies = id(new PhabricatorPolicyQuery())->setViewer($viewer)->setObject($file)->execute();
     $form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setLabel(pht('File'))->setName('file')->setError($e_file))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name'))->setName('name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormPolicyControl())->setUser($viewer)->setCapability(PhabricatorPolicyCapability::CAN_VIEW)->setPolicyObject($file)->setPolicies($policies)->setName('viewPolicy'))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Upload'))->addCancelButton('/file/'))->appendChild($instructions);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Upload'), $request->getRequestURI());
     $crumbs->setBorder(true);
     $title = pht('Upload File');
     $global_upload = id(new PhabricatorGlobalUploadTargetView())->setUser($viewer)->setShowIfSupportedID($support_id);
     $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('File'))->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $header = id(new PHUIHeaderView())->setHeader($title)->setHeaderIcon('fa-upload');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $global_upload));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild($view);
 }
コード例 #3
0
 public function render()
 {
     $right_button = $desc = '';
     $hidden_inputs = array();
     foreach ($this->hidden as $inp) {
         list($key, $value) = $inp;
         $hidden_inputs[] = phutil_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value));
     }
     if ($this->rightButton) {
         $right_button = phutil_tag('div', array('style' => 'float: right;'), $this->rightButton);
     }
     if ($this->description) {
         $desc = phutil_tag('p', array(), $this->description);
         if ($right_button) {
             $desc = hsprintf('%s<div style="clear: both;"></div>', $desc);
         }
     }
     $div_attributes = $this->divAttributes;
     $classes = array('aphront-form-inset');
     if (isset($div_attributes['class'])) {
         $classes[] = $div_attributes['class'];
     }
     $div_attributes['class'] = implode(' ', $classes);
     $content = $hidden_inputs;
     $content[] = $right_button;
     $content[] = $desc;
     if ($this->title != '') {
         array_unshift($content, phutil_tag('h1', array(), $this->title));
     }
     if ($this->content) {
         $content[] = $this->content;
     }
     $content = array_merge($content, $this->renderChildren());
     return phutil_tag('div', $div_attributes, $content);
 }
コード例 #4
0
 protected function markupHyperlinkUngreedy($matches)
 {
     $match = $matches[1];
     $tail = null;
     $trailing = null;
     if (preg_match('/[;,.:!?]+$/', $match, $trailing)) {
         $tail = $trailing[0];
         $match = substr($match, 0, -strlen($tail));
     }
     // If there's a closing paren at the end but no balancing open paren in
     // the URL, don't link the close paren. This is an attempt to gracefully
     // handle the two common paren cases, Wikipedia links and English language
     // parentheticals, e.g.:
     //
     //  http://en.wikipedia.org/wiki/Noun_(disambiguation)
     //  (see also http://www.example.com)
     //
     // We could apply a craftier heuristic here which tries to actually balance
     // the parens, but this is probably sufficient.
     if (preg_match('/\\)$/', $match) && !preg_match('/\\(/', $match)) {
         $tail = ')' . $tail;
         $match = substr($match, 0, -1);
     }
     return hsprintf('%s%s', $this->markupHyperlink(array(null, $match)), $tail);
 }
コード例 #5
0
 private function renderTransactionInfo()
 {
     $info = array();
     if ($this->contentSource) {
         $content_source = new PhabricatorContentSourceView();
         $content_source->setContentSource($this->contentSource);
         $content_source->setUser($this->user);
         $source = $content_source->render();
         if ($source) {
             $info[] = $source;
         }
     }
     if ($this->isPreview) {
         $info[] = 'PREVIEW';
     } else {
         if ($this->epoch) {
             $info[] = phabricator_datetime($this->epoch, $this->user);
         }
     }
     if ($this->anchorName) {
         Javelin::initBehavior('phabricator-watch-anchor');
         $anchor = id(new PhabricatorAnchorView())->setAnchorName($this->anchorName)->render();
         $info[] = hsprintf('%s%s', $anchor, phutil_tag('a', array('href' => '#' . $this->anchorName), $this->anchorText));
     }
     $info = phutil_implode_html(" · ", $info);
     return phutil_tag('span', array('class' => 'phabricator-transaction-info'), $info);
 }
コード例 #6
0
 public function testSingleVariant()
 {
     $translator = $this->newTranslator('en_US');
     // In this translation, we have no alternatives for the first conversion.
     $translator->setTranslations(array('Run the command %s %d time(s).' => array(array('Run the command %s once.', 'Run the command %s %d times.'))));
     $this->assertEqual('Run the command <tt>ls</tt> 123 times.', (string) $translator->translate('Run the command %s %d time(s).', hsprintf('<tt>%s</tt>', 'ls'), 123));
 }
コード例 #7
0
 protected function getHead()
 {
     $framebust = null;
     if (!$this->getFrameable()) {
         $framebust = '(top == self) || top.location.replace(self.location.href);';
     }
     $viewport_tag = null;
     if ($this->getDeviceReady()) {
         $viewport_tag = phutil_tag('meta', array('name' => 'viewport', 'content' => 'width=device-width, ' . 'initial-scale=1, ' . 'maximum-scale=1'));
     }
     $mask_icon = phutil_tag('link', array('rel' => 'mask-icon', 'color' => '#3D4B67', 'href' => celerity_get_resource_uri('/rsrc/favicons/mask-icon.svg')));
     $icon_tag_76 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-76x76.png')));
     $icon_tag_120 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '120x120', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-120x120.png')));
     $icon_tag_152 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '152x152', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-152x152.png')));
     $favicon_tag = phutil_tag('link', array('id' => 'favicon', 'rel' => 'shortcut icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/favicon.ico')));
     $referrer_tag = phutil_tag('meta', array('name' => 'referrer', 'content' => 'never'));
     $response = CelerityAPI::getStaticResourceResponse();
     if ($this->getRequest()) {
         $viewer = $this->getRequest()->getViewer();
         if ($viewer) {
             $postprocessor_key = $viewer->getUserSetting(PhabricatorAccessibilitySetting::SETTINGKEY);
             if (strlen($postprocessor_key)) {
                 $response->setPostProcessorKey($postprocessor_key);
             }
         }
     }
     $developer = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
     return hsprintf('%s%s%s%s%s%s%s%s%s', $viewport_tag, $mask_icon, $icon_tag_76, $icon_tag_120, $icon_tag_152, $favicon_tag, $referrer_tag, CelerityStaticResourceResponse::renderInlineScript($framebust . jsprintf('window.__DEV__=%d;', $developer ? 1 : 0)), $response->renderResourcesOfType('css'));
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $object = id(new PhabricatorObjectQuery())->withPHIDs(array($request->getURIData('phid')))->setViewer($viewer)->executeOne();
     if (!$object) {
         return new Aphront404Response();
     }
     if (!$object instanceof PhabricatorApplicationTransactionInterface) {
         return new Aphront404Response();
     }
     $template = $object->getApplicationTransactionTemplate();
     $queries = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorApplicationTransactionQuery')->execute();
     $object_query = null;
     foreach ($queries as $query) {
         if ($query->getTemplateApplicationTransaction() == $template) {
             $object_query = $query;
             break;
         }
     }
     if (!$object_query) {
         return new Aphront404Response();
     }
     $timeline = $this->buildTransactionTimeline($object, $query);
     $phui_timeline = $timeline->buildPHUITimelineView($with_hiding = false);
     $phui_timeline->setShouldAddSpacers(false);
     $events = $phui_timeline->buildEvents();
     return id(new AphrontAjaxResponse())->setContent(array('timeline' => hsprintf('%s', $events)));
 }
コード例 #9
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);
 }
コード例 #10
0
 public function render()
 {
     require_celerity_resource('pholio-edit-css');
     $image = $this->image;
     $file = $image->getFile();
     $phid = $file->getPHID();
     $replaces_phid = $this->replacesPHID;
     $remove = $this->renderRemoveElement();
     $title = id(new AphrontFormTextControl())->setName('title_' . $phid)->setValue($image->getName())->setSigil('image-title')->setLabel(pht('Title'));
     $description = id(new PhabricatorRemarkupControl())->setName('description_' . $phid)->setValue($image->getDescription())->setSigil('image-description')->setLabel(pht('Description'));
     $thumb_frame = phutil_tag('div', array('class' => 'pholio-thumb-frame', 'style' => 'background-image: url(' . $file->getThumb280x210URI() . ');'));
     $handle = javelin_tag('div', array('class' => 'pholio-drag-handle', 'sigil' => 'pholio-drag-handle'));
     $content = hsprintf('<div class="pholio-thumb-box">
     <div class="pholio-thumb-title">
       %s
       <div class="pholio-thumb-name">%s</div>
     </div>
     %s
   </div>
   <div class="pholio-image-details">
     %s
     %s
   </div>', $remove, $file->getName(), $thumb_frame, $title, $description);
     $input = phutil_tag('input', array('type' => 'hidden', 'name' => 'file_phids[]', 'value' => $phid));
     $replaces_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'replaces[' . $replaces_phid . ']', 'value' => $phid));
     return javelin_tag('div', array('class' => 'pholio-uploaded-image', 'sigil' => 'pholio-drop-image', 'meta' => array('filePHID' => $file->getPHID(), 'replacesPHID' => $replaces_phid)), array($handle, $content, $input, $replaces_input));
 }
コード例 #11
0
 public function renderExample()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $action = id(new PHUIListItemView())->setName(pht('Actions'))->setType(PHUIListItemView::TYPE_LABEL);
     $action1 = id(new PHUIListItemView())->setName(pht('Edit Document'))->setHref('#')->setIcon('fa-edit')->setType(PHUIListItemView::TYPE_LINK);
     $action2 = id(new PHUIListItemView())->setName(pht('Move Document'))->setHref('#')->setIcon('fa-arrows')->setType(PHUIListItemView::TYPE_LINK);
     $action3 = id(new PHUIListItemView())->setName(pht('Delete Document'))->setHref('#')->setIcon('fa-times')->setType(PHUIListItemView::TYPE_LINK);
     $action4 = id(new PHUIListItemView())->setName(pht('View History'))->setHref('#')->setIcon('fa-list')->setType(PHUIListItemView::TYPE_LINK);
     $action5 = id(new PHUIListItemView())->setName(pht('Subscribe'))->setHref('#')->setIcon('fa-plus-circle')->setType(PHUIListItemView::TYPE_LINK);
     $divider = id(new PHUIListItemView())->setType(PHUIListItemView::TYPE_DIVIDER);
     $header = id(new PHUIHeaderView())->setHeader(pht('Installation'));
     $label1 = id(new PHUIListItemView())->setName(pht('Getting Started'))->setType(PHUIListItemView::TYPE_LABEL);
     $label2 = id(new PHUIListItemView())->setName(pht('Documentation'))->setType(PHUIListItemView::TYPE_LABEL);
     $item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $sidenav = id(new PHUIListView())->setType(PHUIListView::SIDENAV_LIST)->addMenuItem($action)->addMenuItem($action1)->addMenuItem($action2)->addMenuItem($action3)->addMenuItem($action4)->addMenuItem($action5)->addMenuItem($divider)->addMenuItem($label1)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($label2)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4)->addMenuItem($item1);
     $home = id(new PHUIListItemView())->setIcon('fa-home')->setHref('#')->setType(PHUIListItemView::TYPE_ICON);
     $item1 = id(new PHUIListItemView())->setName(pht('Installation'))->setHref('#')->setSelected(true)->setType(PHUIListItemView::TYPE_LINK);
     $item2 = id(new PHUIListItemView())->setName(pht('Webserver Config'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item3 = id(new PHUIListItemView())->setName(pht('Adding Users'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $item4 = id(new PHUIListItemView())->setName(pht('Debugging'))->setHref('#')->setType(PHUIListItemView::TYPE_LINK);
     $topnav = id(new PHUIListView())->setType(PHUIListView::NAVBAR_LIST)->addMenuItem($home)->addMenuItem($item1)->addMenuItem($item2)->addMenuItem($item3)->addMenuItem($item4);
     $document = hsprintf('<p class="pl">Lorem ipsum dolor sit amet, consectetur adipisicing, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>' . '<p class="plr pll plb">Lorem ipsum dolor sit amet, consectetur, ' . 'sed do eiusmod tempor incididunt ut labore et dolore magna ' . 'aliqua. Ut enim ad minim veniam, quis nostrud exercitation ' . 'ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis ' . 'aute irure dolor in reprehenderit in voluptate velit esse cillum ' . 'dolore eu fugiat nulla pariatur. Excepteur sint occaecat ' . 'cupidatat non proident, sunt in culpa qui officia deserunt ' . 'mollit anim id est laborum.</p>');
     $content = new PHUIDocumentView();
     $content->setBook(pht('Book or Project Name'), pht('Article'));
     $content->setHeader($header);
     $content->setFluid(true);
     $content->setTopNav($topnav);
     $content->setSidenav($sidenav);
     $content->appendChild($document);
     return $content;
 }
 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);
 }
コード例 #13
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();
 }
コード例 #14
0
 protected function getHead()
 {
     $framebust = null;
     if (!$this->getFrameable()) {
         $framebust = '(top == self) || top.location.replace(self.location.href);';
     }
     $viewport_tag = null;
     if ($this->getDeviceReady()) {
         $viewport_tag = phutil_tag('meta', array('name' => 'viewport', 'content' => 'width=device-width, ' . 'initial-scale=1, ' . 'maximum-scale=1'));
     }
     $icon_tag_76 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-76x76.png')));
     $icon_tag_120 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '120x120', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-120x120.png')));
     $icon_tag_152 = phutil_tag('link', array('rel' => 'apple-touch-icon', 'sizes' => '152x152', 'href' => celerity_get_resource_uri('/rsrc/favicons/apple-touch-icon-152x152.png')));
     $apple_tag = phutil_tag('meta', array('name' => 'apple-mobile-web-app-status-bar-style', 'content' => 'black-translucent'));
     $referrer_tag = phutil_tag('meta', array('name' => 'referrer', 'content' => 'never'));
     $response = CelerityAPI::getStaticResourceResponse();
     if ($this->getRequest()) {
         $viewer = $this->getRequest()->getViewer();
         if ($viewer) {
             $postprocessor_key = $viewer->getPreference(PhabricatorUserPreferences::PREFERENCE_RESOURCE_POSTPROCESSOR);
             if (strlen($postprocessor_key)) {
                 $response->setPostProcessorKey($postprocessor_key);
             }
         }
     }
     $developer = PhabricatorEnv::getEnvConfig('phabricator.developer-mode');
     return hsprintf('%s%s%s%s%s%s%s%s', $viewport_tag, $icon_tag_76, $icon_tag_120, $icon_tag_152, $apple_tag, $referrer_tag, CelerityStaticResourceResponse::renderInlineScript($framebust . jsprintf('window.__DEV__=%d;', $developer ? 1 : 0)), $response->renderResourcesOfType('css'));
 }
コード例 #15
0
 public function render()
 {
     require_celerity_resource('pholio-edit-css');
     $image = $this->image;
     $file = $image->getFile();
     $phid = $file->getPHID();
     $replaces_phid = $this->replacesPHID;
     $remove = $this->renderRemoveElement();
     $title = id(new AphrontFormTextControl())->setName('title_' . $phid)->setValue($image->getName())->setSigil('image-title')->setLabel(pht('Title'));
     $description = id(new PhabricatorRemarkupControl())->setUser($this->getUser())->setName('description_' . $phid)->setValue($image->getDescription())->setSigil('image-description')->setLabel(pht('Description'));
     $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PINBOARD);
     $thumbnail_uri = $file->getURIForTransform($xform);
     $thumb_img = javelin_tag('img', array('class' => 'pholio-thumb-img', 'src' => $thumbnail_uri, 'sigil' => 'pholio-uploaded-thumb'));
     $thumb_frame = phutil_tag('div', array('class' => 'pholio-thumb-frame'), $thumb_img);
     $handle = javelin_tag('div', array('class' => 'pholio-drag-handle', 'sigil' => 'pholio-drag-handle'));
     $content = hsprintf('<div class="pholio-thumb-box">
     <div class="pholio-thumb-title">
       %s
       <div class="pholio-thumb-name">%s</div>
     </div>
     %s
   </div>
   <div class="pholio-image-details">
     %s
     %s
   </div>', $remove, $file->getName(), $thumb_frame, $title, $description);
     $input = phutil_tag('input', array('type' => 'hidden', 'name' => 'file_phids[]', 'value' => $phid));
     $replaces_input = phutil_tag('input', array('type' => 'hidden', 'name' => 'replaces[' . $replaces_phid . ']', 'value' => $phid));
     return javelin_tag('div', array('class' => 'pholio-uploaded-image', 'sigil' => 'pholio-drop-image', 'meta' => array('filePHID' => $file->getPHID(), 'replacesPHID' => $replaces_phid)), array($handle, $content, $input, $replaces_input));
 }
コード例 #16
0
 public function willSendMail(PhabricatorMetaMTAMail $mail)
 {
     $viewer = $this->getViewer();
     $mail->addPHIDHeaders('X-Phabricator-To', $this->rawToPHIDs);
     $mail->addPHIDHeaders('X-Phabricator-Cc', $this->rawCCPHIDs);
     $to_handles = $viewer->loadHandles($this->rawToPHIDs);
     $cc_handles = $viewer->loadHandles($this->rawCCPHIDs);
     $body = $mail->getBody();
     $body .= "\n";
     $body .= $this->getRecipientsSummary($to_handles, $cc_handles);
     $mail->setBody($body);
     $html_body = $mail->getHTMLBody();
     if (strlen($html_body)) {
         $html_body .= hsprintf('%s', $this->getRecipientsSummaryHTML($to_handles, $cc_handles));
     }
     $mail->setHTMLBody($html_body);
     $reply_to = $this->getReplyTo();
     if ($reply_to) {
         $mail->setReplyTo($reply_to);
     }
     $to = array_keys($this->getToMap());
     if ($to) {
         $mail->addTos($to);
     }
     $cc = array_keys($this->getCCMap());
     if ($cc) {
         $mail->addCCs($cc);
     }
     return $mail;
 }
コード例 #17
0
 protected function applyCallback(array $matches)
 {
     // Remove the two exclamation points that represent syntax.
     $excitement = substr($matches[2], 2);
     // $excitement now has two fewer !'s than we started with.
     return hsprintf('<span class="remarkup-highlight">%s%s</span>', $matches[1], $excitement);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $stories = id(new PhabricatorNotificationQuery())->setViewer($viewer)->withUserPHIDs(array($viewer->getPHID()))->withKeys(array($request->getStr('key')))->execute();
     if (!$stories) {
         return $this->buildEmptyResponse();
     }
     $story = head($stories);
     if ($story->getAuthorPHID() === $viewer->getPHID()) {
         // Don't show the user individual notifications about their own
         // actions. Primarily, this stops pages from showing notifications
         // immediately after you click "Submit" on a comment form if the
         // notification server returns faster than the web server.
         // TODO: It would be nice to retain the "page updated" bubble on copies
         // of the page that are open in other tabs, but there isn't an obvious
         // way to do this easily.
         return $this->buildEmptyResponse();
     }
     $builder = id(new PhabricatorNotificationBuilder(array($story)))->setUser($viewer)->setShowTimestamps(false);
     $content = $builder->buildView()->render();
     $dict = $builder->buildDict();
     $data = $dict[0];
     $response = array('pertinent' => true, 'primaryObjectPHID' => $story->getPrimaryObjectPHID(), 'desktopReady' => $data['desktopReady'], 'href' => $data['href'], 'icon' => $data['icon'], 'title' => $data['title'], 'body' => $data['body'], 'content' => hsprintf('%s', $content));
     return id(new AphrontAjaxResponse())->setContent($response);
 }
コード例 #19
0
 public function render()
 {
     $request = $this->request;
     $provider = $this->provider;
     $provider_name = $provider->getProviderName();
     $diagnose = null;
     $view = new AphrontRequestFailureView();
     $view->setHeader($provider_name . ' Auth Failed');
     if ($this->request) {
         $view->appendChild(hsprintf('<p><strong>Description:</strong> %s</p>', $request->getStr('error_description')));
         $view->appendChild(hsprintf('<p><strong>Error:</strong> %s</p>', $request->getStr('error')));
         $view->appendChild(hsprintf('<p><strong>Error Reason:</strong> %s</p>', $request->getStr('error_reason')));
     } else {
         if ($this->exception) {
             $view->appendChild(hsprintf('<p><strong>Error Details:</strong> %s</p>', $this->exception->getMessage()));
         } else {
             // TODO: We can probably refine this.
             $view->appendChild(hsprintf('<p>Unable to authenticate with %s. ' . 'There are several reasons this might happen:</p>' . '<ul>' . '<li>Phabricator may be configured with the wrong Application ' . 'Secret; or</li>' . '<li>the %s OAuth access token may have expired; or</li>' . '<li>%s may have revoked authorization for the Application; ' . 'or</li>' . '<li>%s may be having technical problems.</li>' . '</ul>' . '<p>You can try again, or login using another method.</p>', $provider_name, $provider_name, $provider_name, $provider_name));
             $provider_key = $provider->getProviderKey();
             $diagnose = hsprintf('<a href="/oauth/' . $provider_key . '/diagnose/" class="button green">' . 'Diagnose %s OAuth Problems' . '</a>', $provider_name);
         }
     }
     $view->appendChild('<div class="aphront-failure-continue">' . $diagnose . '<a href="/login/" class="button">Continue</a>' . '</div>');
     return $view->render();
 }
コード例 #20
0
 public function reduceProxyResponse()
 {
     if ($this->transactionView) {
         $view = $this->transactionView;
     } else {
         if ($this->getTransactions()) {
             $view = head($this->getTransactions())->getApplicationTransactionViewObject();
         } else {
             $view = new PhabricatorApplicationTransactionView();
         }
     }
     $view->setUser($this->getViewer())->setTransactions($this->getTransactions())->setIsPreview($this->isPreview);
     if ($this->isPreview) {
         $xactions = mpull($view->buildEvents(), 'render');
     } else {
         $xactions = mpull($view->buildEvents(), 'render', 'getTransactionPHID');
     }
     // Force whatever the underlying views built to render into HTML for
     // the Javascript.
     foreach ($xactions as $key => $xaction) {
         $xactions[$key] = hsprintf('%s', $xaction);
     }
     $content = array('xactions' => $xactions, 'spacer' => PHUITimelineView::renderSpacer());
     return $this->getProxy()->setContent($content);
 }
コード例 #21
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $request->validateCSRF();
     $pull = id(new ReleephRequestQuery())->setViewer($viewer)->withIDs(array($this->requestID))->executeOne();
     if (!$pull) {
         return new Aphront404Response();
     }
     $branch = $pull->getBranch();
     $product = $branch->getProduct();
     $action = $this->action;
     $origin_uri = '/' . $pull->getMonogram();
     $editor = id(new ReleephRequestTransactionalEditor())->setActor($viewer)->setContinueOnNoEffect(true)->setContentSourceFromRequest($request);
     $xactions = array();
     switch ($action) {
         case 'want':
         case 'pass':
             static $action_map = array('want' => ReleephRequest::INTENT_WANT, 'pass' => ReleephRequest::INTENT_PASS);
             $intent = $action_map[$action];
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isAuthoritative', $product->isAuthoritative($viewer))->setNewValue($intent);
             break;
         case 'mark-manually-picked':
         case 'mark-manually-reverted':
             if ($pull->getRequestUserPHID() === $viewer->getPHID() || $product->isAuthoritative($viewer)) {
                 // We're all good!
             } else {
                 throw new Exception(pht("Bug! Only pushers or the requestor can manually change a " . "request's in-branch status!"));
             }
             if ($action === 'mark-manually-picked') {
                 $in_branch = 1;
                 $intent = ReleephRequest::INTENT_WANT;
             } else {
                 $in_branch = 0;
                 $intent = ReleephRequest::INTENT_PASS;
             }
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_USER_INTENT)->setMetadataValue('isManual', true)->setMetadataValue('isAuthoritative', true)->setNewValue($intent);
             $xactions[] = id(new ReleephRequestTransaction())->setTransactionType(ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH)->setNewValue($in_branch);
             break;
         default:
             throw new Exception(pht('Unknown or unimplemented action %s.', $action));
     }
     $editor->applyTransactions($pull, $xactions);
     if ($request->getBool('render')) {
         $field_list = PhabricatorCustomField::getObjectFields($pull, PhabricatorCustomField::ROLE_VIEW);
         $field_list->setViewer($viewer)->readFieldsFromStorage($pull);
         // TODO: This should be more modern and general.
         $engine = id(new PhabricatorMarkupEngine())->setViewer($viewer);
         foreach ($field_list->getFields() as $field) {
             if ($field->shouldMarkup()) {
                 $field->setMarkupEngine($engine);
             }
         }
         $engine->process();
         $pull_box = id(new ReleephRequestView())->setUser($viewer)->setCustomFields($field_list)->setPullRequest($pull)->setIsListView(true);
         return id(new AphrontAjaxResponse())->setContent(array('markup' => hsprintf('%s', $pull_box)));
     }
     return id(new AphrontRedirectResponse())->setURI($origin_uri);
 }
 private function fail($near, $message)
 {
     $message = sprintf('%s near: %s', $message, phutil_utf8_shorten($near, 32000));
     if ($this->getEngine()->isTextMode()) {
         return '(' . $message . ')';
     }
     return hsprintf('<div style="color: red;">%s</div>', $message);
 }
コード例 #23
0
 private function fail($near, $message)
 {
     $message = sprintf('%s near: %s', $message, id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(32000)->truncateString($near));
     if ($this->getEngine()->isTextMode()) {
         return '(' . $message . ')';
     }
     return hsprintf('<div style="color: red;">%s</div>', $message);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $text = $request->getStr('text');
     $remarkup = new PHUIRemarkupView($viewer, $text);
     $content = array('content' => hsprintf('%s', $remarkup));
     return id(new AphrontAjaxResponse())->setContent($content);
 }
コード例 #25
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;
 }
コード例 #26
0
 public function buildSearchForm(AphrontFormView $form, PhabricatorSavedQuery $saved)
 {
     $form->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Name Contains'))->setName('nameContains')->setValue($saved->getParameter('nameContains')));
     $is_stable = $saved->getParameter('isStable');
     $is_unstable = $saved->getParameter('isUnstable');
     $is_deprecated = $saved->getParameter('isDeprecated');
     $form->appendChild(id(new AphrontFormCheckboxControl())->setLabel('Stability')->addCheckbox('isStable', 1, hsprintf('<strong>%s</strong>: %s', pht('Stable Methods'), pht('Show established API methods with stable interfaces.')), $is_stable)->addCheckbox('isUnstable', 1, hsprintf('<strong>%s</strong>: %s', pht('Unstable Methods'), pht('Show new methods which are subject to change.')), $is_unstable)->addCheckbox('isDeprecated', 1, hsprintf('<strong>%s</strong>: %s', pht('Deprecated Methods'), pht('Show old methods which will be deleted in a future ' . 'version of Phabricator.')), $is_deprecated));
 }
コード例 #27
0
 protected function buildHeaderPaneContent(ConpherenceThread $conpherence, array $policy_objects)
 {
     assert_instances_of($policy_objects, 'PhabricatorPolicy');
     $crumbs = $this->buildApplicationCrumbs();
     $data = $conpherence->getDisplayData($this->getViewer());
     $crumbs->addCrumb(id(new PHUICrumbView())->setName($data['title'])->setHref('/' . $conpherence->getMonogram()));
     return hsprintf('%s', array(phutil_tag('div', array('class' => 'header-loading-mask'), ''), $crumbs));
 }
コード例 #28
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $diff = id(new DifferentialDiffQuery())->setViewer($viewer)->withIDs(array($id))->executeOne();
     if (!$diff) {
         return new Aphront404Response();
     }
     if ($diff->getRevisionID()) {
         return id(new AphrontRedirectResponse())->setURI('/D' . $diff->getRevisionID() . '?id=' . $diff->getID());
     }
     $diff_phid = $diff->getPHID();
     $buildables = id(new HarbormasterBuildableQuery())->setViewer($viewer)->withBuildablePHIDs(array($diff_phid))->withManualBuildables(false)->needBuilds(true)->needTargets(true)->execute();
     $buildables = mpull($buildables, null, 'getBuildablePHID');
     $diff->attachBuildable(idx($buildables, $diff_phid));
     // TODO: implement optgroup support in AphrontFormSelectControl?
     $select = array();
     $select[] = hsprintf('<optgroup label="%s">', pht('Create New Revision'));
     $select[] = phutil_tag('option', array('value' => ''), pht('Create a new Revision...'));
     $select[] = hsprintf('</optgroup>');
     $selected_id = $request->getInt('revisionID');
     $revisions = $this->loadSelectableRevisions($viewer, $selected_id);
     if ($revisions) {
         $select[] = hsprintf('<optgroup label="%s">', pht('Update Existing Revision'));
         foreach ($revisions as $revision) {
             if ($selected_id == $revision->getID()) {
                 $selected = 'selected';
             } else {
                 $selected = null;
             }
             $select[] = phutil_tag('option', array('value' => $revision->getID(), 'selected' => $selected), id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(128)->truncateString('D' . $revision->getID() . ' ' . $revision->getTitle()));
         }
         $select[] = hsprintf('</optgroup>');
     }
     $select = phutil_tag('select', array('name' => 'revisionID'), $select);
     $form = id(new AphrontFormView())->setUser($request->getUser())->setAction('/differential/revision/edit/')->addHiddenInput('diffID', $diff->getID())->addHiddenInput('viaDiffView', 1)->addHiddenInput(id(new DifferentialRepositoryField())->getFieldKey(), $diff->getRepositoryPHID())->appendRemarkupInstructions(pht('Review the diff for correctness. When you are satisfied, either ' . '**create a new revision** or **update an existing revision**.'))->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Attach To'))->setValue($select))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Continue')));
     $props = id(new DifferentialDiffProperty())->loadAllWhere('diffID = %d', $diff->getID());
     $props = mpull($props, 'getData', 'getName');
     $property_head = id(new PHUIHeaderView())->setHeader(pht('Properties'));
     $property_view = new PHUIPropertyListView();
     $changesets = $diff->loadChangesets();
     $changesets = msort($changesets, 'getSortKey');
     $table_of_contents = $this->buildTableOfContents($changesets, $changesets, $diff->loadCoverageMap($viewer));
     $refs = array();
     foreach ($changesets as $changeset) {
         $refs[$changeset->getID()] = $changeset->getID();
     }
     $details = id(new DifferentialChangesetListView())->setChangesets($changesets)->setVisibleChangesets($changesets)->setRenderingReferences($refs)->setStandaloneURI('/differential/changeset/')->setDiff($diff)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTitle(pht('Diff %d', $diff->getID()))->setUser($request->getUser());
     $title = pht('Diff %d', $diff->getID());
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($title);
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader($title);
     $prop_box = id(new PHUIObjectBoxView())->setHeader($property_head)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->addPropertyList($property_view)->setForm($form);
     $view = id(new PHUITwoColumnView())->setHeader($header)->setMainColumn(array())->setFooter(array($prop_box, $table_of_contents, $details));
     $page = $this->newPage()->setTitle(pht('Diff View'))->setCrumbs($crumbs)->appendChild($view);
     return $page;
 }
コード例 #29
0
    public function processRequest(AphrontRequest $request)
    {
        $user = $request->getUser();
        $preferences = $user->loadPreferences();
        $pref_monospaced = PhabricatorUserPreferences::PREFERENCE_MONOSPACED;
        $pref_editor = PhabricatorUserPreferences::PREFERENCE_EDITOR;
        $pref_multiedit = PhabricatorUserPreferences::PREFERENCE_MULTIEDIT;
        $pref_titles = PhabricatorUserPreferences::PREFERENCE_TITLES;
        $pref_monospaced_textareas = PhabricatorUserPreferences::PREFERENCE_MONOSPACED_TEXTAREAS;
        $errors = array();
        $e_editor = null;
        if ($request->isFormPost()) {
            $monospaced = $request->getStr($pref_monospaced);
            // Prevent the user from doing stupid things.
            $monospaced = preg_replace('/[^a-z0-9 ,".]+/i', '', $monospaced);
            $preferences->setPreference($pref_titles, $request->getStr($pref_titles));
            $preferences->setPreference($pref_editor, $request->getStr($pref_editor));
            $preferences->setPreference($pref_multiedit, $request->getStr($pref_multiedit));
            $preferences->setPreference($pref_monospaced, $monospaced);
            $preferences->setPreference($pref_monospaced_textareas, $request->getStr($pref_monospaced_textareas));
            $editor_pattern = $preferences->getPreference($pref_editor);
            if (strlen($editor_pattern)) {
                $ok = PhabricatorHelpEditorProtocolController::hasAllowedProtocol($editor_pattern);
                if (!$ok) {
                    $allowed_key = 'uri.allowed-editor-protocols';
                    $allowed_protocols = PhabricatorEnv::getEnvConfig($allowed_key);
                    $proto_names = array();
                    foreach (array_keys($allowed_protocols) as $protocol) {
                        $proto_names[] = $protocol . '://';
                    }
                    $errors[] = pht('Editor link has an invalid or missing protocol. You must ' . 'use a whitelisted editor protocol from this list: %s. To ' . 'add protocols, update %s.', implode(', ', $proto_names), phutil_tag('tt', array(), $allowed_key));
                    $e_editor = pht('Invalid');
                }
            }
            if (!$errors) {
                $preferences->save();
                return id(new AphrontRedirectResponse())->setURI($this->getPanelURI('?saved=true'));
            }
        }
        $example_string = <<<EXAMPLE
// This is what your monospaced font currently looks like.
function helloWorld() {
  alert("Hello world!");
}
EXAMPLE;
        $editor_doc_link = phutil_tag('a', array('href' => PhabricatorEnv::getDoclink('User Guide: Configuring an External Editor')), pht('User Guide: Configuring an External Editor'));
        $font_default = PhabricatorEnv::getEnvConfig('style.monospace');
        $pref_monospaced_textareas_value = $preferences->getPreference($pref_monospaced_textareas);
        if (!$pref_monospaced_textareas_value) {
            $pref_monospaced_textareas_value = 'disabled';
        }
        $editor_instructions = pht('Link to edit files in external editor. ' . '%%f is replaced by filename, %%l by line number, %%r by repository ' . 'callsign, %%%% by literal %%. For documentation, see: %s', $editor_doc_link);
        $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Page Titles'))->setName($pref_titles)->setValue($preferences->getPreference($pref_titles))->setOptions(array('glyph' => pht("In page titles, show Tool names as unicode glyphs: " . "⚙"), 'text' => pht('In page titles, show Tool names as plain text: ' . '[Differential]'))))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Editor Link'))->setName($pref_editor)->setCaption($editor_instructions)->setError($e_editor)->setValue($preferences->getPreference($pref_editor)))->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Edit Multiple Files'))->setName($pref_multiedit)->setOptions(array('' => pht('Supported (paths separated by spaces)'), 'disable' => pht('Not Supported')))->setValue($preferences->getPreference($pref_multiedit)))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Monospaced Font'))->setName($pref_monospaced)->setCaption(hsprintf('%s<br />(%s: %s)', pht('Overrides default fonts in tools like Differential.'), pht('Default'), $font_default))->setValue($preferences->getPreference($pref_monospaced)))->appendChild(id(new AphrontFormMarkupControl())->setValue(phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $example_string)))->appendChild(id(new AphrontFormRadioButtonControl())->setLabel(pht('Monospaced Textareas'))->setName($pref_monospaced_textareas)->setValue($pref_monospaced_textareas_value)->addButton('enabled', pht('Enabled'), pht('Show all textareas using the monospaced font defined above.'))->addButton('disabled', pht('Disabled'), null));
        $form->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Save Preferences')));
        $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Display Preferences'))->setFormErrors($errors)->setFormSaved($request->getStr('saved') === 'true')->setForm($form);
        return array($form_box);
    }
コード例 #30
0
 public function getTitle()
 {
     $author_phid = $this->getAuthorPHID();
     $object_phid = $this->getObjectPHID();
     $old = $this->getOldValue();
     $new = $this->getNewValue();
     switch ($this->getTransactionType()) {
         case self::TYPE_REQUEST:
             return pht('%s requested %s', $this->renderHandleLink($author_phid), $this->renderHandleLink($new));
             break;
         case self::TYPE_USER_INTENT:
             return $this->getIntentTitle();
             break;
         case self::TYPE_EDIT_FIELD:
             $field = newv($this->getMetadataValue('fieldClass'), array());
             $name = $field->getName();
             $markup = $name;
             if ($this->getRenderingTarget() === parent::TARGET_HTML) {
                 $markup = hsprintf('<em>%s</em>', $name);
             }
             return pht('%s changed the %s to "%s"', $this->renderHandleLink($author_phid), $markup, $field->normalizeForTransactionView($this, $new));
             break;
         case self::TYPE_PICK_STATUS:
             switch ($new) {
                 case ReleephRequest::PICK_OK:
                     return pht('%s found this request picks without error', $this->renderHandleLink($author_phid));
                 case ReleephRequest::REVERT_OK:
                     return pht('%s found this request reverts without error', $this->renderHandleLink($author_phid));
                 case ReleephRequest::PICK_FAILED:
                     return pht("%s couldn't pick this request", $this->renderHandleLink($author_phid));
                 case ReleephRequest::REVERT_FAILED:
                     return pht("%s couldn't revert this request", $this->renderHandleLink($author_phid));
             }
             break;
         case self::TYPE_COMMIT:
             $action_type = $this->getMetadataValue('action');
             switch ($action_type) {
                 case 'pick':
                     return pht('%s picked this request and committed the result upstream', $this->renderHandleLink($author_phid));
                     break;
                 case 'revert':
                     return pht('%s reverted this request and committed the result upstream', $this->renderHandleLink($author_phid));
                     break;
             }
             break;
         case self::TYPE_MANUAL_IN_BRANCH:
             $action = $new ? pht('picked') : pht('reverted');
             return pht('%s marked this request as manually %s', $this->renderHandleLink($author_phid), $action);
             break;
         case self::TYPE_DISCOVERY:
             return pht('%s discovered this commit as %s', $this->renderHandleLink($author_phid), $this->renderHandleLink($new));
             break;
         default:
             return parent::getTitle();
             break;
     }
 }