コード例 #1
0
 private function renderProperties(PhameBlog $blog, PhabricatorUser $viewer, PhabricatorActionListView $actions)
 {
     require_celerity_resource('aphront-tooltip-css');
     Javelin::initBehavior('phabricator-tooltips');
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($blog)->setActionList($actions);
     $skin = $blog->getSkin();
     if (!$skin) {
         $skin = pht('(No external skin)');
     }
     $domain = $blog->getDomain();
     if (!$domain) {
         $domain = pht('(No external domain)');
     }
     $properties->addProperty(pht('Skin'), $skin);
     $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();
     if (strlen($blog->getDescription())) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()), 'default', $viewer);
         $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent($description);
     }
     return $properties;
 }
コード例 #2
0
 private function renderItemCommonProperties(PhabricatorUser $viewer, NuanceItem $item, PHUIPropertyListView $view)
 {
     $complaint = $item->getNuanceProperty('complaint');
     $complaint = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($complaint), 'default', $viewer);
     $view->addSectionHeader(pht('Complaint'), 'fa-exclamation-circle');
     $view->addTextContent($complaint);
 }
コード例 #3
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $books = id(new DivinerBookQuery())->setViewer($viewer)->execute();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $crumbs->addTextCrumb(pht('Books'));
     $query_button = id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI('query/'))->setText(pht('Advanced Search'))->setIcon('fa-search');
     $header = id(new PHUIHeaderView())->setHeader(pht('Documentation Books'))->addActionLink($query_button);
     $document = new PHUIDocumentViewPro();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     if ($books) {
         $books = msort($books, 'getTitle');
         $list = array();
         foreach ($books as $book) {
             $item = id(new DivinerBookItemView())->setTitle($book->getTitle())->setHref('/book/' . $book->getName() . '/')->setSubtitle($book->getPreface());
             $list[] = $item;
         }
         $list = id(new PHUIBoxView())->addPadding(PHUI::PADDING_MEDIUM_TOP)->appendChild($list);
         $document->appendChild($list);
     } else {
         $text = pht("(NOTE) **Looking for Phabricator documentation?** " . "If you're looking for help and information about Phabricator, " . "you can [[https://secure.phabricator.com/diviner/ | " . "browse the public Phabricator documentation]] on the live site.\n\n" . "Diviner is the documentation generator used to build the " . "Phabricator documentation.\n\n" . "You haven't generated any Diviner documentation books yet, so " . "there's nothing to show here. If you'd like to generate your own " . "local copy of the Phabricator documentation and have it appear " . "here, run this command:\n\n" . "  %s\n\n", 'phabricator/ $ ./bin/diviner generate');
         $text = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($text), 'default', $viewer);
         $document->appendChild($text);
     }
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => pht('Documentation Books')));
 }
コード例 #4
0
 public function renderPropertyViewValue(array $handles)
 {
     if (!strlen($this->getValue())) {
         return null;
     }
     return PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setContent($this->getValue()), 'default', $this->getViewer());
 }
コード例 #5
0
 public function appendRemarkupInstructions($remarkup)
 {
     if ($this->getUser() === null) {
         throw new Exception('Call `setUser` before appending Remarkup to PHUIFormLayoutView.');
     }
     return $this->appendInstructions(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($remarkup), 'default', $this->getUser()));
 }
コード例 #6
0
    public function renderExample()
    {
        $viewer = $this->getRequest()->getUser();
        $content = pht(<<<EOCONTENT
This is some **remarkup text** using ~~exactly one style~~ //various styles//.

  - Fruit
    - Apple
    - Banana
    - Cherry
  - Vegetables
    1. Carrot
    2. Celery

NOTE: This is a note.

(NOTE) This is also a note.

WARNING: This is a warning.

(WARNING) This is also a warning.

IMPORTANT: This is not really important.

(IMPORTANT) This isn't important either.

EOCONTENT
);
        $remarkup = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($content), 'default', $viewer);
        $frame = id(new PHUIBoxView())->addPadding(PHUI::PADDING_LARGE)->appendChild($remarkup);
        return id(new PHUIObjectBoxView())->setHeaderText(pht('Remarkup Example'))->appendChild($frame);
    }
コード例 #7
0
 protected function getTagContent()
 {
     require_celerity_resource('ponder-view-css');
     $answer = $this->answer;
     $viewer = $this->getUser();
     $author_phid = $answer->getAuthorPHID();
     $actions = $this->buildAnswerActions();
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setUser($viewer)->setEpoch($answer->getDateCreated())->setHeader($viewer->renderHandle($author_phid))->addActionLink($action_button);
     $content = phutil_tag('div', array('class' => 'phabricator-remarkup mlt mlb msr msl'), PhabricatorMarkupEngine::renderOneObject($answer, $answer->getMarkupField(), $viewer));
     $id = $answer->getID();
     $anchor = id(new PhabricatorAnchorView())->setAnchorName("A{$id}");
     $content_id = celerity_generate_unique_node_id();
     $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($this->transactions));
     $votes = $answer->getVoteCount();
     if ($votes) {
         $icon = id(new PHUIIconView())->setIconFont('fa-thumbs-up');
         $helpful = phutil_tag('span', array('class' => 'ponder-footer-action'), array($votes, $icon));
         $footer->addAction($helpful);
     }
     $answer_view = id(new PHUIObjectBoxView())->setHeader($header)->appendChild($anchor)->appendChild($content)->appendChild($footer);
     $transaction_view = id(new PhabricatorApplicationTransactionView())->setUser($viewer)->setObjectPHID($answer->getPHID())->setTransactions($this->transactions)->setMarkupEngine($this->engine);
     $comment_view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($answer->getPHID())->setShowPreview(false)->setHeaderText(pht('Answer Comment'))->setAction("/ponder/answer/comment/{$id}/")->setSubmitButtonName(pht('Comment'));
     $hidden_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($transaction_view, $comment_view));
     return array($answer_view, $hidden_view);
 }
コード例 #8
0
 public function appendRemarkupInstructions($remarkup)
 {
     if ($this->getUser() === null) {
         throw new PhutilInvalidStateException('setUser');
     }
     return $this->appendInstructions(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($remarkup), 'default', $this->getUser()));
 }
コード例 #9
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $books = id(new DivinerBookQuery())->setViewer($viewer)->execute();
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Books'));
     $search_icon = id(new PHUIIconView())->setIconFont('fa-search');
     $query_button = id(new PHUIButtonView())->setTag('a')->setHref($this->getApplicationURI('query/'))->setText(pht('Advanced Search'))->setIcon($search_icon);
     $header = id(new PHUIHeaderView())->setHeader(pht('Documentation Books'))->addActionLink($query_button);
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $document->addClass('diviner-view');
     if ($books) {
         $books = msort($books, 'getTitle');
         $list = array();
         foreach ($books as $book) {
             $item = id(new DivinerBookItemView())->setTitle($book->getTitle())->setHref('/book/' . $book->getName() . '/')->setSubtitle($book->getPreface());
             $list[] = $item;
         }
         $list = id(new PHUIBoxView())->addPadding(PHUI::PADDING_LARGE_LEFT)->addPadding(PHUI::PADDING_LARGE_RIGHT)->addPadding(PHUI::PADDING_SMALL_TOP)->addPadding(PHUI::PADDING_SMALL_BOTTOM)->appendChild($list);
         $document->appendChild($list);
     } else {
         $text = pht("(NOTE) **Looking for Phabricator documentation?** If you're looking " . "for help and information about Phabricator, you can " . "[[ https://secure.phabricator.com/diviner/ | browse the public " . "Phabricator documentation ]] on the live site.\n\n" . "Diviner is the documentation generator used to build the Phabricator " . "documentation.\n\n" . "You haven't generated any Diviner documentation books yet, so " . "there's nothing to show here. If you'd like to generate your own " . "local copy of the Phabricator documentation and have it appear " . "here, run this command:\n\n" . "  phabricator/ \$ ./bin/diviner generate\n\n" . "Right now, Diviner isn't very useful for generating documentation " . "for projects other than Phabricator. If you're interested in using " . "it in your own projects, leave feedback for us on " . "[[ https://secure.phabricator.com/T4558 | T4558 ]].");
         $text = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($text), 'default', $viewer);
         $document->appendChild($text);
     }
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => pht('Documentation Books'), 'fonts' => true));
 }
 private function buildPropertyView(PhabricatorApplication $application, PhabricatorActionListView $actions)
 {
     $viewer = $this->getRequest()->getUser();
     $properties = id(new PHUIPropertyListView());
     $properties->setActionList($actions);
     $properties->addProperty(pht('Description'), $application->getShortDescription());
     if ($application->getFlavorText()) {
         $properties->addProperty(null, phutil_tag('em', array(), $application->getFlavorText()));
     }
     if ($application->isPrototype()) {
         $proto_href = PhabricatorEnv::getDoclink('User Guide: Prototype Applications');
         $learn_more = phutil_tag('a', array('href' => $proto_href, 'target' => '_blank'), pht('Learn More'));
         $properties->addProperty(pht('Prototype'), pht('This application is a prototype. %s', $learn_more));
     }
     $overview = $application->getOverview();
     if ($overview) {
         $properties->addSectionHeader(pht('Overview'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent(PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($overview), 'default', $viewer));
     }
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $application);
     $properties->addSectionHeader(pht('Policies'), 'fa-lock');
     foreach ($application->getCapabilities() as $capability) {
         $properties->addProperty($application->getCapabilityLabel($capability), idx($descriptions, $capability));
     }
     return $properties;
 }
