MediaWiki  1.30.0
DumpNamespaceFilter.php
Go to the documentation of this file.
1 <?php
31  public $invert = false;
32 
34  public $namespaces = [];
35 
41  function __construct( &$sink, $param ) {
42  parent::__construct( $sink );
43 
44  $constants = [
45  "NS_MAIN" => NS_MAIN,
46  "NS_TALK" => NS_TALK,
47  "NS_USER" => NS_USER,
48  "NS_USER_TALK" => NS_USER_TALK,
49  "NS_PROJECT" => NS_PROJECT,
50  "NS_PROJECT_TALK" => NS_PROJECT_TALK,
51  "NS_FILE" => NS_FILE,
52  "NS_FILE_TALK" => NS_FILE_TALK,
53  "NS_IMAGE" => NS_IMAGE, // NS_IMAGE is an alias for NS_FILE
54  "NS_IMAGE_TALK" => NS_IMAGE_TALK,
55  "NS_MEDIAWIKI" => NS_MEDIAWIKI,
56  "NS_MEDIAWIKI_TALK" => NS_MEDIAWIKI_TALK,
57  "NS_TEMPLATE" => NS_TEMPLATE,
58  "NS_TEMPLATE_TALK" => NS_TEMPLATE_TALK,
59  "NS_HELP" => NS_HELP,
60  "NS_HELP_TALK" => NS_HELP_TALK,
61  "NS_CATEGORY" => NS_CATEGORY,
62  "NS_CATEGORY_TALK" => NS_CATEGORY_TALK ];
63 
64  if ( $param { 0 } == '!' ) {
65  $this->invert = true;
66  $param = substr( $param, 1 );
67  }
68 
69  foreach ( explode( ',', $param ) as $key ) {
70  $key = trim( $key );
71  if ( isset( $constants[$key] ) ) {
72  $ns = $constants[$key];
73  $this->namespaces[$ns] = true;
74  } elseif ( is_numeric( $key ) ) {
75  $ns = intval( $key );
76  $this->namespaces[$ns] = true;
77  } else {
78  throw new MWException( "Unrecognized namespace key '$key'\n" );
79  }
80  }
81  }
82 
87  function pass( $page ) {
88  $match = isset( $this->namespaces[$page->page_namespace] );
89  return $this->invert xor $match;
90  }
91 }
DumpNamespaceFilter\pass
pass( $page)
Definition: DumpNamespaceFilter.php:87
NS_HELP
const NS_HELP
Definition: Defines.php:77
DumpNamespaceFilter
Definition: DumpNamespaceFilter.php:29
NS_IMAGE_TALK
const NS_IMAGE_TALK
Definition: Defines.php:96
NS_TEMPLATE_TALK
const NS_TEMPLATE_TALK
Definition: Defines.php:76
NS_FILE
const NS_FILE
Definition: Defines.php:71
NS_TEMPLATE
const NS_TEMPLATE
Definition: Defines.php:75
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
NS_MAIN
const NS_MAIN
Definition: Defines.php:65
namespaces
to move a page</td >< td > &*You are moving the page across namespaces
Definition: All_system_messages.txt:2670
MWException
MediaWiki exception.
Definition: MWException.php:26
NS_PROJECT
const NS_PROJECT
Definition: Defines.php:69
NS_IMAGE
const NS_IMAGE
NS_IMAGE and NS_IMAGE_TALK are the pre-v1.14 names for NS_FILE and NS_FILE_TALK respectively,...
Definition: Defines.php:92
NS_MEDIAWIKI_TALK
const NS_MEDIAWIKI_TALK
Definition: Defines.php:74
NS_CATEGORY
const NS_CATEGORY
Definition: Defines.php:79
NS_USER_TALK
const NS_USER_TALK
Definition: Defines.php:68
NS_PROJECT_TALK
const NS_PROJECT_TALK
Definition: Defines.php:70
DumpFilter
Definition: DumpFilter.php:31
DumpFilter\$sink
DumpOutput $sink
FIXME will need to be made protected whenever legacy code is updated.
Definition: DumpFilter.php:37
NS_HELP_TALK
const NS_HELP_TALK
Definition: Defines.php:78
DumpNamespaceFilter\$invert
bool $invert
Definition: DumpNamespaceFilter.php:31
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
DumpNamespaceFilter\__construct
__construct(&$sink, $param)
Definition: DumpNamespaceFilter.php:41
NS_USER
const NS_USER
Definition: Defines.php:67
NS_TALK
const NS_TALK
Definition: Defines.php:66
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:73
DumpNamespaceFilter\$namespaces
array $namespaces
Definition: DumpNamespaceFilter.php:34
NS_FILE_TALK
const NS_FILE_TALK
Definition: Defines.php:72
NS_CATEGORY_TALK
const NS_CATEGORY_TALK
Definition: Defines.php:80
array
the array() calling protocol came about after MediaWiki 1.4rc1.