public function processRequest() { $items = id(new PhabricatorDirectoryItem())->loadAll(); $items = msort($items, 'getSortKey'); $categories = id(new PhabricatorDirectoryCategory())->loadAll(); $categories = msort($categories, 'getSequence'); $category_map = mpull($categories, 'getName', 'getID'); $category_map[0] = 'Free Radicals'; $items = mgroup($items, 'getCategoryID'); require_celerity_resource('phabricator-directory-css'); $content = array(); foreach ($category_map as $id => $category_name) { $category_items = idx($items, $id); if (!$category_items) { continue; } $item_markup = array(); foreach ($category_items as $item) { $item_markup[] = '<div>' . '<h2>' . phutil_render_tag('a', array('href' => $item->getHref()), phutil_escape_html($item->getName())) . '</h2>' . '<p>' . phutil_escape_html($item->getDescription()) . '</p>' . '</div>'; } $content[] = '<div class="aphront-directory-category">' . '<h1>' . phutil_escape_html($category_name) . '</h1>' . '<div class="aphront-directory-group">' . implode("\n", $item_markup) . '</div>' . '</div>'; } $content = '<div class="aphront-directory-list">' . implode("\n", $content) . '</div>'; return $this->buildStandardPageResponse($content, array('title' => 'Directory', 'tab' => 'directory')); }
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(); $timer = id(new PhabricatorTimer())->load($this->id); if (!$timer) { return new Aphront404Response(); } require_celerity_resource('phabricator-countdown-css'); $chrome_visible = $request->getBool('chrome', true); $chrome_new = $chrome_visible ? false : null; $chrome_link = phutil_render_tag('a', array('href' => $request->getRequestURI()->alter('chrome', $chrome_new), 'class' => 'phabricator-timer-chrome-link'), $chrome_visible ? 'Disable Chrome' : 'Enable Chrome'); $content = '<div class="phabricator-timer"> <h1 class="phabricator-timer-header">' . phutil_escape_html($timer->getTitle()) . ' · ' . phabricator_datetime($timer->getDatePoint(), $user) . '</h1> <div class="phabricator-timer-pane"> <table class="phabricator-timer-table"> <tr> <th>Days</th> <th>Hours</th> <th>Minutes</th> <th>Seconds</th> </tr> <tr> <td id="phabricator-timer-days"></td> <td id="phabricator-timer-hours"></td> <td id="phabricator-timer-minutes"></td> <td id="phabricator-timer-seconds"></td> </table> </div>' . $chrome_link . '</div>'; Javelin::initBehavior('countdown-timer', array('timestamp' => $timer->getDatepoint())); $panel = $content; return $this->buildStandardPageResponse($panel, array('title' => 'Countdown: ' . $timer->getTitle(), 'chrome' => $chrome_visible)); }
public final function render() { require_celerity_resource('aphront-error-view-css'); $errors = $this->errors; if ($errors) { $list = array(); foreach ($errors as $error) { $list[] = phutil_render_tag('li', array(), phutil_escape_html($error)); } $list = '<ul>' . implode("\n", $list) . '</ul>'; } else { $list = null; } $title = $this->title; if (strlen($title)) { $title = '<h1>' . phutil_escape_html($title) . '</h1>'; } else { $title = null; } $this->severity = nonempty($this->severity, self::SEVERITY_ERROR); $this->width = nonempty($this->width, self::WIDTH_DEFAULT); $more_classes = array(); $more_classes[] = 'aphront-error-severity-' . $this->severity; $more_classes[] = 'aphront-error-width-' . $this->width; $more_classes = implode(' ', $more_classes); return phutil_render_tag('div', array('id' => $this->id, 'class' => 'aphront-error-view ' . $more_classes), $title . $this->renderChildren() . $list); }
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() { $title = 'OAuth Clients'; $request = $this->getRequest(); $current_user = $request->getUser(); $offset = $request->getInt('offset', 0); $page_size = 100; $pager = new AphrontPagerView(); $request_uri = $request->getRequestURI(); $pager->setURI($request_uri, 'offset'); $pager->setPageSize($page_size); $pager->setOffset($offset); $query = new PhabricatorOAuthServerClientQuery(); $query->withCreatorPHIDs(array($current_user->getPHID())); $clients = $query->executeWithPager($pager); $rows = array(); $rowc = array(); $highlight = $this->getHighlightPHIDs(); foreach ($clients as $client) { $row = array(phutil_render_tag('a', array('href' => $client->getViewURI()), phutil_escape_html($client->getName())), $client->getPHID(), $client->getSecret(), phutil_render_tag('a', array('href' => $client->getRedirectURI()), phutil_escape_html($client->getRedirectURI())), phutil_render_tag('a', array('class' => 'small button grey', 'href' => $client->getEditURI()), 'Edit')); $rows[] = $row; if (isset($highlight[$client->getPHID()])) { $rowc[] = 'highlighted'; } else { $rowc[] = ''; } } $panel = $this->buildClientList($rows, $rowc, $title); return $this->buildStandardPageResponse(array($this->getNoticeView(), $panel->appendChild($pager)), array('title' => $title)); }
public function renderValueForRevisionView() { $diff = $this->getDiff(); $path_changesets = mpull($diff->loadChangesets(), 'getId', 'getFilename'); $lstar = DifferentialRevisionUpdateHistoryView::renderDiffLintStar($diff); $lmsg = DifferentialRevisionUpdateHistoryView::getDiffLintMessage($diff); $ldata = $this->getDiffProperty('arc:lint'); $ltail = null; if ($ldata) { $ldata = igroup($ldata, 'path'); $lint_messages = array(); foreach ($ldata as $path => $messages) { $message_markup = array(); foreach ($messages as $message) { $path = idx($message, 'path'); $line = idx($message, 'line'); $code = idx($message, 'code'); $severity = idx($message, 'severity'); $name = idx($message, 'name'); $description = idx($message, 'description'); $line_link = phutil_escape_html($line); if (isset($path_changesets[$path])) { // TODO: Create standalone links for large diffs. Logic is in // DifferentialDiffTableOfContentsView::renderChangesetLink(). $line_link = phutil_render_tag('a', array('href' => '#C' . $path_changesets[$path] . 'NL' . $line), $line_link); } $message_markup[] = hsprintf('<li>' . '<span class="lint-severity-%s">%s</span> (%s) %s ' . 'at line ' . $line_link . '<p>%s</p>' . '</li>', $severity, ucwords($severity), $code, $name, $description); } $lint_messages[] = '<li class="lint-file-block">' . 'Lint for <strong>' . phutil_escape_html($path) . '</strong>' . '<ul>' . implode("\n", $message_markup) . '</ul>' . '</li>'; } $lexcuse = $this->getLintExcuse(); $ltail = '<div class="differential-lint-block">' . $lexcuse . '<ul>' . implode("\n", $lint_messages) . '</ul>' . '</div>'; } return $lstar . ' ' . $lmsg . $ltail; }
public function markupDocumentLink($matches) { $slug = trim($matches[1]); $name = trim(idx($matches, 2, $slug)); // If whatever is being linked to begins with "/" or has "://", treat it // as a URI instead of a wiki page. $is_uri = preg_match('@(^/)|(://)@', $slug); if ($is_uri) { $protocols = $this->getEngine()->getConfig('uri.allowed-protocols', array()); $protocol = id(new PhutilURI($slug))->getProtocol(); if (!idx($protocols, $protocol)) { // Don't treat this as a URI if it's not an allowed protocol. $is_uri = false; } } if ($is_uri) { $uri = $slug; // Leave the name unchanged, i.e. link the whole URI if there's no // explicit name. } else { $name = explode('/', trim($name, '/')); $name = end($name); $slug = PhrictionDocument::normalizeSlug($slug); $uri = PhrictionDocument::getSlugURI($slug); } return $this->getEngine()->storeText(phutil_render_tag('a', array('href' => $uri, 'class' => $is_uri ? null : 'phriction-link'), phutil_escape_html($name))); }
public function processRequest() { $drequest = $this->diffusionRequest; $request = $this->getRequest(); $page_size = $request->getInt('pagesize', 100); $offset = $request->getInt('page', 0); $history_query = DiffusionHistoryQuery::newFromDiffusionRequest($drequest); $history_query->setOffset($offset); $history_query->setLimit($page_size + 1); if (!$request->getBool('copies')) { $history_query->needDirectChanges(true); $history_query->needChildChanges(true); } $history = $history_query->loadHistory(); $phids = array(); foreach ($history as $item) { $data = $item->getCommitData(); if ($data) { if ($data->getCommitDetail('authorPHID')) { $phids[$data->getCommitDetail('authorPHID')] = true; } } } $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $pager = new AphrontPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); if (count($history) == $page_size + 1) { array_pop($history); $pager->setHasMorePages(true); } else { $pager->setHasMorePages(false); } $pager->setURI($request->getRequestURI(), 'page'); $content = array(); $content[] = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history')); if ($request->getBool('copies')) { $button_title = 'Hide Copies/Branches'; } else { $button_title = 'Show Copies/Branches'; } $button_uri = $request->getRequestURI()->alter('copies', !$request->getBool('copies')); $button = phutil_render_tag('a', array('class' => 'button small grey', 'href' => $button_uri), phutil_escape_html($button_title)); $history_table = new DiffusionHistoryTableView(); $history_table->setDiffusionRequest($drequest); $history_table->setHandles($handles); $history_table->setHistory($history); $history_panel = new AphrontPanelView(); $history_panel->setHeader('History'); $history_panel->addButton($button); $history_panel->appendChild($history_table); $history_panel->appendChild($pager); $content[] = $history_panel; // TODO: Sometimes we do have a change view, we need to look at the most // recent history entry to figure it out. $nav = $this->buildSideNav('history', false); $nav->appendChild($content); return $this->buildStandardPageResponse($nav, array('title' => 'history')); }
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 $change) { $path = $change->getPath(); $hash = substr(md5($path), 0, 8); if ($change->getFileType() == DifferentialChangeType::FILE_DIRECTORY) { $path .= '/'; } $path_column = phutil_render_tag('a', array('href' => '#' . $hash), 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() { $application = $this->application; require_celerity_resource('phabricator-application-launch-view-css'); $content = array(); $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-name'), phutil_escape_html($application->getName())); $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-description'), phutil_escape_html($application->getShortDescription())); $count = 0; if ($this->status) { $content[] = '<span class="phabricator-application-status-block">'; foreach ($this->status as $status) { $count += $status->getCount(); $content[] = $status; } $content[] = '</span>'; } if ($count) { $content[] = phutil_render_tag('span', array('class' => 'phabricator-application-launch-attention'), phutil_escape_html($count)); } $classes = array(); $classes[] = 'phabricator-application-launch-icon'; $styles = array(); if ($application->getIconURI()) { $styles[] = 'background-image: url(' . $application->getIconURI() . ')'; } else { $autosprite = $application->getAutospriteName(); $classes[] = 'autosprite'; $classes[] = 'app-' . $autosprite . '-full'; } $icon = phutil_render_tag('span', array('class' => implode(' ', $classes), 'style' => nonempty(implode('; ', $styles), null)), ''); return phutil_render_tag('a', array('class' => 'phabricator-application-launch-container', 'href' => $application->getBaseURI()), $icon . $this->renderSingleView($content)); }
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 buildView() { if (!$this->user) { throw new Exception('Call setUser() before buildView()!'); } $user = $this->user; $stories = $this->stories; $handles = array(); if ($stories) { $handle_phids = array_mergev(mpull($stories, 'getRequiredHandlePHIDs')); $object_phids = array_mergev(mpull($stories, 'getRequiredObjectPHIDs')); $handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles(); } $null_view = new AphrontNullView(); require_celerity_resource('phabricator-feed-css'); $last_date = null; foreach ($stories as $story) { $story->setHandles($handles); $story->setFramed($this->framed); $date = ucfirst(phabricator_relative_date($story->getEpoch(), $user)); if ($date !== $last_date) { if ($last_date !== null) { $null_view->appendChild('<div class="phabricator-feed-story-date-separator"></div>'); } $last_date = $date; $null_view->appendChild(phutil_render_tag('div', array('class' => 'phabricator-feed-story-date'), phutil_escape_html($date))); } $view = $story->renderView(); $view->setViewer($user); $null_view->appendChild($view); } return id(new AphrontNullView())->appendChild('<div class="phabricator-feed-frame">' . $null_view->render() . '</div>'); }
public function processRequest() { $request = $this->getRequest(); $nav = new AphrontSideNavView(); $links = array('calls' => 'All Calls'); if (empty($links[$this->view])) { $this->view = key($links); } foreach ($links as $slug => $name) { $nav->addNavItem(phutil_render_tag('a', array('href' => '/conduit/log/view/' . $slug . '/', 'class' => $slug == $this->view ? 'aphront-side-nav-selected' : null), phutil_escape_html($name))); } $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $calls = $call_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $calls = $pager->sliceResults($calls); $pager->setURI(new PhutilURI('/conduit/log/view/' . $this->view . '/'), 'page'); $pager->setEnableKeyboardShortcuts(true); $min = $pager->getOffset() + 1; $max = $min + count($calls) - 1; $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Method Calls (' . $min . '-' . $max . ')'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Conduit Logs', 'tab' => 'logs')); }
public final function render() { require_celerity_resource('aphront-error-view-css'); $errors = $this->errors; if ($errors) { $list = array(); foreach ($errors as $error) { $list[] = phutil_render_tag('li', array(), phutil_escape_html($error)); } $list = phutil_render_tag('ul', array('class' => 'aphront-error-view-list'), implode("\n", $list)); } else { $list = null; } $title = $this->title; if (strlen($title)) { $title = phutil_render_tag('h1', array('class' => 'aphront-error-view-head'), phutil_escape_html($title)); } else { $title = null; } $this->severity = nonempty($this->severity, self::SEVERITY_ERROR); $more_classes = array(); $more_classes[] = 'aphront-error-severity-' . $this->severity; $more_classes = implode(' ', $more_classes); return phutil_render_tag('div', array('id' => $this->id, 'class' => 'aphront-error-view ' . $more_classes), $title . phutil_render_tag('div', array('class' => 'aphront-error-view-body'), $this->renderChildren() . $list)); }
function phabricator_render_form(PhabricatorUser $user, $attributes, $content) { if (strcasecmp(idx($attributes, 'method'), 'POST') == 0 && !preg_match('#^(https?:|//)#', idx($attributes, 'action'))) { $content = phutil_render_tag('input', array('type' => 'hidden', 'name' => AphrontRequest::getCSRFTokenName(), 'value' => $user->getCSRFToken())) . phutil_render_tag('input', array('type' => 'hidden', 'name' => '__form__', 'value' => true)) . $content; } return javelin_render_tag('form', $attributes, $content); }
public function render() { $handle = $this->handle; $type_name = nonempty($handle->getTypeName(), 'Document'); require_celerity_resource('phabricator-search-results-css'); $link = phutil_render_tag('a', array('href' => $handle->getURI()), PhabricatorEnv::getProductionURI($handle->getURI())); $img = $handle->getImageURI(); if ($img) { $img = phutil_render_tag('div', array('class' => 'result-image', 'style' => "background-image: url('{$img}');"), ''); } switch ($handle->getType()) { case PhabricatorPHIDConstants::PHID_TYPE_CMIT: $object_name = $handle->getName(); if ($this->object) { $data = $this->object->getCommitData(); $summary = $data->getSummary(); if (strlen($summary)) { $object_name = $handle->getName() . ': ' . $data->getSummary(); } } break; default: $object_name = $handle->getFullName(); break; } return '<div class="phabricator-search-result">' . $img . '<div class="result-desc">' . phutil_render_tag('a', array('class' => 'result-name', 'href' => $handle->getURI()), $this->emboldenQuery($object_name)) . '<div class="result-type">' . $type_name . ' · ' . $link . '</div>' . '</div>' . '<div style="clear: both;"></div>' . '</div>'; }
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(); if ($request->isFormPost()) { $parser = new ArcanistDiffParser(); $diff = null; try { $diff = PhabricatorFile::readUploadedFileData($_FILES['diff-file']); } catch (Exception $ex) { $diff = $request->getStr('diff'); } $changes = $parser->parseDiff($diff); $diff = DifferentialDiff::newFromRawChanges($changes); $diff->setLintStatus(DifferentialLintStatus::LINT_SKIP); $diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP); $diff->setAuthorPHID($request->getUser()->getPHID()); $diff->setCreationMethod('web'); $diff->save(); return id(new AphrontRedirectResponse())->setURI('/differential/diff/' . $diff->getID() . '/'); } $form = new AphrontFormView(); $arcanist_href = PhabricatorEnv::getDoclink('article/Arcanist_User_Guide.html'); $arcanist_link = phutil_render_tag('a', array('href' => $arcanist_href, 'target' => '_blank'), 'Arcanist'); $form->setAction('/differential/diff/create/')->setEncType('multipart/form-data')->setUser($request->getUser())->appendChild('<p class="aphront-form-instructions">The best way to create a ' . "Differential diff is by using {$arcanist_link}, but you " . 'can also just paste a diff (e.g., from <tt>svn diff</tt> or ' . '<tt>git diff</tt>) into this box or upload it as a file if you ' . 'really want.</p>')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Raw Diff')->setName('diff')->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))->appendChild(id(new AphrontFormFileControl())->setLabel('Raw Diff from file')->setName('diff-file'))->appendChild(id(new AphrontFormSubmitControl())->setValue("Create Diff »")); $panel = new AphrontPanelView(); $panel->setHeader('Create New Diff'); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); return $this->buildStandardPageResponse($panel, array('title' => 'Create Diff', 'tab' => 'create')); }
private function buildNavItems() { $classes = $this->getAllMethodImplementationClasses(); $method_names = array(); foreach ($classes as $method_class) { $method_name = ConduitAPIMethod::getAPIMethodNameFromClassName($method_class); $parts = explode('.', $method_name); $method_names[] = array('full_name' => $method_name, 'group_name' => reset($parts)); } $method_names = igroup($method_names, 'group_name'); ksort($method_names); $items = array(); foreach ($method_names as $group => $methods) { $items[] = phutil_render_tag('a', array(), phutil_escape_html($group)); foreach ($methods as $method) { $method_name = $method['full_name']; $selected = $method_name == $this->method; $items[] = phutil_render_tag('a', array('class' => $selected ? 'aphront-side-nav-selected' : null, 'href' => '/conduit/method/' . $method_name), '<span style="padding-left: 1em;">' . phutil_escape_html($method_name) . '</span>'); } $items[] = '<hr />'; } // Pop off the last '<hr />'. array_pop($items); return $items; }
public function didMarkupText() { $engine = $this->getEngine(); $metadata_key = self::KEY_RULE_MENTION; $metadata = $engine->getTextMetadata($metadata_key, array()); if (empty($metadata)) { // No mentions, or we already processed them. return; } $usernames = array_keys($metadata); $user_table = new PhabricatorUser(); $real_user_names = queryfx_all($user_table->establishConnection('r'), 'SELECT username, phid, realName FROM %T WHERE username IN (%Ls)', $user_table->getTableName(), $usernames); $actual_users = array(); $mentioned_key = self::KEY_MENTIONED; $mentioned = $engine->getTextMetadata($mentioned_key, array()); foreach ($real_user_names as $row) { $actual_users[strtolower($row['username'])] = $row; $mentioned[$row['phid']] = $row['phid']; } $engine->setTextMetadata($mentioned_key, $mentioned); foreach ($metadata as $username => $tokens) { $exists = isset($actual_users[$username]); $class = $exists ? 'phabricator-remarkup-mention-exists' : 'phabricator-remarkup-mention-unknown'; if ($exists) { $tag = phutil_render_tag('a', array('class' => $class, 'href' => '/p/' . $username . '/', 'target' => '_blank', 'title' => $actual_users[$username]['realName']), phutil_escape_html('@' . $username)); } else { $tag = phutil_render_tag('span', array('class' => $class), phutil_escape_html('@' . $username)); } foreach ($tokens as $token) { $engine->overwriteStoredText($token, $tag); } } // Don't re-process these mentions. $engine->setTextMetadata($metadata_key, array()); }
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 render() { $icon = null; if ($this->icon) { $icon = phutil_render_tag('span', array('class' => 'phabricator-action-view-icon autosprite ' . 'action-' . $this->icon), ''); } if ($this->href) { if ($this->renderAsForm) { if (!$this->user) { throw new Exception('Call setUser() when rendering an action as a form.'); } $item = javelin_render_tag('button', array('class' => 'phabricator-action-view-item'), phutil_escape_html($this->name)); $item = phabricator_render_form($this->user, array('action' => $this->href, 'method' => 'POST', 'sigil' => $this->workflow ? 'workflow' : null), $item); } else { $item = javelin_render_tag('a', array('href' => $this->href, 'class' => 'phabricator-action-view-item', 'sigil' => $this->workflow ? 'workflow' : null), phutil_escape_html($this->name)); } } else { $item = phutil_render_tag('span', array('class' => 'phabricator-action-view-item'), phutil_escape_html($this->name)); } $classes = array(); $classes[] = 'phabricator-action-view'; if ($this->disabled) { $classes[] = 'phabricator-action-view-disabled'; } return phutil_render_tag('li', array('class' => implode(' ', $classes)), $icon . $item); }
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(); $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 processRequest() { $classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->selectAndLoadSymbols(); $classes = ipull($classes, 'name', 'name'); $selected = null; foreach ($classes as $class => $ignored) { $classes[$class] = newv($class, array()); if ($this->class == $classes[$class]->getName()) { $selected = $class; } } if (!$selected) { reset($classes); $selected = key($classes); } $nav = new AphrontSideNavView(); foreach ($classes as $class => $obj) { $name = $obj->getName(); $nav->addNavItem(phutil_render_tag('a', array('href' => '/uiexample/view/' . $name . '/', 'class' => $selected == $class ? 'aphront-side-nav-selected' : null), phutil_escape_html($obj->getName()))); } require_celerity_resource('phabricator-ui-example-css'); $example = $classes[$selected]; $example->setRequest($this->getRequest()); $nav->appendChild('<div class="phabricator-ui-example-header">' . '<h1 class="phabricator-ui-example-name">' . phutil_escape_html($example->getName()) . ' (' . get_class($example) . ')' . '</h1>' . '<p class="phabricator-ui-example-description">' . $example->getDescription() . '</p>' . '</div>'); $nav->appendChild($example->renderExample()); return $this->buildStandardPageResponse($nav, array('title' => 'UI Example')); }
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() { $phid = $this->getAuthorizationPHID(); $title = 'Edit OAuth Client Authorization'; $request = $this->getRequest(); $current_user = $request->getUser(); $authorization = id(new PhabricatorOAuthClientAuthorization())->loadOneWhere('phid = %s', $phid); if (empty($authorization)) { return new Aphront404Response(); } if ($authorization->getUserPHID() != $current_user->getPHID()) { $message = 'Access denied to client authorization with phid ' . $phid . '. ' . 'Only the user who authorized the client has permission to ' . 'edit the authorization.'; return id(new Aphront403Response())->setForbiddenText($message); } if ($request->isFormPost()) { $scopes = PhabricatorOAuthServerScope::getScopesFromRequest($request); $authorization->setScope($scopes); $authorization->save(); return id(new AphrontRedirectResponse())->setURI('/oauthserver/clientauthorization/?edited=' . $phid); } $client_phid = $authorization->getClientPHID(); $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $client_phid); $created = phabricator_datetime($authorization->getDateCreated(), $current_user); $updated = phabricator_datetime($authorization->getDateModified(), $current_user); $panel = new AphrontPanelView(); $delete_button = phutil_render_tag('a', array('href' => $authorization->getDeleteURI(), 'class' => 'grey button'), 'Delete OAuth Client Authorization'); $panel->addButton($delete_button); $panel->setHeader($title); $form = id(new AphrontFormView())->setUser($current_user)->appendChild(id(new AphrontFormMarkupControl())->setLabel('Client')->setValue(phutil_render_tag('a', array('href' => $client->getViewURI()), phutil_escape_html($client->getName()))))->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setValue($created))->appendChild(id(new AphrontFormStaticControl())->setLabel('Last Updated')->setValue($updated))->appendChild(PhabricatorOAuthServerScope::getCheckboxControl($authorization->getScope()))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save OAuth Client Authorization')->addCancelButton('/oauthserver/clientauthorization/')); $panel->appendChild($form); return $this->buildStandardPageResponse($panel, array('title' => $title)); }
public function render() { $rows = array(); $any_hidden = false; foreach ($this->rows as $row) { $style = idx($row, 'style'); switch ($style) { case 'section': $cells = phutil_render_tag('th', array('colspan' => 2), idx($row, 'name')); break; default: $name = phutil_render_tag('th', array(), idx($row, 'name')); $value = phutil_render_tag('td', array(), idx($row, 'value')); $cells = $name . $value; break; } $show = idx($row, 'show'); $rows[] = javelin_render_tag('tr', array('style' => $show ? null : 'display: none', 'sigil' => $show ? null : 'differential-results-row-toggle', 'class' => 'differential-results-row-' . $style), $cells); if (!$show) { $any_hidden = true; } } if ($any_hidden) { $show_more = javelin_render_tag('a', array('href' => '#', 'mustcapture' => true), $this->showMoreString); $hide_more = javelin_render_tag('a', array('href' => '#', 'mustcapture' => true), 'Hide'); $rows[] = javelin_render_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-show'), '<th colspan="2">' . $show_more . '</td>'); $rows[] = javelin_render_tag('tr', array('class' => 'differential-results-row-show', 'sigil' => 'differential-results-row-hide', 'style' => 'display: none'), '<th colspan="2">' . $hide_more . '</th>'); Javelin::initBehavior('differential-show-field-details'); } require_celerity_resource('differential-results-table-css'); return javelin_render_tag('table', array('class' => 'differential-results-table', 'sigil' => 'differential-results-table'), implode("\n", $rows)); }
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(); }