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

Revision: 73030
Author:   tparscal
Date:     2010-09-15 00:36:24 +0000 (Wed, 15 Sep 2010)

Log Message:
-----------
Intitial import. Ported from UsabilityInitiative/Vector

Added Paths:
-----------
    trunk/extensions/Vector/
    trunk/extensions/Vector/Vector.hooks.php
    trunk/extensions/Vector/Vector.i18n.php
    trunk/extensions/Vector/Vector.php
    trunk/extensions/Vector/modules/

Added: trunk/extensions/Vector/Vector.hooks.php
===================================================================
--- trunk/extensions/Vector/Vector.hooks.php                            (rev 0)
+++ trunk/extensions/Vector/Vector.hooks.php    2010-09-15 00:36:24 UTC (rev 
73030)
@@ -0,0 +1,195 @@
+<?php
+/**
+ * Hooks for Vector extension
+ * 
+ * @file
+ * @ingroup Extensions
+ */
+
+class VectorHooks {
+       
+       /* Static Members */
+       
+       static $modules = array(
+               'collapsiblenav' => array(
+                       'name' => 'vector.collapsibleNav',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                               'messages' => array(
+                                       'vector-collapsiblenav-more',
+                               ),
+                       )
+                       'preferences' => array(
+                               'key' => 'vector-collapsiblenav',
+                               'ui' => array(
+                                       'type' => 'toggle',
+                                       'label-message' => 
'vector-collapsiblenav-preference',
+                                       'section' => 
'rendering/advancedrendering',
+                               ),
+                       ),
+                       'configurations' => array(
+                               'wgCollapsibleNavBucketTest',
+                               'wgCollapsibleNavForceNewVersion',
+                       ),
+               ),
+               'collapsibletabs' => array(
+                       'name' => 'vector.collapsibleTabs',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                       )
+               ),
+               'editwarning' => array(
+                       'name' => 'vector.editWarning',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                               'messages' => array(
+                                       'vector-editwarning-warning',
+                               ),
+                       ),
+                       'preferences' => array(
+                               // Ideally this would be 'vector-editwarning'
+                               'key' => 'useeditwarning',
+                               'ui' => array(
+                                       'type' => 'toggle',
+                                       'label-message' => 
'vector-editwarning-preference',
+                                       'section' => 'editing/advancedediting',
+                               ),
+                       ),
+               ),
+               'expandablesearch' => array(
+                       'name' => 'vector.expandableSearch',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                       ),
+                       'preferences' => array(
+                               'requirements' = array( 'vector-simplesearch', 
'disablesuggest' ),
+                       ),
+               ),
+               'footercleanup' => array(
+                       'name' => 'vector.footerCleanup',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                       ),
+               ),
+               'simplesearch' => array(
+                       'name' => 'vector.simpleSearch',
+                       'resources' => array(
+                               'scripts' => '',
+                               'styles' => '',
+                               'messages' => array(
+                                       'vector-simplesearch-search',
+                                       'vector-simplesearch-containing',
+                               ),
+                       ),
+                       'preferences' => array(
+                               'requirements' = array( 'vector-simplesearch', 
'disablesuggest' ),
+                       ),
+               ),
+       );
+       
+       /* Protected Static Methods */
+       
+       protected static isEnabled( $module ) {
+               global $wgVectorModules, $wgUser;
+               
+               $enabled =
+                       $wgVectorModules[$module]['global'] ||
+                       (
+                               $wgVectorModules[$module]['user'] &&
+                               isset( 
self::$modules[$module]['preferences']['key'] ) &&
+                               $wgUser->getOption( 
self::$modules[$module]['preferences']['key']
+                       );
+               if ( !$enabled ) {
+                       return false;
+               }
+               foreach ( 
self::$modules[$module]['preferences']['requirements'] as $requirement ) {
+                       if ( !$wgUser->getOption( $requirement ) ) {
+                               return false;
+                       }
+               }
+               return true;
+       }
+       
+       /* Static Methods */
+       
+       /**
+        * BeforePageDisplay hook
+        * 
+        * Adds the modules to the edit form
+        * 
+        * @param $out OutputPage output page
+        * @param $skin Skin current skin
+        */
+       public static function beforePageDisplay( $out, $skin ) {
+               global $wgVectorModules;
+               
+               // Don't load Vector modules for non-Vector skins
+               if ( !( $skin instanceof SkinVector ) ) {
+                       return true;
+               }
+               
+               // Add enabled modules
+               foreach ( $wgVectorModules as $module => $enable ) {
+                       if ( self::isEnabled( $module ) ) {
+                               $out->addModules( 
self::$modules[$module]['name'] );
+                       }
+               }
+       }
+       
+       /**
+        * GetPreferences hook
+        * 
+        * Adds Vector-releated items to the preferences
+        * 
+        * @param $out User current user
+        * @param $skin array list of default user preference controls
+        */
+       public static function getPreferences( $user, &$defaultPreferences ) {
+               global $wgVectorModules;
+               
+               foreach ( $wgVectorModules as $module => $enable ) {
+                       if ( $enable['user'] ) && isset( 
self::$modules['preferences'][$module]['ui'] ) ) {
+                               
$defaultPreferences[self::$modules['preferences'][$module]['key']] =
+                                       
self::$modules['preferences'][$module]['ui'];
+                       }
+               }
+       }
+       
+       /**
+        * MakeGlobalVariablesScript hook
+        * 
+        * Adds enabled/disabled switches for Vector modules
+        */
+       public static function makeGlobalVariablesScript( &$vars ) {
+               $configurations = array();
+               foreach ( $wgVectorModules as $module => $enable ) {
+                       if (
+                               isset( 
self::$modules[$module]['configurations'] ) &&
+                               is_array( 
self::$modules[$module]['configurations'] )
+                       ) {
+                               foreach ( 
self::$modules[$module]['configurations'] as $configuration ) {
+                                       global $$configuration;
+                                       $configurations[$configuration] = 
$$configuration;
+                               }
+                       }
+               }
+               if ( count( $configurations ) ) {
+                       $vars = array_merge( $vars, $configurations );
+               }
+               return true;
+       }
+       
+       /*
+        * ResourceLoaderRegisterModules hook
+        * 
+        * Adds modules to ResourceLoader
+        */
+       public static function resourceLoaderRegisterModules() {
+               ResourceLoader::register(  );
+       }
+}
\ No newline at end of file


