public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pager->setURI($request->getRequestURI(), 'page'); $timers = id(new PhabricatorTimer())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $timers = $pager->sliceResults($timers); $phids = mpull($timers, 'getAuthorPHID'); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); foreach ($timers as $timer) { $edit_button = null; $delete_button = null; if ($user->getIsAdmin() || $user->getPHID() == $timer->getAuthorPHID()) { $edit_button = phutil_render_tag('a', array('class' => 'small button grey', 'href' => '/countdown/edit/' . $timer->getID() . '/'), 'Edit'); $delete_button = javelin_render_tag('a', array('class' => 'small button grey', 'href' => '/countdown/delete/' . $timer->getID() . '/', 'sigil' => 'workflow'), 'Delete'); } $rows[] = array(phutil_escape_html($timer->getID()), $handles[$timer->getAuthorPHID()]->renderLink(), phutil_render_tag('a', array('href' => '/countdown/' . $timer->getID() . '/'), phutil_escape_html($timer->getTitle())), phabricator_datetime($timer->getDatepoint(), $user), $edit_button, $delete_button); } $table = new AphrontTableView($rows); $table->setHeaders(array('ID', 'Author', 'Title', 'End Date', '', '')); $table->setColumnClasses(array(null, null, 'wide pri', null, 'action', 'action')); $panel = id(new AphrontPanelView())->appendChild($table)->setHeader('Timers')->setCreateButton('Create Timer', '/countdown/edit/')->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Countdown')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $nav = $this->buildSideNav('resource'); $pager = new AphrontPagerView(); $pager->setURI(new PhutilURI('/drydock/resource/'), 'page'); $data = id(new DrydockResource())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $phids = mpull($data, 'getOwnerPHID'); $handles = $this->loadViewerHandles($phids); $rows = array(); foreach ($data as $resource) { $rows[] = array($resource->getID(), $resource->getOwnerPHID() ? $handles[$resource->getOwnerPHID()]->renderLink() : null, phutil_escape_html($resource->getType()), DrydockResourceStatus::getNameForStatus($resource->getStatus()), phutil_escape_html(nonempty($resource->getName(), 'Unnamed')), phabricator_datetime($resource->getDateCreated(), $user)); } $table = new AphrontTableView($rows); $table->setHeaders(array('ID', 'Owner', 'Type', 'Status', 'Resource', 'Created')); $table->setColumnClasses(array('', '', '', '', 'pri wide', 'right')); $panel = new AphrontPanelView(); $panel->setHeader('Drydock Resources'); $panel->addButton(phutil_render_tag('a', array('href' => '/drydock/resource/allocate/', 'class' => 'green button'), 'Allocate Resource')); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Resources')); }
public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $macro_table = new PhabricatorFileImageMacro(); $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize()); // Get an exact count since the size here is reasonably going to be a few // thousand at most in any reasonable case. $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName()); $count = $count['N']; $pager->setCount($count); $pager->setURI($request->getRequestURI(), 'page'); $rows = array(); foreach ($macros as $macro) { $src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID()); $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), phutil_render_tag('a', array('href' => $src, 'target' => '_blank'), phutil_render_tag('img', array('src' => $src))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Image', '')); $table->setColumnClasses(array('pri', 'wide thumb', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Image Macros'); $panel->setCreateButton('New Image Macro', '/file/macro/edit/'); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Image Macros', 'tab' => 'macros')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $nav = $this->buildSideNav('lease'); $pager = new AphrontPagerView(); $pager->setURI(new PhutilURI('/drydock/lease/'), 'page'); $data = id(new DrydockLease())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $phids = mpull($data, 'getOwnerPHID'); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $resource_ids = mpull($data, 'getResourceID'); $resources = array(); if ($resource_ids) { $resources = id(new DrydockResource())->loadAllWhere('id IN (%Ld)', $resource_ids); } $rows = array(); foreach ($data as $lease) { $resource = idx($resources, $lease->getResourceID()); $rows[] = array($lease->getID(), DrydockLeaseStatus::getNameForStatus($lease->getStatus()), $lease->getOwnerPHID() ? $handles[$lease->getOwnerPHID()]->renderLink() : null, $lease->getResourceID(), $resource ? phutil_escape_html($resource->getName()) : null, phabricator_datetime($lease->getDateCreated(), $user)); } $table = new AphrontTableView($rows); $table->setHeaders(array('ID', 'Status', 'Owner', 'Resource ID', 'Resource', 'Created')); $table->setColumnClasses(array('', '', '', '', 'wide pri', 'right')); $panel = new AphrontPanelView(); $panel->setHeader('Drydock Leases'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Leases')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $nav = $this->buildSideNav('log'); $query = new DrydockLogQuery(); $resource_ids = $request->getStrList('resource'); if ($resource_ids) { $query->withResourceIDs($resource_ids); } $lease_ids = $request->getStrList('lease'); if ($lease_ids) { $query->withLeaseIDs($lease_ids); } $pager = new AphrontPagerView(); $pager->setPageSize(500); $pager->setOffset($request->getInt('offset')); $pager->setURI($request->getRequestURI(), 'offset'); $logs = $query->executeWithOffsetPager($pager); $rows = array(); foreach ($logs as $log) { $rows[] = array($log->getResourceID(), $log->getLeaseID(), phutil_escape_html($log->getMessage()), phabricator_datetime($log->getEpoch(), $user)); } $table = new AphrontTableView($rows); $table->setHeaders(array('Resource', 'Lease', 'Message', 'Date')); $table->setColumnClasses(array('', '', 'wide', '')); $panel = new AphrontPanelView(); $panel->setHeader('Drydock Logs'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Logs')); }
public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pastes = id(new PhabricatorPaste())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $pastes = $pager->sliceResults($pastes); $pager->setURI($request->getRequestURI(), 'page'); $phids = mpull($pastes, 'getAuthorPHID'); $handles = array(); if ($phids) { $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); } $rows = array(); foreach ($pastes as $paste) { $handle = $handles[$paste->getAuthorPHID()]; $rows[] = array(phutil_escape_html('P' . $paste->getID()), phutil_render_tag('a', array('href' => '/p/' . $handle->getName() . '/'), phutil_escape_html($handle->getName())), phutil_escape_html($paste->getLanguage()), phutil_render_tag('a', array('href' => '/P' . $paste->getID()), phutil_escape_html(nonempty($paste->getTitle(), 'Untitled Masterwork P' . $paste->getID()))), phutil_render_tag('a', array('href' => PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID())), phutil_escape_html($paste->getFilePHID()))); } $table = new AphrontTableView($rows); $table->setHeaders(array('Paste ID', 'Author', 'Language', 'Title', 'File')); $table->setColumnClasses(array(null, null, null, 'wide pri', null)); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->setHeader("Paste"); $panel->setCreateButton('Paste Something', '/paste/'); $panel->appendChild($table); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Paste List', 'tab' => 'list')); }
public function render() { $drequest = $this->getDiffusionRequest(); $handles = $this->handles; $rows = array(); foreach ($this->history as $history) { $epoch = $history->getEpoch(); if ($epoch) { $date = date('M j, Y', $epoch); $time = date('g:i A', $epoch); } else { $date = null; $time = null; } $data = $history->getCommitData(); $author_phid = null; if ($data) { $author_phid = $data->getCommitDetail('authorPHID'); } if ($author_phid && isset($handles[$author_phid])) { $author = $handles[$author_phid]->renderLink(); } else { $author = phutil_escape_html($history->getAuthorName()); } $rows[] = array($this->linkBrowse($drequest->getPath(), array('commit' => $history->getCommitIdentifier())), self::linkCommit($drequest->getRepository(), $history->getCommitIdentifier()), $this->linkChange($history->getChangeType(), $history->getFileType(), null, $history->getCommitIdentifier()), $date, $time, $author, phutil_escape_html($history->getSummary())); } $view = new AphrontTableView($rows); $view->setHeaders(array('Browse', 'Commit', 'Change', 'Date', 'Time', 'Author', 'Details')); $view->setColumnClasses(array('', 'n', '', '', 'right', '', 'wide wrap')); return $view->render(); }
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 processRequest() { $method_groups = $this->getMethodFilters(); $rows = array(); foreach ($method_groups as $group => $methods) { foreach ($methods as $info) { switch ($info['status']) { case ConduitAPIMethod::METHOD_STATUS_DEPRECATED: $status = 'Deprecated'; break; case ConduitAPIMethod::METHOD_STATUS_UNSTABLE: $status = 'Unstable'; break; default: $status = null; break; } $rows[] = array($group, phutil_render_tag('a', array('href' => '/conduit/method/' . $info['full_name']), phutil_escape_html($info['full_name'])), $info['description'], $status); $group = null; } } $table = new AphrontTableView($rows); $table->setHeaders(array('Group', 'Name', 'Description', 'Status')); $table->setColumnClasses(array('pri', 'pri', 'wide', null)); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Methods'); $panel->appendChild($table); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $utils = new AphrontPanelView(); $utils->setHeader('Utilities'); $utils->appendChild('<ul>' . '<li><a href="/conduit/log/">Log</a> - Conduit Method Calls</li>' . '<li><a href="/conduit/token/">Token</a> - Certificate Install</li>' . '</ul>'); $utils->setWidth(AphrontPanelView::WIDTH_FULL); $this->setShowSideNav(false); return $this->buildStandardPageResponse(array($panel, $utils), array('title' => 'Conduit Console')); }
public function render() { $user = $this->getUser(); $blogs = $this->getBlogs(); $panel = new AphrontPanelView(); if (empty($blogs)) { $panel = id(new AphrontPanelView())->setHeader('No blogs... Yet!')->setCaption('Will you answer the call to phame?')->setCreateButton('New Blog', '/phame/blog/new'); return $panel->render(); } $table_data = array(); foreach ($blogs as $blog) { $view_link = phutil_render_tag('a', array('href' => $blog->getViewURI()), phutil_escape_html($blog->getName())); $bloggers = $blog->getBloggers(); if (isset($bloggers[$user->getPHID()])) { $edit = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $blog->getEditURI()), 'Edit'); } else { $edit = null; } $view = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $blog->getViewURI()), 'View'); $table_data[] = array($view_link, implode(', ', mpull($blog->getBloggers(), 'renderLink')), $view, $edit); } $table = new AphrontTableView($table_data); $table->setHeaders(array('Name', 'Bloggers', '', '')); $table->setColumnClasses(array(null, null, 'action', 'action')); $panel->setCreateButton('Create a Blog', '/phame/blog/new/'); $panel->setHeader($this->getHeader()); $panel->appendChild($table); return $panel->render(); }
public function renderConfigurationFooter() { $hashers = PhabricatorPasswordHasher::getAllHashers(); $hashers = msort($hashers, 'getStrength'); $hashers = array_reverse($hashers); $yes = phutil_tag('strong', array('style' => 'color: #009900'), pht('Yes')); $no = phutil_tag('strong', array('style' => 'color: #990000'), pht('Not Installed')); $best_hasher_name = null; try { $best_hasher = PhabricatorPasswordHasher::getBestHasher(); $best_hasher_name = $best_hasher->getHashName(); } catch (PhabricatorPasswordHasherUnavailableException $ex) { // There are no suitable hashers. The user might be able to enable some, // so we don't want to fatal here. We'll fatal when users try to actually // use this stuff if it isn't fixed before then. Until then, we just // don't highlight a row. In practice, at least one hasher should always // be available. } $rows = array(); $rowc = array(); foreach ($hashers as $hasher) { $is_installed = $hasher->canHashPasswords(); $rows[] = array($hasher->getHumanReadableName(), $hasher->getHashName(), $hasher->getHumanReadableStrength(), $is_installed ? $yes : $no, $is_installed ? null : $hasher->getInstallInstructions()); $rowc[] = $best_hasher_name == $hasher->getHashName() ? 'highlighted' : null; } $table = new AphrontTableView($rows); $table->setRowClasses($rowc); $table->setHeaders(array(pht('Algorithm'), pht('Name'), pht('Strength'), pht('Installed'), pht('Install Instructions'))); $table->setColumnClasses(array('', '', '', '', 'wide')); $header = id(new PHUIHeaderView())->setHeader(pht('Password Hash Algorithms'))->setSubheader(pht('Stronger algorithms are listed first. The highlighted algorithm ' . 'will be used when storing new hashes. Older hashes will be ' . 'upgraded to the best algorithm over time.')); return id(new PHUIObjectBoxView())->setHeader($header)->appendChild($table); }
public function render() { $user = $this->user; if (!$user) { throw new Exception("Call setUser() before render()!"); } foreach ($this->fields as $field) { $field->setUser($this->user); $field->setHandles($this->handles); } $rows = array(); foreach ($this->revisions as $revision) { $row = array(); foreach ($this->fields as $field) { $row[] = $field->renderValueForRevisionList($revision); } $rows[] = $row; } $headers = array(); $classes = array(); foreach ($this->fields as $field) { $headers[] = $field->renderHeaderForRevisionList(); $classes[] = $field->getColumnClassForRevisionList(); } $table = new AphrontTableView($rows); $table->setHeaders($headers); $table->setColumnClasses($classes); $table->setNoDataString(DifferentialRevisionListView::NO_DATA_STRING); return $table->render(); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); if ($request->isFormPost()) { $uri = new PhutilURI('/fact/chart/'); $uri->setQueryParam('y1', $request->getStr('y1')); return id(new AphrontRedirectResponse())->setURI($uri); } $types = array('+N:*', '+N:DREV', 'updated'); $engines = PhabricatorFactEngine::loadAllEngines(); $specs = PhabricatorFactSpec::newSpecsForFactTypes($engines, $types); $facts = id(new PhabricatorFactAggregate())->loadAllWhere('factType IN (%Ls)', $types); $rows = array(); foreach ($facts as $fact) { $spec = $specs[$fact->getFactType()]; $name = $spec->getName(); $value = $spec->formatValueForDisplay($user, $fact->getValueX()); $rows[] = array(phutil_escape_html($name), phutil_escape_html($value)); } $table = new AphrontTableView($rows); $table->setHeaders(array('Fact', 'Value')); $table->setColumnClasses(array('wide', 'n')); $panel = new AphrontPanelView(); $panel->setHeader('Facts!'); $panel->appendChild($table); $chart_form = $this->buildChartForm(); return $this->buildStandardPageResponse(array($chart_form, $panel), array('title' => 'Facts!')); }
public function render() { $rows = array(); foreach ($this->edits as $edit) { $name = nonempty($edit->getRuleName(), 'Unknown Rule'); $rule_name = phutil_render_tag('strong', array(), phutil_escape_html($name)); switch ($edit->getAction()) { case 'create': $details = "Created rule '{$rule_name}'."; break; case 'delete': $details = "Deleted rule '{$rule_name}'."; break; case 'edit': default: $details = "Edited rule '{$rule_name}'."; break; } $rows[] = array($edit->getRuleID(), $this->handles[$edit->getEditorPHID()]->renderLink(), $details, phabricator_datetime($edit->getDateCreated(), $this->user)); } $table = new AphrontTableView($rows); $table->setNoDataString("No edits for rule."); $table->setHeaders(array('Rule ID', 'Editor', 'Details', 'Edit Date')); $table->setColumnClasses(array('', '', 'wide', '')); return $table->render(); }
public function renderPanel() { $data = $this->getData(); $sections = array('Basics' => array('Machine' => php_uname('n'))); // NOTE: This may not be present for some SAPIs, like php-fpm. if (!empty($data['Server']['SERVER_ADDR'])) { $addr = $data['Server']['SERVER_ADDR']; $sections['Basics']['Host'] = $addr; $sections['Basics']['Hostname'] = @gethostbyaddr($addr); } $sections = array_merge($sections, $data); $mask = array('HTTP_COOKIE' => true, 'HTTP_X_PHABRICATOR_CSRF' => true); $out = array(); foreach ($sections as $header => $map) { $rows = array(); foreach ($map as $key => $value) { if (isset($mask[$key])) { $rows[] = array($key, phutil_tag('em', array(), '(Masked)')); } else { $rows[] = array($key, is_array($value) ? json_encode($value) : $value); } } $table = new AphrontTableView($rows); $table->setHeaders(array($header, null)); $table->setColumnClasses(array('header', 'wide wrap')); $out[] = $table->render(); } return phutil_implode_html("\n", $out); }
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(); }
public function handleRequest(AphrontRequest $request) { $viewer = $request->getViewer(); if ($request->isFormPost()) { $uri = new PhutilURI('/fact/chart/'); $uri->setQueryParam('y1', $request->getStr('y1')); return id(new AphrontRedirectResponse())->setURI($uri); } $types = array('+N:*', '+N:DREV', 'updated'); $engines = PhabricatorFactEngine::loadAllEngines(); $specs = PhabricatorFactSpec::newSpecsForFactTypes($engines, $types); $facts = id(new PhabricatorFactAggregate())->loadAllWhere('factType IN (%Ls)', $types); $rows = array(); foreach ($facts as $fact) { $spec = $specs[$fact->getFactType()]; $name = $spec->getName(); $value = $spec->formatValueForDisplay($viewer, $fact->getValueX()); $rows[] = array($name, $value); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Fact'), pht('Value'))); $table->setColumnClasses(array('wide', 'n')); $panel = new PHUIObjectBoxView(); $panel->setHeaderText(pht('Facts')); $panel->setTable($table); $chart_form = $this->buildChartForm(); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Home')); $title = pht('Facts'); return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($chart_form, $panel)); }
public function render() { $data = $this->getData(); $rows = array(); $details = ''; foreach ($data as $index => $row) { $file = $row['file']; $line = $row['line']; $tag = phutil_render_tag('a', array('onclick' => jsprintf('show_details(%d)', $index)), phutil_escape_html($row['str'] . ' at [' . basename($file) . ':' . $line . ']')); $rows[] = array($tag); $details .= '<div class="dark-console-panel-error-details" id="row-details-' . $index . '">' . phutil_escape_html($row['details']) . "\n" . 'Stack trace:' . "\n"; foreach ($row['trace'] as $key => $entry) { $line = ''; if (isset($entry['class'])) { $line .= $entry['class'] . '::'; } $line .= idx($entry, 'function', ''); $onclick = ''; if (isset($entry['file'])) { $line .= ' called at [' . $entry['file'] . ':' . $entry['line'] . ']'; $onclick = jsprintf('open_file(%s, %d)', $entry['file'], $entry['line']); } $details .= phutil_render_tag('a', array('onclick' => $onclick), phutil_escape_html($line)); $details .= "\n"; } $details .= '</div>'; } $table = new AphrontTableView($rows); $table->setClassName('error-log'); $table->setHeaders(array('Error')); $table->setNoDataString('No errors.'); return '<div>' . '<div>' . $table->render() . '</div>' . '<div class="dark-console-panel-error-separator"></div>' . '<pre class="PhabricatorMonospaced">' . $details . '</pre>' . '</div>'; }
public function processRequest(AphrontRequest $request) { $viewer = $request->getUser(); $tokens = id(new PhabricatorAuthTemporaryTokenQuery())->setViewer($viewer)->withObjectPHIDs(array($viewer->getPHID()))->execute(); $rows = array(); foreach ($tokens as $token) { if ($token->isRevocable()) { $button = javelin_tag('a', array('href' => '/auth/token/revoke/' . $token->getID() . '/', 'class' => 'small grey button', 'sigil' => 'workflow'), pht('Revoke')); } else { $button = javelin_tag('a', array('class' => 'small grey button disabled'), pht('Revoke')); } if ($token->getTokenExpires() >= time()) { $expiry = phabricator_datetime($token->getTokenExpires(), $viewer); } else { $expiry = pht('Expired'); } $rows[] = array($token->getTokenReadableTypeName(), $expiry, $button); } $table = new AphrontTableView($rows); $table->setNoDataString(pht("You don't have any active tokens.")); $table->setHeaders(array(pht('Type'), pht('Expires'), pht(''))); $table->setColumnClasses(array('wide', 'right', 'action')); $terminate_button = id(new PHUIButtonView())->setText(pht('Revoke All'))->setHref('/auth/token/revoke/all/')->setTag('a')->setWorkflow(true)->setIcon('fa-exclamation-triangle'); $header = id(new PHUIHeaderView())->setHeader(pht('Temporary Tokens'))->addActionLink($terminate_button); $panel = id(new PHUIObjectBoxView())->setHeader($header)->setTable($table); return $panel; }
public function render() { $drequest = $this->getDiffusionRequest(); $current_branch = $drequest->getBranch(); $rows = array(); $rowc = array(); foreach ($this->branches as $branch) { $commit = idx($this->commits, $branch->getHeadCommitIdentifier()); if ($commit) { $details = $commit->getCommitData()->getCommitMessage(); $details = idx(explode("\n", $details), 0); $details = substr($details, 0, 80); $datetime = phabricator_datetime($commit->getEpoch(), $this->user); } else { $datetime = null; $details = null; } $rows[] = array(phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getName()))), 'History'), phutil_render_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getName()))), phutil_escape_html($branch->getName())), self::linkCommit($drequest->getRepository(), $branch->getHeadCommitIdentifier()), $datetime, AphrontTableView::renderSingleDisplayLine(phutil_escape_html($details))); if ($branch->getName() == $current_branch) { $rowc[] = 'highlighted'; } else { $rowc[] = null; } } $view = new AphrontTableView($rows); $view->setHeaders(array('History', 'Branch', 'Head', 'Modified', 'Details')); $view->setColumnClasses(array('', 'pri', '', '', 'wide')); $view->setRowClasses($rowc); return $view->render(); }
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(); $offset = $request->getInt('offset', 0); $pager = new AphrontPagerView(); $pager->setPageSize(250); $pager->setOffset($offset); $pager->setURI($request->getRequestURI(), 'offset'); $list = new PhabricatorMetaMTAMailingList(); $conn_r = $list->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT * FROM %T ORDER BY name ASC LIMIT %d, %d', $list->getTableName(), $pager->getOffset(), $pager->getPageSize() + 1); $data = $pager->sliceResults($data); $lists = $list->loadAllFromArray($data); $rows = array(); foreach ($lists as $list) { $rows[] = array(phutil_escape_html($list->getName()), phutil_escape_html($list->getEmail()), phutil_render_tag('a', array('class' => 'button grey small', 'href' => $this->getApplicationURI('/edit/' . $list->getID() . '/')), 'Edit')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Email', '')); $table->setColumnClasses(array(null, 'wide', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Mailing Lists'); $panel->setCreateButton('Add New List', $this->getApplicationURI('/edit/')); $panel->appendChild($pager); return $this->buildApplicationPage($panel, array('title' => 'Mailing Lists')); }
public function render() { $data = $this->getData(); $lib_data = $data['libraries']; $lib_rows = array(); foreach ($lib_data as $key => $value) { $lib_rows[] = array(phutil_escape_html($key), phutil_escape_html($value)); } $lib_table = new AphrontTableView($lib_rows); $lib_table->setHeaders(array('Library', 'Loaded From')); $lib_table->setColumnClasses(array('header', 'wide wrap')); $config_data = $data['config']; ksort($config_data); $mask = PhabricatorEnv::getEnvConfig('darkconsole.config-mask'); $mask = array_fill_keys($mask, true); foreach ($mask as $masked_key => $ignored) { if (!PhabricatorEnv::envConfigExists($masked_key)) { throw new Exception("Configuration 'darkconsole.config-mask' masks unknown " . "configuration key '" . $masked_key . "'. If this key has been " . "renamed, you might be accidentally exposing information which you " . "don't intend to."); } } $rows = array(); foreach ($config_data as $key => $value) { if (empty($mask[$key])) { $display_value = is_array($value) ? json_encode($value) : $value; $display_value = phutil_escape_html($display_value); } else { $display_value = phutil_escape_html('<Masked>'); } $rows[] = array(phutil_escape_html($key), $display_value); } $table = new AphrontTableView($rows); $table->setHeaders(array('Key', 'Value')); $table->setColumnClasses(array('header', 'wide wrap')); return $lib_table->render() . $table->render(); }
public function processRequest() { $request = $this->getRequest(); $phids = $request->getStrList('phids'); if ($phids) { $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); foreach ($handles as $handle) { if ($handle->getURI()) { $link = phutil_render_tag('a', array('href' => $handle->getURI()), phutil_escape_html($handle->getURI())); } else { $link = null; } $rows[] = array(phutil_escape_html($handle->getPHID()), phutil_escape_html($handle->getType()), phutil_escape_html($handle->getName()), $link); } $table = new AphrontTableView($rows); $table->setHeaders(array('PHID', 'Type', 'Name', 'URI')); $table->setColumnClasses(array(null, null, null, 'wide')); $panel = new AphrontPanelView(); $panel->setHeader('PHID Handles'); $panel->appendChild($table); return $this->buildStandardPageResponse($panel, array('title' => 'PHID Lookup Results')); } $lookup_form = new AphrontFormView(); $lookup_form->setUser($request->getUser()); $lookup_form->setAction('/phid/')->appendChild(id(new AphrontFormTextAreaControl())->setName('phids')->setCaption('Enter PHIDs separated by spaces or commas.'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Lookup PHIDs')); $lookup_panel = new AphrontPanelView(); $lookup_panel->setHeader('Lookup PHIDs'); $lookup_panel->appendChild($lookup_form); $lookup_panel->setWidth(AphrontPanelView::WIDTH_WIDE); return $this->buildStandardPageResponse(array($lookup_panel), array('title' => 'PHID Lookup')); }
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 processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); $query = $request->getStr('q'); // Default this to the query string to make debugging a little bit easier. $raw_query = nonempty($request->getStr('raw'), $query); // This makes form submission easier in the debug view. $this->class = nonempty($request->getStr('class'), $this->class); $sources = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorTypeaheadDatasource')->loadObjects(); if (isset($sources[$this->class])) { $source = $sources[$this->class]; $source->setParameters($request->getRequestData()); $composite = new PhabricatorTypeaheadRuntimeCompositeDatasource(); $composite->addDatasource($source); $composite->setViewer($viewer)->setQuery($query)->setRawQuery($raw_query); $results = $composite->loadResults(); } else { $results = array(); } $content = mpull($results, 'getWireFormat'); if ($request->isAjax()) { return id(new AphrontAjaxResponse())->setContent($content); } // If there's a non-Ajax request to this endpoint, show results in a tabular // format to make it easier to debug typeahead output. $options = array_fuse(array_keys($sources)); asort($options); $form = id(new AphrontFormView())->setUser($viewer)->setAction('/typeahead/class/')->appendChild(id(new AphrontFormSelectControl())->setLabel(pht('Source Class'))->setName('class')->setValue($this->class)->setOptions($options))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Query'))->setName('q')->setValue($request->getStr('q')))->appendChild(id(new AphrontFormTextControl())->setLabel(pht('Raw Query'))->setName('raw')->setValue($request->getStr('raw')))->appendChild(id(new AphrontFormSubmitControl())->setValue(pht('Query'))); $form_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Token Query'))->setForm($form); $table = new AphrontTableView($content); $table->setHeaders(array(pht('Name'), pht('URI'), pht('PHID'), pht('Priority'), pht('Display Name'), pht('Display Type'), pht('Image URI'), pht('Priority Type'), pht('Icon'), pht('Closed'), pht('Sprite'))); $result_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Token Results (%s)', $this->class))->appendChild($table); return $this->buildApplicationPage(array($form_box, $result_box), array('title' => pht('Typeahead Results'), 'device' => false)); }
public function render() { $rows = array(); $rowc = array(); // TODO: Experiment with path stack rendering. // TODO: Copy Away and Move Away are rendered junkily still. foreach ($this->pathChanges as $id => $change) { $path = $change->getPath(); $hash = substr(md5($path), 0, 8); if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) { $path .= '/'; } if (isset($this->renderingReferences[$id])) { $path_column = javelin_render_tag('a', array('href' => '#' . $hash, 'meta' => array('id' => 'diff-' . $hash, 'ref' => $this->renderingReferences[$id]), 'sigil' => 'differential-load'), phutil_escape_html($path)); } else { $path_column = phutil_escape_html($path); } $rows[] = array($this->linkHistory($change->getPath()), $this->linkBrowse($change->getPath()), $this->linkChange($change->getChangeType(), $change->getFileType(), $change->getPath()), $path_column); $row_class = null; foreach ($this->ownersPaths as $owners_path) { $owners_path = $owners_path->getPath(); if (strncmp('/' . $path, $owners_path, strlen($owners_path)) == 0) { $row_class = 'highlighted'; break; } } $rowc[] = $row_class; } $view = new AphrontTableView($rows); $view->setHeaders(array('History', 'Browse', 'Change', 'Path')); $view->setColumnClasses(array('', '', '', 'wide')); $view->setRowClasses($rowc); $view->setNoDataString('This change has not been fully parsed yet.'); return $view->render(); }
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(); }
public function render() { $drequest = $this->getDiffusionRequest(); $current_branch = $drequest->getBranch(); $repository = $drequest->getRepository(); Javelin::initBehavior('phabricator-tooltips'); $doc_href = PhabricatorEnv::getDoclink('Diffusion User Guide: Autoclose'); $rows = array(); $rowc = array(); foreach ($this->branches as $branch) { $commit = idx($this->commits, $branch->getCommitIdentifier()); if ($commit) { $details = $commit->getSummary(); $datetime = phabricator_datetime($commit->getEpoch(), $this->user); } else { $datetime = null; $details = null; } switch ($repository->shouldSkipAutocloseBranch($branch->getShortName())) { case PhabricatorRepository::BECAUSE_REPOSITORY_IMPORTING: $icon = 'fa-times bluegrey'; $tip = pht('Repository Importing'); break; case PhabricatorRepository::BECAUSE_AUTOCLOSE_DISABLED: $icon = 'fa-times bluegrey'; $tip = pht('Repository Autoclose Disabled'); break; case PhabricatorRepository::BECAUSE_BRANCH_UNTRACKED: $icon = 'fa-times bluegrey'; $tip = pht('Branch Untracked'); break; case PhabricatorRepository::BECAUSE_BRANCH_NOT_AUTOCLOSE: $icon = 'fa-times bluegrey'; $tip = pht('Branch Autoclose Disabled'); break; case null: $icon = 'fa-check bluegrey'; $tip = pht('Autoclose Enabled'); break; default: $icon = 'fa-question'; $tip = pht('Status Unknown'); break; } $status_icon = id(new PHUIIconView())->setIconFont($icon)->addSigil('has-tooltip')->setHref($doc_href)->setMetadata(array('tip' => $tip, 'size' => 200)); $rows[] = array(phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'history', 'branch' => $branch->getShortName()))), pht('History')), phutil_tag('a', array('href' => $drequest->generateURI(array('action' => 'browse', 'branch' => $branch->getShortName()))), $branch->getShortName()), self::linkCommit($drequest->getRepository(), $branch->getCommitIdentifier()), $status_icon, $datetime, AphrontTableView::renderSingleDisplayLine($details)); if ($branch->getShortName() == $current_branch) { $rowc[] = 'highlighted'; } else { $rowc[] = null; } } $view = new AphrontTableView($rows); $view->setHeaders(array(pht('History'), pht('Branch'), pht('Head'), pht(''), pht('Modified'), pht('Details'))); $view->setColumnClasses(array('', 'pri', '', '', '', 'wide')); $view->setRowClasses($rowc); return $view->render(); }
public function render() { $user = $this->getUser(); $trace = $this->trace; $libraries = PhutilBootloader::getInstance()->getAllLibraries(); // TODO: Make this configurable? $path = 'https://secure.phabricator.com/diffusion/%s/browse/master/src/'; $callsigns = array('arcanist' => 'ARC', 'phutil' => 'PHU', 'phabricator' => 'P'); $rows = array(); $depth = count($trace); foreach ($trace as $part) { $lib = null; $file = idx($part, 'file'); $relative = $file; foreach ($libraries as $library) { $root = phutil_get_library_root($library); if (Filesystem::isDescendant($file, $root)) { $lib = $library; $relative = Filesystem::readablePath($file, $root); break; } } $where = ''; if (isset($part['class'])) { $where .= $part['class'] . '::'; } if (isset($part['function'])) { $where .= $part['function'] . '()'; } if ($file) { if (isset($callsigns[$lib])) { $attrs = array('title' => $file); try { $attrs['href'] = $user->loadEditorLink('/src/' . $relative, $part['line'], $callsigns[$lib]); } catch (Exception $ex) { // The database can be inaccessible. } if (empty($attrs['href'])) { $attrs['href'] = sprintf($path, $callsigns[$lib]) . str_replace(DIRECTORY_SEPARATOR, '/', $relative) . '$' . $part['line']; $attrs['target'] = '_blank'; } $file_name = phutil_tag('a', $attrs, $relative); } else { $file_name = phutil_tag('span', array('title' => $file), $relative); } $file_name = hsprintf('%s : %d', $file_name, $part['line']); } else { $file_name = phutil_tag('em', array(), '(Internal)'); } $rows[] = array($depth--, $lib, $file_name, $where); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Depth'), pht('Library'), pht('File'), pht('Where'))); $table->setColumnClasses(array('n', '', '', 'wide')); return phutil_tag('div', array('class' => 'exception-trace'), $table->render()); }