本文整理汇总了PHP中phutil_safe_html函数的典型用法代码示例。如果您正苦于以下问题:PHP phutil_safe_html函数的具体用法?PHP phutil_safe_html怎么用?PHP phutil_safe_html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了phutil_safe_html函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: restore
public function restore($corpus)
{
if ($this->map) {
$corpus = phutil_safe_html(str_replace(array_reverse(array_keys($this->map)), array_map('phutil_escape_html', array_reverse($this->map)), phutil_escape_html($corpus)));
}
return $corpus;
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:7,代码来源:PhutilRemarkupBlockStorage.php
示例2: renderInput
protected function renderInput()
{
self::requireLib();
$uri = new PhutilURI(PhabricatorEnv::getEnvConfig('phabricator.base-uri'));
$protocol = $uri->getProtocol();
$use_ssl = $protocol == 'https';
return phutil_safe_html(recaptcha_get_html(PhabricatorEnv::getEnvConfig('recaptcha.public-key'), $error = null, $use_ssl));
}
开发者ID:pugong,项目名称:phabricator,代码行数:8,代码来源:AphrontFormRecaptchaControl.php
示例3: overwriteStoredText
public function overwriteStoredText($token, $new_text)
{
if ($this->isTextMode()) {
$new_text = phutil_safe_html($new_text);
}
$this->storage->overwrite($token, $new_text);
return $this;
}
开发者ID:jasteele12,项目名称:prb_lint_tests,代码行数:8,代码来源:PhutilRemarkupEngine.php
示例4: renderExample
public function renderExample()
{
$out = '';
$out .= $this->renderTestThings('AphrontProgressBarView', 13, 10);
$out .= $this->renderTestThings('AphrontGlyphBarView', 13, 10);
$out .= $this->renderWeirdOrderGlyphBars();
$out .= $this->renderAsciiStarBar();
return phutil_safe_html($out);
}
开发者ID:denghp,项目名称:phabricator,代码行数:9,代码来源:PhabricatorAphrontBarExample.php
示例5: buildResources
private function buildResources()
{
$css = array('application/config/config-template.css', 'application/config/setup-issue.css');
$webroot = dirname(phutil_get_library_root('phabricator')) . '/webroot/';
$resources = array();
foreach ($css as $path) {
$resources[] = phutil_tag('style', array('type' => 'text/css'), phutil_safe_html(Filesystem::readFile($webroot . '/rsrc/css/' . $path)));
}
return phutil_implode_html("\n", $resources);
}
开发者ID:denghp,项目名称:phabricator,代码行数:10,代码来源:PhabricatorConfigResponse.php
示例6: buildResources
private function buildResources()
{
$paths = $this->getResources();
$webroot = dirname(phutil_get_library_root('phabricator')) . '/webroot/';
$resources = array();
foreach ($paths as $path) {
$resources[] = phutil_tag('style', array('type' => 'text/css'), phutil_safe_html(Filesystem::readFile($webroot . '/rsrc/' . $path)));
}
return phutil_implode_html("\n", $resources);
}
开发者ID:pugong,项目名称:phabricator,代码行数:10,代码来源:AphrontStandaloneHTMLResponse.php
示例7: restore
public function restore($corpus, $text_mode = false)
{
if ($this->map) {
if ($text_mode) {
$corpus = str_replace(array_reverse(array_keys($this->map)), array_reverse($this->map), $corpus);
} else {
$corpus = phutil_safe_html(str_replace(array_reverse(array_keys($this->map)), array_map('phutil_escape_html', array_reverse($this->map)), phutil_escape_html($corpus)));
}
}
return $corpus;
}
开发者ID:lsubra,项目名称:libphutil,代码行数:11,代码来源:PhutilRemarkupBlockStorage.php
示例8: renderTemplate
private function renderTemplate($__template__, array $__scope__)
{
chdir($this->getPath());
ob_start();
if (Filesystem::pathExists($this->getPath($__template__))) {
// Fool lint.
$__evil__ = 'extract';
$__evil__($__scope__ + $this->getDefaultScope());
require $this->getPath($__template__);
}
return phutil_safe_html(ob_get_clean());
}
开发者ID:patelhardik,项目名称:phabricator,代码行数:12,代码来源:PhameBasicTemplateBlogSkin.php
示例9: didReceiveResult
protected function didReceiveResult($result)
{
list($err, $stdout, $stderr) = $result;
if (!$err && strlen($stdout)) {
// Strip off fluff Pygments adds.
$stdout = preg_replace('@^<div class="highlight"><pre>(.*)</pre></div>\\s*$@s', '\\1', $stdout);
if ($this->scrub) {
$stdout = preg_replace('/^.*\\n/', '', $stdout);
}
return phutil_safe_html($stdout);
}
throw new PhutilSyntaxHighlighterException($stderr, $err);
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:13,代码来源:PhutilDefaultSyntaxHighlighterEnginePygmentsFuture.php
示例10: getHighlightFuture
public function getHighlightFuture($source)
{
$source = phutil_escape_html($source);
// This highlighter isn't perfect but tries to do an okay job at getting
// some of the basics at least. There's lots of room for improvement.
$blocks = explode("\n\n", $source);
foreach ($blocks as $key => $block) {
if (preg_match('/^[^ ](?! )/m', $block)) {
$blocks[$key] = $this->highlightBlock($block);
}
}
$source = implode("\n\n", $blocks);
$source = phutil_safe_html($source);
return new ImmediateFuture($source);
}
开发者ID:lsubra,项目名称:libphutil,代码行数:15,代码来源:PhutilDivinerSyntaxHighlighter.php
示例11: applyIntralineDiff
public static function applyIntralineDiff($str, $intra_stack)
{
$buf = '';
$p = $s = $e = 0;
// position, start, end
$highlight = $tag = $ent = false;
$highlight_o = '<span class="bright">';
$highlight_c = '</span>';
$is_html = false;
if ($str instanceof PhutilSafeHTML) {
$is_html = true;
$str = $str->getHTMLContent();
}
$n = strlen($str);
for ($i = 0; $i < $n; $i++) {
if ($p == $e) {
do {
if (empty($intra_stack)) {
$buf .= substr($str, $i);
break 2;
}
$stack = array_shift($intra_stack);
$s = $e;
$e += $stack[1];
} while ($stack[0] == 0);
}
if (!$highlight && !$tag && !$ent && $p == $s) {
$buf .= $highlight_o;
$highlight = true;
}
if ($str[$i] == '<') {
$tag = true;
if ($highlight) {
$buf .= $highlight_c;
}
}
if (!$tag) {
if ($str[$i] == '&') {
$ent = true;
}
if ($ent && $str[$i] == ';') {
$ent = false;
}
if (!$ent) {
$p++;
}
}
$buf .= $str[$i];
if ($tag && $str[$i] == '>') {
$tag = false;
if ($highlight) {
$buf .= $highlight_o;
}
}
if ($highlight && ($p == $e || $i == $n - 1)) {
$buf .= $highlight_c;
$highlight = false;
}
}
if ($is_html) {
return phutil_safe_html($buf);
}
return $buf;
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:64,代码来源:ArcanistDiffUtils.php
示例12: addTaskToTree
private function addTaskToTree($task)
{
$cdate = $this->getTaskCreatedDate($task);
$date_created = phabricator_date($cdate, $this->viewer);
$udate = $this->getTaskModifiedDate($task);
$last_updated = phabricator_date($udate, $this->viewer);
$status = $task->getStatus();
$owner_link = $this->setOwnerLink($this->handles, $task);
$priority = $this->getPriority($task);
$priority_name = $this->getPriorityName($task);
$is_open = ManiphestTaskStatus::isOpenStatus($task->getStatus());
if ($this->blocker === true && $is_open === true) {
$blockericon = $this->getIconforBlocker();
} else {
$blockericon = '';
}
if ($this->blocked === true && $is_open === true) {
$blockedicon = $this->getIconforBlocked();
} else {
$blockedicon = '';
}
$output = array();
$output[] = array(phutil_safe_html(phutil_tag('a', array('href' => '/' . $task->getMonogram(), 'class' => $status !== 'open' ? 'phui-tag-core-closed' : ''), array($this->buildTaskLink($task), $blockericon, $blockedicon))), $cdate, $date_created, $udate, $last_updated, $owner_link, $priority, $priority_name, $this->points, $status);
return $output;
}
开发者ID:kanarip,项目名称:phabricator-extensions-Sprint,代码行数:25,代码来源:TaskTableDataProvider.php
示例13: renderChangesetTable
public final function renderChangesetTable($content)
{
$props = null;
if ($this->shouldRenderPropertyChangeHeader()) {
$props = $this->renderPropertyChangeHeader();
}
$notice = null;
if ($this->getIsTopLevel()) {
$force = !$content && !$props;
$notice = $this->renderChangeTypeHeader($force);
}
$result = $notice . $props . $content;
// TODO: Let the user customize their tab width / display style.
// TODO: We should possibly post-process "\r" as well.
// TODO: Both these steps should happen earlier.
$result = str_replace("\t", ' ', $result);
return phutil_safe_html($result);
}
开发者ID:denghp,项目名称:phabricator,代码行数:18,代码来源:DifferentialChangesetRenderer.php
示例14: loadContent
private function loadContent(array $pastes)
{
$cache = new PhabricatorKeyValueDatabaseCache();
$cache = new PhutilKeyValueCacheProfiler($cache);
$cache->setProfiler(PhutilServiceProfiler::getInstance());
$keys = array();
foreach ($pastes as $paste) {
$keys[] = $this->getContentCacheKey($paste);
}
$caches = $cache->getKeys($keys);
$results = array();
$need_raw = array();
foreach ($pastes as $key => $paste) {
$key = $this->getContentCacheKey($paste);
if (isset($caches[$key])) {
$paste->attachContent(phutil_safe_html($caches[$key]));
$results[$paste->getID()] = $paste;
} else {
$need_raw[$key] = $paste;
}
}
if (!$need_raw) {
return $results;
}
$write_data = array();
$need_raw = $this->loadRawContent($need_raw);
foreach ($need_raw as $key => $paste) {
$content = $this->buildContent($paste);
$paste->attachContent($content);
$write_data[$this->getContentCacheKey($paste)] = (string) $content;
$results[$paste->getID()] = $paste;
}
$cache->setKeys($write_data);
return $results;
}
开发者ID:denghp,项目名称:phabricator,代码行数:35,代码来源:PhabricatorPasteQuery.php
示例15: renderTextChange
public function renderTextChange($range_start, $range_len, $rows)
{
$hunk_starts = $this->getHunkStartLines();
$context_not_available = null;
if ($hunk_starts) {
$context_not_available = javelin_tag('tr', array('sigil' => 'context-target'), phutil_tag('td', array('colspan' => 6, 'class' => 'show-more'), pht('Context not available.')));
}
$html = array();
$old_lines = $this->getOldLines();
$new_lines = $this->getNewLines();
$gaps = $this->getGaps();
$reference = $this->getRenderingReference();
$left_id = $this->getOldChangesetID();
$right_id = $this->getNewChangesetID();
// "N" stands for 'new' and means the comment should attach to the new file
// when stored, i.e. DifferentialInlineComment->setIsNewFile().
// "O" stands for 'old' and means the comment should attach to the old file.
$left_char = $this->getOldAttachesToNewFile() ? 'N' : 'O';
$right_char = $this->getNewAttachesToNewFile() ? 'N' : 'O';
$changeset = $this->getChangeset();
$copy_lines = idx($changeset->getMetadata(), 'copy:lines', array());
$highlight_old = $this->getHighlightOld();
$highlight_new = $this->getHighlightNew();
$old_render = $this->getOldRender();
$new_render = $this->getNewRender();
$original_left = $this->getOriginalOld();
$original_right = $this->getOriginalNew();
$depths = $this->getDepths();
$mask = $this->getMask();
for ($ii = $range_start; $ii < $range_start + $range_len; $ii++) {
if (empty($mask[$ii])) {
// If we aren't going to show this line, we've just entered a gap.
// Pop information about the next gap off the $gaps stack and render
// an appropriate "Show more context" element. This branch eventually
// increments $ii by the entire size of the gap and then continues
// the loop.
$gap = array_pop($gaps);
$top = $gap[0];
$len = $gap[1];
$end = $top + $len - 20;
$contents = array();
if ($len > 40) {
$is_first_block = false;
if ($ii == 0) {
$is_first_block = true;
}
$contents[] = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'sigil' => 'show-more', 'meta' => array('ref' => $reference, 'range' => "{$top}-{$len}/{$top}-20")), $is_first_block ? pht('Show First 20 Lines') : pht("▲ Show 20 Lines"));
}
$contents[] = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'sigil' => 'show-more', 'meta' => array('type' => 'all', 'ref' => $reference, 'range' => "{$top}-{$len}/{$top}-{$len}")), pht('Show All %d Lines', $len));
$is_last_block = false;
if ($ii + $len >= $rows) {
$is_last_block = true;
}
if ($len > 40) {
$contents[] = javelin_tag('a', array('href' => '#', 'mustcapture' => true, 'sigil' => 'show-more', 'meta' => array('ref' => $reference, 'range' => "{$top}-{$len}/{$end}-20")), $is_last_block ? pht('Show Last 20 Lines') : pht("▼ Show 20 Lines"));
}
$context = null;
$context_line = null;
if (!$is_last_block && $depths[$ii + $len]) {
for ($l = $ii + $len - 1; $l >= $ii; $l--) {
$line = $new_lines[$l]['text'];
if ($depths[$l] < $depths[$ii + $len] && trim($line) != '') {
$context = $new_render[$l];
$context_line = $new_lines[$l]['line'];
break;
}
}
}
$container = javelin_tag('tr', array('sigil' => 'context-target'), array(phutil_tag('td', array('colspan' => 2, 'class' => 'show-more'), phutil_implode_html(" • ", $contents)), phutil_tag('th', array('class' => 'show-context-line'), $context_line ? (int) $context_line : null), phutil_tag('td', array('colspan' => 3, 'class' => 'show-context'), phutil_safe_html($context))));
$html[] = $container;
$ii += $len - 1;
continue;
}
$o_num = null;
$o_classes = '';
$o_text = null;
if (isset($old_lines[$ii])) {
$o_num = $old_lines[$ii]['line'];
$o_text = isset($old_render[$ii]) ? $old_render[$ii] : null;
if ($old_lines[$ii]['type']) {
if ($old_lines[$ii]['type'] == '\\') {
$o_text = $old_lines[$ii]['text'];
$o_class = 'comment';
} else {
if ($original_left && !isset($highlight_old[$o_num])) {
$o_class = 'old-rebase';
} else {
if (empty($new_lines[$ii])) {
$o_class = 'old old-full';
} else {
$o_class = 'old';
}
}
}
$o_classes = $o_class;
}
}
$n_copy = hsprintf('<td class="copy" />');
$n_cov = null;
$n_colspan = 2;
//.........这里部分代码省略.........
开发者ID:denghp,项目名称:phabricator,代码行数:101,代码来源:DifferentialChangesetTwoUpRenderer.php
示例16: handleRequest
//.........这里部分代码省略.........
switch ($kind) {
case PhabricatorAuthSessionEngine::KIND_ANONYMOUS:
// If this is an anonymous session. It's expected that they won't
// be logged in, so we can just continue.
break;
default:
// The session cookie is invalid, so clear it.
$request->clearCookie(PhabricatorCookies::COOKIE_USERNAME);
$request->clearCookie(PhabricatorCookies::COOKIE_SESSION);
return $this->renderError(pht('Your login session is invalid. Try reloading the page and ' . 'logging in again. If that does not work, clear your browser ' . 'cookies.'));
}
}
$providers = PhabricatorAuthProvider::getAllEnabledProviders();
foreach ($providers as $key => $provider) {
if (!$provider->shouldAllowLogin()) {
unset($providers[$key]);
}
}
if (!$providers) {
if ($this->isFirstTimeSetup()) {
// If this is a fresh install, let the user register their admin
// account.
return id(new AphrontRedirectResponse())->setURI($this->getApplicationURI('/register/'));
}
return $this->renderError(pht('This Phabricator install is not configured with any enabled ' . 'authentication providers which can be used to log in. If you ' . 'have accidentally locked yourself out by disabling all providers, ' . 'you can use `%s` to recover access to an administrative account.', 'phabricator/bin/auth recover <username>'));
}
$next_uri = $request->getStr('next');
if (!strlen($next_uri)) {
if ($this->getDelegatingController()) {
// Only set a next URI from the request path if this controller was
// delegated to, which happens when a user tries to view a page which
// requires them to login.
// If this controller handled the request directly, we're on the main
// login page, and never want to redirect the user back here after they
// login.
$next_uri = (string) $this->getRequest()->getRequestURI();
}
}
if (!$request->isFormPost()) {
if (strlen($next_uri)) {
PhabricatorCookies::setNextURICookie($request, $next_uri);
}
PhabricatorCookies::setClientIDCookie($request);
}
if (!$request->getURIData('loggedout') && count($providers) == 1) {
$auto_login_provider = head($providers);
$auto_login_config = $auto_login_provider->getProviderConfig();
if ($auto_login_provider instanceof PhabricatorPhabricatorAuthProvider && $auto_login_config->getShouldAutoLogin()) {
$auto_login_adapter = $provider->getAdapter();
$auto_login_adapter->setState($provider->getAuthCSRFCode($request));
return id(new AphrontRedirectResponse())->setIsExternal(true)->setURI($provider->getAdapter()->getAuthenticateURI());
}
}
$invite = $this->loadInvite();
$not_buttons = array();
$are_buttons = array();
$providers = msort($providers, 'getLoginOrder');
foreach ($providers as $provider) {
if ($invite) {
$form = $provider->buildInviteForm($this);
} else {
$form = $provider->buildLoginForm($this);
}
if ($provider->isLoginFormAButton()) {
$are_buttons[] = $form;
} else {
$not_buttons[] = $form;
}
}
$out = array();
$out[] = $not_buttons;
if ($are_buttons) {
require_celerity_resource('auth-css');
foreach ($are_buttons as $key => $button) {
$are_buttons[$key] = phutil_tag('div', array('class' => 'phabricator-login-button mmb'), $button);
}
// If we only have one button, add a second pretend button so that we
// always have two columns. This makes it easier to get the alignments
// looking reasonable.
if (count($are_buttons) == 1) {
$are_buttons[] = null;
}
$button_columns = id(new AphrontMultiColumnView())->setFluidLayout(true);
$are_buttons = array_chunk($are_buttons, ceil(count($are_buttons) / 2));
foreach ($are_buttons as $column) {
$button_columns->addColumn($column);
}
$out[] = phutil_tag('div', array('class' => 'phabricator-login-buttons'), $button_columns);
}
$login_message = PhabricatorEnv::getEnvConfig('auth.login-message');
$login_message = phutil_safe_html($login_message);
$invite_message = null;
if ($invite) {
$invite_message = $this->renderInviteHeader($invite);
}
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Login'));
$crumbs->setBorder(true);
return $this->buildApplicationPage(array($crumbs, $login_message, $invite_message, $out), array('title' => pht('Login to Phabricator')));
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:101,代码来源:PhabricatorAuthStartController.php
示例17: addRawHTMLSection
public function addRawHTMLSection($html)
{
$this->htmlSections[] = phutil_safe_html($html);
return $this;
}
开发者ID:hrb518,项目名称:phabricator,代码行数:5,代码来源:PhabricatorMetaMTAMailBody.php
示例18: loadContent
private function loadContent(array $pastes)
{
$cache = new PhabricatorKeyValueDatabaseCache();
$cache = new PhutilKeyValueCacheProfiler($cache);
$cache->setProfiler(PhutilServiceProfiler::getInstance());
$keys = array();
foreach ($pastes as $paste) {
$keys[] = $this->getContentCacheKey($paste);
}
$caches = $cache->getKeys($keys);
$need_raw = array();
$have_cache = array();
foreach ($pastes as $paste) {
$key = $this->getContentCacheKey($paste);
if (isset($caches[$key])) {
$paste->attachContent(phutil_safe_html($caches[$key]));
$have_cache[$paste->getPHID()] = true;
} else {
$need_raw[$key] = $paste;
}
}
if (!$need_raw) {
return $pastes;
}
$write_data = array();
$have_raw = $this->loadRawContent($need_raw);
$have_raw = mpull($have_raw, null, 'getPHID');
foreach ($pastes as $key => $paste) {
$paste_phid = $paste->getPHID();
if (isset($have_cache[$paste_phid])) {
continue;
}
if (empty($have_raw[$paste_phid])) {
unset($pastes[$key]);
continue;
}
$content = $this->buildContent($paste);
$paste->attachContent($content);
$write_data[$this->getContentCacheKey($paste)] = (string) $content;
}
if ($write_data) {
$cache->setKeys($write_data);
}
return $pastes;
}
开发者ID:fengshao0907,项目名称:phabricator,代码行数:45,代码来源:PhabricatorPasteQuery.php
示例19: translate
public function translate($text)
{
if (isset($this->translations[$text])) {
$translation = $this->translations[$text];
} else {
$translation = $text;
}
$args = func_get_args();
while (is_array($translation)) {
$arg = next($args);
$translation = $this->chooseVariant($translation, $arg);
if ($translation === null) {
$pos = key($args);
if (is_object($arg)) {
$kind = get_class($arg);
} else {
$kind = gettype($arg);
}
return sprintf('[Invalid Translation!] The "%s" language data offers variant ' . 'translations for the plurality or gender of argument %s, but ' . 'the value for that argument is not an integer, PhutilNumber, or ' . 'PhutilPerson (it is a value of type "%s"). Raw input: <%s>.', $this->localeCode, $pos, $kind, $text);
}
}
array_shift($args);
foreach ($args as $k => $arg) {
if ($arg instanceof PhutilNumber) {
$args[$k] = $this->formatNumber($arg->getNumber(), $arg->getDecimals());
}
}
// Check if any arguments are PhutilSafeHTML. If they are, we will apply
// any escaping necessary and output HTML.
$is_html = false;
foreach ($args as $arg) {
if ($arg instanceof PhutilSafeHTML || $arg instanceof PhutilSafeHTMLProducerInterface) {
$is_html = true;
break;
}
}
if ($is_html) {
foreach ($args as $k => $arg) {
$args[$k] = (string) phutil_escape_html($arg);
}
}
$result = vsprintf($translation, $args);
if ($result === false) {
// If vsprintf() fails (often because the translated string references
// too many parameters), show the bad template with a note instead of
// returning an empty string. This makes it easier to figure out what
// went wrong and fix it.
$result = pht('[Invalid Translation!] %s', $translation);
}
if ($this->shouldPostProcess) {
$result = $this->locale->didTranslateString($text, $translation, $args, $result);
}
if ($is_html) {
$result = phutil_safe_html($result);
}
return $result;
}
开发者ID:endlessm,项目名称:libphutil,代码行数:57,代码来源:PhutilTranslator.php
示例20: replaceHTML
protected function replaceHTML($pattern, $callback, $text)
{
$this->replaceCallback = $callback;
return phutil_safe_html(preg_replace_callback($pattern, array($this, 'replaceHTMLCallback'), phutil_escape_html($text)));
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:5,代码来源:PhutilRemarkupRule.php
注:本文中的phutil_safe_html函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论