M4tx has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/104906


Change subject: Add an ability to change the copyright warning in editor and 
uploader
......................................................................

Add an ability to change the copyright warning in editor and uploader

* License for editor is now taken from LocalSettings.php
* There's a way to hook into both license texts from code now

Bug: 56639
Change-Id: Ib8a1ce46d8b3dc5ea444cc538e48be0cb280222f
---
M MobileFrontend.i18n.php
M MobileFrontend.php
M includes/Resources.php
A includes/modules/LicenseTextModule.php
4 files changed, 88 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/06/104906/1

diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index e72f067..0b21467 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -305,7 +305,7 @@
        'mobile-frontend-photo-upload-error-file-type' => 'Please only upload 
images.',
        'mobile-frontend-photo-upload-error-filename' => 'Error, please provide 
a more descriptive summary.',
        'mobile-frontend-photo-upload-success-article' => 'Success! Your image 
is now live on this page.',
-       'mobile-frontend-photo-license' => 'By uploading this image, you agree 
to our [//wikimediafoundation.org/wiki/Terms_of_use Terms of Use] and agree to 
release your image under the [//creativecommons.org/licenses/by-sa/3.0/ 
Creative Commons Attribution-ShareAlike 3.0 License].',
+       'mobile-frontend-photo-license' => 'By uploading this image, you agree 
to release it under the [//creativecommons.org/licenses/by-sa/3.0/ Creative 
Commons Attribution-ShareAlike 3.0 License].',
        'mobile-frontend-photo-submit' => 'Submit',
        'mobile-frontend-photo-cancel' => 'Cancel',
        'mobile-frontend-photo-upload-user-count' => 
'{{PLURAL:$1|<span>1</span> upload|<span>$1</span> uploads}}',
@@ -328,7 +328,10 @@
        'mobile-frontend-editor-save' => 'Save',
        'mobile-frontend-editor-cancel' => 'Cancel',
        'mobile-frontend-editor-keep-editing' => 'Keep editing',
-       'mobile-frontend-editor-license' => 'By saving changes, you agree to 
our [//wikimediafoundation.org/wiki/Terms_of_use Terms of Use] and agree to 
release your text under the [//creativecommons.org/licenses/by-sa/3.0/ CC BY-SA 
3.0 License] and 
[//en.wikipedia.org/wiki/Wikipedia:Text_of_the_GNU_Free_Documentation_License 
GFDL].',
+       'mobile-frontend-editor-copyright' => "Please note that all 
contributions to {{SITENAME}} are considered to be released under the $2 (see 
$1 for details).
+'''Do not submit copyrighted work without permission!'''",
+       'mobile-frontend-editor-copyright2' => "Please note that all 
contributions to {{SITENAME}} may be edited, altered, or removed by other 
contributors (see $1 for details).
+'''Do not submit copyrighted work without permission!'''",
        'mobile-frontend-editor-placeholder' => 'This section is empty. Be the 
first to expand it!',
        'mobile-frontend-editor-summary-placeholder' => 'Tell us what you 
changed (optional)',
        'mobile-frontend-editor-cancel-confirm' => 'Do you really want to 
abandon your edit?',
@@ -697,6 +700,15 @@
 {{Identical|Privacy}}',
        'mobile-frontend-footer-sitename' => 'Name of site',
        'mobile-frontend-footer-license' => 'License shown in footer',
+       'mobile-frontend-editor-copyright' => "Copyright warning displayed 
under the edit box in editor. Parameters:
+* $1 - link
+* $2 - license name
+'''See also'''
+* {{msg-mw|Copyrightwarning}}",
+       'mobile-frontend-editor-copyright2' => "Copyright warning displayed 
under the edit box in editor
+*$1 - license name
+'''See also'''
+* {{msg-mw|Copyrightwarning2}}",
        'mobile-frontend-copyright' => "A short sentence explaining that the 
content of the page is available under a particular license. Parameters:
 * $1 - license name
 '''See also'''
@@ -922,7 +934,7 @@
        'mobile-frontend-photo-upload-error-file-type' => 'Text that displays 
when user tries to preview something that cannot be rendered in an img tag 
(e.g. mp3 or video)',
        'mobile-frontend-photo-upload-error-filename' => 'Text that displays 
when an image fails to upload due to filename',
        'mobile-frontend-photo-upload-success-article' => 'Text that displays 
when an image has been successfully added to a page.',
-       'mobile-frontend-photo-license' => 'Text notifying user of license that 
image will be published under. You can change the URL to a "local" Wikipedia 
URL, but you cannot make it point to the country specific CC BY-SA 3.0 
license.',
+       'mobile-frontend-photo-license' => 'Text notifying user of license that 
image will be published under. You cannot make it point to the country specific 
CC BY-SA 3.0 license.',
        'mobile-frontend-photo-submit' => 'Caption for the submit button on the 
image uplaod form.
 {{Identical|Submit}}',
        'mobile-frontend-photo-cancel' => 'Caption for the cancel button on the 
image upload form.
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 701b21c..847ceb8 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -64,6 +64,7 @@
        'InlineDifferenceEngine' => 'diff/InlineDifferenceEngine',
 
        'MFResourceLoaderModule' => 'modules/MFResourceLoaderModule',
+       'LicenseTextModule' => 'modules/LicenseTextModule',
        'MobileSiteModule' => 'modules/MobileSiteModule',
 
        'SpecialUploads' => 'specials/SpecialUploads',
diff --git a/includes/Resources.php b/includes/Resources.php
index 64fb857..bb2939c 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -230,7 +230,8 @@
                ),
        ),
 