Property changes on: trunk/extensions/Vector/Vector.hooks.php
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/extensions/Vector/Vector.i18n.php
===================================================================
--- trunk/extensions/Vector/Vector.i18n.php                             (rev 0)
+++ trunk/extensions/Vector/Vector.i18n.php     2010-09-15 00:36:24 UTC (rev 
73030)
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Internationalisation for Vector extension
+ * 
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author Trevor Parscal
+ */
+$messages['en'] = array(
+       'vector' => 'UI improvements for Vector',
+       'vector-desc' => 'Improves on the user interface elements of the Vector 
skin.',
+       'vector-collapsiblenav-preference' => 'Enable collapsing of items in 
the navigation menu in Vector skin',
+       'vector-collapsiblenav-more' => 'More languages',
+       'vector-editwarning-warning' => 'Leaving this page may cause you to 
lose any changes you have made.
+If you are logged in, you can disable this warning in the "Editing" section of 
your preferences.',
+       'vector-editwarning-preference' => 'Warn me when I leave an edit page 
with unsaved changes',
+       'vector-simplesearch-search' => 'Search',
+       'vector-simplesearch-containing' => 'containing...',
+);


Property changes on: trunk/extensions/Vector/Vector.i18n.php
___________________________________________________________________
Added: svn:eol-style
   + native

Added: trunk/extensions/Vector/Vector.php
===================================================================
--- trunk/extensions/Vector/Vector.php                          (rev 0)
+++ trunk/extensions/Vector/Vector.php  2010-09-15 00:36:24 UTC (rev 73030)
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Vector extension
+ * 
+ * @file
+ * @ingroup Extensions
+ * 
+ * @author Trevor Parscal <[email protected]>
+ * @author Roan Kattouw <[email protected]>
+ * @author Nimish Gautam <[email protected]>
+ * @author Adam Miller <[email protected]>
+ * @license GPL v2 or later
+ * @version 0.2.0
+ */
+
+/* Configuration */
+
+// Each module may be configured individually to be globally on/off or user 
preference based
+$wgVectorModules = array(
+       'collapsiblenav' => array( 'global' => true, 'user' => true ),
+       'collapsibletabs' => array( 'global' => true, 'user' => false ),
+       'editwarning' => array( 'global' => false, 'user' => true ),
+       'expandablesearch' => array( 'global' => false, 'user' => true ),
+       'footercleanup' => array( 'global' => false, 'user' => false ),
+       'simplesearch' => array( 'global' => false, 'user' => true ),
+);
+
+// The Vector skin has a basic version of simple search, which is a 
prerequisite for the enhanced one
+$wgDefaultUserOptions['vector-simplesearch'] = 1;
+
+// Enable bucket testing for new version of collapsible nav
+$wgCollapsibleNavBucketTest = false;
+// Force the new version
+$wgCollapsibleNavForceNewVersion = false;
+
+/* Setup */
+
+$wgExtensionCredits['other'][] = array(
+       'path' => __FILE__,
+       'name' => 'Vector',
+       'author' => array( 'Trevor Parscal', 'Roan Kattouw', 'Nimish Gautam', 
'Adam Miller' ),
+       'version' => '0.3.0',
+       'url' => 'http://www.mediawiki.org/wiki/Extension:Vector',
+       'descriptionmsg' => 'vector-desc',
+);
+$wgAutoloadClasses['VectorHooks'] = dirname( __FILE__ ) . '/Vector.hooks.php';
+$wgExtensionMessagesFiles['Vector'] = dirname( __FILE__ ) . '/Vector.i18n.php';
+$wgHooks['BeforePageDisplay'][] = 'VectorHooks::beforePageDisplay';
+$wgHooks['GetPreferences'][] = 'VectorHooks::getPreferences';
+$wgHooks['MakeGlobalVariablesScript'][] = 
'VectorHooks::MakeGlobalVariablesScript';
+$wgHooks['ResourceLoaderRegisterModules'][] = 
'VectorHooks::resourceLoaderRegisterModules';
\ No newline at end of file


Property changes on: trunk/extensions/Vector/Vector.php
___________________________________________________________________
Added: svn:eol-style
   + native



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

Reply via email to