protected function getTagContent()
 {
     $user = $this->profile;
     $profile = $user->loadUserProfile();
     $picture = $user->getProfileImageURI();
     $viewer = $this->viewer;
     require_celerity_resource('project-card-view-css');
     $profile_icon = PhabricatorPeopleIconSet::getIconIcon($profile->getIcon());
     $profile_title = $profile->getDisplayTitle();
     $tag = id(new PHUITagView())->setIcon($profile_icon)->setName($profile_title)->addClass('project-view-header-tag')->setType(PHUITagView::TYPE_SHADE);
     $header = id(new PHUIHeaderView())->setHeader(array($user->getFullName(), $tag))->setUser($viewer)->setImage($picture);
     $body = array();
     $body[] = $this->addItem(pht('User Since'), phabricator_date($profile->getDateCreated(), $viewer));
     if (PhabricatorApplication::isClassInstalledForViewer('PhabricatorCalendarApplication', $viewer)) {
         $body[] = $this->addItem(pht('Availability'), id(new PHUIUserAvailabilityView())->setViewer($viewer)->setAvailableUser($user));
     }
     $badges = $this->buildBadges($user, $viewer);
     if ($badges) {
         $badges = id(new PHUIBadgeBoxView())->addItems($badges)->setCollapsed(true);
         $body[] = phutil_tag('div', array('class' => 'phui-hovercard-body-item hovercard-badges'), $badges);
     }
     $body = phutil_tag('div', array('class' => 'project-card-body'), $body);
     $card = phutil_tag('div', array('class' => 'project-card-inner'), array($header, $body));
     return $card;
 }
 private function handleHovercardEvent($event)
 {
     $viewer = $event->getUser();
     $hovercard = $event->getValue('hovercard');
     $object_handle = $event->getValue('handle');
     $commit = $event->getValue('object');
     if (!$commit instanceof PhabricatorRepositoryCommit) {
         return;
     }
     $commit_data = $commit->loadCommitData();
     $revision = PhabricatorEdgeQuery::loadDestinationPHIDs($commit->getPHID(), PhabricatorEdgeConfig::TYPE_COMMIT_HAS_DREV);
     $revision = reset($revision);
     $author = $commit->getAuthorPHID();
     $phids = array_filter(array($revision, $author));
     $handles = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs($phids)->execute();
     if ($author) {
         $author = $handles[$author]->renderLink();
     } else {
         $author = phutil_tag('em', array(), $commit_data->getAuthorName());
     }
     $hovercard->setTitle($object_handle->getName());
     $hovercard->setDetail($commit->getSummary());
     $hovercard->addField(pht('Author'), $author);
     $hovercard->addField(pht('Date'), phabricator_date($commit->getEpoch(), $viewer));
     if ($commit->getAuditStatus() != PhabricatorAuditCommitStatusConstants::NONE) {
         $hovercard->addField(pht('Audit Status'), PhabricatorAuditCommitStatusConstants::getStatusName($commit->getAuditStatus()));
     }
     if ($revision) {
         $rev_handle = $handles[$revision];
         $hovercard->addField(pht('Revision'), $rev_handle->renderLink());
     }
     $event->setValue('hovercard', $hovercard);
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $mails = id(new PhabricatorMetaMTAReceivedMail())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $mails = $pager->sliceResults($mails);
     $phids = array_merge(mpull($mails, 'getAuthorPHID'), mpull($mails, 'getRelatedPHID'));
     $phids = array_unique(array_filter($phids));
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     foreach ($mails as $mail) {
         $rows[] = array($mail->getID(), phabricator_date($mail->getDateCreated(), $user), phabricator_time($mail->getDateCreated(), $user), $mail->getAuthorPHID() ? $handles[$mail->getAuthorPHID()]->renderLink() : '-', $mail->getRelatedPHID() ? $handles[$mail->getRelatedPHID()]->renderLink() : '-', phutil_escape_html($mail->getMessage()));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Date', 'Time', 'Author', 'Object', 'Message'));
     $table->setColumnClasses(array(null, null, 'right', null, null, 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Received Mail');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav = $this->buildSideNavView();
     $nav->selectFilter('received');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'Received Mail'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $views = array(self::VIEW_ALL => 'All Slowvotes', self::VIEW_CREATED => 'Created', self::VIEW_VOTED => 'Voted In');
     $view = isset($views[$this->view]) ? $this->view : self::VIEW_ALL;
     $side_nav = $this->renderSideNav($views, $view);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $polls = $this->loadPolls($pager, $view);
     $phids = mpull($polls, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $rows = array();
     foreach ($polls as $poll) {
         $rows[] = array('V' . $poll->getID(), phutil_render_tag('a', array('href' => '/V' . $poll->getID()), phutil_escape_html($poll->getQuestion())), $handles[$poll->getAuthorPHID()]->renderLink(), phabricator_date($poll->getDateCreated(), $user), phabricator_time($poll->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setColumnClasses(array('', 'pri wide', '', '', 'right'));
     $table->setHeaders(array('ID', 'Poll', 'Author', 'Date', 'Time'));
     $panel = new AphrontPanelView();
     $panel->setHeader($this->getTableHeader($view));
     $panel->setCreateButton('Create Slowvote', '/vote/create/');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $side_nav->appendChild($panel);
     return $this->buildStandardPageResponse($side_nav, array('title' => 'Slowvotes'));
 }
 public function renderHovercard(PHUIHovercardView $hovercard, PhabricatorObjectHandle $handle, $object, $data)
 {
     $viewer = $this->getViewer();
     $user = idx($data['users'], $object->getPHID());
     if (!$user) {
         return;
     }
     $hovercard->setTitle($user->getUsername());
     $profile = $user->getUserProfile();
     $detail = $user->getRealName();
     if ($profile->getTitle()) {
         $detail .= ' - ' . $profile->getTitle();
     }
     $hovercard->setDetail($detail);
     if ($user->getIsDisabled()) {
         $hovercard->addField(pht('Account'), pht('Disabled'));
     } else {
         if (!$user->isUserActivated()) {
             $hovercard->addField(pht('Account'), pht('Not Activated'));
         } else {
             if (PhabricatorApplication::isClassInstalledForViewer('PhabricatorCalendarApplication', $viewer)) {
                 $hovercard->addField(pht('Status'), $user->getAvailabilityDescription($viewer));
             }
         }
     }
     $hovercard->addField(pht('User Since'), phabricator_date($user->getDateCreated(), $viewer));
     if ($profile->getBlurb()) {
         $hovercard->addField(pht('Blurb'), id(new PhutilUTF8StringTruncator())->setMaximumGlyphs(120)->truncateString($profile->getBlurb()));
     }
     $badges = $this->buildBadges($user, $viewer);
     foreach ($badges as $badge) {
         $hovercard->addBadge($badge);
     }
 }
 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->daemonLogs as $log) {
         $epoch = $log->getDateCreated();
         if ($log->getHost() == php_uname('n')) {
             $pid = $log->getPID();
             $is_running = PhabricatorDaemonReference::isProcessRunning($pid);
             if ($is_running) {
                 $running = phutil_render_tag('span', array('style' => 'color: #00cc00', 'title' => 'Running'), '•');
             } else {
                 $running = phutil_render_tag('span', array('style' => 'color: #cc0000', 'title' => 'Not running'), '•');
             }
         } else {
             $running = phutil_render_tag('span', array('style' => 'color: #888888', 'title' => 'Not on this host'), '?');
         }
         $rows[] = array($running, phutil_escape_html($log->getDaemon()), phutil_escape_html($log->getHost()), $log->getPID(), phabricator_date($epoch, $this->user), phabricator_time($epoch, $this->user), phutil_render_tag('a', array('href' => '/daemon/log/' . $log->getID() . '/', 'class' => 'button small grey'), 'View Log'));
     }
     $daemon_table = new AphrontTableView($rows);
     $daemon_table->setHeaders(array('', 'Daemon', 'Host', 'PID', 'Date', 'Time', 'View'));
     $daemon_table->setColumnClasses(array('', 'wide wrap', '', '', '', 'right', 'action'));
     return $daemon_table->render();
 }
 public function render()
 {
     $user = $this->user;
     if (!$user) {
         throw new Exception("Call setUser() before render()!");
     }
     $rows = array();
     foreach ($this->revisions as $revision) {
         $status = $revision->getStatus();
         $status = DifferentialRevisionStatus::getNameForRevisionStatus($status);
         $reviewer_phids = $revision->getReviewers();
         if ($reviewer_phids) {
             $first = reset($reviewer_phids);
             if (count($reviewer_phids) > 1) {
                 $suffix = ' (+' . (count($reviewer_phids) - 1) . ')';
             } else {
                 $suffix = null;
             }
             $reviewers = $this->handles[$first]->renderLink() . $suffix;
         } else {
             $reviewers = '<em>None</em>';
         }
         $link = phutil_render_tag('a', array('href' => '/D' . $revision->getID()), phutil_escape_html($revision->getTitle()));
         $rows[] = array('D' . $revision->getID(), $link, phutil_escape_html($status), number_format($revision->getLineCount()), $this->handles[$revision->getAuthorPHID()]->renderLink(), $reviewers, phabricator_datetime($revision->getDateModified(), $user), phabricator_date($revision->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('ID', 'Revision', 'Status', 'Lines', 'Author', 'Reviewers', 'Updated', 'Created'));
     $table->setColumnClasses(array(null, 'wide pri', null, 'n', null, null, 'right', 'right'));
     if ($this->noDataString) {
         $table->setNoDataString($this->noDataString);
     }
     return $table->render();
 }
 protected function renderResultList(array $pastes, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($pastes, 'PhabricatorPaste');
     $viewer = $this->requireViewer();
     $lang_map = PhabricatorEnv::getEnvConfig('pygments.dropdown-choices');
     $list = new PHUIObjectItemListView();
     $list->setUser($viewer);
     foreach ($pastes as $paste) {
         $created = phabricator_date($paste->getDateCreated(), $viewer);
         $author = $handles[$paste->getAuthorPHID()]->renderLink();
         $snippet_type = $paste->getSnippet()->getType();
         $lines = phutil_split_lines($paste->getSnippet()->getContent());
         $preview = id(new PhabricatorSourceCodeView())->setLines($lines)->setTruncatedFirstBytes($snippet_type == PhabricatorPasteSnippet::FIRST_BYTES)->setTruncatedFirstLines($snippet_type == PhabricatorPasteSnippet::FIRST_LINES)->setURI(new PhutilURI($paste->getURI()));
         $source_code = phutil_tag('div', array('class' => 'phabricator-source-code-summary'), $preview);
         $created = phabricator_datetime($paste->getDateCreated(), $viewer);
         $line_count = count($lines);
         $line_count = pht('%s Line(s)', new PhutilNumber($line_count));
         $title = nonempty($paste->getTitle(), pht('(An Untitled Masterwork)'));
         $item = id(new PHUIObjectItemView())->setObjectName('P' . $paste->getID())->setHeader($title)->setHref('/P' . $paste->getID())->setObject($paste)->addByline(pht('Author: %s', $author))->addIcon('none', $created)->addIcon('none', $line_count)->appendChild($source_code);
         if ($paste->isArchived()) {
             $item->setDisabled(true);
         }
         $lang_name = $paste->getLanguage();
         if ($lang_name) {
             $lang_name = idx($lang_map, $lang_name, $lang_name);
             $item->addIcon('none', $lang_name);
         }
         $list->addItem($item);
     }
     $result = new PhabricatorApplicationSearchResultView();
     $result->setObjectList($list);
     $result->setNoDataString(pht('No pastes found.'));
     return $result;
 }
Ejemplo n.º 9
0
 public function render()
 {
     require_celerity_resource('ponder-core-view-css');
     require_celerity_resource('ponder-feed-view-css');
     $user = $this->user;
     $aoffset = $this->answeroffset;
     $answers = $this->answers;
     $uri = $this->uri;
     $aparam = $this->aparam;
     $pagesize = $this->pagesize;
     $apagebuttons = id(new AphrontPagerView())->setPageSize($pagesize)->setOffset($aoffset)->setURI($uri->setFragment('answers'), $aparam);
     $answers = $apagebuttons->sliceResults($answers);
     $view = new PhabricatorObjectItemListView();
     $view->setNoDataString(pht('No matching answers.'));
     foreach ($answers as $answer) {
         $question = $answer->getQuestion();
         $author_phid = $question->getAuthorPHID();
         $item = new PhabricatorObjectItemView();
         $href = id(new PhutilURI('/Q' . $question->getID()))->setFragment('A' . $answer->getID());
         $item->setHeader('A' . $answer->getID() . ' ' . self::abbreviate($answer->getContent()));
         $item->setHref($href);
         $item->addDetail(pht('Votes'), $answer->getVoteCount());
         $item->addDetail(pht('Question'), self::abbreviate($question->getTitle()));
         $item->addAttribute(pht('Created %s', phabricator_date($answer->getDateCreated(), $user)));
         $view->addItem($item);
     }
     $view->appendChild($apagebuttons);
     return $view->render();
 }
 private function loadVersions(PhabricatorUser $viewer)
 {
     $specs = array('phabricator', 'arcanist', 'phutil');
     $all_libraries = PhutilBootloader::getInstance()->getAllLibraries();
     // This puts the core libraries at the top:
     $other_libraries = array_diff($all_libraries, $specs);
     $specs = array_merge($specs, $other_libraries);
     $futures = array();
     foreach ($specs as $lib) {
         $root = dirname(phutil_get_library_root($lib));
         $futures[$lib] = id(new ExecFuture('git log --format=%s -n 1 --', '%H %ct'))->setCWD($root);
     }
     $results = array();
     foreach ($futures as $key => $future) {
         list($err, $stdout) = $future->resolve();
         if (!$err) {
             list($hash, $epoch) = explode(' ', $stdout);
             $version = pht('%s (%s)', $hash, phabricator_date($epoch, $viewer));
         } else {
             $version = pht('Unknown');
         }
         $results[$key] = $version;
     }
     return $results;
 }
Ejemplo n.º 11
0
 public function render()
 {
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     $task = $this->task;
     $handles = $this->handles;
     require_celerity_resource('maniphest-task-summary-css');
     $pri_class = self::getPriorityClass($task->getPriority());
     $status_map = ManiphestTaskStatus::getTaskStatusMap();
     $batch = null;
     if ($this->showBatchControls) {
         $batch = '<td class="maniphest-task-batch">' . javelin_render_tag('input', array('type' => 'checkbox', 'name' => 'batch[]', 'value' => $task->getID(), 'sigil' => 'maniphest-batch'), null) . '</td>';
     }
     $projects_view = new ManiphestTaskProjectsView();
     $projects_view->setHandles(array_select_keys($this->handles, $task->getProjectPHIDs()));
     $control_class = null;
     $control_sigil = null;
     if ($this->showSubpriorityControls) {
         $control_class = 'maniphest-active-handle';
         $control_sigil = 'maniphest-task-handle';
     }
     $handle = javelin_render_tag('td', array('class' => 'maniphest-task-handle ' . $pri_class . ' ' . $control_class, 'sigil' => $control_sigil), '');
     return javelin_render_tag('table', array('class' => 'maniphest-task-summary', 'sigil' => 'maniphest-task', 'meta' => array('taskID' => $task->getID())), '<tr>' . $handle . $batch . '<td class="maniphest-task-number">' . 'T' . $task->getID() . '</td>' . '<td class="maniphest-task-status">' . idx($status_map, $task->getStatus(), 'Unknown') . '</td>' . '<td class="maniphest-task-owner">' . ($task->getOwnerPHID() ? $handles[$task->getOwnerPHID()]->renderLink() : '<em>None</em>') . '</td>' . '<td class="maniphest-task-name">' . phutil_render_tag('a', array('href' => '/T' . $task->getID()), phutil_escape_html($task->getTitle())) . '</td>' . '<td class="maniphest-task-projects">' . $projects_view->render() . '</td>' . '<td class="maniphest-task-updated">' . phabricator_date($task->getDateModified(), $this->user) . '</td>' . '</tr>');
 }
 public function render()
 {
     $viewer = $this->getViewer();
     $rows = array();
     foreach ($this->events as $event) {
         // Limit display log size. If a daemon gets stuck in an output loop this
         // page can be like >100MB if we don't truncate stuff. Try to do cheap
         // line-based truncation first, and fall back to expensive UTF-8 character
         // truncation if that doesn't get things short enough.
         $message = $event->getMessage();
         $more = null;
         if (!$this->showFullMessage) {
             $more_lines = null;
             $more_chars = null;
             $line_limit = 12;
             if (substr_count($message, "\n") > $line_limit) {
                 $message = explode("\n", $message);
                 $more_lines = count($message) - $line_limit;
                 $message = array_slice($message, 0, $line_limit);
                 $message = implode("\n", $message);
             }
             $char_limit = 8192;
             if (strlen($message) > $char_limit) {
                 $message = phutil_utf8v($message);
                 $more_chars = count($message) - $char_limit;
                 $message = array_slice($message, 0, $char_limit);
                 $message = implode('', $message);
             }
             if ($more_chars) {
                 $more = new PhutilNumber($more_chars);
                 $more = pht('Show %d more character(s)...', $more);
             } else {
                 if ($more_lines) {
                     $more = new PhutilNumber($more_lines);
                     $more = pht('Show %d more line(s)...', $more);
                 }
             }
             if ($more) {
                 $id = $event->getID();
                 $more = array("\n...\n", phutil_tag('a', array('href' => "/daemon/event/{$id}/"), $more));
             }
         }
         $row = array($event->getLogType(), phabricator_date($event->getEpoch(), $viewer), phabricator_time($event->getEpoch(), $viewer), array($message, $more));
         if ($this->combinedLog) {
             array_unshift($row, phutil_tag('a', array('href' => '/daemon/log/' . $event->getLogID() . '/'), pht('Daemon %s', $event->getLogID())));
         }
         $rows[] = $row;
     }
     $classes = array('', '', 'right', 'wide prewrap');
     $headers = array('Type', 'Date', 'Time', 'Message');
     if ($this->combinedLog) {
         array_unshift($classes, 'pri');
         array_unshift($headers, 'Daemon');
     }
     $log_table = new AphrontTableView($rows);
     $log_table->setHeaders($headers);
     $log_table->setColumnClasses($classes);
     return $log_table->render();
 }
Ejemplo n.º 13
0
 public function getStatusDescription(PhabricatorUser $viewer)
 {
     $until = phabricator_date($this->dateTo, $viewer);
     if ($this->status == PhabricatorUserStatus::STATUS_SPORADIC) {
         return 'Sporadic until ' . $until;
     } else {
         return 'Away until ' . $until;
     }
 }
Ejemplo n.º 14
0
 public function getTerseSummary(PhabricatorUser $viewer)
 {
     $until = phabricator_date($this->dateTo, $viewer);
     if ($this->status == PhabricatorCalendarEvent::STATUS_SPORADIC) {
         return pht('Sporadic until %s', $until);
     } else {
         return pht('Away until %s', $until);
     }
 }
 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->events as $event) {
         // Limit display log size. If a daemon gets stuck in an output loop this
         // page can be like >100MB if we don't truncate stuff. Try to do cheap
         // line-based truncation first, and fall back to expensive UTF-8 character
         // truncation if that doesn't get things short enough.
         $message = $event->getMessage();
         $more_lines = null;
         $more_chars = null;
         $line_limit = 12;
         if (substr_count($message, "\n") > $line_limit) {
             $message = explode("\n", $message);
             $more_lines = count($message) - $line_limit;
             $message = array_slice($message, 0, $line_limit);
             $message = implode("\n", $message);
         }
         $char_limit = 8192;
         if (strlen($message) > $char_limit) {
             $message = phutil_utf8v($message);
             $more_chars = count($message) - $char_limit;
             $message = array_slice($message, 0, $char_limit);
             $message = implode('', $message);
         }
         $more = null;
         if ($more_chars) {
             $more = number_format($more_chars);
             $more = "\n<... {$more} more characters ...>";
         } else {
             if ($more_lines) {
                 $more = number_format($more_lines);
                 $more = "\n<... {$more} more lines ...>";
             }
         }
         $row = array(phutil_escape_html($event->getLogType()), phabricator_date($event->getEpoch(), $this->user), phabricator_time($event->getEpoch(), $this->user), str_replace("\n", '<br />', phutil_escape_html($message . $more)));
         if ($this->combinedLog) {
             array_unshift($row, phutil_render_tag('a', array('href' => '/daemon/log/' . $event->getLogID() . '/'), phutil_escape_html('Daemon ' . $event->getLogID())));
         }
         $rows[] = $row;
     }
     $classes = array('', '', 'right', 'wide wrap');
     $headers = array('Type', 'Date', 'Time', 'Message');
     if ($this->combinedLog) {
         array_unshift($classes, 'pri');
         array_unshift($headers, 'Daemon');
     }
     $log_table = new AphrontTableView($rows);
     $log_table->setHeaders($headers);
     $log_table->setColumnClasses($classes);
     return $log_table->render();
 }
 public function render()
 {
     $rows = array();
     if (!$this->user) {
         throw new Exception("Call setUser() before rendering!");
     }
     foreach ($this->daemonLogs as $log) {
         $epoch = $log->getDateCreated();
         $status = $log->getStatus();
         if ($log->getHost() == php_uname('n') && $status != PhabricatorDaemonLog::STATUS_EXITED && $status != PhabricatorDaemonLog::STATUS_DEAD) {
             $pid = $log->getPID();
             $is_running = PhabricatorDaemonReference::isProcessRunning($pid);
             if (!$is_running) {
                 $guard = AphrontWriteGuard::beginScopedUnguardedWrites();
                 $log->setStatus(PhabricatorDaemonLog::STATUS_DEAD);
                 $log->save();
                 unset($guard);
                 $status = PhabricatorDaemonLog::STATUS_DEAD;
             }
         }
         $heartbeat_timeout = $log->getDateModified() + 3 * PhutilDaemonOverseer::HEARTBEAT_WAIT;
         if ($status == PhabricatorDaemonLog::STATUS_RUNNING && $heartbeat_timeout < time()) {
             $status = PhabricatorDaemonLog::STATUS_UNKNOWN;
         }
         switch ($status) {
             case PhabricatorDaemonLog::STATUS_RUNNING:
                 $style = 'color: #00cc00';
                 $title = 'Running';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_DEAD:
                 $style = 'color: #cc0000';
                 $title = 'Died';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_EXITED:
                 $style = 'color: #000000';
                 $title = 'Exited';
                 $symbol = '&bull;';
                 break;
             case PhabricatorDaemonLog::STATUS_UNKNOWN:
             default:
                 // fallthrough
                 $style = 'color: #888888';
                 $title = 'Unknown';
                 $symbol = '?';
         }
         $running = phutil_render_tag('span', array('style' => $style, 'title' => $title), $symbol);
         $rows[] = array($running, phutil_escape_html($log->getDaemon()), phutil_escape_html($log->getHost()), $log->getPID(), phabricator_date($epoch, $this->user), phabricator_time($epoch, $this->user), phutil_render_tag('a', array('href' => '/daemon/log/' . $log->getID() . '/', 'class' => 'button small grey'), 'View Log'));
     }
     $daemon_table = new AphrontTableView($rows);
     $daemon_table->setHeaders(array('', 'Daemon', 'Host', 'PID', 'Date', 'Time', 'View'));
     $daemon_table->setColumnClasses(array('', 'wide wrap', '', '', '', 'right', 'action'));
     return $daemon_table->render();
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $upload_panel = $this->renderUploadPanel();
     $author = null;
     $author_username = $request->getStr('author');
     if ($author_username) {
         $author = id(new PhabricatorUser())->loadOneWhere('userName = %s', $author_username);
         if (!$author) {
             return id(new Aphront404Response());
         }
         $title = 'Files Uploaded by ' . phutil_escape_html($author->getUsername());
     } else {
         $title = 'Files';
     }
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     if ($author) {
         $files = id(new PhabricatorFile())->loadAllWhere('authorPHID = %s ORDER BY id DESC LIMIT %d, %d', $author->getPHID(), $pager->getOffset(), $pager->getPageSize() + 1);
     } else {
         $files = id(new PhabricatorFile())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     }
     $files = $pager->sliceResults($files);
     $pager->setURI($request->getRequestURI(), 'page');
     $phids = mpull($files, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     $highlighted = $request->getStr('h');
     $highlighted = explode('-', $highlighted);
     $highlighted = array_fill_keys($highlighted, true);
     $rows = array();
     $rowc = array();
     foreach ($files as $file) {
         if ($file->isViewableInBrowser()) {
             $view_button = phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/view/' . $file->getPHID() . '/'), 'View');
         } else {
             $view_button = null;
         }
         if (isset($highlighted[$file->getID()])) {
             $rowc[] = 'highlighted';
         } else {
             $rowc[] = '';
         }
         $rows[] = array(phutil_escape_html('F' . $file->getID()), $file->getAuthorPHID() ? $handles[$file->getAuthorPHID()]->renderLink() : null, phutil_render_tag('a', array('href' => $file->getViewURI()), phutil_escape_html($file->getName())), phutil_escape_html(number_format($file->getByteSize()) . ' bytes'), phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/info/' . $file->getPHID() . '/'), 'Info'), $view_button, phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/file/download/' . $file->getPHID() . '/'), 'Download'), phabricator_date($file->getDateCreated(), $user), phabricator_time($file->getDateCreated(), $user));
     }
     $table = new AphrontTableView($rows);
     $table->setRowClasses($rowc);
     $table->setHeaders(array('File ID', 'Author', 'Name', 'Size', '', '', '', 'Created', ''));
     $table->setColumnClasses(array(null, '', 'wide pri', 'right', 'action', 'action', 'action', '', 'right'));
     $panel = new AphrontPanelView();
     $panel->appendChild($table);
     $panel->setHeader($title);
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse(array($upload_panel, $panel), array('title' => 'Files', 'tab' => 'files'));
 }
 public function testLocalTimeFormatting()
 {
     $user = new PhabricatorUser();
     $user->setTimezoneIdentifier('America/Los_Angeles');
     $utc = new PhabricatorUser();
     $utc->setTimezoneIdentifier('UTC');
     $this->assertEqual('Jan 1 2000, 12:00 AM', phabricator_datetime(946684800, $utc), 'Datetime formatting');
     $this->assertEqual('Jan 1 2000', phabricator_date(946684800, $utc), 'Date formatting');
     $this->assertEqual('12:00 AM', phabricator_time(946684800, $utc), 'Time formatting');
     $this->assertEqual('Dec 31 1999, 4:00 PM', phabricator_datetime(946684800, $user), 'Localization');
     $this->assertEqual('', phabricator_datetime(0, $user), 'Missing epoch should fail gracefully');
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $is_admin = $viewer->getIsAdmin();
     $user = new PhabricatorUser();
     $count = queryfx_one($user->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $user->getTableName());
     $count = idx($count, 'N', 0);
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page', 0));
     $pager->setCount($count);
     $pager->setURI($request->getRequestURI(), 'page');
     $users = id(new PhabricatorPeopleQuery())->needPrimaryEmail(true)->executeWithOffsetPager($pager);
     $rows = array();
     foreach ($users as $user) {
         $primary_email = $user->loadPrimaryEmail();
         if ($primary_email && $primary_email->getIsVerified()) {
             $email = 'Verified';
         } else {
             $email = 'Unverified';
         }
         $status = array();
         if ($user->getIsDisabled()) {
             $status[] = 'Disabled';
         }
         if ($user->getIsAdmin()) {
             $status[] = 'Admin';
         }
         if ($user->getIsSystemAgent()) {
             $status[] = 'System Agent';
         }
         $status = implode(', ', $status);
         $rows[] = array(phabricator_date($user->getDateCreated(), $viewer), phabricator_time($user->getDateCreated(), $viewer), phutil_render_tag('a', array('href' => '/p/' . $user->getUsername() . '/'), phutil_escape_html($user->getUserName())), phutil_escape_html($user->getRealName()), $status, $email, phutil_render_tag('a', array('class' => 'button grey small', 'href' => '/people/edit/' . $user->getID() . '/'), 'Administrate User'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Join Date', 'Time', 'Username', 'Real Name', 'Roles', 'Email', ''));
     $table->setColumnClasses(array(null, 'right', 'pri', 'wide', null, null, 'action'));
     $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin, $is_admin));
     $panel = new AphrontPanelView();
     $panel->setHeader('People (' . number_format($count) . ')');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     if ($is_admin) {
         $panel->addButton(phutil_render_tag('a', array('href' => '/people/edit/', 'class' => 'button green'), 'Create New Account'));
         if (PhabricatorEnv::getEnvConfig('ldap.auth-enabled')) {
             $panel->addButton(phutil_render_tag('a', array('href' => '/people/ldap/', 'class' => 'button green'), 'Import from LDAP'));
         }
     }
     $nav = $this->buildSideNavView();
     $nav->selectFilter('people');
     $nav->appendChild($panel);
     return $this->buildApplicationPage($nav, array('title' => 'People'));
 }
 private function renderColumns(DiffusionRequest $drequest, array $handles, PhabricatorRepositoryCommit $commit = null, $lint = null)
 {
     assert_instances_of($handles, 'PhabricatorObjectHandle');
     $viewer = $this->getRequest()->getUser();
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($drequest->getRepository(), $commit->getCommitIdentifier());
         $date = phabricator_date($epoch, $viewer);
         $time = phabricator_time($epoch, $viewer);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     $data = $commit->getCommitData();
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = DiffusionView::renderName($data->getAuthorName());
         }
         $committer = $data->getCommitDetail('committer');
         if ($committer) {
             $committer_phid = $data->getCommitDetail('committerPHID');
             if ($committer_phid && isset($handles[$committer_phid])) {
                 $committer = $handles[$committer_phid]->renderLink();
             } else {
                 $committer = DiffusionView::renderName($committer);
             }
             if ($author != $committer) {
                 $author = hsprintf('%s/%s', $author, $committer);
             }
         }
         $details = AphrontTableView::renderSingleDisplayLine($data->getSummary());
     } else {
         $author = '';
         $details = '';
     }
     $return = array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
     if ($lint !== null) {
         $return['lint'] = phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'lint', 'lint' => null))), number_format($lint));
     }
     // The client treats these results as markup, so make sure they have been
     // escaped correctly.
     foreach ($return as $key => $value) {
         $return[$key] = hsprintf('%s', $value);
     }
     return $return;
 }
