WorkflowStatesMessageGroup.php

Go to the documentation of this file.
00001 <?php
00015 class WorkflowStatesMessageGroup extends WikiMessageGroup {
00016     // id and source are not needed
00017     public function __construct() {
00018     }
00019 
00020     public function getId() {
00021         return 'translate-workflow-states';
00022     }
00023 
00024     public function getLabel( IContextSource $context = null ) {
00025         $msg = wfMessage( 'translate-workflowgroup-label' );
00026         $msg = self::addContext( $msg, $context );
00027 
00028         return $msg->plain();
00029     }
00030 
00031     public function getDescription( IContextSource $context = null ) {
00032         $msg = wfMessage( 'translate-workflowgroup-desc' );
00033         $msg = self::addContext( $msg, $context );
00034 
00035         return $msg->plain();
00036     }
00037 
00038     public function getDefinitions() {
00039         $groups = MessageGroups::getAllGroups();
00040         $keys = array();
00041 
00045         foreach ( $groups as $g ) {
00046             $states = $g->getMessageGroupStates()->getStates();
00047             foreach ( array_keys( $states ) as $state ) {
00048                 $keys["Translate-workflow-state-$state"] = $state;
00049             }
00050         }
00051 
00052         $defs = TranslateUtils::getContents( array_keys( $keys ), $this->getNamespace() );
00053         foreach ( $keys as $key => $state ) {
00054             if ( !isset( $defs[$key] ) ) {
00055                 // @todo Use jobqueue
00056                 $title = Title::makeTitleSafe( $this->getNamespace(), $key );
00057                 $page = new WikiPage( $title );
00058                 $page->doEdit(
00059                     $state /*content*/,
00060                     wfMessage( 'translate-workflow-autocreated-summary', $state )->inContentLanguage()->text(),
00061                     0, /*flags*/
00062                     false, /* base revision id */
00063                     FuzzyBot::getUser()
00064                 );
00065             } else {
00066                 // Use the wiki translation as definition if available.
00067                 // getContents returns array( content, last author )
00068                 list( $content, ) = $defs[$key];
00069                 $keys[$key] = $content;
00070             }
00071         }
00072 
00073         return $keys;
00074     }
00075 }
Generated on Tue Oct 29 00:00:24 2013 for MediaWiki Translate Extension by  doxygen 1.6.3