r112883 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r112882‎ | r112883 | r112884 >
Date:12:57, 2 March 2012
Author:siebrand
Status:ok
Tags:
Comment:
Looks like we finally came up with a name. We're calling her TranslationNotifications.
Modified paths:
  • /trunk/extensions/Translate/lcadft (deleted) (history)
  • /trunk/extensions/TranslationNotifications (added) (history)

Diff [purge]

Index: trunk/extensions/TranslationNotifications/LCADFT.i18n.php
@@ -0,0 +1,95 @@
 2+<?php
 3+/**
 4+ * Translations for the translator outreach features.
 5+ *
 6+ * @file
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ */
 9+
 10+$messages = array();
 11+
 12+/** English
 13+ * @author Niklas Laxström
 14+ */
 15+$messages['en'] = array(
 16+ 'translatorsignup' => 'Translator signup',
 17+ 'lcadft-desc' => 'Allows translators sign up for translation notifications',
 18+ 'lcadft-info' => 'User information',
 19+ 'lcadft-username' => 'Username:',
 20+ 'lcadft-emailstatus' => 'E-mail status:',
 21+ 'lcadft-email-confirmed' => 'Your e-mail address is confirmed',
 22+ 'lcadft-email-unconfirmed' => 'Your e-mail address is not confirmed. $1',
 23+ 'lcadft-email-notset' => 'You have not provided an e-mail address. You can do that in your [[Special:Preferences|preferences]].',
 24+ 'lcadft-languages' => 'Languages',
 25+ 'lcadft-lang' => 'Language #$1',
 26+ 'lcadft-nolang' => 'Choose a language',
 27+ 'lcadft-contact' => 'Preferred contact methods',
 28+ 'lcadft-cmethod-email' => 'E-mail',
 29+ 'lcadft-cmethod-talkpage' => 'Talk page',
 30+ 'lcadft-cmethod-talkpage-elsewhere' => 'Talk page on other wiki',
 31+ 'lcadft-cmethod-feed' => 'Feed',
 32+ 'lcadft-cmethod-no' => 'Do not contact me',
 33+ 'lcadft-frequency' => 'Contact frequency',
 34+ 'lcadft-freq-always' => 'When there is something new to translate',
 35+ 'lcadft-freq-week' => 'At most once a week',
 36+ 'lcadft-freq-month' => 'At most once a month',
 37+ 'lcadft-freq-weekly' => 'Weekly digest',
 38+ 'lcadft-freq-monthly' => 'Monthly digest',
 39+ 'lcadft-submit' => 'Sign up',
 40+);
 41+
 42+$messages['qqq'] = array(
 43+ 'lcadft' => 'Special page header',
 44+ 'lcadft-desc' => '{{desc}}',
 45+ 'lcadft-info' => 'Fieldset header',
 46+ 'lcadft-username' => 'Label followed by username',
 47+ 'lcadft-emailstatus' => 'Label',
 48+ 'lcadft-email-unconfirmed' => 'Parameters:
 49+* $1 is a button which can be used to send confirmation email. Button text is {{msg-mw|mediawiki:confirmemail_send}}.',
 50+ 'lcadft-languages' => 'Fieldset header',
 51+ 'lcadft-lang' => 'Label for select, $1 is a numbeer',
 52+ 'lcadft-nolang' => 'First option in a language select',
 53+ 'lcadft-contact' => 'Fieldset header',
 54+ 'lcadft-cmethod-email' => 'Check option label',
 55+ 'lcadft-cmethod-talkpage' => 'Check option label',
 56+ 'lcadft-cmethod-talkpage-elsewhere' => 'Check option label',
 57+ 'lcadft-cmethod-feed' => 'Check option label',
 58+ 'lcadft-cmethod-no' => 'Check option label',
 59+ 'lcadft-frequency' => 'Fieldset header',
 60+ 'lcadft-freq-always' => 'Radio option label',
 61+ 'lcadft-freq-week' => 'Radio option label',
 62+ 'lcadft-freq-month' => 'Radio option label',
 63+ 'lcadft-freq-weekly' => 'Radio option label',
 64+ 'lcadft-freq-monthly' => 'Radio option label',
 65+ 'lcadft-submit' => 'Submit button text',
 66+);
 67+
 68+/** Hebrew
 69+ * @author amire80
 70+ */
 71+$messages['he'] = array(
 72+ 'translatorsignup' => 'רישום מתרגמים',
 73+ 'lcadft-desc' => 'רישום מתרגמים לעדכונים על מיזמי תרגום',
 74+ 'lcadft-info' => 'מידע על המשתמש',
 75+ 'lcadft-username' => 'שם משתמש:',
 76+ 'lcadft-emailstatus' => 'מצב דוא"ל:',
 77+ 'lcadft-email-confirmed' => 'הדוא"ל שלך מאומת',
 78+ 'lcadft-email-unconfirmed' => 'הדוא"ל שלך אינו מאומת. $1',
 79+ 'lcadft-email-notset' => 'לא נתת כתובת דוא"ל. אפשר לעשות את זה ב[[Special:Preferences|העדפות]] שלך.',
 80+ 'lcadft-languages' => 'שפות',
 81+ 'lcadft-lang' => 'שפה מס\' $1',
 82+ 'lcadft-nolang' => 'בחירת שפה',
 83+ 'lcadft-contact' => 'דרכי התקשרות מועדפות',
 84+ 'lcadft-cmethod-email' => 'דוא"ל',
 85+ 'lcadft-cmethod-talkpage' => 'דף שיחה',
 86+ 'lcadft-cmethod-talkpage-elsewhere' => 'דף שיחה בוויקי אחר',
 87+ 'lcadft-cmethod-feed' => 'הזנה',
 88+ 'lcadft-cmethod-no' => 'לא ליצור אתי קשר',
 89+ 'lcadft-frequency' => 'תדירות ההתקשרות',
 90+ 'lcadft-freq-always' => 'כשיש מה לתרגם',
 91+ 'lcadft-freq-week' => 'לכל היותר פעם בשבוע',
 92+ 'lcadft-freq-month' => 'לכל היותר פעם בחודש',
 93+ 'lcadft-freq-weekly' => 'סיכום שבועי',
 94+ 'lcadft-freq-monthly' => 'סיכום חודשי',
 95+ 'lcadft-submit' => 'רישום',
 96+);