コード例 #11
0
 protected function getTagContent()
 {
     require_celerity_resource('ponder-view-css');
     $answer = $this->answer;
     $viewer = $this->getUser();
     $status = $answer->getStatus();
     $author_phid = $answer->getAuthorPHID();
     $actions = $this->buildAnswerActions();
     $handle = $this->handle;
     $id = $answer->getID();
     if ($status == PonderAnswerStatus::ANSWER_STATUS_HIDDEN) {
         $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $answer, PhabricatorPolicyCapability::CAN_EDIT);
         $message = array();
         $message[] = phutil_tag('em', array(), pht('This answer has been hidden.'));
         if ($can_edit) {
             $message[] = phutil_tag('a', array('href' => "/ponder/answer/edit/{$id}/"), pht('Edit Answer'));
         }
         $message = phutil_implode_html(' ', $message);
         return id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NODATA)->appendChild($message);
     }
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIcon('fa-bars')->setDropdownMenu($actions);
     $header_name = phutil_tag('a', array('href' => $handle->getURI()), $handle->getName());
     $header = id(new PHUIHeaderView())->setUser($viewer)->setEpoch($answer->getDateModified())->setHeader($header_name)->addActionLink($action_button)->setImage($handle->getImageURI())->setImageURL($handle->getURI());
     $content = phutil_tag('div', array('class' => 'phabricator-remarkup'), PhabricatorMarkupEngine::renderOneObject($answer, $answer->getMarkupField(), $viewer));
     $anchor = id(new PhabricatorAnchorView())->setAnchorName("A{$id}");
     $content_id = celerity_generate_unique_node_id();
     $footer = id(new PonderFooterView())->setContentID($content_id)->setCount(count($this->transactions));
     $content = phutil_tag_div('ponder-answer-content', array($anchor, $content, $footer));
     $answer_view = id(new PHUIObjectBoxView())->setHeader($header)->setBackground(PHUIObjectBoxView::GREY)->addClass('ponder-answer')->appendChild($content);
     $comment_view = id(new PhabricatorApplicationTransactionCommentView())->setUser($viewer)->setObjectPHID($answer->getPHID())->setShowPreview(false)->setHeaderText(pht('Answer Comment'))->setAction("/ponder/answer/comment/{$id}/")->setSubmitButtonName(pht('Comment'));
     $hidden_view = phutil_tag('div', array('id' => $content_id, 'style' => 'display: none;'), array($this->timeline, $comment_view));
     return array($answer_view, $hidden_view);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $class = $request->getURIData('class');
     $sources = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorTypeaheadDatasource')->loadObjects();
     if (!isset($sources[$class])) {
         return new Aphront404Response();
     }
     $source = $sources[$class];
     $application_class = $source->getDatasourceApplicationClass();
     if ($application_class) {
         $result = id(new PhabricatorApplicationQuery())->setViewer($this->getViewer())->withClasses(array($application_class))->execute();
         if (!$result) {
             return new Aphront404Response();
         }
     }
     $source->setViewer($viewer);
     $title = pht('Typeahead Function Help');
     $functions = $source->getAllDatasourceFunctions();
     ksort($functions);
     $content = array();
     $content[] = '= ' . pht('Overview');
     $content[] = pht('Typeahead functions are an advanced feature which allow you to build ' . 'more powerful queries. This document explains functions available ' . 'for the selected control.' . "\n\n" . 'For general help with search, see the [[ %s | Search User Guide ]] in ' . 'the documentation.' . "\n\n" . 'Note that different controls support //different// functions ' . '(depending on what the control is doing), so these specific functions ' . 'may not work everywhere. You can always check the help for a control ' . 'to review which functions are available for that control.', PhabricatorEnv::getDoclink('Search User Guide'));
     $table = array();
     $table_header = array(pht('Function'), pht('Token Name'), pht('Summary'));
     $table[] = '| ' . implode(' | ', $table_header) . ' |';
     $table[] = '|---|---|---|';
     foreach ($functions as $function => $spec) {
         $spec = $spec + array('summary' => null, 'arguments' => null);
         if (idx($spec, 'arguments')) {
             $signature = '**' . $function . '(**//' . $spec['arguments'] . '//**)**';
         } else {
             $signature = '**' . $function . '()**';
         }
         $name = idx($spec, 'name', '');
         $summary = idx($spec, 'summary', '');
         $table[] = '| ' . $signature . ' | ' . $name . ' | ' . $summary . ' |';
     }
     $table = implode("\n", $table);
     $content[] = '= ' . pht('Function Quick Reference');
     $content[] = pht('This table briefly describes available functions for this control. ' . 'For details on a particular function, see the corresponding section ' . 'below.');
     $content[] = $table;
     $content[] = '= ' . pht('Using Typeahead Functions');
     $content[] = pht("In addition to typing user and project names to build queries, you can " . "also type the names of special functions which give you more options " . "and the ability to express more complex queries.\n\n" . "Functions have an internal name (like `%s`) and a human-readable name, " . "like `Current Viewer`. In general, you can type either one to select " . "the function. You can also click the {nav icon=search} button on any " . "typeahead control to browse available functions and find this " . "documentation.\n\n" . "This documentation uses the internal names to make it clear where " . "tokens begin and end. Specifically, you will find queries written " . "out like this in the documentation:\n\n%s\n\n" . "When this query is actually shown in the control, it will look more " . "like this:\n\n%s", 'viewer()', '> viewer(), alincoln', '> {nav Current Viewer} {nav alincoln (Abraham Lincoln)}');
     $middot = "·";
     foreach ($functions as $function => $spec) {
         $arguments = idx($spec, 'arguments', '');
         $name = idx($spec, 'name');
         $content[] = '= ' . $function . '(' . $arguments . ') ' . $middot . ' ' . $name;
         $content[] = $spec['description'];
     }
     $content = implode("\n\n", $content);
     $content_box = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($content), 'default', $viewer);
     $header = id(new PHUIHeaderView())->setHeader($title);
     $document = id(new PHUIDocumentView())->setHeader($header)->appendChild($content_box);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb(pht('Function Help'));
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $title));
 }
