r95769 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95768‎ | r95769 | r95770 >
Date:12:41, 30 August 2011
Author:nikerabbit
Status:resolved
Tags:
Comment:
* Annotate hook functions
* Small cleanups to weird code
Modified paths:
  • /trunk/extensions/Translate/TranslateEditAddons.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Translate/TranslateEditAddons.php
@@ -19,6 +19,7 @@
2020
2121 /**
2222 * Add some tabs for navigation for users who do not use Ajax interface.
 23+ * Hooks: SkinTemplateNavigation, SkinTemplateTabs
2324 * @param $skin Skin
2425 * @param $tabs Array
2526 */
@@ -95,7 +96,7 @@
9697 );
9798 self::addTab( $skin, $tabs, 'list', $data, $tabindex );
9899
99 - if ( $next !== null && $next !== true ) {
 100+ if ( $next !== null ) {
100101 $linktitle = Title::makeTitleSafe( $ns, "$next/$code" );
101102 $data = array(
102103 'text' => wfMsg( 'translate-edit-tab-next' ),
@@ -119,12 +120,13 @@
120121
121122 /**
122123 * Keep the usual diiba daaba hidden from translators.
 124+ * Hook: AlternateEdit
123125 */
124 - static function intro( $object ) {
 126+ public static function intro( $editpage ) {
125127 $object->suppressIntro = true;
126128
127129 $msg = wfMsgForContent( 'translate-edit-tag-warning' );
128 - if ( $msg !== '' && $msg !== '-' && TranslatablePage::isSourcePage( $object->mTitle ) ) {
 130+ if ( $msg !== '' && $msg !== '-' && TranslatablePage::isSourcePage( $editpage->mTitle ) ) {
129131 global $wgOut;
130132 $object->editFormTextTop .= $wgOut->parse( $msg );
131133 }
@@ -133,6 +135,7 @@
134136
135137 /**
136138 * Adds the translation aids and navigation to the normal edit page.
 139+ * Hook: EditPage::showEditForm:initial
137140 */
138141 static function addTools( $object ) {
139142 if ( !self::isMessageNamespace( $object->mTitle ) ) {
@@ -147,6 +150,7 @@
148151 /**
149152 * Replace the normal save button with one that says if you are editing
150153 * message documentation to try to avoid accidents.
 154+ * Hook: EditPageBeforeEditButtons
151155 */
152156 static function buttonHack( $editpage, &$buttons, $tabindex ) {
153157 global $wgTranslateDocumentationLanguageCode, $wgLang;
@@ -199,8 +203,8 @@
200204 }
201205
202206 /**
203 - * @return Array of the message and the language
204 - */
 207+ * @return Array of the message and the language
 208+ */
205209 public static function figureMessage( Title $title ) {
206210 $text = $title->getDBkey();
207211 $pos = strrpos( $text, '/' );
@@ -273,8 +277,8 @@
274278 return strpos( $text, TRANSLATE_FUZZY ) !== false;
275279 }
276280
277 - /** Check if a title is marked as fuzzy.
278 - *
 281+ /**
 282+ * Check if a title is marked as fuzzy.
279283 * @param $title Title
280284 * @return \bool If title is marked fuzzy.
281285 */
@@ -282,7 +286,7 @@
283287 $dbr = wfGetDB( DB_SLAVE );
284288
285289 $tables = array( 'page', 'revtag' );
286 - $fields = array( 'rt_type' );
 290+ $fields = 'rt_type';
287291 $conds = array(
288292 'page_namespace' => $title->getNamespace(),
289293 'page_title' => $title->getDBkey(),
@@ -291,14 +295,14 @@
292296 'page_latest=rt_revision'
293297 );
294298
295 - $res = $dbr->selectField( $tables, $fields, $conds, __METHOD__ );
 299+ $res = $dbr->selectField( $tables, $field, $conds, __METHOD__ );
296300
297 - return $res === RevTag::getType( 'fuzzy' );
 301+ return $res !== false;
298302 }
299303
300304
301 - /** Check if a title is in a message namespace.
302 - *
 305+ /**
 306+ * Check if a title is in a message namespace.
303307 * @param $title Title
304308 * @return \bool If title is in a message namespace.
305309 */
@@ -311,10 +315,8 @@
312316 }
313317
314318 /**
315 - * @static
316 - * @param $skin Skin
317 - * @param $tabs
318 - * @return bool
 319+ * Removes protection tab for message namespaces - not useful.
 320+ * Hook: SkinTemplateTabs
319321 */
320322 public static function tabs( $skin, &$tabs ) {
321323 if ( !self::isMessageNamespace( $skin->getTitle() ) ) {
@@ -326,6 +328,7 @@
327329 return true;
328330 }
329331
 332+ /// Hook: EditPage::showEditForm:fields
330333 public static function keepFields( $edit, $out ) {
331334 global $wgRequest;
332335
@@ -338,6 +341,7 @@
339342 return true;
340343 }
341344
 345+ /// Hook: ArticleSaveComplete
342346 public static function onSave( $article, $user, $text, $summary,
343347 $minor, $_, $_, $flags, $revision
344348 ) {
@@ -444,6 +448,7 @@
445449 return $text;
446450 }
447451
 452+ /// Hook: LanguageGetTranslatedLanguageNames
448453 public static function translateMessageDocumentationLanguage( &$names, $code ) {
449454 global $wgTranslateDocumentationLanguageCode;
450455 if ( $wgTranslateDocumentationLanguageCode ) {
@@ -453,6 +458,7 @@
454459 return true;
455460 }
456461
 462+ /// Hook: ArticlePrepareTextForEdit
457463 public static function disablePreSaveTransform( $article, $popts ) {
458464 global $wgTranslateDocumentationLanguageCode;
459465 $keycodegroup = self::getKeyCodeGroup( $article->getTitle() );
@@ -463,6 +469,7 @@
464470 return true;
465471 }
466472
 473+ /// Hook: ArticleContentOnDiff
467474 public static function displayOnDiff( $de, $out ) {
468475 $title = $de->getTitle();
469476 $handle = new MessageHandle( $title );
@@ -488,6 +495,7 @@
489496 return false;
490497 }
491498
 499+ /// Hook: SpecialSearchProfiles
492500 public static function searchProfile( &$profiles ) {
493501 global $wgTranslateMessageNamespaces;
494502 $insert = array();
@@ -501,6 +509,7 @@
502510 return true;
503511 }
504512
 513+ /// Hook: SpecialSearchProfileForm
505514 public static function searchProfileForm( $search, &$form, $profile, $term, $opts ) {
506515 if ( $profile !== 'translation' ) {
507516 return true;
@@ -547,6 +556,7 @@
548557 return false;
549558 }
550559
 560+ /// Hook: SpecialSearchSetupEngine
551561 public static function searchProfileSetupEngine( $search, $profile, $engine ) {
552562 if ( $profile !== 'translation' ) {
553563 return true;

Follow-up revisions

RevisionCommit summaryAuthorDate
r95774Follow-up r95769: change more $object to $editpage.siebrand13:21, 30 August 2011
r95779This is better to be the last typofix for me todaynikerabbit13:45, 30 August 2011

Status & tagging log