public function render()
 {
     if (!$this->handle) {
         throw new PhutilInvalidStateException('setObjectHandle');
     }
     $viewer = $this->getUser();
     $handle = $this->handle;
     require_celerity_resource('phabricator-hovercard-view-css');
     $title = array(id(new PHUISpacesNamespaceContextView())->setUser($viewer)->setObject($this->getObject()), pht('%s: %s', $handle->getTypeName(), $this->title ? $this->title : $handle->getName()));
     $header = new PHUIActionHeaderView();
     $header->setHeaderColor($this->color);
     $header->setHeaderTitle($title);
     if ($this->tags) {
         foreach ($this->tags as $tag) {
             $header->setTag($tag);
         }
     }
     $body = array();
     if ($this->detail) {
         $body_title = $this->detail;
     } else {
         // Fallback for object handles
         $body_title = $handle->getFullName();
     }
     $body[] = phutil_tag_div('phabricator-hovercard-body-header', $body_title);
     foreach ($this->fields as $field) {
         $item = array(phutil_tag('strong', array(), $field['label']), ' ', phutil_tag('span', array(), $field['value']));
         $body[] = phutil_tag_div('phabricator-hovercard-body-item', $item);
     }
     if ($handle->getImageURI()) {
         // Probably a user, we don't need to assume something else
         // "Prepend" the image by appending $body
         $body = phutil_tag('div', array('class' => 'phabricator-hovercard-body-image'), phutil_tag('div', array('class' => 'profile-header-picture-frame', 'style' => 'background-image: url(' . $handle->getImageURI() . ');'), ''))->appendHTML(phutil_tag('div', array('class' => 'phabricator-hovercard-body-details'), $body));
     }
     $buttons = array();
     foreach ($this->actions as $action) {
         $options = array('class' => 'button grey', 'href' => $action['uri']);
         if ($action['workflow']) {
             $options['sigil'] = 'workflow';
             $buttons[] = javelin_tag('a', $options, $action['label']);
         } else {
             $buttons[] = phutil_tag('a', $options, $action['label']);
         }
     }
     $tail = null;
     if ($buttons) {
         $tail = phutil_tag_div('phabricator-hovercard-tail', $buttons);
     }
     // Assemble container
     // TODO: Add color support
     $hovercard = phutil_tag_div('phabricator-hovercard-container', array(phutil_tag_div('phabricator-hovercard-head', $header), phutil_tag_div('phabricator-hovercard-body grouped', $body), $tail));
     // Wrap for thick border
     // and later the tip at the bottom
     return phutil_tag_div('phabricator-hovercard-wrapper', $hovercard);
 }
Пример #2
0
 public function buildView()
 {
     if (!$this->user) {
         throw new PhutilInvalidStateException('setUser');
     }
     $user = $this->user;
     $stories = $this->stories;
     $null_view = new AphrontNullView();
     require_celerity_resource('phabricator-feed-css');
     $last_date = null;
     foreach ($stories as $story) {
         $story->setFramed($this->framed);
         $story->setHovercard($this->hovercards);
         $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user));
         if ($date !== $last_date) {
             if ($last_date !== null) {
                 $null_view->appendChild(phutil_tag_div('phabricator-feed-story-date-separator'));
             }
             $last_date = $date;
             $header = new PHUIActionHeaderView();
             $header->setHeaderTitle($date);
             $null_view->appendChild($header);
         }
         try {
             $view = $story->renderView();
             $view->setUser($user);
             $view = $view->render();
         } catch (Exception $ex) {
             // If rendering failed for any reason, don't fail the entire feed,
             // just this one story.
             $view = id(new PHUIFeedStoryView())->setUser($user)->setChronologicalKey($story->getChronologicalKey())->setEpoch($story->getEpoch())->setTitle(pht('Feed Story Failed to Render (%s)', get_class($story)))->appendChild(pht('%s: %s', get_class($ex), $ex->getMessage()));
         }
         $null_view->appendChild($view);
     }
     if (empty($stories)) {
         $nodatastring = pht('No Stories.');
         if ($this->noDataString) {
             $nodatastring = $this->noDataString;
         }
         $view = id(new PHUIInfoView())->setSeverity(PHUIInfoView::SEVERITY_NODATA)->appendChild($nodatastring);
         $null_view->appendChild($view);
     }
     return id(new AphrontNullView())->appendChild($null_view->render());
 }
 private function newItem(AphrontRequest $request, $title, $done, $content)
 {
     $viewer = $request->getUser();
     $box = new PHUIObjectBoxView();
     $header = new PHUIActionHeaderView();
     $header->setHeaderTitle($title);
     if ($done === true) {
         $box->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTGREEN);
         $header->addAction(id(new PHUIIconView())->setIconFont('fa-check'));
     } else {
         if ($done === false) {
             $box->setHeaderColor(PHUIActionHeaderView::HEADER_LIGHTVIOLET);
             $header->addAction(id(new PHUIIconView())->setIconFont('fa-exclamation'));
         }
     }
     $content = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($content), 'default', $viewer);
     $content = phutil_tag('div', array('class' => 'config-welcome-box-content'), $content);
     $box->setHeader($header);
     $box->appendChild($content);
     return $box;
 }
