r113669 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r113668‎ | r113669 | r113670 >
Date:21:19, 12 March 2012
Author:amire80
Status:ok (Comments)
Tags:i18nreview 
Comment:
Completing the form fields.
Modified paths:
  • /trunk/extensions/TranslationNotifications/SpecialNotifyTranslators.php (modified) (history)
  • /trunk/extensions/TranslationNotifications/TranslationNotifications.i18n.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TranslationNotifications/SpecialNotifyTranslators.php
@@ -25,12 +25,19 @@
2626
2727 public function execute( $parameters ) {
2828 global $wgUser, $wgOut;
 29+ $this->setHeaders();
 30+
2931 if ( !$wgUser->isallowed( self::$right ) ) {
3032 throw new PermissionsError( self::$right );
3133 }
3234
33 - $wgOut->addModules( 'ext.translationnotifications.notifytranslators' );
 35+ $htmlFormDataModel = $this->getDataModel();
3436
 37+ if ( !is_array( $htmlFormDataModel ) ) {
 38+ $wgOut->addWikiMsg( $htmlFormDataModel );
 39+ return;
 40+ }
 41+
3542 $context = $this->getContext();
3643 $htmlForm = new HtmlForm( $this->getDataModel(), $context, 'translationnotifications' );
3744 $htmlForm->setId( 'notifytranslators-form' );
@@ -39,10 +46,35 @@
4047 $htmlForm->setSubmitCallback( array( $this, 'formSubmit' ) );
4148 $htmlForm->show();
4249
43 - $this->setHeaders();
 50+ $wgOut->addModules( 'ext.translationnotifications.notifytranslators' );
4451 }
4552
46 - public function getDataModel() {
 53+ /**
 54+ * Builds the form fields
 55+ *
 56+ * @return array or string with an error message key in case of error
 57+ */
 58+ private function getDataModel() {
 59+
 60+ // Translatable pages dropdown
 61+ $translatablePagesIDs = TranslatablePage::getTranslatablePages();
 62+ if ( count ( $translatablePagesIDs ) ) {
 63+ return 'translationnotifications-error-no-translatable-pages';
 64+ }
 65+
 66+ $translatablePagesOptions = array();
 67+ foreach ( $translatablePagesIDs as $translatablePagesID ) {
 68+ $translatablePagesOptions[Title::newFromID( $translatablePagesID )->getText()] = $translatablePagesID;
 69+ }
 70+
 71+ $m['TranslatablePage'] = array(
 72+ 'type' => 'select',
 73+ 'label-message' => array( 'translationnotifications-translatablepage-title' ),
 74+ 'options' => $translatablePagesOptions,
 75+ 'default' => 'unset',
 76+ );
 77+
 78+ // Languages to notify input box
4779 $m['LanguagesToNotify'] = array(
4880 'type' => 'text',
4981 'rows' => 20,
@@ -50,19 +82,37 @@
5183 'label-message' => 'translationnotifications-languages-to-notify-label',
5284 );
5385
54 - $m['NotificationText'] = array(
55 - 'type' => 'textarea',
56 - 'rows' => 20,
57 - 'cols' => 80,
58 - 'label-message' => 'emailmessage',
 86+ // Priotity dropdown
 87+ $priorityOptions = array();
 88+ $priorities = array( 'unset', 'high', 'medium', 'low' );
 89+
 90+ foreach ( $priorities as $priority ) {
 91+ $priorityMessage = wfMessage( "translationnotifications-priority-$priority" )->plain();
 92+ $priorityOptions[$priorityMessage] = $priority;
 93+ }
 94+
 95+ $m['Priority'] = array(
 96+ 'type' => 'select',
 97+ 'label-message' => array( 'translationnotifications-priority' ),
 98+ 'options' => $priorityOptions,
 99+ 'default' => 'unset',
59100 );
60101
 102+ // Deadline date input box with datepicker
61103 $m['DeadlineDate'] = array(
62104 'type' => 'text',
63105 'size' => 20,
64106 'label-message' => 'translationnotifications-deadline-label',
65107 );
66108
 109+ // Custom text
 110+ $m['NotificationText'] = array(
 111+ 'type' => 'textarea',
 112+ 'rows' => 20,
 113+ 'cols' => 80,
 114+ 'label-message' => 'emailmessage',
 115+ );
 116+
67117 return $m;
68118 }
69119 }
Index: trunk/extensions/TranslationNotifications/TranslationNotifications.i18n.php
@@ -42,7 +42,14 @@
4343 'translationnotifications-notifytranslators' => 'Notify translators',
4444 'translationnotifications-send-notification-button' => 'Send a notification to translators',
4545 'translationnotifications-deadline-label' => 'Deadline to indicate in this notification:',
46 - 'translationnotifications-languages-to-notify-label' => 'Which languages to notify (code):',
 46+ 'translationnotifications-languages-to-notify-label' => 'Which languages to notify (comma-separated codes):',
 47+ 'translationnotifications-priority' => 'Priority:',
 48+ 'translationnotifications-priority-high' => 'high',
 49+ 'translationnotifications-priority-medium' => 'medium',
 50+ 'translationnotifications-priority-low' => 'low',
 51+ 'translationnotifications-priority-unset' => '(unset)',
 52+ 'translationnotifications-translatablepage-title' => 'Translatable page name:',
 53+ 'translationnotifications-error-no-translatable-pages' => 'There are no translatable pages in this wiki.',
4754 );
4855
4956 /** Message documentation (Message documentation)
@@ -80,6 +87,13 @@
8188 'translationnotifications-send-notification-button' => 'A title for the submit button of the translator notification form.',
8289 'translationnotifications-deadline-label' => 'A label for the deadline field, which will have a datepicker.',
8390 'translationnotifications-languages-to-notify-label' => 'A label for language codes field.',
 91+ 'translationnotifications-priority' => 'A label for translation priority field.',
 92+ 'translationnotifications-priority-high' => 'high (priority), an item in a dropdown box.',
 93+ 'translationnotifications-priority-medium' => 'medium (priority), an item in a dropdown box.',
 94+ 'translationnotifications-priority-low' => 'low (priority), an item in a dropdown box.',
 95+ 'translationnotifications-priority-unset' => 'unset (priority), an item in a dropdown box.',
 96+ 'translationnotifications-translatablepage-title' => 'A label for language codes field. Can be translated as "A page designated for translation, intended for translation", etc.',
 97+ 'translationnotifications-error-no-translatable-pages' => 'An error message.',
8498 );
8599
86100 /** Belarusian (Taraškievica orthography) (‪Беларуская (тарашкевіца)‬)

Follow-up revisions

RevisionCommit summaryAuthorDate
r113711Follow up, r113669, corrected the condition for checking whether translatable...amire8008:42, 13 March 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r113462Follow up to r113459. Adding SpecialNotifyTranslators.php, only the parts tha...amire8010:04, 9 March 2012

Comments

#Comment by Santhosh.thottingal (talk | contribs)   05:10, 19 March 2012

Please define the variable $m as array() somewhere in the beginning. And it would be better if the variable is renamed to a more descriptive name.

#Comment by Amire80 (talk | contribs)   11:07, 20 March 2012

Addressed in r114128.

#Comment by Santhosh.thottingal (talk | contribs)   11:35, 20 March 2012

The comment for getDataModel is wrong. It always returns an array.

#Comment by 😂 (talk | contribs)   03:06, 21 March 2012

Not true, see line 62.

Status & tagging log