RcFilter.php

Go to the documentation of this file.
00001 <?php
00016 class TranslateRcFilter {
00028     public static function translationFilter( &$conds, &$tables, &$join_conds, $opts ) {
00029         global $wgTranslateMessageNamespaces, $wgTranslateRcFilterDefault;
00030 
00031         $request = RequestContext::getMain()->getRequest();
00032         $translations = $request->getVal( 'translations', $wgTranslateRcFilterDefault );
00033         $opts->add( 'translations', $wgTranslateRcFilterDefault );
00034         $opts->setValue( 'translations', $translations );
00035 
00036         $dbr = wfGetDB( DB_SLAVE );
00037 
00038         $namespaces = array();
00039 
00040         foreach ( $wgTranslateMessageNamespaces as $index ) {
00041             $namespaces[] = $index;
00042             $namespaces[] = $index + 1; // Talk too
00043         }
00044 
00045         if ( $translations === 'only' ) {
00046             $conds[] = 'rc_namespace IN (' . $dbr->makeList( $namespaces ) . ')';
00047             $conds[] = 'rc_title like \'%%/%%\'';
00048         } elseif ( $translations === 'filter' ) {
00049             $conds[] = 'rc_namespace NOT IN (' . $dbr->makeList( $namespaces ) . ')';
00050         } elseif ( $translations === 'site' ) {
00051             $conds[] = 'rc_namespace IN (' . $dbr->makeList( $namespaces ) . ')';
00052             $conds[] = 'rc_title not like \'%%/%%\'';
00053         }
00054 
00055         return true;
00056     }
00057 
00067     public static function translationFilterForm( &$items, $opts ) {
00068         $opts->consumeValue( 'translations' );
00069         $default = $opts->getValue( 'translations' );
00070 
00071         $label = Xml::label(
00072             wfMessage( 'translate-rc-translation-filter' )->text(),
00073             'mw-translation-filter'
00074         );
00075         $select = new XmlSelect( 'translations', 'mw-translation-filter', $default );
00076         $select->addOption(
00077             wfMessage( 'translate-rc-translation-filter-no' )->text(),
00078             'noaction'
00079         );
00080         $select->addOption( wfMessage( 'translate-rc-translation-filter-only' )->text(), 'only' );
00081         $select->addOption(
00082             wfMessage( 'translate-rc-translation-filter-filter' )->text(),
00083             'filter'
00084         );
00085         $select->addOption( wfMessage( 'translate-rc-translation-filter-site' )->text(), 'site' );
00086 
00087         $items['translations'] = array( $label, $select->getHTML() );
00088 
00089         return true;
00090     }
00091 }
Generated on Tue Oct 29 00:00:26 2013 for MediaWiki Translate Extension by  doxygen 1.6.3