MediaWiki  1.28.0
CategoryViewer.php
Go to the documentation of this file.
1 <?php
23 
26  public $limit;
27 
29  public $from;
30 
32  public $until;
33 
35  public $articles;
36 
39 
41  public $children;
42 
45 
47  public $showGallery;
48 
51 
54 
56  public $nextPage;
57 
59  protected $prevPage;
60 
62  public $flip;
63 
65  public $title;
66 
68  public $collation;
69 
71  public $gallery;
72 
74  private $cat;
75 
77  private $query;
78 
89  $until = [], $query = []
90  ) {
91  $this->title = $title;
92  $this->setContext( $context );
93  $this->getOutput()->addModuleStyles( [
94  'mediawiki.action.view.categoryPage.styles'
95  ] );
96  $this->from = $from;
97  $this->until = $until;
98  $this->limit = $context->getConfig()->get( 'CategoryPagingLimit' );
99  $this->cat = Category::newFromTitle( $title );
100  $this->query = $query;
101  $this->collation = Collation::singleton();
102  unset( $this->query['title'] );
103  }
104 
110  public function getHTML() {
111 
112  $this->showGallery = $this->getConfig()->get( 'CategoryMagicGallery' )
113  && !$this->getOutput()->mNoGallery;
114 
115  $this->clearCategoryState();
116  $this->doCategoryQuery();
117  $this->finaliseCategoryState();
118 
119  $r = $this->getSubcategorySection() .
120  $this->getPagesSection() .
121  $this->getImageSection();
122 
123  if ( $r == '' ) {
124  // If there is no category content to display, only
125  // show the top part of the navigation links.
126  // @todo FIXME: Cannot be completely suppressed because it
127  // is unknown if 'until' or 'from' makes this
128  // give 0 results.
129  $r = $r . $this->getCategoryTop();
130  } else {
131  $r = $this->getCategoryTop() .
132  $r .
133  $this->getCategoryBottom();
134  }
135 
136  // Give a proper message if category is empty
137  if ( $r == '' ) {
138  $r = $this->msg( 'category-empty' )->parseAsBlock();
139  }
140 
141  $lang = $this->getLanguage();
142  $attribs = [
143  'class' => 'mw-category-generated',
144  'lang' => $lang->getHtmlCode(),
145  'dir' => $lang->getDir()
146  ];
147  # put a div around the headings which are in the user language
148  $r = Html::openElement( 'div', $attribs ) . $r . '</div>';
149 
150  return $r;
151  }
152 
153  function clearCategoryState() {
154  $this->articles = [];
155  $this->articles_start_char = [];
156  $this->children = [];
157  $this->children_start_char = [];
158  if ( $this->showGallery ) {
159  // Note that null for mode is taken to mean use default.
160  $mode = $this->getRequest()->getVal( 'gallerymode', null );
161  try {
162  $this->gallery = ImageGalleryBase::factory( $mode, $this->getContext() );
163  } catch ( Exception $e ) {
164  // User specified something invalid, fallback to default.
165  $this->gallery = ImageGalleryBase::factory( false, $this->getContext() );
166  }
167 
168  $this->gallery->setHideBadImages();
169  } else {
170  $this->imgsNoGallery = [];
171  $this->imgsNoGallery_start_char = [];
172  }
173  }
174 
181  function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) {
182  // Subcategory; strip the 'Category' namespace from the link text.
183  $title = $cat->getTitle();
184 
185  $this->children[] = $this->generateLink(
186  'subcat',
187  $title,
188  $title->isRedirect(),
189  htmlspecialchars( $title->getText() )
190  );
191 
192  $this->children_start_char[] =
193  $this->getSubcategorySortChar( $cat->getTitle(), $sortkey );
194  }
195 
196  function generateLink( $type, Title $title, $isRedirect, $html = null ) {
197  $link = null;
198  Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
199  if ( $link === null ) {
200  $link = Linker::link( $title, $html );
201  }
202  if ( $isRedirect ) {
203  $link = '<span class="redirect-in-category">' . $link . '</span>';
204  }
205 
206  return $link;
207  }
208 
220  function getSubcategorySortChar( $title, $sortkey ) {
222 
223  if ( $title->getPrefixedText() == $sortkey ) {
224  $word = $title->getDBkey();
225  } else {
226  $word = $sortkey;
227  }
228 
229  $firstChar = $this->collation->getFirstLetter( $word );
230 
231  return $wgContLang->convert( $firstChar );
232  }
233 
241  function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) {
243  if ( $this->showGallery ) {
244  $flip = $this->flip['file'];
245  if ( $flip ) {
246  $this->gallery->insert( $title );
247  } else {
248  $this->gallery->add( $title );
249  }
250  } else {
251  $this->imgsNoGallery[] = $this->generateLink( 'image', $title, $isRedirect );
252 
253  $this->imgsNoGallery_start_char[] = $wgContLang->convert(
254  $this->collation->getFirstLetter( $sortkey ) );
255  }
256  }
257 
265  function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
267 
268  $this->articles[] = $this->generateLink( 'page', $title, $isRedirect );
269 
270  $this->articles_start_char[] = $wgContLang->convert(
271  $this->collation->getFirstLetter( $sortkey ) );
272  }
273 
275  if ( $this->flip['subcat'] ) {
276  $this->children = array_reverse( $this->children );
277  $this->children_start_char = array_reverse( $this->children_start_char );
278  }
279  if ( $this->flip['page'] ) {
280  $this->articles = array_reverse( $this->articles );
281  $this->articles_start_char = array_reverse( $this->articles_start_char );
282  }
283  if ( !$this->showGallery && $this->flip['file'] ) {
284  $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
285  $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
286  }
287  }
288 
289  function doCategoryQuery() {
290  $dbr = wfGetDB( DB_REPLICA, 'category' );
291 
292  $this->nextPage = [
293  'page' => null,
294  'subcat' => null,
295  'file' => null,
296  ];
297  $this->prevPage = [
298  'page' => null,
299  'subcat' => null,
300  'file' => null,
301  ];
302 
303  $this->flip = [ 'page' => false, 'subcat' => false, 'file' => false ];
304 
305  foreach ( [ 'page', 'subcat', 'file' ] as $type ) {
306  # Get the sortkeys for start/end, if applicable. Note that if
307  # the collation in the database differs from the one
308  # set in $wgCategoryCollation, pagination might go totally haywire.
309  $extraConds = [ 'cl_type' => $type ];
310  if ( isset( $this->from[$type] ) && $this->from[$type] !== null ) {
311  $extraConds[] = 'cl_sortkey >= '
312  . $dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
313  } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
314  $extraConds[] = 'cl_sortkey < '
315  . $dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) );
316  $this->flip[$type] = true;
317  }
318 
319  $res = $dbr->select(
320  [ 'page', 'categorylinks', 'category' ],
321  array_merge(
323  [
324  'page_namespace',
325  'page_title',
326  'cl_sortkey',
327  'cat_id',
328  'cat_title',
329  'cat_subcats',
330  'cat_pages',
331  'cat_files',
332  'cl_sortkey_prefix',
333  'cl_collation'
334  ]
335  ),
336  array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ),
337  __METHOD__,
338  [
339  'USE INDEX' => [ 'categorylinks' => 'cl_sortkey' ],
340  'LIMIT' => $this->limit + 1,
341  'ORDER BY' => $this->flip[$type] ? 'cl_sortkey DESC' : 'cl_sortkey',
342  ],
343  [
344  'categorylinks' => [ 'INNER JOIN', 'cl_from = page_id' ],
345  'category' => [ 'LEFT JOIN', [
346  'cat_title = page_title',
347  'page_namespace' => NS_CATEGORY
348  ] ]
349  ]
350  );
351 
352  Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
353  $linkCache = MediaWikiServices::getInstance()->getLinkCache();
354 
355  $count = 0;
356  foreach ( $res as $row ) {
357  $title = Title::newFromRow( $row );
358  $linkCache->addGoodLinkObjFromRow( $title, $row );
359 
360  if ( $row->cl_collation === '' ) {
361  // Hack to make sure that while updating from 1.16 schema
362  // and db is inconsistent, that the sky doesn't fall.
363  // See r83544. Could perhaps be removed in a couple decades...
364  $humanSortkey = $row->cl_sortkey;
365  } else {
366  $humanSortkey = $title->getCategorySortkey( $row->cl_sortkey_prefix );
367  }
368 
369  if ( ++$count > $this->limit ) {
370  # We've reached the one extra which shows that there
371  # are additional pages to be had. Stop here...
372  $this->nextPage[$type] = $humanSortkey;
373  break;
374  }
375  if ( $count == $this->limit ) {
376  $this->prevPage[$type] = $humanSortkey;
377  }
378 
379  if ( $title->getNamespace() == NS_CATEGORY ) {
380  $cat = Category::newFromRow( $row, $title );
381  $this->addSubcategoryObject( $cat, $humanSortkey, $row->page_len );
382  } elseif ( $title->getNamespace() == NS_FILE ) {
383  $this->addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
384  } else {
385  $this->addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
386  }
387  }
388  }
389  }
390 
394  function getCategoryTop() {
395  $r = $this->getCategoryBottom();
396  return $r === ''
397  ? $r
398  : "<br style=\"clear:both;\"/>\n" . $r;
399  }
400 
405  # Don't show subcategories section if there are none.
406  $r = '';
407  $rescnt = count( $this->children );
408  $dbcnt = $this->cat->getSubcatCount();
409  // This function should be called even if the result isn't used, it has side-effects
410  $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'subcat' );
411 
412  if ( $rescnt > 0 ) {
413  # Showing subcategories
414  $r .= "<div id=\"mw-subcategories\">\n";
415  $r .= '<h2>' . $this->msg( 'subcategories' )->parse() . "</h2>\n";
416  $r .= $countmsg;
417  $r .= $this->getSectionPagingLinks( 'subcat' );
418  $r .= $this->formatList( $this->children, $this->children_start_char );
419  $r .= $this->getSectionPagingLinks( 'subcat' );
420  $r .= "\n</div>";
421  }
422  return $r;
423  }
424 
428  function getPagesSection() {
429  $ti = wfEscapeWikiText( $this->title->getText() );
430  # Don't show articles section if there are none.
431  $r = '';
432 
433  # @todo FIXME: Here and in the other two sections: we don't need to bother
434  # with this rigmarole if the entire category contents fit on one page
435  # and have already been retrieved. We can just use $rescnt in that
436  # case and save a query and some logic.
437  $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
438  - $this->cat->getFileCount();
439  $rescnt = count( $this->articles );
440  // This function should be called even if the result isn't used, it has side-effects
441  $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'article' );
442 
443  if ( $rescnt > 0 ) {
444  $r = "<div id=\"mw-pages\">\n";
445  $r .= '<h2>' . $this->msg( 'category_header', $ti )->parse() . "</h2>\n";
446  $r .= $countmsg;
447  $r .= $this->getSectionPagingLinks( 'page' );
448  $r .= $this->formatList( $this->articles, $this->articles_start_char );
449  $r .= $this->getSectionPagingLinks( 'page' );
450  $r .= "\n</div>";
451  }
452  return $r;
453  }
454 
458  function getImageSection() {
459  $r = '';
460  $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
461  $dbcnt = $this->cat->getFileCount();
462  // This function should be called even if the result isn't used, it has side-effects
463  $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
464 
465  if ( $rescnt > 0 ) {
466  $r .= "<div id=\"mw-category-media\">\n";
467  $r .= '<h2>' .
468  $this->msg(
469  'category-media-header',
470  wfEscapeWikiText( $this->title->getText() )
471  )->text() .
472  "</h2>\n";
473  $r .= $countmsg;
474  $r .= $this->getSectionPagingLinks( 'file' );
475  if ( $this->showGallery ) {
476  $r .= $this->gallery->toHTML();
477  } else {
478  $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
479  }
480  $r .= $this->getSectionPagingLinks( 'file' );
481  $r .= "\n</div>";
482  }
483  return $r;
484  }
485 
493  private function getSectionPagingLinks( $type ) {
494  if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
495  // The new value for the until parameter should be pointing to the first
496  // result displayed on the page which is the second last result retrieved
497  // from the database.The next link should have a from parameter pointing
498  // to the until parameter of the current page.
499  if ( $this->nextPage[$type] !== null ) {
500  return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
501  } else {
502  // If the nextPage variable is null, it means that we have reached the first page
503  // and therefore the previous link should be disabled.
504  return $this->pagingLinks( null, $this->until[$type], $type );
505  }
506  } elseif ( $this->nextPage[$type] !== null
507  || ( isset( $this->from[$type] ) && $this->from[$type] !== null )
508  ) {
509  return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
510  } else {
511  return '';
512  }
513  }
514 
518  function getCategoryBottom() {
519  return '';
520  }
521 
532  function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
533  $list = '';
534  if ( count( $articles ) > $cutoff ) {
535  $list = self::columnList( $articles, $articles_start_char );
536  } elseif ( count( $articles ) > 0 ) {
537  // for short lists of articles in categories.
538  $list = self::shortList( $articles, $articles_start_char );
539  }
540 
541  $pageLang = $this->title->getPageLanguage();
542  $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
543  'class' => 'mw-content-' . $pageLang->getDir() ];
544  $list = Html::rawElement( 'div', $attribs, $list );
545 
546  return $list;
547  }
548 
564  $columns = array_combine( $articles, $articles_start_char );
565 
566  $ret = Html::openElement( 'div', [ 'class' => 'mw-category' ] );
567 
568  $colContents = [];
569 
570  # Kind of like array_flip() here, but we keep duplicates in an
571  # array instead of dropping them.
572  foreach ( $columns as $article => $char ) {
573  if ( !isset( $colContents[$char] ) ) {
574  $colContents[$char] = [];
575  }
576  $colContents[$char][] = $article;
577  }
578 
579  foreach ( $colContents as $char => $articles ) {
580  # Change space to non-breaking space to keep headers aligned
581  $h3char = $char === ' ' ? '&#160;' : htmlspecialchars( $char );
582 
583  $ret .= '<div class="mw-category-group"><h3>' . $h3char;
584  $ret .= "</h3>\n";
585 
586  $ret .= '<ul><li>';
587  $ret .= implode( "</li>\n<li>", $articles );
588  $ret .= '</li></ul></div>';
589 
590  }
591 
592  $ret .= Html::closeElement( 'div' );
593  return $ret;
594  }
595 
605  $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
606  $r .= '<ul><li>' . $articles[0] . '</li>';
607  $articleCount = count( $articles );
608  for ( $index = 1; $index < $articleCount; $index++ ) {
609  if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
610  $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
611  }
612 
613  $r .= "<li>{$articles[$index]}</li>";
614  }
615  $r .= '</ul>';
616  return $r;
617  }
618 
628  private function pagingLinks( $first, $last, $type = '' ) {
629  $prevLink = $this->msg( 'prev-page' )->text();
630 
631  if ( $first != '' ) {
632  $prevQuery = $this->query;
633  $prevQuery["{$type}until"] = $first;
634  unset( $prevQuery["{$type}from"] );
635  $prevLink = Linker::linkKnown(
636  $this->addFragmentToTitle( $this->title, $type ),
637  $prevLink,
638  [],
639  $prevQuery
640  );
641  }
642 
643  $nextLink = $this->msg( 'next-page' )->text();
644 
645  if ( $last != '' ) {
646  $lastQuery = $this->query;
647  $lastQuery["{$type}from"] = $last;
648  unset( $lastQuery["{$type}until"] );
649  $nextLink = Linker::linkKnown(
650  $this->addFragmentToTitle( $this->title, $type ),
651  $nextLink,
652  [],
653  $lastQuery
654  );
655  }
656 
657  return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
658  }
659 
669  private function addFragmentToTitle( $title, $section ) {
670  switch ( $section ) {
671  case 'page':
672  $fragment = 'mw-pages';
673  break;
674  case 'subcat':
675  $fragment = 'mw-subcategories';
676  break;
677  case 'file':
678  $fragment = 'mw-category-media';
679  break;
680  default:
681  throw new MWException( __METHOD__ .
682  " Invalid section $section." );
683  }
684 
686  $title->getDBkey(), $fragment );
687  }
688 
699  private function getCountMessage( $rescnt, $dbcnt, $type ) {
700  // There are three cases:
701  // 1) The category table figure seems sane. It might be wrong, but
702  // we can't do anything about it if we don't recalculate it on ev-
703  // ery category view.
704  // 2) The category table figure isn't sane, like it's smaller than the
705  // number of actual results, *but* the number of results is less
706  // than $this->limit and there's no offset. In this case we still
707  // know the right figure.
708  // 3) We have no idea.
709 
710  // Check if there's a "from" or "until" for anything
711 
712  // This is a little ugly, but we seem to use different names
713  // for the paging types then for the messages.
714  if ( $type === 'article' ) {
715  $pagingType = 'page';
716  } else {
717  $pagingType = $type;
718  }
719 
720  $fromOrUntil = false;
721  if ( ( isset( $this->from[$pagingType] ) && $this->from[$pagingType] !== null ) ||
722  ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
723  ) {
724  $fromOrUntil = true;
725  }
726 
727  if ( $dbcnt == $rescnt ||
728  ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
729  ) {
730  // Case 1: seems sane.
731  $totalcnt = $dbcnt;
732  } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
733  // Case 2: not sane, but salvageable. Use the number of results.
734  // Since there are fewer than 200, we can also take this opportunity
735  // to refresh the incorrect category table entry -- which should be
736  // quick due to the small number of entries.
737  $totalcnt = $rescnt;
738  $category = $this->cat;
739  DeferredUpdates::addCallableUpdate( function () use ( $category ) {
740  $category->refreshCounts();
741  } );
742  } else {
743  // Case 3: hopeless. Don't give a total count at all.
744  // Messages: category-subcat-count-limited, category-article-count-limited,
745  // category-file-count-limited
746  return $this->msg( "category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
747  }
748  // Messages: category-subcat-count, category-article-count, category-file-count
749  return $this->msg( "category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
750  }
751 }
setContext(IContextSource $context)
Set the IContextSource object.
static newFromRow($row)
Make a Title object from a DB row.
Definition: Title.php:450
formatList($articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format...
array $articles_start_char
static closeElement($element)
Returns "".
Definition: Html.php:305
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:1936
Interface for objects which can provide a MediaWiki context on request.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
getLanguage()
Get the Language object.
generateLink($type, Title $title, $isRedirect, $html=null)
getText()
Get the text form (spaces not underscores) of the main part.
Definition: Title.php:880
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
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:1936
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
Definition: hooks.txt:2102
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:209
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
static singleton()
Definition: Collation.php:34
if(!isset($args[0])) $lang
isRedirect($flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
Definition: Title.php:3197
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
array $children_start_char
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 MediaWikiServices
Definition: injection.txt:23
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:1455
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
title
IContextSource $context
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:2889
$last
getRequest()
Get the WebRequest object.
static factory($mode=false, IContextSource $context=null)
Get a new image gallery.
getCountMessage($rescnt, $dbcnt, $type)
What to do if the category table conflicts with the number of results returned? This function says wh...
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getConfig()
Get the site configuration.
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:247
getTitle()
Definition: Category.php:245
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
getDBkey()
Get the main part with underscores.
Definition: Title.php:898
Collation $collation
$res
Definition: database.txt:21
getConfig()
Get the Config object.
getContext()
Get the base IContextSource object.
static newFromTitle($title)
Factory function.
Definition: Category.php:140
const NS_CATEGORY
Definition: Defines.php:70
ImageGallery $gallery
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:1936
array $query
The original query array, to be used in generating paging links.
addImage(Title $title, $sortkey, $pageLength, $isRedirect=false)
Add a page in the image namespace.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:255
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
getNamespace()
Get the namespace index, i.e.
Definition: Title.php:921
const NS_FILE
Definition: Defines.php:62
static columnList($articles, $articles_start_char)
Format a list of articles chunked by letter in a three-column list, ordered vertically.
getSubcategorySortChar($title, $sortkey)
Get the character to be used for sorting subcategories.
pagingLinks($first, $last, $type= '')
Create paging links, as a helper method to getSectionPagingLinks().
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
Definition: distributors.txt:9
addFragmentToTitle($title, $section)
Takes a title, and adds the fragment identifier that corresponds to the correct segment of the catego...
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:2889
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
Definition: Linker.php:203
array $imgsNoGallery_start_char
static getSelectFields()
Fields that LinkCache needs to select.
Definition: LinkCache.php:210
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
getSectionPagingLinks($type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output...
__construct($title, IContextSource $context, $from=[], $until=[], $query=[])
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:35
getCategorySortkey($prefix= '')
Returns the raw sort key to be used for categories, with the specified prefix.
Definition: Title.php:4616
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:56
addPage($title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
$count
static addCallableUpdate($callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
const DB_REPLICA
Definition: defines.php:22
static newFromRow($row, $title=null)
Factory function, for constructing a Category object from a result set.
Definition: Category.php:173
static shortList($articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
string[] $articles
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:2491
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:511
For a write query
Definition: database.txt:26
getHTML()
Format the category data list.
Category $cat
Category object for this page.
getOutput()
Get the OutputPage object.