本文整理汇总了PHP中MWNamespace::getCanonicalName方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::getCanonicalName方法的具体用法?PHP MWNamespace::getCanonicalName怎么用?PHP MWNamespace::getCanonicalName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::getCanonicalName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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()));
}
示例2: __construct
public function __construct()
{
global $wgContentStagingPrefix, $wgContentStagingNamespace, $wgContentStagingStages;
$this->mwNamespaceIndex = isset($wgContentStagingNamespace) ? $wgContentStagingNamespace : 0;
$this->mwNamespace = MWNamespace::getCanonicalName($this->mwNamespaceIndex) . ":";
$this->pagePrefix = isset($wgContentStagingPrefix) ? $wgContentStagingPrefix : "CMS";
# TODO: make the special page respect user defined names and number of stages
$this->stages = isset($wgContentStagingStages) ? $wgContentStagingStages : array("test" => 0, "stage" => 0, "production" => 0);
parent::__construct('ContentStaging', 'edit', true, false, 'default', false);
}
示例3: execute
/**
* Show the special page
* @param string|null $par
*/
public function execute($par)
{
$this->setHeaders();
$this->outputHeader();
$out = $this->getOutput();
$out->addModuleStyles('mediawiki.special');
$out->wrapWikiMsg("<div class=\"mw-listgrouprights-key\">\n\$1\n</div>", 'listgrouprights-key');
$out->addHTML(Xml::openElement('table', ['class' => 'wikitable mw-listgrouprights-table']) . '<tr>' . Xml::element('th', null, $this->msg('listgrouprights-group')->text()) . Xml::element('th', null, $this->msg('listgrouprights-rights')->text()) . '</tr>');
$config = $this->getConfig();
$groupPermissions = $config->get('GroupPermissions');
$revokePermissions = $config->get('RevokePermissions');
$addGroups = $config->get('AddGroups');
$removeGroups = $config->get('RemoveGroups');
$groupsAddToSelf = $config->get('GroupsAddToSelf');
$groupsRemoveFromSelf = $config->get('GroupsRemoveFromSelf');
$allGroups = array_unique(array_merge(array_keys($groupPermissions), array_keys($revokePermissions), array_keys($addGroups), array_keys($removeGroups), array_keys($groupsAddToSelf), array_keys($groupsRemoveFromSelf)));
asort($allGroups);
foreach ($allGroups as $group) {
$permissions = isset($groupPermissions[$group]) ? $groupPermissions[$group] : [];
$groupname = $group == '*' ? 'all' : $group;
$msg = $this->msg('group-' . $groupname);
$groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
$msg = $this->msg('grouppage-' . $groupname)->inContentLanguage();
$grouppageLocalized = !$msg->isBlank() ? $msg->text() : MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
$grouppageLocalizedTitle = Title::newFromText($grouppageLocalized);
if ($group == '*' || !$grouppageLocalizedTitle) {
// Do not make a link for the generic * group or group with invalid group page
$grouppage = htmlspecialchars($groupnameLocalized);
} else {
$grouppage = Linker::link($grouppageLocalizedTitle, htmlspecialchars($groupnameLocalized));
}
if ($group === 'user') {
// Link to Special:listusers for implicit group 'user'
$grouplink = '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Listusers'), $this->msg('listgrouprights-members')->escaped());
} elseif (!in_array($group, $config->get('ImplicitGroups'))) {
$grouplink = '<br />' . Linker::linkKnown(SpecialPage::getTitleFor('Listusers'), $this->msg('listgrouprights-members')->escaped(), [], ['group' => $group]);
} else {
// No link to Special:listusers for other implicit groups as they are unlistable
$grouplink = '';
}
$revoke = isset($revokePermissions[$group]) ? $revokePermissions[$group] : [];
$addgroups = isset($addGroups[$group]) ? $addGroups[$group] : [];
$removegroups = isset($removeGroups[$group]) ? $removeGroups[$group] : [];
$addgroupsSelf = isset($groupsAddToSelf[$group]) ? $groupsAddToSelf[$group] : [];
$removegroupsSelf = isset($groupsRemoveFromSelf[$group]) ? $groupsRemoveFromSelf[$group] : [];
$id = $group == '*' ? false : Sanitizer::escapeId($group);
$out->addHTML(Html::rawElement('tr', ['id' => $id], "\n\t\t\t\t<td>{$grouppage}{$grouplink}</td>\n\t\t\t\t\t<td>" . $this->formatPermissions($permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf) . '</td>
'));
}
$out->addHTML(Xml::closeElement('table'));
$this->outputNamespaceProtectionInfo();
}
示例4: execute
/**
* Show the special page
*/
public function execute($par)
{
global $wgOut, $wgImplicitGroups, $wgMessageCache;
global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups;
global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$wgMessageCache->loadAllMessages();
$this->setHeaders();
$this->outputHeader();
$wgOut->addHTML(Xml::openElement('table', array('class' => 'wikitable mw-listgrouprights-table')) . '<tr>' . Xml::element('th', null, wfMsg('listgrouprights-group')) . Xml::element('th', null, wfMsg('listgrouprights-rights')) . '</tr>');
foreach ($wgGroupPermissions as $group => $permissions) {
$groupname = $group == '*' ? 'all' : $group;
// Replace * with a more descriptive groupname
$msg = wfMsg('group-' . $groupname);
if (wfEmptyMsg('group-' . $groupname, $msg) || $msg == '') {
$groupnameLocalized = $groupname;
} else {
$groupnameLocalized = $msg;
}
$msg = wfMsgForContent('grouppage-' . $groupname);
if (wfEmptyMsg('grouppage-' . $groupname, $msg) || $msg == '') {
$grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
} else {
$grouppageLocalized = $msg;
}
if ($group == '*') {
// Do not make a link for the generic * group
$grouppage = htmlspecialchars($groupnameLocalized);
} else {
$grouppage = $this->skin->link(Title::newFromText($grouppageLocalized), htmlspecialchars($groupnameLocalized));
}
if ($group === 'user') {
// Link to Special:listusers for implicit group 'user'
$grouplink = '<br />' . $this->skin->link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array(), array('known', 'noclasses'));
} elseif (!in_array($group, $wgImplicitGroups)) {
$grouplink = '<br />' . $this->skin->link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array('group' => $group), array('known', 'noclasses'));
} else {
// No link to Special:listusers for other implicit groups as they are unlistable
$grouplink = '';
}
$revoke = isset($wgRevokePermissions[$group]) ? $wgRevokePermissions[$group] : array();
$addgroups = isset($wgAddGroups[$group]) ? $wgAddGroups[$group] : array();
$removegroups = isset($wgRemoveGroups[$group]) ? $wgRemoveGroups[$group] : array();
$addgroupsSelf = isset($wgGroupsAddToSelf[$group]) ? $wgGroupsAddToSelf[$group] : array();
$removegroupsSelf = isset($wgGroupsRemoveFromSelf[$group]) ? $wgGroupsRemoveFromSelf[$group] : array();
$wgOut->addHTML('<tr>
<td>' . $grouppage . $grouplink . '</td>
<td>' . self::formatPermissions($permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf) . '</td>
</tr>');
}
$wgOut->addHTML(Xml::closeElement('table') . "\n<br /><hr />\n");
$wgOut->wrapWikiMsg("<div class=\"mw-listgrouprights-key\">\n\$1\n</div>", 'listgrouprights-key');
}
示例5: getNamespaceName
public function getNamespaceName($ns)
{
$ns = intval($ns);
if (!$ns) {
$name = "Main";
} else {
$name = MWNamespace::getCanonicalName($ns);
if (empty($name)) {
$name = "Namespace-{$ns}";
}
}
return $name;
}
示例6: select
function select($table, $fields, $conds = '', $fname = 'DatabaseBase::select', $options = array())
{
$row = array();
$title = false;
if (isset($conds['page_title'])) {
$title = $conds['page_title'];
if ($conds['page_namespace'] && MWNamespace::getCanonicalName($conds['page_namespace'])) {
$title = MWNamespace::getCanonicalName($conds['page_namespace']) . ':' . $title;
}
}
if ($title && ($table == 'page' || is_array($table) && in_array('page', $table))) {
if (preg_match('/Template:Pp-/i', $title)) {
return false;
}
$textid = CachedStorage::fetchIdByTitle($title);
if (!$textid) {
$content = DumpReader::load_article($title);
if (!$content) {
wfDebug('no content for ' . $title);
return false;
}
$textid = CachedStorage::set($title, $content);
}
} elseif (isset($conds['rev_id'])) {
$textid = $conds['rev_id'];
}
if (!isset($textid)) {
return $this->resultObject(array());
}
if ($table == 'page') {
// Given a page_title, get the id of text content. For efficiency,
// we fetch the text and store it by ID to access in case 2.
$row = array_fill_keys($fields, '');
$row['page_id'] = $textid;
$row['page_title'] = $title;
$row['page_latest'] = $textid;
} elseif ($table == array('page', 'revision')) {
// Redundantly return textid which is cache key to article wml.
$fields[] = 'rev_user';
$fields[] = 'rev_user_text';
$row = array_fill_keys($fields, '');
$row['rev_id'] = $textid;
$row['rev_text_id'] = $textid;
} else {
print_r($table);
print_r($conds);
}
return $this->resultObject($row);
}
示例7: getFilePrefixRegex
/**
* @param $contLang \Language
* Used as local cache for getting string to remove
*/
private function getFilePrefixRegex($contLang)
{
$langCode = $contLang->getCode();
if (empty($this->filePrefixRegex[$langCode])) {
$fileNamespaces = [\MWNamespace::getCanonicalName(NS_FILE), $contLang->getNamespaces()[NS_FILE]];
$aliases = $contLang->getNamespaceAliases();
foreach ($aliases as $alias => $namespaceId) {
if ($namespaceId == NS_FILE) {
$fileNamespaces[] = $alias;
}
}
$this->filePrefixRegex[$langCode] = '^(' . implode('|', $fileNamespaces) . '):';
}
return $this->filePrefixRegex[$langCode];
}
示例8: execute
/**
* Show the special page
*/
public function execute($par)
{
global $wgOut, $wgImplicitGroups, $wgMessageCache;
global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups;
$wgMessageCache->loadAllMessages();
$this->setHeaders();
$this->outputHeader();
$wgOut->addHTML(Xml::openElement('table', array('class' => 'mw-listgrouprights-table')) . '<tr>' . Xml::element('th', null, wfMsg('listgrouprights-group')) . Xml::element('th', null, wfMsg('listgrouprights-rights')) . '</tr>');
foreach ($wgGroupPermissions as $group => $permissions) {
$groupname = $group == '*' ? 'all' : htmlspecialchars($group);
// Replace * with a more descriptive groupname
$msg = wfMsg('group-' . $groupname);
if (wfEmptyMsg('group-' . $groupname, $msg) || $msg == '') {
$groupnameLocalized = $groupname;
} else {
$groupnameLocalized = $msg;
}
$msg = wfMsgForContent('grouppage-' . $groupname);
if (wfEmptyMsg('grouppage-' . $groupname, $msg) || $msg == '') {
$grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
} else {
$grouppageLocalized = $msg;
}
if ($group == '*') {
// Do not make a link for the generic * group
$grouppage = $groupnameLocalized;
} else {
$grouppage = $this->skin->makeLink($grouppageLocalized, $groupnameLocalized);
}
if ($group === 'user') {
// Link to Special:listusers for implicit group 'user'
$grouplink = '<br />' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), '');
} elseif (!in_array($group, $wgImplicitGroups)) {
$grouplink = '<br />' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), 'group=' . $group);
} else {
// No link to Special:listusers for other implicit groups as they are unlistable
$grouplink = '';
}
$addgroups = isset($wgAddGroups[$group]) ? $wgAddGroups[$group] : array();
$removegroups = isset($wgRemoveGroups[$group]) ? $wgRemoveGroups[$group] : array();
$wgOut->addHTML('<tr>
<td>' . $grouppage . $grouplink . '</td>
<td>' . self::formatPermissions($permissions, $addgroups, $removegroups) . '</td>
</tr>');
}
$wgOut->addHTML(Xml::closeElement('table') . "\n");
}
示例9: execute
/**
* Show the special page
*/
public function execute($par)
{
global $wgImplicitGroups;
global $wgGroupPermissions, $wgRevokePermissions, $wgAddGroups, $wgRemoveGroups;
global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf;
$out = $this->getOutput();
$this->setHeaders();
$this->outputHeader();
$out->addModuleStyles('mediawiki.special');
$out->addHTML(Xml::openElement('table', array('class' => 'wikitable mw-listgrouprights-table')) . '<tr>' . Xml::element('th', null, wfMsg('listgrouprights-group')) . Xml::element('th', null, wfMsg('listgrouprights-rights')) . '</tr>');
$allGroups = array_unique(array_merge(array_keys($wgGroupPermissions), array_keys($wgRevokePermissions), array_keys($wgAddGroups), array_keys($wgRemoveGroups), array_keys($wgGroupsAddToSelf), array_keys($wgGroupsRemoveFromSelf)));
asort($allGroups);
foreach ($allGroups as $group) {
$permissions = isset($wgGroupPermissions[$group]) ? $wgGroupPermissions[$group] : array();
$groupname = $group == '*' ? 'all' : $group;
$msg = wfMessage('group-' . $groupname);
$groupnameLocalized = !$msg->isBlank() ? $msg->text() : $groupname;
$msg = wfMessage('grouppage-' . $groupname)->inContentLanguage();
$grouppageLocalized = !$msg->isBlank() ? $msg->text() : MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
if ($group == '*') {
// Do not make a link for the generic * group
$grouppage = htmlspecialchars($groupnameLocalized);
} else {
$grouppage = Linker::link(Title::newFromText($grouppageLocalized), htmlspecialchars($groupnameLocalized));
}
if ($group === 'user') {
// Link to Special:listusers for implicit group 'user'
$grouplink = '<br />' . Linker::link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array(), array('known', 'noclasses'));
} elseif (!in_array($group, $wgImplicitGroups)) {
$grouplink = '<br />' . Linker::link(SpecialPage::getTitleFor('Listusers'), wfMsgHtml('listgrouprights-members'), array(), array('group' => $group), array('known', 'noclasses'));
} else {
// No link to Special:listusers for other implicit groups as they are unlistable
$grouplink = '';
}
$revoke = isset($wgRevokePermissions[$group]) ? $wgRevokePermissions[$group] : array();
$addgroups = isset($wgAddGroups[$group]) ? $wgAddGroups[$group] : array();
$removegroups = isset($wgRemoveGroups[$group]) ? $wgRemoveGroups[$group] : array();
$addgroupsSelf = isset($wgGroupsAddToSelf[$group]) ? $wgGroupsAddToSelf[$group] : array();
$removegroupsSelf = isset($wgGroupsRemoveFromSelf[$group]) ? $wgGroupsRemoveFromSelf[$group] : array();
$id = $group == '*' ? false : Sanitizer::escapeId($group);
$out->addHTML(Html::rawElement('tr', array('id' => $id), "\n\t\t\t\t<td>{$grouppage}{$grouplink}</td>\n\t\t\t\t\t<td>" . self::formatPermissions($permissions, $revoke, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf) . '</td>
'));
}
$out->addHTML(Xml::closeElement('table') . "\n<br /><hr />\n");
$out->wrapWikiMsg("<div class=\"mw-listgrouprights-key\">\n\$1\n</div>", 'listgrouprights-key');
}
示例10: createPage
protected function createPage($page, $text, $model = null)
{
if (is_string($page)) {
if (!preg_match('/:/', $page) && ($model === null || $model === CONTENT_MODEL_WIKITEXT)) {
$ns = $this->getDefaultWikitextNS();
$page = MWNamespace::getCanonicalName($ns) . ':' . $page;
}
$page = Title::newFromText($page);
}
if ($page instanceof Title) {
$page = new WikiPage($page);
}
if ($page->exists()) {
$page->doDeleteArticle("done");
}
$content = ContentHandler::makeContent($text, $page->getTitle(), $model);
$page->doEditContent($content, "testing", EDIT_NEW);
return $page;
}
示例11: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgNonincludableNamespaces;
$lib = array('loadSiteStats' => array($this, 'loadSiteStats'), 'getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !($wgNonincludableNamespaces && in_array($ns, $wgNonincludableNamespaces)), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->text();
self::$namespacesCache = $namespaces;
}
$info['namespaces'] = self::$namespacesCache;
if (self::$siteStatsLoaded) {
$stats = $this->loadSiteStats();
$info['stats'] = $stats[0];
}
$this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例12: register
function register()
{
global $wgContLang, $wgNamespaceAliases, $wgDisableCounters;
$lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap'));
$info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) {
$namespaces = array();
$namespacesByName = array();
foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
$canonical = MWNamespace::getCanonicalName($ns);
$namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array());
if ($ns >= NS_MAIN) {
$namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
$namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
$namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
} else {
$namespaces[$ns]['subject'] = $ns;
}
$namespacesByName[strtr($title, ' ', '_')] = $ns;
if ($canonical) {
$namespacesByName[$canonical] = $ns;
}
}
$aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
foreach ($aliases as $title => $ns) {
if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) {
$ct = count($namespaces[$ns]['aliases']);
$namespaces[$ns]['aliases'][$ct + 1] = $title;
$namespacesByName[$title] = $ns;
}
}
$namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text();
self::$namespacesCache = $namespaces;
self::$namespacesCacheLang = $wgContLang->getCode();
}
$info['namespaces'] = self::$namespacesCache;
$info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop'));
return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
}
示例13: SharedHelpArticleExists
/**
* does $title article exist @help.wikia?
*
* @see SharedHelpHook
*/
function SharedHelpArticleExists($title)
{
global $wgMemc, $wgSharedDB, $wgHelpWikiId;
wfProfileIn(__METHOD__);
$exists = false;
$sharedLinkKey = $wgSharedDB . ':sharedLinks:' . $wgHelpWikiId . ':' . MWNamespace::getCanonicalName($title->getNamespace()) . ':' . $title->getDBkey();
$sharedLink = $wgMemc->get($sharedLinkKey);
if ($sharedLink) {
$exists = true;
} else {
$sharedArticleKey = $wgSharedDB . ':sharedArticles:' . $wgHelpWikiId . ':' . MWNamespace::getCanonicalName($title->getNamespace()) . ':' . $title->getDBkey() . ':' . SHAREDHELP_CACHE_VERSION;
$sharedArticle = $wgMemc->get($sharedArticleKey);
if (!empty($sharedArticle['timestamp'])) {
$exists = true;
} else {
wfProfileIn(__METHOD__ . '::query');
$dbr = wfGetDB(DB_SLAVE, array(), WikiFactory::IDtoDB($wgHelpWikiId));
$res = $dbr->select('page', 'page_id', array('page_namespace' => NS_HELP, 'page_title' => $title->getDBkey()), __METHOD__);
if ($row = $dbr->fetchObject($res)) {
if (!empty($row->page_id)) {
$exists = true;
}
}
wfProfileOut(__METHOD__ . '::query');
}
if ($exists) {
$wgMemc->set($sharedLinkKey, true);
}
}
wfProfileOut(__METHOD__);
return $exists;
}
示例14: getGroupStats
private function getGroupStats()
{
global $wgGroupPermissions, $wgImplicitGroups;
$text = '';
foreach ($wgGroupPermissions as $group => $permissions) {
# Skip generic * and implicit groups
if (in_array($group, $wgImplicitGroups) || $group == '*') {
continue;
}
$groupname = htmlspecialchars($group);
$msg = $this->msg('group-' . $groupname);
if ($msg->isBlank()) {
$groupnameLocalized = $groupname;
} else {
$groupnameLocalized = $msg->text();
}
$msg = $this->msg('grouppage-' . $groupname)->inContentLanguage();
if ($msg->isBlank()) {
$grouppageLocalized = MWNamespace::getCanonicalName(NS_PROJECT) . ':' . $groupname;
} else {
$grouppageLocalized = $msg->text();
}
$linkTarget = Title::newFromText($grouppageLocalized);
$grouppage = Linker::link($linkTarget, htmlspecialchars($groupnameLocalized));
$grouplink = Linker::linkKnown(SpecialPage::getTitleFor('Listusers'), $this->msg('listgrouprights-members')->escaped(), array(), array('group' => $group));
# Add a class when a usergroup contains no members to allow hiding these rows
$classZero = '';
$countUsers = SiteStats::numberingroup($groupname);
if ($countUsers == 0) {
$classZero = ' statistics-group-zero';
}
$text .= $this->formatRow($grouppage . ' ' . $grouplink, $this->getLanguage()->formatNum($countUsers), array('class' => 'statistics-group-' . Sanitizer::escapeClass($group) . $classZero));
}
return $text;
}
示例15: formatLinksInComment
/**
* Formats wiki links and media links in text; all other wiki formatting
* is ignored
*
* @todo FIXME: Doesn't handle sub-links as in image thumb texts like the main parser
* @param string $comment Text to format links in. WARNING! Since the output of this
* function is html, $comment must be sanitized for use as html. You probably want
* to pass $comment through Sanitizer::escapeHtmlAllowEntities() before calling
* this function.
* @param Title|null $title An optional title object used to links to sections
* @param bool $local Whether section links should refer to local page
* @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
* as used by WikiMap.
*
* @return string
*/
public static function formatLinksInComment($comment, $title = null, $local = false, $wikiId = null)
{
return preg_replace_callback('/
\\[\\[
:? # ignore optional leading colon
([^\\]|]+) # 1. link target; page names cannot include ] or |
(?:\\|
# 2. a pipe-separated substring; only the last is captured
# Stop matching at | and ]] without relying on backtracking.
((?:]?[^\\]|])*+)
)*
\\]\\]
([^[]*) # 3. link trail (the text up until the next link)
/x', function ($match) use($title, $local, $wikiId) {
global $wgContLang;
$medians = '(?:' . preg_quote(MWNamespace::getCanonicalName(NS_MEDIA), '/') . '|';
$medians .= preg_quote($wgContLang->getNsText(NS_MEDIA), '/') . '):';
$comment = $match[0];
# fix up urlencoded title texts (copied from Parser::replaceInternalLinks)
if (strpos($match[1], '%') !== false) {
$match[1] = strtr(rawurldecode($match[1]), array('<' => '<', '>' => '>'));
}
# Handle link renaming [[foo|text]] will show link as "text"
if ($match[2] != "") {
$text = $match[2];
} else {
$text = $match[1];
}
$submatch = array();
$thelink = null;
if (preg_match('/^' . $medians . '(.*)$/i', $match[1], $submatch)) {
# Media link; trail not supported.
$linkRegexp = '/\\[\\[(.*?)\\]\\]/';
$title = Title::makeTitleSafe(NS_FILE, $submatch[1]);
if ($title) {
$thelink = Linker::makeMediaLinkObj($title, $text);
}
} else {
# Other kind of link
if (preg_match($wgContLang->linkTrail(), $match[3], $submatch)) {
$trail = $submatch[1];
} else {
$trail = "";
}
$linkRegexp = '/\\[\\[(.*?)\\]\\]' . preg_quote($trail, '/') . '/';
if (isset($match[1][0]) && $match[1][0] == ':') {
$match[1] = substr($match[1], 1);
}
list($inside, $trail) = Linker::splitTrail($trail);
$linkText = $text;
$linkTarget = Linker::normalizeSubpageLink($title, $match[1], $linkText);
$target = Title::newFromText($linkTarget);
if ($target) {
if ($target->getText() == '' && !$target->isExternal() && !$local && $title) {
$newTarget = clone $title;
$newTarget->setFragment('#' . $target->getFragment());
$target = $newTarget;
}
$thelink = Linker::makeCommentLink($target, $linkText . $inside, $wikiId) . $trail;
}
}
if ($thelink) {
// If the link is still valid, go ahead and replace it in!
$comment = preg_replace($linkRegexp, StringUtils::escapeRegexReplacement($thelink), $comment, 1);
}
return $comment;
}, $comment);
}