当前位置: 首页>>代码示例>>PHP>>正文


PHP Sanitizer::normalizeSectionNameWhitespace方法代码示例

本文整理汇总了PHP中Sanitizer::normalizeSectionNameWhitespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitizer::normalizeSectionNameWhitespace方法的具体用法?PHP Sanitizer::normalizeSectionNameWhitespace怎么用?PHP Sanitizer::normalizeSectionNameWhitespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sanitizer的用法示例。


在下文中一共展示了Sanitizer::normalizeSectionNameWhitespace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: formatAutocommentsCallback

 /**
  * @param $match
  * @return string
  */
 private static function formatAutocommentsCallback($match)
 {
     $title = self::$autocommentTitle;
     $local = self::$autocommentLocal;
     $pre = $match[1];
     $auto = $match[2];
     $post = $match[3];
     $link = '';
     if ($title) {
         $section = $auto;
         # Remove links that a user may have manually put in the autosummary
         # This could be improved by copying as much of Parser::stripSectionName as desired.
         $section = str_replace('[[:', '', $section);
         $section = str_replace('[[', '', $section);
         $section = str_replace(']]', '', $section);
         $section = Sanitizer::normalizeSectionNameWhitespace($section);
         # bug 22784
         if ($local) {
             $sectionTitle = Title::newFromText('#' . $section);
         } else {
             $sectionTitle = Title::makeTitleSafe($title->getNamespace(), $title->getDBkey(), $section);
         }
         if ($sectionTitle) {
             $link = self::link($sectionTitle, htmlspecialchars(wfMsgForContent('sectionlink')), array(), array(), 'noclasses');
         } else {
             $link = '';
         }
     }
     $auto = "{$link}{$auto}";
     if ($pre) {
         # written summary $presep autocomment (summary /* section */)
         $auto = wfMsgExt('autocomment-prefix', array('escapenoentities', 'content')) . $auto;
     }
     if ($post) {
         # autocomment $postsep written summary (/* section */ summary)
         $auto .= wfMsgExt('colon-separator', array('escapenoentities', 'content'));
     }
     $auto = '<span class="autocomment">' . $auto . '</span>';
     $comment = $pre . $auto . $post;
     return $comment;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:45,代码来源:Linker.php

示例2: guessLegacySectionNameFromWikiText

 /**
  * Same as guessSectionNameFromWikiText(), but produces legacy anchors
  * instead.  For use in redirects, since IE6 interprets Redirect: headers
  * as something other than UTF-8 (apparently?), resulting in breakage.
  *
  * @param string $text The section name
  * @return string An anchor
  */
 public function guessLegacySectionNameFromWikiText($text)
 {
     # Strip out wikitext links(they break the anchor)
     $text = $this->stripSectionName($text);
     $text = Sanitizer::normalizeSectionNameWhitespace($text);
     return '#' . Sanitizer::escapeId($text, array('noninitial', 'legacy'));
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:15,代码来源:Parser.php

示例3: formatAutocommentsCallback

 /**
  * @param $match
  * @return string
  */
 private static function formatAutocommentsCallback($match)
 {
     global $wgLang;
     $title = self::$autocommentTitle;
     $local = self::$autocommentLocal;
     $pre = $match[1];
     $auto = $match[2];
     $post = $match[3];
     $comment = null;
     wfRunHooks('FormatAutocomments', array(&$comment, $pre, $auto, $post, $title, $local));
     if ($comment === null) {
         $link = '';
         if ($title) {
             $section = $auto;
             # Remove links that a user may have manually put in the autosummary
             # This could be improved by copying as much of Parser::stripSectionName as desired.
             $section = str_replace('[[:', '', $section);
             $section = str_replace('[[', '', $section);
             $section = str_replace(']]', '', $section);
             $section = Sanitizer::normalizeSectionNameWhitespace($section);
             # bug 22784
             if ($local) {
                 $sectionTitle = Title::newFromText('#' . $section);
             } else {
                 $sectionTitle = Title::makeTitleSafe($title->getNamespace(), $title->getDBkey(), $section);
             }
             if ($sectionTitle) {
                 $link = self::link($sectionTitle, $wgLang->getArrow(), array(), array(), 'noclasses');
             } else {
                 $link = '';
             }
         }
         if ($pre) {
             # written summary $presep autocomment (summary /* section */)
             $pre .= wfMessage('autocomment-prefix')->inContentLanguage()->escaped();
         }
         if ($post) {
             # autocomment $postsep written summary (/* section */ summary)
             $auto .= wfMessage('colon-separator')->inContentLanguage()->escaped();
         }
         $auto = '<span class="autocomment">' . $auto . '</span>';
         $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto . $post . '</span>';
     }
     return $comment;
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:49,代码来源:Linker.php

示例4: formatAutocomments

 /**
  * Converts autogenerated comments in edit summaries into section links.
  *
  * The pattern for autogen comments is / * foo * /, which makes for
  * some nasty regex.
  * We look for all comments, match any text before and after the comment,
  * add a separator where needed and format the comment itself with CSS
  * Called by Linker::formatComment.
  *
  * @param string $comment Comment text
  * @param Title|null $title An optional title object used to links to sections
  * @param bool $local Whether section links should refer to local page
  * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
  *  as used by WikiMap.
  *
  * @return string Formatted comment (wikitext)
  */
 private static function formatAutocomments($comment, $title = null, $local = false, $wikiId = null)
 {
     // @todo $append here is something of a hack to preserve the status
     // quo. Someone who knows more about bidi and such should decide
     // (1) what sane rendering even *is* for an LTR edit summary on an RTL
     // wiki, both when autocomments exist and when they don't, and
     // (2) what markup will make that actually happen.
     $append = '';
     $comment = preg_replace_callback('!(?:(?<=(.)))?/\\*\\s*(.*?)\\s*\\*/(?:(?=(.)))?!', function ($match) use($title, $local, $wikiId, &$append) {
         global $wgLang;
         // Ensure all match positions are defined
         $match += array('', '', '', '');
         $pre = $match[1] !== '';
         $auto = $match[2];
         $post = $match[3] !== '';
         $comment = null;
         Hooks::run('FormatAutocomments', array(&$comment, $pre, $auto, $post, $title, $local, $wikiId));
         if ($comment === null) {
             $link = '';
             if ($title) {
                 $section = $auto;
                 # Remove links that a user may have manually put in the autosummary
                 # This could be improved by copying as much of Parser::stripSectionName as desired.
                 $section = str_replace('[[:', '', $section);
                 $section = str_replace('[[', '', $section);
                 $section = str_replace(']]', '', $section);
                 $section = Sanitizer::normalizeSectionNameWhitespace($section);
                 # bug 22784
                 if ($local) {
                     $sectionTitle = Title::newFromText('#' . $section);
                 } else {
                     $sectionTitle = Title::makeTitleSafe($title->getNamespace(), $title->getDBkey(), $section);
                 }
                 if ($sectionTitle) {
                     $link = Linker::makeCommentLink($sectionTitle, $wgLang->getArrow(), $wikiId, 'noclasses');
                 } else {
                     $link = '';
                 }
             }
             if ($pre) {
                 # written summary $presep autocomment (summary /* section */)
                 $pre = wfMessage('autocomment-prefix')->inContentLanguage()->escaped();
             }
             if ($post) {
                 # autocomment $postsep written summary (/* section */ summary)
                 $auto .= wfMessage('colon-separator')->inContentLanguage()->escaped();
             }
             $auto = '<span class="autocomment">' . $auto . '</span>';
             $comment = $pre . $link . $wgLang->getDirMark() . '<span dir="auto">' . $auto;
             $append .= '</span>';
         }
         return $comment;
     }, $comment);
     return $comment . $append;
 }
开发者ID:paladox,项目名称:2,代码行数:72,代码来源:Linker.php

示例5: createFeedItem

 /**
  * @param $info array
  * @return FeedItem
  */
 private function createFeedItem($info)
 {
     $titleStr = $info['title'];
     $title = Title::newFromText($titleStr);
     if ($this->linkToDiffs && isset($info['revid'])) {
         $titleUrl = $title->getFullURL(array('diff' => $info['revid']));
     } else {
         $titleUrl = $title->getFullURL();
     }
     $comment = isset($info['comment']) ? $info['comment'] : null;
     // Create an anchor to section.
     // The anchor won't work for sections that have dupes on page
     // as there's no way to strip that info from ApiWatchlist (apparently?).
     // RegExp in the line below is equal to Linker::formatAutocomments().
     if ($this->linkToSections && $comment !== null && preg_match('!(.*)/\\*\\s*(.*?)\\s*\\*/(.*)!', $comment, $matches)) {
         global $wgParser;
         $sectionTitle = $wgParser->stripSectionName($matches[2]);
         $sectionTitle = Sanitizer::normalizeSectionNameWhitespace($sectionTitle);
         $titleUrl .= Title::newFromText('#' . $sectionTitle)->getFragmentForURL();
     }
     $timestamp = $info['timestamp'];
     $user = $info['user'];
     $completeText = "{$comment} ({$user})";
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:29,代码来源:ApiFeedWatchlist.php

示例6: createFeedItem

 /**
  * @param array $info
  * @return FeedItem
  */
 private function createFeedItem($info)
 {
     if (!isset($info['title'])) {
         // Probably a revdeled log entry, skip it.
         return null;
     }
     $titleStr = $info['title'];
     $title = Title::newFromText($titleStr);
     $curidParam = array();
     if (!$title || $title->isExternal()) {
         // Probably a formerly-valid title that's now conflicting with an
         // interwiki prefix or the like.
         if (isset($info['pageid'])) {
             $title = Title::newFromId($info['pageid']);
             $curidParam = array('curid' => $info['pageid']);
         }
         if (!$title || $title->isExternal()) {
             return null;
         }
     }
     if (isset($info['revid'])) {
         $titleUrl = $title->getFullURL(array('diff' => $info['revid']));
     } else {
         $titleUrl = $title->getFullURL($curidParam);
     }
     $comment = isset($info['comment']) ? $info['comment'] : null;
     // Create an anchor to section.
     // The anchor won't work for sections that have dupes on page
     // as there's no way to strip that info from ApiWatchlist (apparently?).
     // RegExp in the line below is equal to Linker::formatAutocomments().
     if ($this->linkToSections && $comment !== null && preg_match('!(.*)/\\*\\s*(.*?)\\s*\\*/(.*)!', $comment, $matches)) {
         global $wgParser;
         $sectionTitle = $wgParser->stripSectionName($matches[2]);
         $sectionTitle = Sanitizer::normalizeSectionNameWhitespace($sectionTitle);
         $titleUrl .= Title::newFromText('#' . $sectionTitle)->getFragmentForURL();
     }
     $timestamp = $info['timestamp'];
     if (isset($info['user'])) {
         $user = $info['user'];
         $completeText = "{$comment} ({$user})";
     } else {
         $user = '';
         $completeText = (string) $comment;
     }
     return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:50,代码来源:ApiFeedWatchlist.php


注:本文中的Sanitizer::normalizeSectionNameWhitespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。