MediaWiki  1.23.14
transstat.php
Go to the documentation of this file.
1 <?php
29 $optionsWithArgs = array( 'output' );
30 
31 require_once __DIR__ . '/../commandLine.inc';
32 require_once 'languages.inc';
33 require_once __DIR__ . '/StatOutputs.php';
34 
35 if ( isset( $options['help'] ) ) {
36  showUsage();
37 }
38 
39 # Default output is WikiText
40 if ( !isset( $options['output'] ) ) {
41  $options['output'] = 'wiki';
42 }
43 
45 function showUsage() {
46  print <<<TEXT
47 Usage: php transstat.php [--help] [--output=csv|text|wiki]
48  --help : this helpful message
49  --output : select an output engine one of:
50  * 'csv' : Comma Separated Values.
51  * 'wiki' : MediaWiki syntax (default).
52  * 'text' : Text with tabs.
53 Example: php maintenance/transstat.php --output=text
54 
55 TEXT;
56  exit( 1 );
57 }
58 
59 # Select an output engine
60 switch ( $options['output'] ) {
61  case 'wiki':
62  $output = new WikiStatsOutput();
63  break;
64  case 'text':
65  $output = new TextStatsOutput();
66  break;
67  case 'csv':
68  $output = new CsvStatsOutput();
69  break;
70  default:
71  showUsage();
72 }
73 
74 # Languages
75 $wgLanguages = new Languages();
76 
77 # Header
78 $output->heading();
79 $output->blockstart();
80 $output->element( 'Language', true );
81 $output->element( 'Code', true );
82 $output->element( 'Fallback', true );
83 $output->element( 'Translated', true );
84 $output->element( '%', true );
85 $output->element( 'Obsolete', true );
86 $output->element( '%', true );
87 $output->element( 'Problematic', true );
88 $output->element( '%', true );
89 $output->blockend();
90 
91 $wgGeneralMessages = $wgLanguages->getGeneralMessages();
93 
94 foreach ( $wgLanguages->getLanguages() as $code ) {
95  # Don't check English, RTL English or dummy language codes
96  if ( $code == 'en' || $code == 'enRTL' || ( is_array( $wgDummyLanguageCodes ) &&
97  isset( $wgDummyLanguageCodes[$code] ) )
98  ) {
99  continue;
100  }
101 
102  # Calculate the numbers
103  $language = Language::fetchLanguageName( $code );
104  $fallback = $wgLanguages->getFallback( $code );
105  $messages = $wgLanguages->getMessages( $code );
106  $messagesNumber = count( $messages['translated'] );
107  $requiredMessagesNumber = count( $messages['required'] );
108  $requiredMessagesPercent = $output->formatPercent(
109  $requiredMessagesNumber,
111  );
112  $obsoleteMessagesNumber = count( $messages['obsolete'] );
113  $obsoleteMessagesPercent = $output->formatPercent(
114  $obsoleteMessagesNumber,
115  $messagesNumber,
116  true
117  );
118  $messagesWithMismatchVariables = $wgLanguages->getMessagesWithMismatchVariables( $code );
119  $emptyMessages = $wgLanguages->getEmptyMessages( $code );
120  $messagesWithWhitespace = $wgLanguages->getMessagesWithWhitespace( $code );
121  $nonXHTMLMessages = $wgLanguages->getNonXHTMLMessages( $code );
122  $messagesWithWrongChars = $wgLanguages->getMessagesWithWrongChars( $code );
123  $problematicMessagesNumber = count( array_unique( array_merge(
124  $messagesWithMismatchVariables,
125  $emptyMessages,
126  $messagesWithWhitespace,
127  $nonXHTMLMessages,
128  $messagesWithWrongChars
129  ) ) );
130  $problematicMessagesPercent = $output->formatPercent(
131  $problematicMessagesNumber,
132  $messagesNumber,
133  true
134  );
135 
136  # Output them
137  $output->blockstart();
138  $output->element( "$language" );
139  $output->element( "$code" );
140  $output->element( "$fallback" );
141  $output->element( "$requiredMessagesNumber/$wgRequiredMessagesNumber" );
142  $output->element( $requiredMessagesPercent );
143  $output->element( "$obsoleteMessagesNumber/$messagesNumber" );
144  $output->element( $obsoleteMessagesPercent );
145  $output->element( "$problematicMessagesNumber/$messagesNumber" );
146  $output->element( $problematicMessagesPercent );
147  $output->blockend();
148 }
149 
150 # Footer
151 $output->footer();
CsvStatsOutput
csv output.
Definition: StatOutputs.php:137
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
$wgLanguages
switch( $options['output']) $wgLanguages
Definition: transstat.php:75
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
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
$fallback
$fallback
Definition: MessagesAb.php: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
TextStatsOutput
Output text.
Definition: StatOutputs.php:126
MediaWiki
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
$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:1530
$wgRequiredMessagesNumber
$wgRequiredMessagesNumber
Definition: transstat.php:92
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=null, $include='all')
Definition: Language.php:941
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
showUsage
if(isset( $options['help'])) if(!isset( $options['output'])) showUsage()
Print a usage message.
Definition: transstat.php:45
$output
& $output
Definition: hooks.txt:375
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
$optionsWithArgs
$optionsWithArgs
Definition: transstat.php:29
WikiStatsOutput
Outputs WikiText.
Definition: StatOutputs.php:53
$wgGeneralMessages
$wgGeneralMessages
Definition: transstat.php:91
select
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like select() and insert() are usually more convenient. They take care of things like table prefixes and escaping for you. If you really need to make your own SQL
message
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 after in associative array form externallinks including delete and has completed for all link tables 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:1624