Ejemplo n.º 21
0
 private function renderEventLink($event)
 {
     Javelin::initBehavior('phabricator-tooltips');
     if ($event->getMultiDay()) {
         $tip = pht('%s, Until: %s', $event->getName(), phabricator_date($event->getEpochEnd(), $this->getUser()));
     } else {
         $tip = pht('%s, Until: %s', $event->getName(), phabricator_time($event->getEpochEnd(), $this->getUser()));
     }
     $description = $event->getDescription();
     if (strlen($description) == 0) {
         $description = pht('(%s)', $event->getName());
     }
     $anchor = javelin_tag('a', array('sigil' => 'has-tooltip', 'class' => 'phui-calendar-item-link', 'href' => '/calendar/event/view/' . $event->getEventID() . '/', 'meta' => array('tip' => $tip, 'size' => 200)), $description);
     return $anchor;
 }
 public function render()
 {
     $project_phid = $this->request->getStr('project');
     $project_handle = null;
     if ($project_phid) {
         $phids = array($project_phid);
         $project_handle = $this->getProjectHandle($phids, $project_phid, $this->request);
         $tasks = $this->getOpenTasksforProject($this->user, $phids);
     } else {
         $tasks = $this->getOpenTasks($this->user);
     }
     $recently_closed = $this->loadRecentlyClosedTasks();
     $date = phabricator_date(time(), $this->user);
     $viewer_task_view = new UserOpenTasksView();
     $project_task_view = new ProjectOpenTasksView();
     if ($this->view == 'user') {
         list($leftover, $leftover_closed, $base_link, $leftover_name, $col_header, $header, $result_closed, $result) = $viewer_task_view->execute($tasks, $recently_closed, $date);
     } else {
         if ($this->view == 'project') {
             list($leftover, $base_link, $leftover_name, $col_header, $header, $result_closed, $leftover_closed, $result) = $project_task_view->execute($tasks, $recently_closed, $date);
         } else {
             $result = array();
             $result_closed = array();
             $base_link = null;
             $leftover = array();
             $leftover_closed = array();
             $leftover_name = null;
             $col_header = '';
             $header = '';
         }
     }
     $order = $this->request->getStr('order', 'name');
     list($order, $reverse) = AphrontTableView::parseSort($order);
     require_celerity_resource('aphront-tooltip-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $rows = $this->buildRowsfromResult($project_handle, $result, $result_closed, $base_link, $leftover, $leftover_name, $leftover_closed, $order, $reverse);
     list($cname, $cclass) = $this->buildTableColumns($col_header);
     $table = $this->buildOpenTasksTable($rows, $cname, $cclass, $order, $reverse);
     $panel = new PHUIObjectBoxView();
     $panel->setHeaderText($header);
     $panel->setTable($table);
     $tokens = array();
     if ($project_handle) {
         $tokens = array($project_handle);
     }
     $filter = $this->renderReportFilters($tokens, $has_window = false, $this->request, $this->user);
     return array($filter, $panel);
 }
Ejemplo n.º 23
0
 protected function renderResultList(array $mocks, PhabricatorSavedQuery $query, array $handles)
 {
     assert_instances_of($mocks, 'PholioMock');
     $viewer = $this->requireViewer();
     $board = new PHUIPinboardView();
     foreach ($mocks as $mock) {
         $header = 'M' . $mock->getID() . ' ' . $mock->getName();
         $item = id(new PHUIPinboardItemView())->setHeader($header)->setURI('/M' . $mock->getID())->setImageURI($mock->getCoverFile()->getThumb280x210URI())->setImageSize(280, 210)->setDisabled($mock->isClosed())->addIconCount('fa-picture-o', count($mock->getImages()))->addIconCount('fa-trophy', $mock->getTokenCount());
         if ($mock->getAuthorPHID()) {
             $author_handle = $handles[$mock->getAuthorPHID()];
             $datetime = phabricator_date($mock->getDateCreated(), $viewer);
             $item->appendChild(pht('By %s on %s', $author_handle->renderLink(), $datetime));
         }
         $board->addItem($item);
     }
     return $board;
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $document = id(new PhrictionDocument())->loadOneWhere('slug = %s', PhabricatorSlug::normalize($this->slug));
     if (!$document) {
         return new Aphront404Response();
     }
     $current = id(new PhrictionContent())->load($document->getContentID());
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('page'));
     $pager->setURI($request->getRequestURI(), 'page');
     $history = id(new PhrictionContent())->loadAllWhere('documentID = %d ORDER BY version DESC LIMIT %d, %d', $document->getID(), $pager->getOffset(), $pager->getPageSize() + 1);
     $history = $pager->sliceResults($history);
     $author_phids = mpull($history, 'getAuthorPHID');
     $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles();
     $rows = array();
     foreach ($history as $content) {
         $uri = PhrictionDocument::getSlugURI($document->getSlug());
         $version = $content->getVersion();
         $diff_uri = new PhutilURI('/phriction/diff/' . $document->getID() . '/');
         $vs_previous = '<em>Created</em>';
         if ($content->getVersion() != 1) {
             $uri = $diff_uri->alter('l', $content->getVersion() - 1)->alter('r', $content->getVersion());
             $vs_previous = phutil_render_tag('a', array('href' => $uri), 'Show Change');
         }
         $vs_head = '<em>Current</em>';
         if ($content->getID() != $document->getContentID()) {
             $uri = $diff_uri->alter('l', $content->getVersion())->alter('r', $current->getVersion());
             $vs_head = phutil_render_tag('a', array('href' => $uri), 'Show Later Changes');
         }
         $change_type = PhrictionChangeType::getChangeTypeLabel($content->getChangeType());
         $rows[] = array(phabricator_date($content->getDateCreated(), $user), phabricator_time($content->getDateCreated(), $user), phutil_render_tag('a', array('href' => $uri . '?v=' . $version), 'Version ' . $version), $handles[$content->getAuthorPHID()]->renderLink(), $change_type, phutil_escape_html($content->getDescription()), $vs_previous, $vs_head);
     }
     $crumbs = new AphrontCrumbsView();
     $crumbs->setCrumbs(array('Phriction', phutil_render_tag('a', array('href' => PhrictionDocument::getSlugURI($document->getSlug())), phutil_escape_html($current->getTitle())), 'History'));
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Version', 'Author', 'Type', 'Description', 'Against Previous', 'Against Current'));
     $table->setColumnClasses(array('', 'right', 'pri', '', '', 'wide', '', ''));
     $panel = new AphrontPanelView();
     $panel->setHeader('Document History');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     return $this->buildStandardPageResponse(array($crumbs, $panel), array('title' => 'Document History'));
 }
 public function processRequest()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     // Get one page of data together with the pager.
     // Pull these objects manually since the serialized fields are gigantic.
     $transcript = new HeraldTranscript();
     $conn_r = $transcript->establishConnection('r');
     $phid = $request->getStr('phid');
     $where_clause = '';
     if ($phid) {
         $where_clause = qsprintf($conn_r, 'WHERE objectPHID = %s', $phid);
     }
     $pager = new AphrontPagerView();
     $pager->setOffset($request->getInt('offset'));
     $pager->setURI($request->getRequestURI(), 'offset');
     $limit_clause = qsprintf($conn_r, 'LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1);
     $data = queryfx_all($conn_r, 'SELECT id, objectPHID, time, duration, dryRun FROM %T
     %Q
     ORDER BY id DESC
     %Q', $transcript->getTableName(), $where_clause, $limit_clause);
     $data = $pager->sliceResults($data);
     // Render the table.
     $handles = array();
     if ($data) {
         $phids = ipull($data, 'objectPHID', 'objectPHID');
         $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
     }
     $rows = array();
     foreach ($data as $xscript) {
         $rows[] = array(phabricator_date($xscript['time'], $user), phabricator_time($xscript['time'], $user), $handles[$xscript['objectPHID']]->renderLink(), $xscript['dryRun'] ? 'Yes' : '', number_format((int) (1000 * $xscript['duration'])) . ' ms', phutil_render_tag('a', array('href' => '/herald/transcript/' . $xscript['id'] . '/', 'class' => 'button small grey'), 'View Transcript'));
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array('Date', 'Time', 'Object', 'Dry Run', 'Duration', 'View'));
     $table->setColumnClasses(array('', 'right', 'wide wrap', '', '', 'action'));
     // Render the whole page.
     $panel = new AphrontPanelView();
     $panel->setHeader('Herald Transcripts');
     $panel->appendChild($table);
     $panel->appendChild($pager);
     $nav = $this->renderNav();
     $nav->selectFilter('transcript');
     $nav->appendChild($panel);
     return $this->buildStandardPageResponse($nav, array('title' => 'Herald Transcripts', 'tab' => 'transcripts'));
 }
Ejemplo n.º 26
0
function phabricator_relative_date($epoch, $user, $on = false)
{
    static $today;
    static $yesterday;
    if (!$today || !$yesterday) {
        $now = time();
        $today = phabricator_date($now, $user);
        $yesterday = phabricator_date($now - 86400, $user);
    }
    $date = phabricator_date($epoch, $user);
    if ($date === $today) {
        return 'today';
    }
    if ($date === $yesterday) {
        return 'yesterday';
    }
    return ($on ? 'on ' : '') . $date;
}
Ejemplo n.º 27
0
 public function render()
 {
     $logs = $this->logs;
     $viewer = $this->getUser();
     $view = new PHUIObjectItemListView();
     $rows = array();
     foreach ($logs as $log) {
         $resource_uri = '/drydock/resource/' . $log->getResourceID() . '/';
         $lease_uri = '/drydock/lease/' . $log->getLeaseID() . '/';
         $rows[] = array(phutil_tag('a', array('href' => $resource_uri), $log->getResourceID()), phutil_tag('a', array('href' => $lease_uri), $log->getLeaseID()), $log->getMessage(), phabricator_date($log->getEpoch(), $viewer));
     }
     $table = new AphrontTableView($rows);
     $table->setDeviceReadyTable(true);
     $table->setHeaders(array(pht('Resource'), pht('Lease'), pht('Message'), pht('Date')));
     $table->setShortHeaders(array('R', 'L', pht('Message'), ''));
     $table->setColumnClasses(array('', '', 'wide', ''));
     return $table;
 }
 public function renderHovercard(PhabricatorHovercardView $hovercard, PhabricatorObjectHandle $handle, $commit, $data)
 {
     $viewer = $this->getViewer();
     $author_phid = $commit->getAuthorPHID();
     if ($author_phid) {
         $author = $viewer->renderHandle($author_phid);
     } else {
         $commit_data = $commit->loadCommitData();
         $author = phutil_tag('em', array(), $commit_data->getAuthorName());
     }
     $hovercard->setTitle($handle->getName());
     $hovercard->setDetail($commit->getSummary());
     $hovercard->addField(pht('Author'), $author);
     $hovercard->addField(pht('Date'), phabricator_date($commit->getEpoch(), $viewer));
     if ($commit->getAuditStatus() != PhabricatorAuditCommitStatusConstants::NONE) {
         $hovercard->addField(pht('Audit Status'), PhabricatorAuditCommitStatusConstants::getStatusName($commit->getAuditStatus()));
     }
 }
 private function buildSprintHistoryData()
 {
     $rows = array();
     foreach ($this->history as $project) {
         $remove_action = $project['projectremoved'];
         $add_action = $project['projectadded'];
         // $projectPHID = $project['projPHID'];
         $projectname = $project['projName'];
         // $transactionPHID = $project['transactionPHID'];
         // $objectPHID = $project['objectPHID'];
         $taskname = $project['taskName'];
         $createdEpoch = $project['createdEpoch'];
         $created = phabricator_date($createdEpoch, $this->viewer);
         $row = $this->buildRowSet($remove_action, $add_action, $projectname, $taskname, $createdEpoch, $created);
         $rows[] = $row;
     }
     $this->rows = array_map(function ($a) {
         return $a['0'];
     }, $rows);
     return $this;
 }
 /**
  * @param array $commit_phids phids of the commits to render
  * @param PhabricatorUser $user phabricator user
  * @return AphrontTableView
  */
 private static function createCommitTable(array $commit_phids, PhabricatorUser $user)
 {
     $loader = new PhabricatorObjectHandleData($commit_phids);
     $handles = $loader->loadHandles();
     $objects = $loader->loadObjects();
     $rows = array();
     foreach ($commit_phids as $phid) {
         $handle = $handles[$phid];
         $object = $objects[$phid];
         $commit_data = $object->getCommitData();
         $epoch = $handle->getTimeStamp();
         $date = phabricator_date($epoch, $user);
         $time = phabricator_time($epoch, $user);
         $link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getName()));
         $rows[] = array($link, $date, $time, phutil_escape_html($commit_data->getSummary()));
     }
     $commit_table = new AphrontTableView($rows);
     $commit_table->setHeaders(array('Commit', 'Date', 'Time', 'Summary'));
     $commit_table->setColumnClasses(array('', '', 'right', 'wide'));
     return $commit_table;
 }