MediaWiki  1.31.0
CategoryTree.php
Go to the documentation of this file.
1 <?php
29 class CategoryTree {
30  public $mOptions = [];
31 
35  public function __construct( $options ) {
36  global $wgCategoryTreeDefaultOptions;
37 
38  // ensure default values and order of options.
39  // Order may become important, it may influence the cache key!
40  foreach ( $wgCategoryTreeDefaultOptions as $option => $default ) {
41  if ( isset( $options[$option] ) ) {
42  $this->mOptions[$option] = $options[$option];
43  } else {
44  $this->mOptions[$option] = $default;
45  }
46  }
47 
48  $this->mOptions['mode'] = self::decodeMode( $this->mOptions['mode'] );
49 
50  if ( $this->mOptions['mode'] == CategoryTreeMode::PARENTS ) {
51  // namespace filter makes no sense with CategoryTreeMode::PARENTS
52  $this->mOptions['namespaces'] = false;
53  }
54 
55  $this->mOptions['hideprefix'] = self::decodeHidePrefix( $this->mOptions['hideprefix'] );
56  $this->mOptions['showcount'] = self::decodeBoolean( $this->mOptions['showcount'] );
57  $this->mOptions['namespaces'] = self::decodeNamespaces( $this->mOptions['namespaces'] );
58 
59  if ( $this->mOptions['namespaces'] ) {
60  # automatically adjust mode to match namespace filter
61  if ( count( $this->mOptions['namespaces'] ) === 1
62  && $this->mOptions['namespaces'][0] == NS_CATEGORY ) {
63  $this->mOptions['mode'] = CategoryTreeMode::CATEGORIES;
64  } elseif ( !in_array( NS_FILE, $this->mOptions['namespaces'] ) ) {
65  $this->mOptions['mode'] = CategoryTreeMode::PAGES;
66  } else {
67  $this->mOptions['mode'] = CategoryTreeMode::ALL;
68  }
69  }
70  }
71 
76  public function getOption( $name ) {
77  return $this->mOptions[$name];
78  }
79 
83  private function isInverse() {
84  return $this->getOption( 'mode' ) == CategoryTreeMode::PARENTS;
85  }
86 
91  private static function decodeNamespaces( $nn ) {
93 
94  if ( $nn === false || is_null( $nn ) ) {
95  return false;
96  }
97 
98  if ( !is_array( $nn ) ) {
99  $nn = preg_split( '![\s#:|]+!', $nn );
100  }
101 
102  $namespaces = [];
103 
104  foreach ( $nn as $n ) {
105  if ( is_int( $n ) ) {
106  $ns = $n;
107  } else {
108  $n = trim( $n );
109  if ( $n === '' ) {
110  continue;
111  }
112 
113  $lower = strtolower( $n );
114 
115  if ( is_numeric( $n ) ) {
116  $ns = (int)$n;
117  } elseif ( $n == '-' || $n == '_' || $n == '*' || $lower == 'main' ) {
118  $ns = NS_MAIN;
119  } else {
120  $ns = $wgContLang->getNsIndex( $n );
121  }
122  }
123 
124  if ( is_int( $ns ) ) {
125  $namespaces[] = $ns;
126  }
127  }
128 
129  sort( $namespaces ); # get elements into canonical order
130  return $namespaces;
131  }
132 
137  public static function decodeMode( $mode ) {
138  global $wgCategoryTreeDefaultOptions;
139 
140  if ( is_null( $mode ) ) {
141  return $wgCategoryTreeDefaultOptions['mode'];
142  }
143  if ( is_int( $mode ) ) {
144  return $mode;
145  }
146 
147  $mode = trim( strtolower( $mode ) );
148 
149  if ( is_numeric( $mode ) ) {
150  return (int)$mode;
151  }
152 
153  if ( $mode == 'all' ) {
154  $mode = CategoryTreeMode::ALL;
155  } elseif ( $mode == 'pages' ) {
156  $mode = CategoryTreeMode::PAGES;
157  } elseif ( $mode == 'categories' || $mode == 'sub' ) {
159  } elseif ( $mode == 'parents' || $mode == 'super' || $mode == 'inverse' ) {
161  } elseif ( $mode == 'default' ) {
162  $mode = $wgCategoryTreeDefaultOptions['mode'];
163  }
164 
165  return (int)$mode;
166  }
167 
174  public static function decodeBoolean( $value ) {
175  if ( is_null( $value ) ) {
176  return null;
177  }
178  if ( is_bool( $value ) ) {
179  return $value;
180  }
181  if ( is_int( $value ) ) {
182  return ( $value > 0 );
183  }
184 
185  $value = trim( strtolower( $value ) );
186  if ( is_numeric( $value ) ) {
187  return ( (int)$value > 0 );
188  }
189 
190  if ( $value == 'yes' || $value == 'y'
191  || $value == 'true' || $value == 't' || $value == 'on'
192  ) {
193  return true;
194  } elseif ( $value == 'no' || $value == 'n'
195  || $value == 'false' || $value == 'f' || $value == 'off'
196  ) {
197  return false;
198  } elseif ( $value == 'null' || $value == 'default' || $value == 'none' || $value == 'x' ) {
199  return null;
200  } else {
201  return false;
202  }
203  }
204 
209  public static function decodeHidePrefix( $value ) {
210  global $wgCategoryTreeDefaultOptions;
211 
212  if ( is_null( $value ) ) {
213  return $wgCategoryTreeDefaultOptions['hideprefix'];
214  }
215  if ( is_int( $value ) ) {
216  return $value;
217  }
218  if ( $value === true ) {
220  }
221  if ( $value === false ) {
223  }
224 
225  $value = trim( strtolower( $value ) );
226 
227  if ( $value == 'yes' || $value == 'y'
228  || $value == 'true' || $value == 't' || $value == 'on'
229  ) {
231  } elseif ( $value == 'no' || $value == 'n'
232  || $value == 'false' || $value == 'f' || $value == 'off'
233  ) {
235  } elseif ( $value == 'always' ) {
237  } elseif ( $value == 'never' ) {
239  } elseif ( $value == 'auto' ) {
241  } elseif ( $value == 'categories' || $value == 'category' || $value == 'smart' ) {
243  } else {
244  return $wgCategoryTreeDefaultOptions['hideprefix'];
245  }
246  }
247 
252  public static function setHeaders( $outputPage ) {
253  # Add the modules
254  $outputPage->addModuleStyles( 'ext.categoryTree.css' );
255  $outputPage->addModules( 'ext.categoryTree' );
256  }
257 
264  protected static function encodeOptions( $options, $enc ) {
265  if ( $enc == 'mode' || $enc == '' ) {
266  $opt = $options['mode'];
267  } elseif ( $enc == 'json' ) {
269  } else {
270  throw new Exception( 'Unknown encoding for CategoryTree options: ' . $enc );
271  }
272 
273  return $opt;
274  }
275 
280  public function getOptionsAsCacheKey( $depth = null ) {
281  $key = "";
282 
283  foreach ( $this->mOptions as $k => $v ) {
284  if ( is_array( $v ) ) {
285  $v = implode( '|', $v );
286  }
287  $key .= $k . ':' . $v . ';';
288  }
289 
290  if ( !is_null( $depth ) ) {
291  $key .= ";depth=" . $depth;
292  }
293  return $key;
294  }
295 
300  public function getOptionsAsJsStructure( $depth = null ) {
301  if ( $depth !== null ) {
303  $opt['depth'] = $depth;
304  $s = self::encodeOptions( $opt, 'json' );
305  } else {
306  $s = self::encodeOptions( $this->mOptions, 'json' );
307  }
308 
309  return $s;
310  }
311 
315  private function getOptionsAsUrlParameters() {
316  return http_build_query( $this->mOptions );
317  }
318 
330  public function getTag( $parser, $category, $hideroot = false, $attr = [], $depth = 1,
331  $allowMissing = false
332  ) {
333  global $wgCategoryTreeDisableCache;
334 
335  $category = trim( $category );
336  if ( $category === '' ) {
337  return false;
338  }
339 
340  if ( $parser ) {
341  if ( $wgCategoryTreeDisableCache === true ) {
342  $parser->disableCache();
343  } elseif ( is_int( $wgCategoryTreeDisableCache ) ) {
344  $parser->getOutput()->updateCacheExpiry( $wgCategoryTreeDisableCache );
345  }
346  }
347 
348  $title = self::makeTitle( $category );
349 
350  if ( $title === false || $title === null ) {
351  return false;
352  }
353 
354  if ( isset( $attr['class'] ) ) {
355  $attr['class'] .= ' CategoryTreeTag';
356  } else {
357  $attr['class'] = ' CategoryTreeTag';
358  }
359 
360  $attr['data-ct-mode'] = $this->mOptions['mode'];
361  $attr['data-ct-options'] = $this->getOptionsAsJsStructure();
362 
363  $html = '';
364  $html .= Html::openElement( 'div', $attr );
365 
366  if ( !$allowMissing && !$title->getArticleID() ) {
367  $html .= Html::openElement( 'span', [ 'class' => 'CategoryTreeNotice' ] );
368  if ( $parser ) {
369  $html .= $parser->recursiveTagParse(
370  wfMessage( 'categorytree-not-found', $category )->plain() );
371  } else {
372  $html .= wfMessage( 'categorytree-not-found', $category )->parse();
373  }
374  $html .= Html::closeElement( 'span' );
375  } else {
376  if ( !$hideroot ) {
377  $html .= $this->renderNode( $title, $depth );
378  } else {
379  $html .= $this->renderChildren( $title, $depth );
380  }
381  }
382 
383  $html .= Xml::closeElement( 'div' );
384  $html .= "\n\t\t";
385 
386  return $html;
387  }
388 
395  public function renderChildren( $title, $depth = 1 ) {
396  global $wgCategoryTreeMaxChildren, $wgCategoryTreeUseCategoryTable;
397 
398  if ( $title->getNamespace() != NS_CATEGORY ) {
399  // Non-categories can't have children. :)
400  return '';
401  }
402 
403  $dbr = wfGetDB( DB_REPLICA );
404 
405  $inverse = $this->isInverse();
406  $mode = $this->getOption( 'mode' );
407  $namespaces = $this->getOption( 'namespaces' );
408 
409  $tables = [ 'page', 'categorylinks' ];
410  $fields = [ 'page_id', 'page_namespace', 'page_title',
411  'page_is_redirect', 'page_len', 'page_latest', 'cl_to',
412  'cl_from' ];
413  $where = [];
414  $joins = [];
415  $options = [ 'ORDER BY' => 'cl_type, cl_sortkey', 'LIMIT' => $wgCategoryTreeMaxChildren ];
416 
417  if ( $inverse ) {
418  $joins['categorylinks'] = [ 'RIGHT JOIN', [
419  'cl_to = page_title', 'page_namespace' => NS_CATEGORY
420  ] ];
421  $where['cl_from'] = $title->getArticleID();
422  } else {
423  $joins['categorylinks'] = [ 'JOIN', 'cl_from = page_id' ];
424  $where['cl_to'] = $title->getDBkey();
425  $options['USE INDEX']['categorylinks'] = 'cl_sortkey';
426 
427  # namespace filter.
428  if ( $namespaces ) {
429  // NOTE: we assume that the $namespaces array contains only integers!
430  // decodeNamepsaces makes it so.
431  $where['page_namespace'] = $namespaces;
432  } elseif ( $mode != CategoryTreeMode::ALL ) {
433  if ( $mode == CategoryTreeMode::PAGES ) {
434  $where['cl_type'] = [ 'page', 'subcat' ];
435  } else {
436  $where['cl_type'] = 'subcat';
437  }
438  }
439  }
440 
441  # fetch member count if possible
442  $doCount = !$inverse && $wgCategoryTreeUseCategoryTable;
443 
444  if ( $doCount ) {
445  $tables = array_merge( $tables, [ 'category' ] );
446  $fields = array_merge( $fields, [
447  'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files'
448  ] );
449  $joins['category'] = [ 'LEFT JOIN', [
450  'cat_title = page_title', 'page_namespace' => NS_CATEGORY ]
451  ];
452  }
453 
454  $res = $dbr->select( $tables, $fields, $where, __METHOD__, $options, $joins );
455 
456  # collect categories separately from other pages
457  $categories = '';
458  $other = '';
459 
460  foreach ( $res as $row ) {
461  # NOTE: in inverse mode, the page record may be null, because we use a right join.
462  # happens for categories with no category page (red cat links)
463  if ( $inverse && $row->page_title === null ) {
464  $t = Title::makeTitle( NS_CATEGORY, $row->cl_to );
465  } else {
466  # TODO: translation support; ideally added to Title object
467  $t = Title::newFromRow( $row );
468  }
469 
470  $cat = null;
471 
472  if ( $doCount && $row->page_namespace == NS_CATEGORY ) {
473  $cat = Category::newFromRow( $row, $t );
474  }
475 
476  $s = $this->renderNodeInfo( $t, $cat, $depth - 1 );
477  $s .= "\n\t\t";
478 
479  if ( $row->page_namespace == NS_CATEGORY ) {
480  $categories .= $s;
481  } else {
482  $other .= $s;
483  }
484  }
485 
486  return $categories . $other;
487  }
488 
494  public function renderParents( $title ) {
495  global $wgCategoryTreeMaxChildren;
496 
497  $dbr = wfGetDB( DB_REPLICA );
498 
499  $res = $dbr->select(
500  'categorylinks',
501  [
502  'page_namespace' => NS_CATEGORY,
503  'page_title' => 'cl_to',
504  ],
505  [ 'cl_from' => $title->getArticleID() ],
506  __METHOD__,
507  [
508  'LIMIT' => $wgCategoryTreeMaxChildren,
509  'ORDER BY' => 'cl_to'
510  ]
511  );
512 
513  $special = SpecialPage::getTitleFor( 'CategoryTree' );
514 
515  $s = '';
516 
517  foreach ( $res as $row ) {
518  $t = Title::newFromRow( $row );
519 
520  $label = htmlspecialchars( $t->getText() );
521 
522  $wikiLink = $special->getLocalURL( 'target=' . $t->getPartialURL() .
523  '&' . $this->getOptionsAsUrlParameters() );
524 
525  if ( $s !== '' ) {
526  $s .= wfMessage( 'pipe-separator' )->escaped();
527  }
528 
529  $s .= Xml::openElement( 'span', [ 'class' => 'CategoryTreeItem' ] );
530  $s .= Xml::openElement( 'a', [ 'class' => 'CategoryTreeLabel', 'href' => $wikiLink ] )
531  . $label . Xml::closeElement( 'a' );
532  $s .= Xml::closeElement( 'span' );
533 
534  $s .= "\n\t\t";
535  }
536 
537  return $s;
538  }
539 
546  public function renderNode( $title, $children = 0 ) {
547  global $wgCategoryTreeUseCategoryTable;
548 
549  if ( $wgCategoryTreeUseCategoryTable && $title->getNamespace() == NS_CATEGORY
550  && !$this->isInverse()
551  ) {
552  $cat = Category::newFromTitle( $title );
553  } else {
554  $cat = null;
555  }
556 
557  return $this->renderNodeInfo( $title, $cat, $children );
558  }
559 
568  public function renderNodeInfo( $title, $cat, $children = 0 ) {
569  $mode = $this->getOption( 'mode' );
570 
571  $ns = $title->getNamespace();
572  $key = $title->getDBkey();
573 
574  $hideprefix = $this->getOption( 'hideprefix' );
575 
576  if ( $hideprefix == CategoryTreeHidePrefix::ALWAYS ) {
577  $hideprefix = true;
578  } elseif ( $hideprefix == CategoryTreeHidePrefix::AUTO ) {
579  $hideprefix = ( $mode == CategoryTreeMode::CATEGORIES );
580  } elseif ( $hideprefix == CategoryTreeHidePrefix::CATEGORIES ) {
581  $hideprefix = ( $ns == NS_CATEGORY );
582  } else {
583  $hideprefix = true;
584  }
585 
586  // when showing only categories, omit namespace in label unless we explicitely defined the
587  // configuration setting
588  // patch contributed by Manuel Schneider <manuel.schneider@wikimedia.ch>, Bug 8011
589  if ( $hideprefix ) {
590  $label = htmlspecialchars( $title->getText() );
591  } else {
592  $label = htmlspecialchars( $title->getPrefixedText() );
593  }
594 
595  $labelClass = 'CategoryTreeLabel ' . ' CategoryTreeLabelNs' . $ns;
596 
597  if ( !$title->getArticleID() ) {
598  $labelClass .= ' new';
599  $wikiLink = $title->getLocalURL( 'action=edit&redlink=1' );
600  } else {
601  $wikiLink = $title->getLocalURL();
602  }
603 
604  if ( $ns == NS_CATEGORY ) {
605  $labelClass .= ' CategoryTreeLabelCategory';
606  } else {
607  $labelClass .= ' CategoryTreeLabelPage';
608  }
609 
610  if ( ( $ns % 2 ) > 0 ) {
611  $labelClass .= ' CategoryTreeLabelTalk';
612  }
613 
614  $count = false;
615  $s = '';
616 
617  # NOTE: things in CategoryTree.js rely on the exact order of tags!
618  # Specifically, the CategoryTreeChildren div must be the first
619  # sibling with nodeName = DIV of the grandparent of the expland link.
620 
621  $s .= Xml::openElement( 'div', [ 'class' => 'CategoryTreeSection' ] );
622  $s .= Xml::openElement( 'div', [ 'class' => 'CategoryTreeItem' ] );
623 
624  $attr = [ 'class' => 'CategoryTreeBullet' ];
625 
626  if ( $ns == NS_CATEGORY ) {
627  if ( $cat ) {
628  if ( $mode == CategoryTreeMode::CATEGORIES ) {
629  $count = intval( $cat->getSubcatCount() );
630  } elseif ( $mode == CategoryTreeMode::PAGES ) {
631  $count = intval( $cat->getPageCount() ) - intval( $cat->getFileCount() );
632  } else {
633  $count = intval( $cat->getPageCount() );
634  }
635  }
636  if ( $count === 0 ) {
637  $bullet = wfMessage( 'categorytree-empty-bullet' )->plain() . ' ';
638  $attr['class'] = 'CategoryTreeEmptyBullet';
639  } else {
640  $linkattr = [];
641 
642  $linkattr[ 'class' ] = "CategoryTreeToggle";
643  $linkattr['data-ct-title'] = $key;
644 
645  $tag = 'span';
646  if ( $children == 0 ) {
647  $txt = wfMessage( 'categorytree-expand-bullet' )->plain();
648  $linkattr[ 'data-ct-state' ] = 'collapsed';
649  } else {
650  $txt = wfMessage( 'categorytree-collapse-bullet' )->plain();
651  $linkattr[ 'data-ct-loaded' ] = true;
652  $linkattr[ 'data-ct-state' ] = 'expanded';
653  }
654 
655  $bullet = Xml::openElement( $tag, $linkattr ) . $txt . Xml::closeElement( $tag ) . ' ';
656  }
657  } else {
658  $bullet = wfMessage( 'categorytree-page-bullet' )->plain();
659  }
660  $s .= Xml::tags( 'span', $attr, $bullet ) . ' ';
661 
662  $s .= Xml::openElement( 'a', [ 'class' => $labelClass, 'href' => $wikiLink ] )
663  . $label . Xml::closeElement( 'a' );
664 
665  if ( $count !== false && $this->getOption( 'showcount' ) ) {
666  $s .= self::createCountString( RequestContext::getMain(), $cat, $count );
667  }
668 
669  $s .= Xml::closeElement( 'div' );
670  $s .= "\n\t\t";
671  $s .= Xml::openElement(
672  'div',
673  [
674  'class' => 'CategoryTreeChildren',
675  'style' => $children > 0 ? "display:block" : "display:none"
676  ]
677  );
678 
679  if ( $ns == NS_CATEGORY && $children > 0 ) {
680  $children = $this->renderChildren( $title, $children );
681  if ( $children == '' ) {
682  $s .= Xml::openElement( 'i', [ 'class' => 'CategoryTreeNotice' ] );
683  if ( $mode == CategoryTreeMode::CATEGORIES ) {
684  $s .= wfMessage( 'categorytree-no-subcategories' )->text();
685  } elseif ( $mode == CategoryTreeMode::PAGES ) {
686  $s .= wfMessage( 'categorytree-no-pages' )->text();
687  } elseif ( $mode == CategoryTreeMode::PARENTS ) {
688  $s .= wfMessage( 'categorytree-no-parent-categories' )->text();
689  } else {
690  $s .= wfMessage( 'categorytree-nothing-found' )->text();
691  }
692  $s .= Xml::closeElement( 'i' );
693  } else {
694  $s .= $children;
695  }
696  }
697 
698  $s .= Xml::closeElement( 'div' );
699  $s .= Xml::closeElement( 'div' );
700 
701  $s .= "\n\t\t";
702 
703  return $s;
704  }
705 
713  public static function createCountString( IContextSource $context, $cat, $countMode ) {
715 
716  # Get counts, with conversion to integer so === works
717  # Note: $allCount is the total number of cat members,
718  # not the count of how many members are normal pages.
719  $allCount = $cat ? intval( $cat->getPageCount() ) : 0;
720  $subcatCount = $cat ? intval( $cat->getSubcatCount() ) : 0;
721  $fileCount = $cat ? intval( $cat->getFileCount() ) : 0;
722  $pages = $allCount - $subcatCount - $fileCount;
723 
724  $attr = [
725  'title' => $context->msg( 'categorytree-member-counts' )
726  ->numParams( $subcatCount, $pages, $fileCount, $allCount, $countMode )->text(),
727  'dir' => $context->getLanguage()->getDir() # numbers and commas get messed up in a mixed dir env
728  ];
729 
730  $s = $wgContLang->getDirMark() . ' ';
731 
732  # Create a list of category members with only non-zero member counts
733  $memberNums = [];
734  if ( $subcatCount ) {
735  $memberNums[] = $context->msg( 'categorytree-num-categories' )
736  ->numParams( $subcatCount )->text();
737  }
738  if ( $pages ) {
739  $memberNums[] = $context->msg( 'categorytree-num-pages' )->numParams( $pages )->text();
740  }
741  if ( $fileCount ) {
742  $memberNums[] = $context->msg( 'categorytree-num-files' )
743  ->numParams( $fileCount )->text();
744  }
745  $memberNumsShort = $memberNums
746  ? $context->getLanguage()->commaList( $memberNums )
747  : $context->msg( 'categorytree-num-empty' )->text();
748 
749  # Only $5 is actually used in the default message.
750  # Other arguments can be used in a customized message.
751  $s .= Xml::tags(
752  'span',
753  $attr,
754  $context->msg( 'categorytree-member-num' )
755  // Do not use numParams on params 1-4, as they are only used for customisation.
756  ->params( $subcatCount, $pages, $fileCount, $allCount, $memberNumsShort )
757  ->escaped()
758  );
759 
760  return $s;
761  }
762 
768  public static function makeTitle( $title ) {
769  $title = trim( $title );
770 
771  if ( strval( $title ) === '' ) {
772  return null;
773  }
774 
775  # The title must be in the category namespace
776  # Ignore a leading Category: if there is one
778  if ( !$t || $t->getNamespace() != NS_CATEGORY || $t->getInterwiki() != '' ) {
779  // If we were given something like "Wikipedia:Foo" or "Template:",
780  // try it again but forced.
781  $title = "Category:$title";
783  }
784  return $t;
785  }
786 
793  public static function capDepth( $mode, $depth ) {
794  global $wgCategoryTreeMaxDepth;
795 
796  if ( is_numeric( $depth ) ) {
797  $depth = intval( $depth );
798  } else {
799  return 1;
800  }
801 
802  if ( is_array( $wgCategoryTreeMaxDepth ) ) {
803  $max = isset( $wgCategoryTreeMaxDepth[$mode] ) ? $wgCategoryTreeMaxDepth[$mode] : 1;
804  } elseif ( is_numeric( $wgCategoryTreeMaxDepth ) ) {
805  $max = $wgCategoryTreeMaxDepth;
806  } else {
807  wfDebug( 'CategoryTree::capDepth: $wgCategoryTreeMaxDepth is invalid.' );
808  $max = 1;
809  }
810 
811  return min( $depth, $max );
812  }
813 }
CategoryTree\getTag
getTag( $parser, $category, $hideroot=false, $attr=[], $depth=1, $allowMissing=false)
Custom tag implementation.
Definition: CategoryTree.php:330
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:273
$tables
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist & $tables
Definition: hooks.txt:990
CategoryTree\getOption
getOption( $name)
Definition: CategoryTree.php:76
CategoryTree\isInverse
isInverse()
Definition: CategoryTree.php:83
$context
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
Definition: hooks.txt:2604
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
CategoryTree\capDepth
static capDepth( $mode, $depth)
Internal function to cap depth.
Definition: CategoryTree.php:793
CategoryTree\decodeMode
static decodeMode( $mode)
Definition: CategoryTree.php:137
$opt
$opt
Definition: postprocess-phan.php:115
captcha-old.count
count
Definition: captcha-old.py:249
CategoryTree\renderChildren
renderChildren( $title, $depth=1)
Returns a string with an HTML representation of the children of the given category.
Definition: CategoryTree.php:395
CategoryTree\renderNodeInfo
renderNodeInfo( $title, $cat, $children=0)
Returns a string with a HTML represenation of the given page.
Definition: CategoryTree.php:568
$namespaces
namespace and then decline to actually register it & $namespaces
Definition: hooks.txt:934
NS_FILE
const NS_FILE
Definition: Defines.php:71
CategoryTree
Core functions for the CategoryTree extension, an AJAX based gadget to display the category structure...
Definition: CategoryTree.php:29
$s
$s
Definition: mergeMessageFileList.php:187
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Definition: SpecialPage.php:82
a
</source > ! result< div class="mw-highlight mw-content-ltr" dir="ltr">< pre >< span ></span >< span class="kd"> var</span >< span class="nx"> a</span >< span class="p"></span ></pre ></div > ! end ! test Multiline< source/> in lists !input *< source > a b</source > *foo< source > a b</source > ! html< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! html tidy< ul >< li >< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul >< ul >< li > foo< div class="mw-highlight mw-content-ltr" dir="ltr">< pre > a b</pre ></div ></li ></ul > ! end ! test Custom attributes !input< source lang="javascript" id="foo" class="bar" dir="rtl" style="font-size: larger;"> var a
Definition: parserTests.txt:89
$res
$res
Definition: database.txt:21
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
CategoryTree\decodeHidePrefix
static decodeHidePrefix( $value)
Definition: CategoryTree.php:209
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
CategoryTree\setHeaders
static setHeaders( $outputPage)
Add ResourceLoader modules to the OutputPage object.
Definition: CategoryTree.php:252
php
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
CategoryTreeHidePrefix\NEVER
const NEVER
Definition: CategoryTreeHidePrefix.php:31
CategoryTreeMode\PAGES
const PAGES
Definition: CategoryTreeMode.php:32
$dbr
$dbr
Definition: testCompression.php:50
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
Html\closeElement
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:309
FormatJson\encode
static encode( $value, $pretty=false, $escaping=0)
Returns the JSON representation of a value.
Definition: FormatJson.php:127
$html
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:1987
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
Title\newFromRow
static newFromRow( $row)
Make a Title object from a DB row.
Definition: Title.php:464
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2800
CategoryTreeHidePrefix\ALWAYS
const ALWAYS
Definition: CategoryTreeHidePrefix.php:33
in
null for the wiki Added in
Definition: hooks.txt:1591
CategoryTree\__construct
__construct( $options)
Definition: CategoryTree.php:35
$parser
do that in ParserLimitReportFormat instead $parser
Definition: hooks.txt:2595
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:534
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:79
wfDebug
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
Definition: GlobalFunctions.php:982
Category\newFromRow
static newFromRow( $row, $title=null)
Factory function, for constructing a Category object from a result set.
Definition: Category.php:179
Category\newFromTitle
static newFromTitle( $title)
Factory function.
Definition: Category.php:146
$value
$value
Definition: styleTest.css.php:45
CategoryTreeMode\PARENTS
const PARENTS
Definition: CategoryTreeMode.php:36
CategoryTree\$mOptions
$mOptions
Definition: CategoryTree.php:30
CategoryTreeMode\ALL
const ALL
Definition: CategoryTreeMode.php:34
CategoryTree\decodeBoolean
static decodeBoolean( $value)
Helper function to convert a string to a boolean value.
Definition: CategoryTree.php:174
$special
this hook is for auditing only RecentChangesLinked and Watchlist $special
Definition: hooks.txt:990
RequestContext\getMain
static getMain()
Get the RequestContext object associated with the main request.
Definition: RequestContext.php:434
CategoryTree\renderParents
renderParents( $title)
Returns a string with an HTML representation of the parents of the given category.
Definition: CategoryTree.php:494
plain
either a plain
Definition: hooks.txt:2048
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:53
CategoryTree\getOptionsAsUrlParameters
getOptionsAsUrlParameters()
Definition: CategoryTree.php:315
and
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
up
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set up
Definition: hooks.txt:2220
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
CategoryTree\getOptionsAsCacheKey
getOptionsAsCacheKey( $depth=null)
Definition: CategoryTree.php:280
$options
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 & $options
Definition: hooks.txt:1987
CategoryTreeHidePrefix\AUTO
const AUTO
Definition: CategoryTreeHidePrefix.php:37
as
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
Html\openElement
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
CategoryTree\encodeOptions
static encodeOptions( $options, $enc)
Definition: CategoryTree.php:264
CategoryTree\makeTitle
static makeTitle( $title)
Creates a Title object from a user provided (and thus unsafe) string.
Definition: CategoryTree.php:768
wfMessage
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "&lt
$t
$t
Definition: testCompression.php:69
CategoryTree\getOptionsAsJsStructure
getOptionsAsJsStructure( $depth=null)
Definition: CategoryTree.php:300
CategoryTreeMode\CATEGORIES
const CATEGORIES
Definition: CategoryTreeMode.php:30
CategoryTreeHidePrefix\CATEGORIES
const CATEGORIES
Definition: CategoryTreeHidePrefix.php:35
order
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add in any order
Definition: design.txt:12
CategoryTree\renderNode
renderNode( $title, $children=0)
Returns a string with a HTML represenation of the given page.
Definition: CategoryTree.php:546
CategoryTree\decodeNamespaces
static decodeNamespaces( $nn)
Definition: CategoryTree.php:91
$wgContLang
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 content language as $wgContLang
Definition: design.txt:56
CategoryTree\createCountString
static createCountString(IContextSource $context, $cat, $countMode)
Create a string which format the page, subcat and file counts of a category.
Definition: CategoryTree.php:713