InsertablesAid.php

Go to the documentation of this file.
00001 <?php
00017 class InsertablesAid extends TranslationAid {
00018     public function getData() {
00019 
00020         // We need to get the primary group to get the correct file
00021         // So $group can be different from $this->group
00022         $group = $this->handle->getGroup();
00023 
00024         // This was added later, so not all classes have it. In addition
00025         // the message group class hierarche doesn't lend itself easily
00026         // to the user of interfaces for this purpose.
00027         if ( !method_exists( $group, 'getInsertablesSuggester' ) ) {
00028             throw new TranslationHelperException( "Group does not have a suggester" );
00029         }
00030 
00031         $suggester = $group->getInsertablesSuggester();
00032 
00033         // It is okay to return null suggester
00034         if ( !$suggester ) {
00035             throw new TranslationHelperException( "Group does not have a suggester" );
00036         }
00037 
00038         $insertables = $suggester->getInsertables( $this->getDefinition() );
00039         $blob = array();
00040         foreach ( $insertables as $insertable ) {
00041             $displayText = $insertable->getDisplayText();
00042 
00043             // The keys are used for de-duplication
00044             $blob[$displayText] = array(
00045                 'display' => $displayText,
00046                 'pre' => $insertable->getPreText(),
00047                 'post' => $insertable->getPostText(),
00048             );
00049         }
00050 
00051         $blob = array_values( $blob );
00052         $blob['**'] = 'insertable';
00053 
00054         return $blob;
00055     }
00056 }
Generated on Tue Oct 29 00:00:25 2013 for MediaWiki Translate Extension by  doxygen 1.6.3