Siebrand has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124162

Change subject: Remove classes used for supporting the old MediaWiki core format
......................................................................

Remove classes used for supporting the old MediaWiki core format

Change-Id: I2f8a7265a58c280f75071e19f513a97012fdaaf0
---
M _autoload.php
D ffs/Wiki.php
D messagegroups/CoreMessageGroup.php
D messagegroups/CoreMostUsedMessageGroup.php
4 files changed, 0 insertions(+), 470 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/62/124162/1

diff --git a/_autoload.php b/_autoload.php
index 1a26323..3f86498 100644
--- a/_autoload.php
+++ b/_autoload.php
@@ -60,8 +60,6 @@
  */
 $wgAutoloadClasses['SimpleFormatReader'] = "$dir/ffs/Simple.php";
 $wgAutoloadClasses['SimpleFormatWriter'] = "$dir/ffs/Simple.php";
-$wgAutoloadClasses['WikiFormatReader'] = "$dir/ffs/Wiki.php";
-$wgAutoloadClasses['WikiFormatWriter'] = "$dir/ffs/Wiki.php";
 /**@}*/
 
 /**
@@ -240,8 +238,6 @@
  * @{
  */
 $wgAutoloadClasses['AggregateMessageGroup'] = 
"$dir/messagegroups/AggregateMessageGroup.php";
-$wgAutoloadClasses['CoreMessageGroup'] = 
"$dir/messagegroups/CoreMessageGroup.php";
-$wgAutoloadClasses['CoreMostUsedMessageGroup'] = 
"$dir/messagegroups/CoreMostUsedMessageGroup.php";
 $wgAutoloadClasses['FileBasedMessageGroup'] = 
"$dir/messagegroups/FileBasedMessageGroup.php";
 $wgAutoloadClasses['MediaWikiMessageGroup'] = 
"$dir/messagegroups/MediaWikiMessageGroup.php";
 $wgAutoloadClasses['MediaWikiExtensionMessageGroup'] =
