r90467 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90466‎ | r90467 | r90468 >
Date:16:00, 20 June 2011
Author:nikerabbit
Status:deferred
Tags:
Comment:
Move the handy button up one level
Modified paths:
  • /trunk/extensions/Translate/specials/SpecialManageGroups.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/specials/SpecialManageGroups.php
@@ -44,6 +44,7 @@
4545 }
4646
4747 if ( $group ) {
 48+
4849 if (
4950 $wgRequest->getBool( 'rebuildall', false ) &&
5051 $wgRequest->wasPosted() &&
@@ -64,70 +65,96 @@
6566 $code = 'en';
6667 }
6768
68 - $this->importForm( $group, $code );
69 - } else {
70 - global $wgLang, $wgOut;
 69+ if ( $wgRequest->getVal( 'from' ) !== 'main' ) {
 70+ $this->importForm( $group, $code );
 71+ return;
 72+ }
7173
72 - $groups = MessageGroups::singleton()->getGroups();
 74+ }
 75+ // Main list
 76+ global $wgLang, $wgOut;
7377
74 - $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups' );
75 - $separator = wfMsg( 'word-separator' );
 78+ $groups = MessageGroups::singleton()->getGroups();
7679
77 - $languages = array_keys( Language::getLanguageNames( false ) );
 80+ $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups' );
 81+ $separator = wfMsg( 'word-separator' );
7882
79 - foreach ( $groups as $group ) {
80 - if ( !$group instanceof FileBasedMessageGroup ) {
81 - continue;
82 - }
 83+ $languages = array_keys( Language::getLanguageNames( false ) );
8384
84 - wfDebug( __METHOD__ . ": {$group->getId()}\n" );
 85+ foreach ( $groups as $group ) {
 86+ if ( !$group instanceof FileBasedMessageGroup ) {
 87+ continue;
 88+ }
8589
86 - $link = $this->skin->link( $this->getTitle(), $group->getLabel(), array(), array( 'group' => $group->getId() ) );
87 - $out = $link . $separator;
 90+ wfDebug( __METHOD__ . ": {$group->getId()}\n" );
8891
89 - $cache = new MessageGroupCache( $group );
90 - if ( $cache->exists() ) {
91 - $timestamp = wfTimestamp( TS_MW, $cache->getTimestamp() );
92 - $out .= wfMsg( 'translate-manage-cacheat',
93 - $wgLang->date( $timestamp ),
94 - $wgLang->time( $timestamp )
95 - );
 92+ $link = $this->skin->link( $this->getTitle(), $group->getLabel(), array(), array( 'group' => $group->getId() ) );
 93+ $out = $link . $separator;
9694
97 - $modified = array();
 95+ $cache = new MessageGroupCache( $group );
 96+ if ( $cache->exists() ) {
 97+ $timestamp = wfTimestamp( TS_MW, $cache->getTimestamp() );
 98+ $out .= wfMsg( 'translate-manage-cacheat',
 99+ $wgLang->date( $timestamp ),
 100+ $wgLang->time( $timestamp )
 101+ );
98102
99 - foreach ( $languages as $code ) {
100 - $cache = new MessageGroupCache( $group, $code );
101 - if ( !$cache->isValid() ) $modified[] = $code;
102 - }
 103+ $modified = array();
103104
104 - if ( count( $modified ) ) {
105 - $out = '[' . implode( ",", $modified ) . '] ' . $out;
106 - } else {
107 - $out = Html::rawElement( 'span', array( 'style' => 'color:grey' ), $out );
 105+ foreach ( $languages as $code ) {
 106+ $cache = new MessageGroupCache( $group, $code );
 107+ if ( !$cache->isValid() ) $modified[] = $code;
 108+ }
 109+
 110+ if ( count( $modified ) ) {
 111+ $out = '[' . implode( ",", $modified ) . '] ' . $out;
 112+ if ( !in_array( 'en', $modified ) && $this->user->isAllowed( 'translate-manage' ) ) {
 113+ $out .= $this->rebuildButton( $group, $modified, 'main' );
108114 }
109115 } else {
110 - $out .= wfMsg( 'translate-manage-newgroup' );
 116+ $out = Html::rawElement( 'span', array( 'style' => 'color:grey' ), $out );
111117 }
112 -
113 - $wgOut->addHtml( $out );
114 - $wgOut->addHtml( '<hr>' );
 118+ } else {
 119+ $out .= wfMsg( 'translate-manage-newgroup' );
115120 }
116121
117 - $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups-old' );
118 - $wgOut->addHTML( '<ul>' );
 122+ $wgOut->addHtml( $out );
 123+ $wgOut->addHtml( '<hr>' );
 124+ }
119125
120 - foreach ( $groups as $group ) {
121 - if ( $group instanceof FileBasedMessageGroup ) {
122 - continue;
123 - }
 126+ $wgOut->wrapWikiMsg( '<h2>$1</h2>', 'translate-manage-listgroups-old' );
 127+ $wgOut->addHTML( '<ul>' );
124128
125 - $wgOut->addHtml( Xml::element( 'li', null, $group->getLabel() ) );
 129+ foreach ( $groups as $group ) {
 130+ if ( $group instanceof FileBasedMessageGroup ) {
 131+ continue;
126132 }
127133
128 - $wgOut->addHTML( '</ul>' );
 134+ $wgOut->addHtml( Xml::element( 'li', null, $group->getLabel() ) );
129135 }
 136+
 137+ $wgOut->addHTML( '</ul>' );
130138 }
131139
 140+ protected function rebuildButton( $group, $codes, $from ) {
 141+ $formParams = array(
 142+ 'method' => 'post',
 143+ 'action' => $this->getTitle()->getLocalURL(),
 144+ );
 145+
 146+ $html =
 147+ Xml::openElement( 'form', $formParams ) .
 148+ Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
 149+ Html::hidden( 'token', $this->user->editToken() ) .
 150+ Html::hidden( 'group', $group->getId() ) .
 151+ Html::hidden( 'codes', implode( ',', $codes ) ) .
 152+ Html::hidden( 'rebuildall', 1 ) .
 153+ Html::hidden( 'from', $from ) .
 154+ Xml::submitButton( wfMsg( 'translate-manage-import-rebuild-all' ) ) .
 155+ Xml::closeElement( 'form' );
 156+ return $html;
 157+ }
 158+
132159 /**
133160 * @todo Very long code block; split up.
134161 */
@@ -402,18 +429,7 @@
403430 );
404431
405432 if ( $this->user->isAllowed( 'translate-manage' ) ) {
406 -
407 - $this->out->addHTML(
408 - Xml::openElement( 'form', $formParams ) .
409 - Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) .
410 - Html::hidden( 'token', $this->user->editToken() ) .
411 - Html::hidden( 'group', $group->getId() ) .
412 - Html::hidden( 'codes', implode( ',', $codes ) ) .
413 - Html::hidden( 'rebuildall', 1 ) .
414 - Xml::submitButton( wfMsg( 'translate-manage-import-rebuild-all' ) ) .
415 - Xml::closeElement( 'form' )
416 - );
417 -
 433+ $this->out->addHTML( $this->rebuildButton( $group, $codes, 'import' ) );
418434 }
419435
420436 $this->out->addHTML(

Status & tagging log