https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111997
Revision: 111997
Author: nikerabbit
Date: 2012-02-21 09:59:39 +0000 (Tue, 21 Feb 2012)
Log Message:
-----------
Committing this from git so that Siebrand can review it using CR tool.
Added Paths:
-----------
trunk/extensions/Translate/lcadft/
trunk/extensions/Translate/lcadft/LCADFT.alias.php
trunk/extensions/Translate/lcadft/LCADFT.i18n.php
trunk/extensions/Translate/lcadft/LCADFT.php
trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
Added: trunk/extensions/Translate/lcadft/LCADFT.alias.php
===================================================================
--- trunk/extensions/Translate/lcadft/LCADFT.alias.php
(rev 0)
+++ trunk/extensions/Translate/lcadft/LCADFT.alias.php 2012-02-21 09:59:39 UTC
(rev 111997)
@@ -0,0 +1,14 @@
+<?php
+/**
+ * Aliases for special pages of LCADFT extension.
+ *
+ * @file
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
2.0 or later
+ */
+
+$specialPageAliases = array();
+
+/** English (English) */
+$specialPageAliases['en'] = array(
+ 'TranslatorSignup' => array( 'Translator Signup' ),
+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.alias.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Translate/lcadft/LCADFT.i18n.php
===================================================================
--- trunk/extensions/Translate/lcadft/LCADFT.i18n.php
(rev 0)
+++ trunk/extensions/Translate/lcadft/LCADFT.i18n.php 2012-02-21 09:59:39 UTC
(rev 111997)
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Translations for the translator outreach features.
+ *
+ * @file
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
2.0 or later
+ */
+
+$messages = array();
+
+/** English
+ * @author Niklas Laxström
+ */
+$messages['en'] = array(
+ 'translatorsignup' => 'Translator signup',
+ 'lcadft-desc' => 'Allows translators sign up for translation
notifications',
+ 'lcadft-info' => 'Info',
+ 'lcadft-username' => 'Username',
+ 'lcadft-emailstatus' => 'E-mail status',
+ 'lcadft-email-confirmed' => 'Your e-mail address is confirmed',
+ 'lcadft-email-unconfirmed' => 'Your e-mail address is not confirmed.
$1',
+ 'lcadft-email-notset' => 'You have not provided an e-mail address. You
can do that in your [[Special:Preferences|preferences]].',
+ 'lcadft-contact' => 'Preferred contact methods',
+ 'lcadft-cmethod-email' => 'E-mail',
+ 'lcadft-cmethod-talkpage' => 'Talk page',
+ 'lcadft-cmethod-talkpage-elsewhere' => 'Talk page on other wiki',
+ 'lcadft-cmethod-feed' => 'Feed',
+ 'lcadft-frequency' => 'Contact frequency',
+ 'lcadft-freq-always' => 'When there is something new to translate',
+ 'lcadft-freq-week' => 'At most once a week',
+ 'lcadft-freq-month' => 'At most once a month',
+ 'lcadft-freq-weekly' => 'Weekly digest',
+ 'lcadft-freq-monthly' => 'Monthly digest',
+ 'lcadft-submit' => 'Sign up',
+);
+
+$messages['qqq'] = array(
+ 'lcadft' => 'Special page header',
+ 'lcadft-desc' => '{{desct}}',
+ 'lcadft-info' => 'Fieldset header',
+ 'lcadft-username' => 'Label followed by username',
+ 'lcadft-emailstatus' => 'Label',
+ 'lcadft-email-unconfirmed' => '$1 is a button which can be used to send
confirmation email. Button text is in Mediawiki:confirmemail_send message.',
+ 'lcadft-contact' => 'Fieldset header',
+ 'lcadft-cmethod-email' => 'Check option label',
+ 'lcadft-cmethod-talkpage' => 'Check option label',
+ 'lcadft-cmethod-talkpage-elsewhere' => 'Check option label',
+ 'lcadft-cmethod-feed' => 'Check option label',
+ 'lcadft-frequency' => 'Fieldset header',
+ 'lcadft-freq-always' => 'Radio option label',
+ 'lcadft-freq-week' => 'Radio option label',
+ 'lcadft-freq-month' => 'Radio option label',
+ 'lcadft-freq-weekly' => 'Radio option label',
+ 'lcadft-freq-monthly' => 'Radio option label',
+ 'lcadft-submit' => 'Submit button text',
+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.i18n.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Translate/lcadft/LCADFT.php
===================================================================
--- trunk/extensions/Translate/lcadft/LCADFT.php
(rev 0)
+++ trunk/extensions/Translate/lcadft/LCADFT.php 2012-02-21 09:59:39 UTC
(rev 111997)
@@ -0,0 +1,37 @@
+<?php
+if ( !defined( 'MEDIAWIKI' ) ) die();
+/**
+ * An extension to keep in touch with translators
+ *
+ * @file
+ * @ingroup Extensions
+ *
+ * @author Niklas Laxström
+ * @copyright Copyright © 2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
2.0 or later
+ */
+
+/**
+ * Extension credits properties.
+ */
+$wgExtensionCredits['specialpage'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'LCADFT',
+ 'version' => '2012-02-20',
+ 'author' => array( 'Niklas Laxström' ),
+ 'descriptionmsg' => 'lcadft-desc',
+ #'url' => 'https://www.mediawiki.org/wiki/Extension:',
+);
+
+$dir = dirname( __FILE__ );
+$wgSpecialPages['TranslatorSignup'] = 'SpecialTranslatorSignup';
+$wgExtensionMessagesFiles['LCADFT'] = "$dir/LCADFT.i18n.php";
+$wgExtensionMessagesFiles['LCADFT-alias'] = "$dir/LCADFT.alias.php";
+$wgAutoloadClasses['SpecialTranslatorSignup'] =
"$dir/SpecialTranslatorSignup.php";
+
+$wgLCADFTContactMethods = array(
+ 'email' => true,
+ 'talkpage' => true,
+ 'talkpage-elsewhere' => false,
+ 'feed' => false,
+);
Property changes on: trunk/extensions/Translate/lcadft/LCADFT.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
===================================================================
--- trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
(rev 0)
+++ trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
2012-02-21 09:59:39 UTC (rev 111997)
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Form for translators to register contact methods
+ *
+ * @file
+ * @author Niklas Laxström
+ * @copyright Copyright © 2012, Niklas Laxström
+ * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License
2.0 or later
+ */
+
+/**
+ * Form for translators to register contact methods
+ *
+ * @ingroup SpecialPage TranslateSpecialPage
+ */
+
+class SpecialTranslatorSignup extends SpecialPage {
+ public function __construct() {
+ parent::__construct( 'TranslatorSignup' );
+ }
+
+ public function execute( $parameters ) {
+ if ( !$this->getUser()->isLoggedIn() ) {
+ throw new PermissionsError( 'read' );
+ }
+
+ $context = $this->getContext();
+ $htmlForm = new HtmlForm( $this->getDataModel(), $context,
'lcadft' );
+ $htmlForm->setId( 'lcadft-form' );
+ $htmlForm->setSubmitText( $context->msg( 'lcadft-submit'
)->text() );
+ $htmlForm->setSubmitID( 'lcadft-submit' );
+ $htmlForm->setSubmitCallback( array( $this, 'formSubmit' ) );
+ $htmlForm->show();
+
+ $this->setHeaders();
+ $this->getOutput()->addInlineScript(
+<<<JAVASCRIPT
+jQuery( function ( $ ) {
+ var toggle = function () {
+ $( '#mw-input-wpcmethod-talkpage-elsewhere-loc' ).toggle( $(
'#mw-input-wpcmethod-talkpage-elsewhere' ).prop( 'checked' ) );
+ };
+ toggle();
+ $( '#mw-input-wpcmethod-talkpage-elsewhere' ).change( toggle );
+} );
+JAVASCRIPT
+ );
+ }
+ public function getDataModel() {
+ global $wgLCADFTContactMethods, $wgScript;
+
+ $m['username'] = array(
+ 'type' => 'info',
+ 'label-message' => 'lcadft-username',
+ 'default' => $this->getUser()->getName(),
+ 'section' => 'info',
+ );
+
+ $user = $this->getUser();
+ if ( $user->isEmailConfirmed() ) {
+ $status = $this->msg( 'lcadft-email-confirmed'
)->parse();
+ } elseif ( trim( $user->getEmail() ) !== '' ) {
+ $submit = Xml::submitButton( $this->msg(
'confirmemail_send' )->text(), array( 'name' => 'x' ) );
+ $status = $this->msg( 'lcadft-email-unconfirmed'
)->rawParams( $submit )->parse();
+ } else {
+ $status = $this->msg( 'lcadft-email-notset' )->parse();
+ }
+
+
+ $m['emailstatus'] = array(
+ 'type' => 'info',
+ 'label-message' => 'lcadft-emailstatus',
+ 'default' => $status,
+ 'section' => 'info',
+ 'raw' => true,
+ );
+
+ foreach ( $wgLCADFTContactMethods as $method => $value ) {
+ if ( $value === false ) {
+ continue;
+ }
+
+ $m["cmethod-$method"] = array(
+ 'type' => 'check',
+ 'label-message' => "lcadft-cmethod-$method",
+ 'default' => $user->getOption(
"lcadft-cmethod-$method" ),
+ 'section' => 'contact',
+ );
+ if ( $method === 'email' ) {
+ $m["cmethod-$method"]['disabled'] = !$user->
isEmailConfirmed();
+ }
+
+ if ( $method === 'talkpage-elsewhere' ) {
+ $m['cmethod-talkpage-elsewhere-loc'] = array(
+ 'type' => 'select',
+ 'default' => $user->getOption(
'lcadft-cmethod-talkpage-elsewhere-loc' ),
+ 'section' => 'contact',
+ 'options' => $this->getOtherWikis(),
+ );
+ }
+ }
+
+ $m['freq'] = array(
+ 'type' => 'radio',
+ 'default' => $user->getOption( 'lcadft-freq', 'always'
),
+ 'section' => 'frequency',
+ 'options' => array(
+ $this->msg( 'lcadft-freq-always' )->text() =>
'always',
+ $this->msg( 'lcadft-freq-week' )->text() =>
'week',
+ $this->msg( 'lcadft-freq-month' )->text() =>
'month',
+ $this->msg( 'lcadft-freq-weekly' )->text() =>
'weekly',
+ $this->msg( 'lcadft-freq-monthly' )->text() =>
'monthl',
+ ),
+ );
+ return $m;
+ }
+
+ public function formSubmit( $formData, $form ) {
+ global $wgRequest;
+ $user = $this->getUser();
+
+ if ( $wgRequest->getVal( 'x' ) === $this->msg(
'confirmemail_send' )->text() ) {
+ $user->sendConfirmationMail( 'set' );
+ return;
+ }
+
+ foreach ( $formData as $key => $value ) {
+ $user->setOption( "lcadft-$key", $value );
+ }
+ $user->saveSettings();
+ }
+
+ protected function getOtherWikis() {
+ $wikis = array();
+ if ( !class_exists( 'CentralAuthUser' ) ) {
+ return array();
+ }
+ $globalUser = new CentralAuthUser( $this->getUser->getName() );
+ if ( !$globalUser->exists() ) {
+ return array();
+ }
+
+ $stuff = $this->mGlobalUser->queryAttached();
+ foreach ( $suff as $dbname => $value ) {
+ $wikis[] = $dname;
+ }
+
+ return array_combine( $wikis, $wikis );
+ }
+
+}
Property changes on:
trunk/extensions/Translate/lcadft/SpecialTranslatorSignup.php
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs