Jack Phoenix has submitted this change and it was merged.

Change subject: Version 3.1 - fixed color picker and moved it to its own file.
......................................................................


Version 3.1 - fixed color picker and moved it to its own file.

Also various, miscellaneous fixes, such as:
* special page grouping updated to use the modern method (a getGroupName()
 method in the special page class file instead of $wgSpecialPageGroups)
* fixed color picker image URLs not to load 'em from Yahoo's servers since
 they're no longer there
* removed some $wgTitle usages
* documentation tweaks

Change-Id: Icb2429f5a478055483f0e48f9eed09062cf6258b
---
M FanBox.php
M FanBoxHooks.php
M FanBoxPage.php
M FanBoxesClass.php
M SpecialFanBoxes.php
M SpecialTopFanBoxes.php
M SpecialViewFanBoxes.php
A color-picker.js
8 files changed, 105 insertions(+), 68 deletions(-)

Approvals:
  Jack Phoenix: Verified; Looks good to me, approved



diff --git a/FanBox.php b/FanBox.php
index 8c29312..7eec95d 100644
--- a/FanBox.php
+++ b/FanBox.php
@@ -6,12 +6,12 @@
  *
  * @file
  * @ingroup Extensions
- * @version 3.0
+ * @version 3.1
  * @author Aaron Wright <[email protected]>
  * @author David Pean <[email protected]>
  * @author Robert Lefkowitz
  * @author Jack Phoenix <[email protected]>
- * @link http://www.mediawiki.org/wiki/Extension:FanBox Documentation
+ * @link https://www.mediawiki.org/wiki/Extension:FanBox Documentation
  * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 
2.0 or later
  */
 
@@ -22,9 +22,9 @@
 // Extension credits that show up on Special:Version
 $wgExtensionCredits['other'][] = array(
        'name' => 'FanBox',
-       'version' => '3.0',
+       'version' => '3.1',
        'author' => array( 'Aaron Wright', 'David Pean', 'Robert Lefkowitz', 
'Jack Phoenix' ),
-       'url' => 'https://www.mediawiki.org/wiki/Extension:FanBox',
+       'url' => 'https://www.mediawiki.org/wiki/Extension:FanBoxes',
        'description' => 'A new way of creating and using userboxes, based on 
special pages',
 );
 
@@ -42,6 +42,12 @@
        'position' => 'top' // available since r85616
 );
 
+$wgResourceModules['ext.fanBoxes.colorpicker'] = array(
+       'scripts' => 'color-picker.js',
+       'localBasePath' => dirname( __FILE__ ),
+       'remoteExtPath' => 'FanBoxes',
+);
+
 // Global fantag namespace reference
 if ( !defined( 'NS_FANTAG' ) ) {
        define( 'NS_FANTAG', 600 );
@@ -55,6 +61,7 @@
 $dir = dirname( __FILE__ ) . '/';
 $wgExtensionMessagesFiles['FanBox'] = $dir . 'FanBox.i18n.php';
 $wgExtensionMessagesFiles['FanBoxNamespaces'] = $dir . 'FanBox.namespaces.php';
+
 $wgAutoloadClasses['FanBox'] = $dir . 'FanBoxClass.php';
 $wgAutoloadClasses['SpecialFanBoxAjaxUpload'] = $dir . 'MiniAjaxUpload.php';
 $wgAutoloadClasses['FanBoxAjaxUploadForm'] = $dir . 'MiniAjaxUpload.php';
@@ -65,14 +72,11 @@
 $wgAutoloadClasses['TopFanBoxes'] = $dir . 'SpecialTopFanBoxes.php';
 $wgAutoloadClasses['UserFanBoxes'] = $dir . 'FanBoxesClass.php';
 $wgAutoloadClasses['ViewFanBoxes'] = $dir . 'SpecialViewFanBoxes.php';
+
 $wgSpecialPages['FanBoxAjaxUpload'] = 'SpecialFanBoxAjaxUpload';
 $wgSpecialPages['UserBoxes'] = 'FanBoxes';
 $wgSpecialPages['TopUserboxes'] = 'TopFanBoxes';
 $wgSpecialPages['ViewUserBoxes'] = 'ViewFanBoxes';
-// Special page groups for MW 1.13+
-$wgSpecialPageGroups['UserBoxes'] = 'users';
-$wgSpecialPageGroups['TopUserboxes'] = 'users';
-$wgSpecialPageGroups['ViewUserBoxes'] = 'users';
 
 // API module
 $wgAutoloadClasses['ApiFanBoxes'] = $dir . 'ApiFanBoxes.php';
diff --git a/FanBoxHooks.php b/FanBoxHooks.php
index 0407cb7..11c730c 100644
--- a/FanBoxHooks.php
+++ b/FanBoxHooks.php
@@ -1,6 +1,6 @@
 <?php
 /**
- * FanBox extension's hooked function. All class methods are obviously public
+ * FanBox extension's hooked functions. All class methods are obviously public
  * and static.
  *
  * @file
@@ -124,13 +124,12 @@
         * Calls FanBoxPage instead of standard Article for pages in the 
NS_FANTAG
         * namespace.
         *
-        * @param $title Object: instance of Title
-        * @param $article Object: instance of Article that we transform into an
-        *                         instance of FanBoxPage
+        * @param $title Title
+        * @param $article Article|WikiPage|FanBoxPage
         * @return Boolean: true
         */
        public static function fantagFromTitle( &$title, &$article ) {
-               global $wgRequest, $wgOut, $wgTitle, $wgSupressPageTitle, 
$wgSupressPageCategories;
+               global $wgRequest, $wgOut, $wgSupressPageTitle;
 
                if ( $title->getNamespace() == NS_FANTAG ) {
                        $wgSupressPageTitle = true;
@@ -146,11 +145,11 @@
                                        $wgOut->redirect( 
$addTitle->getFullURL( 'destName=' . $fan->getName() ) );
                                } else {
                                        $update = SpecialPage::getTitleFor( 
'UserBoxes' );
-                                       $wgOut->redirect( $update->getFullURL( 
'id=' . $wgTitle->getArticleID() ) );
+                                       $wgOut->redirect( $update->getFullURL( 
'id=' . $title->getArticleID() ) );
                                }
                        }
 
-                       $article = new FanBoxPage( $wgTitle );
+                       $article = new FanBoxPage( $title );
                }
 
                return true;
