MediaWiki master
CategoryViewer.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Category;
10
11use Collation;
12use InvalidArgumentException;
13use MediaWiki\Cache\LinkCache;
16use MediaWiki\Debug\DeprecationHelper;
19use MediaWiki\HookContainer\ProtectedHookAccessorTrait;
32
34 use ProtectedHookAccessorTrait;
35 use DeprecationHelper;
36
38 public $limit;
39
41 public $from;
42
44 public $until;
45
47 public $articles;
48
51
53 public $children;
54
57
60
63
66
68 public $nextPage;
69
71 protected $prevPage;
72
74 public $flip;
75
77 protected $page;
78
80 public $collation;
81
83 public $gallery;
84
86 private $cat;
87
89 private $query;
90
92 private $languageConverter;
93
103 public function __construct( PageIdentity $page, IContextSource $context, array $from = [],
104 array $until = [], array $query = []
105 ) {
106 $this->page = $page;
107
108 $this->deprecatePublicPropertyFallback(
109 'title',
110 '1.37',
111 function (): Title {
112 return Title::newFromPageIdentity( $this->page );
113 },
114 function ( PageIdentity $page ) {
115 $this->page = $page;
116 }
117 );
118
119 $this->setContext( $context );
120 $this->getOutput()->addModuleStyles( [
121 'mediawiki.action.styles',
122 ] );
123 $this->from = $from;
124 $this->until = $until;
125 $this->limit = $context->getConfig()->get( MainConfigNames::CategoryPagingLimit );
126 $this->cat = Category::newFromTitle( $page );
127 $this->query = $query;
128 $this->collation = MediaWikiServices::getInstance()->getCollationFactory()->getCategoryCollation();
129 $this->languageConverter = MediaWikiServices::getInstance()
130 ->getLanguageConverterFactory()->getLanguageConverter();
131 unset( $this->query['title'] );
132 }
133
139 public function getHTML() {
140 $this->showGallery = $this->getConfig()->get( MainConfigNames::CategoryMagicGallery )
141 && !$this->getOutput()->getOutputFlag( ParserOutputFlags::NO_GALLERY );
142
143 $this->clearCategoryState();
144 $this->doCategoryQuery();
145 $this->finaliseCategoryState();
146
147 $html = $this->getSubcategorySection() .
148 $this->getPagesSection() .
149 $this->getImageSection();
150
151 if ( $html == '' ) {
152 // If there is no category content to display, only
153 // show the top part of the navigation links.
154 // @todo FIXME: Cannot be completely suppressed because it
155 // is unknown if 'until' or 'from' makes this
156 // give 0 results.
157 $html = $this->getCategoryTop();
158 } else {
159 $html = $this->getCategoryTop() .
160 $html .
161 $this->getCategoryBottom();
162 }
163
164 // Give a proper message if category is empty
165 if ( $html == '' ) {
166 $html = $this->msg( 'category-empty' )->parseAsBlock();
167 }
168
169 $lang = $this->getLanguage();
170 $attribs = [
171 'class' => 'mw-category-generated',
172 'lang' => $lang->getHtmlCode(),
173 'dir' => $lang->getDir()
174 ];
175 # put a div around the headings which are in the user language
176 $html = Html::rawElement( 'div', $attribs, $html );
177
178 return $html;
179 }
180
181 protected function clearCategoryState() {
182 $this->articles = [];
183 $this->articles_start_char = [];
184 $this->children = [];
185 $this->children_start_char = [];
186 if ( $this->showGallery ) {
187 // Note that null for mode is taken to mean use default.
188 $mode = $this->getRequest()->getVal( 'gallerymode', null );
189 try {
190 $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
192 // User specified something invalid, fallback to default.
193 $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
194 }
195
196 $this->gallery->setHideBadImages();
197 } else {
198 $this->imgsNoGallery = [];
199 $this->imgsNoGallery_start_char = [];
200 }
201 }
202
209 public function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
210 $page = $cat->getPage();
211 if ( !$page ) {
212 return;
213 }
214
215 // Subcategory; strip the 'Category' namespace from the link text.
216 $pageRecord = MediaWikiServices::getInstance()->getPageStore()
217 ->getPageByReference( $page );
218 if ( !$pageRecord ) {
219 return;
220 }
221
222 $this->children[] = $this->generateLink(
223 'subcat',
224 $pageRecord,
225 $pageRecord->isRedirect(),
226 htmlspecialchars( str_replace( '_', ' ', $pageRecord->getDBkey() ) )
227 );
228
229 $this->children_start_char[] =
230 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
231 }
232
244 private function generateLink(
245 string $type, PageReference $page, bool $isRedirect, ?string $html = null
246 ): string {
247 $link = null;
248 $legacyTitle = MediaWikiServices::getInstance()->getTitleFactory()
249 ->newFromPageReference( $page );
250 // @phan-suppress-next-line PhanTypeMismatchArgument Type mismatch on pass-by-ref args
251 $this->getHookRunner()->onCategoryViewer__generateLink( $type, $legacyTitle, $html, $link );
252 if ( $link === null ) {
253 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
254 if ( $html !== null ) {
255 $html = new HtmlArmor( $html );
256 }
257 $link = $linkRenderer->makeLink( $page, $html );
258 }
259 if ( $isRedirect ) {
260 $link = Html::rawElement(
261 'span',
262 [ 'class' => 'redirect-in-category' ],
263 $link
264 );
265 }
266
267 return $link;
268 }
269
278 public function getSubcategorySortChar( PageIdentity $page, string $sortkey ): string {
279 wfDeprecated( __METHOD__, '1.45' );
280 $firstChar = $this->collation->getFirstLetter( $sortkey );
281
282 return $this->languageConverter->convert( $firstChar );
283 }
284
292 public function addImage(
293 PageReference $page, string $sortkey, int $pageLength, bool $isRedirect = false
294 ): void {
295 $title = MediaWikiServices::getInstance()->getTitleFactory()
296 ->newFromPageReference( $page );
297 if ( $this->showGallery ) {
298 $flip = $this->flip['file'];
299 if ( $flip ) {
300 $this->gallery->insert( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
301 } else {
302 $this->gallery->add( $title, '', '', '', [], ImageGalleryBase::LOADING_LAZY );
303 }
304 } else {
305 $this->imgsNoGallery[] = $this->generateLink( 'image', $page, $isRedirect );
306
307 $this->imgsNoGallery_start_char[] =
308 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
309 }
310 }
311
319 public function addPage(
320 PageReference $page,
321 string $sortkey,
322 int $pageLength,
323 bool $isRedirect = false
324 ): void {
325 $this->articles[] = $this->generateLink( 'page', $page, $isRedirect );
326
327 $this->articles_start_char[] =
328 $this->languageConverter->convert( $this->collation->getFirstLetter( $sortkey ) );
329 }
330
331 protected function finaliseCategoryState() {
332 if ( $this->flip['subcat'] ) {
333 $this->children = array_reverse( $this->children );
334 $this->children_start_char = array_reverse( $this->children_start_char );
335 }
336 if ( $this->flip['page'] ) {
337 $this->articles = array_reverse( $this->articles );
338 $this->articles_start_char = array_reverse( $this->articles_start_char );
339 }
340 if ( !$this->showGallery && $this->flip['file'] ) {
341 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
342 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
343 }
344 }
345
346 protected function doCategoryQuery() {
347 $dbr = MediaWikiServices::getInstance()->getConnectionProvider()->getReplicaDatabase();
348
349 $this->nextPage = [
350 'page' => null,
351 'subcat' => null,
352 'file' => null,
353 ];
354 $this->prevPage = [
355 'page' => null,
356 'subcat' => null,
357 'file' => null,
358 ];
359
360 $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
361
362 foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
363 # Get the sortkeys for start/end, if applicable. Note that if
364 # the collation in the database differs from the one
365 # set in $wgCategoryCollation, pagination might go totally haywire.
366 $extraConds = [ 'cl_type' => $type ];
367 if ( isset( $this->from[$type] ) ) {
368 $extraConds[] = $dbr->expr(
369 'cl_sortkey',
370 '>=',
371 $this->collation->getSortKey( $this->from[$type] )
372 );
373 } elseif ( isset( $this->until[$type] ) ) {
374 $extraConds[] = $dbr->expr(
375 'cl_sortkey',
376 '<',
377 $this->collation->getSortKey( $this->until[$type] )
378 );
379 $this->flip[$type] = true;
380 }
381
382 $queryBuilder = $dbr->newSelectQueryBuilder();
383 $queryBuilder->select( array_merge(
384 LinkCache::getSelectFields(),
385 [
386 'cl_sortkey',
387 'cat_id',
388 'cat_title',
389 'cat_subcats',
390 'cat_pages',
391 'cat_files',
392 'cl_sortkey_prefix',
393 'collation_name',
394 ]
395 ) )
396 ->from( 'page' )
397 ->andWhere( $extraConds );
398
399 if ( $this->flip[$type] ) {
400 $queryBuilder->orderBy( 'cl_sortkey', SelectQueryBuilder::SORT_DESC );
401 } else {
402 $queryBuilder->orderBy( 'cl_sortkey' );
403 }
404
405 $queryBuilder
406 ->join( 'categorylinks', null, [ 'cl_from = page_id' ] )
407 ->join( 'linktarget', null, 'cl_target_id = lt_id' )
408 ->straightJoin( 'collation', null, 'cl_collation_id = collation_id' )
409 ->where( [ 'lt_title' => $this->page->getDBkey(), 'lt_namespace' => NS_CATEGORY ] )
410 ->leftJoin( 'category', null, [
411 'cat_title = page_title',
412 'page_namespace' => NS_CATEGORY
413 ] )
414 ->useIndex( [ 'categorylinks' => 'cl_sortkey_id' ] )
415 ->limit( $this->limit + 1 );
416
417 $res = $queryBuilder->caller( __METHOD__ )->fetchResultSet();
418
419 $this->getHookRunner()->onCategoryViewer__doCategoryQuery( $type, $res );
420 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
421
422 $count = 0;
423 foreach ( $res as $row ) {
424 $title = Title::newFromRow( $row );
425 $linkCache->addGoodLinkObjFromRow( $title, $row );
426 $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
427
428 if ( ++$count > $this->limit ) {
429 # We've reached the one extra which shows that there
430 # are additional pages to be had. Stop here...
431 $this->nextPage[$type] = $humanSortkey;
432 break;
433 }
434 if ( $count == $this->limit ) {
435 $this->prevPage[$type] = $humanSortkey;
436 }
437
438 if ( $title->getNamespace() === NS_CATEGORY ) {
439 $cat = Category::newFromRow( $row, $title );
440 $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
441 } elseif ( $title->getNamespace() === NS_FILE ) {
442 $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
443 } else {
444 $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
445 }
446 }
447 }
448 }
449
453 protected function getCategoryTop() {
454 $html = $this->getCategoryBottom();
455 return $html === ''
456 ? $html
457 : "<br style=\"clear:both;\"/>\n" . $html;
458 }
459
463 protected function getSubcategorySection() {
464 # Don't show subcategories section if there are none.
465 $html = '';
466 $localCount = count( $this->children );
467 $databaseCount = $this->cat->getSubcatCount();
468 // This function should be called even if the result isn't used, it has side-effects
469 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'subcat' );
470
471 if ( $localCount > 0 ) {
472 $html .= Html::openElement( 'div', [ 'id' => 'mw-subcategories' ] ) . "\n";
473 $html .= Html::rawElement( 'h2', [], $this->msg( 'subcategories' )->parse() ) . "\n";
474 $html .= $countMessage;
475 $html .= $this->getSectionPagingLinks( 'subcat' );
476 $html .= $this->formatList( $this->children, $this->children_start_char );
477 $html .= $this->getSectionPagingLinks( 'subcat' );
478 $html .= "\n" . Html::closeElement( 'div' );
479 }
480 return $html;
481 }
482
486 protected function getPagesSection() {
487 $name = $this->getOutput()->getUnprefixedDisplayTitle();
488 # Don't show articles section if there are none.
489 $html = '';
490
491 # @todo FIXME: Here and in the other two sections: we don't need to bother
492 # with this rigmarole if the entire category contents fit on one page
493 # and have already been retrieved. We can just use $rescnt in that
494 # case and save a query and some logic.
495 $databaseCount = $this->cat->getPageCount( Category::COUNT_CONTENT_PAGES );
496 $localCount = count( $this->articles );
497 // This function should be called even if the result isn't used, it has side-effects
498 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'article' );
499
500 if ( $localCount > 0 ) {
501 $html .= Html::openElement( 'div', [ 'id' => 'mw-pages' ] ) . "\n";
502 $html .= Html::rawElement(
503 'h2',
504 [],
505 $this->msg( 'category_header' )->rawParams( $name )->parse()
506 ) . "\n";
507 $html .= $countMessage;
508 $html .= $this->getSectionPagingLinks( 'page' );
509 $html .= $this->formatList( $this->articles, $this->articles_start_char );
510 $html .= $this->getSectionPagingLinks( 'page' );
511 $html .= "\n" . Html::closeElement( 'div' );
512 }
513 return $html;
514 }
515
519 protected function getImageSection() {
520 $name = $this->getOutput()->getUnprefixedDisplayTitle();
521 $html = '';
522 $localCount = $this->showGallery ?
523 $this->gallery->count() :
524 count( $this->imgsNoGallery ?? [] );
525 $databaseCount = $this->cat->getFileCount();
526 // This function should be called even if the result isn't used, it has side-effects
527 $countMessage = $this->getCountMessage( $localCount, $databaseCount, 'file' );
528
529 if ( $localCount > 0 ) {
530 $html .= Html::openElement( 'div', [ 'id' => 'mw-category-media' ] ) . "\n";
531 $html .= Html::rawElement(
532 'h2',
533 [],
534 $this->msg( 'category-media-header' )->rawParams( $name )->parse()
535 ) . "\n";
536 $html .= $countMessage;
537 $html .= $this->getSectionPagingLinks( 'file' );
538 if ( $this->showGallery ) {
539 $html .= $this->gallery->toHTML();
540 } else {
541 $html .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
542 }
543 $html .= $this->getSectionPagingLinks( 'file' );
544 $html .= "\n" . Html::closeElement( 'div' );
545 }
546 return $html;
547 }
548
556 private function getSectionPagingLinks( $type ) {
557 if ( isset( $this->until[$type] ) ) {
558 // The new value for the until parameter should be pointing to the first
559 // result displayed on the page which is the second last result retrieved
560 // from the database.The next link should have a from parameter pointing
561 // to the until parameter of the current page.
562 if ( $this->nextPage[$type] !== null ) {
563 return $this->pagingLinks(
564 $this->prevPage[$type] ?? '',
565 $this->until[$type],
566 $type
567 );
568 }
569
570 // If the nextPage variable is null, it means that we have reached the first page
571 // and therefore the previous link should be disabled.
572 return $this->pagingLinks(
573 '',
574 $this->until[$type],
575 $type
576 );
577 } elseif ( $this->nextPage[$type] !== null || isset( $this->from[$type] ) ) {
578 return $this->pagingLinks(
579 $this->from[$type] ?? '',
580 $this->nextPage[$type],
581 $type
582 );
583 }
584
585 return '';
586 }
587
591 protected function getCategoryBottom() {
592 return '';
593 }
594
605 private function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
606 $list = '';
607 if ( count( $articles ) > $cutoff ) {
608 $list = self::columnList( $articles, $articles_start_char );
609 } elseif ( count( $articles ) > 0 ) {
610 // for short lists of articles in categories.
611 $list = self::shortList( $articles, $articles_start_char );
612 }
613
614 $pageLang = MediaWikiServices::getInstance()->getTitleFactory()
615 ->newFromPageIdentity( $this->page )
616 ->getPageLanguage();
617 $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
618 'class' => 'mw-content-' . $pageLang->getDir() ];
619 $list = Html::rawElement( 'div', $attribs, $list );
620
621 return $list;
622 }
623
634 public static function columnList(
635 $articles,
636 $articles_start_char,
637 $cssClasses = 'mw-category mw-category-columns'
638 ) {
639 $columns = array_combine( $articles, $articles_start_char );
640
641 $ret = Html::openElement( 'div', [ 'class' => $cssClasses ] );
642
643 $colContents = [];
644
645 # Kind of like array_flip() here, but we keep duplicates in an
646 # array instead of dropping them.
647 foreach ( $columns as $article => $char ) {
648 $colContents[$char][] = $article;
649 }
650
651 foreach ( $colContents as $char => $articles ) {
652 # Change space to non-breaking space to keep headers aligned
653 $h3char = $char === ' ' ? "\u{00A0}" : htmlspecialchars( $char );
654
655 $ret .= Html::openElement( 'div', [ 'class' => 'mw-category-group' ] );
656 $ret .= Html::rawElement( 'h3', [], $h3char ) . "\n";
657 $ret .= Html::openElement( 'ul' );
658 $ret .= implode(
659 "\n",
660 array_map(
661 static function ( $article ) {
662 return Html::rawElement( 'li', [], $article );
663 },
664 $articles
665 )
666 );
667 $ret .= Html::closeElement( 'ul' ) . Html::closeElement( 'div' );
668
669 }
670
671 $ret .= Html::closeElement( 'div' );
672 return $ret;
673 }
674
683 public static function shortList( $articles, $articles_start_char ) {
684 return self::columnList( $articles, $articles_start_char, 'mw-category' );
685 }
686
696 private function pagingLinks( $first, $last, $type = '' ) {
697 $prevLink = $this->msg( 'prev-page' )->escaped();
698
699 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
700 if ( $first != '' ) {
701 $prevQuery = $this->query;
702 $prevQuery["{$type}until"] = $first;
703 unset( $prevQuery["{$type}from"] );
704 $prevLink = $linkRenderer->makeKnownLink(
705 $this->addFragmentToTitle( $this->page, $type ),
706 new HtmlArmor( $prevLink ),
707 [],
708 $prevQuery
709 );
710 }
711
712 $nextLink = $this->msg( 'next-page' )->escaped();
713
714 if ( $last != '' ) {
715 $lastQuery = $this->query;
716 $lastQuery["{$type}from"] = $last;
717 unset( $lastQuery["{$type}until"] );
718 $nextLink = $linkRenderer->makeKnownLink(
719 $this->addFragmentToTitle( $this->page, $type ),
720 new HtmlArmor( $nextLink ),
721 [],
722 $lastQuery
723 );
724 }
725
726 return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
727 }
728
737 private function addFragmentToTitle( PageReference $page, string $section ): LinkTarget {
738 $fragment = match ( $section ) {
739 'page' => 'mw-pages',
740 'subcat' => 'mw-subcategories',
741 'file' => 'mw-category-media',
742 default => throw new InvalidArgumentException( __METHOD__ . " Invalid section $section." )
743 };
744 return new TitleValue( $page->getNamespace(), $page->getDBkey(), $fragment );
745 }
746
757 private function getCountMessage( $localCount, $databaseCount, $type ) {
758 // There are three cases:
759 // 1) The category table figure seems good. It might be wrong, but
760 // we can't do anything about it if we don't recalculate it on ev-
761 // ery category view.
762 // 2) The category table figure isn't good, like it's smaller than the
763 // number of actual results, *but* the number of results is less
764 // than $this->limit and there's no offset. In this case we still
765 // know the right figure.
766 // 3) We have no idea.
767
768 // Check if there's a "from" or "until" for anything
769
770 // This is a little ugly, but we seem to use different names
771 // for the paging types then for the messages.
772 if ( $type === 'article' ) {
773 $pagingType = 'page';
774 } else {
775 $pagingType = $type;
776 }
777
778 $fromOrUntil = false;
779 if ( isset( $this->from[$pagingType] ) || isset( $this->until[$pagingType] ) ) {
780 $fromOrUntil = true;
781 }
782
783 if ( $databaseCount == $localCount ||
784 ( ( $localCount == $this->limit || $fromOrUntil ) && $databaseCount > $localCount )
785 ) {
786 // Case 1: seems good.
787 $totalCount = $databaseCount;
788 } elseif ( $localCount < $this->limit && !$fromOrUntil ) {
789 // Case 2: not good, but salvageable. Use the number of results.
790 $totalCount = $localCount;
791 } else {
792 // Case 3: hopeless. Don't give a total count at all.
793 // Messages: category-subcat-count-limited, category-article-count-limited,
794 // category-file-count-limited
795 return $this->msg( "category-$type-count-limited" )->numParams( $localCount )->parseAsBlock();
796 }
797 // Messages: category-subcat-count, category-article-count, category-file-count
798 return $this->msg( "category-$type-count" )->numParams( $localCount, $totalCount )->parseAsBlock();
799 }
800}
const NS_FILE
Definition Defines.php:57
const NS_CATEGORY
Definition Defines.php:65
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
getHTML()
Format the category data list.
static columnList( $articles, $articles_start_char, $cssClasses='mw-category mw-category-columns')
Format a list of articles chunked by letter in a three-column list, ordered vertically.
static shortList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
addImage(PageReference $page, string $sortkey, int $pageLength, bool $isRedirect=false)
Add a page in the image namespace.
getSubcategorySortChar(PageIdentity $page, string $sortkey)
Get the character to be used for sorting subcategories.
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
__construct(PageIdentity $page, IContextSource $context, array $from=[], array $until=[], array $query=[])
addPage(PageReference $page, string $sortkey, int $pageLength, bool $isRedirect=false)
Add a miscellaneous page.
Category objects are immutable, strictly speaking.
Definition Category.php:29
static newFromTitle(PageIdentity $page)
Factory function.
Definition Category.php:176
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
setContext(IContextSource $context)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
Class for exceptions thrown by ImageGalleryBase::factory().
static factory( $mode=false, ?IContextSource $context=null)
Get a new image gallery.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
A class containing constants representing the names of configuration variables.
const CategoryPagingLimit
Name constant for the CategoryPagingLimit setting, for use with Config::get()
const CategoryMagicGallery
Name constant for the CategoryMagicGallery setting, for use with Config::get()
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Represents the target of a wiki link.
Represents a title within MediaWiki.
Definition Title.php:69
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
Build SELECT queries with a fluent interface.
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
The shared interface for all language converters.
Represents the target of a wiki link.
Interface for objects (potentially) representing an editable wiki page.
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
getNamespace()
Returns the page's namespace number.
getDBkey()
Get the page title in DB key form.
msg( $key,... $params)