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() { 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() { require_celerity_resource('differential-changeset-view-css'); require_celerity_resource('syntax-highlighting-css'); if ($this->revisionID) { $edit = true; } else { $edit = false; } $changeset = $this->changeset; $class = 'differential-changeset'; if (!$edit) { $class .= ' differential-changeset-immutable'; } $buttons = null; if ($this->buttons) { $buttons = '<div class="differential-changeset-buttons">' . implode('', $this->buttons) . '</div>'; } $id = $this->getID(); if ($this->symbolIndex) { Javelin::initBehavior('repository-crossreference', array('container' => $id) + $this->symbolIndex); } $display_filename = $changeset->getDisplayFilename(); $output = javelin_render_tag('div', array('sigil' => 'differential-changeset', 'meta' => array('left' => $this->changeset->getID(), 'right' => $this->changeset->getID()), 'class' => $class, 'id' => $id), phutil_render_tag('a', array('name' => $changeset->getAnchorName()), '') . $buttons . '<h1>' . phutil_escape_html($display_filename) . '</h1>' . '<div style="clear: both;"></div>' . $this->renderChildren()); return $output; }
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(); $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'); $container = celerity_generate_unique_node_id(); $content = '<div class="phabricator-timer" id="' . $container . '"> <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>' . javelin_render_tag('td', array('sigil' => 'phabricator-timer-days'), '') . javelin_render_tag('td', array('sigil' => 'phabricator-timer-hours'), '') . javelin_render_tag('td', array('sigil' => 'phabricator-timer-minutes'), '') . javelin_render_tag('td', array('sigil' => 'phabricator-timer-seconds'), '') . '</tr> </table> </div>' . $chrome_link . '</div>'; Javelin::initBehavior('countdown-timer', array('timestamp' => $timer->getDatepoint(), 'container' => $container)); $panel = $content; return $this->buildStandardPageResponse($panel, array('title' => 'Countdown: ' . $timer->getTitle(), 'chrome' => $chrome_visible)); }
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 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')); }
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() { $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); }
private function renderNotificationMenu() { $user = $this->user; require_celerity_resource('phabricator-notification-css'); require_celerity_resource('phabricator-notification-menu-css'); $indicator_id = celerity_generate_unique_node_id(); $dropdown_id = celerity_generate_unique_node_id(); $menu_id = celerity_generate_unique_node_id(); $notification_count = id(new PhabricatorFeedStoryNotification())->countUnread($user); $classes = array('phabricator-main-menu-alert-indicator'); if ($notification_count) { $classes[] = 'phabricator-main-menu-alert-indicator-unread'; } $notification_indicator = javelin_render_tag('span', array('id' => $indicator_id, 'class' => implode(' ', $classes)), $notification_count); $classes = array(); $classes[] = 'phabricator-main-menu-alert-item'; $classes[] = 'phabricator-main-menu-alert-item-notification'; $classes[] = 'autosprite'; $classes[] = 'main-menu-item-icon-notifications'; $notification_icon = javelin_render_tag('a', array('href' => '/notification/', 'class' => implode(' ', $classes), 'id' => $menu_id), $notification_indicator); $notification_menu = javelin_render_tag('div', array('class' => 'phabricator-main-menu-alert'), $notification_icon); Javelin::initBehavior('aphlict-dropdown', array('menuID' => $menu_id, 'indicatorID' => $indicator_id, 'dropdownID' => $dropdown_id)); $notification_dropdown = javelin_render_tag('div', array('id' => $dropdown_id, 'class' => 'phabricator-notification-menu', 'sigil' => 'phabricator-notification-menu', 'style' => 'display: none;'), ''); return array($notification_menu, $notification_dropdown); }
public function render() { require_celerity_resource('aphront-form-view-css'); Javelin::initBehavior('aphront-form-disable-on-submit'); $layout = id(new AphrontFormLayoutView())->setBackgroundShading(true)->setPadded(true)->appendChild($this->renderDataInputs())->appendChild($this->renderChildren()); return javelin_render_tag('form', array('action' => $this->action, 'method' => $this->method, 'enctype' => $this->encType, 'sigil' => $this->workflow ? 'workflow' : null, 'id' => $this->id), $layout->render()); }
public function renderExample() { require_celerity_resource('phabricator-notification-css'); Javelin::initBehavior('phabricator-notification-example'); $content = javelin_render_tag('a', array('sigil' => 'notification-example', 'class' => 'button green'), 'Show Notification'); $content = '<div style="padding: 1em 3em;">' . $content . '</content>'; return $content; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $package = id(new PhabricatorOwnersPackage())->load($this->id); if (!$package) { return new Aphront404Response(); } $paths = $package->loadPaths(); $owners = $package->loadOwners(); $phids = array(); foreach ($paths as $path) { $phids[$path->getRepositoryPHID()] = true; } foreach ($owners as $owner) { $phids[$owner->getUserPHID()] = true; } $phids = array_keys($phids); $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); $rows = array(); $rows[] = array('Name', phutil_escape_html($package->getName())); $rows[] = array('Description', phutil_escape_html($package->getDescription())); $primary_owner = null; $primary_phid = $package->getPrimaryOwnerPHID(); if ($primary_phid && isset($handles[$primary_phid])) { $primary_owner = '<strong>' . $handles[$primary_phid]->renderLink() . '</strong>'; } $rows[] = array('Primary Owner', $primary_owner); $owner_links = array(); foreach ($owners as $owner) { $owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); } $owner_links = implode('<br />', $owner_links); $rows[] = array('Owners', $owner_links); $rows[] = array('Auditing', $package->getAuditingEnabled() ? 'Enabled' : 'Disabled'); $rows[] = array('Related Commits', phutil_render_tag('a', array('href' => '/owners/related/view/all/?phid=' . $package->getPHID()), phutil_escape_html('Related Commits'))); $path_links = array(); foreach ($paths as $path) { $callsign = $handles[$path->getRepositoryPHID()]->getName(); $repo = phutil_escape_html('r' . $callsign); $path_link = phutil_render_tag('a', array('href' => '/diffusion/' . $callsign . '/browse/:' . $path->getPath()), phutil_escape_html($path->getPath())); $path_links[] = $repo . ' ' . $path_link; } $path_links = implode('<br />', $path_links); $rows[] = array('Paths', $path_links); $table = new AphrontTableView($rows); $table->setColumnClasses(array('header', 'wide')); $panel = new AphrontPanelView(); $panel->setHeader('Package Details for "' . phutil_escape_html($package->getName()) . '"'); $panel->addButton(javelin_render_tag('a', array('href' => '/owners/delete/' . $package->getID() . '/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Delete Package')); $panel->addButton(phutil_render_tag('a', array('href' => '/owners/edit/' . $package->getID() . '/', 'class' => 'button'), 'Edit Package')); $panel->appendChild($table); $nav = new AphrontSideNavView(); $nav->appendChild($panel); $nav->addNavItem(phutil_render_tag('a', array('href' => '/owners/package/' . $package->getID() . '/', 'class' => 'aphront-side-nav-selected'), 'Package Details')); return $this->buildStandardPageResponse($nav, array('title' => "Package '" . $package->getName() . "'")); }
public function render() { $marker = null; if ($this->navigationMarker) { $marker = javelin_render_tag('legend', array('class' => 'phabricator-anchor-navigation-marker', 'sigil' => 'marker', 'meta' => array('anchor' => $this->anchorName)), ''); } $anchor = phutil_render_tag('a', array('name' => $this->anchorName, 'id' => $this->anchorName, 'class' => 'phabricator-anchor-view'), ''); return $marker . $anchor; }
public function render() { $some = $this->some; $link = null; if ($this->more && $this->more != $this->some) { Javelin::initBehavior('aphront-more'); $link = ' ' . javelin_render_tag('a', array('sigil' => 'aphront-more-view-show-more', 'mustcapture' => true, 'href' => '#', 'meta' => array('more' => $this->more)), "(Show More…)"); } return javelin_render_tag('div', array('sigil' => 'aphront-more-view'), $some . $link); }
public function render() { $form_id = celerity_generate_unique_node_id(); require_celerity_resource('stripe-payment-form-css'); require_celerity_resource('aphront-tooltip-css'); Javelin::initBehavior('phabricator-tooltips'); $form = id(new AphrontFormView())->setID($form_id)->setUser($this->getUser())->appendChild(id(new AphrontFormMarkupControl())->setLabel('')->setValue(javelin_render_tag('div', array('class' => 'credit-card-logos', 'sigil' => 'has-tooltip', 'meta' => array('tip' => 'We support Visa, Mastercard, American Express, ' . 'Discover, JCB, and Diners Club.', 'size' => 440)))))->appendChild(id(new AphrontFormTextControl())->setLabel('Card Number')->setDisableAutocomplete(true)->setSigil('number-input')->setError($this->getCardNumberError()))->appendChild(id(new AphrontFormTextControl())->setLabel('CVC')->setDisableAutocomplete(true)->setSigil('cvc-input')->setError($this->getCardCVCError()))->appendChild(id(new PhortuneMonthYearExpiryControl())->setLabel('Expiration')->setUser($this->getUser())->setError($this->getCardExpirationError()))->appendChild(javelin_render_tag('input', array('hidden' => true, 'name' => 'stripeToken', 'sigil' => 'stripe-token-input')))->appendChild(javelin_render_tag('input', array('hidden' => true, 'name' => 'cardErrors', 'sigil' => 'card-errors-input')))->appendChild(phutil_render_tag('input', array('hidden' => true, 'name' => 'stripeKey', 'value' => $this->getStripeKey())))->appendChild(id(new AphrontFormSubmitControl())->setValue('Submit Payment')); Javelin::initBehavior('stripe-payment-form', array('stripePublishKey' => $this->getStripeKey(), 'root' => $form_id)); return $form->render(); }
public function render() { require_celerity_resource('ponder-vote-css'); require_celerity_resource('javelin-behavior-ponder-votebox'); Javelin::initBehavior('ponder-votebox', array()); $uri = id(new PhutilURI($this->uri))->alter('phid', $this->phid); $up = javelin_render_tag('a', array('href' => (string) $uri, 'sigil' => 'upvote', 'mustcapture' => true, 'class' => $this->vote > 0 ? 'ponder-vote-active' : null), "▲"); $down = javelin_render_tag('a', array('href' => (string) $uri, 'sigil' => 'downvote', 'mustcapture' => true, 'class' => $this->vote < 0 ? 'ponder-vote-active' : null), "▼"); $count = javelin_render_tag('div', array('class' => 'ponder-vote-count', 'sigil' => 'ponder-vote-count'), phutil_escape_html($this->count)); return javelin_render_tag('div', array('class' => 'ponder-votable', 'sigil' => 'ponder-votable', 'meta' => array('count' => (int) $this->count, 'vote' => (int) $this->vote)), javelin_render_tag('div', array('class' => 'ponder-votebox'), $up . $count . $down) . phutil_render_tag('div', array('class' => 'ponder-votebox-content'), $this->renderChildren())); }
public function renderExample() { $request = $this->getRequest(); $user = $request->getUser(); // toggle-class $container_id = celerity_generate_unique_node_id(); $button_red_id = celerity_generate_unique_node_id(); $button_blue_id = celerity_generate_unique_node_id(); $button_red = javelin_render_tag('a', array('class' => 'button', 'sigil' => 'jx-toggle-class', 'href' => '#', 'id' => $button_red_id, 'meta' => array('map' => array($container_id => 'jxui-red-border', $button_red_id => 'jxui-active'))), 'Toggle Red Border'); $button_blue = javelin_render_tag('a', array('class' => 'button jxui-active', 'sigil' => 'jx-toggle-class', 'href' => '#', 'id' => $button_blue_id, 'meta' => array('state' => true, 'map' => array($container_id => 'jxui-blue-background', $button_blue_id => 'jxui-active'))), 'Toggle Blue Background'); $div = phutil_render_tag('div', array('id' => $container_id, 'class' => 'jxui-example-container jxui-blue-background'), $button_red . $button_blue); return array($div); }
public function render() { $name = $this->getName(); $href = $this->getHref(); $classes = $this->classes; $classes[] = 'phabricator-main-menu-icon'; $label = javelin_render_tag('a', array('href' => $href, 'class' => 'phabricator-main-menu-icon-label'), phutil_escape_html($name)); $item = javelin_render_tag('a', array('href' => $href, 'class' => implode(' ', $classes), 'style' => $this->style, 'sigil' => $this->workflow ? 'workflow' : null), ''); $group = new PhabricatorMainMenuGroupView(); $group->appendChild($item); $group->appendChild($label); return $group->render(); }
public function render() { require_celerity_resource('aphront-typeahead-control-css'); $id = $this->id; $name = $this->getName(); $values = nonempty($this->getValue(), array()); $tokens = array(); foreach ($values as $key => $value) { $tokens[] = $this->renderToken($key, $value); } $input = javelin_render_tag('input', array('name' => $name, 'class' => 'jx-typeahead-input', 'sigil' => 'typeahead', 'type' => 'text', 'value' => $this->value, 'autocomplete' => 'off')); return javelin_render_tag('div', array('id' => $id, 'sigil' => 'typeahead-hardpoint', 'class' => 'jx-typeahead-hardpoint'), $input . '<div style="clear: both;"></div>'); }
public function render() { require_celerity_resource('aphront-tokenizer-control-css'); $id = $this->id; $name = $this->getName(); $values = nonempty($this->getValue(), array()); $tokens = array(); foreach ($values as $key => $value) { $tokens[] = $this->renderToken($key, $value); } $input = javelin_render_tag('input', array('mustcapture' => true, 'name' => $name, 'class' => 'jx-tokenizer-input', 'sigil' => 'tokenizer-input', 'style' => 'width: 0px;', 'disabled' => 'disabled', 'type' => 'text')); return phutil_render_tag('div', array('id' => $id, 'class' => 'jx-tokenizer-container'), implode('', $tokens) . $input . '<div style="clear: both;"></div>'); }
public function processRequest() { $request = $this->getRequest(); $macro_table = new PhabricatorFileImageMacro(); if ($request->getStr('name') !== null) { $macros = $macro_table->loadAllWhere('name LIKE %~', $request->getStr('name')); } else { $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $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'); } $file_phids = mpull($macros, 'getFilePHID'); $files = array(); if ($file_phids) { $files = id(new PhabricatorFile())->loadAllWhere("phid IN (%Ls)", $file_phids); $author_phids = mpull($files, 'getAuthorPHID', 'getPHID'); $handles = id(new PhabricatorObjectHandleData($author_phids))->loadHandles(); } $files_map = mpull($files, null, 'getPHID'); $rows = array(); foreach ($macros as $macro) { $file_phid = $macro->getFilePHID(); $file = idx($files_map, $file_phid); $author_link = isset($author_phids[$file_phid]) ? $handles[$author_phids[$file_phid]]->renderLink() : null; $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), $author_link, phutil_render_tag('a', array('href' => $file ? $file->getBestURI() : null, 'target' => '_blank'), phutil_render_tag('img', array('src' => $file ? $file->getBestURI() : null))), 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', 'Author', 'Image', '')); $table->setColumnClasses(array('pri', '', 'wide thumb', 'action')); $filter_form = id(new AphrontFormView())->setMethod('GET')->setAction('/file/macro/')->setUser($request->getUser())->appendChild(id(new AphrontFormTextControl())->setName('name')->setLabel('Name')->setValue($request->getStr('name')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Filter Image Macros')); $filter_view = new AphrontListFilterView(); $filter_view->appendChild($filter_form); $filter_view->addButton(phutil_render_tag('a', array('href' => '/file/macro/edit/', 'class' => 'green button'), 'New Image Macro')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Image Macros'); if ($request->getStr('name') === null) { $panel->appendChild($pager); } $side_nav = new PhabricatorFileSideNavView(); $side_nav->setSelectedFilter('all_macros'); $side_nav->appendChild($filter_view); $side_nav->appendChild($panel); return $this->buildStandardPageResponse($side_nav, array('title' => 'Image Macros')); }
public function didMarkupText() { $engine = $this->getEngine(); $metadata_key = self::KEY_RULE_COUNTDOWN; $metadata = $engine->getTextMetadata($metadata_key, array()); require_celerity_resource('javelin-behavior-countdown-timer'); foreach ($metadata as $id => $info) { list($time, $token) = $info; $count = phutil_render_tag('span', array('id' => $id), javelin_render_tag('span', array('sigil' => 'phabricator-timer-days'), '') . 'd' . javelin_render_tag('span', array('sigil' => 'phabricator-timer-hours'), '') . 'h' . javelin_render_tag('span', array('sigil' => 'phabricator-timer-minutes'), '') . 'm' . javelin_render_tag('span', array('sigil' => 'phabricator-timer-seconds'), '') . 's'); Javelin::initBehavior('countdown-timer', array('timestamp' => $time, 'container' => $id)); $engine->overwriteStoredText($token, $count); } $engine->setTextMetadata($metadata_key, array()); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $task = id(new PhabricatorWorkerTask())->load($this->id); if (!$task) { $error_view = new AphrontErrorView(); $error_view->setTitle('No Such Task'); $error_view->appendChild('<p>This task may have recently completed.</p>'); $error_view->setSeverity(AphrontErrorView::SEVERITY_WARNING); return $this->buildStandardPageResponse($error_view, array('title' => 'Task Does Not Exist')); } $data = id(new PhabricatorWorkerTaskData())->loadOneWhere('id = %d', $task->getDataID()); $extra = null; switch ($task->getTaskClass()) { case 'PhabricatorRepositorySvnCommitChangeParserWorker': case 'PhabricatorRepositoryGitCommitChangeParserWorker': $commit_id = idx($data->getData(), 'commitID'); if ($commit_id) { $commit = id(new PhabricatorRepositoryCommit())->load($commit_id); if ($commit) { $repository = id(new PhabricatorRepository())->load($commit->getRepositoryID()); if ($repository) { $extra = "<strong>NOTE:</strong> " . "You can manually retry this task by running this script:" . "<pre>" . "phabricator/\$ ./scripts/repository/reparse.php " . "r" . phutil_escape_html($repository->getCallsign()) . phutil_escape_html($commit->getCommitIdentifier()) . " " . "--change" . "</pre>"; } } } break; default: break; } if ($data) { $data = json_encode($data->getData()); } $form = id(new AphrontFormView())->setUser($user)->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setValue($task->getID()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Type')->setValue($task->getTaskClass()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Lease Owner')->setValue($task->getLeaseOwner()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Lease Expires')->setValue($task->getLeaseExpires() - time()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Failure Count')->setValue($task->getFailureCount()))->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Data')->setValue($data)); if ($extra) { $form->appendChild(id(new AphrontFormMarkupControl())->setLabel('More')->setValue($extra)); } $form->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/daemon/', 'Back')); $panel = new AphrontPanelView(); $panel->setHeader('Task Detail'); $panel->setWidth(AphrontPanelView::WIDTH_WIDE); $panel->appendChild($form); $panel->addButton(javelin_render_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/delete/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Delete Task')); $panel->addButton(javelin_render_tag('a', array('href' => '/daemon/task/' . $task->getID() . '/release/', 'class' => 'button grey', 'sigil' => 'workflow'), 'Free Lease')); $nav = $this->buildSideNavView(); $nav->selectFilter(''); $nav->appendChild($panel); return $this->buildApplicationPage($nav, array('title' => 'Task')); }
public function render() { $handles = $this->handles; require_celerity_resource('phabricator-object-list-view-css'); $out = array(); foreach ($handles as $handle) { $buttons = idx($this->buttons, $handle->getPHID(), array()); if ($buttons) { $buttons = '<div class="phabricator-object-list-view-buttons">' . implode('', $buttons) . '</div>'; } else { $buttons = null; } $out[] = javelin_render_tag('div', array('class' => 'phabricator-object-list-view-item', 'style' => 'background-image: url(' . $handle->getImageURI() . ');'), $handle->renderLink() . $buttons); } return '<div class="phabricator-object-list-view">' . implode("\n", $out) . '</div>'; }
public function render() { $user = $this->user; $target_id = celerity_generate_unique_node_id(); $search_id = $this->getID(); $input = phutil_render_tag('input', array('type' => 'text', 'name' => 'query', 'id' => $search_id, 'autocomplete' => 'off')); $scope = $this->scope; $target = javelin_render_tag('div', array('id' => $target_id, 'class' => 'phabricator-main-menu-search-target'), ''); Javelin::initBehavior('phabricator-search-typeahead', array('id' => $target_id, 'input' => $search_id, 'src' => '/typeahead/common/mainsearch/', 'limit' => 10, 'placeholder' => PhabricatorSearchScope::getScopePlaceholder($scope))); $scope_input = phutil_render_tag('input', array('type' => 'hidden', 'name' => 'scope', 'value' => $scope)); $form = phabricator_render_form($user, array('action' => '/search/', 'method' => 'POST'), '<div class="phabricator-main-menu-search-container">' . $input . '<button>Search</button>' . $scope_input . $target . '</div>'); $group = new PhabricatorMainMenuGroupView(); $group->addClass('phabricator-main-menu-search'); $group->appendChild($form); return $group->render(); }
public function render() { if ($this->instant) { $button_class = $this->class . ' link'; return phabricator_render_form($this->user, array('action' => $this->uri, 'method' => 'post', 'style' => 'display: inline'), '<button class="' . $button_class . '">' . phutil_escape_html($this->name) . '</button>'); } if ($this->uri) { $tag = 'a'; } else { $tag = 'span'; } $attrs = array('href' => $this->uri, 'class' => $this->class); if ($this->workflow) { $attrs['sigil'] = 'workflow'; } return javelin_render_tag($tag, $attrs, phutil_escape_html($this->name)); }
public function processRequest() { $categories = id(new PhabricatorDirectoryCategory())->loadAll(); $categories = msort($categories, 'getSequence'); $rows = array(); foreach ($categories as $category) { $rows[] = array($category->getID(), phutil_render_tag('a', array('href' => '/directory/category/edit/' . $category->getID() . '/'), phutil_escape_html($category->getName())), javelin_render_tag('a', array('href' => '/directory/category/delete/' . $category->getID() . '/', 'class' => 'button grey small', 'sigil' => 'workflow'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('ID', 'Name', '')); $table->setColumnClasses(array(null, 'wide', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Directory Categories'); $panel->setCreateButton('New Category', '/directory/category/edit/'); return $this->buildStandardPageResponse($panel, array('title' => 'Directory Category List', 'tab' => 'categories')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $task_ids = $request->getArr('batch'); $tasks = id(new ManiphestTask())->loadAllWhere('id IN (%Ld)', $task_ids); $actions = $request->getStr('actions'); if ($actions) { $actions = json_decode($actions, true); } if ($request->isFormPost() && is_array($actions)) { foreach ($tasks as $task) { $xactions = $this->buildTransactions($actions, $task); if ($xactions) { $editor = new ManiphestTransactionEditor(); $editor->applyTransactions($task, $xactions); } } $task_ids = implode(',', mpull($tasks, 'getID')); return id(new AphrontRedirectResponse())->setURI('/maniphest/view/custom/?s=oc&tasks=' . $task_ids); } $panel = new AphrontPanelView(); $panel->setHeader('Maniphest Batch Editor'); $handle_phids = mpull($tasks, 'getOwnerPHID'); $handles = id(new PhabricatorObjectHandleData($handle_phids))->loadHandles(); $list = new ManiphestTaskListView(); $list->setTasks($tasks); $list->setUser($user); $list->setHandles($handles); $template = new AphrontTokenizerTemplateView(); $template = $template->render(); require_celerity_resource('maniphest-batch-editor'); Javelin::initBehavior('maniphest-batch-editor', array('root' => 'maniphest-batch-edit-form', 'tokenizerTemplate' => $template, 'sources' => array('project' => array('src' => '/typeahead/common/projects/', 'placeholder' => 'Type a project name...'), 'owner' => array('src' => '/typeahead/common/searchowner/', 'placeholder' => 'Type a user name...', 'limit' => 1)), 'input' => 'batch-form-actions', 'priorityMap' => ManiphestTaskPriority::getTaskPriorityMap(), 'statusMap' => ManiphestTaskStatus::getTaskStatusMap())); $form = new AphrontFormView(); $form->setUser($user); $form->setID('maniphest-batch-edit-form'); foreach ($tasks as $task) { $form->appendChild(phutil_render_tag('input', array('type' => 'hidden', 'name' => 'batch[]', 'value' => $task->getID()), null)); } $form->appendChild(phutil_render_tag('input', array('type' => 'hidden', 'name' => 'actions', 'id' => 'batch-form-actions'), null)); $form->appendChild('<p>These tasks will be edited:</p>'); $form->appendChild($list); $form->appendChild(id(new AphrontFormInsetView())->setTitle('Actions')->setRightButton(javelin_render_tag('a', array('href' => '#', 'class' => 'button green', 'sigil' => 'add-action', 'mustcapture' => true), 'Add Another Action'))->setContent(javelin_render_tag('table', array('sigil' => 'maniphest-batch-actions', 'class' => 'maniphest-batch-actions-table'), '')))->appendChild(id(new AphrontFormSubmitControl())->setValue('Update Tasks')->addCancelButton('/maniphest/', 'Done')); $panel->appendChild($form); return $this->buildStandardPageResponse($panel, array('title' => 'Batch Editor')); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $is_admin = $user->getIsAdmin(); $repos = id(new PhabricatorRepository())->loadAll(); $rows = array(); foreach ($repos as $repo) { if ($repo->getDetail('tracking-enabled')) { $diffusion_link = phutil_render_tag('a', array('href' => '/diffusion/' . $repo->getCallsign() . '/'), 'View in Diffusion'); } else { $diffusion_link = '<em>Not Tracked</em>'; } $rows[] = array(phutil_escape_html($repo->getCallsign()), phutil_escape_html($repo->getName()), PhabricatorRepositoryType::getNameForRepositoryType($repo->getVersionControlSystem()), $diffusion_link, phutil_render_tag('a', array('class' => 'button small grey', 'href' => '/repository/edit/' . $repo->getID() . '/'), 'Edit'), javelin_render_tag('a', array('class' => 'button small grey', 'href' => '/repository/delete/' . $repo->getID() . '/', 'sigil' => 'workflow'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Callsign', 'Repository', 'Type', 'Diffusion', '', '')); $table->setColumnClasses(array(null, 'wide', null, null, 'action', 'action')); $table->setColumnVisibility(array(true, true, true, true, $is_admin, $is_admin)); $panel = new AphrontPanelView(); $panel->setHeader('Repositories'); if ($is_admin) { $panel->setCreateButton('Create New Repository', '/repository/create/'); } $panel->appendChild($table); $projects = id(new PhabricatorRepositoryArcanistProject())->loadAll(); $rows = array(); foreach ($projects as $project) { $repo = idx($repos, $project->getRepositoryID()); if ($repo) { $repo_name = phutil_escape_html($repo->getName()); } else { $repo_name = '-'; } $rows[] = array(phutil_escape_html($project->getName()), $repo_name, phutil_render_tag('a', array('href' => '/repository/project/' . $project->getID() . '/', 'class' => 'button grey small'), 'Edit')); } $project_table = new AphrontTableView($rows); $project_table->setHeaders(array('Project ID', 'Repository', '')); $project_table->setColumnClasses(array('', 'wide', 'action')); $project_table->setColumnVisibility(array(true, true, $is_admin)); $project_panel = new AphrontPanelView(); $project_panel->setHeader('Arcanist Projects'); $project_panel->appendChild($project_table); return $this->buildStandardPageResponse(array($panel, $project_panel), array('title' => 'Repository List')); }