本文整理汇总了PHP中Title::getTalkPage方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getTalkPage方法的具体用法?PHP Title::getTalkPage怎么用?PHP Title::getTalkPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getTalkPage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Title $title Title object that this entry is for.
* @param String $pubDate Publish date formattable by wfTimestamp.
* @param Array $keywords list of (String) keywords
* @param Mixed Boolean or Integer. Namespace containing comments page for entry.
* True for the corresponding talk page of $title
* False for none
* An integer for the page name of $title in the specific namespace denoted by that integer.
*/
public function __construct($title, $pubDate, $keywords = '', $comment = true)
{
if (!$title || !$title instanceof Title) {
// Paranoia
throw new MWException('Invalid title object passed to FeedSMItem');
}
$commentsURL = '';
if ($comment === true) {
// The comment ns is this article's talk namespace.
$commentsURL = $title->getTalkPage()->getFullUrl();
} elseif (is_int($comment)) {
// There's a specific comments namespace.
$commentsTitle = Title::makeTitle($comment, $title->getDBkey());
if ($commentsTitle) {
$commentsURL = $commentsTitle->getFullUrl();
}
}
$this->keywords = $keywords;
$this->titleObj = $title;
parent::__construct($title->getText(), '', $title->getFullURL(), $pubDate, '', $commentsURL);
}
示例2: moveSubpages
/**
* Move this page's subpages to be subpages of $nt
*
* @param Title $nt Move target
* @param bool $auth Whether $wgUser's permissions should be checked
* @param string $reason The reason for the move
* @param bool $createRedirect Whether to create redirects from the old subpages to
* the new ones Ignored if the user doesn't have the 'suppressredirect' right
* @return array Array with old page titles as keys, and strings (new page titles) or
* arrays (errors) as values, or an error array with numeric indices if no pages
* were moved
*/
public function moveSubpages($nt, $auth = true, $reason = '', $createRedirect = true)
{
global $wgMaximumMovedPages;
// Check permissions
if (!$this->userCan('move-subpages')) {
return array('cant-move-subpages');
}
// Do the source and target namespaces support subpages?
if (!MWNamespace::hasSubpages($this->getNamespace())) {
return array('namespace-nosubpages', MWNamespace::getCanonicalName($this->getNamespace()));
}
if (!MWNamespace::hasSubpages($nt->getNamespace())) {
return array('namespace-nosubpages', MWNamespace::getCanonicalName($nt->getNamespace()));
}
$subpages = $this->getSubpages($wgMaximumMovedPages + 1);
$retval = array();
$count = 0;
foreach ($subpages as $oldSubpage) {
$count++;
if ($count > $wgMaximumMovedPages) {
$retval[$oldSubpage->getPrefixedText()] = array('movepage-max-pages', $wgMaximumMovedPages);
break;
}
// We don't know whether this function was called before
// or after moving the root page, so check both
// $this and $nt
if ($oldSubpage->getArticleID() == $this->getArticleID() || $oldSubpage->getArticleID() == $nt->getArticleID()) {
// When moving a page to a subpage of itself,
// don't move it twice
continue;
}
$newPageName = preg_replace('#^' . preg_quote($this->getDBkey(), '#') . '#', StringUtils::escapeRegexReplacement($nt->getDBkey()), $oldSubpage->getDBkey());
if ($oldSubpage->isTalkPage()) {
$newNs = $nt->getTalkPage()->getNamespace();
} else {
$newNs = $nt->getSubjectPage()->getNamespace();
}
# Bug 14385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
$newSubpage = Title::makeTitleSafe($newNs, $newPageName);
$success = $oldSubpage->moveTo($newSubpage, $auth, $reason, $createRedirect);
if ($success === true) {
$retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
} else {
$retval[$oldSubpage->getPrefixedText()] = $success;
}
}
return $retval;
}
示例3: getVariableValue
//.........这里部分代码省略.........
break;
case 'pagename':
$value = wfEscapeWikiText($this->mTitle->getText());
break;
case 'pagenamee':
$value = wfEscapeWikiText($this->mTitle->getPartialURL());
break;
case 'fullpagename':
$value = wfEscapeWikiText($this->mTitle->getPrefixedText());
break;
case 'fullpagenamee':
$value = wfEscapeWikiText($this->mTitle->getPrefixedURL());
break;
case 'subpagename':
$value = wfEscapeWikiText($this->mTitle->getSubpageText());
break;
case 'subpagenamee':
$value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm());
break;
case 'rootpagename':
$value = wfEscapeWikiText($this->mTitle->getRootText());
break;
case 'rootpagenamee':
$value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getRootText())));
break;
case 'basepagename':
$value = wfEscapeWikiText($this->mTitle->getBaseText());
break;
case 'basepagenamee':
$value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())));
break;
case 'talkpagename':
if ($this->mTitle->canTalk()) {
$talkPage = $this->mTitle->getTalkPage();
$value = wfEscapeWikiText($talkPage->getPrefixedText());
} else {
$value = '';
}
break;
case 'talkpagenamee':
if ($this->mTitle->canTalk()) {
$talkPage = $this->mTitle->getTalkPage();
$value = wfEscapeWikiText($talkPage->getPrefixedURL());
} else {
$value = '';
}
break;
case 'subjectpagename':
$subjPage = $this->mTitle->getSubjectPage();
$value = wfEscapeWikiText($subjPage->getPrefixedText());
break;
case 'subjectpagenamee':
$subjPage = $this->mTitle->getSubjectPage();
$value = wfEscapeWikiText($subjPage->getPrefixedURL());
break;
case 'pageid':
// requested in bug 23427
$pageid = $this->getTitle()->getArticleID();
if ($pageid == 0) {
# 0 means the page doesn't exist in the database,
# which means the user is previewing a new page.
# The vary-revision flag must be set, because the magic word
# will have a different value once the page is saved.
$this->mOutput->setFlag('vary-revision');
wfDebug(__METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n");
}
示例4: getVariableValue
//.........这里部分代码省略.........
break;
case 'localday':
$value = $wgContLang->formatNum($localDay);
break;
case 'localday2':
$value = $wgContLang->formatNum($localDay2);
break;
case 'pagename':
$value = wfEscapeWikiText($this->mTitle->getText());
break;
case 'pagenamee':
$value = wfEscapeWikiText($this->mTitle->getPartialURL());
break;
case 'fullpagename':
$value = wfEscapeWikiText($this->mTitle->getPrefixedText());
break;
case 'fullpagenamee':
$value = wfEscapeWikiText($this->mTitle->getPrefixedURL());
break;
case 'subpagename':
$value = wfEscapeWikiText($this->mTitle->getSubpageText());
break;
case 'subpagenamee':
$value = wfEscapeWikiText($this->mTitle->getSubpageUrlForm());
break;
case 'basepagename':
$value = wfEscapeWikiText($this->mTitle->getBaseText());
break;
case 'basepagenamee':
$value = wfEscapeWikiText(wfUrlEncode(str_replace(' ', '_', $this->mTitle->getBaseText())));
break;
case 'talkpagename':
if ($this->mTitle->canTalk()) {
$talkPage = $this->mTitle->getTalkPage();
$value = wfEscapeWikiText($talkPage->getPrefixedText());
} else {
$value = '';
}
break;
case 'talkpagenamee':
if ($this->mTitle->canTalk()) {
$talkPage = $this->mTitle->getTalkPage();
$value = wfEscapeWikiText($talkPage->getPrefixedUrl());
} else {
$value = '';
}
break;
case 'subjectpagename':
$subjPage = $this->mTitle->getSubjectPage();
$value = wfEscapeWikiText($subjPage->getPrefixedText());
break;
case 'subjectpagenamee':
$subjPage = $this->mTitle->getSubjectPage();
$value = wfEscapeWikiText($subjPage->getPrefixedUrl());
break;
case 'revisionid':
# Let the edit saving system know we should parse the page
# *after* a revision ID has been assigned.
$this->mOutput->setFlag('vary-revision');
wfDebug(__METHOD__ . ": {{REVISIONID}} used, setting vary-revision...\n");
$value = $this->mRevisionId;
break;
case 'revisionday':
# Let the edit saving system know we should parse the page
# *after* a revision ID has been assigned. This is for null edits.
$this->mOutput->setFlag('vary-revision');
示例5: 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');
}
}
示例6: 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';
//.........这里部分代码省略.........
示例7: duplicateEntries
/**
* Check if the given title already is watched by the user, and if so
* add watches on a new title. To be used for page renames and such.
*
* @param Title $ot Page title to duplicate entries from, if present
* @param Title $nt Page title to add watches on
*/
public static function duplicateEntries($ot, $nt)
{
WatchedItem::doDuplicateEntries($ot->getSubjectPage(), $nt->getSubjectPage());
WatchedItem::doDuplicateEntries($ot->getTalkPage(), $nt->getTalkPage());
}
示例8: 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);
}
示例9: duplicateEntries
/**
* Check if the given title already is watched by the user, and if so
* add watches on a new title. To be used for page renames and such.
*
* @param Title $ot Page title to duplicate entries from, if present
* @param Title $nt Page title to add watches on
* @static
*/
function duplicateEntries($ot, $nt, $summary = null)
{
//WERELATE - add optional $summary parameter
WatchedItem::doDuplicateEntries($ot->getSubjectPage(), $nt->getSubjectPage(), $summary);
WatchedItem::doDuplicateEntries($ot->getTalkPage(), $nt->getTalkPage());
}
示例10: createTalk
/**
*
* @param Title $related_title The title the talk is related to
* @param User $user
* @param string $content
* @return Title
*/
public static function createTalk($related_title, $user, $content = '-')
{
if (!$related_title instanceof Title || !$user instanceof User) {
throw new MWException('Cannot create talk page (wrong argument)');
}
if (!$related_title->canTalk()) {
return array('sz-internal-error');
}
$talk = $related_title->getTalkPage();
if (!$talk instanceof Title) {
return array('sz-internal-error');
}
if ($talk->isKnown()) {
return array('wp-title-already-exists');
}
// as seen in EditPage->getEditPermissionErrors() ( called by EditPage->edit() )
$permErrors = $talk->getUserPermissionsErrors('edit', $user);
$permErrors = array_merge($permErrors, wfArrayDiff2($talk->getUserPermissionsErrors('create', $user), $permErrors));
if ($permErrors) {
// creation impossible
return $permErrors[0];
// strange, but only key 0 seems to be used by MW when reading errors
}
// now store the new page in mediawiki, this will trigger the WikiplaceHook, wich will
// allow the page saving
$article = new Article($talk);
$status = $article->doEdit($content, '', EDIT_NEW, false, $user);
if (!$status->isgood()) {
return array('sz-internal-error');
}
return $talk;
}
示例11: removeWatch
/**
* Stop watching an article.
* @since 1.22 $checkRights parameter added
* @param Title $title Title of the article to look at
* @param bool $checkRights Whether to check 'viewmywatchlist'/'editmywatchlist' rights.
* Pass User::CHECK_USER_RIGHTS or User::IGNORE_USER_RIGHTS.
*/
public function removeWatch($title, $checkRights = self::CHECK_USER_RIGHTS)
{
if (!$checkRights || $this->isAllowed('editmywatchlist')) {
$store = MediaWikiServices::getInstance()->getWatchedItemStore();
$store->removeWatch($this, $title->getSubjectPage());
$store->removeWatch($this, $title->getTalkPage());
}
$this->invalidateCache();
}