コード例 #13
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $text = $request->getStr('text');
     $output = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setContent($text), 'default', $viewer);
     return id(new AphrontAjaxResponse())->setContent($output);
 }
コード例 #14
0
 public function renderPropertyViewValue(array $handles)
 {
     $blurb = $this->getObject()->loadUserProfile()->getBlurb();
     if (!strlen($blurb)) {
         return null;
     }
     return PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($blurb), 'default', $this->getViewer());
 }
コード例 #15
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $body = $request->getStr('body');
     $post = id(new PhamePost())->setBody($body);
     $content = PhabricatorMarkupEngine::renderOneObject($post, PhamePost::MARKUP_FIELD_BODY, $viewer);
     $content = phutil_tag_div('phabricator-remarkup', $content);
     return id(new AphrontAjaxResponse())->setContent($content);
 }
コード例 #16
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $text = $request->getStr('text');
     $slug = $request->getURIData('slug');
     $output = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setDisableCache(true)->setContent($text), 'default', $viewer, array('phriction.isPreview' => true, 'phriction.slug' => $slug));
     return id(new AphrontAjaxResponse())->setContent($output);
 }
コード例 #17
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $description = $request->getStr('description');
     $task = new ManiphestTask();
     $task->setDescription($description);
     $output = PhabricatorMarkupEngine::renderOneObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION, $request->getUser());
     $content = phutil_tag_div('phabricator-remarkup', $output);
     return id(new AphrontAjaxResponse())->setContent($content);
 }
コード例 #18
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $description = $request->getStr('description');
     $task = new ManiphestTask();
     $task->setDescription($description);
     $output = PhabricatorMarkupEngine::renderOneObject($task, ManiphestTask::MARKUP_FIELD_DESCRIPTION);
     $content = '<div class="phabricator-remarkup">' . $output . '</div>';
     return id(new AphrontAjaxResponse())->setContent($content);
 }