-       'mobile.editor.common' => $wgMFMobileResourceBoilerplate + array(
+       'mobile.editor.common' => array(
+               'class' => 'LicenseTextModule',
                'dependencies' => array(
                        'mobile.stable',
                        'mobile.templates',
@@ -247,7 +248,6 @@
                        'mobile-frontend-editor-continue',
                        'mobile-frontend-editor-cancel',
                        'mobile-frontend-editor-keep-editing',
-                       'mobile-frontend-editor-license' => array( 'parse' ),
                        'mobile-frontend-editor-placeholder',
                        'mobile-frontend-editor-summary-placeholder',
                        'mobile-frontend-editor-cancel-confirm',
@@ -266,7 +266,7 @@
                        'mobile-frontend-editor-abusefilter-disallow',
                        'mobile-frontend-editor-abusefilter-read-more',
                ),
-       ),
+       ) + $wgMFMobileResourceBoilerplate, // at the end to allow 'class' 
override
        'mobile.editor.styles' => $wgMFMobileResourceBoilerplate + array(
                'styles' => array(
                        'less/modules/editor.less',
@@ -392,7 +392,8 @@
                ),
        ),
 
-       'mobile.uploads' => $wgMFMobileResourceBoilerplate + array(
+       'mobile.uploads' => array(
+               'class' => 'LicenseTextModule',
                'dependencies' => array(
                        'mobile.stable',
                        'mobile.templates',
@@ -423,7 +424,6 @@
                        'mobile-frontend-photo-ownership-confirm',
 
                        // PhotoUploaderPreview.js
-                       'mobile-frontend-photo-license' => array( 'parse' ),
                        'mobile-frontend-photo-ownership',
                        'mobile-frontend-photo-ownership-help',
                        'mobile-frontend-photo-caption-placeholder',
@@ -434,7 +434,6 @@
                        'mobile-frontend-photo-ownership-bullet-two',
                        'mobile-frontend-photo-ownership-bullet-three',
                        'mobile-frontend-photo-upload-error-file-type',
-                       'mobile-frontend-photo-license' => array( 'parse' ),
 
                        // PhotoUploadProgress.js
                        'mobile-frontend-image-uploading-wait',
@@ -455,9 +454,10 @@
                        'mobile-frontend-photo-nag-learn-more-2' => array( 
'parse' ),
                        'mobile-frontend-photo-nag-learn-more-3' => array( 
'parse' ),
                ),
-       ),
+       ) + $wgMFMobileResourceBoilerplate,
 
