Index: trunk/extensions/TranslationNotifications/SpecialNotifyTranslators.php |
— | — | @@ -25,12 +25,19 @@ |
26 | 26 | |
27 | 27 | public function execute( $parameters ) { |
28 | 28 | global $wgUser, $wgOut; |
| 29 | + $this->setHeaders(); |
| 30 | + |
29 | 31 | if ( !$wgUser->isallowed( self::$right ) ) { |
30 | 32 | throw new PermissionsError( self::$right ); |
31 | 33 | } |
32 | 34 | |
33 | | - $wgOut->addModules( 'ext.translationnotifications.notifytranslators' ); |
| 35 | + $htmlFormDataModel = $this->getDataModel(); |
34 | 36 | |
| 37 | + if ( !is_array( $htmlFormDataModel ) ) { |
| 38 | + $wgOut->addWikiMsg( $htmlFormDataModel ); |
| 39 | + return; |
| 40 | + } |
| 41 | + |
35 | 42 | $context = $this->getContext(); |
36 | 43 | $htmlForm = new HtmlForm( $this->getDataModel(), $context, 'translationnotifications' ); |
37 | 44 | $htmlForm->setId( 'notifytranslators-form' ); |
— | — | @@ -39,10 +46,35 @@ |
40 | 47 | $htmlForm->setSubmitCallback( array( $this, 'formSubmit' ) ); |
41 | 48 | $htmlForm->show(); |
42 | 49 | |
43 | | - $this->setHeaders(); |
| 50 | + $wgOut->addModules( 'ext.translationnotifications.notifytranslators' ); |
44 | 51 | } |
45 | 52 | |
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 |
47 | 79 | $m['LanguagesToNotify'] = array( |
48 | 80 | 'type' => 'text', |
49 | 81 | 'rows' => 20, |
— | — | @@ -50,19 +82,37 @@ |
51 | 83 | 'label-message' => 'translationnotifications-languages-to-notify-label', |
52 | 84 | ); |
53 | 85 | |
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', |
59 | 100 | ); |
60 | 101 | |
| 102 | + // Deadline date input box with datepicker |
61 | 103 | $m['DeadlineDate'] = array( |
62 | 104 | 'type' => 'text', |
63 | 105 | 'size' => 20, |
64 | 106 | 'label-message' => 'translationnotifications-deadline-label', |
65 | 107 | ); |
66 | 108 | |
| 109 | + // Custom text |
| 110 | + $m['NotificationText'] = array( |
| 111 | + 'type' => 'textarea', |
| 112 | + 'rows' => 20, |
| 113 | + 'cols' => 80, |
| 114 | + 'label-message' => 'emailmessage', |
| 115 | + ); |
| 116 | + |
67 | 117 | return $m; |
68 | 118 | } |
69 | 119 | } |
Index: trunk/extensions/TranslationNotifications/TranslationNotifications.i18n.php |
— | — | @@ -42,7 +42,14 @@ |
43 | 43 | 'translationnotifications-notifytranslators' => 'Notify translators', |
44 | 44 | 'translationnotifications-send-notification-button' => 'Send a notification to translators', |
45 | 45 | '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.', |
47 | 54 | ); |
48 | 55 | |
49 | 56 | /** Message documentation (Message documentation) |
— | — | @@ -80,6 +87,13 @@ |
81 | 88 | 'translationnotifications-send-notification-button' => 'A title for the submit button of the translator notification form.', |
82 | 89 | 'translationnotifications-deadline-label' => 'A label for the deadline field, which will have a datepicker.', |
83 | 90 | '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.', |
84 | 98 | ); |
85 | 99 | |
86 | 100 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |