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 renderValueForRevisionView()
 {
     $diff = $this->getDiff();
     $ustar = DifferentialRevisionUpdateHistoryView::renderDiffUnitStar($diff);
     $umsg = DifferentialRevisionUpdateHistoryView::getDiffUnitMessage($diff);
     $postponed_count = 0;
     $udata = $this->getDiffProperty('arc:unit');
     $utail = null;
     if ($udata) {
         $unit_messages = array();
         foreach ($udata as $test) {
             $name = idx($test, 'name');
             $result = idx($test, 'result');
             if ($result != DifferentialUnitTestResult::RESULT_POSTPONED && $result != DifferentialUnitTestResult::RESULT_PASS) {
                 $engine = PhabricatorMarkupEngine::newDifferentialMarkupEngine();
                 $userdata = phutil_utf8_shorten(idx($test, 'userdata'), 512);
                 $userdata = $engine->markupText($userdata);
                 $unit_messages[] = '<li>' . '<span class="unit-result-' . phutil_escape_html($result) . '">' . phutil_escape_html(ucwords($result)) . '</span>' . ' ' . phutil_escape_html($name) . '<p>' . $userdata . '</p>' . '</li>';
             } else {
                 if ($result == DifferentialUnitTestResult::RESULT_POSTPONED) {
                     $postponed_count++;
                 }
             }
         }
         $uexcuse = $this->getUnitExcuse();
         if ($unit_messages) {
             $utail = '<div class="differential-unit-block">' . $uexcuse . '<ul>' . implode("\n", $unit_messages) . '</ul>' . '</div>';
         }
     }
     if ($postponed_count > 0 && $diff->getUnitStatus() == DifferentialUnitStatus::UNIT_POSTPONED) {
         $umsg = $postponed_count . ' ' . $umsg;
     }
     return $ustar . ' ' . $umsg . $utail;
 }
 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()) . ' &middot; ' . 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 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 static function renderLastModifiedColumns(PhabricatorRepository $repository, array $handles, PhabricatorRepositoryCommit $commit = null, PhabricatorRepositoryCommitData $data = null)
 {
     if ($commit) {
         $epoch = $commit->getEpoch();
         $modified = DiffusionView::linkCommit($repository, $commit->getCommitIdentifier());
         $date = date('M j, Y', $epoch);
         $time = date('g:i A', $epoch);
     } else {
         $modified = '';
         $date = '';
         $time = '';
     }
     if ($data) {
         $author_phid = $data->getCommitDetail('authorPHID');
         if ($author_phid && isset($handles[$author_phid])) {
             $author = $handles[$author_phid]->renderLink();
         } else {
             $author = phutil_escape_html($data->getAuthorName());
         }
         $details = AphrontTableView::renderSingleDisplayLine(phutil_escape_html($data->getSummary()));
     } else {
         $author = '';
         $details = '';
     }
     return array('commit' => $modified, 'date' => $date, 'time' => $time, 'author' => $author, 'details' => $details);
 }
 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();
     $keys = $request->getStr('keys');
     $keys = json_decode($keys, true);
     if (!is_array($keys)) {
         return new Aphront400Response();
     }
     // There have been at least two users asking for a keyboard shortcut to
     // close the dialog, so be explicit that escape works since it isn't
     // terribly discoverable.
     $keys[] = array('keys' => array('esc'), 'description' => 'Close any dialog, including this one.');
     $rows = array();
     foreach ($keys as $shortcut) {
         $keystrokes = array();
         foreach ($shortcut['keys'] as $stroke) {
             $keystrokes[] = '<kbd>' . phutil_escape_html($stroke) . '</kbd>';
         }
         $keystrokes = implode(' or ', $keystrokes);
         $rows[] = '<tr>' . '<th>' . $keystrokes . '</th>' . '<td>' . phutil_escape_html($shortcut['description']) . '</td>' . '</tr>';
     }
     $table = '<table class="keyboard-shortcut-help">' . implode('', $rows) . '</table>';
     $dialog = id(new AphrontDialogView())->setUser($user)->setTitle('Keyboard Shortcuts')->appendChild($table)->addCancelButton('#', 'Close');
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
    public function processRequest()
    {
        $request = $this->getRequest();
        $user = $request->getUser();
        $preferences = $user->loadPreferences();
        if ($request->isFormPost()) {
            $monospaced = $request->getStr(PhabricatorUserPreferences::PREFERENCE_MONOSPACED);
            // Prevent the user from doing stupid things.
            $monospaced = preg_replace('/[^a-z0-9 ,"]+/i', '', $monospaced);
            $pref_dict = array(PhabricatorUserPreferences::PREFERENCE_TITLES => $request->getStr(PhabricatorUserPreferences::PREFERENCE_TITLES), PhabricatorUserPreferences::PREFERENCE_MONOSPACED => $monospaced);
            $preferences->setPreferences($pref_dict);
            $preferences->save();
            return id(new AphrontRedirectResponse())->setURI('/settings/page/preferences/?saved=true');
        }
        $example_string = <<<EXAMPLE
// This is what your monospaced font currently looks like.
function helloWorld() {
  alert("Hello world!");
}
EXAMPLE;
        $form = id(new AphrontFormView())->setUser($user)->setAction('/settings/page/preferences/')->appendChild(id(new AphrontFormSelectControl())->setLabel('Page Titles')->setName(PhabricatorUserPreferences::PREFERENCE_TITLES)->setValue($preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_TITLES))->setOptions(array('glyph' => "In page titles, show Tool names as unicode glyphs: ⚙", 'text' => 'In page titles, show Tool names as plain text: [Differential]')))->appendChild(id(new AphrontFormTextControl())->setLabel('Monospaced Font')->setName(PhabricatorUserPreferences::PREFERENCE_MONOSPACED)->setCaption('Overrides default fonts in tools like Differential. ' . '(Default: 10px "Menlo", "Consolas", "Monaco", ' . 'monospace)')->setValue($preferences->getPreference(PhabricatorUserPreferences::PREFERENCE_MONOSPACED)))->appendChild(id(new AphrontFormMarkupControl())->setValue('<pre class="PhabricatorMonospaced">' . phutil_escape_html($example_string) . '</pre>'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save Preferences'));
        $panel = new AphrontPanelView();
        $panel->setWidth(AphrontPanelView::WIDTH_WIDE);
        $panel->setHeader('Phabricator Preferences');
        $panel->appendChild($form);
        $error_view = null;
        if ($request->getStr('saved') === 'true') {
            $error_view = id(new AphrontErrorView())->setTitle('Preferences Saved')->setSeverity(AphrontErrorView::SEVERITY_NOTICE)->setErrors(array('Your preferences have been saved.'));
        }
        return id(new AphrontNullView())->appendChild(array($error_view, $panel));
    }
 public function processRequest()
 {
     $rule = id(new HeraldRule())->load($this->id);
     if (!$rule) {
         return new Aphront404Response();
     }
     $request = $this->getRequest();
     $user = $request->getUser();
     if ($user->getPHID() != $rule->getAuthorPHID()) {
         return new Aphront400Response();
     }
     if ($request->isFormPost()) {
         $rule->delete();
         if ($request->isAjax()) {
             return new AphrontRedirectResponse();
         } else {
             return id(new AphrontRedirectResponse())->setURI('/herald/');
         }
     }
     $dialog = new AphrontDialogView();
     $dialog->setUser($request->getUser());
     $dialog->setTitle('Really delete this rule?');
     $dialog->appendChild("Are you sure you want to delete the rule " . "'<strong>" . phutil_escape_html($rule->getName()) . "</strong>'?");
     $dialog->addSubmitButton('Delete');
     $dialog->addCancelButton('/herald/');
     $dialog->setSubmitURI($request->getPath());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 private function renderServerStatus(array $status)
 {
     $rows = array();
     foreach ($status as $key => $value) {
         $label = phutil_escape_html($key);
         switch ($key) {
             case 'uptime':
                 $value /= 1000;
                 $value = phabricator_format_relative_time_detailed($value);
                 break;
             case 'log':
                 $value = phutil_escape_html($value);
                 break;
             default:
                 $value = phutil_escape_html(number_format($value));
                 break;
         }
         $rows[] = array($label, $value);
     }
     $table = new AphrontTableView($rows);
     $table->setColumnClasses(array('header', 'wide'));
     $panel = new AphrontPanelView();
     $panel->setHeader('Server Status');
     $panel->appendChild($table);
     return $panel;
 }
 private function getNoticeView()
 {
     $edited = $this->getRequest()->getStr('edited');
     $new = $this->getRequest()->getStr('new');
     $deleted = $this->getRequest()->getBool('deleted');
     if ($edited) {
         $edited = phutil_escape_html($edited);
         $title = 'Successfully edited client with id ' . $edited . '.';
     } else {
         if ($new) {
             $new = phutil_escape_html($new);
             $title = 'Successfully created client with id ' . $new . '.';
         } else {
             if ($deleted) {
                 $title = 'Successfully deleted client.';
             } else {
                 $title = null;
             }
         }
     }
     if ($title) {
         $view = new AphrontErrorView();
         $view->setTitle($title);
         $view->setSeverity(AphrontErrorView::SEVERITY_NOTICE);
     } else {
         $view = null;
     }
     return $view;
 }
Exemplo n.º 12
0
 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));
 }
 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()
 {
     $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();
 }