コード例 #19
0
 public function render()
 {
     $viewer = $this->getUser();
     $corpus = $this->corpus;
     $content = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setContent($corpus), 'default', $viewer);
     if ($this->markupType == self::DOCUMENT) {
         return phutil_tag('div', array('class' => 'phabricator-remarkup phui-document-view'), $content);
     }
     return $content;
 }
コード例 #20
0
 protected function renderCartDescription(PhortuneCart $cart)
 {
     $description = $cart->getDescription();
     if (!strlen($description)) {
         return null;
     }
     $output = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setPreserveLinebreaks(true)->setContent($description), 'default', $this->getViewer());
     $box = id(new PHUIBoxView())->addMargin(PHUI::MARGIN_LARGE)->appendChild($output);
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Description'))->appendChild($box);
 }
コード例 #21
0
 private function buildPropertyView(PhabricatorSlowvotePoll $poll, PhabricatorActionListView $actions)
 {
     $viewer = $this->getRequest()->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($poll)->setActionList($actions);
     $view->invokeWillRenderEvent();
     if (strlen($poll->getDescription())) {
         $view->addTextContent($output = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($poll->getDescription()), 'default', $viewer));
     }
     return $view;
 }
コード例 #22
0
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $book_name = $request->getURIData('book');
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($book_name))->needRepositories(true)->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $actions = $this->buildActionView($viewer, $book);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->setBorder(true);
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $action_button = id(new PHUIButtonView())->setTag('a')->setText(pht('Actions'))->setHref('#')->setIconFont('fa-bars')->addClass('phui-mobile-menu')->setDropdownMenu($actions);
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book)->setEpoch($book->getDateModified())->addActionLink($action_button);
     // TODO: This could probably look better.
     if ($book->getRepositoryPHID()) {
         $header->addTag(id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_BLUE)->setName($book->getRepository()->getMonogram()));
     }
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->withGhosts(false)->withIsDocumentable(true)->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
コード例 #23
0
 private function buildPropertyListView(PonderQuestion $question, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($question)->setActionList($actions);
     $view->addProperty(pht('Author'), $viewer->renderHandle($question->getAuthorPHID()));
     $view->addProperty(pht('Created'), phabricator_datetime($question->getDateCreated(), $viewer));
     $view->invokeWillRenderEvent();
     $view->addSectionHeader(pht('Question'));
     $view->addTextContent(array(phutil_tag('div', array('class' => 'phabricator-remarkup'), PhabricatorMarkupEngine::renderOneObject($question, $question->getMarkupField(), $viewer))));
     return $view;
 }
コード例 #24
0
 public function renderPropertyViewValue(array $handles)
 {
     $value = $this->getFieldValue();
     if (!strlen($value)) {
         return null;
     }
     // TODO: Once this stabilizes, it would be nice to let fields batch this.
     // For now, an extra query here and there on object detail pages isn't the
     // end of the world.
     $viewer = $this->getViewer();
     return PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($value)->setPReserveLinebreaks(true), 'default', $viewer);
 }
コード例 #25
0
 private function buildPropertyView(PhabricatorPhurlURL $url)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($url);
     $properties->addProperty(pht('Original URL'), $url->getLongURL());
     $properties->invokeWillRenderEvent();
     if (strlen($url->getDescription())) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($url->getDescription()), 'default', $viewer);
         $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent($description);
     }
     return $properties;
 }
コード例 #26
0
 private function renderContextualProjectDescription(PhabricatorConfigOption $option, AphrontRequest $request)
 {
     $viewer = $request->getUser();
     $publishers = id(new PhutilSymbolLoader())->setAncestorClass('DoorkeeperFeedStoryPublisher')->loadObjects();
     $out = array();
     $out[] = pht('To specify projects to add tasks to, enter a JSON map with publisher ' . 'class names as keys and a list of project IDs as values. For example, ' . 'to put Differential tasks into Asana projects with IDs `123` and ' . '`456`, enter:' . "\n\n" . "  lang=txt\n" . "  {\n" . "    \"DifferentialDoorkeeperRevisionFeedStoryPublisher\" : [123, 456]\n" . "  }\n");
     $out[] = pht('Available publishers class names are:');
     foreach ($publishers as $publisher) {
         $out[] = '  - `' . get_class($publisher) . '`';
     }
     $out[] = pht('You can find an Asana project ID by clicking the project in Asana and ' . 'then examining the URL:' . "\n\n" . "  lang=txt\n" . "  https://app.asana.com/0/12345678901234567890/111111111111111111\n" . "                          ^^^^^^^^^^^^^^^^^^^^\n" . "                        This is the ID to use.\n");
     $out = implode("\n", $out);
     return PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($out), 'default', $viewer);
 }
