本文整理汇总了PHP中MWNamespace类的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace类的具体用法?PHP MWNamespace怎么用?PHP MWNamespace使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MWNamespace类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfigSettings
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getConfigSettings($context)
{
$hash = $context->getHash();
if (isset($this->configVars[$hash])) {
return $this->configVars[$hash];
}
global $wgContLang;
$mainPage = Title::newMainPage();
/**
* Namespace related preparation
* - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
* - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
*/
$namespaceIds = $wgContLang->getNamespaceIds();
$caseSensitiveNamespaces = array();
foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
$namespaceIds[$wgContLang->lc($name)] = $index;
if (!MWNamespace::isCapitalized($index)) {
$caseSensitiveNamespaces[] = $index;
}
}
$conf = $this->getConfig();
// Build list of variables
$vars = array('wgLoadScript' => wfScript('load'), 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $conf->get('StylePath'), 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $conf->get('ArticlePath'), 'wgScriptPath' => $conf->get('ScriptPath'), 'wgScriptExtension' => '.php', 'wgScript' => wfScript(), 'wgSearchType' => $conf->get('SearchType'), 'wgVariantArticlePath' => $conf->get('VariantArticlePath'), 'wgActionPaths' => (object) $conf->get('ActionPaths'), 'wgServer' => $conf->get('Server'), 'wgServerName' => $conf->get('ServerName'), 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgTranslateNumerals' => $conf->get('TranslateNumerals'), 'wgVersion' => $conf->get('Version'), 'wgEnableAPI' => $conf->get('EnableAPI'), 'wgEnableWriteAPI' => $conf->get('EnableWriteAPI'), 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $conf->get('Sitename'), 'wgDBname' => $conf->get('DBname'), 'wgExtraSignatureNamespaces' => $conf->get('ExtraSignatureNamespaces'), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $conf->get('ExtensionAssetsPath'), 'wgCookiePrefix' => $conf->get('CookiePrefix'), 'wgCookieDomain' => $conf->get('CookieDomain'), 'wgCookiePath' => $conf->get('CookiePath'), 'wgCookieExpiration' => $conf->get('CookieExpiration'), 'wgResourceLoaderMaxQueryLength' => $conf->get('ResourceLoaderMaxQueryLength'), 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $conf->get('ResourceLoaderStorageVersion'), 'wgResourceLoaderStorageEnabled' => $conf->get('ResourceLoaderStorageEnabled'), 'wgResourceLoaderLegacyModules' => self::getLegacyModules(), 'wgForeignUploadTargets' => $conf->get('ForeignUploadTargets'), 'wgEnableUploads' => $conf->get('EnableUploads'));
Hooks::run('ResourceLoaderGetConfigVars', array(&$vars));
$this->configVars[$hash] = $vars;
return $this->configVars[$hash];
}
示例2: getConfig
/**
* @param $context ResourceLoaderContext
* @return array
*/
protected function getConfig($context)
{
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgUseAjax, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgEnableMWSuggest, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength;
$mainPage = Title::newMainPage();
/**
* Namespace related preparation
* - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
* - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
*/
$namespaceIds = $wgContLang->getNamespaceIds();
$caseSensitiveNamespaces = array();
foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
$namespaceIds[$wgContLang->lc($name)] = $index;
if (!MWNamespace::isCapitalized($index)) {
$caseSensitiveNamespaces[] = $index;
}
}
// Build list of variables
$vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgDefaultDateFormat' => $wgContLang->getDefaultDateFormat(), 'wgMonthNames' => $wgContLang->getMonthNamesArray(), 'wgMonthNamesShort' => $wgContLang->getMonthAbbreviationsArray(), 'wgMainPageTitle' => $mainPage ? $mainPage->getPrefixedText() : null, 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values($wgFileExtensions), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgSassParams' => SassUtil::getSassSettings());
if ($wgUseAjax && $wgEnableMWSuggest) {
$vars['wgMWSuggestTemplate'] = SearchEngine::getMWSuggestTemplate();
}
wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
return $vars;
}
示例3: PlusoHeader
public static function PlusoHeader(&$article, &$outputDone, &$pcache)
{
global $wgOut, $wgPlusoUserID, $wgPlusoHeader, $wgPlusoMain, $wgPlusoBackgroundHeader, $wgPlusoThemeHeader, $wgPlusoServicesHeader;
# Check if page is in content namespace and the setting to enable/disable article header tooblar either on the main page or at all
if (!MWNamespace::isContent($article->getTitle()->getNamespace()) || !$wgPlusoHeader || $article->getTitle()->equals(Title::newMainPage()) && !$wgPlusoMain) {
return true;
}
/* Output Pluso header in <h1> */
$wgOut->addHTML('
<script type="text/javascript">
(function() {
if (window.pluso)if (typeof window.pluso.start == "function") return;
if (window.ifpluso==undefined) { window.ifpluso = 1;
var d = document, s = d.createElement("script"), g = "getElementsByTagName";
s.type = "text/javascript"; s.charset="UTF-8"; s.async = true;
s.src = ("https:" == window.location.protocol ? "https" : "http") + "://share.pluso.ru/pluso-like.js";
var h=d[g]("body")[0];
h.appendChild(s);
}
})();
jQuery(document).ready(function() {
var title = jQuery("#firstHeading").html();
jQuery("#firstHeading").html(title + \'<div data-user="' . $wgPlusoUserID . '" class="pluso" style="float: right;right: 10px;" data-background="' . $wgPlusoBackgroundHeader . '" data-options="medium,round,line,horizontal,counter,theme=' . $wgPlusoThemeHeader . '" data-services="' . $wgPlusoServicesHeader . '"></div>\');
});</script>');
return true;
}
示例4: thread
public function thread()
{
wfProfileIn(__METHOD__);
$this->addAsset();
$title = $this->request->getVal('title', $this->app->wg->Title);
$id = $this->request->getVal('id', null);
$this->getThread($id);
$this->response->setVal('showNewMessage', false);
$this->response->setVal('type', 'Thread');
$this->response->setVal('condenseMessage', false);
if (count($this->threads) > 0) {
$wn = F::build('WallNotifications', array());
foreach ($this->threads as $key => $val) {
$all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
break;
}
}
$this->response->setVal('renderUserTalkArchiveAnchor', false);
$this->response->setVal('greeting', '');
$title = F::build('Title', array($id), 'newFromId');
if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
$wallMessage = F::build('WallMessage', array($title), 'newFromTitle');
$wallMessage->load();
$this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
}
wfProfileOut(__METHOD__);
}
示例5: execute
/**
* main()
*/
public function execute($par)
{
global $wgOut;
$fname = 'SpecialAdvancedRandom::execute';
wfProfileIn($fname);
list($page, $namespace) = $this->extractParamaters($par);
$ft = Title::newFromText($page);
if (is_null($ft)) {
$this->redirect(Title::newMainPage());
wfProfileOut($fname);
return;
}
$rand = wfRandom();
$dbr = wfGetDB(DB_SLAVE);
if ($ft->getNamespace() == NS_TEMPLATE) {
$res = $dbr->selectRow(array('page', 'templatelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = tl_from', 'tl_namespace' => NS_TEMPLATE, 'page_namespace' => $namespace, 'tl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
} else {
$res = $dbr->selectRow(array('page', 'pagelinks'), array('page_namespace', 'page_title', 'page_random'), array('page_id = pl_from', 'pl_namespace' => $ft->getNamespace(), 'page_namespace' => $namespace, 'pl_title' => $ft->getDBkey(), "page_random > {$rand}"), $fname, array('ORDER BY' => 'page_random', 'USE INDEX' => array('page' => 'page_random')));
}
$title =& Title::makeTitle(MWNamespace::getSubject($namespace), $res->page_title);
if (is_null($title) || $title->getText() == '') {
$title = Title::newMainPage();
}
$this->redirect($title);
wfProfileOut($fname);
}
示例6: onGetNotificationMessage
public static function onGetNotificationMessage($nc, &$msg, $isMain, $data, $authors, $userCount, $myName)
{
if (empty($data->article_title_ns) || MWNamespace::getSubject($data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
return true;
}
if (!$isMain) {
if ($data->parent_username == $myName) {
$replyTo = "your";
} else {
$replyTo = "someone";
}
$secondUser = '';
if ($userCount == 2) {
$secondUser = $nc->getDisplayname($authors[1]['displayname']);
}
$params = [$nc->getDisplayname($data->msg_author_displayname), $secondUser, $data->article_title_text, $myName];
// Messages that can be used here:
// * forum-notification-user1-reply-to-your
// * forum-notification-user2-reply-to-your
// * forum-notification-user3-reply-to-your
// * forum-notification-user1-reply-to-someone
// * forum-notification-user2-reply-to-someone
// * forum-notification-user3-reply-to-someone
$msgKey = "forum-notification-user{$userCount}-reply-to-{$replyTo}";
} else {
$msgKey = 'forum-notification-newmsg-on-followed-wall';
$params = [$nc->getDisplayname($data->msg_author_displayname), $data->wall_displayname];
}
$msg = wfMessage($msgKey, $params)->text();
return true;
}
示例7: thread
public function thread()
{
wfProfileIn(__METHOD__);
$this->addAsset();
$title = $this->request->getVal('title', $this->app->wg->Title);
$id = $this->request->getVal('id', null);
$this->getThread($id);
$this->response->setVal('showNewMessage', false);
$this->response->setVal('type', 'Thread');
$this->response->setVal('condenseMessage', false);
if (count($this->threads) > 0) {
$wn = new WallNotifications();
foreach ($this->threads as $key => $val) {
$all = $wn->markRead($this->wg->User->getId(), $this->wg->CityId, $key);
break;
}
}
$this->response->setVal('renderUserTalkArchiveAnchor', false);
$this->response->setVal('greeting', '');
$title = Title::newFromId($id);
if (!empty($title) && $title->exists() && in_array(MWNamespace::getSubject($title->getNamespace()), $this->app->wg->WallNS)) {
$wallMessage = WallMessage::newFromTitle($title);
$wallMessage->load();
$this->app->wg->Out->setPageTitle($wallMessage->getMetaTitle());
}
// TODO: keep the varnish cache and do purging on post
$this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED);
wfProfileOut(__METHOD__);
}
示例8: __construct
/**
* @param Title $rootPage The root page under which all pages should be
* created
*/
public function __construct(Title $rootPage)
{
if (!MWNamespace::hasSubpages($rootPage->getNamespace())) {
throw new MWException("The root page you specified, {$rootPage}, is in a " . "namespace where subpages are not allowed");
}
$this->rootPage = $rootPage;
}
示例9: __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;
}
示例10: getConfig
/**
* @param ResourceLoaderContext $context
* @return array
*/
protected function getConfig($context)
{
$hash = $context->getHash();
if (isset($this->configVars[$hash])) {
return $this->configVars[$hash];
}
global $wgLoadScript, $wgScript, $wgStylePath, $wgScriptExtension, $wgArticlePath, $wgScriptPath, $wgServer, $wgContLang, $wgVariantArticlePath, $wgActionPaths, $wgVersion, $wgEnableAPI, $wgEnableWriteAPI, $wgDBname, $wgSitename, $wgFileExtensions, $wgExtensionAssetsPath, $wgCookiePrefix, $wgResourceLoaderMaxQueryLength, $wgResourceLoaderStorageEnabled, $wgResourceLoaderStorageVersion, $wgSearchType;
$mainPage = Title::newMainPage();
/**
* Namespace related preparation
* - wgNamespaceIds: Key-value pairs of all localized, canonical and aliases for namespaces.
* - wgCaseSensitiveNamespaces: Array of namespaces that are case-sensitive.
*/
$namespaceIds = $wgContLang->getNamespaceIds();
$caseSensitiveNamespaces = array();
foreach (MWNamespace::getCanonicalNamespaces() as $index => $name) {
$namespaceIds[$wgContLang->lc($name)] = $index;
if (!MWNamespace::isCapitalized($index)) {
$caseSensitiveNamespaces[] = $index;
}
}
// Build list of variables
$vars = array('wgLoadScript' => $wgLoadScript, 'debug' => $context->getDebug(), 'skin' => $context->getSkin(), 'stylepath' => $wgStylePath, 'wgUrlProtocols' => wfUrlProtocols(), 'wgArticlePath' => $wgArticlePath, 'wgScriptPath' => $wgScriptPath, 'wgScriptExtension' => $wgScriptExtension, 'wgScript' => $wgScript, 'wgSearchType' => $wgSearchType, 'wgVariantArticlePath' => $wgVariantArticlePath, 'wgActionPaths' => (object) $wgActionPaths, 'wgServer' => $wgServer, 'wgUserLanguage' => $context->getLanguage(), 'wgContentLanguage' => $wgContLang->getCode(), 'wgVersion' => $wgVersion, 'wgEnableAPI' => $wgEnableAPI, 'wgEnableWriteAPI' => $wgEnableWriteAPI, 'wgMainPageTitle' => $mainPage->getPrefixedText(), 'wgFormattedNamespaces' => $wgContLang->getFormattedNamespaces(), 'wgNamespaceIds' => $namespaceIds, 'wgContentNamespaces' => MWNamespace::getContentNamespaces(), 'wgSiteName' => $wgSitename, 'wgFileExtensions' => array_values(array_unique($wgFileExtensions)), 'wgDBname' => $wgDBname, 'wgFileCanRotate' => BitmapHandler::canRotate(), 'wgAvailableSkins' => Skin::getSkinNames(), 'wgExtensionAssetsPath' => $wgExtensionAssetsPath, 'wgCookiePrefix' => $wgCookiePrefix, 'wgResourceLoaderMaxQueryLength' => $wgResourceLoaderMaxQueryLength, 'wgCaseSensitiveNamespaces' => $caseSensitiveNamespaces, 'wgLegalTitleChars' => Title::convertByteClassToUnicodeClass(Title::legalChars()), 'wgResourceLoaderStorageVersion' => $wgResourceLoaderStorageVersion, 'wgResourceLoaderStorageEnabled' => $wgResourceLoaderStorageEnabled);
wfRunHooks('ResourceLoaderGetConfigVars', array(&$vars));
$this->configVars[$hash] = $vars;
return $this->configVars[$hash];
}
示例11: getQueryInfo
function getQueryInfo()
{
$dbr = wfGetDB(DB_SLAVE);
$dMsgText = wfMsgForContent('disambiguationspage');
$linkBatch = new LinkBatch();
# If the text can be treated as a title, use it verbatim.
# Otherwise, pull the titles from the links table
$dp = Title::newFromText($dMsgText);
if ($dp) {
if ($dp->getNamespace() != NS_TEMPLATE) {
# @todo FIXME: We assume the disambiguation message is a template but
# the page can potentially be from another namespace :/
wfDebug("Mediawiki:disambiguationspage message does not refer to a template!\n");
}
$linkBatch->addObj($dp);
} else {
# Get all the templates linked from the Mediawiki:Disambiguationspage
$disPageObj = Title::makeTitleSafe(NS_MEDIAWIKI, 'disambiguationspage');
$res = $dbr->select(array('pagelinks', 'page'), 'pl_title', array('page_id = pl_from', 'pl_namespace' => NS_TEMPLATE, 'page_namespace' => $disPageObj->getNamespace(), 'page_title' => $disPageObj->getDBkey()), __METHOD__);
foreach ($res as $row) {
$linkBatch->addObj(Title::makeTitle(NS_TEMPLATE, $row->pl_title));
}
}
$set = $linkBatch->constructSet('tl', $dbr);
if ($set === false) {
# We must always return a valid SQL query, but this way
# the DB will always quickly return an empty result
$set = 'FALSE';
wfDebug("Mediawiki:disambiguationspage message does not link to any templates!\n");
}
// @todo FIXME: What are pagelinks and p2 doing here?
return array('tables' => array('templatelinks', 'p1' => 'page', 'pagelinks', 'p2' => 'page'), 'fields' => array('p1.page_namespace AS namespace', 'p1.page_title AS title', 'pl_from AS value'), 'conds' => array($set, 'p1.page_id = tl_from', 'pl_namespace = p1.page_namespace', 'pl_title = p1.page_title', 'p2.page_id = pl_from', 'p2.page_namespace' => MWNamespace::getContentNamespaces()));
}
示例12: getIconType
public static function getIconType($item)
{
wfProfileIn(__METHOD__);
$type = false;
if (MWNamespace::isTalk($item['namespace'])) {
wfProfileOut(__METHOD__);
return self::FEED_TALK_ICON;
}
if (defined('NS_BLOG_ARTICLE_TALK') && $item['namespace'] == NS_BLOG_ARTICLE_TALK) {
wfProfileOut(__METHOD__);
return self::FEED_COMMENT_ICON;
}
//video namespace
if ($item['namespace'] == 400) {
wfProfileOut(__METHOD__);
return self::FEED_FILM_ICON;
}
switch ($item['type']) {
case 'upload':
$type = self::FEED_PHOTO_ICON;
break;
default:
$type = $item['new'] == '1' ? self::FEED_SUN_ICON : self::FEED_PENCIL_ICON;
}
wfProfileOut(__METHOD__);
return $type;
}
示例13: getGroupHtml
/**
* Creates and returns the HTML for a single watchlist group.
*
* @since 0.1
*
* @param SWLGroup $group
*
* @return string
*/
protected function getGroupHtml(SWLGroup $group)
{
$namespaces = $group->getNamespaces();
foreach ($namespaces as &$ns) {
$ns = $ns == 0 ? 'Main' : MWNamespace::getCanonicalName($ns);
}
return Html::rawElement('fieldset', array('id' => 'swl_group_' . $group->getId(), 'groupid' => $group->getId(), 'class' => 'swl_group', 'groupname' => $group->getName(), 'categories' => implode('|', $group->getCategories()), 'namespaces' => implode('|', $namespaces), 'properties' => implode('|', $group->getProperties()), 'concepts' => implode('|', $group->getConcepts()), 'customTexts' => implode('|', $group->getSerializedCustomTexts())), Html::element('legend', array(), $this->msg('swl-group-legend')->text()));
}
示例14: tearDown
public function tearDown()
{
global $wgContLang;
// Reset namespace cache
MWNamespace::getCanonicalNamespaces(true);
$wgContLang->resetNamespaces();
parent::tearDown();
}
示例15: onGetMailNotificationMessage
public function onGetMailNotificationMessage($notification, &$data, $key, $watcherName, $author_signature, $textNoHtml, $text)
{
if (empty($notification->data->article_title_ns) || MWNamespace::getSubject($notification->data->article_title_ns) != NS_WIKIA_FORUM_BOARD) {
return true;
}
$data = array('$WATCHER' => $watcherName, '$BOARDNAME' => $notification->data->article_title_text, '$WIKI' => $notification->data->wikiname, '$AUTHOR_NAME' => $notification->data->msg_author_displayname, '$AUTHOR' => $notification->data->msg_author_username, '$AUTHOR_SIGNATURE' => $author_signature, '$MAIL_SUBJECT' => wfMsg('forum-mail-notification-subject', array('$1' => $notification->data->thread_title, '$2' => $notification->data->wikiname)), '$METATITLE' => $notification->data->thread_title, '$MESSAGE_LINK' => $notification->data->url, '$MESSAGE_NO_HTML' => $textNoHtml, '$MESSAGE_HTML' => $text, '$MSG_KEY_SUBJECT' => 'forum-' . $key, '$MSG_KEY_BODY' => 'forum-mail-notification-body', '$MSG_KEY_GREETING' => 'forum-mail-notification-html-greeting');
return true;
}