-       'mobile.uploadsNew' => $wgMFMobileResourceBoilerplate + array(
+       'mobile.uploadsNew' => array(
+               'class' => 'LicenseTextModule',
                'dependencies' => array(
                        'mobile.stable',
                        'mobile.templates',
@@ -486,13 +486,12 @@
                        'mobile-frontend-photo-caption-placeholder',
                        'mobile-frontend-photo-submit',
                        'mobile-frontend-photo-upload-error-file-type',
-                       'mobile-frontend-photo-license' => array( 'parse' ),
 
                        // PhotoUploadProgress.js
                        'mobile-frontend-image-uploading' => array( 'parse' ),
                        'mobile-frontend-image-cancel-confirm' => array( 
'parse' ),
                ),
-       ),
+       ) + $wgMFMobileResourceBoilerplate,
 
        'mobile.beta.common' => $wgMFMobileResourceBoilerplate + array(
                'dependencies' => array(
@@ -615,7 +614,8 @@
                ),
        ),
 
-       'mobile.talk' => $wgMFMobileResourceBoilerplate + array(
+       'mobile.talk' => array(
+               'class' => 'LicenseTextModule',
                'dependencies' => array(
                        'mobile.beta',
                        'mobile.templates',
@@ -645,9 +645,8 @@
                        'mobile-frontend-talk-topic-feedback',
                        // FIXME: Gets loaded twice if editor and talk both 
loaded.
                        'mobile-frontend-editor-cancel',
-                       'mobile-frontend-editor-license' => array( 'parse' ),
                ),
-       ),
+       ) + $wgMFMobileResourceBoilerplate,
 
        'mobile.alpha' => $wgMFMobileResourceBoilerplate + array(
                'dependencies' => array(
diff --git a/includes/modules/LicenseTextModule.php 
b/includes/modules/LicenseTextModule.php
new file mode 100644
index 0000000..0ce1d5f
--- /dev/null
+++ b/includes/modules/LicenseTextModule.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * Provides a way to pass the license texts to JavaScript.
+ */
+class LicenseTextModule extends MFResourceLoaderModule {
+       /**
+        * Get the copyright warning text as HTML
+        *
+        * @param Title $title
+        * @return string
+        */
+       public static function getEditorCopyrightWarning( $title = null ) {
+               global $wgRightsText;
+               if ( $wgRightsText ) {
+                       $copywarnMsg = array( 
'mobile-frontend-editor-copyright',
+                               '[[' . wfMessage( 'copyrightpage' 
)->inContentLanguage()->text() . ']]',
+                               $wgRightsText );
+               } else {
+                       $copywarnMsg = array( 
'mobile-frontend-editor-copyright2',
+                               '[[' . wfMessage( 'copyrightpage' 
)->inContentLanguage()->text() . ']]' );
+               }
+               // Allow for site and per-namespace customization of 
contribution/copyright notice.
+               wfRunHooks( 'EditPageMobileCopyrightWarning', array( $title, 
&$copywarnMsg ) );
+
+               return call_user_func_array( 'wfMessage', $copywarnMsg 
)->parse();
+       }
+
+       /**
+        * Get the upload copyright warning text as HTML
+        *
+        * @param Title $title
+        * @return string
+        */
+       public static function getUploadCopyrightWarning( $title = null ) {
+               $copywarnMsg = array( 'mobile-frontend-photo-license' );
+
+               // Allow for site and per-namespace customization of 
contribution/copyright notice.
+               wfRunHooks( 'UploadMobileCopyrightWarning', array( $title, 
&$copywarnMsg ) );
+
+               return call_user_func_array( 'wfMessage', $copywarnMsg 
)->parse();
+       }
+
+    /**
+     * Used to pass the license texts to JavaScript.
+     *
+     * @param ResourceLoaderContext $context
+     *
+     * @return string
+     */
+    public function getScript( ResourceLoaderContext $context ) {
+               $script = parent::getScript( $context );
+           $license = $this->getEditorCopyrightWarning();
+           $imageLicense = $this->getUploadCopyrightWarning();
+
+               $js = Xml::encodeJsCall( 'mw.messages.set', array( 
'mobile-frontend-editor-license', $license ) );
+           $js .= Xml::encodeJsCall( 'mw.messages.set', array( 
'mobile-frontend-photo-license', $imageLicense ) );
+           return $js . "\n" . $script;
+    }
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/104906
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib8a1ce46d8b3dc5ea444cc538e48be0cb280222f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: M4tx <m...@m4tx.pl>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to