http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89006

Revision: 89006
Author:   foxtrott
Date:     2011-05-27 22:44:12 +0000 (Fri, 27 May 2011)
Log Message:
-----------
followup r89002: nasty trick to support both the old and the new signatures for 
the userCanExecute() method

Modified Paths:
--------------
    trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php

Modified: trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php
===================================================================
--- trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php        
2011-05-27 22:42:20 UTC (rev 89005)
+++ trunk/extensions/SemanticForms/specials/SF_UploadWindow2.php        
2011-05-27 22:44:12 UTC (rev 89006)
@@ -14,7 +14,7 @@
 /**
  * @ingroup SFSpecialPages
  */
-class SFUploadWindow2 extends UnlistedSpecialPage {
+class SFUploadWindow2Proto extends UnlistedSpecialPage {
        /**
         * Constructor : initialise object
         * Get data POSTed through the form and assign them to the object
@@ -105,23 +105,6 @@
        }
 
        /**
-        * This page can be shown if uploading is enabled.
-        * Handle permission checking elsewhere in order to be able to show
-        * custom error messages.
-        *
-        * @param User $user
-        * @return bool
-        */
-       // @TODO The "User" class was added to the function header
-       // for SpecialPage::userCanExecute in MW 1.19 (r86407) - somehow
-       // both the old and new signatures need to be supported. For now,
-       // though, support only the old signature, since that's used by
-       // the vast majority of users.
-       public function userCanExecute( $user ) {
-               return UploadBase::isEnabled() && parent::userCanExecute( $user 
);
-       }
-
-       /**
         * Special page entry point
         */
        public function execute( $par ) {
@@ -1101,3 +1084,51 @@
        }
        
 }
+
+global $wgVersion;
+// @TODO The "User" class was added to the function header
+// for SpecialPage::userCanExecute in MW 1.19 (r86407) - somehow
+// both the old and new signatures need to be supported. When support
+// is dropped for MW below 1.19 this should be reintegrated into one
+// class.
+if ( version_compare( $wgVersion, '1.18alpha', '<' )) {
+
+       /**
+        * Class variant for MW up to 1.17
+        */
+       class SFUploadWindow2 extends SFUploadWindow2Proto {
+               /**
+                * This page can be shown if uploading is enabled.
+                * Handle permission checking elsewhere in order to be able to 
show
+                * custom error messages.
+                *
+                * @param User $user
+                * @return bool
+                */
+               public function userCanExecute( $user ) {
+                       return UploadBase::isEnabled() && 
parent::userCanExecute( $user );
+               }
+
+
+       }
+
+} else {
+
+       /**
+        * Class variant for MW 1.18+
+        */
+       class SFUploadWindow2 extends SFUploadWindow2Proto {
+               /**
+                * This page can be shown if uploading is enabled.
+                * Handle permission checking elsewhere in order to be able to 
show
+                * custom error messages.
+                *
+                * @param User $user
+                * @return bool
+                */
+               public function userCanExecute( User $user ) {
+                       return UploadBase::isEnabled() && 
parent::userCanExecute( $user );
+               }
+       }
+
+}
\ No newline at end of file


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

Reply via email to