r67093 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r67092‎ | r67093 | r67094 >
Date:17:56, 30 May 2010
Author:siebrand
Status:deferred
Tags:
Comment:
Add pop-up editing functionality. Not yet complete, but working.
Modified paths:
  • /trunk/extensions/Translate/SpecialTranslations.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/SpecialTranslations.php
@@ -24,9 +24,13 @@
2525 function execute( $par ) {
2626 global $wgRequest, $wgOut;
2727
 28+ TranslateUtils::injectCSS();
 29+
2830 $this->setHeaders();
2931 $this->outputHeader();
3032
 33+ self::includeAssets();
 34+
3135 $title = null;
3236
3337 if ( $this->including() ) {
@@ -36,6 +40,7 @@
3741 } else {
3842 $this->showTranslations( $title );
3943 }
 44+
4045 return;
4146 }
4247
@@ -63,6 +68,7 @@
6469 */
6570 function namespaceMessageForm( Title $title = null ) {
6671 global $wgContLang, $wgScript, $wgTranslateMessageNamespaces;
 72+
6773 $t = $this->getTitle();
6874
6975 $namespaces = new XmlSelect( 'namespace', 'namespace' );
@@ -99,6 +105,7 @@
100106 $out .= Xml::closeElement( 'fieldset' );
101107 $out .= Xml::closeElement( 'form' );
102108 $out .= Xml::closeElement( 'div' );
 109+
103110 return $out;
104111 }
105112
@@ -114,6 +121,7 @@
115122
116123 if ( !$inMessageGroup ) {
117124 $wgOut->addWikiMsg( 'translate-translations-no-message', $title->getPrefixedText() );
 125+
118126 return;
119127 }
120128
@@ -134,12 +142,17 @@
135143
136144 if ( !$res->numRows() ) {
137145 $wgOut->addWikiMsg( 'translate-translations-no-message', $title->getPrefixedText() );
 146+
138147 return;
139148 }
140149
141150 // Normal output
142151 $titles = array();
143 - foreach ( $res as $s ) { $titles[] = $s->page_title; }
 152+
 153+ foreach ( $res as $s ) {
 154+ $titles[] = $s->page_title;
 155+ }
 156+
144157 $pageInfo = TranslateUtils::getContents( $titles, $namespace );
145158
146159 $tableheader = Xml::openElement( 'table', array(
@@ -158,43 +171,33 @@
159172
160173 foreach ( $res as $s ) {
161174 $key = $s->page_title;
162 - $t = Title::makeTitle( $s->page_namespace, $key );
 175+ $tTitle = Title::makeTitle( $s->page_namespace, $key );
163176
164 - $niceTitle = htmlspecialchars( $this->getTheCode( $s->page_title ) );
 177+ $text = htmlspecialchars( $this->getCode( $s->page_title ) );
165178
166179 if ( $canTranslate ) {
167 - $tools['edit'] = $sk->link(
168 - $t,
169 - $niceTitle,
170 - array( 'action' ),
171 - array(
172 - 'action' => 'edit',
173 - 'loadgroup' => $inMessageGroup
174 - )
 180+ $tools['edit'] = TranslationHelpers::ajaxEditLink(
 181+ $tTitle,
 182+ $text
175183 );
176184 } else {
177 - $tools['edit'] = $sk->link( $t, $niceTitle );
 185+ $tools['edit'] = $sk->link( $t, $text );
178186 }
179187
180188 $tools['history'] = $sk->link(
181 - $t,
 189+ $tTitle,
182190 "&#160;<sup>h</sup>&#160;",
183191 array( 'action' ),
184192 array( 'action' => 'history' )
185193 );
186194
187 - $anchor = 'msg_' . $key;
188 - $anchor = Xml::element( 'a', array( 'id' => $anchor, 'href' => "#$anchor" ), "↓" );
189 -
190 - $extra = '';
191 -
192 - if ( TranslateEditAddons::isFuzzy( $t ) ) {
 195+ if ( TranslateEditAddons::isFuzzy( $tTitle ) ) {
193196 $class = 'orig';
194197 } else {
195198 $class = 'def';
196199 }
197 -
198 - $leftColumn = $anchor . $tools['history'] . $tools['edit'] . $extra;
 200+
 201+ $leftColumn = $tools['history'] . $tools['edit'];
199202 $out .= Xml::tags( 'tr', array( 'class' => $class ),
200203 Xml::tags( 'td', null, $leftColumn ) .
201204 Xml::tags( 'td', null, TranslateUtils::convertWhiteSpaceToHTML( $pageInfo[$key][0] ) )
@@ -206,8 +209,23 @@
207210 $wgOut->addHTML( $out );
208211 }
209212
210 - public function getTheCode( $name ) {
 213+ private function getCode( $name ) {
211214 $from = strrpos( $name, '/' );
 215+
212216 return substr( $name, $from + 1 );
213217 }
 218+
 219+ private static function includeAssets() {
 220+ global $wgOut, $wgScript;
 221+
 222+ $wgOut->addScriptFile( TranslateUtils::assetPath( 'js/quickedit.js' ) );
 223+ $wgOut->includeJQuery();
 224+ $wgOut->addScriptFile( TranslateUtils::assetPath( 'js/jquery-ui-1.7.2.custom.min.js' ) );
 225+ $wgOut->addScriptFile( TranslateUtils::assetPath( 'js/jquery.form.js' ) );
 226+ $wgOut->addExtensionStyle( TranslateUtils::assetPath( 'js/base/custom-theme/jquery-ui-1.7.2.custom.css' ) );
 227+
 228+ // Might be needed, but ajax doesn't load it
 229+ $diff = new DifferenceEngine;
 230+ $diff->showDiffStyle();
 231+ }
214232 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r67173Follow-up r67093: update variable name.siebrand22:04, 31 May 2010

Status & tagging log