Property changes on: trunk/extensions/TranslationNotifications/LCADFT.i18n.php
___________________________________________________________________
Added: svn:eol-style
197 + native
Index: trunk/extensions/TranslationNotifications/LCADFT.php
@@ -0,0 +1,39 @@
 2+<?php
 3+if ( !defined( 'MEDIAWIKI' ) ) die();
 4+/**
 5+ * An extension to keep in touch with translators
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ *
 10+ * @author Niklas Laxström
 11+ * @copyright Copyright © 2012, Niklas Laxström
 12+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 13+ */
 14+
 15+/**
 16+ * Extension credits properties.
 17+ */
 18+$wgExtensionCredits['specialpage'][] = array(
 19+ 'path' => __FILE__,
 20+ 'name' => 'LCADFT',
 21+ 'version' => '2012-02-20',
 22+ 'author' => array( 'Niklas Laxström' ),
 23+ 'descriptionmsg' => 'lcadft-desc',
 24+ #'url' => 'https://www.mediawiki.org/wiki/Extension:',
 25+);
 26+
 27+$dir = dirname( __FILE__ );
 28+$wgSpecialPages['TranslatorSignup'] = 'SpecialTranslatorSignup';
 29+$wgSpecialPageGroups['TranslatorSignup'] = 'login';
 30+$wgExtensionMessagesFiles['LCADFT'] = "$dir/LCADFT.i18n.php";
 31+$wgExtensionMessagesFiles['LCADFT-alias'] = "$dir/LCADFT.alias.php";
 32+$wgAutoloadClasses['SpecialTranslatorSignup'] = "$dir/SpecialTranslatorSignup.php";
 33+
 34+$wgLCADFTContactMethods = array(
 35+ 'email' => true,
 36+ 'talkpage' => true,
 37+ 'talkpage-elsewhere' => false,
 38+ 'feed' => false,
 39+ 'no' => true,
 40+);
