本文整理汇总了PHP中SpecialPage::resolveAliasWithSubpage方法的典型用法代码示例。如果您正苦于以下问题:PHP SpecialPage::resolveAliasWithSubpage方法的具体用法?PHP SpecialPage::resolveAliasWithSubpage怎么用?PHP SpecialPage::resolveAliasWithSubpage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpecialPage
的用法示例。
在下文中一共展示了SpecialPage::resolveAliasWithSubpage方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: efSkinPerPageBeforePageDisplayHook
/**
* Hook function for BeforePageDisplay
*/
function efSkinPerPageBeforePageDisplayHook( &$out, &$skin ){
global $wgSkinPerNamespace, $wgSkinPerSpecialPage,
$wgSkinPerNamespaceOverrideLoggedIn, $wgUser;
if( !$wgSkinPerNamespaceOverrideLoggedIn && $wgUser->isLoggedIn() )
return true;
$title = $out->getTitle();
$ns = $title->getNamespace();
$skinName = null;
if( $ns == NS_SPECIAL ) {
list( $canonical, /* $subpage */ ) = SpecialPage::resolveAliasWithSubpage( $title->getDBkey() );
if( isset( $wgSkinPerSpecialPage[$canonical] ) ) {
$skinName = $wgSkinPerSpecialPage[$canonical];
}
}
if( $skinName === null && isset( $wgSkinPerNamespace[$ns] ) ) {
$skinName = $wgSkinPerNamespace[$ns];
}
if( $skinName !== null ) {
$skin = Skin::newFromKey( $skinName );
$skin->setTitle( $out->getTitle() );
}
return true;
}
示例2: handleSpecialCases
/**
* Initialize some special cases:
* - bad titles
* - local interwiki redirects
* - redirect loop
* - special pages
*
* @param $title Title
* @param $output OutputPage
* @param $request WebRequest
* @return bool true if the request is already executed
*/
function handleSpecialCases(&$title, &$output, $request)
{
wfProfileIn(__METHOD__);
$action = $this->getVal('Action');
// Invalid titles. Bug 21776: The interwikis must redirect even if the page name is empty.
if (is_null($title) || $title->getDBkey() == '' && $title->getInterwiki() == '') {
$title = SpecialPage::getTitleFor('Badtitle');
$output->setTitle($title);
// bug 21456
// Die now before we mess up $wgArticle and the skin stops working
throw new ErrorPageError('badtitle', 'badtitletext');
// Interwiki redirects
} else {
if ($title->getInterwiki() != '') {
$rdfrom = $request->getVal('rdfrom');
if ($rdfrom) {
$url = $title->getFullURL('rdfrom=' . urlencode($rdfrom));
} else {
$query = $request->getValues();
unset($query['title']);
$url = $title->getFullURL($query);
}
/* Check for a redirect loop */
if (!preg_match('/^' . preg_quote($this->getVal('Server'), '/') . '/', $url) && $title->isLocal()) {
// 301 so google et al report the target as the actual url.
$output->redirect($url, 301);
} else {
$title = SpecialPage::getTitleFor('Badtitle');
$output->setTitle($title);
// bug 21456
wfProfileOut(__METHOD__);
throw new ErrorPageError('badtitle', 'badtitletext');
}
// Redirect loops, no title in URL, $wgUsePathInfo URLs, and URLs with a variant
} else {
if ($action == 'view' && !$request->wasPosted() && ($request->getVal('title') === null || $title->getPrefixedDBKey() != $request->getVal('title')) && !count(array_diff(array_keys($request->getValues()), array('action', 'title')))) {
if ($title->getNamespace() == NS_SPECIAL) {
list($name, $subpage) = SpecialPage::resolveAliasWithSubpage($title->getDBkey());
if ($name) {
$title = SpecialPage::getTitleFor($name, $subpage);
}
}
$targetUrl = $title->getFullURL();
// Redirect to canonical url, make it a 301 to allow caching
if ($targetUrl == $request->getFullRequestURL()) {
$message = "Redirect loop detected!\n\n" . "This means the wiki got confused about what page was " . "requested; this sometimes happens when moving a wiki " . "to a new server or changing the server configuration.\n\n";
if ($this->getVal('UsePathInfo')) {
$message .= "The wiki is trying to interpret the page " . "title from the URL path portion (PATH_INFO), which " . "sometimes fails depending on the web server. Try " . "setting \"\$wgUsePathInfo = false;\" in your " . "LocalSettings.php, or check that \$wgArticlePath " . "is correct.";
} else {
$message .= "Your web server was detected as possibly not " . "supporting URL path components (PATH_INFO) correctly; " . "check your LocalSettings.php for a customized " . "\$wgArticlePath setting and/or toggle \$wgUsePathInfo " . "to true.";
}
wfHttpError(500, "Internal error", $message);
wfProfileOut(__METHOD__);
return false;
} else {
$output->setSquidMaxage(1200);
$output->redirect($targetUrl, '301');
}
// Special pages
} else {
if (NS_SPECIAL == $title->getNamespace()) {
/* actions that need to be made when we have a special pages */
SpecialPage::executePath($title);
} else {
/* No match to special cases */
wfProfileOut(__METHOD__);
return false;
}
}
}
}
/* Did match a special case */
wfProfileOut(__METHOD__);
return true;
}
示例3: isSpecial
/**
* Returns true if this title resolves to the named special page
* @param string $name The special page name
*/
public function isSpecial($name)
{
if ($this->getNamespace() == NS_SPECIAL) {
list($thisName, ) = SpecialPage::resolveAliasWithSubpage($this->getDBkey());
if ($name == $thisName) {
return true;
}
}
return false;
}
示例4: recentChangesLine
/**
* Format a line for enhanced recentchange (aka with javascript and block of lines).
*/
public function recentChangesLine(&$baseRC, $watched = false)
{
global $wgLang, $wgContLang, $wgUser;
wfProfileIn(__METHOD__);
# Create a specialised object
$rc = RCCacheEntry::newFromParent($baseRC);
# Extract fields from DB into the function scope (rc_xxxx variables)
// FIXME: Would be good to replace this extract() call with something
// that explicitly initializes variables.
extract($rc->mAttribs);
$curIdEq = 'curid=' . $rc_cur_id;
# If it's a new day, add the headline and flush the cache
$date = $wgLang->date($rc_timestamp, true);
$ret = '';
if ($date != $this->lastdate) {
# Process current cache
$ret = $this->recentChangesBlock();
$this->rc_cache = array();
$ret .= "<h4>{$date}</h4>\n";
$this->lastdate = $date;
}
# Should patrol-related stuff be shown?
if ($wgUser->useRCPatrol()) {
$rc->unpatrolled = !$rc_patrolled;
} else {
$rc->unpatrolled = false;
}
$showdifflinks = true;
# Make article link
// Page moves
if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
$msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir";
$clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), ''));
// New unpatrolled pages
} else {
if ($rc->unpatrolled && $rc_type == RC_NEW) {
$clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}");
// Log entries
} else {
if ($rc_type == RC_LOG) {
if ($rc_log_type) {
$logtitle = SpecialPage::getTitleFor('Log', $rc_log_type);
$clink = '(' . $this->skin->makeKnownLinkObj($logtitle, LogPage::logName($rc_log_type)) . ')';
} else {
$clink = $this->skin->makeLinkObj($rc->getTitle(), '');
}
$watched = false;
// Log entries (old format) and special pages
} elseif ($rc_namespace == NS_SPECIAL) {
list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($rc_title);
if ($specialName == 'Log') {
# Log updates, etc
$logname = LogPage::logName($logtype);
$clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')';
} else {
wfDebug("Unexpected special page in recentchanges\n");
$clink = '';
}
// Edits
} else {
$clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '');
}
}
}
# Don't show unusable diff links
if (!ChangesList::userCan($rc, Revision::DELETED_TEXT)) {
$showdifflinks = false;
}
$time = $wgContLang->time($rc_timestamp, true, true);
$rc->watched = $watched;
$rc->link = $clink;
$rc->timestamp = $time;
$rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
# Make "cur" and "diff" links
if ($rc->unpatrolled) {
$rcIdQuery = "&rcid={$rc_id}";
} else {
$rcIdQuery = '';
}
$querycur = $curIdEq . "&diff=0&oldid={$rc_this_oldid}";
$querydiff = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcIdQuery}";
$aprops = ' tabindex="' . $baseRC->counter . '"';
$curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['cur'], $querycur, '', '', $aprops);
# Make "diff" an "cur" links
if (!$showdifflinks) {
$curLink = $this->message['cur'];
$diffLink = $this->message['diff'];
} else {
if (in_array($rc_type, array(RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
$curLink = $rc_type != RC_NEW ? $this->message['cur'] : $curLink;
$diffLink = $this->message['diff'];
} else {
$diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['diff'], $querydiff, '', '', $aprops);
}
}
# Make "last" link
if (!$showdifflinks || !$rc_last_oldid) {
//.........这里部分代码省略.........
示例5: recentChangesLine
/**
* Format a line for enhanced recentchange (aka with javascript and block of lines).
*/
function recentChangesLine(&$baseRC, $watched = false)
{
global $wgLang, $wgContLang;
# Create a specialised object
$rc = RCCacheEntry::newFromParent($baseRC);
# Extract fields from DB into the function scope (rc_xxxx variables)
// FIXME: Would be good to replace this extract() call with something that explicitly initializes local variables.
extract($rc->mAttribs);
$curIdEq = 'curid=' . $rc_cur_id;
# If it's a new day, add the headline and flush the cache
$date = $wgLang->date($rc_timestamp, true);
$ret = '';
if ($date != $this->lastdate) {
# Process current cache
$ret = $this->recentChangesBlock();
$this->rc_cache = array();
$ret .= "<h4>{$date}</h4>\n";
$this->lastdate = $date;
}
// BizzWiki begin {{
$ns = $rc->getTitle()->getNamespace();
# Should patrol-related stuff be shown?
if ($this->usePatrol($ns)) {
$rc->unpatrolled = !$rc_patrolled;
} else {
$rc->unpatrolled = false;
}
// BizzWiki end }}
# Make article link
if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
$msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir";
$clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), ''));
} elseif ($rc_namespace == NS_SPECIAL) {
list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($rc_title);
if ($specialName == 'Log') {
# Log updates, etc
$logname = LogPage::logName($logtype);
$clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')';
} else {
wfDebug("Unexpected special page in recentchanges\n");
$clink = '';
}
} elseif ($rc->unpatrolled && $rc_type == RC_NEW) {
# Unpatrolled new page, give rc_id in query
$clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}");
} else {
$clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '');
}
$time = $wgContLang->time($rc_timestamp, true, true);
$rc->watched = $watched;
$rc->link = $clink;
$rc->timestamp = $time;
$rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
# Make "cur" and "diff" links
if ($rc->unpatrolled) {
$rcIdQuery = "&rcid={$rc_id}";
} else {
$rcIdQuery = '';
}
$querycur = $curIdEq . "&diff=0&oldid={$rc_this_oldid}";
$querydiff = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcIdQuery}";
$aprops = ' tabindex="' . $baseRC->counter . '"';
$curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['cur'], $querycur, '', '', $aprops);
if ($rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
if ($rc_type != RC_NEW) {
$curLink = $this->message['cur'];
}
$diffLink = $this->message['diff'];
} else {
$diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['diff'], $querydiff, '', '', $aprops);
}
# Make "last" link
if ($rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
$lastLink = $this->message['last'];
} else {
$lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery);
}
$rc->userlink = $this->skin->userLink($rc_user, $rc_user_text);
$rc->lastlink = $lastLink;
$rc->curlink = $curLink;
$rc->difflink = $diffLink;
$rc->usertalklink = $this->skin->userToolLinks($rc_user, $rc_user_text);
# Put accumulated information into the cache, for later display
# Page moves go on their own line
$title = $rc->getTitle();
$secureName = $title->getPrefixedDBkey();
if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
# Use an @ character to prevent collision with page names
$this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
} else {
if (!isset($this->rc_cache[$secureName])) {
$this->rc_cache[$secureName] = array();
}
array_push($this->rc_cache[$secureName], $rc);
}
return $ret;
}
示例6: getTitleLink
protected static function getTitleLink($type, $skin, $title, &$params)
{
global $wgLang, $wgContLang;
if (!$skin) {
return $title->getPrefixedText();
}
switch ($type) {
case 'move':
$titleLink = $skin->makeLinkObj($title, htmlspecialchars($title->getPrefixedText()), 'redirect=no');
$targetTitle = Title::newFromText($params[0]);
if (!$targetTitle) {
# Workaround for broken database
$params[0] = htmlspecialchars($params[0]);
} else {
$params[0] = $skin->makeLinkObj($targetTitle, htmlspecialchars($params[0]));
}
break;
case 'block':
if (substr($title->getText(), 0, 1) == '#') {
$titleLink = $title->getText();
} else {
// TODO: Store the user identifier in the parameters
// to make this faster for future log entries
$id = User::idFromName($title->getText());
$titleLink = $skin->userLink($id, $title->getText()) . $skin->userToolLinks($id, $title->getText(), false, Linker::TOOL_LINKS_NOBLOCK);
}
break;
case 'rights':
$text = $wgContLang->ucfirst($title->getText());
$titleLink = $skin->makeLinkObj(Title::makeTitle(NS_USER, $text));
break;
case 'merge':
$titleLink = $skin->makeLinkObj($title, $title->getPrefixedText(), 'redirect=no');
$params[0] = $skin->makeLinkObj(Title::newFromText($params[0]), htmlspecialchars($params[0]));
$params[1] = $wgLang->timeanddate($params[1]);
break;
default:
if ($title->getNamespace() == NS_SPECIAL) {
list($name, $par) = SpecialPage::resolveAliasWithSubpage($title->getDBKey());
# Use the language name for log titles, rather than Log/X
if ($name == 'Log') {
$titleLink = '(' . $skin->makeLinkObj($title, LogPage::logName($par)) . ')';
} else {
$titleLink = $skin->makeLinkObj($title);
}
} else {
$titleLink = $skin->makeLinkObj($title);
}
}
return $titleLink;
}
示例7: getLinksFromRow
/**
* @param $row
* @create diff/hist/page link
*/
protected function getLinksFromRow($row)
{
// Log items (old format) and events to logs
if ($row->cuc_type == RC_LOG && $row->cuc_namespace == NS_SPECIAL) {
list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($row->cuc_title);
$logname = LogPage::logName($logtype);
$title = Title::makeTitle($row->cuc_namespace, $row->cuc_title);
$links = '(' . $this->sk->makeKnownLinkObj($title, $logname) . ')';
// Log items (newer format)
} elseif ($row->cuc_type == RC_LOG) {
$title = Title::makeTitle($row->cuc_namespace, $row->cuc_title);
$links = '(' . $this->sk->makeKnownLinkObj(SpecialPage::getTitleFor('Log'), $this->message['log'], wfArrayToCGI(array('page' => $title->getPrefixedText()))) . ')';
} else {
$title = Title::makeTitle($row->cuc_namespace, $row->cuc_title);
# New pages
if ($row->cuc_type == RC_NEW) {
$links = '(' . $this->message['diff'] . ') ';
} else {
# Diff link
$links = ' (' . $this->sk->makeKnownLinkObj($title, $this->message['diff'], wfArrayToCGI(array('curid' => $row->cuc_page_id, 'diff' => $row->cuc_this_oldid, 'oldid' => $row->cuc_last_oldid))) . ') ';
}
# History link
$links .= ' (' . $this->sk->makeKnownLinkObj($title, $this->message['hist'], wfArrayToCGI(array('curid' => $row->cuc_page_id, 'action' => 'history'))) . ') . . ';
# Some basic flags
if ($row->cuc_type == RC_NEW) {
$links .= '<span class="newpage">' . $this->message['newpageletter'] . '</span>';
}
if ($row->cuc_minor) {
$links .= '<span class="minor">' . $this->message['minoreditletter'] . '</span>';
}
# Page link
$links .= ' ' . $this->sk->makeLinkObj($title);
}
return $links;
}
示例8: normaliseSpecialPage
function normaliseSpecialPage(Title $title)
{
if ($title->getNamespace() == NS_SPECIAL) {
list($name, $subpage) = SpecialPage::resolveAliasWithSubpage($title->getDBkey());
if (!$name) {
return $title;
}
$ret = SpecialPage::getTitleFor($name, $subpage);
$ret->mFragment = $title->getFragment();
return $ret;
} else {
return $title;
}
}
示例9: buildPersonalUrls
/**
* build array of urls for personal toolbar
* @return array
* @private
*/
function buildPersonalUrls()
{
global $wgTitle, $wgRequest;
$pageurl = $wgTitle->getLocalURL();
wfProfileIn(__METHOD__);
/* set up the default links for the personal toolbar */
$personal_urls = array();
if ($this->loggedin) {
$personal_urls['userpage'] = array('text' => $this->username, 'href' => &$this->userpageUrlDetails['href'], 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', 'active' => $this->userpageUrlDetails['href'] == $pageurl);
$usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
$personal_urls['mytalk'] = array('text' => wfMsg('mytalk'), 'href' => &$usertalkUrlDetails['href'], 'class' => $usertalkUrlDetails['exists'] ? false : 'new', 'active' => $usertalkUrlDetails['href'] == $pageurl);
$href = self::makeSpecialUrl('Preferences');
$personal_urls['preferences'] = array('text' => wfMsg('mypreferences'), 'href' => $href, 'active' => $href == $pageurl);
$href = self::makeSpecialUrl('Watchlist');
$personal_urls['watchlist'] = array('text' => wfMsg('mywatchlist'), 'href' => $href, 'active' => $href == $pageurl);
# We need to do an explicit check for Special:Contributions, as we
# have to match both the title, and the target (which could come
# from request values or be specified in "sub page" form. The plot
# thickens, because $wgTitle is altered for special pages, so doesn't
# contain the original alias-with-subpage.
$title = Title::newFromText($wgRequest->getText('title'));
if ($title instanceof Title && $title->getNamespace() == NS_SPECIAL) {
list($spName, $spPar) = SpecialPage::resolveAliasWithSubpage($title->getText());
$active = $spName == 'Contributions' && ($spPar && $spPar == $this->username || $wgRequest->getText('target') == $this->username);
} else {
$active = false;
}
$href = self::makeSpecialUrlSubpage('Contributions', $this->username);
$personal_urls['mycontris'] = array('text' => wfMsg('mycontris'), 'href' => $href, 'active' => $active);
$personal_urls['logout'] = array('text' => wfMsg('userlogout'), 'href' => self::makeSpecialUrl('Userlogout', $wgTitle->isSpecial('Preferences') ? '' : "returnto={$this->thisurl}"), 'active' => false);
} else {
global $wgUser;
$loginlink = $wgUser->isAllowed('createaccount') ? 'nav-login-createaccount' : 'login';
if ($this->showIPinHeader()) {
$href =& $this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array('text' => $this->username, 'href' => $href, 'class' => $this->userpageUrlDetails['exists'] ? false : 'new', 'active' => $pageurl == $href);
$usertalkUrlDetails = $this->makeTalkUrlDetails($this->userpage);
$href =& $usertalkUrlDetails['href'];
$personal_urls['anontalk'] = array('text' => wfMsg('anontalk'), 'href' => $href, 'class' => $usertalkUrlDetails['exists'] ? false : 'new', 'active' => $pageurl == $href);
$personal_urls['anonlogin'] = array('text' => wfMsg($loginlink), 'href' => self::makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl), 'active' => $wgTitle->isSpecial('Userlogin'));
} else {
$personal_urls['login'] = array('text' => wfMsg($loginlink), 'href' => self::makeSpecialUrl('Userlogin', 'returnto=' . $this->thisurl), 'active' => $wgTitle->isSpecial('Userlogin'));
}
}
wfRunHooks('PersonalUrls', array(&$personal_urls, &$wgTitle));
wfProfileOut(__METHOD__);
return $personal_urls;
}
示例10: special
static function special($parser, $text)
{
list($page, $subpage) = SpecialPage::resolveAliasWithSubpage($text);
if ($page) {
$title = SpecialPage::getTitleFor($page, $subpage);
return $title;
} else {
return wfMsgForContent('nosuchspecialpage');
}
}
示例11: linkfix
/**
* Make Special:MyLanguage links red if the target page doesn't exists.
* A bit hacky because the core code is not so flexible.
* @param $dummy
* @param $target Title
* @param $html
* @param $customAttribs
* @param $query
* @param $options
* @param $ret
* @return bool
*/
public static function linkfix( $dummy, $target, &$html, &$customAttribs, &$query, &$options, &$ret ) {
if ( $target->getNamespace() == NS_SPECIAL ) {
list( $name, $subpage ) = SpecialPage::resolveAliasWithSubpage( $target->getDBkey() );
if ( $name === 'MyLanguage' ) {
$realTarget = Title::newFromText( $subpage );
if ( !$realTarget || !$realTarget->exists() ) {
$options[] = 'broken';
$index = array_search( 'known', $options, true );
if ( $index !== false ) unset( $options[$index] );
$index = array_search( 'noclasses', $options, true );
if ( $index !== false ) unset( $options[$index] );
}
}
}
return true;
}