MediaWiki  1.29.2
checkDupeMessages.php
Go to the documentation of this file.
1 <?php
24 $optionsWithArgs = [ 'lang', 'clang', 'mode' ];
25 require_once __DIR__ . '/../commandLine.inc';
26 $messagesDir = __DIR__ . '/../../languages/messages/';
27 $runTest = false;
28 $run = false;
29 $runMode = 'text';
30 
31 // Check parameters
32 if ( isset( $options['lang'] ) && isset( $options['clang'] ) ) {
33  if ( !isset( $options['mode'] ) ) {
34  $runMode = 'text';
35  } else {
36  if ( !strcmp( $options['mode'], 'wiki' ) ) {
37  $runMode = 'wiki';
38  } elseif ( !strcmp( $options['mode'], 'php' ) ) {
39  $runMode = 'php';
40  } elseif ( !strcmp( $options['mode'], 'raw' ) ) {
41  $runMode = 'raw';
42  } else {
43  }
44  }
45  $runTest = true;
46 } else {
47  echo <<<TEXT
48 Run this script to print out the duplicates against a message array.
49 Parameters:
50  * lang: Language code to be checked.
51  * clang: Language code to be compared.
52 Options:
53  * mode: Output format, can be either:
54  * text: Text output on the console (default)
55  * wiki: Wiki format, with * at beginning of each line
56  * php: Output text as PHP syntax in an array named \$dupeMessages
57  * raw: Raw output for duplicates
58 TEXT;
59 }
60 
61 // Check file exists
62 if ( $runTest ) {
63  $langCode = $options['lang'];
64  $langCodeC = $options['clang'];
65  $langCodeF = ucfirst( strtolower( preg_replace( '/-/', '_', $langCode ) ) );
66  $langCodeFC = ucfirst( strtolower( preg_replace( '/-/', '_', $langCodeC ) ) );
67  $messagesFile = $messagesDir . 'Messages' . $langCodeF . '.php';
68  $messagesFileC = $messagesDir . 'Messages' . $langCodeFC . '.php';
69  if ( file_exists( $messagesFile ) && file_exists( $messagesFileC ) ) {
70  $run = true;
71  } else {
72  echo "Messages file(s) could not be found.\nMake sure both files are exists.\n";
73  }
74 }
75 
76 // Run to check the dupes
77 if ( $run ) {
78  if ( !strcmp( $runMode, 'wiki' ) ) {
79  $runMode = 'wiki';
80  } elseif ( !strcmp( $runMode, 'raw' ) ) {
81  $runMode = 'raw';
82  }
83  include $messagesFile;
84  $messageExist = isset( $messages );
85  if ( $messageExist ) {
86  $wgMessages[$langCode] = $messages;
87  }
88  include $messagesFileC;
89  $messageCExist = isset( $messages );
90  if ( $messageCExist ) {
91  $wgMessages[$langCodeC] = $messages;
92  }
93  $count = 0;
94 
95  if ( ( $messageExist ) && ( $messageCExist ) ) {
96 
97  if ( !strcmp( $runMode, 'php' ) ) {
98  print "<?php\n";
99  print '$dupeMessages = [' . "\n";
100  }
101  foreach ( $wgMessages[$langCodeC] as $key => $value ) {
102  foreach ( $wgMessages[$langCode] as $ckey => $cvalue ) {
103  if ( !strcmp( $key, $ckey ) ) {
104  if ( ( !strcmp( $key, $ckey ) ) && ( !strcmp( $value, $cvalue ) ) ) {
105  if ( !strcmp( $runMode, 'raw' ) ) {
106  print "$key\n";
107  } elseif ( !strcmp( $runMode, 'php' ) ) {
108  print "'$key' => '',\n";
109  } elseif ( !strcmp( $runMode, 'wiki' ) ) {
110  $uKey = ucfirst( $key );
111  print "* MediaWiki:$uKey/$langCode\n";
112  } else {
113  print "* $key\n";
114  }
115  $count++;
116  }
117  }
118  }
119  }
120  if ( !strcmp( $runMode, 'php' ) ) {
121  print "];\n";
122  }
123  if ( !strcmp( $runMode, 'text' ) ) {
124  if ( $count == 1 ) {
125  echo "\nThere are $count duplicated message in $langCode, against to $langCodeC.\n";
126  } else {
127  echo "\nThere are $count duplicated messages in $langCode, against to $langCodeC.\n";
128  }
129  }
130  } else {
131  if ( !$messageExist ) {
132  echo "There are no messages defined in $langCode.\n";
133  }
134  if ( !$messageCExist ) {
135  echo "There are no messages defined in $langCodeC.\n";
136  }
137  }
138 }
compared
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of compared
Definition: contenthandler.txt:5
$optionsWithArgs
$optionsWithArgs
Definition: checkDupeMessages.php:24
text
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 text
Definition: design.txt:12
wiki
Prior to maintenance scripts were a hodgepodge of code that had no cohesion or formal method of action Beginning maintenance scripts have been cleaned up to use a unified class Directory structure How to run a script How to write your own DIRECTORY STRUCTURE The maintenance directory of a MediaWiki installation contains several all of which have unique purposes HOW TO RUN A SCRIPT Ridiculously just call php someScript php that s in the top level maintenance directory if not default wiki
Definition: maintenance.txt:1
$messages
$messages
Definition: LogTests.i18n.php:8
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
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
script
script(document.cookie)%253c/script%253e</pre ></div > !! end !! test XSS is escaped(inline) !!input< source lang
code
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
Definition: hooks.txt:23
in
null for the wiki Added in
Definition: hooks.txt:1572
mode
if write to the Free Software Franklin Fifth MA USA Also add information on how to contact you by electronic and paper mail If the program is make it output a short notice like this when it starts in an interactive mode
Definition: COPYING.txt:307
message
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 message
Definition: hooks.txt:2114
$messagesDir
$messagesDir
Definition: checkDupeMessages.php:26
PHP
The ContentHandler facility adds support for arbitrary content types on wiki instead of relying on wikitext for everything It was introduced in MediaWiki Each kind of and so on Built in content types as usual *javascript user provided javascript code *json simple implementation for use by etc *css user provided css code *text plain text In PHP
Definition: contenthandler.txt:5
$value
$value
Definition: styleTest.css.php:45
on
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
Definition: hooks.txt:86
format
if the prop value should be in the metadata multi language array format
Definition: hooks.txt:1630
$runMode
$runMode
Definition: checkDupeMessages.php:29
output
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 and then calling output() to send it all. It could be easily changed to send incrementally if that becomes useful
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
$run
$run
Definition: checkDupeMessages.php:28
of
globals txt Globals are evil The original MediaWiki code relied on globals for processing context far too often MediaWiki development since then has been a story of slowly moving context out of global variables and into objects Storing processing context in object member variables allows those objects to be reused in a much more flexible way Consider the elegance of
Definition: globals.txt:10
$runTest
$runTest
Definition: checkDupeMessages.php:27
$options
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 and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
Definition: hooks.txt:1049
Language
Internationalisation code.
Definition: Language.php:35
line
I won t presume to tell you how to I m just describing the methods I chose to use for myself If you do choose to follow these it will probably be easier for you to collaborate with others on the but if you want to contribute without by all means do which work well I also use K &R brace matching style I know that s a religious issue for so if you want to use a style that puts opening braces on the next line
Definition: design.txt:79
array
the array() calling protocol came about after MediaWiki 1.4rc1.