Property changes on: trunk/extensions/TranslationNotifications/LCADFT.php
___________________________________________________________________
Added: svn:eol-style
141 + native
Index: trunk/extensions/TranslationNotifications/SpecialTranslatorSignup.php
@@ -0,0 +1,175 @@
 2+<?php
 3+/**
 4+ * Form for translators to register contact methods
 5+ *
 6+ * @file
 7+ * @author Niklas Laxström
 8+ * @copyright Copyright © 2012, Niklas Laxström
 9+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 10+ */
 11+
 12+/**
 13+ * Form for translators to register contact methods
 14+ *
 15+ * @ingroup SpecialPage TranslateSpecialPage
 16+ */
 17+
 18+class SpecialTranslatorSignup extends SpecialPage {
 19+ public function __construct() {
 20+ parent::__construct( 'TranslatorSignup' );
 21+ }
 22+
 23+ public function execute( $parameters ) {
 24+ if ( !$this->getUser()->isLoggedIn() ) {
 25+ throw new PermissionsError( 'read' );
 26+ }
 27+
 28+ $context = $this->getContext();
 29+ $htmlForm = new HtmlForm( $this->getDataModel(), $context, 'lcadft' );
 30+ $htmlForm->setId( 'lcadft-form' );
 31+ $htmlForm->setSubmitText( $context->msg( 'lcadft-submit' )->text() );
 32+ $htmlForm->setSubmitID( 'lcadft-submit' );
 33+ $htmlForm->setSubmitCallback( array( $this, 'formSubmit' ) );
 34+ $htmlForm->show();
 35+
 36+ $this->setHeaders();
 37+ $this->getOutput()->addInlineScript(
 38+<<<JAVASCRIPT
 39+jQuery( function ( $ ) {
 40+ var toggle = function () {
 41+ $( '#mw-input-wpcmethod-talkpage-elsewhere-loc' ).toggle( $( '#mw-input-wpcmethod-talkpage-elsewhere' ).prop( 'checked' ) );
 42+ };
 43+ toggle();
 44+ $( '#mw-input-wpcmethod-talkpage-elsewhere' ).change( toggle );
 45+} );
 46+JAVASCRIPT
 47+ );
 48+ }
 49+ public function getDataModel() {
 50+ global $wgLCADFTContactMethods, $wgLang;
 51+
 52+ $m['username'] = array(
 53+ 'type' => 'info',
 54+ 'label-message' => 'lcadft-username',
 55+ 'default' => $this->getUser()->getName(),
 56+ 'section' => 'info',
 57+ );
 58+
 59+ $user = $this->getUser();
 60+ if ( $user->isEmailConfirmed() ) {
 61+ $status = $this->msg( 'lcadft-email-confirmed' )->parse();
 62+ } elseif ( trim( $user->getEmail() ) !== '' ) {
 63+ $submit = Xml::submitButton( $this->msg( 'confirmemail_send' )->text(), array( 'name' => 'x' ) );
 64+ $status = $this->msg( 'lcadft-email-unconfirmed' )->rawParams( $submit )->parse();
 65+ } else {
 66+ $status = $this->msg( 'lcadft-email-notset' )->parse();
 67+ }
 68+
 69+ $m['emailstatus'] = array(
 70+ 'type' => 'info',
 71+ 'label-message' => 'lcadft-emailstatus',
 72+ 'default' => $status,
 73+ 'section' => 'info',
 74+ 'raw' => true,
 75+ );
 76+
 77+
 78+ $languages = Language::getLanguageNames();
 79+ ksort( $languages );
 80+
 81+ $options = array();
 82+ foreach ( $languages as $code => $name ) {
 83+ $display = wfBCP47( $code ) . ' - ' . $name;
 84+ $options[$display] = $code;
 85+ }
 86+
 87+ $options = array( wfMessage( 'lcadft-nolang' )->plain() => '' ) + $options;
 88+
 89+ for ( $i = 1; $i < 4; $i++ ) {
 90+ $m["lang-$i"] = array(
 91+ 'type' => 'select',
 92+ 'label-message' => array( "lcadft-lang", $wgLang->formatNum( $i ) ),
 93+ 'section' => 'languages',
 94+ 'options' => $options,
 95+ 'default' => $user->getOption( "lcadft-lang-$i" ),
 96+ );
 97+
 98+ if ( $i === 1 ) {
 99+ $m["lang-$i"]['default'] = $user->getOption( "lcadft-lang-$i", $wgLang->getCode() );
 100+ $m["lang-$i"]['required'] = true;
 101+ }
 102+ }
 103+
 104+ foreach ( $wgLCADFTContactMethods as $method => $value ) {
 105+ if ( $value === false ) {
 106+ continue;
 107+ }
 108+
 109+ $m["cmethod-$method"] = array(
 110+ 'type' => 'check',
 111+ 'label-message' => "lcadft-cmethod-$method",
 112+ 'default' => $user->getOption( "lcadft-cmethod-$method" ),
 113+ 'section' => 'contact',
 114+ );
 115+ if ( $method === 'email' ) {
 116+ $m["cmethod-$method"]['disabled'] = !$user-> isEmailConfirmed();
 117+ }
 118+
 119+ if ( $method === 'talkpage-elsewhere' ) {
 120+ $m['cmethod-talkpage-elsewhere-loc'] = array(
 121+ 'type' => 'select',
 122+ 'default' => $user->getOption( 'lcadft-cmethod-talkpage-elsewhere-loc' ),
 123+ 'section' => 'contact',
 124+ 'options' => $this->getOtherWikis(),
 125+ );
 126+ }
 127+ }
 128+
 129+ $m['freq'] = array(
 130+ 'type' => 'radio',
 131+ 'default' => $user->getOption( 'lcadft-freq', 'always' ),
 132+ 'section' => 'frequency',
 133+ 'options' => array(
 134+ $this->msg( 'lcadft-freq-always' )->text() => 'always',
 135+ $this->msg( 'lcadft-freq-week' )->text() => 'week',
 136+ $this->msg( 'lcadft-freq-month' )->text() => 'month',
 137+ $this->msg( 'lcadft-freq-weekly' )->text() => 'weekly',
 138+ $this->msg( 'lcadft-freq-monthly' )->text() => 'monthly',
 139+ ),
 140+ );
 141+ return $m;
 142+ }
 143+
 144+ public function formSubmit( $formData, $form ) {
 145+ global $wgRequest;
 146+ $user = $this->getUser();
 147+
 148+ if ( $wgRequest->getVal( 'x' ) === $this->msg( 'confirmemail_send' )->text() ) {
 149+ $user->sendConfirmationMail( 'set' );
 150+ return;
 151+ }
 152+
 153+ foreach ( $formData as $key => $value ) {
 154+ $user->setOption( "lcadft-$key", $value );
 155+ }
 156+ $user->saveSettings();
 157+ }
 158+
 159+ protected function getOtherWikis() {
 160+ if ( !class_exists( 'CentralAuthUser' ) ) {
 161+ return array();
 162+ }
 163+ $globalUser = new CentralAuthUser( $this->getUser()->getName() );
 164+ if ( !$globalUser->exists() ) {
 165+ return array();
 166+ }
 167+
 168+ $wikis = array();
 169+ $stuff = $globalUser->queryAttached();
 170+ foreach ( $stuff as $dbname => $value ) {
 171+ $wikis[] = $dbname;
 172+ }
 173+
 174+ return array_combine( $wikis, $wikis );
 175+ }
 176+}
Property changes on: trunk/extensions/TranslationNotifications/SpecialTranslatorSignup.php
___________________________________________________________________
Added: svn:eol-style
1177 + native
Index: trunk/extensions/TranslationNotifications/LCADFT.alias.php
@@ -0,0 +1,14 @@
 2+<?php
 3+/**
 4+ * Aliases for special pages of LCADFT extension.
 5+ *
 6+ * @file
 7+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
 8+ */
 9+
 10+$specialPageAliases = array();
 11+
 12+/** English (English) */
 13+$specialPageAliases['en'] = array(
 14+ 'TranslatorSignup' => array( 'TranslatorSignup' ),
 15+);
Property changes on: trunk/extensions/TranslationNotifications/LCADFT.alias.php
___________________________________________________________________
Added: svn:eol-style
116 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r112884Follow-up r112883: Rename files and update what needs updating.siebrand13:06, 2 March 2012

Status & tagging log