Exemplo n.º 15
0
/**
 * @group markup
 */
function phutil_render_tag($tag, array $attributes = array(), $content = null)
{
    if (!empty($attributes['href'])) {
        // This might be a URI object, so cast it to a string.
        $href = (string) $attributes['href'];
        // Block 'javascript:' hrefs at the tag level: no well-designed application
        // should ever use them, and they are a potent attack vector. This function
        // is deep in the core and performance sensitive, so skip the relatively
        // expensive preg_match() call if the initial character is '/' (this is the
        // case with essentially every URI Phabricator renders).
        if (isset($href[0]) && $href[0] != '/' && preg_match('/^\\s*javascript:/i', $href)) {
            throw new Exception("Attempting to render a tag with an 'href' attribute that begins " . "with 'javascript:'. This is either a serious security concern or a " . "serious architecture concern. Seek urgent remedy.");
        }
    }
    foreach ($attributes as $k => $v) {
        if ($v === null) {
            continue;
        }
        $v = phutil_escape_html($v);
        $attributes[$k] = ' ' . $k . '="' . $v . '"';
    }
    $attributes = implode('', $attributes);
    if ($content === null) {
        return '<' . $tag . $attributes . ' />';
    } else {
        return '<' . $tag . $attributes . '>' . $content . '</' . $tag . '>';
    }
}
 public function renderValueForRevisionView()
 {
     if (!$this->value) {
         return null;
     }
     return phutil_escape_html($this->value);
 }