@@ -159,7 +158,7 @@
        /**
         * Register the new <fan> hook with the parser.
         *
-        * @param $parser Object: instance of Parser (not necessarily $wgParser)
+        * @param $parser Parser
         * @return Boolean: true
         */
        public static function registerFanTag( &$parser ) {
@@ -173,7 +172,7 @@
         *
         * @param $input
         * @param $argv Array: array of user-supplied arguments
-        * @param $parser Object: instance of Parser
+        * @param $parser Parser
         * @return String: HTML
         */
        public static function embedFanBox( $input, $argv, $parser ) {
@@ -216,8 +215,8 @@
        /**
         * Add FanBox's CSS and JS into the page output.
         *
-        * @param $out Object: instance of OutputPage
-        * @param $skin Object: instance of Skin or a descendant class
+        * @param $out OutputPage
+        * @param $skin Skin
         * @return Boolean: true
         */
        public static function addFanBoxScripts( &$out, &$skin ) {
diff --git a/FanBoxPage.php b/FanBoxPage.php
index 725c567..db4f8d7 100644
--- a/FanBoxPage.php
+++ b/FanBoxPage.php
@@ -20,14 +20,14 @@
        }
 
        function view() {
-               global $wgOut, $wgUser, $wgTitle;
+               global $wgOut, $wgUser;
 
                // Add JS
                $wgOut->addModuleScripts( 'ext.fanBoxes' );
 
                // Set the page title
-               $wgOut->setHTMLTitle( $wgTitle->getText() );
-               $wgOut->setPageTitle( $wgTitle->getText() );
+               $wgOut->setHTMLTitle( $this->getTitle()->getText() );
+               $wgOut->setPageTitle( $this->getTitle()->getText() );
 
                // Don't throw a bunch of E_NOTICEs when we're viewing the page 
of a
                // nonexistent fanbox
diff --git a/FanBoxesClass.php b/FanBoxesClass.php
index 5bbb4c4..288ec10 100644
--- a/FanBoxesClass.php
+++ b/FanBoxesClass.php
@@ -1,5 +1,8 @@
 <?php
 /**
+ * Functions for handling the displaying of an individual user's fanboxes.
+ * Used by SpecialFanBoxes.php and UserBoxesHook.php.
+ *
  * @file
  * @todo document
  */
diff --git a/SpecialFanBoxes.php b/SpecialFanBoxes.php
index e6698b4..058986b 100644
--- a/SpecialFanBoxes.php
+++ b/SpecialFanBoxes.php
@@ -16,6 +16,15 @@
        }
 
        /**
+        * Group this special page under the correct header on 
Special:SpecialPages.
+        *
+        * @return String
+        */
+       protected function getGroupName() {
+               return 'users';
+       }
+
+       /**
         * Show the special page
         *
         * @param $par Mixed: parameter passed to the page or null
@@ -46,7 +55,7 @@
                }
 
                // Extension's CSS & JS
-               $out->addModules( 'ext.fanBoxes' );
+               $out->addModules( array( 'ext.fanBoxes', 
'ext.fanBoxes.colorpicker' ) );
 
                // colorpicker
                $out->addScript( "<script type=\"text/javascript\" 
src=\"http://yui.yahooapis.com/2.5.2/build/utilities/utilities.js\";></script>\n"
 );
@@ -344,6 +353,12 @@
                }
        }
 
+       /**
+        * Return the HTML for the color picker and the category cloud.
+        *
+        * @param $categories String
+        * @return String
+        */
        function colorPickerAndCategoryCloud( $categories ) {
                $output = '<div class="add-colors">
                                        <h1>' . $this->msg( 'fan-add-colors' 
)->plain() . '</h1>
@@ -359,56 +374,16 @@
                                                        $this->msg( 
'fanbox-rightbg-color' )->plain() .
                                                '<br />
                                                <input type="radio" 
name="colorpickerchoice" value="rightText" />' .
-                                               $this->msg( 
'fanbox-righttext-color' )->plain() . "
+                                               $this->msg( 
'fanbox-righttext-color' )->plain() . '
                                                </form>
                                        </div>
 
-                                       <div id=\"add-colors-right\">
-                                       <div id=\"colorpickerholder\"></div>
+                                       <div id="add-colors-right">
+                                       <div id="colorpickerholder"></div>
                                        </div>
 
-                                       <script type=\"text/javascript\">
-                                       jQuery( document ).ready( function() {
-                                               var colorPickerTest = new 
YAHOO.widget.ColorPicker( 'colorpickerholder', {
-                                                       showhsvcontrols: true,
-                                                       showhexcontrols: true,
-                                                       images: {
-                                                               PICKER_THUMB: 
'http://developer.yahoo.com/yui/build/colorpicker/assets/picker_thumb.png',
-                                                               HUE_THUMB: 
'http://developer.yahoo.com/yui/build/colorpicker/assets/hue_thumb.png'
-                                                       }
-                                               });
-
-                                               colorPickerTest.on( 
'rgbChange', function( p_oEvent ) {
-                                                       var sColor = '#' + 
this.get( 'hex' );
-
-                                                       if ( 
document.colorpickerradio.colorpickerchoice[0].checked ) {
-                                                               
document.getElementById( 'fanBoxLeftSideOutput2' ).style.backgroundColor = 
sColor;
-                                                               // The 
commented-out line below is the original NYC code but I noticed that it doesn't 
work
-                                                               
//document.getElementById( 'fanBoxLeftSideContainer' ).style.backgroundColor = 
sColor;
-                                                               
document.getElementById( 'bgColorLeftSideColor' ).value = sColor;
-                                                       }
-
-                                                       if ( 
document.colorpickerradio.colorpickerchoice[1].checked ) {
-                                                               
document.getElementById( 'fanBoxLeftSideOutput2' ).style.color = sColor;
-                                                               
document.getElementById( 'textColorLeftSideColor' ).value = sColor;
-                                                       }
-
-                                                       if ( 
document.colorpickerradio.colorpickerchoice[2].checked ) {
-                                                               
document.getElementById( 'fanBoxRightSideOutput2' ).style.backgroundColor = 
sColor;
-                                                               // The 
commented-out line below is the original NYC code but I noticed that it doesn't 
work
-                                                               
//document.getElementById( 'fanBoxRightSideContainer' ).style.backgroundColor = 
sColor;
-                                                               
document.getElementById( 'bgColorRightSideColor' ).value = sColor;
-                                                       }
-
-                                                       if ( 
document.colorpickerradio.colorpickerchoice[3].checked ) {
-                                                               
document.getElementById( 'fanBoxRightSideOutput2' ).style.color = sColor;
-                                                               
document.getElementById( 'textColorRightSideColor' ).value = sColor;
-                                                       }
-                                               });
-                                       } );
-                                       </script>
-                                       <div class=\"cleared\"></div>
-                               </div>";
+                                       <div class="cleared"></div>
+                               </div>';
 
                // Category cloud stuff
                $cloud = new TagCloud( 10 );
diff --git a/SpecialTopFanBoxes.php b/SpecialTopFanBoxes.php
index 455ac4d..bd77c3e 100644
--- a/SpecialTopFanBoxes.php
+++ b/SpecialTopFanBoxes.php
@@ -16,6 +16,15 @@
        }
 
        /**
+        * Group this special page under the correct header on 
Special:SpecialPages.
+        *
+        * @return String
+        */
+       protected function getGroupName() {
+               return 'users';
+       }
+
+       /**
         * Show the special page
         *
         * @param $par Mixed: parameter passed to the page or null
diff --git a/SpecialViewFanBoxes.php b/SpecialViewFanBoxes.php
index fc25795..56eecd0 100644
--- a/SpecialViewFanBoxes.php
+++ b/SpecialViewFanBoxes.php
@@ -16,6 +16,15 @@
        }
 
        /**
+        * Group this special page under the correct header on 
Special:SpecialPages.
+        *
+        * @return String
+        */
+       protected function getGroupName() {
+               return 'users';
+       }
+
+       /**
         * Show the special page
         *
         * @param $par Mixed: parameter passed to the page or null
diff --git a/color-picker.js b/color-picker.js
new file mode 100644
index 0000000..39cc486
--- /dev/null
+++ b/color-picker.js
@@ -0,0 +1,38 @@
+jQuery( document ).ready( function() {
+       var colorPickerTest = new YAHOO.widget.ColorPicker( 
'colorpickerholder', {
+               showhsvcontrols: true,
+               showhexcontrols: true,
+               images: {
+                       PICKER_THUMB: 
'https://web.archive.org/web/20130310031336/http://developer.yahoo.com/yui/build/colorpicker/assets/picker_thumb.png',
+                       HUE_THUMB: 
'https://web.archive.org/web/20130310031339/http://developer.yahoo.com/yui/build/colorpicker/assets/hue_thumb.png'
+               }
+       } );
+
+       colorPickerTest.on( 'rgbChange', function( p_oEvent ) {
+               var sColor = '#' + this.get( 'hex' );
+
+               if ( document.colorpickerradio.colorpickerchoice[0].checked ) {
+                       document.getElementById( 'fanBoxLeftSideOutput2' 
).style.backgroundColor = sColor;
+                       // The commented-out line below is the original NYC 
code but I noticed that it doesn't work
+                       //document.getElementById( 'fanBoxLeftSideContainer' 
).style.backgroundColor = sColor;
+                       document.getElementById( 'bgColorLeftSideColor' ).value 
= sColor;
+               }
+
+               if ( document.colorpickerradio.colorpickerchoice[1].checked ) {
+                       document.getElementById( 'fanBoxLeftSideOutput2' 
).style.color = sColor;
+                       document.getElementById( 'textColorLeftSideColor' 
).value = sColor;
+               }
+
+               if ( document.colorpickerradio.colorpickerchoice[2].checked ) {
+                       document.getElementById( 'fanBoxRightSideOutput2' 
).style.backgroundColor = sColor;
+                       // The commented-out line below is the original NYC 
code but I noticed that it doesn't work
+                       //document.getElementById( 'fanBoxRightSideContainer' 
).style.backgroundColor = sColor;
+                       document.getElementById( 'bgColorRightSideColor' 
).value = sColor;
+               }
+
+               if ( document.colorpickerradio.colorpickerchoice[3].checked ) {
+                       document.getElementById( 'fanBoxRightSideOutput2' 
).style.color = sColor;
+                       document.getElementById( 'textColorRightSideColor' 
).value = sColor;
+               }
+       } );
+} );
\ No newline at end of file

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Icb2429f5a478055483f0e48f9eed09062cf6258b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/FanBoxes
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <[email protected]>
Gerrit-Reviewer: Jack Phoenix <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to