コード例 #27
0
 private function buildPropertyListView(PhabricatorCountdown $countdown, PhabricatorActionListView $actions)
 {
     $viewer = $this->getViewer();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($countdown)->setActionList($actions);
     $view->addProperty(pht('Author'), $viewer->renderHandle($countdown->getAuthorPHID()));
     $view->invokeWillRenderEvent();
     $description = $countdown->getDescription();
     if (strlen($description)) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($description), 'default', $viewer);
         $view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent($description);
     }
     return $view;
 }
コード例 #28
0
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $book = id(new DivinerBookQuery())->setViewer($viewer)->withNames(array($this->bookName))->executeOne();
     if (!$book) {
         return new Aphront404Response();
     }
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($book->getShortTitle(), '/book/' . $book->getName() . '/');
     $header = id(new PHUIHeaderView())->setHeader($book->getTitle())->setUser($viewer)->setPolicyObject($book);
     $document = new PHUIDocumentView();
     $document->setHeader($header);
     $document->addClass('diviner-view');
     $document->setFontKit(PHUIDocumentView::FONT_SOURCE_SANS);
     $properties = $this->buildPropertyList($book);
     $atoms = id(new DivinerAtomQuery())->setViewer($viewer)->withBookPHIDs(array($book->getPHID()))->execute();
     $atoms = msort($atoms, 'getSortKey');
     $group_spec = $book->getConfig('groups');
     if (!is_array($group_spec)) {
         $group_spec = array();
     }
     $groups = mgroup($atoms, 'getGroupName');
     $groups = array_select_keys($groups, array_keys($group_spec)) + $groups;
     if (isset($groups[''])) {
         $no_group = $groups[''];
         unset($groups['']);
         $groups[''] = $no_group;
     }
     $out = array();
     foreach ($groups as $group => $atoms) {
         $group_name = $book->getGroupName($group);
         if (!strlen($group_name)) {
             $group_name = pht('Free Radicals');
         }
         $section = id(new DivinerSectionView())->setHeader($group_name);
         $section->addContent($this->renderAtomList($atoms));
         $out[] = $section;
     }
     $preface = $book->getPreface();
     $preface_view = null;
     if (strlen($preface)) {
         $preface_view = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($preface), 'default', $viewer);
     }
     $document->appendChild($properties);
     $document->appendChild($preface_view);
     $document->appendChild($out);
     return $this->buildApplicationPage(array($crumbs, $document), array('title' => $book->getTitle()));
 }
コード例 #29
0
 private function buildPropertyListView(PhabricatorSpacesNamespace $space)
 {
     $viewer = $this->getRequest()->getUser();
     $list = id(new PHUIPropertyListView())->setUser($viewer);
     $list->addProperty(pht('Default Space'), $space->getIsDefaultNamespace() ? pht('Yes') : pht('No'));
     $descriptions = PhabricatorPolicyQuery::renderPolicyDescriptions($viewer, $space);
     $list->addProperty(pht('Editable By'), $descriptions[PhabricatorPolicyCapability::CAN_EDIT]);
     $description = $space->getDescription();
     if (strlen($description)) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($description), 'default', $viewer);
         $list->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $list->addTextContent($description);
     }
     return $list;
 }
コード例 #30
0
 private function renderDescription(PhameBlog $blog, PhabricatorUser $viewer)
 {
     require_celerity_resource('phame-css');
     if (strlen($blog->getDescription())) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($blog->getDescription()), 'default', $viewer);
     } else {
         $description = phutil_tag('em', array(), pht('No description.'));
     }
     $picture = $blog->getProfileImageURI();
     $description = phutil_tag_div('phame-blog-description-content', $description);
     $image = phutil_tag('div', array('class' => 'phame-blog-description-image', 'style' => 'background-image: url(' . $picture . ');'));
     $header = phutil_tag('div', array('class' => 'phame-blog-description-name'), pht('About %s', $blog->getName()));
     $view = phutil_tag('div', array('class' => 'phame-blog-description'), array($image, $header, $description));
     return $view;
 }