本文整理汇总了PHP中phutil_escape_html函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_escape_html函数的具体用法?PHP phutil_escape_html怎么用?PHP phutil_escape_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_escape_html函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processRequest
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'));
}
示例2: renderValueForRevisionView
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;
}
示例3: processRequest
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));
}
示例4: processRequest
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'));
}
示例5: renderLastModifiedColumns
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);
}
示例6: processRequest
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'));
}
示例7: processRequest
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);
}
示例8: processRequest
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));
}
开发者ID:nguyennamtien,项目名称:phabricator,代码行数:31,代码来源:PhabricatorUserPreferenceSettingsPanelController.php
示例9: processRequest
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);
}
示例10: renderServerStatus
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;
}
示例11: getNoticeView
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;
}
示例12: render
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));
}
示例13: processRequest
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));
}
示例14: render
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();
}
示例15: phutil_render_tag
/**
* @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 . '>';
}
}