本文整理汇总了PHP中wfUrlProtocolsWithoutProtRel函数的典型用法代码示例。如果您正苦于以下问题:PHP wfUrlProtocolsWithoutProtRel函数的具体用法?PHP wfUrlProtocolsWithoutProtRel怎么用?PHP wfUrlProtocolsWithoutProtRel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wfUrlProtocolsWithoutProtRel函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: link
/**
* @param $text string
* @return string
*/
function link($text)
{
# Catch links like http://www.mediawiki.org/wiki/Special:Code/MediaWiki/44245#c829
# Ended by space or brackets (like those pesky <br /> tags)
$text = preg_replace_callback('/(^|[^\\w[])(' . wfUrlProtocolsWithoutProtRel() . ')(' . Parser::EXT_LINK_URL_CLASS . '+)/', array($this, 'generalLink'), $text);
$text = preg_replace_callback('/\\br(\\d+)\\b/', array($this, 'messageRevLink'), $text);
$text = preg_replace_callback(CodeRevision::BugReference, array($this, 'messageBugLink'), $text);
return $text;
}
示例2: markNoConversion
/**
* Prepare external link text for conversion. When the text is
* a URL, it shouldn't be converted, and it'll be wrapped in
* the "raw" tag (-{R| }-) to prevent conversion.
*
* This function is called "markNoConversion" for historical
* reasons.
*
* @param string $text Text to be used for external link
* @param bool $noParse Wrap it without confirming it's a real URL first
* @return string The tagged text
*/
public function markNoConversion($text, $noParse = false)
{
// Excluding protocal-relative URLs may avoid many false positives.
if ($noParse || preg_match('/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text)) {
return $this->mConverter->markNoConversion($text);
} else {
return $text;
}
}
示例3: doMagicLinks
/**
* Replace special strings like "ISBN xxx" and "RFC xxx" with
* magic external links.
*
* DML
* @private
*
* @param $text string
*
* @return string
*/
function doMagicLinks($text)
{
wfProfileIn(__METHOD__);
$prots = wfUrlProtocolsWithoutProtRel();
$urlChar = self::EXT_LINK_URL_CLASS;
$text = preg_replace_callback('!(?: # Start cases
(<a[ \\t\\r\\n>].*?</a>) | # m[1]: Skip link text
(<.*?>) | # m[2]: Skip stuff inside HTML elements' . "\n\t\t\t\t(\\b(?i:{$prots}){$urlChar}+) | # m[3]: Free external links" . '
(?:RFC|PMID)\\s+([0-9]+) | # m[4]: RFC or PMID, capture number
ISBN\\s+(\\b # m[5]: ISBN, capture number
(?: 97[89] [\\ \\-]? )? # optional 13-digit ISBN prefix
(?: [0-9] [\\ \\-]? ){9} # 9 digits with opt. delimiters
[0-9Xx] # check digit
\\b)
)!xu', array(&$this, 'magicLinkCallback'), $text);
wfProfileOut(__METHOD__);
return $text;
}
示例4: doMagicLinks
/**
* Replace special strings like "ISBN xxx" and "RFC xxx" with
* magic external links.
*
* DML
* @private
*
* @param string $text
*
* @return string
*/
public function doMagicLinks($text)
{
$prots = wfUrlProtocolsWithoutProtRel();
$urlChar = self::EXT_LINK_URL_CLASS;
$addr = self::EXT_LINK_ADDR;
$space = self::SPACE_NOT_NL;
# non-newline space
$spdash = "(?:-|{$space})";
# a dash or a non-newline space
$spaces = "{$space}++";
# possessive match of 1 or more spaces
$text = preg_replace_callback('!(?: # Start cases
(<a[ \\t\\r\\n>].*?</a>) | # m[1]: Skip link text
(<.*?>) | # m[2]: Skip stuff inside
# HTML elements' . "\n\t\t\t\t(\\b(?i:{$prots})({$addr}{$urlChar}*)) | # m[3]: Free external links\n\t\t\t\t # m[4]: Post-protocol path\n\t\t\t\t\\b(?:RFC|PMID) {$spaces} # m[5]: RFC or PMID, capture number\n\t\t\t\t\t([0-9]+)\\b |\n\t\t\t\t\\bISBN {$spaces} ( # m[6]: ISBN, capture number\n\t\t\t\t\t(?: 97[89] {$spdash}? )? # optional 13-digit ISBN prefix\n\t\t\t\t\t(?: [0-9] {$spdash}? ){9} # 9 digits with opt. delimiters\n\t\t\t\t\t[0-9Xx] # check digit\n\t\t\t\t)\\b\n\t\t\t)!xu", array(&$this, 'magicLinkCallback'), $text);
return $text;
}
示例5: formatHTML
/**
* Pretty-print various elements in HTML format, such as xml tags and
* URLs. This method also escapes characters like <
* @deprecated since 1.25
* @param string $text
* @return string
*/
protected function formatHTML($text)
{
wfDeprecated(__METHOD__, '1.25');
// Escape everything first for full coverage
$text = htmlspecialchars($text);
if ($this->mFormat === 'XML') {
// encode all comments or tags as safe blue strings
$text = str_replace('<', '<span style="color:blue;"><', $text);
$text = str_replace('>', '></span>', $text);
}
// identify requests to api.php
$text = preg_replace('#^(\\s*)(api\\.php\\?[^ <\\n\\t]+)$#m', '\\1<a href="\\2">\\2</a>', $text);
if ($this->mHelp) {
// make lines inside * bold
$text = preg_replace('#^(\\s*)(\\*[^<>\\n]+\\*)(\\s*)$#m', '$1<b>$2</b>$3', $text);
}
// Armor links (bug 61362)
$masked = [];
$text = preg_replace_callback('#<a .*?</a>#', function ($matches) use(&$masked) {
$sha = sha1($matches[0]);
$masked[$sha] = $matches[0];
return "<{$sha}>";
}, $text);
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (" included in the URL)
$text = preg_replace("#(((?i){$protos}).*?)(")?([ \\'\"<>\n]|<|>|")#", '<a href="\\1">\\1</a>\\3\\4', $text);
// Unarmor links
$text = preg_replace_callback('#<([0-9a-f]{40})>#', function ($matches) use(&$masked) {
$sha = $matches[1];
return isset($masked[$sha]) ? $masked[$sha] : $matches[0];
}, $text);
/**
* Temporary fix for bad links in help messages. As a special case,
* XML-escaped metachars are de-escaped one level in the help message
* for legibility. Should be removed once we have completed a fully-HTML
* version of the help message.
*/
if ($this->mUnescapeAmps) {
$text = preg_replace('/&(amp|quot|lt|gt);/', '&\\1;', $text);
}
return $text;
}
示例6: formatHTML
/**
* Pretty-print various elements in HTML format, such as xml tags and
* URLs. This method also escapes characters like <
* @param $text string
* @return string
*/
protected function formatHTML($text)
{
// Escape everything first for full coverage
$text = htmlspecialchars($text);
// encode all comments or tags as safe blue strings
$text = str_replace('<', '<span style="color:blue;"><', $text);
$text = str_replace('>', '></span>', $text);
// identify requests to api.php
$text = preg_replace("#api\\.php\\?[^ <\n\t]+#", '<a href="\\0">\\0</a>', $text);
if ($this->mHelp) {
// make strings inside * bold
$text = preg_replace("#\\*[^<>\n]+\\*#", '<b>\\0</b>', $text);
}
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (" included in the URL)
$text = preg_replace("#(((?i){$protos}).*?)(")?([ \\'\"<>\n]|<|>|")#", '<a href="\\1">\\1</a>\\3\\4', $text);
/**
* Temporary fix for bad links in help messages. As a special case,
* XML-escaped metachars are de-escaped one level in the help message
* for legibility. Should be removed once we have completed a fully-HTML
* version of the help message.
*/
if ($this->mUnescapeAmps) {
$text = preg_replace('/&(amp|quot|lt|gt);/', '&\\1;', $text);
}
return $text;
}
示例7: formatHTML
/**
* Pretty-print various elements in HTML format, such as xml tags and
* URLs. This method also escapes characters like <
* @param $text string
* @return string
*/
protected function formatHTML($text)
{
// Escape everything first for full coverage
$text = htmlspecialchars($text);
// encode all comments or tags as safe blue strings
$text = preg_replace('/\\<(!--.*?--|.*?)\\>/', '<span style="color:blue;"><\\1></span>', $text);
// identify requests to api.php
$text = preg_replace('#^(\\s*)(api\\.php\\?[^ <\\n\\t]+)$#m', '\\1<a href="\\2">\\2</a>', $text);
if ($this->mHelp) {
// make strings inside * bold
$text = preg_replace("#\\*[^<>\n]+\\*#", '<b>\\0</b>', $text);
// make strings inside $ italic
$text = preg_replace("#\\\$[^<>\n]+\\\$#", '<b><i>\\0</i></b>', $text);
}
// Armor links (bug 61362)
$this->mMasked = array();
$text = preg_replace_callback('#<a .*?</a>#', array($this, 'armorLinkCallback'), $text);
// identify URLs
$protos = wfUrlProtocolsWithoutProtRel();
// This regex hacks around bug 13218 (" included in the URL)
$text = preg_replace("#(({$protos}).*?)(")?([ \\'\"<>\n]|<|>|")#", '<a href="\\1">\\1</a>\\3\\4', $text);
// Unarmor links
$text = preg_replace_callback('#<([0-9a-f]{40})>#', array($this, 'unarmorLinkCallback'), $text);
$this->mMasked = null;
/**
* Temporary fix for bad links in help messages. As a special case,
* XML-escaped metachars are de-escaped one level in the help message
* for legibility. Should be removed once we have completed a fully-HTML
* version of the help message.
*/
if ($this->mUnescapeAmps) {
$text = preg_replace('/&(amp|quot|lt|gt);/', '&\\1;', $text);
}
return $text;
}