diff --git a/ffs/Wiki.php b/ffs/Wiki.php
deleted file mode 100644
index 74d99e0..0000000
--- a/ffs/Wiki.php
+++ /dev/null
@@ -1,259 +0,0 @@
-<?php
-/**
- * Wike file format handler.
- *
- * @author Niklas Laxström
- * @copyright Copyright © 2008-2010, Niklas Laxström
- * @license GPL-2.0+
- * @file
- */
-
-/**
- * Old-style parser for %MediaWiki i18n format (one file per language).
- */
-class WikiFormatReader extends SimpleFormatReader {
-       // Set by creater
-       public $variableName = 'messages';
-
-       /**
-        * Reads all \@author tags from the file and returns array of authors.
-        *
-        * @return \array List of authors.
-        */
-       public function parseAuthors() {
-               if ( $this->filename === false ) {
-                       return array();
-               }
-               $contents = file_get_contents( $this->filename );
-               $m = array();
-               preg_match_all( '/@author (.*)/', $contents, $m );
-
-               return $m[1];
-       }
-
-       /**
-        * @return string
-        */
-       public function parseStaticHeader() {
-               if ( $this->filename === false ) {
-                       return '';
-               }
-
-               $contents = file_get_contents( $this->filename );
-
-               // @todo Handle the case where the first comment is missing */
-               // $dollarstart = strpos( $contents, '$' );
-
-               $start = strpos( $contents, '*/' );
-               $end = strpos( $contents, '$messages' );
-
-               if ( $start === false ) {
-                       return '';
-               }
-
-               if ( $start === $end ) {
-                       return '';
-               }
-
-               $start += 2; // Get over the comment ending
-
-               if ( $end === false ) {
-                       return trim( substr( $contents, $start ) );
-               }
-
-               return trim( substr( $contents, $start, $end - $start ) );
-       }
-
-       public function parseMessages( StringMangler $mangler ) {
-               if ( $this->filename === false ) {
-                       return array();
-               }
-
-               ${$this->variableName} = array();
-               require $this->filename;
-
-               return $mangler->mangle( ${$this->variableName} );
-       }
-}
-
-/**
- * Old-style writer for %MediaWiki i18n format (one file per language).
- */
-class WikiFormatWriter extends SimpleFormatWriter {
-       public $commaToArray = false;
-
-       public function makeHeader( $handle, $code ) {
-               list( $name, $native ) = $this->getLanguageNames( $code );
-               $authors = $this->formatAuthors( ' * @author ', $code );
-
-               fwrite( $handle, <<<HEADER
-<?php
-/** $name ($native)
- *
- * See MessagesQqq.php for message documentation incl. usage of parameters
- * To improve a translation please visit http://translatewiki.net
- *
- * @ingroup Language
- * @file
- *
-$authors */
-
-HEADER
-               );
-       }
-
-       protected function exportStaticHeader( $target ) {
-               if ( $this->staticHeader ) {
-                       fwrite( $target, "\n" . $this->staticHeader . "\n" );
-               }
-       }
-
-       protected function exportMessages( $handle, MessageCollection 
$collection ) {
-               fwrite( $handle, "\n\$messages = array(\n" );
-
-               $messages = $this->makeExportArray( $collection );
-
-               $dir = $this->group->getMetaDataPrefix();
-               if ( !$dir ) {
-                       $this->writeMessagesBlock( $handle, $messages );
-                       fwrite( $handle, ");\n" );
-
-                       return;
-               }
-
-               require $dir . '/messages.inc';
-
-               # Sort messages to blocks
-               $sortedMessages['unknown'] = $messages;
-               foreach ( $wgMessageStructure as $blockName => $block ) {
-                       foreach ( $block as $key ) {
-                               if ( array_key_exists( $key, 
$sortedMessages['unknown'] ) ) {
-                                       $sortedMessages[$blockName][$key] = 
$sortedMessages['unknown'][$key];
-                                       unset( $sortedMessages['unknown'][$key] 
);
-                               }
-                       }
-               }
-
-               foreach ( $sortedMessages as $block => $messages ) {
-                       # Skip if it's the block of unknown messages - handle 
that in the end of file
-                       if ( $block === 'unknown' ) {
-                               continue;
-                       }
-
-                       $this->writeMessagesBlockComment( $handle, 
$wgBlockComments[$block] );
-                       $this->writeMessagesBlock( $handle, $messages );
-                       fwrite( $handle, "\n" );
-               }
-
-               # Write the unknown messages, alphabetically sorted.
-               if ( count( $sortedMessages['unknown'] ) ) {
-                       ksort( $sortedMessages['unknown'] );
-                       $this->writeMessagesBlockComment( $handle, 'Unknown 
messages' );
-                       $this->writeMessagesBlock( $handle, 
$sortedMessages['unknown'] );
-               }
-
-               fwrite( $handle, ");\n" );
-       }
-
-       /**
-        * Preprocesses MessageArray to suitable format and filters things that 
should
-        * not be exported.
-        *
-        * @param $messages MessageCollection Reference of MessageArray.
-        * @return Array of key-translation pairs.
-        */
-       public function makeExportArray( MessageCollection $messages ) {
-               // We copy only relevant translations to this new array
-               $new = array();
-               $mangler = $this->group->getMangler();
-
-               foreach ( $messages as $key => $m ) {
-                       $key = $mangler->unMangle( $key );
-                       # Remove fuzzy markings before export
-                       $translation = str_replace( TRANSLATE_FUZZY, '', 
$m->translation() );
-                       $new[$key] = $translation;
-               }
-
-               return $new;
-       }
-
-       protected function writeMessagesBlockComment( $handle, $blockComment ) {
-               # Format the block comment (if exists); check for multiple 
lines comments
-               if ( !empty( $blockComment ) ) {
-                       if ( strpos( $blockComment, "\n" ) === false ) {
-                               fwrite( $handle, "# $blockComment\n" );
-                       } else {
-                               fwrite( $handle, "/*\n$blockComment\n*/\n" );
-                       }
-               }
-       }
-
-       protected function writeMessagesBlock( $handle, $messages, $prefix = '' 
) {
-               # Skip the block if it includes no messages
-               if ( empty( $messages ) ) {
-                       return;
-               }
-
-               foreach ( $messages as $key => $value ) {
-                       fwrite( $handle, $prefix );
-                       $this->exportItemPad( $handle, $key, $value );
-               }
-       }
-
-       protected function exportItemPad( $handle, $key, $value, $pad = 0 ) {
-               # Add the key name
-               fwrite( $handle, "'$key'" );
-
-               # Add the appropriate block whitespace
-               if ( $pad ) {
-                       fwrite( $handle, str_repeat( ' ', $pad - strlen( $key ) 
) );
-               }
-
-               fwrite( $handle, ' => ' );
-
-               if ( $this->commaToArray ) {
-                       fwrite( $handle, 'array( ' );
-                       $values = array_map( 'trim', explode( ',', $value ) );
-                       $values = array_map( array( __CLASS__, 'quote' ), 
$values );
-                       fwrite( $handle, implode( ', ', $values ) );
-                       fwrite( $handle, " ),\n" );
-               } else {
-                       fwrite( $handle, self::quote( $value ) );
-                       fwrite( $handle, ",\n" );
-               }
-       }
-
-       public static function quote( $value ) {
-               # Check for the appropriate apostrophe and add the value
-               # Quote \ here, because it needs always escaping
-               $value = addcslashes( $value, '\\' );
-
-               # For readability
-               $single = "'";
-               $double = '"';
-               $quote = $single; // Default
-
-               # It is safe to use '-quoting, unless there is '-quote in the 
text
-               if ( strpos( $value, $single ) !== false ) {
-                       # In case there are no variables that need to be 
escaped, just use "-quote
-                       if ( strpos( $value, $double ) === false && 
!preg_match( '/\$[^0-9]/', $value ) ) {
-                               $quote = $double;
-                       } else {
-                               # Something needs quoting, so pick the quote 
which causes less quoting
-                               $doubleEsc = substr_count( $value, $double ) + 
substr_count( $value, '$' );
-                               $singleEsc = substr_count( $value, $single );
-
-                               if ( $doubleEsc < $singleEsc ) {
-                                       $quote = $double;
-                                       $extra = '$';
-                               } else {
-                                       $extra = '';
-                               }
-
-                               $value = addcslashes( $value, $quote . $extra );
-                       }
-               }
-
-               return $quote . $value . $quote;
-       }
-}
diff --git a/messagegroups/CoreMessageGroup.php 
b/messagegroups/CoreMessageGroup.php
deleted file mode 100644
index e9f281d..0000000
--- a/messagegroups/CoreMessageGroup.php
+++ /dev/null
@@ -1,154 +0,0 @@
-<?php
-/**
- * This file contains an unmanaged message group implementation.
- *
- * @file
- * @author Niklas Laxström
- * @author Siebrand Mazeland
- * @copyright Copyright © 2008-2013, Niklas Laxström, Siebrand Mazeland
- * @license GPL-2.0+
- */
-
-/**
- * This group supports the %MediaWiki messages.
- * @todo Move to the new interface.
- * @ingroup MessageGroup
- */
-class CoreMessageGroup extends MessageGroupOld {
-       protected $label = 'MediaWiki';
-       protected $id = 'core';
-       protected $type = 'mediawiki';
-       protected $description = '{{int:translate-group-desc-mediawikicore}}';
-       protected $icon;
-
-       public function __construct() {
-               parent::__construct();
-
-               global $IP;
-
-               $this->prefix = $IP . '/languages/messages';
-               $this->metaDataPrefix = $IP . '/maintenance/language';
-       }
-
-       protected $prefix = '';
-
-       public function getPrefix() {
-               return $this->prefix;
-       }
-
-       public function setPrefix( $value ) {
-               $this->prefix = $value;
-       }
-
-       protected $metaDataPrefix = '';
-
-       public function getMetaDataPrefix() {
-               return $this->metaDataPrefix;
-       }
-
-       public function setMetaDataPrefix( $value ) {
-               $this->metaDataPrefix = $value;
-       }
-
-       public $parentId = null;
-
-       public static function factory( $label, $id ) {
-               $group = new CoreMessageGroup;
-               $group->setLabel( $label );
-               $group->setId( $id );
-
-               return $group;
-       }
-
-       /// @see MessageGroup::getIcon
-       public function setIcon( $icon ) {
-               $this->icon = $icon;
-       }
-
-       public function getIcon() {
-               return $this->icon;
-       }
-
-       public function getUniqueDefinitions() {
-               if ( $this->parentId ) {
-                       $parent = MessageGroups::getGroup( $this->parentId );
-                       $parentDefs = $parent->getDefinitions();
-                       $ourDefs = $this->getDefinitions();
-
-                       // Filter out shared messages.
-                       foreach ( array_keys( $parentDefs ) as $key ) {
-                               unset( $ourDefs[$key] );
-                       }
-
-                       return $ourDefs;
-               }
-
-               return $this->getDefinitions();
-       }
-
-       public function getMessageFile( $code ) {
-               $code = ucfirst( str_replace( '-', '_', $code ) );
-
-               return "Messages$code.php";
-       }
-
-       public function getPath() {
-               return $this->prefix;
-       }
-
-       public function getReader( $code ) {
-               return new WikiFormatReader( $this->getMessageFileWithPath( 
$code ) );
-       }
-
-       public function getWriter() {
-               return new WikiFormatWriter( $this );
-       }
-
-       public function getTags( $type = null ) {
-               require $this->getMetaDataPrefix() . '/messageTypes.inc';
-               $mangler = $this->getMangler();
-               $this->optional = $mangler->mangle( $wgOptionalMessages );
-               $this->ignored = $mangler->mangle( $wgIgnoredMessages );
-
-               return parent::getTags( $type );
-       }
-
-       public function load( $code ) {
-               $file = $this->getMessageFileWithPath( $code );
-               // Can return null, convert to array.
-               $mangler = $this->getMangler();
-               $messages = (array)$mangler->mangle(
-                       PHPVariableLoader::loadVariableFromPHPFile( $file, 
'messages' )
-               );
-
-               if ( $this->parentId ) {
-                       if ( !$this->isSourceLanguage( $code ) ) {
-                               // For branches, load newer compatible messages 
for missing entries, if any.
-                               $trunk = MessageGroups::getGroup( 
$this->parentId );
-                               $messages += $trunk->getMangler()->mangle( 
$trunk->load( $code ) );
-                       }
-               }
-
-               return $messages;
-       }
-
-       public function getChecker() {
-               $checker = new MediaWikiMessageChecker( $this );
-               $checker->setChecks( array(
-                       array( $checker, 'pluralCheck' ),
-                       array( $checker, 'pluralFormsCheck' ),
-                       array( $checker, 'wikiParameterCheck' ),
-                       array( $checker, 'wikiLinksCheck' ),
-                       array( $checker, 'XhtmlCheck' ),
-                       array( $checker, 'braceBalanceCheck' ),
-                       array( $checker, 'pagenameMessagesCheck' ),
-                       array( $checker, 'miscMWChecks' )
-               ) );
-
-               return $checker;
-       }
-
-       public function getInsertablesSuggester() {
-               return new MediaWikiInsertablesSuggester();
-       }
-}
diff --git a/messagegroups/CoreMostUsedMessageGroup.php 
b/messagegroups/CoreMostUsedMessageGroup.php
deleted file mode 100644
index 9d90dca..0000000
--- a/messagegroups/CoreMostUsedMessageGroup.php
+++ /dev/null
@@ -1,53 +0,0 @@
-<?php
-/**
- * This file contains an unmanaged message group implementation.
- *
- * @file
- * @author Niklas Laxström
- * @author Siebrand Mazeland
- * @copyright Copyright © 2008-2013, Niklas Laxström, Siebrand Mazeland
- * @license GPL-2.0+
- */
-
-/**
- * This class implements the "Most used messages" group for %MediaWiki.
- * @todo Move to the new interface.
- * @ingroup MessageGroup
- */
-class CoreMostUsedMessageGroup extends CoreMessageGroup {
-       protected $label = 'MediaWiki (most used)';
-       protected $id = 'core-0-mostused';
-       protected $meta = true;
-       protected $list;
-
-       protected $description = 
'{{int:translate-group-desc-mediawikimostused}}';
-
-       public function export( MessageCollection $messages ) {
-               return 'Not supported';
-       }
-
-       public function exportToFile( MessageCollection $messages, $authors ) {
-               return 'Not supported';
-       }
-
-       public function setListFile( $file ) {
-               $this->list = $file;
-       }
-
-       function getDefinitions() {
-               $data = file_get_contents( $this->list );
-               $data = str_replace( "\r", '', $data );
-               $messages = explode( "\n", $data );
-               $contents = parent::getDefinitions();
-               $definitions = array();
-
-               foreach ( $messages as $key ) {
-                       if ( isset( $contents[$key] ) ) {
-                               $definitions[$key] = $contents[$key];
-                       }
-               }
-
-               return $definitions;
-       }
-}
-

-- 
To view, visit https://gerrit.wikimedia.org/r/124162
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2f8a7265a58c280f75071e19f513a97012fdaaf0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to