本文整理汇总了PHP中Title::isSpecial方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::isSpecial方法的具体用法?PHP Title::isSpecial怎么用?PHP Title::isSpecial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::isSpecial方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUserName
/**
* Get name of the user this page referrs to
*/
public static function getUserName(Title $title, $namespaces, $fallbackToGlobal = true)
{
wfProfileIn(__METHOD__);
global $wgUser, $wgRequest;
$userName = null;
if (in_array($title->getNamespace(), $namespaces)) {
// get "owner" of this user / user talk / blog page
$parts = explode('/', $title->getText());
} else {
if ($title->getNamespace() == NS_SPECIAL) {
if ($title->isSpecial('Following') || $title->isSpecial('Contributions')) {
$target = $wgRequest->getText('target');
if ($target != '') {
// /wiki/Special:Contributions?target=FooBar (RT #68323)
$parts = array($target);
} else {
// get user this special page referrs to
$parts = explode('/', $wgRequest->getText('title', false));
// remove special page name
array_shift($parts);
}
}
}
}
if (isset($parts[0]) && $parts[0] != '') {
//this line was usign urldecode($parts[0]) before, see RT #107278, user profile pages with '+' symbols get 'non-existing' message
$userName = str_replace('_', ' ', $parts[0]);
} elseif ($fallbackToGlobal) {
// fallback value
$userName = $wgUser->getName();
}
wfProfileOut(__METHOD__);
return $userName;
}
示例2: isInvalidLoginRedirect
/**
* @param Title|null $title
*
* @return bool
*/
public function isInvalidLoginRedirect($title)
{
return !$title instanceof Title || $title->isSpecial('Userlogout') || $title->isSpecial('Signup') || $title->isSpecial('Connect') || $title->isSpecial('FacebookConnect') || $title->isSpecial('UserLogin');
}
示例3: hookPersonalUrls
/**
* Replace the MediaWiki login/logout links with direct links to SimpleSamlPhp.
* This takes away the need to set up a redirect on the special UserLogin and UserLogout pages,
* and as a side effect makes redirects after login/logout more predictable.
*
* @link http://www.mediawiki.org/wiki/Manual:Hooks/PersonalUrls
*
* @param &$personal_urls array the array of URLs set up so far
* @param Title $title the Title object of the current article
*
* @return boolean|string true on success, false on silent error, string on verbose error
*/
public static function hookPersonalUrls(array &$personal_urls, Title $title)
{
if (!self::init()) {
return true;
}
global $wgSamlRequirement;
global $wgSamlPostLogoutRedirect;
global $wgRequest;
if ($wgSamlRequirement >= SAML_LOGIN_ONLY || self::$as->isAuthenticated()) {
if (isset($personal_urls['logout'])) {
if (isset($wgSamlPostLogoutRedirect)) {
$personal_urls['logout']['href'] = self::$as->getLogoutURL($wgSamlPostLogoutRedirect);
} elseif ($wgSamlRequirement >= SAML_REQUIRED) {
$personal_urls['logout']['href'] = self::$as->getLogoutURL(self::$as->getLoginURL(Title::newMainPage()->getFullUrl()));
} else {
$personal_urls['logout']['href'] = self::$as->getLogoutURL($personal_urls['logout']['href']);
}
}
if (!self::$as->isAuthenticated()) {
foreach (array('login', 'anonlogin') as $link) {
if (isset($personal_urls[$link])) {
if ($returnTo = $wgRequest->getVal('returnto') && ($page = Title::newFromText($returnTo))) {
$url = $page->getFullUrl();
$personal_urls[$link]['href'] = self::$as->getLoginURL($url);
} elseif ($title->isSpecial('Userlogout')) {
$personal_urls[$link]['href'] = self::$as->getLoginURL(Title::newMainPage()->getFullUrl());
} else {
$personal_urls[$link]['href'] = self::$as->getLoginURL();
}
}
}
}
}
return true;
}
示例4: isInvalidRedirectOnConnect
/**
* Check if we should redirect back to the specified page by comparing it to this black list
* @param Title|null $title
* @return bool
*/
private function isInvalidRedirectOnConnect(Title $title = null)
{
return !$title instanceof Title || $title->isSpecial('Userlogout') || $title->isSpecial('Signup') || $title->isSpecial('UserLogin');
}
示例5: DOMParse
/**
* @param $html string
* @return string
*/
public function DOMParse($html)
{
global $wgScript;
wfProfileIn(__METHOD__);
$html = mb_convert_encoding($html, 'HTML-ENTITIES', "UTF-8");
libxml_use_internal_errors(true);
$this->doc = new DOMDocument();
$this->doc->loadHTML('<?xml encoding="UTF-8">' . $html);
libxml_use_internal_errors(false);
$this->doc->preserveWhiteSpace = false;
$this->doc->strictErrorChecking = false;
$this->doc->encoding = 'UTF-8';
$itemToRemoveRecords = $this->parseItemsToRemove();
$zeroRatedBannerElement = $this->doc->getElementById('zero-rated-banner');
if (!$zeroRatedBannerElement) {
$zeroRatedBannerElement = $this->doc->getElementById('zero-rated-banner-red');
}
if ($zeroRatedBannerElement) {
self::$zeroRatedBanner = $this->doc->saveXML($zeroRatedBannerElement, LIBXML_NOEMPTYTAG);
}
if (self::$isBetaGroupMember) {
$ptLogout = $this->doc->getElementById('pt-logout');
if ($ptLogout) {
$ptLogoutLink = $ptLogout->firstChild;
self::$logoutHtml = $this->doc->saveXML($ptLogoutLink, LIBXML_NOEMPTYTAG);
}
$ptAnonLogin = $this->doc->getElementById('pt-anonlogin');
if (!$ptAnonLogin) {
$ptAnonLogin = $this->doc->getElementById('pt-login');
}
if ($ptAnonLogin) {
$ptAnonLoginLink = $ptAnonLogin->firstChild;
if ($ptAnonLoginLink && $ptAnonLoginLink->hasAttributes()) {
$ptAnonLoginLinkHref = $ptAnonLoginLink->getAttributeNode('href');
$ptAnonLoginLinkTitle = $ptAnonLoginLink->getAttributeNode('title');
if ($ptAnonLoginLinkTitle) {
$ptAnonLoginLinkTitle->nodeValue = self::$messages['mobile-frontend-login'];
}
if ($ptAnonLoginLinkHref) {
$ptAnonLoginLinkHref->nodeValue = str_replace("&", "&", $ptAnonLoginLinkHref->nodeValue);
}
$ptAnonLoginLinkText = $ptAnonLoginLink->firstChild;
if ($ptAnonLoginLinkText) {
$ptAnonLoginLinkText->nodeValue = self::$messages['mobile-frontend-login'];
}
}
self::$loginHtml = $this->doc->saveXML($ptAnonLoginLink, LIBXML_NOEMPTYTAG);
}
}
if (self::$title->isSpecial('Userlogin') && self::$isBetaGroupMember) {
$userlogin = $this->doc->getElementById('userloginForm');
if ($userlogin && get_class($userlogin) === 'DOMElement') {
$firstHeading = $this->doc->getElementById('firstHeading');
if ($firstHeading) {
$firstHeading->nodeValue = '';
}
}
}
// Tags
// You can't remove DOMNodes from a DOMNodeList as you're iterating
// over them in a foreach loop. It will seemingly leave the internal
// iterator on the foreach out of wack and results will be quite
// strange. Though, making a queue of items to remove seems to work.
// For example:
if (self::$disableImages == 1) {
$itemToRemoveRecords['TAG'][] = "img";
$itemToRemoveRecords['TAG'][] = "audio";
$itemToRemoveRecords['TAG'][] = "video";
$itemToRemoveRecords['CLASS'][] = "thumb tright";
$itemToRemoveRecords['CLASS'][] = "thumb tleft";
$itemToRemoveRecords['CLASS'][] = "thumbcaption";
$itemToRemoveRecords['CLASS'][] = "gallery";
}
$tagToRemoveNodeIdAttributeValues = array('zero-language-search');
$domElemsToRemove = array();
foreach ($itemToRemoveRecords['TAG'] as $tagToRemove) {
$tagToRemoveNodes = $this->doc->getElementsByTagName($tagToRemove);
foreach ($tagToRemoveNodes as $tagToRemoveNode) {
$tagToRemoveNodeIdAttributeValue = '';
if ($tagToRemoveNode) {
$tagToRemoveNodeIdAttribute = $tagToRemoveNode->getAttributeNode('id');
if ($tagToRemoveNodeIdAttribute) {
$tagToRemoveNodeIdAttributeValue = $tagToRemoveNodeIdAttribute->value;
}
if (!in_array($tagToRemoveNodeIdAttributeValue, $tagToRemoveNodeIdAttributeValues)) {
$domElemsToRemove[] = $tagToRemoveNode;
}
}
}
}
foreach ($domElemsToRemove as $domElement) {
$domElement->parentNode->removeChild($domElement);
}
// Elements with named IDs
foreach ($itemToRemoveRecords['ID'] as $itemToRemove) {
$itemToRemoveNode = $this->doc->getElementById($itemToRemove);
//.........这里部分代码省略.........
示例6: onTestCanonicalRedirect
/**
* This hook is called when about to force a redirect to a canonical URL
* for a title when we have no other parameters on the URL.
*
* Return false when we want to prevent the redirect to the canonical URL
* for Our404Handler special page
*
* @see PLATFORM-811
*
* @param WebRequest $request
* @param Title $title
* @param OutputPage $output
* @return bool
*/
public static function onTestCanonicalRedirect(WebRequest $request, Title $title, OutputPage $output)
{
if ($title->isSpecial(self::NAME)) {
return false;
}
return true;
}
示例7: isIgnoredPage
function isIgnoredPage(Title $title)
{
global $wgGoogleUniversalAnalyticsIgnoreNsIDs, $wgGoogleUniversalAnalyticsIgnorePages, $wgGoogleUniversalAnalyticsIgnoreSpecials;
$ignoreSpecials = count(array_filter($wgGoogleUniversalAnalyticsIgnoreSpecials, function ($v) use($title) {
return $title->isSpecial($v);
})) > 0;
return $ignoreSpecials || in_array($title->getNamespace(), $wgGoogleUniversalAnalyticsIgnoreNsIDs, true) || in_array($title->getPrefixedText(), $wgGoogleUniversalAnalyticsIgnorePages, true);
}
开发者ID:kolzchut,项目名称:mediawiki-extensions-GoogleUniversalAnalytics,代码行数:8,代码来源:GoogleUniversalAnalytics.hooks.php
示例8: isSpecialGoogleSearch
static function isSpecialGoogleSearch(Title $title)
{
return $title->isSpecial('WRGoogleSearch');
}