本文整理汇总了PHP中Title::isTalkPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::isTalkPage方法的具体用法?PHP Title::isTalkPage怎么用?PHP Title::isTalkPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::isTalkPage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForm
/**
* Show the form
*
* @param array $err Error messages. Each item is an error message.
* It may either be a string message name or array message name and
* parameters, like the second argument to OutputPage::wrapWikiMsg().
*/
function showForm($err)
{
global $wgContLang;
$this->getSkin()->setRelevantTitle($this->oldTitle);
$oldTitleLink = Linker::link($this->oldTitle);
$out = $this->getOutput();
$out->setPageTitle($this->msg('move-page', $this->oldTitle->getPrefixedText()));
$out->addModules('mediawiki.special.movePage');
$out->addModuleStyles('mediawiki.special.movePage.styles');
$this->addHelpLink('Help:Moving a page');
$newTitle = $this->newTitle;
if (!$newTitle) {
# Show the current title as a default
# when the form is first opened.
$newTitle = $this->oldTitle;
} elseif (!count($err)) {
# If a title was supplied, probably from the move log revert
# link, check for validity. We can then show some diagnostic
# information and save a click.
$newerr = $this->oldTitle->isValidMoveOperation($newTitle);
if (is_array($newerr)) {
$err = $newerr;
}
}
$user = $this->getUser();
if (count($err) == 1 && isset($err[0][0]) && $err[0][0] == 'articleexists' && $newTitle->quickUserCan('delete', $user)) {
$out->addWikiMsg('delete_and_move_text', $newTitle->getPrefixedText());
$movepagebtn = $this->msg('delete_and_move')->text();
$submitVar = 'wpDeleteAndMove';
$confirm = true;
$err = array();
} else {
if ($this->oldTitle->getNamespace() == NS_USER && !$this->oldTitle->isSubpage()) {
$out->wrapWikiMsg("<div class=\"error mw-moveuserpage-warning\">\n\$1\n</div>", 'moveuserpage-warning');
} elseif ($this->oldTitle->getNamespace() == NS_CATEGORY) {
$out->wrapWikiMsg("<div class=\"error mw-movecategorypage-warning\">\n\$1\n</div>", 'movecategorypage-warning');
}
$out->addWikiMsg($this->getConfig()->get('FixDoubleRedirects') ? 'movepagetext' : 'movepagetext-noredirectfixer');
$movepagebtn = $this->msg('movepagebtn')->text();
$submitVar = 'wpMove';
$confirm = false;
}
if (count($err) == 1 && isset($err[0][0]) && $err[0][0] == 'file-exists-sharedrepo' && $user->isAllowed('reupload-shared')) {
$out->addWikiMsg('move-over-sharedrepo', $newTitle->getPrefixedText());
$submitVar = 'wpMoveOverSharedFile';
$err = array();
}
$oldTalk = $this->oldTitle->getTalkPage();
$oldTitleSubpages = $this->oldTitle->hasSubpages();
$oldTitleTalkSubpages = $this->oldTitle->getTalkPage()->hasSubpages();
$canMoveSubpage = ($oldTitleSubpages || $oldTitleTalkSubpages) && !count($this->oldTitle->getUserPermissionsErrors('move-subpages', $user));
# We also want to be able to move assoc. subpage talk-pages even if base page
# has no associated talk page, so || with $oldTitleTalkSubpages.
$considerTalk = !$this->oldTitle->isTalkPage() && ($oldTalk->exists() || $oldTitleTalkSubpages && $canMoveSubpage);
$dbr = wfGetDB(DB_SLAVE);
if ($this->getConfig()->get('FixDoubleRedirects')) {
$hasRedirects = $dbr->selectField('redirect', '1', array('rd_namespace' => $this->oldTitle->getNamespace(), 'rd_title' => $this->oldTitle->getDBkey()), __METHOD__);
} else {
$hasRedirects = false;
}
if ($considerTalk) {
$out->addWikiMsg('movepagetalktext');
}
if (count($err)) {
$out->addHTML("<div class='error'>\n");
$action_desc = $this->msg('action-move')->plain();
$out->addWikiMsg('permissionserrorstext-withaction', count($err), $action_desc);
if (count($err) == 1) {
$errMsg = $err[0];
$errMsgName = array_shift($errMsg);
if ($errMsgName == 'hookaborted') {
$out->addHTML("<p>{$errMsg[0]}</p>\n");
} else {
$out->addWikiMsgArray($errMsgName, $errMsg);
}
} else {
$errStr = array();
foreach ($err as $errMsg) {
if ($errMsg[0] == 'hookaborted') {
$errStr[] = $errMsg[1];
} else {
$errMsgName = array_shift($errMsg);
$errStr[] = $this->msg($errMsgName, $errMsg)->parse();
}
}
$out->addHTML('<ul><li>' . implode("</li>\n<li>", $errStr) . "</li></ul>\n");
}
$out->addHTML("</div>\n");
}
if ($this->oldTitle->isProtected('move')) {
# Is the title semi-protected?
if ($this->oldTitle->isSemiProtected('move')) {
$noticeMsg = 'semiprotectedpagemovewarning';
//.........这里部分代码省略.........
示例2: wfProfileIn
/**
* Process [[ ]] wikilinks (RIL)
* @param $s
* @throws MWException
* @return LinkHolderArray
*
* @private
*/
function replaceInternalLinks2(&$s)
{
wfProfileIn(__METHOD__);
wfProfileIn(__METHOD__ . '-setup');
static $tc = false, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if (!$tc) {
$tc = Title::legalChars() . '#%';
# Match a link having the form [[namespace:link|alternate]]trail
$e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
# Match cases where there is no "]]", which might still be images
$e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
}
$holders = new LinkHolderArray($this);
# split the entire text string on occurrences of [[
$a = StringUtils::explode('[[', ' ' . $s);
# get the first element (all text up to first [[), and remove the space we added
$s = $a->current();
$a->next();
$line = $a->current();
# Workaround for broken ArrayIterator::next() that returns "void"
$s = substr($s, 1);
$useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
$e2 = null;
if ($useLinkPrefixExtension) {
# Match the end of a line for a word that's not followed by whitespace,
# e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
global $wgContLang;
$charset = $wgContLang->linkPrefixCharset();
$e2 = "/^((?>.*[^{$charset}]|))(.+)\$/sDu";
}
if (is_null($this->mTitle)) {
wfProfileOut(__METHOD__ . '-setup');
wfProfileOut(__METHOD__);
throw new MWException(__METHOD__ . ": \$this->mTitle is null\n");
}
$nottalk = !$this->mTitle->isTalkPage();
if ($useLinkPrefixExtension) {
$m = array();
if (preg_match($e2, $s, $m)) {
$first_prefix = $m[2];
} else {
$first_prefix = false;
}
} else {
$prefix = '';
}
$useSubpages = $this->areSubpagesAllowed();
wfProfileOut(__METHOD__ . '-setup');
# Loop for each link
for (; $line !== false && $line !== null; $a->next(), $line = $a->current()) {
# Check for excessive memory usage
if ($holders->isBig()) {
# Too big
# Do the existence check, replace the link holders and clear the array
$holders->replace($s);
$holders->clear();
}
if ($useLinkPrefixExtension) {
wfProfileIn(__METHOD__ . '-prefixhandling');
if (preg_match($e2, $s, $m)) {
$prefix = $m[2];
$s = $m[1];
} else {
$prefix = '';
}
# first link
if ($first_prefix) {
$prefix = $first_prefix;
$first_prefix = false;
}
wfProfileOut(__METHOD__ . '-prefixhandling');
}
$might_be_img = false;
wfProfileIn(__METHOD__ . "-e1");
if (preg_match($e1, $line, $m)) {
# page with normal text or alt
$text = $m[2];
# If we get a ] at the beginning of $m[3] that means we have a link that's something like:
# [[Image:Foo.jpg|[http://example.com desc]]] <- having three ] in a row fucks up,
# the real problem is with the $e1 regex
# See bug 1300.
#
# Still some problems for cases where the ] is meant to be outside punctuation,
# and no image is in sight. See bug 2095.
#
if ($text !== '' && substr($m[3], 0, 1) === ']' && strpos($text, '[') !== false) {
$text .= ']';
# so that replaceExternalLinks($text) works later
$m[3] = substr($m[3], 1);
}
# fix up urlencoded title texts
//.........这里部分代码省略.........
示例3: getPageClasses
/**
* TODO: document
* @param Title $title
* @return string
*/
function getPageClasses($title)
{
$numeric = 'ns-' . $title->getNamespace();
if ($title->isSpecialPage()) {
$type = 'ns-special';
// bug 23315: provide a class based on the canonical special page name without subpages
list($canonicalName) = SpecialPageFactory::resolveAlias($title->getDBkey());
if ($canonicalName) {
$type .= ' ' . Sanitizer::escapeClass("mw-special-{$canonicalName}");
} else {
$type .= ' mw-invalidspecialpage';
}
} elseif ($title->isTalkPage()) {
$type = 'ns-talk';
} else {
$type = 'ns-subject';
}
$name = Sanitizer::escapeClass('page-' . $title->getPrefixedText());
return "{$numeric} {$type} {$name}";
}
示例4: noCreatePermission
/**
* Show an error page saying to the user that he has insufficient permissions
* to create a new page
*
* @deprecated in 1.19; throw an exception directly instead
*/
function noCreatePermission()
{
wfDeprecated(__METHOD__, '1.19');
$permission = $this->mTitle->isTalkPage() ? 'createtalk' : 'createpage';
throw new PermissionsError($permission);
}
示例5: showHeader
/**
* @return bool
*/
protected function showHeader()
{
global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
global $wgAllowUserCss, $wgAllowUserJs;
if ($this->mTitle->isTalkPage()) {
$wgOut->addWikiMsg('talkpagetext');
}
// Add edit notices
$wgOut->addHTML(implode("\n", $this->mTitle->getEditNotices($this->oldid)));
if ($this->isConflict) {
$wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict');
$this->edittime = $this->mArticle->getTimestamp();
} else {
if ($this->section != '' && !$this->isSectionEditSupported()) {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// at this point we can't reset $this->section to '' to fallback to non-section editing.
// Someone is welcome to try refactoring though
$wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text');
return false;
}
if ($this->section != '' && $this->section != 'new') {
if (!$this->summary && !$this->preview && !$this->diff) {
$sectionTitle = self::extractSectionTitle($this->textbox1);
//FIXME: use Content object
if ($sectionTitle !== false) {
$this->summary = "/* {$sectionTitle} */ ";
}
}
}
if ($this->missingComment) {
$wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext');
}
if ($this->missingSummary && $this->section != 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary');
}
if ($this->missingSummary && $this->section == 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader');
}
if ($this->blankArticle) {
$wgOut->wrapWikiMsg("<div id='mw-blankarticle'>\n\$1\n</div>", 'blankarticle');
}
if ($this->hookError !== '') {
$wgOut->addWikiText($this->hookError);
}
if (!$this->checkUnicodeCompliantBrowser()) {
$wgOut->addWikiMsg('nonunicodebrowser');
}
if ($this->section != 'new') {
$revision = $this->mArticle->getRevisionFetched();
if ($revision) {
// Let sysop know that this will make private content public if saved
if (!$revision->userCan(Revision::DELETED_TEXT, $wgUser)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission');
} elseif ($revision->isDeleted(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view');
}
if (!$revision->isCurrent()) {
$this->mArticle->setOldSubtitle($revision->getId());
$wgOut->addWikiMsg('editingold');
}
} elseif ($this->mTitle->exists()) {
// Something went wrong
$wgOut->wrapWikiMsg("<div class='errorbox'>\n\$1\n</div>\n", array('missing-revision', $this->oldid));
}
}
}
if (wfReadOnly()) {
$wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
} elseif ($wgUser->isAnon()) {
if ($this->formtype != 'preview') {
$wgOut->wrapWikiMsg("<div id='mw-anon-edit-warning'>\n\$1\n</div>", array('anoneditwarning', '{{fullurl:Special:UserLogin|returnto={{FULLPAGENAMEE}}}}', '{{fullurl:Special:UserLogin/signup|returnto={{FULLPAGENAMEE}}}}'));
} else {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning');
}
} else {
if ($this->isCssJsSubpage) {
# Check the skin exists
if ($this->isWrongCaseCssJsPage) {
$wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
}
if ($this->formtype !== 'preview') {
if ($this->isCssSubpage && $wgAllowUserCss) {
$wgOut->wrapWikiMsg("<div id='mw-usercssyoucanpreview'>\n\$1\n</div>", array('usercssyoucanpreview'));
}
if ($this->isJsSubpage && $wgAllowUserJs) {
$wgOut->wrapWikiMsg("<div id='mw-userjsyoucanpreview'>\n\$1\n</div>", array('userjsyoucanpreview'));
}
}
}
}
if ($this->mTitle->isProtected('edit') && MWNamespace::getRestrictionLevels($this->mTitle->getNamespace()) !== array('')) {
# Is the title semi-protected?
if ($this->mTitle->isSemiProtected()) {
$noticeMsg = 'semiprotectedpagewarning';
} else {
# Then it must be protected based on static groups (regular)
$noticeMsg = 'protectedpagewarning';
//.........这里部分代码省略.........
示例6: showSubpages
/**
* Show subpages of the page being moved. Section is not shown if both current
* namespace does not support subpages and no talk subpages were found.
*
* @param Title $title Page being moved.
*/
function showSubpages($title)
{
$nsHasSubpages = MWNamespace::hasSubpages($title->getNamespace());
$subpages = $title->getSubpages();
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;
$titleIsTalk = $title->isTalkPage();
$subpagesTalk = $title->getTalkPage()->getSubpages();
$countTalk = $subpagesTalk instanceof TitleArray ? $subpagesTalk->count() : 0;
$totalCount = $count + $countTalk;
if (!$nsHasSubpages && $countTalk == 0) {
return;
}
$this->getOutput()->wrapWikiMsg('== $1 ==', ['movesubpage', $titleIsTalk ? $count : $totalCount]);
if ($nsHasSubpages) {
$this->showSubpagesList($subpages, $count, 'movesubpagetext', true);
}
if (!$titleIsTalk && $countTalk > 0) {
$this->showSubpagesList($subpagesTalk, $countTalk, 'movesubpagetalktext');
}
}
示例7: addTalkPageText
protected function addTalkPageText()
{
global $wgOut;
if ($this->mTitle->isTalkPage()) {
$wgOut->addWikiMsg('talkpagetext');
}
}
示例8: edit
/**
* This is the function that gets called for "action=edit". It
* sets up various member variables, then passes execution to
* another function, usually showEditForm()
*
* The edit form is self-submitting, so that when things like
* preview and edit conflicts occur, we get the same form back
* with the extra stuff added. Only when the final submission
* is made and all is well do we actually save and redirect to
* the newly-edited page.
*/
function edit()
{
global $wgOut, $wgRequest, $wgUser;
// Allow extensions to modify/prevent this form or submission
if (!wfRunHooks('AlternateEdit', array($this))) {
return;
}
wfProfileIn(__METHOD__);
wfDebug(__METHOD__ . ": enter\n");
// This is not an article
$wgOut->setArticleFlag(false);
$this->importFormData($wgRequest);
$this->firsttime = false;
if ($this->live) {
$this->livePreview();
wfProfileOut(__METHOD__);
return;
}
if (wfReadOnly() && $this->save) {
// Force preview
$this->save = false;
$this->preview = true;
}
$wgOut->addModules(array('mediawiki.action.edit'));
if ($wgUser->getOption('uselivepreview', false)) {
$wgOut->addModules('mediawiki.legacy.preview');
}
// Bug #19334: textarea jumps when editing articles in IE8
$wgOut->addStyle('common/IE80Fixes.css', 'screen', 'IE 8');
$permErrors = $this->getEditPermissionErrors();
if ($permErrors) {
// Auto-block user's IP if the account was "hard" blocked
$wgUser->spreadAnyEditBlock();
wfDebug(__METHOD__ . ": User can't edit\n");
$content = $this->getContent(null);
$content = $content === '' ? null : $content;
$this->readOnlyPage($content, true, $permErrors, 'edit');
wfProfileOut(__METHOD__);
return;
} else {
if ($this->save) {
$this->formtype = 'save';
} elseif ($this->preview) {
$this->formtype = 'preview';
} elseif ($this->diff) {
$this->formtype = 'diff';
} else {
# First time through
$this->firsttime = true;
if ($this->previewOnOpen()) {
$this->formtype = 'preview';
} else {
$this->formtype = 'initial';
}
}
}
// If they used redlink=1 and the page exists, redirect to the main article
if ($wgRequest->getBool('redlink') && $this->mTitle->exists()) {
$wgOut->redirect($this->mTitle->getFullURL());
}
wfProfileIn(__METHOD__ . "-business-end");
$this->isConflict = false;
// css / js subpages of user pages get a special treatment
$this->isCssJsSubpage = $this->mTitle->isCssJsSubpage();
$this->isCssSubpage = $this->mTitle->isCssSubpage();
$this->isJsSubpage = $this->mTitle->isJsSubpage();
$this->isWrongCaseCssJsPage = $this->isWrongCaseCssJsPage();
$this->isNew = !$this->mTitle->exists() || $this->section == 'new';
# Show applicable editing introductions
if ($this->formtype == 'initial' || $this->firsttime) {
$this->showIntro();
}
if ($this->mTitle->isTalkPage()) {
$wgOut->addWikiMsg('talkpagetext');
}
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
$editnotice_ns_message = wfMessage($editnotice_ns)->inContentLanguage();
if ($editnotice_ns_message->exists()) {
$wgOut->addWikiText($editnotice_ns_message->plain());
}
if (MWNamespace::hasSubpages($this->mTitle->getNamespace())) {
$parts = explode('/', $this->mTitle->getDBkey());
$editnotice_base = $editnotice_ns;
while (count($parts) > 0) {
$editnotice_base .= '-' . array_shift($parts);
$editnotice_base_msg = wfMessage($editnotice_base)->inContentLanguage();
if ($editnotice_base_msg->exists()) {
$wgOut->addWikiText($editnotice_base_msg->plain());
//.........这里部分代码省略.........
示例9: newFromTitle
/**
* Given a page title, returns the Open Graph representation.
* @param Title $title
* @return OpenGraphObject|NULL
*/
public static function newFromTitle($title)
{
global $wgFbNamespace;
if ($title instanceof Title) {
// Talk pages redirect to subject pages
if ($title->isTalkPage()) {
// TODO: Parse subject page to extract <opengraph> attributes
$title = $title->getSubjectPage();
}
// Use built-in type "website" for main page
if ($title->equals(Title::newMainPage())) {
global $wgSitename, $wgContentLanguage;
return new OpenGraphArticleObject($title, array('og:type' => 'website', 'og:description' => $wgSitename . ' (' . $wgContentLanguage . ')'));
}
// File
if ($title->getNamespace() == NS_FILE) {
//$file = wfLocalFile( $title );
$file = wfFindFile($title);
if (!empty($file) && $file->exists()) {
return self::newFromFile($file);
}
return NULL;
}
// Blog articles are used by an extension on Wikia
if (defined('NS_BLOG_ARTICLE') && $title->getNamespace() == NS_BLOG_ARTICLE || defined('NS_BLOG_ARTICLE_TALK') && $title->getNamespace() == NS_BLOG_ARTICLE_TALK) {
global $wgServer, $wgUser;
// Use a custom image for blog posts
$image = $wgServer . '/index.php?action=ajax&rs=FacebookPushEvent::showImage&time=' . time() . '&fb_id=' . $wgUser->getId() . '&event=FBPush_OnAddBlogPost&img=blogpost.png';
$parameters = array('og:type' => $this->translateType('blog'), 'og:image' => $image);
return new OpenGraphArticleObject($title, $parameters);
}
// Don't consider NS_SPECIAL and NS_MEDIA to be articles
if ($title->canExist()) {
$parameters = FacebookOpenGraph::resolveTitle($title);
// Prepend Open Graph properties with 'og:' or the app namespace
foreach ($parameters as $name => $value) {
unset($parameters[$name]);
// Unset properties with no content
if (empty($value)) {
continue;
}
// Ignore parameters starting with fb:
if (substr($name, 0, 3) == 'fb:') {
continue;
}
// Prepent og: to built-in properties and namespace: to custom properties
if (in_array('og:' . $name, OpenGraphArticleObject::getBuiltinProperties())) {
$parameters['og:' . $name] = $value;
} else {
if (FacebookAPI::isNamespaceSetup()) {
$parameters[$wgFbNamespace . ':' . $name] = $value;
}
}
}
// Need to prepend the custom type with the namespace
if (isset($parameters['og:type']) && FacebookAPI::isNamespaceSetup()) {
$parameters['og:type'] = $wgFbNamespace . ':' . $parameters['og:type'];
}
return new OpenGraphArticleObject($title, $parameters);
}
}
return NULL;
}
示例10: onArticleDelete
/**
* Clears caches when article is deleted
*
* @param Title $title
*/
public static function onArticleDelete($title)
{
// Update existence markers on article/talk tabs...
if ($title->isTalkPage()) {
$other = $title->getSubjectPage();
} else {
$other = $title->getTalkPage();
}
$other->invalidateCache();
$other->purgeSquid();
$title->touchLinks();
$title->purgeSquid();
// File cache
HTMLFileCache::clearFileCache($title);
InfoAction::invalidateCache($title);
// Messages
if ($title->getNamespace() == NS_MEDIAWIKI) {
MessageCache::singleton()->replace($title->getDBkey(), false);
}
// Images
if ($title->getNamespace() == NS_FILE) {
$update = new HTMLCacheUpdate($title, 'imagelinks');
$update->doUpdate();
}
// User talk pages
if ($title->getNamespace() == NS_USER_TALK) {
$user = User::newFromName($title->getText(), false);
if ($user) {
$user->setNewtalk(false);
}
}
// Image redirects
RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect($title);
}
示例11: wfProfileIn
/**
* Process [[ ]] wikilinks (RIL)
* @return LinkHolderArray
*
* @private
*/
function replaceInternalLinks2(&$s)
{
wfProfileIn(__METHOD__);
# RTE (Rich Text Editor) - begin
# @author: Inez Korczyński
global $wgRTEParserEnabled;
# RTE (Rich Text Editor) - end
wfProfileIn(__METHOD__ . '-setup');
static $tc = FALSE, $e1, $e1_img;
# the % is needed to support urlencoded titles as well
if (!$tc) {
$tc = Title::legalChars() . '#%';
# Match a link having the form [[namespace:link|alternate]]trail
$e1 = "/^([{$tc}]+)(?:\\|(.+?))?]](.*)\$/sD";
# Match cases where there is no "]]", which might still be images
$e1_img = "/^([{$tc}]+)\\|(.*)\$/sD";
}
$holders = new LinkHolderArray($this);
# split the entire text string on occurences of [[
$a = StringUtils::explode('[[', ' ' . $s);
# get the first element (all text up to first [[), and remove the space we added
$s = $a->current();
$a->next();
$line = $a->current();
# Workaround for broken ArrayIterator::next() that returns "void"
$s = substr($s, 1);
$useLinkPrefixExtension = $this->getTargetLanguage()->linkPrefixExtension();
$e2 = null;
if ($useLinkPrefixExtension) {
# Match the end of a line for a word that's not followed by whitespace,
# e.g. in the case of 'The Arab al[[Razi]]', 'al' will be matched
$e2 = wfMsgForContent('linkprefix');
}
if (is_null($this->mTitle)) {
wfProfileOut(__METHOD__ . '-setup');
wfProfileOut(__METHOD__);
throw new MWException(__METHOD__ . ": \$this->mTitle is null\n");
}
$nottalk = !$this->mTitle->isTalkPage();
if ($useLinkPrefixExtension) {
$m = array();
if (preg_match($e2, $s, $m)) {
$first_prefix = $m[2];
} else {
$first_prefix = false;
}
} else {
$prefix = '';
}
if ($this->getConverterLanguage()->hasVariants()) {
$selflink = $this->getConverterLanguage()->autoConvertToAllVariants($this->mTitle->getPrefixedText());
} else {
$selflink = array($this->mTitle->getPrefixedText());
}
$useSubpages = $this->areSubpagesAllowed();
wfProfileOut(__METHOD__ . '-setup');
# Loop for each link
for (; $line !== false && $line !== null; $a->next(), $line = $a->current()) {
# Check for excessive memory usage
if ($holders->isBig()) {
# Too big
# Do the existence check, replace the link holders and clear the array
$holders->replace($s);
$holders->clear();
}
# RTE (Rich Text Editor) - begin
# @author: Inez Korczyński
if (!empty($wgRTEParserEnabled)) {
$RTE_wikitextIdx = RTEMarker::getDataIdx(RTEMarker::INTERNAL_WIKITEXT, $line);
// decode entities inside links wikimarkup (RT #38844)
if ($pos = strpos($line, ']]')) {
// unmark entities inside link
$link = substr($line, 0, $pos);
$link = RTEParser::unmarkEntities($link);
// leave the rest of the line untouched
$line = $link . substr($line, $pos);
}
}
# RTE - end
if ($useLinkPrefixExtension) {
wfProfileIn(__METHOD__ . '-prefixhandling');
if (preg_match($e2, $s, $m)) {
$prefix = $m[2];
$s = $m[1];
} else {
$prefix = '';
}
# first link
if ($first_prefix) {
$prefix = $first_prefix;
$first_prefix = false;
}
wfProfileOut(__METHOD__ . '-prefixhandling');
}
//.........这里部分代码省略.........