本文整理汇总了PHP中MWNamespace::hasSubpages方法的典型用法代码示例。如果您正苦于以下问题:PHP MWNamespace::hasSubpages方法的具体用法?PHP MWNamespace::hasSubpages怎么用?PHP MWNamespace::hasSubpages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MWNamespace
的用法示例。
在下文中一共展示了MWNamespace::hasSubpages方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
示例2: canBeUsedOn
/**
* @param $title Title of page to check
* @return bool
*/
public function canBeUsedOn(Title $title)
{
global $wgCollaborationHubAllowedNamespaces;
$namespace = $title->getNamespace();
if (in_array($namespace, array_keys(array_filter($wgCollaborationHubAllowedNamespaces))) && MWNamespace::hasSubpages($namespace)) {
return true;
}
return false;
}
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:13,代码来源:CollaborationHubContentHandler.php
示例3: cdbfGetMainSubpage
function cdbfGetMainSubpage($title)
{
if ($title->getNamespace() != NS_MAIN) {
return true;
}
if (!MWNamespace::hasSubpages($title->getNamespace())) {
return true;
}
$parts = explode('/', $title->getText());
return $parts[0];
}
示例4: setTitlesDefault
private function setTitlesDefault()
{
$ns = $this->title->getNamespace();
$titles = array();
if (!MWNamespace::hasSubpages($ns)) {
$titles[] = $this->title;
} else {
$explosion = explode('/', $this->title->getText());
$text = '';
foreach ($explosion as $atom) {
$text .= $atom;
$titles[] = Title::newFromText($text, $ns);
$text .= '/';
}
}
$this->titles = $titles;
}
示例5: onGetDefaultSortkey
/**
* The GetDefaultSortkey hook.
* Basically prefixes the normal sortkey with some of the subpage
* parts of the current title.
*
* Example, if configured with "1,3..5,7" and given the
* page 0/1/2/3/4/5/6/7/8 it would prefix the sortkey with
* 1/3/4/5/7. Adding it to the normal sortkey,
* resulting in "0/1/3/4/5/7\n0/1/2/3/4/5/6/7/8".
* From there it might be further prefixed with whatever the
* {{DEFUALTSORT for a page is.
*
* Another example: Configuration -3..-1 turns 1/2/3/4/5 -> 3/4
* and -3.. turns 1/2/3/4/5 -> 3/4/5
*/
public static function onGetDefaultSortkey( $title, &$unprefixed ) {
global $wgSubpageSortkeyDefault,
$wgSubpageSortkeyByNamespace,
$wgSubpageSortkeyIfNoSubpageUseFullName;
$newSortkey = array();
$ns = $title->getNamespace();
if ( !MWNamespace::hasSubpages( $ns ) ) {
// Do nothing
return true;
}
if ( isset( $wgSubpageSortkeyByNamespace[$ns] ) ) {
$descript = $wgSubpageSortkeyByNamespace[$ns];
} else {
$descript = $wgSubpageSortkeyDefault;
}
$elms = explode( ',', $descript );
foreach( $elms as $item ) {
$ranges = explode( '..', $item, 2 );
$start = intval( $ranges[0] );
if ( count( $ranges ) === 1 ) {
$count = 1;
} elseif ( $ranges[1] === '' ) {
$count = false;
} else {
$count = intval( $ranges[1] );
}
$newSortkey = array_merge( $newSortkey,
self::getSubpage( $start, $count, $title ) );
}
$newPrefix = implode( '/', $newSortkey );
// Don't prefix an extra \n if the prefix is empty.
if ( $newPrefix !== ''
|| !$wgSubpageSortkeyIfNoSubpageUseFullName
) {
$unprefixed = $newPrefix . "\n" . $unprefixed;
}
return true;
}
示例6: execute
public function execute()
{
global $wgLang, $wgParser;
$provided = $this->getArg(0);
$namespace = $wgLang->getNsIndex($provided);
if (!$namespace) {
$this->error("Invalid namespace provided: {$provided}");
return;
}
$namespaceName = $wgLang->getNsText($namespace);
if (!MWNamespace::hasSubpages($namespace)) {
$this->error("Subpages are not enabled in the {$namespaceName} namespace.");
$this->error("In order to convert this namespace to Flow, you must enable subpages using:");
$this->error("\$wgNamespacesWithSubpages[{$namespace}] = true;");
return;
}
$noConvertTemplates = explode(',', $this->getOption('no-convert-templates', ''));
if ($noConvertTemplates === array('')) {
// explode( ',', '' ) returns array( '' )
$noConvertTemplates = array();
}
// Convert to Title objects
foreach ($noConvertTemplates as &$template) {
$title = Title::newFromText($template, NS_TEMPLATE);
if (!$title) {
$this->error("Invalid template name: {$template}");
return;
}
$template = $title;
}
// @todo send to prod logger?
$logger = new MaintenanceDebugLogger($this);
$dbw = wfGetDB(DB_MASTER);
$converter = new \Flow\Import\Converter($dbw, Flow\Container::get('importer'), $logger, FlowHooks::getOccupationController()->getTalkpageManager(), new Flow\Import\Wikitext\ConversionStrategy($wgParser, new Flow\Import\NullImportSourceStore(), $logger, $noConvertTemplates, $this->getOption('archive-pattern', null)));
$logger->info("Starting conversion of {$namespaceName} namespace");
// Iterate over all existing pages of the namespace.
$it = new NamespaceIterator($dbw, $namespace);
// NamespaceIterator is an IteratorAggregate. Get an Iterator
// so we can wrap that.
$it = $it->getIterator();
$converter->convertAll($it);
$logger->info("Finished conversion of {$namespaceName} namespace");
}
示例7: 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);
}
示例8: 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);
}
示例9: subPageSubtitle
/**
* @return string
*/
function subPageSubtitle()
{
global $wgLang;
$out = $this->getOutput();
$subpages = '';
if (!wfRunHooks('SkinSubPageSubtitle', array(&$subpages, $this, $out))) {
return $subpages;
}
if ($out->isArticle() && MWNamespace::hasSubpages($out->getTitle()->getNamespace())) {
$ptext = $this->getTitle()->getPrefixedText();
if (preg_match('/\\//', $ptext)) {
$links = explode('/', $ptext);
array_pop($links);
$c = 0;
$growinglink = '';
$display = '';
foreach ($links as $link) {
$growinglink .= $link;
$display .= $link;
$linkObj = Title::newFromText($growinglink);
if (is_object($linkObj) && $linkObj->isKnown()) {
$getlink = Linker::linkKnown($linkObj, htmlspecialchars($display));
$c++;
if ($c > 1) {
$subpages .= $wgLang->getDirMarkEntity() . $this->msg('pipe-separator')->escaped();
} else {
$subpages .= '< ';
}
$subpages .= $getlink;
$display = '';
} else {
$display .= '/';
}
$growinglink .= '/';
}
}
}
return $subpages;
}
示例10: moveSubpages
/**
* Move this page's subpages to be subpages of $nt
*
* @param $nt Title Move target
* @param $auth bool Whether $wgUser's permissions should be checked
* @param $reason string The reason for the move
* @param $createRedirect bool Whether to create redirects from the old subpages to
* the new ones Ignored if the user doesn't have the 'suppressredirect' right
* @return mixed array with old page titles as keys, and strings (new page titles) or
* arrays (errors) as values, or an error array with numeric indices if no pages
* were moved
*/
public function moveSubpages($nt, $auth = true, $reason = '', $createRedirect = true)
{
global $wgMaximumMovedPages;
// Check permissions
if (!$this->userCan('move-subpages')) {
return array('cant-move-subpages');
}
// Do the source and target namespaces support subpages?
if (!MWNamespace::hasSubpages($this->getNamespace())) {
return array('namespace-nosubpages', MWNamespace::getCanonicalName($this->getNamespace()));
}
if (!MWNamespace::hasSubpages($nt->getNamespace())) {
return array('namespace-nosubpages', MWNamespace::getCanonicalName($nt->getNamespace()));
}
$subpages = $this->getSubpages($wgMaximumMovedPages + 1);
$retval = array();
$count = 0;
foreach ($subpages as $oldSubpage) {
$count++;
if ($count > $wgMaximumMovedPages) {
$retval[$oldSubpage->getPrefixedTitle()] = array('movepage-max-pages', $wgMaximumMovedPages);
break;
}
// We don't know whether this function was called before
// or after moving the root page, so check both
// $this and $nt
if ($oldSubpage->getArticleId() == $this->getArticleId() || $oldSubpage->getArticleID() == $nt->getArticleId()) {
// When moving a page to a subpage of itself,
// don't move it twice
continue;
}
$newPageName = preg_replace('#^' . preg_quote($this->getDBkey(), '#') . '#', StringUtils::escapeRegexReplacement($nt->getDBkey()), $oldSubpage->getDBkey());
if ($oldSubpage->isTalkPage()) {
$newNs = $nt->getTalkPage()->getNamespace();
} else {
$newNs = $nt->getSubjectPage()->getNamespace();
}
# Bug 14385: we need makeTitleSafe because the new page names may
# be longer than 255 characters.
$newSubpage = Title::makeTitleSafe($newNs, $newPageName);
$success = $oldSubpage->moveTo($newSubpage, $auth, $reason, $createRedirect);
if ($success === true) {
$retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
} else {
$retval[$oldSubpage->getPrefixedText()] = $success;
}
}
return $retval;
}
示例11: showSubpages
function showSubpages($title, $out)
{
global $wgLang;
if (!MWNamespace::hasSubpages($title->getNamespace())) {
return;
}
$subpages = $title->getSubpages();
$count = $subpages instanceof TitleArray ? $subpages->count() : 0;
$out->wrapWikiMsg('== $1 ==', array('movesubpage', $count));
# No subpages.
if ($count == 0) {
$out->addWikiMsg('movenosubpage');
return;
}
$out->addWikiMsg('movesubpagetext', $wgLang->formatNum($count));
$skin = $this->getSkin();
$out->addHTML("<ul>\n");
foreach ($subpages as $subpage) {
$link = $skin->link($subpage);
$out->addHTML("<li>{$link}</li>\n");
}
$out->addHTML("</ul>\n");
}
示例12: showHeader
protected function showHeader()
{
global $wgOut, $wgUser, $wgMaxArticleSize, $wgLang;
if ($this->mTitle->isTalkPage()) {
$wgOut->addWikiMsg('talkpagetext');
}
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-' . $this->mTitle->getNamespace();
$editnotice_ns_message = wfMessage($editnotice_ns)->inContentLanguage();
if ($editnotice_ns_message->exists()) {
$wgOut->addWikiText($editnotice_ns_message->plain());
}
if (MWNamespace::hasSubpages($this->mTitle->getNamespace())) {
$parts = explode('/', $this->mTitle->getDBkey());
$editnotice_base = $editnotice_ns;
while (count($parts) > 0) {
$editnotice_base .= '-' . array_shift($parts);
$editnotice_base_msg = wfMessage($editnotice_base)->inContentLanguage();
if ($editnotice_base_msg->exists()) {
$wgOut->addWikiText($editnotice_base_msg->plain());
}
}
} else {
# Even if there are no subpages in namespace, we still don't want / in MW ns.
$editnoticeText = $editnotice_ns . '-' . str_replace('/', '-', $this->mTitle->getDBkey());
$editnoticeMsg = wfMessage($editnoticeText)->inContentLanguage();
if ($editnoticeMsg->exists()) {
$wgOut->addWikiText($editnoticeMsg->plain());
}
}
if ($this->isConflict) {
$wgOut->wrapWikiMsg("<div class='mw-explainconflict'>\n\$1\n</div>", 'explainconflict');
$this->edittime = $this->mArticle->getTimestamp();
} else {
if ($this->section != '' && !$this->isSectionEditSupported()) {
// We use $this->section to much before this and getVal('wgSection') directly in other places
// at this point we can't reset $this->section to '' to fallback to non-section editing.
// Someone is welcome to try refactoring though
$wgOut->showErrorPage('sectioneditnotsupported-title', 'sectioneditnotsupported-text');
return false;
}
if ($this->section != '' && $this->section != 'new') {
if (!$this->summary && !$this->preview && !$this->diff) {
$sectionTitle = self::extractSectionTitle($this->textbox1);
if ($sectionTitle !== false) {
$this->summary = "/* {$sectionTitle} */ ";
}
}
}
if ($this->missingComment) {
$wgOut->wrapWikiMsg("<div id='mw-missingcommenttext'>\n\$1\n</div>", 'missingcommenttext');
}
if ($this->missingSummary && $this->section != 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingsummary'>\n\$1\n</div>", 'missingsummary');
}
if ($this->missingSummary && $this->section == 'new') {
$wgOut->wrapWikiMsg("<div id='mw-missingcommentheader'>\n\$1\n</div>", 'missingcommentheader');
}
if ($this->hookError !== '') {
$wgOut->addWikiText($this->hookError);
}
if (!$this->checkUnicodeCompliantBrowser()) {
$wgOut->addWikiMsg('nonunicodebrowser');
}
if ($this->section != 'new') {
$revision = $this->mArticle->getRevisionFetched();
if ($revision) {
// Let sysop know that this will make private content public if saved
if (!$revision->userCan(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-permission');
} elseif ($revision->isDeleted(Revision::DELETED_TEXT)) {
$wgOut->wrapWikiMsg("<div class='mw-warning plainlinks'>\n\$1\n</div>\n", 'rev-deleted-text-view');
}
if (!$revision->isCurrent()) {
$this->mArticle->setOldSubtitle($revision->getId());
$wgOut->addWikiMsg('editingold');
}
} elseif ($this->mTitle->exists()) {
// Something went wrong
$wgOut->wrapWikiMsg("<div class='errorbox'>\n\$1\n</div>\n", array('missing-article', $this->mTitle->getPrefixedText(), wfMsgNoTrans('missingarticle-rev', $this->oldid)));
}
}
}
if (wfReadOnly()) {
$wgOut->wrapWikiMsg("<div id=\"mw-read-only-warning\">\n\$1\n</div>", array('readonlywarning', wfReadOnlyReason()));
} elseif ($wgUser->isAnon()) {
if ($this->formtype != 'preview') {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-edit-warning\">\n\$1</div>", 'anoneditwarning');
} else {
$wgOut->wrapWikiMsg("<div id=\"mw-anon-preview-warning\">\n\$1</div>", 'anonpreviewwarning');
}
} else {
if ($this->isCssJsSubpage) {
# Check the skin exists
if ($this->isWrongCaseCssJsPage) {
$wgOut->wrapWikiMsg("<div class='error' id='mw-userinvalidcssjstitle'>\n\$1\n</div>", array('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage()));
}
if ($this->getTitle()->isSubpageOf($wgUser->getUserPage())) {
if ($this->formtype !== 'preview') {
if ($this->isCssSubpage) {
//.........这里部分代码省略.........
示例13: pageCounts
/**
* Returns page counts that would be too "expensive" to retrieve by normal means.
*
* @param Title $title Title to get counts for
* @return array
*/
protected function pageCounts(Title $title)
{
$id = $title->getArticleID();
$config = $this->context->getConfig();
$dbrWatchlist = wfGetDB(DB_SLAVE, 'watchlist');
$result = array();
// Number of page watchers
$watchers = (int) $dbrWatchlist->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey()), __METHOD__);
$result['watchers'] = $watchers;
if ($config->get('ShowUpdatedMarker')) {
// Threshold: last visited about 26 weeks before latest edit
$updated = wfTimestamp(TS_UNIX, $this->page->getTimestamp());
$age = $config->get('WatchersMaxAge');
$threshold = $dbrWatchlist->timestamp($updated - $age);
// Number of page watchers who also visited a "recent" edit
$visitingWatchers = (int) $dbrWatchlist->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $title->getNamespace(), 'wl_title' => $title->getDBkey(), 'wl_notificationtimestamp >= ' . $dbrWatchlist->addQuotes($threshold) . ' OR wl_notificationtimestamp IS NULL'), __METHOD__);
$result['visitingWatchers'] = $visitingWatchers;
}
$dbr = wfGetDB(DB_SLAVE);
// Total number of edits
$edits = (int) $dbr->selectField('revision', 'COUNT(*)', array('rev_page' => $id), __METHOD__);
$result['edits'] = $edits;
// Total number of distinct authors
if ($config->get('MiserMode')) {
$result['authors'] = 0;
} else {
$result['authors'] = (int) $dbr->selectField('revision', 'COUNT(DISTINCT rev_user_text)', array('rev_page' => $id), __METHOD__);
}
// "Recent" threshold defined by RCMaxAge setting
$threshold = $dbr->timestamp(time() - $config->get('RCMaxAge'));
// Recent number of edits
$edits = (int) $dbr->selectField('revision', 'COUNT(rev_page)', array('rev_page' => $id, "rev_timestamp >= " . $dbr->addQuotes($threshold)), __METHOD__);
$result['recent_edits'] = $edits;
// Recent number of distinct authors
$result['recent_authors'] = (int) $dbr->selectField('revision', 'COUNT(DISTINCT rev_user_text)', array('rev_page' => $id, "rev_timestamp >= " . $dbr->addQuotes($threshold)), __METHOD__);
// Subpages (if enabled)
if (MWNamespace::hasSubpages($title->getNamespace())) {
$conds = array('page_namespace' => $title->getNamespace());
$conds[] = 'page_title ' . $dbr->buildLike($title->getDBkey() . '/', $dbr->anyString());
// Subpages of this page (redirects)
$conds['page_is_redirect'] = 1;
$result['subpages']['redirects'] = (int) $dbr->selectField('page', 'COUNT(page_id)', $conds, __METHOD__);
// Subpages of this page (non-redirects)
$conds['page_is_redirect'] = 0;
$result['subpages']['nonredirects'] = (int) $dbr->selectField('page', 'COUNT(page_id)', $conds, __METHOD__);
// Subpages of this page (total)
$result['subpages']['total'] = $result['subpages']['redirects'] + $result['subpages']['nonredirects'];
}
// Counts for the number of transclusion links (to/from)
if ($config->get('MiserMode')) {
$result['transclusion']['to'] = 0;
} else {
$result['transclusion']['to'] = (int) $dbr->selectField('templatelinks', 'COUNT(tl_from)', array('tl_namespace' => $title->getNamespace(), 'tl_title' => $title->getDBkey()), __METHOD__);
}
$result['transclusion']['from'] = (int) $dbr->selectField('templatelinks', 'COUNT(*)', array('tl_from' => $title->getArticleID()), __METHOD__);
return $result;
}
示例14: getEditNotices
/**
* Get a list of rendered edit notices for this page.
*
* Array is keyed by the original message key, and values are rendered using parseAsBlock, so
* they will already be wrapped in paragraphs.
*
* @since 1.21
* @param int $oldid Revision ID that's being edited
* @return array
*/
public function getEditNotices($oldid = 0)
{
$notices = array();
# Optional notices on a per-namespace and per-page basis
$editnotice_ns = 'editnotice-' . $this->getNamespace();
$editnotice_ns_message = wfMessage($editnotice_ns);
if ($editnotice_ns_message->exists()) {
$notices[$editnotice_ns] = $editnotice_ns_message->parseAsBlock();
}
if (MWNamespace::hasSubpages($this->getNamespace())) {
$parts = explode('/', $this->getDBkey());
$editnotice_base = $editnotice_ns;
while (count($parts) > 0) {
$editnotice_base .= '-' . array_shift($parts);
$editnotice_base_msg = wfMessage($editnotice_base);
if ($editnotice_base_msg->exists()) {
$notices[$editnotice_base] = $editnotice_base_msg->parseAsBlock();
}
}
} else {
# Even if there are no subpages in namespace, we still don't want / in MW ns.
$editnoticeText = $editnotice_ns . '-' . str_replace('/', '-', $this->getDBkey());
$editnoticeMsg = wfMessage($editnoticeText);
if ($editnoticeMsg->exists()) {
$notices[$editnoticeText] = $editnoticeMsg->parseAsBlock();
}
}
wfRunHooks('TitleGetEditNotices', array($this, $oldid, &$notices));
return $notices;
}
示例15: getParentHub
/**
* Find the parent hub, if any.
* Returns the first CollaborationHub Title found, even if more are higher up, or null if none
* @param $title Title to start looking from
* @return Title|null
*/
public static function getParentHub(Title $title)
{
global $wgCollaborationHubAllowedNamespaces;
$namespace = $title->getNamespace();
if (MWNamespace::hasSubpages($namespace) && in_array($namespace, array_keys(array_filter($wgCollaborationHubAllowedNamespaces)))) {
$parentTitle = $title->getBaseTitle();
while (!$title->equals($parentTitle)) {
$parentRev = Revision::newFromTitle($parentTitle);
if ($parentTitle->getContentModel() == 'CollaborationHubContent' && isset($parentRev)) {
return $parentTitle;
}
// keep looking
$title = $parentTitle;
}
}
// Nothing was found
return null;
}