Exemplo n.º 17
0
 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 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();
     $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 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 processRequest()
 {
     $phid = $this->getClientPHID();
     $title = 'Delete OAuth Client';
     $request = $this->getRequest();
     $current_user = $request->getUser();
     $client = id(new PhabricatorOAuthServerClient())->loadOneWhere('phid = %s', $phid);
     if (empty($client)) {
         return new Aphront404Response();
     }
     if ($client->getCreatorPHID() != $current_user->getPHID()) {
         $message = 'Access denied to client with phid ' . $phid . '. ' . 'Only the user who created the client has permission to ' . 'delete the client.';
         return id(new Aphront403Response())->setForbiddenText($message);
     }
     if ($request->isFormPost()) {
         $client->delete();
         return id(new AphrontRedirectResponse())->setURI('/oauthserver/client/?deleted=1');
     }
     $client_name = phutil_escape_html($client->getName());
     $title .= ' ' . $client_name;
     $dialog = new AphrontDialogView();
     $dialog->setUser($current_user);
     $dialog->setTitle($title);
     $dialog->appendChild('<p>Are you sure you want to delete this client?</p>');
     $dialog->addSubmitButton();
     $dialog->addCancelButton($client->getEditURI());
     return id(new AphrontDialogResponse())->setDialog($dialog);
 }
 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 render()
 {
     require_celerity_resource('differential-core-view-css');
     require_celerity_resource('differential-revision-detail-css');
     $revision = $this->revision;
     $rows = array();
     foreach ($this->auxiliaryFields as $field) {
         $value = $field->renderValueForRevisionView();
         if (strlen($value)) {
             $label = $field->renderLabelForRevisionView();
             $rows[] = '<tr>' . '<th>' . $label . '</th>' . '<td>' . $value . '</td>' . '</tr>';
         }
     }
     $properties = '<table class="differential-revision-properties">' . implode("\n", $rows) . '</table>';
     $actions = array();
     foreach ($this->actions as $action) {
         $obj = new AphrontHeadsupActionView();
         $obj->setName($action['name']);
         $obj->setURI(idx($action, 'href'));
         $obj->setWorkflow(idx($action, 'sigil') == 'workflow');
         $obj->setClass(idx($action, 'class'));
         $obj->setInstant(idx($action, 'instant'));
         $obj->setUser($this->user);
         $actions[] = $obj;
     }
     $action_list = new AphrontHeadsupActionListView();
     $action_list->setActions($actions);
     return '<div class="differential-revision-detail differential-panel">' . $action_list->render() . '<div class="differential-keyboard-shortcuts">' . id(new AphrontKeyboardShortcutsAvailableView())->render() . '</div>' . '<div class="differential-revision-detail-core">' . '<h1>' . '<span class="aphront-headsup-object-name">' . phutil_escape_html('D' . $revision->getID()) . '</span>' . ' ' . phutil_escape_html($revision->getTitle()) . '</h1>' . $properties . '</div>' . '<div style="clear: both;"></div>' . '</div>';
 }
