MediaWiki REL1_27
CategoryViewer.php
Go to the documentation of this file.
1<?php
25 public $limit;
26
28 public $from;
29
31 public $until;
32
34 public $articles;
35
38
40 public $children;
41
44
47
50
53
55 public $nextPage;
56
58 protected $prevPage;
59
61 public $flip;
62
64 public $title;
65
67 public $collation;
68
70 public $gallery;
71
73 private $cat;
74
76 private $query;
77
88 $until = [], $query = []
89 ) {
90 $this->title = $title;
91 $this->setContext( $context );
92 $this->getOutput()->addModuleStyles( [
93 'mediawiki.action.view.categoryPage.styles'
94 ] );
95 $this->from = $from;
96 $this->until = $until;
97 $this->limit = $context->getConfig()->get( 'CategoryPagingLimit' );
98 $this->cat = Category::newFromTitle( $title );
99 $this->query = $query;
100 $this->collation = Collation::singleton();
101 unset( $this->query['title'] );
102 }
103
109 public function getHTML() {
110
111 $this->showGallery = $this->getConfig()->get( 'CategoryMagicGallery' )
112 && !$this->getOutput()->mNoGallery;
113
114 $this->clearCategoryState();
115 $this->doCategoryQuery();
116 $this->finaliseCategoryState();
117
118 $r = $this->getSubcategorySection() .
119 $this->getPagesSection() .
120 $this->getImageSection();
121
122 if ( $r == '' ) {
123 // If there is no category content to display, only
124 // show the top part of the navigation links.
125 // @todo FIXME: Cannot be completely suppressed because it
126 // is unknown if 'until' or 'from' makes this
127 // give 0 results.
128 $r = $r . $this->getCategoryTop();
129 } else {
130 $r = $this->getCategoryTop() .
131 $r .
132 $this->getCategoryBottom();
133 }
134
135 // Give a proper message if category is empty
136 if ( $r == '' ) {
137 $r = $this->msg( 'category-empty' )->parseAsBlock();
138 }
139
140 $lang = $this->getLanguage();
141 $attribs = [
142 'class' => 'mw-category-generated',
143 'lang' => $lang->getHtmlCode(),
144 'dir' => $lang->getDir()
145 ];
146 # put a div around the headings which are in the user language
147 $r = Html::openElement( 'div', $attribs ) . $r . '</div>';
148
149 return $r;
150 }
151
153 $this->articles = [];
154 $this->articles_start_char = [];
155 $this->children = [];
156 $this->children_start_char = [];
157 if ( $this->showGallery ) {
158 // Note that null for mode is taken to mean use default.
159 $mode = $this->getRequest()->getVal( 'gallerymode', null );
160 try {
161 $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
162 } catch ( Exception $e ) {
163 // User specified something invalid, fallback to default.
164 $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
165 }
166
167 $this->gallery->setHideBadImages();
168 } else {
169 $this->imgsNoGallery = [];
170 $this->imgsNoGallery_start_char = [];
171 }
172 }
173
180 function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
181 // Subcategory; strip the 'Category' namespace from the link text.
182 $title = $cat->getTitle();
183
184 $this->children[] = $this->generateLink(
185 'subcat',
186 $title,
188 htmlspecialchars( $title->getText() )
189 );
190
191 $this->children_start_char[] =
192 $this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
193 }
194
195 function generateLink( $type, Title $title, $isRedirect, $html = null ) {
196 $link = null;
197 Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
198 if ( $link === null ) {
200 }
201 if ( $isRedirect ) {
202 $link = '<span class="redirect-in-category">' . $link . '</span>';
203 }
204
205 return $link;
206 }
207
219 function getSubcategorySortChar( $title, $sortkey ) {
221
222 if ( $title->getPrefixedText() == $sortkey ) {
223 $word = $title->getDBkey();
224 } else {
225 $word = $sortkey;
226 }
227
228 $firstChar = $this->collation->getFirstLetter( $word );
229
230 return $wgContLang->convert( $firstChar );
231 }
232
240 function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
242 if ( $this->showGallery ) {
243 $flip = $this->flip['file'];
244 if ( $flip ) {
245 $this->gallery->insert( $title );
246 } else {
247 $this->gallery->add( $title );
248 }
249 } else {
250 $this->imgsNoGallery[] = $this->generateLink( 'image', $title, $isRedirect );
251
252 $this->imgsNoGallery_start_char[] = $wgContLang->convert(
253 $this->collation->getFirstLetter( $sortkey ) );
254 }
255 }
256
264 function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
266
267 $this->articles[] = $this->generateLink( 'page', $title, $isRedirect );
268
269 $this->articles_start_char[] = $wgContLang->convert(
270 $this->collation->getFirstLetter( $sortkey ) );
271 }
272
274 if ( $this->flip['subcat'] ) {
275 $this->children = array_reverse( $this->children );
276 $this->children_start_char = array_reverse( $this->children_start_char );
277 }
278 if ( $this->flip['page'] ) {
279 $this->articles = array_reverse( $this->articles );
280 $this->articles_start_char = array_reverse( $this->articles_start_char );
281 }
282 if ( !$this->showGallery && $this->flip['file'] ) {
283 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
284 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
285 }
286 }
287
288 function doCategoryQuery() {
289 $dbr = wfGetDB( DB_SLAVE, 'category' );
290
291 $this->nextPage = [
292 'page' => null,
293 'subcat' => null,
294 'file' => null,
295 ];
296 $this->prevPage = [
297 'page' => null,
298 'subcat' => null,
299 'file' => null,
300 ];
301
302 $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
303
304 foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
305 # Get the sortkeys for start/end, if applicable. Note that if
306 # the collation in the database differs from the one
307 # set in $wgCategoryCollation, pagination might go totally haywire.
308 $extraConds = [ 'cl_type' => $type ];
309 if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
310 $extraConds[] = 'cl_sortkey >= '
311 . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
312 } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
313 $extraConds[] = 'cl_sortkey < '
314 . $dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) );
315 $this->flip[$type] = true;
316 }
317
318 $res = $dbr->select(
319 [ 'page', 'categorylinks', 'category' ],
320 [ 'page_id', 'page_title', 'page_namespace', 'page_len',
321 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title',
322 'cat_subcats', 'cat_pages', 'cat_files',
323 'cl_sortkey_prefix', 'cl_collation' ],
324 array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ),
325 __METHOD__,
326 [
327 'USE INDEX' => [ 'categorylinks' => 'cl_sortkey' ],
328 'LIMIT' => $this->limit + 1,
329 'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
330 ],
331 [
332 'categorylinks' => [ 'INNER JOIN', 'cl_from = page_id' ],
333 'category' => [ 'LEFT JOIN', [
334 'cat_title = page_title',
335 'page_namespace' => NS_CATEGORY
336 ] ]
337 ]
338 );
339
340 Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
341
342 $count = 0;
343 foreach ( $res as $row ) {
344 $title = Title::newFromRow( $row );
345 if ( $row->cl_collation === '' ) {
346 // Hack to make sure that while updating from 1.16 schema
347 // and db is inconsistent, that the sky doesn't fall.
348 // See r83544. Could perhaps be removed in a couple decades...
349 $humanSortkey = $row->cl_sortkey;
350 } else {
351 $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
352 }
353
354 if ( ++$count > $this->limit ) {
355 # We've reached the one extra which shows that there
356 # are additional pages to be had. Stop here...
357 $this->nextPage[$type] = $humanSortkey;
358 break;
359 }
360 if ( $count == $this->limit ) {
361 $this->prevPage[$type] = $humanSortkey;
362 }
363
364 if ( $title->getNamespace() == NS_CATEGORY ) {
366 $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
367 } elseif ( $title->getNamespace() == NS_FILE ) {
368 $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
369 } else {
370 $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
371 }
372 }
373 }
374 }
375
379 function getCategoryTop() {
380 $r = $this->getCategoryBottom();
381 return $r === ''
382 ? $r
383 : "<br style=\"clear:both;\"/>\n" . $r;
384 }
385
390 # Don't show subcategories section if there are none.
391 $r = '';
392 $rescnt = count( $this->children );
393 $dbcnt = $this->cat->getSubcatCount();
394 // This function should be called even if the result isn't used, it has side-effects
395 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
396
397 if ( $rescnt > 0 ) {
398 # Showing subcategories
399 $r .= "<div id=\"mw-subcategories\">\n";
400 $r .= '<h2>' . $this->msg( 'subcategories' )->parse() . "</h2>\n";
401 $r .= $countmsg;
402 $r .= $this->getSectionPagingLinks( 'subcat' );
403 $r .= $this->formatList( $this->children, $this->children_start_char );
404 $r .= $this->getSectionPagingLinks( 'subcat' );
405 $r .= "\n</div>";
406 }
407 return $r;
408 }
409
413 function getPagesSection() {
414 $ti = wfEscapeWikiText( $this->title->getText() );
415 # Don't show articles section if there are none.
416 $r = '';
417
418 # @todo FIXME: Here and in the other two sections: we don't need to bother
419 # with this rigmarole if the entire category contents fit on one page
420 # and have already been retrieved. We can just use $rescnt in that
421 # case and save a query and some logic.
422 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
423 - $this->cat->getFileCount();
424 $rescnt = count( $this->articles );
425 // This function should be called even if the result isn't used, it has side-effects
426 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
427
428 if ( $rescnt > 0 ) {
429 $r = "<div id=\"mw-pages\">\n";
430 $r .= '<h2>' . $this->msg( 'category_header', $ti )->parse() . "</h2>\n";
431 $r .= $countmsg;
432 $r .= $this->getSectionPagingLinks( 'page' );
433 $r .= $this->formatList( $this->articles, $this->articles_start_char );
434 $r .= $this->getSectionPagingLinks( 'page' );
435 $r .= "\n</div>";
436 }
437 return $r;
438 }
439
443 function getImageSection() {
444 $r = '';
445 $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
446 $dbcnt = $this->cat->getFileCount();
447 // This function should be called even if the result isn't used, it has side-effects
448 $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
449
450 if ( $rescnt > 0 ) {
451 $r .= "<div id=\"mw-category-media\">\n";
452 $r .= '<h2>' .
453 $this->msg(
454 'category-media-header',
455 wfEscapeWikiText( $this->title->getText() )
456 )->text() .
457 "</h2>\n";
458 $r .= $countmsg;
459 $r .= $this->getSectionPagingLinks( 'file' );
460 if ( $this->showGallery ) {
461 $r .= $this->gallery->toHTML();
462 } else {
463 $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
464 }
465 $r .= $this->getSectionPagingLinks( 'file' );
466 $r .= "\n</div>";
467 }
468 return $r;
469 }
470
478 private function getSectionPagingLinks( $type ) {
479 if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
480 // The new value for the until parameter should be pointing to the first
481 // result displayed on the page which is the second last result retrieved
482 // from the database.The next link should have a from parameter pointing
483 // to the until parameter of the current page.
484 if ( $this->nextPage[$type] !== null ) {
485 return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
486 } else {
487 // If the nextPage variable is null, it means that we have reached the first page
488 // and therefore the previous link should be disabled.
489 return $this->pagingLinks( null, $this->until[$type], $type );
490 }
491 } elseif ( $this->nextPage[$type] !== null
492 || ( isset( $this->from[$type] ) && $this->from[$type] !== null )
493 ) {
494 return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
495 } else {
496 return '';
497 }
498 }
499
503 function getCategoryBottom() {
504 return '';
505 }
506
517 function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
518 $list = '';
519 if ( count( $articles ) > $cutoff ) {
521 } elseif ( count( $articles ) > 0 ) {
522 // for short lists of articles in categories.
524 }
525
526 $pageLang = $this->title->getPageLanguage();
527 $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
528 'class' => 'mw-content-' . $pageLang->getDir() ];
529 $list = Html::rawElement( 'div', $attribs, $list );
530
531 return $list;
532 }
533
549 $columns = array_combine( $articles, $articles_start_char );
550
551 $ret = Html::openElement( 'div', [ 'class' => 'mw-category' ] );
552
553 $colContents = [];
554
555 # Kind of like array_flip() here, but we keep duplicates in an
556 # array instead of dropping them.
557 foreach ( $columns as $article => $char ) {
558 if ( !isset( $colContents[$char] ) ) {
559 $colContents[$char] = [];
560 }
561 $colContents[$char][] = $article;
562 }
563
564 foreach ( $colContents as $char => $articles ) {
565 # Change space to non-breaking space to keep headers aligned
566 $h3char = $char === ' ' ? '&#160;' : htmlspecialchars( $char );
567
568 $ret .= '<div class="mw-category-group"><h3>' . $h3char;
569 $ret .= "</h3>\n";
570
571 $ret .= '<ul><li>';
572 $ret .= implode( "</li>\n<li>", $articles );
573 $ret .= '</li></ul></div>';
574
575 }
576
577 $ret .= Html::closeElement( 'div' );
578 return $ret;
579 }
580
589 $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
590 $r .= '<ul><li>' . $articles[0] . '</li>';
591 $articleCount = count( $articles );
592 for ( $index = 1; $index < $articleCount; $index++ ) {
593 if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
594 $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
595 }
596
597 $r .= "<li>{$articles[$index]}</li>";
598 }
599 $r .= '</ul>';
600 return $r;
601 }
602
612 private function pagingLinks( $first, $last, $type = '' ) {
613 $prevLink = $this->msg( 'prev-page' )->text();
614
615 if ( $first != '' ) {
616 $prevQuery = $this->query;
617 $prevQuery["{$type}until"] = $first;
618 unset( $prevQuery["{$type}from"] );
619 $prevLink = Linker::linkKnown(
620 $this->addFragmentToTitle( $this->title, $type ),
621 $prevLink,
622 [],
623 $prevQuery
624 );
625 }
626
627 $nextLink = $this->msg( 'next-page' )->text();
628
629 if ( $last != '' ) {
630 $lastQuery = $this->query;
631 $lastQuery["{$type}from"] = $last;
632 unset( $lastQuery["{$type}until"] );
633 $nextLink = Linker::linkKnown(
634 $this->addFragmentToTitle( $this->title, $type ),
635 $nextLink,
636 [],
637 $lastQuery
638 );
639 }
640
641 return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
642 }
643
653 private function addFragmentToTitle( $title, $section ) {
654 switch ( $section ) {
655 case 'page':
656 $fragment = 'mw-pages';
657 break;
658 case 'subcat':
659 $fragment = 'mw-subcategories';
660 break;
661 case 'file':
662 $fragment = 'mw-category-media';
663 break;
664 default:
665 throw new MWException( __METHOD__ .
666 " Invalid section $section." );
667 }
668
670 $title->getDBkey(), $fragment );
671 }
672
683 private function getCountMessage( $rescnt, $dbcnt, $type ) {
684 // There are three cases:
685 // 1) The category table figure seems sane. It might be wrong, but
686 // we can't do anything about it if we don't recalculate it on ev-
687 // ery category view.
688 // 2) The category table figure isn't sane, like it's smaller than the
689 // number of actual results, *but* the number of results is less
690 // than $this->limit and there's no offset. In this case we still
691 // know the right figure.
692 // 3) We have no idea.
693
694 // Check if there's a "from" or "until" for anything
695
696 // This is a little ugly, but we seem to use different names
697 // for the paging types then for the messages.
698 if ( $type === 'article' ) {
699 $pagingType = 'page';
700 } else {
701 $pagingType = $type;
702 }
703
704 $fromOrUntil = false;
705 if ( ( isset( $this->from[$pagingType] ) && $this->from[$pagingType] !== null ) ||
706 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
707 ) {
708 $fromOrUntil = true;
709 }
710
711 if ( $dbcnt == $rescnt ||
712 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
713 ) {
714 // Case 1: seems sane.
715 $totalcnt = $dbcnt;
716 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
717 // Case 2: not sane, but salvageable. Use the number of results.
718 // Since there are fewer than 200, we can also take this opportunity
719 // to refresh the incorrect category table entry -- which should be
720 // quick due to the small number of entries.
721 $totalcnt = $rescnt;
722 $category = $this->cat;
723 DeferredUpdates::addCallableUpdate( function () use ( $category ) {
724 $category->refreshCounts();
725 } );
726 } else {
727 // Case 3: hopeless. Don't give a total count at all.
728 // Messages: category-subcat-count-limited, category-article-count-limited,
729 // category-file-count-limited
730 return $this->msg( "category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
731 }
732 // Messages: category-subcat-count, category-article-count, category-file-count
733 return $this->msg( "category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
734 }
735}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
getCountMessage( $rescnt, $dbcnt, $type)
What to do if the category table conflicts with the number of results returned? This function says wh...
pagingLinks( $first, $last, $type='')
Create paging links, as a helper method to getSectionPagingLinks().
Collation $collation
getSectionPagingLinks( $type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output.
Category $cat
Category object for this page.
__construct( $title, IContextSource $context, $from=[], $until=[], $query=[])
addPage( $title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
formatList( $articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format,...
addImage(Title $title, $sortkey, $pageLength, $isRedirect=false)
Add a page in the image namespace.
static columnList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a three-column list, ordered vertically.
ImageGallery $gallery
getSubcategorySortChar( $title, $sortkey)
Get the character to be used for sorting subcategories.
getHTML()
Format the category data list.
addFragmentToTitle( $title, $section)
Takes a title, and adds the fragment identifier that corresponds to the correct segment of the catego...
array $imgsNoGallery_start_char
generateLink( $type, Title $title, $isRedirect, $html=null)
array $query
The original query array, to be used in generating paging links.
static shortList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
Category objects are immutable, strictly speaking.
Definition Category.php:31
static newFromTitle( $title)
Factory function.
Definition Category.php:131
static newFromRow( $row, $title=null)
Factory function, for constructing a Category object from a result set.
Definition Category.php:164
static singleton()
Definition Collation.php:34
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
getRequest()
Get the WebRequest object.
getConfig()
Get the Config object.
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getOutput()
Get the OutputPage object.
IContextSource $context
getLanguage()
Get the Language object.
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Set the IContextSource object.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition Html.php:210
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition Html.php:248
static closeElement( $element)
Returns "</$element>".
Definition Html.php:306
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
Backwards compatibility.
static link( $target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition Linker.php:195
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known', 'noclasses'])
Identical to link(), except $options defaults to 'known'.
Definition Linker.php:264
MediaWiki exception.
Represents a title within MediaWiki.
Definition Title.php:34
getNamespace()
Get the namespace index, i.e.
Definition Title.php:934
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition Title.php:524
getDBkey()
Get the main part with underscores.
Definition Title.php:911
getText()
Get the text form (spaces not underscores) of the main part.
Definition Title.php:893
isRedirect( $flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
Definition Title.php:3230
getPrefixedText()
Get the prefixed title with spaces.
Definition Title.php:1449
getCategorySortkey( $prefix='')
Returns the raw sort key to be used for categories, with the specified prefix.
Definition Title.php:4638
static newFromRow( $row)
Make a Title object from a DB row.
Definition Title.php:465
$res
Definition database.txt:21
For a write query
Definition database.txt:26
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
Definition design.txt:57
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
const NS_FILE
Definition Defines.php:76
const NS_CATEGORY
Definition Defines.php:84
const DB_SLAVE
Definition Defines.php:47
the array() calling protocol came about after MediaWiki 1.4rc1.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
Definition hooks.txt:1819
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition hooks.txt:1810
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
Definition hooks.txt:2413
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition hooks.txt:1818
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
Definition hooks.txt:78
the value to return A Title object or null for latest to be modified or replaced by the hook handler or if authentication is not possible after cache objects are set for highlighting & $link
Definition hooks.txt:2692
processing should stop and the error should be shown to the user * false
Definition hooks.txt:189
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
Definition hooks.txt:2727
returning false will NOT prevent logging $e
Definition hooks.txt:1940
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition injection.txt:37
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
title
$last
if(!isset( $args[0])) $lang