Пример #4
0
 public final function render()
 {
     require_celerity_resource('aphront-dialog-view-css');
     $buttons = array();
     if ($this->submitButton) {
         $meta = array();
         if ($this->disableWorkflowOnSubmit) {
             $meta['disableWorkflow'] = true;
         }
         $buttons[] = javelin_tag('button', array('name' => '__submit__', 'sigil' => '__default__', 'type' => 'submit', 'meta' => $meta), $this->submitButton);
     }
     if ($this->cancelURI) {
         $meta = array();
         if ($this->disableWorkflowOnCancel) {
             $meta['disableWorkflow'] = true;
         }
         $buttons[] = javelin_tag('a', array('href' => $this->cancelURI, 'class' => 'button grey', 'name' => '__cancel__', 'sigil' => 'jx-workflow-button', 'meta' => $meta), $this->cancelText);
     }
     if (!$this->user) {
         throw new Exception(pht('You must call setUser() when rendering an AphrontDialogView.'));
     }
     $more = $this->class;
     if ($this->flush) {
         $more .= ' aphront-dialog-flush';
     }
     switch ($this->width) {
         case self::WIDTH_FORM:
         case self::WIDTH_FULL:
             $more .= ' aphront-dialog-view-width-' . $this->width;
             break;
         case self::WIDTH_DEFAULT:
             break;
         default:
             throw new Exception("Unknown dialog width '{$this->width}'!");
     }
     if ($this->isStandalone) {
         $more .= ' aphront-dialog-view-standalone';
     }
     $attributes = array('class' => 'aphront-dialog-view ' . $more, 'sigil' => 'jx-dialog');
     $form_attributes = array('action' => $this->submitURI, 'method' => $this->method, 'id' => $this->formID);
     $hidden_inputs = array();
     $hidden_inputs[] = phutil_tag('input', array('type' => 'hidden', 'name' => '__dialog__', 'value' => '1'));
     foreach ($this->hidden as $desc) {
         list($key, $value) = $desc;
         $hidden_inputs[] = javelin_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value, 'sigil' => 'aphront-dialog-application-input'));
     }
     if (!$this->renderAsForm) {
         $buttons = array(phabricator_form($this->user, $form_attributes, array_merge($hidden_inputs, $buttons)));
     }
     $children = $this->renderChildren();
     $errors = $this->errors;
     $ex = $this->validationException;
     $exception_errors = null;
     if ($ex) {
         foreach ($ex->getErrors() as $error) {
             $errors[] = $error->getMessage();
         }
     }
     if ($errors) {
         $children = array(id(new AphrontErrorView())->setErrors($errors), $children);
     }
     $header = new PHUIActionHeaderView();
     $header->setHeaderTitle($this->title);
     $header->setHeaderColor($this->headerColor);
     $footer = null;
     if ($this->footers) {
         $footer = phutil_tag('div', array('class' => 'aphront-dialog-foot'), $this->footers);
     }
     $content = array(phutil_tag('div', array('class' => 'aphront-dialog-head'), $header), phutil_tag('div', array('class' => 'aphront-dialog-body grouped'), $children), phutil_tag('div', array('class' => 'aphront-dialog-tail grouped'), array($buttons, $footer)));
     if ($this->renderAsForm) {
         return phabricator_form($this->user, $form_attributes + $attributes, array($hidden_inputs, $content));
     } else {
         return javelin_tag('div', $attributes, $content);
     }
 }