本文整理汇总了PHP中Title::getPartialURL方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getPartialURL方法的具体用法?PHP Title::getPartialURL怎么用?PHP Title::getPartialURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getPartialURL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInexpensiveTitleData
/**
* Extract inexpensive information from a Title object for return to Lua
*
* @param $title Title Title to return
* @return array Lua data
*/
private function getInexpensiveTitleData(Title $title)
{
$ns = $title->getNamespace();
$ret = array('isLocal' => (bool) $title->isLocal(), 'interwiki' => $title->getInterwiki(), 'namespace' => $ns, 'nsText' => $title->getNsText(), 'text' => $title->getText(), 'fragment' => $title->getFragment(), 'thePartialUrl' => $title->getPartialURL());
if ($ns === NS_SPECIAL) {
// Core doesn't currently record special page links, but it may in the future.
if ($this->getParser() && !$title->equals($this->getTitle())) {
$this->getParser()->getOutput()->addLink($title);
}
$ret['exists'] = (bool) SpecialPageFactory::exists($title->getDBkey());
}
if ($ns !== NS_FILE && $ns !== NS_MEDIA) {
$ret['file'] = false;
}
return $ret;
}
示例2: getVariableValue
/**
* Return value of a magic variable (like PAGENAME)
*
* @private
*
* @param $index integer
* @param bool|\PPFrame $frame
*
* @throws MWException
* @return string
*/
function getVariableValue($index, $frame = false)
{
global $wgContLang, $wgSitename, $wgServer;
global $wgArticlePath, $wgScriptPath, $wgStylePath;
if (is_null($this->mTitle)) {
// If no title set, bad things are going to happen
// later. Title should always be set since this
// should only be called in the middle of a parse
// operation (but the unit-tests do funky stuff)
throw new MWException(__METHOD__ . ' Should only be ' . ' called while parsing (no title set)');
}
/**
* Some of these require message or data lookups and can be
* expensive to check many times.
*/
if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
if (isset($this->mVarCache[$index])) {
return $this->mVarCache[$index];
}
}
$ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
$pageLang = $this->getFunctionLang();
switch ($index) {
case 'currentmonth':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('m'));
break;
case 'currentmonth1':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('n'));
break;
case 'currentmonthname':
$value = $pageLang->getMonthName(MWTimestamp::getInstance($ts)->format('n'));
break;
case 'currentmonthnamegen':
$value = $pageLang->getMonthNameGen(MWTimestamp::getInstance($ts)->format('n'));
break;
case 'currentmonthabbrev':
$value = $pageLang->getMonthAbbreviation(MWTimestamp::getInstance($ts)->format('n'));
break;
case 'currentday':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('j'));
break;
case 'currentday2':
$value = $pageLang->formatNum(MWTimestamp::getInstance($ts)->format('d'));
break;
case 'localmonth':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('m'));
break;
case 'localmonth1':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('n'));
break;
case 'localmonthname':
$value = $pageLang->getMonthName(MWTimestamp::getLocalInstance($ts)->format('n'));
break;
case 'localmonthnamegen':
$value = $pageLang->getMonthNameGen(MWTimestamp::getLocalInstance($ts)->format('n'));
break;
case 'localmonthabbrev':
$value = $pageLang->getMonthAbbreviation(MWTimestamp::getLocalInstance($ts)->format('n'));
break;
case 'localday':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('j'));
break;
case 'localday2':
$value = $pageLang->formatNum(MWTimestamp::getLocalInstance($ts)->format('d'));
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())));
//.........这里部分代码省略.........
示例3: getUploadUrl
/**
* Get the URL to upload a certain file
*
* @param Title $destFile Title object of the file to upload
* @param string $query Urlencoded query string to prepend
* @return string Urlencoded URL
*/
protected static function getUploadUrl($destFile, $query = '')
{
global $wgUploadMissingFileUrl, $wgUploadNavigationUrl;
$q = 'wpDestFile=' . $destFile->getPartialURL();
if ($query != '') {
$q .= '&' . $query;
}
if ($wgUploadMissingFileUrl) {
return wfAppendQuery($wgUploadMissingFileUrl, $q);
} elseif ($wgUploadNavigationUrl) {
return wfAppendQuery($wgUploadNavigationUrl, $q);
} else {
$upload = SpecialPage::getTitleFor('Upload');
return $upload->getLocalURL($q);
}
}
示例4: getVariableValue
/**
* Return value of a magic variable (like PAGENAME)
*
* @private
*
* @param $index integer
* @param $frame PPFrame
*/
function getVariableValue($index, $frame = false)
{
global $wgContLang, $wgSitename, $wgServer;
global $wgArticlePath, $wgScriptPath, $wgStylePath;
/**
* Some of these require message or data lookups and can be
* expensive to check many times.
*/
if (wfRunHooks('ParserGetVariableValueVarCache', array(&$this, &$this->mVarCache))) {
if (isset($this->mVarCache[$index])) {
return $this->mVarCache[$index];
}
}
$ts = wfTimestamp(TS_UNIX, $this->mOptions->getTimestamp());
wfRunHooks('ParserGetVariableValueTs', array(&$this, &$ts));
# Use the time zone
global $wgLocaltimezone;
if (isset($wgLocaltimezone)) {
$oldtz = date_default_timezone_get();
date_default_timezone_set($wgLocaltimezone);
}
$localTimestamp = date('YmdHis', $ts);
$localMonth = date('m', $ts);
$localMonth1 = date('n', $ts);
$localMonthName = date('n', $ts);
$localDay = date('j', $ts);
$localDay2 = date('d', $ts);
$localDayOfWeek = date('w', $ts);
$localWeek = date('W', $ts);
$localYear = date('Y', $ts);
$localHour = date('H', $ts);
if (isset($wgLocaltimezone)) {
date_default_timezone_set($oldtz);
}
switch ($index) {
case 'currentmonth':
$value = $wgContLang->formatNum(gmdate('m', $ts));
break;
case 'currentmonth1':
$value = $wgContLang->formatNum(gmdate('n', $ts));
break;
case 'currentmonthname':
$value = $wgContLang->getMonthName(gmdate('n', $ts));
break;
case 'currentmonthnamegen':
$value = $wgContLang->getMonthNameGen(gmdate('n', $ts));
break;
case 'currentmonthabbrev':
$value = $wgContLang->getMonthAbbreviation(gmdate('n', $ts));
break;
case 'currentday':
$value = $wgContLang->formatNum(gmdate('j', $ts));
break;
case 'currentday2':
$value = $wgContLang->formatNum(gmdate('d', $ts));
break;
case 'localmonth':
$value = $wgContLang->formatNum($localMonth);
break;
case 'localmonth1':
$value = $wgContLang->formatNum($localMonth1);
break;
case 'localmonthname':
$value = $wgContLang->getMonthName($localMonthName);
break;
case 'localmonthnamegen':
$value = $wgContLang->getMonthNameGen($localMonthName);
break;
case 'localmonthabbrev':
$value = $wgContLang->getMonthAbbreviation($localMonthName);
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;
//.........这里部分代码省略.........
示例5: onTitleMoveComplete
/**
* @param Title $title
* @param Title $newtitle
* @param User $user
* @param $oldid
* @param $newid
* @return bool
*/
public static function onTitleMoveComplete(Title &$title, Title &$newtitle, User &$user, $oldid, $newid)
{
ArticlesApiController::purgeCache($newtitle->getArticleID());
ArticlesApiController::purgeMethods([['getAsJson', ['id' => $title->getArticleID()]], ['getAsJson', ['title' => $title->getPartialURL()]]]);
return true;
}
示例6: ArticleFromTitle
/**
* ArticleFromTitle
*
* hook handler for redirecting pages from old central to new community wiki
*
* @author Marooned
*/
static function ArticleFromTitle(Title &$title, &$article)
{
global $wgRequest, $wgCorporatePageRedirectWiki;
//do not redirect for action different than view (allow creating, deleting, etc)
if ($wgRequest->getVal('action', 'view') != 'view') {
return true;
}
wfProfileIn(__METHOD__);
switch ($title->getNamespace()) {
case NS_USER:
case NS_USER_TALK:
case NS_FILE_TALK:
case NS_HELP:
case NS_HELP_TALK:
case NS_CATEGORY_TALK:
case NS_FORUM:
case NS_FORUM_TALK:
case 150:
//NS_HUB
//NS_HUB
case 151:
//NS_HUB_TALK
//NS_HUB_TALK
case 400:
//NS_VIDEO
//NS_VIDEO
case 401:
//NS_VIDEO_TALK
//NS_VIDEO_TALK
case 500:
//NS_BLOG_ARTICLE
//NS_BLOG_ARTICLE
case 501:
//NS_BLOG_ARTICLE_TALK
//NS_BLOG_ARTICLE_TALK
case 502:
//NS_BLOG_LISTING
//NS_BLOG_LISTING
case 503:
//NS_BLOG_LISTING_TALK
//NS_BLOG_LISTING_TALK
case 1200:
// NS_WALL
if (!$title->exists() && !empty($wgCorporatePageRedirectWiki)) {
$redirect = $wgCorporatePageRedirectWiki . self::getPrefixedText($title->getPartialURL(), array($title->getInterwiki(), $title->getNsText()));
}
break;
case NS_FILE:
$file = wfFindFile($title);
if (empty($file) && !empty($wgCorporatePageRedirectWiki)) {
$redirect = $wgCorporatePageRedirectWiki . self::getPrefixedText($title->getPartialURL(), array($title->getInterwiki(), $title->getNsText()));
}
break;
case NS_PROJECT:
case NS_PROJECT_TALK:
if (!$title->exists()) {
//"Project" namespace hardcoded because MW will rename it to name of redirecting page - not the destination wiki
$redirect = 'http://community.wikia.com/wiki/Project:' . $title->getPartialURL();
}
break;
case NS_TALK:
$t = $title->getSubjectPage();
if ($t->exists()) {
$redirect = 'http://www.wikia.com/' . $t->getPartialURL();
}
break;
}
if (!wfRunHooks('CorporateBeforeRedirect', array(&$title))) {
wfProfileOut(__METHOD__);
return true;
}
if (!empty($redirect)) {
header("Location: {$redirect}");
wfProfileOut(__METHOD__);
exit;
}
wfProfileOut(__METHOD__);
return true;
}
示例7: onTitleGetSquidURLs
/**
* @desc Add Mercury Article API urls to the purge urls list
*
* @param Title $title
* @param array $urls
* @return bool
*/
public static function onTitleGetSquidURLs(Title $title, array &$urls)
{
global $wgServer;
if ($title->inNamespaces(NS_MAIN)) {
// Mercury API call from Ember.js to Hapi.js e.g.
// http://elderscrolls.wikia.com/api/v1/article/Morrowind
// To access it, you have to set your client to be directed to the Mercury machines.
$urls[] = $wgServer . self::SERVICE_API_BASE . self::SERVICE_API_ARTICLE . $title->getPartialURL();
// Mercury API call from Hapi.js to MediaWiki e.g.
// http://elderscrolls.wikia.com/wikia.php?controller=MercuryApi&method=getArticle&title=Morrowind
$urls[] = MercuryApiController::getUrl('getArticle', ['title' => $title->getPartialURL()]);
}
return true;
}