本文整理汇总了PHP中MWNamespace::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::exists方法的具体用法?PHP MWNamespace::exists怎么用?PHP MWNamespace::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param int $ns The namespace to use for all pages
*/
public function __construct($ns)
{
if (!MWNamespace::exists($ns)) {
throw new MWException("Namespace {$ns} doesn't exist on this wiki");
}
$this->ns = $ns;
}
示例2: checkNamespace
private function checkNamespace($name, $argIdx, &$arg, $default = null)
{
global $wgContLang;
if ($arg === null && $default !== null) {
$arg = $default;
} elseif (is_numeric($arg)) {
$arg = (int) $arg;
if (!MWNamespace::exists($arg)) {
throw new Scribunto_LuaError("bad argument #{$argIdx} to '{$name}' (unrecognized namespace number '{$arg}')");
}
} elseif (is_string($arg)) {
$ns = $wgContLang->getNsIndex($arg);
if ($ns === false) {
throw new Scribunto_LuaError("bad argument #{$argIdx} to '{$name}' (unrecognized namespace name '{$arg}')");
}
$arg = $ns;
} else {
$this->checkType($name, $argIdx, $arg, 'namespace number or name');
}
}
示例3: createTitleFromForeignTitle
/**
* Determines which local title best corresponds to the given foreign title.
* If such a title can't be found or would be locally invalid, null is
* returned.
*
* @param ForeignTitle $foreignTitle The ForeignTitle to convert
* @return Title|null
*/
public function createTitleFromForeignTitle(ForeignTitle $foreignTitle)
{
global $wgContLang;
if ($foreignTitle->isNamespaceIdKnown()) {
$foreignNs = $foreignTitle->getNamespaceId();
// For built-in namespaces (0 <= ID < 100), we try to find a local NS with
// the same namespace ID
if ($foreignNs < 100 && MWNamespace::exists($foreignNs)) {
return Title::makeTitleSafe($foreignNs, $foreignTitle->getText());
}
}
// Do we have a local namespace by the same name as the foreign
// namespace?
$targetNs = $wgContLang->getNsIndex($foreignTitle->getNamespaceName());
if ($targetNs !== false) {
return Title::makeTitleSafe($targetNs, $foreignTitle->getText());
}
// Otherwise, just fall back to main namespace
return Title::makeTitleSafe(0, $foreignTitle->getFullText());
}
示例4: execute
public function execute()
{
global $wgTranslateMessageNamespaces;
$namespace = $this->getOption('namespace', $wgTranslateMessageNamespaces);
if (is_string($namespace)) {
if (!MWNamespace::exists($namespace)) {
$namespace = MWNamespace::getCanonicalIndex($namespace);
if ($namespace === null) {
$this->error('Bad namespace', true);
}
}
}
$db = wfGetDB(DB_MASTER);
$tables = array('page', 'text', 'revision');
$fields = array('page_id', 'page_title', 'page_namespace', 'rev_id', 'old_text', 'old_flags');
$conds = array('page_latest = rev_id', 'old_id = rev_text_id', 'page_namespace' => $namespace);
$limit = 100;
$offset = 0;
while (true) {
$inserts = array();
$this->output('.', 0);
$options = array('LIMIT' => $limit, 'OFFSET' => $offset);
$res = $db->select($tables, $fields, $conds, __METHOD__, $options);
if (!$res->numRows()) {
break;
}
foreach ($res as $r) {
$text = Revision::getRevisionText($r);
if (strpos($text, TRANSLATE_FUZZY) !== false) {
$inserts[] = array('rt_page' => $r->page_id, 'rt_revision' => $r->rev_id, 'rt_type' => RevTag::getType('fuzzy'));
}
}
$offset += $limit;
$db->replace('revtag', 'rt_type_page_revision', $inserts, __METHOD__);
}
}
示例5: setTargetNamespace
/**
* Set a target namespace to override the defaults
* @param null|int $namespace
* @return bool
*/
public function setTargetNamespace($namespace)
{
if (is_null($namespace)) {
// Don't override namespaces
$this->mTargetNamespace = null;
$this->setImportTitleFactory(new NaiveImportTitleFactory());
return true;
} elseif ($namespace >= 0 && MWNamespace::exists(intval($namespace))) {
$namespace = intval($namespace);
$this->mTargetNamespace = $namespace;
$this->setImportTitleFactory(new NamespaceImportTitleFactory($namespace));
return true;
} else {
return false;
}
}
示例6: moveInconsistentPage
/**
* @param object $row
* @param Title $title
*/
protected function moveInconsistentPage($row, $title)
{
if ($title->exists() || $title->getInterwiki() || !$title->canExist()) {
if ($title->getInterwiki() || !$title->canExist()) {
$prior = $title->getPrefixedDBkey();
} else {
$prior = $title->getDBkey();
}
# Old cleanupTitles could move articles there. See bug 23147.
$ns = $row->page_namespace;
if ($ns < 0) {
$ns = 0;
}
# Namespace which no longer exists. Put the page in the main namespace
# since we don't have any idea of the old namespace name. See bug 68501.
if (!MWNamespace::exists($ns)) {
$ns = 0;
}
$clean = 'Broken/' . $prior;
$verified = Title::makeTitleSafe($ns, $clean);
if (!$verified || $verified->exists()) {
$blah = "Broken/id:" . $row->page_id;
$this->output("Couldn't legalize; form '{$clean}' exists; using '{$blah}'\n");
$verified = Title::makeTitleSafe($ns, $blah);
}
$title = $verified;
}
if (is_null($title)) {
$this->error("Something awry; empty title.", true);
}
$ns = $title->getNamespace();
$dest = $title->getDBkey();
if ($this->dryrun) {
$this->output("DRY RUN: would rename {$row->page_id} ({$row->page_namespace}," . "'{$row->page_title}') to ({$ns},'{$dest}')\n");
} else {
$this->output("renaming {$row->page_id} ({$row->page_namespace}," . "'{$row->page_title}') to ({$ns},'{$dest}')\n");
$dbw = wfGetDB(DB_MASTER);
$dbw->update('page', array('page_namespace' => $ns, 'page_title' => $dest), array('page_id' => $row->page_id), __METHOD__);
LinkCache::singleton()->clear();
}
}
示例7: getInvalidTitleDescription
/**
* Get a message saying that an invalid title was encountered.
* This should be called after a method like Title::makeTitleSafe() returned
* a value indicating that the title object is invalid.
*
* @param $context IContextSource context to use to get the messages
* @param $namespace int Namespace number
* @param $title string Text of the title, without the namespace part
*/
public static function getInvalidTitleDescription(IContextSource $context, $namespace, $title)
{
global $wgContLang;
// First we check whether the namespace exists or not.
if (MWNamespace::exists($namespace)) {
if ($namespace == NS_MAIN) {
$name = $context->msg('blanknamespace')->text();
} else {
$name = $wgContLang->getFormattedNsText($namespace);
}
return $context->msg('invalidtitle-knownnamespace', $namespace, $name, $title)->text();
} else {
return $context->msg('invalidtitle-unknownnamespace', $namespace, $title)->text();
}
}
示例8: getNS
/**
* Decode the namespace URL parameter.
* @param $ns String Either numeric NS number, NS name, or special value :all:
* @return Mixed Integer or false Namespace number or false for no NS filtering.
*/
private function getNS($ns)
{
global $wgContLang;
$nsNumb = $wgContLang->getNsIndex($ns);
if ($nsNumb !== false) {
// If they specified something like Talk or Image.
return $nsNumb;
} elseif (is_numeric($ns)) {
// If they specified a number.
$nsVal = intval($ns);
if ($nsVal >= 0 && MWNamespace::exists($nsVal)) {
return $nsVal;
} else {
wfDebug(__METHOD__ . ' Invalid numeric ns number. Using main.');
return 0;
}
} elseif ($ns === ':all:') {
// Need someway to denote no namespace filtering,
// This seems as good as any since a namespace can't
// have colons in it.
return false;
} else {
// Default of main only if user gives bad input.
// Note, this branch is only reached on bad input. Omitting
// the namespace parameter is like saying namespace=0.
wfDebug(__METHOD__ . ' Invalid (non-numeric) ns. Using main.');
return 0;
}
}
示例9: getJSVars
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
* DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
* This is only public until that function is removed. You have been warned.
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript
* - in other words, page-indendent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
*/
public function getJSVars()
{
global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
if ($ns == NS_SPECIAL) {
list($canonicalName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
} else {
$canonicalName = false;
# bug 21115
}
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBKey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $title->getLatestRevID(), 'wgArticleId' => $title->getArticleId(), 'wgIsArticle' => $this->isArticle(), 'wgAction' => $this->getRequest()->getText('action', 'view'), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY');
if ($wgContLang->hasVariants()) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
foreach ($title->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($this->getUser());
}
if ($title->isMainPage()) {
$vars['wgIsMainPage'] = true;
}
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
// page-dependant but site-wide (without state).
// Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
// Merge in variables from addJsConfigVars last
return array_merge($vars, $this->mJsConfigVars);
}
示例10: makeGlobalVariablesScript
/**
* Make a <script> tag containing global variables
* @param $skinName string Name of the skin
* The odd calling convention is for backwards compatibility
* @TODO @FIXME Make this not depend on $wgTitle!
*/
static function makeGlobalVariablesScript($skinName)
{
if (is_array($skinName)) {
# Weird back-compat stuff.
$skinName = $skinName['skinname'];
}
global $wgScript, $wgTitle, $wgStylePath, $wgUser, $wgScriptExtension;
global $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgLang;
global $wgOut, $wgArticle;
global $wgBreakFrames, $wgRequest, $wgVariantArticlePath, $wgActionPaths;
global $wgUseAjax, $wgAjaxWatch;
global $wgVersion, $wgEnableAPI, $wgEnableWriteAPI;
global $wgRestrictionTypes;
global $wgMWSuggestTemplate, $wgDBname, $wgEnableMWSuggest;
global $wgSitename;
$ns = $wgTitle->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $wgTitle->getNsText();
$separatorTransTable = $wgContLang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $wgContLang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$mainPage = Title::newFromText(wfMsgForContent('mainpage'));
$vars = array('skin' => $skinName, 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $ns == NS_SPECIAL ? SpecialPage::resolveAlias($wgTitle->getDBkey()) : false, 'wgNamespaceNumber' => $wgTitle->getNamespace(), 'wgPageName' => $wgTitle->getPrefixedDBKey(), 'wgTitle' => $wgTitle->getText(), 'wgAction' => $wgRequest->getText('action', 'view'), 'wgArticleId' => $wgTitle->getArticleId(), 'wgIsArticle' => $wgOut->isArticle(), 'wgUserName' => $wgUser->isAnon() ? null : $wgUser->getName(), 'wgUserGroups' => $wgUser->isAnon() ? null : $wgUser->getEffectiveGroups(), 'wgUserLanguage' => $wgLang->getCode(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgBreakFrames' => $wgBreakFrames, 'wgCurRevisionId' => isset($wgArticle) ? $wgArticle->getLatest() : 0, 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $wgContLang->getNamespaceIds(), 'wgSiteName' => $wgSitename, 'wgCategories' => $wgOut->getCategories());
if ($wgContLang->hasVariants()) {
$vars['wgUserVariant'] = $wgContLang->getPreferredVariant();
}
// if on upload page output the extension list & js_upload
if (SpecialPage::resolveAlias($wgTitle->getDBkey()) == 'Upload') {
global $wgFileExtensions, $wgAjaxUploadInterface;
$vars['wgFileExtensions'] = $wgFileExtensions;
}
if ($wgUseAjax && $wgEnableMWSuggest && !$wgUser->getOption('disablesuggest', false)) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
$vars['wgDBname'] = $wgDBname;
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($wgUser);
$vars['wgMWSuggestMessages'] = array(wfMsg('search-mwsuggest-enabled'), wfMsg('search-mwsuggest-disabled'));
}
foreach ($wgRestrictionTypes as $type) {
$vars['wgRestriction' . ucfirst($type)] = $wgTitle->getRestrictions($type);
}
if ($wgOut->isArticleRelated() && $wgUseAjax && $wgAjaxWatch && $wgUser->isLoggedIn()) {
$msgs = (object) array();
foreach (array('watch', 'unwatch', 'watching', 'unwatching', 'tooltip-ca-watch', 'tooltip-ca-unwatch') as $msgName) {
$msgs->{$msgName . 'Msg'} = wfMsg($msgName);
}
$vars['wgAjaxWatch'] = $msgs;
}
// Allow extensions to add their custom variables to the global JS variables
wfRunHooks('MakeGlobalVariablesScript', array(&$vars));
return self::makeVariablesScript($vars);
}
示例11: getJSVars
/**
* Get an array containing the variables to be set in mw.config in JavaScript.
*
* DO NOT CALL THIS FROM OUTSIDE OF THIS CLASS OR Skin::makeGlobalVariablesScript().
* This is only public until that function is removed. You have been warned.
*
* Do not add things here which can be evaluated in ResourceLoaderStartupScript
* - in other words, page-independent/site-wide variables (without state).
* You will only be adding bloat to the html page and causing page caches to
* have to be purged on configuration changes.
* @return array
*/
public function getJSVars()
{
global $wgUseAjax, $wgEnableMWSuggest;
$latestRevID = 0;
$pageID = 0;
$canonicalName = false;
# bug 21115
$title = $this->getTitle();
$ns = $title->getNamespace();
$nsname = MWNamespace::exists($ns) ? MWNamespace::getCanonicalName($ns) : $title->getNsText();
// Get the relevant title so that AJAX features can use the correct page name
// when making API requests from certain special pages (bug 34972).
$relevantTitle = $this->getSkin()->getRelevantTitle();
if ($ns == NS_SPECIAL) {
list($canonicalName, ) = SpecialPageFactory::resolveAlias($title->getDBkey());
} elseif ($this->canUseWikiPage()) {
$wikiPage = $this->getWikiPage();
$latestRevID = $wikiPage->getLatest();
$pageID = $wikiPage->getId();
}
$lang = $title->getPageLanguage();
// Pre-process information
$separatorTransTable = $lang->separatorTransformTable();
$separatorTransTable = $separatorTransTable ? $separatorTransTable : array();
$compactSeparatorTransTable = array(implode("\t", array_keys($separatorTransTable)), implode("\t", $separatorTransTable));
$digitTransTable = $lang->digitTransformTable();
$digitTransTable = $digitTransTable ? $digitTransTable : array();
$compactDigitTransTable = array(implode("\t", array_keys($digitTransTable)), implode("\t", $digitTransTable));
$vars = array('wgCanonicalNamespace' => $nsname, 'wgCanonicalSpecialPageName' => $canonicalName, 'wgNamespaceNumber' => $title->getNamespace(), 'wgPageName' => $title->getPrefixedDBKey(), 'wgTitle' => $title->getText(), 'wgCurRevisionId' => $latestRevID, 'wgArticleId' => $pageID, 'wgIsArticle' => $this->isArticle(), 'wgAction' => Action::getActionName($this->getContext()), 'wgUserName' => $this->getUser()->isAnon() ? null : $this->getUser()->getName(), 'wgUserGroups' => $this->getUser()->getEffectiveGroups(), 'wgCategories' => $this->getCategories(), 'wgBreakFrames' => $this->getFrameOptions() == 'DENY', 'wgPageContentLanguage' => $lang->getCode(), 'wgSeparatorTransformTable' => $compactSeparatorTransTable, 'wgDigitTransformTable' => $compactDigitTransTable, 'wgRelevantPageName' => $relevantTitle->getPrefixedDBKey());
if ($lang->hasVariants()) {
$vars['wgUserVariant'] = $lang->getPreferredVariant();
}
foreach ($title->getRestrictionTypes() as $type) {
$vars['wgRestriction' . ucfirst($type)] = $title->getRestrictions($type);
}
if ($wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption('disablesuggest', false)) {
$vars['wgSearchNamespaces'] = SearchEngine::userNamespaces($this->getUser());
}
if ($title->isMainPage()) {
$vars['wgIsMainPage'] = true;
}
if ($this->mRedirectedFrom) {
$vars['wgRedirectedFrom'] = $this->mRedirectedFrom->getPrefixedDBKey();
}
// Allow extensions to add their custom variables to the mw.config map.
// Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
// page-dependant but site-wide (without state).
// Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
wfRunHooks('MakeGlobalVariablesScript', array(&$vars, $this));
// Merge in variables from addJsConfigVars last
return array_merge($vars, $this->mJsConfigVars);
}
示例12: execute
public function execute($par = null)
{
global $wgOut, $wgRequest, $wgServer, $wgWikiFeedsSettings, $wgUser;
$request = isset($par) ? $par : $wgRequest->getText('request');
if (!$request) {
$wgOut->addWikiText(wfMsg('wikifeeds_mainpage'));
// do special voodoo if private watchlist is enabled
if ($wgWikiFeedsSettings['watchlistPrivate'] && $wgUser->isLoggedIn()) {
if (!$wgUser->getOption('watchlistToken')) {
$token = md5(microtime() . $wgUser->getID());
$wgUser->setOption('watchlistToken', $token);
$wgUser->saveSettings();
}
$token = $wgUser->getOption('watchlistToken');
$privateFeedUrl = Title::newFromText('WikiFeeds/atom/watchlist/user/' . $wgUser->getName() . '/token/' . $token, NS_SPECIAL);
// and display blurb about token
$wgOut->addWikiText(wfMsg('wikifeeds_tokeninfo', $token, $privateFeedUrl->getFullUrl()));
}
} else {
$arr = explode('/', $request);
//might have a valid request for a feed
if (count($arr) >= 2) {
$format = null;
$feed = null;
$count = self::DEFAULT_COUNT;
$namespace = null;
$params = array();
$areSane = true;
if (strtolower($arr[0]) == 'atom') {
$format = GenericXmlSyndicationFeed::FORMAT_ATOM10;
} else {
if (strtolower($arr[0]) == 'rss') {
$format = GenericXmlSyndicationFeed::FORMAT_RSS20;
} else {
$wgOut->addWikiText(wfMsg('wikifeeds_unknownformat'));
$areSane = false;
}
}
switch (strtolower($arr[1])) {
case 'newestarticles':
$feed = self::FEED_NEWESTARTICLES;
break;
case 'recentarticlechanges':
$feed = self::FEED_RECENTARTICLECHANGES;
break;
case 'recentuserchanges':
$feed = self::FEED_RECENTUSERCHANGES;
break;
case 'newestuserarticles':
$feed = self::FEED_NEWESTARTICLESBYUSER;
break;
case 'watchlist':
$feed = self::FEED_USERWATCHLIST;
break;
case 'recentcategorychanges':
$feed = self::FEED_RECENTCATEGORYCHANGES;
break;
case 'newestcategoryarticles':
$feed = self::FEED_NEWESTCATEGORYARTICLES;
break;
case 'recentchangesnotincategory':
$feed = self::FEED_RECENTCHANGESNOTINCATEGORY;
break;
case 'newestarticlesnotincategory':
$feed = self::FEED_NEWESTARTICLESNOTINCATEGORY;
break;
default:
$wgOut->addWikiText(wfMsg('wikifeeds_unknownfeed'));
$areSane = false;
}
//now we look for additional parameters
if (count($arr) > 3 && count($arr) % 2 == 0) {
for ($i = 2; $i < count($arr); $i += 2) {
$params[$arr[$i]] = $arr[$i + 1];
}
}
//if we are dealing with a category feed, we need a category specified
if ($feed === self::FEED_RECENTCATEGORYCHANGES || $feed === self::FEED_NEWESTCATEGORYARTICLES || $feed === self::FEED_RECENTCHANGESNOTINCATEGORY || $feed === self::FEED_NEWESTARTICLESNOTINCATEGORY) {
if (!array_key_exists('category', $params)) {
$wgOut->addWikiText(wfMsg('wikifeeds_undefinedcategory'));
$areSane = false;
} else {
//verify category is valid
if (!$this->categoryExists($params['category'])) {
$wgOut->addWikiText(wfMsg('wikifeeds_categorynoexist'));
$areSane = false;
}
}
}
//if we are asking for a user feed, we need the user parameter
if ($feed === self::FEED_RECENTUSERCHANGES || $feed === self::FEED_USERWATCHLIST || $feed === self::FEED_NEWESTARTICLESBYUSER) {
if (!array_key_exists('user', $params)) {
$wgOut->addWikiText(wfMsg('wikifeeds_undefineduser'));
$areSane = false;
} else {
//verify the user exists
$userId = User::idFromName($params['user']);
if (is_null($userId) || $userId === 0) {
$wgOut->addWikiText(wfMsg('wikifeeds_unknownuser'));
$areSane = false;
//.........这里部分代码省略.........
示例13: outputPage
/**
* initialize various variables and generate the template
*
* @param $out OutputPage
*/
function outputPage(OutputPage $out)
{
global $wgUser, $wgLang, $wgContLang;
global $wgScript, $wgStylePath;
global $wgMimeType, $wgJsMimeType, $wgRequest;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
global $wgMaxCredits, $wgShowCreditsIfMax;
global $wgPageShowWatchingUsers;
global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
global $wgArticlePath, $wgScriptPath, $wgServer;
wfProfileIn(__METHOD__);
Profiler::instance()->setTemplated(true);
$oldid = $wgRequest->getVal('oldid');
$diff = $wgRequest->getVal('diff');
$action = $wgRequest->getVal('action', 'view');
wfProfileIn(__METHOD__ . '-init');
$this->initPage($out);
$tpl = $this->setupTemplate($this->template, 'skins');
wfProfileOut(__METHOD__ . '-init');
wfProfileIn(__METHOD__ . '-stuff');
$this->thispage = $this->getTitle()->getPrefixedDBkey();
$this->userpage = $wgUser->getUserPage()->getPrefixedText();
$query = array();
if (!$wgRequest->wasPosted()) {
$query = $wgRequest->getValues();
unset($query['title']);
unset($query['returnto']);
unset($query['returntoquery']);
}
$this->thisquery = wfArrayToCGI($query);
$this->loggedin = $wgUser->isLoggedIn();
$this->iscontent = $this->getTitle()->getNamespace() != NS_SPECIAL;
$this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
$this->username = $wgUser->getName();
if ($wgUser->isLoggedIn() || $this->showIPinHeader()) {
$this->userpageUrlDetails = self::makeUrlDetails($this->userpage);
} else {
# This won't be used in the standard skins, but we define it to preserve the interface
# To save time, we check for existence
$this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage);
}
$this->titletxt = $this->getTitle()->getPrefixedText();
wfProfileOut(__METHOD__ . '-stuff');
wfProfileIn(__METHOD__ . '-stuff-head');
if ($this->useHeadElement) {
$pagecss = $this->setupPageCss();
if ($pagecss) {
$out->addInlineStyle($pagecss);
}
} else {
$this->setupUserCss($out);
$tpl->set('pagecss', $this->setupPageCss());
$tpl->set('usercss', false);
$this->userjs = $this->userjsprev = false;
# @todo FIXME: This is the only use of OutputPage::isUserJsAllowed() anywhere; can we
# get rid of it? For that matter, why is any of this here at all?
$this->setupUserJs($out->isUserJsAllowed());
$tpl->setRef('userjs', $this->userjs);
$tpl->setRef('userjsprev', $this->userjsprev);
if ($wgUseSiteJs) {
$jsCache = $this->loggedin ? '&smaxage=0' : '';
$tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName())));
} else {
$tpl->set('jsvarurl', false);
}
$tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace);
$tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces);
$tpl->set('html5version', $wgHtml5Version);
$tpl->set('headlinks', $out->getHeadLinks($this));
$tpl->set('csslinks', $out->buildCssLinks($this));
if ($wgUseTrackbacks && $out->isArticleRelated()) {
$tpl->set('trackbackhtml', $out->getTitle()->trackbackRDF());
} else {
$tpl->set('trackbackhtml', null);
}
}
wfProfileOut(__METHOD__ . '-stuff-head');
wfProfileIn(__METHOD__ . '-stuff2');
$tpl->set('title', $out->getPageTitle());
$tpl->set('pagetitle', $out->getHTMLTitle());
$tpl->set('displaytitle', $out->mPageLinkTitle);
$tpl->set('pageclass', $this->getPageClasses($this->getTitle()));
$tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName()));
$nsname = MWNamespace::exists($this->getTitle()->getNamespace()) ? MWNamespace::getCanonicalName($this->getTitle()->getNamespace()) : $this->getTitle()->getNsText();
$tpl->set('nscanonical', $nsname);
$tpl->set('nsnumber', $this->getTitle()->getNamespace());
$tpl->set('titleprefixeddbkey', $this->getTitle()->getPrefixedDBKey());
$tpl->set('titletext', $this->getTitle()->getText());
$tpl->set('articleid', $this->getTitle()->getArticleId());
$tpl->set('currevisionid', $this->getTitle()->getLatestRevID());
$tpl->set('isarticle', $out->isArticle());
$tpl->setRef('thispage', $this->thispage);
$subpagestr = $this->subPageSubtitle();
$tpl->set('subtitle', !empty($subpagestr) ? '<span class="subpages">' . $subpagestr . '</span>' . $out->getSubtitle() : $out->getSubtitle());
//.........这里部分代码省略.........
示例14: outputPage
/**
* initialize various variables and generate the template
*
* @param $out OutputPage
*/
function outputPage(OutputPage $out)
{
global $wgArticle, $wgUser, $wgLang, $wgContLang;
global $wgScript, $wgStylePath, $wgContLanguageCode;
global $wgMimeType, $wgJsMimeType, $wgOutputEncoding, $wgRequest;
global $wgXhtmlDefaultNamespace, $wgXhtmlNamespaces, $wgHtml5Version;
global $wgDisableCounters, $wgLogo, $wgHideInterlanguageLinks;
global $wgMaxCredits, $wgShowCreditsIfMax;
global $wgPageShowWatchingUsers;
global $wgUseTrackbacks, $wgUseSiteJs, $wgDebugComments;
global $wgArticlePath, $wgScriptPath, $wgServer;
wfProfileIn(__METHOD__);
$oldid = $wgRequest->getVal('oldid');
$diff = $wgRequest->getVal('diff');
$action = $wgRequest->getVal('action', 'view');
wfProfileIn(__METHOD__ . '-init');
$this->initPage($out);
$this->setMembers();
$tpl = $this->setupTemplate($this->template, 'skins');
#if ( $wgUseDatabaseMessages ) { // uncomment this to fall back to GetText
$tpl->setTranslator(new MediaWiki_I18N());
#}
wfProfileOut(__METHOD__ . '-init');
wfProfileIn(__METHOD__ . '-stuff');
$this->thispage = $this->mTitle->getPrefixedDBkey();
$this->thisurl = $this->mTitle->getPrefixedURL();
$query = array();
if (!$wgRequest->wasPosted()) {
$query = $wgRequest->getValues();
unset($query['title']);
unset($query['returnto']);
unset($query['returntoquery']);
}
$this->thisquery = wfUrlencode(wfArrayToCGI($query));
$this->loggedin = $wgUser->isLoggedIn();
$this->iscontent = $this->mTitle->getNamespace() != NS_SPECIAL;
$this->iseditable = ($this->iscontent and !($action == 'edit' or $action == 'submit'));
$this->username = $wgUser->getName();
if ($wgUser->isLoggedIn() || $this->showIPinHeader()) {
$this->userpageUrlDetails = self::makeUrlDetails($this->userpage);
} else {
# This won't be used in the standard skins, but we define it to preserve the interface
# To save time, we check for existence
$this->userpageUrlDetails = self::makeKnownUrlDetails($this->userpage);
}
$this->titletxt = $this->mTitle->getPrefixedText();
wfProfileOut(__METHOD__ . '-stuff');
wfProfileIn(__METHOD__ . '-stuff-head');
if ($this->useHeadElement) {
$pagecss = $this->setupPageCss();
if ($pagecss) {
$out->addInlineStyle($pagecss);
}
} else {
$this->setupUserCss($out);
$tpl->set('pagecss', $this->setupPageCss());
$tpl->setRef('usercss', $this->usercss);
$this->userjs = $this->userjsprev = false;
$this->setupUserJs($out->isUserJsAllowed());
$tpl->setRef('userjs', $this->userjs);
$tpl->setRef('userjsprev', $this->userjsprev);
if ($wgUseSiteJs) {
$jsCache = $this->loggedin ? '&smaxage=0' : '';
$tpl->set('jsvarurl', self::makeUrl('-', "action=raw{$jsCache}&gen=js&useskin=" . urlencode($this->getSkinName())));
} else {
$tpl->set('jsvarurl', false);
}
$tpl->setRef('xhtmldefaultnamespace', $wgXhtmlDefaultNamespace);
$tpl->set('xhtmlnamespaces', $wgXhtmlNamespaces);
$tpl->set('html5version', $wgHtml5Version);
$tpl->set('headlinks', $out->getHeadLinks());
$tpl->set('csslinks', $out->buildCssLinks());
if ($wgUseTrackbacks && $out->isArticleRelated()) {
$tpl->set('trackbackhtml', $out->getTitle()->trackbackRDF());
} else {
$tpl->set('trackbackhtml', null);
}
}
wfProfileOut(__METHOD__ . '-stuff-head');
wfProfileIn(__METHOD__ . '-stuff2');
$tpl->set('title', $out->getPageTitle());
$tpl->set('pagetitle', $out->getHTMLTitle());
$tpl->set('displaytitle', $out->mPageLinkTitle);
$tpl->set('pageclass', $this->getPageClasses($this->mTitle));
$tpl->set('skinnameclass', 'skin-' . Sanitizer::escapeClass($this->getSkinName()));
$nsname = MWNamespace::exists($this->mTitle->getNamespace()) ? MWNamespace::getCanonicalName($this->mTitle->getNamespace()) : $this->mTitle->getNsText();
$tpl->set('nscanonical', $nsname);
$tpl->set('nsnumber', $this->mTitle->getNamespace());
$tpl->set('titleprefixeddbkey', $this->mTitle->getPrefixedDBKey());
$tpl->set('titletext', $this->mTitle->getText());
$tpl->set('articleid', $this->mTitle->getArticleId());
$tpl->set('currevisionid', isset($wgArticle) ? $wgArticle->getLatest() : 0);
$tpl->set('isarticle', $out->isArticle());
$tpl->setRef('thispage', $this->thispage);
$subpagestr = $this->subPageSubtitle();
//.........这里部分代码省略.........
示例15: parseNamespace
/**
* @brief Parse a namespace specification.
*
* @param int|string $param Namespace name or namespace index.
* @return int Namespace index.
* @throws Scribunto_LuaError
*/
public function parseNamespace($param)
{
if (is_numeric($param)) {
/** A numeric parameter (including a numeric literal) is
* interpreted as a namespace index. */
$index = intval($param);
if (!MWNamespace::exists($index)) {
throw new Scribunto_LuaError(wfMessage('dple-error-invalid-ns-index', $index)->text());
}
return $index;
}
global $wgContLang;
$index = $wgContLang->getNsIndex($param);
if ($index === false) {
return 0;
}
return $index;
}