MediaWiki  master
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 
46  public $showGallery;
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 
152  function clearCategoryState() {
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,
187  $title->isRedirect(),
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 ) {
199  $link = Linker::link( $title, $html );
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 ) {
365  $cat = Category::newFromRow( $row, $title );
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 
417  $displayTitle = $this->getOutput()->getPageTitle();
418  if ( $displayTitle === $this->getTitle()->getPrefixedText() ) {
419  return htmlspecialchars( $this->getTitle()->getText() );
420  } else {
421  return $displayTitle;
422  }
423  }
424 
428  function getPagesSection() {
429  $name = $this->getPrettyPageNameHtml();
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' )->rawParams( $name )->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  $name = $this->getPrettyPageNameHtml();
460  $r = '';
461  $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
462  $dbcnt = $this->cat->getFileCount();
463  // This function should be called even if the result isn't used, it has side-effects
464  $countmsg = $this->getCountMessage( $rescnt, $dbcnt, 'file' );
465 
466  if ( $rescnt > 0 ) {
467  $r .= "<div id=\"mw-category-media\">\n";
468  $r .= '<h2>' .
469  $this->msg( 'category-media-header' )->rawParams( $name )->parse() .
470  "</h2>\n";
471  $r .= $countmsg;
472  $r .= $this->getSectionPagingLinks( 'file' );
473  if ( $this->showGallery ) {
474  $r .= $this->gallery->toHTML();
475  } else {
476  $r .= $this->formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
477  }
478  $r .= $this->getSectionPagingLinks( 'file' );
479  $r .= "\n</div>";
480  }
481  return $r;
482  }
483 
491  private function getSectionPagingLinks( $type ) {
492  if ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
493  // The new value for the until parameter should be pointing to the first
494  // result displayed on the page which is the second last result retrieved
495  // from the database.The next link should have a from parameter pointing
496  // to the until parameter of the current page.
497  if ( $this->nextPage[$type] !== null ) {
498  return $this->pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
499  } else {
500  // If the nextPage variable is null, it means that we have reached the first page
501  // and therefore the previous link should be disabled.
502  return $this->pagingLinks( null, $this->until[$type], $type );
503  }
504  } elseif ( $this->nextPage[$type] !== null
505  || ( isset( $this->from[$type] ) && $this->from[$type] !== null )
506  ) {
507  return $this->pagingLinks( $this->from[$type], $this->nextPage[$type], $type );
508  } else {
509  return '';
510  }
511  }
512 
516  function getCategoryBottom() {
517  return '';
518  }
519 
530  function formatList( $articles, $articles_start_char, $cutoff = 6 ) {
531  $list = '';
532  if ( count( $articles ) > $cutoff ) {
533  $list = self::columnList( $articles, $articles_start_char );
534  } elseif ( count( $articles ) > 0 ) {
535  // for short lists of articles in categories.
536  $list = self::shortList( $articles, $articles_start_char );
537  }
538 
539  $pageLang = $this->title->getPageLanguage();
540  $attribs = [ 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
541  'class' => 'mw-content-' . $pageLang->getDir() ];
542  $list = Html::rawElement( 'div', $attribs, $list );
543 
544  return $list;
545  }
546 
562  $columns = array_combine( $articles, $articles_start_char );
563 
564  $ret = Html::openElement( 'div', [ 'class' => 'mw-category' ] );
565 
566  $colContents = [];
567 
568  # Kind of like array_flip() here, but we keep duplicates in an
569  # array instead of dropping them.
570  foreach ( $columns as $article => $char ) {
571  if ( !isset( $colContents[$char] ) ) {
572  $colContents[$char] = [];
573  }
574  $colContents[$char][] = $article;
575  }
576 
577  foreach ( $colContents as $char => $articles ) {
578  # Change space to non-breaking space to keep headers aligned
579  $h3char = $char === ' ' ? '&#160;' : htmlspecialchars( $char );
580 
581  $ret .= '<div class="mw-category-group"><h3>' . $h3char;
582  $ret .= "</h3>\n";
583 
584  $ret .= '<ul><li>';
585  $ret .= implode( "</li>\n<li>", $articles );
586  $ret .= '</li></ul></div>';
587 
588  }
589 
590  $ret .= Html::closeElement( 'div' );
591  return $ret;
592  }
593 
603  $r = '<h3>' . htmlspecialchars( $articles_start_char[0] ) . "</h3>\n";
604  $r .= '<ul><li>' . $articles[0] . '</li>';
605  $articleCount = count( $articles );
606  for ( $index = 1; $index < $articleCount; $index++ ) {
607  if ( $articles_start_char[$index] != $articles_start_char[$index - 1] ) {
608  $r .= "</ul><h3>" . htmlspecialchars( $articles_start_char[$index] ) . "</h3>\n<ul>";
609  }
610 
611  $r .= "<li>{$articles[$index]}</li>";
612  }
613  $r .= '</ul>';
614  return $r;
615  }
616 
626  private function pagingLinks( $first, $last, $type = '' ) {
627  $prevLink = $this->msg( 'prev-page' )->text();
628 
629  if ( $first != '' ) {
630  $prevQuery = $this->query;
631  $prevQuery["{$type}until"] = $first;
632  unset( $prevQuery["{$type}from"] );
633  $prevLink = Linker::linkKnown(
634  $this->addFragmentToTitle( $this->title, $type ),
635  $prevLink,
636  [],
637  $prevQuery
638  );
639  }
640 
641  $nextLink = $this->msg( 'next-page' )->text();
642 
643  if ( $last != '' ) {
644  $lastQuery = $this->query;
645  $lastQuery["{$type}from"] = $last;
646  unset( $lastQuery["{$type}until"] );
647  $nextLink = Linker::linkKnown(
648  $this->addFragmentToTitle( $this->title, $type ),
649  $nextLink,
650  [],
651  $lastQuery
652  );
653  }
654 
655  return $this->msg( 'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
656  }
657 
667  private function addFragmentToTitle( $title, $section ) {
668  switch ( $section ) {
669  case 'page':
670  $fragment = 'mw-pages';
671  break;
672  case 'subcat':
673  $fragment = 'mw-subcategories';
674  break;
675  case 'file':
676  $fragment = 'mw-category-media';
677  break;
678  default:
679  throw new MWException( __METHOD__ .
680  " Invalid section $section." );
681  }
682 
684  $title->getDBkey(), $fragment );
685  }
686 
697  private function getCountMessage( $rescnt, $dbcnt, $type ) {
698  // There are three cases:
699  // 1) The category table figure seems sane. It might be wrong, but
700  // we can't do anything about it if we don't recalculate it on ev-
701  // ery category view.
702  // 2) The category table figure isn't sane, like it's smaller than the
703  // number of actual results, *but* the number of results is less
704  // than $this->limit and there's no offset. In this case we still
705  // know the right figure.
706  // 3) We have no idea.
707 
708  // Check if there's a "from" or "until" for anything
709 
710  // This is a little ugly, but we seem to use different names
711  // for the paging types then for the messages.
712  if ( $type === 'article' ) {
713  $pagingType = 'page';
714  } else {
715  $pagingType = $type;
716  }
717 
718  $fromOrUntil = false;
719  if ( ( isset( $this->from[$pagingType] ) && $this->from[$pagingType] !== null ) ||
720  ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
721  ) {
722  $fromOrUntil = true;
723  }
724 
725  if ( $dbcnt == $rescnt ||
726  ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
727  ) {
728  // Case 1: seems sane.
729  $totalcnt = $dbcnt;
730  } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
731  // Case 2: not sane, but salvageable. Use the number of results.
732  // Since there are fewer than 200, we can also take this opportunity
733  // to refresh the incorrect category table entry -- which should be
734  // quick due to the small number of entries.
735  $totalcnt = $rescnt;
736  $category = $this->cat;
737  DeferredUpdates::addCallableUpdate( function () use ( $category ) {
738  $category->refreshCounts();
739  } );
740  } else {
741  // Case 3: hopeless. Don't give a total count at all.
742  // Messages: category-subcat-count-limited, category-article-count-limited,
743  // category-file-count-limited
744  return $this->msg( "category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
745  }
746  // Messages: category-subcat-count, category-article-count, category-file-count
747  return $this->msg( "category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
748  }
749 }
setContext(IContextSource $context)
Set the IContextSource object.
static newFromRow($row)
Make a Title object from a DB row.
Definition: Title.php:444
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 "</$element>".
Definition: Html.php:306
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:1816
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:872
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:189
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:1980
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:210
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:3167
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
getPrefixedText()
Get the prefixed title with spaces.
Definition: Title.php:1430
Represents a title within MediaWiki.
Definition: Title.php:36
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
IContextSource $context
getTitle()
Get the Title object.
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:2621
static addCallableUpdate($callable, $type=self::POSTSEND)
Add a callable update.
$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:248
getTitle()
Definition: Category.php:245
getDBkey()
Get the main part with underscores.
Definition: Title.php:890
Collation $collation
$res
Definition: database.txt:21
getConfig()
Get the Config object.
MediaWiki exception.
Definition: MWException.php:26
getContext()
Get the base IContextSource object.
static newFromTitle($title)
Factory function.
Definition: Category.php:140
const NS_CATEGORY
Definition: Defines.php:83
ImageGallery $gallery
array $query
The original query array, to be used in generating paging links.
const DB_SLAVE
Definition: Defines.php:46
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:913
const NS_FILE
Definition: Defines.php:75
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().
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:1816
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...
Category objects are immutable, strictly speaking.
Definition: Category.php:31
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:2755
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
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
getPrettyPageNameHtml()
Return pretty name which is display name if given and different from prefix text or the unprefixed pa...
getCategorySortkey($prefix= '')
Returns the raw sort key to be used for categories, with the specified prefix.
Definition: Title.php:4582
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
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
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:1816
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:2376
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:503
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.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:310