Exemplo n.º 24
0
    public function render()
    {
        $this->willRenderPage();
        $title = phutil_escape_html($this->getTitle());
        $head = $this->getHead();
        $body = $this->getBody();
        $tail = $this->getTail();
        $body_classes = $this->getBodyClasses();
        $response = <<<EOHTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>{$title}</title>
    {$head}
  </head>
  <body class="{$body_classes}">
    {$body}
    {$tail}
  </body>
</html>

EOHTML;
        $response = $this->willSendResponse($response);
        return $response;
    }
Exemplo n.º 25
0
 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()
 {
     $classes = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorUIExample')->setConcreteOnly(true)->selectAndLoadSymbols();
     $classes = ipull($classes, 'name', 'name');
     foreach ($classes as $class => $ignored) {
         $classes[$class] = newv($class, array());
     }
     $classes = msort($classes, 'getName');
     $nav = new AphrontSideNavFilterView();
     $nav->setBaseURI(new PhutilURI($this->getApplicationURI('view/')));
     foreach ($classes as $class => $obj) {
         $name = $obj->getName();
         $nav->addFilter($class, $name);
     }
     $selected = $nav->selectFilter($this->class, head_key($classes));
     require_celerity_resource('phabricator-ui-example-css');
     $example = $classes[$selected];
     $example->setRequest($this->getRequest());
     $result = $example->renderExample();
     if ($result instanceof AphrontResponse) {
         // This allows examples to generate dialogs, etc., for demonstration.
         return $result;
     }
     $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($result);
     return $this->buildApplicationPage($nav, array('title' => 'UI Example', 'device' => true));
 }
 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>';
 }
Exemplo n.º 28
0
 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();
     $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 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'));
 }