Index: trunk/extensions/Vector/Vector.i18n.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation for Vector extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Trevor Parscal |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'vector' => 'UI improvements for Vector', |
| 17 | + 'vector-desc' => 'Improves on the user interface elements of the Vector skin.', |
| 18 | + 'vector-collapsiblenav-preference' => 'Enable collapsing of items in the navigation menu in Vector skin', |
| 19 | + 'vector-collapsiblenav-more' => 'More languages', |
| 20 | + 'vector-editwarning-warning' => 'Leaving this page may cause you to lose any changes you have made. |
| 21 | +If you are logged in, you can disable this warning in the "Editing" section of your preferences.', |
| 22 | + 'vector-editwarning-preference' => 'Warn me when I leave an edit page with unsaved changes', |
| 23 | + 'vector-simplesearch-search' => 'Search', |
| 24 | + 'vector-simplesearch-containing' => 'containing...', |
| 25 | +); |
Property changes on: trunk/extensions/Vector/Vector.i18n.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 26 | + native |
Index: trunk/extensions/Vector/Vector.php |
— | — | @@ -0,0 +1,51 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Vector extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * @author Trevor Parscal <trevor@wikimedia.org> |
| 10 | + * @author Roan Kattouw <roan.kattouw@gmail.com> |
| 11 | + * @author Nimish Gautam <nimish@wikimedia.org> |
| 12 | + * @author Adam Miller <amiller@wikimedia.org> |
| 13 | + * @license GPL v2 or later |
| 14 | + * @version 0.2.0 |
| 15 | + */ |
| 16 | + |
| 17 | +/* Configuration */ |
| 18 | + |
| 19 | +// Each module may be configured individually to be globally on/off or user preference based |
| 20 | +$wgVectorModules = array( |
| 21 | + 'collapsiblenav' => array( 'global' => true, 'user' => true ), |
| 22 | + 'collapsibletabs' => array( 'global' => true, 'user' => false ), |
| 23 | + 'editwarning' => array( 'global' => false, 'user' => true ), |
| 24 | + 'expandablesearch' => array( 'global' => false, 'user' => true ), |
| 25 | + 'footercleanup' => array( 'global' => false, 'user' => false ), |
| 26 | + 'simplesearch' => array( 'global' => false, 'user' => true ), |
| 27 | +); |
| 28 | + |
| 29 | +// The Vector skin has a basic version of simple search, which is a prerequisite for the enhanced one |
| 30 | +$wgDefaultUserOptions['vector-simplesearch'] = 1; |
| 31 | + |
| 32 | +// Enable bucket testing for new version of collapsible nav |
| 33 | +$wgCollapsibleNavBucketTest = false; |
| 34 | +// Force the new version |
| 35 | +$wgCollapsibleNavForceNewVersion = false; |
| 36 | + |
| 37 | +/* Setup */ |
| 38 | + |
| 39 | +$wgExtensionCredits['other'][] = array( |
| 40 | + 'path' => __FILE__, |
| 41 | + 'name' => 'Vector', |
| 42 | + 'author' => array( 'Trevor Parscal', 'Roan Kattouw', 'Nimish Gautam', 'Adam Miller' ), |
| 43 | + 'version' => '0.3.0', |
| 44 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:Vector', |
| 45 | + 'descriptionmsg' => 'vector-desc', |
| 46 | +); |
| 47 | +$wgAutoloadClasses['VectorHooks'] = dirname( __FILE__ ) . '/Vector.hooks.php'; |
| 48 | +$wgExtensionMessagesFiles['Vector'] = dirname( __FILE__ ) . '/Vector.i18n.php'; |
| 49 | +$wgHooks['BeforePageDisplay'][] = 'VectorHooks::beforePageDisplay'; |
| 50 | +$wgHooks['GetPreferences'][] = 'VectorHooks::getPreferences'; |
| 51 | +$wgHooks['MakeGlobalVariablesScript'][] = 'VectorHooks::MakeGlobalVariablesScript'; |
| 52 | +$wgHooks['ResourceLoaderRegisterModules'][] = 'VectorHooks::resourceLoaderRegisterModules'; |
\ No newline at end of file |
Property changes on: trunk/extensions/Vector/Vector.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 53 | + native |
Index: trunk/extensions/Vector/Vector.hooks.php |
— | — | @@ -0,0 +1,195 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Hooks for Vector extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class VectorHooks { |
| 11 | + |
| 12 | + /* Static Members */ |
| 13 | + |
| 14 | + static $modules = array( |
| 15 | + 'collapsiblenav' => array( |
| 16 | + 'name' => 'vector.collapsibleNav', |
| 17 | + 'resources' => array( |
| 18 | + 'scripts' => '', |
| 19 | + 'styles' => '', |
| 20 | + 'messages' => array( |
| 21 | + 'vector-collapsiblenav-more', |
| 22 | + ), |
| 23 | + ) |
| 24 | + 'preferences' => array( |
| 25 | + 'key' => 'vector-collapsiblenav', |
| 26 | + 'ui' => array( |
| 27 | + 'type' => 'toggle', |
| 28 | + 'label-message' => 'vector-collapsiblenav-preference', |
| 29 | + 'section' => 'rendering/advancedrendering', |
| 30 | + ), |
| 31 | + ), |
| 32 | + 'configurations' => array( |
| 33 | + 'wgCollapsibleNavBucketTest', |
| 34 | + 'wgCollapsibleNavForceNewVersion', |
| 35 | + ), |
| 36 | + ), |
| 37 | + 'collapsibletabs' => array( |
| 38 | + 'name' => 'vector.collapsibleTabs', |
| 39 | + 'resources' => array( |
| 40 | + 'scripts' => '', |
| 41 | + 'styles' => '', |
| 42 | + ) |
| 43 | + ), |
| 44 | + 'editwarning' => array( |
| 45 | + 'name' => 'vector.editWarning', |
| 46 | + 'resources' => array( |
| 47 | + 'scripts' => '', |
| 48 | + 'styles' => '', |
| 49 | + 'messages' => array( |
| 50 | + 'vector-editwarning-warning', |
| 51 | + ), |
| 52 | + ), |
| 53 | + 'preferences' => array( |
| 54 | + // Ideally this would be 'vector-editwarning' |
| 55 | + 'key' => 'useeditwarning', |
| 56 | + 'ui' => array( |
| 57 | + 'type' => 'toggle', |
| 58 | + 'label-message' => 'vector-editwarning-preference', |
| 59 | + 'section' => 'editing/advancedediting', |
| 60 | + ), |
| 61 | + ), |
| 62 | + ), |
| 63 | + 'expandablesearch' => array( |
| 64 | + 'name' => 'vector.expandableSearch', |
| 65 | + 'resources' => array( |
| 66 | + 'scripts' => '', |
| 67 | + 'styles' => '', |
| 68 | + ), |
| 69 | + 'preferences' => array( |
| 70 | + 'requirements' = array( 'vector-simplesearch', 'disablesuggest' ), |
| 71 | + ), |
| 72 | + ), |
| 73 | + 'footercleanup' => array( |
| 74 | + 'name' => 'vector.footerCleanup', |
| 75 | + 'resources' => array( |
| 76 | + 'scripts' => '', |
| 77 | + 'styles' => '', |
| 78 | + ), |
| 79 | + ), |
| 80 | + 'simplesearch' => array( |
| 81 | + 'name' => 'vector.simpleSearch', |
| 82 | + 'resources' => array( |
| 83 | + 'scripts' => '', |
| 84 | + 'styles' => '', |
| 85 | + 'messages' => array( |
| 86 | + 'vector-simplesearch-search', |
| 87 | + 'vector-simplesearch-containing', |
| 88 | + ), |
| 89 | + ), |
| 90 | + 'preferences' => array( |
| 91 | + 'requirements' = array( 'vector-simplesearch', 'disablesuggest' ), |
| 92 | + ), |
| 93 | + ), |
| 94 | + ); |
| 95 | + |
| 96 | + /* Protected Static Methods */ |
| 97 | + |
| 98 | + protected static isEnabled( $module ) { |
| 99 | + global $wgVectorModules, $wgUser; |
| 100 | + |
| 101 | + $enabled = |
| 102 | + $wgVectorModules[$module]['global'] || |
| 103 | + ( |
| 104 | + $wgVectorModules[$module]['user'] && |
| 105 | + isset( self::$modules[$module]['preferences']['key'] ) && |
| 106 | + $wgUser->getOption( self::$modules[$module]['preferences']['key'] |
| 107 | + ); |
| 108 | + if ( !$enabled ) { |
| 109 | + return false; |
| 110 | + } |
| 111 | + foreach ( self::$modules[$module]['preferences']['requirements'] as $requirement ) { |
| 112 | + if ( !$wgUser->getOption( $requirement ) ) { |
| 113 | + return false; |
| 114 | + } |
| 115 | + } |
| 116 | + return true; |
| 117 | + } |
| 118 | + |
| 119 | + /* Static Methods */ |
| 120 | + |
| 121 | + /** |
| 122 | + * BeforePageDisplay hook |
| 123 | + * |
| 124 | + * Adds the modules to the edit form |
| 125 | + * |
| 126 | + * @param $out OutputPage output page |
| 127 | + * @param $skin Skin current skin |
| 128 | + */ |
| 129 | + public static function beforePageDisplay( $out, $skin ) { |
| 130 | + global $wgVectorModules; |
| 131 | + |
| 132 | + // Don't load Vector modules for non-Vector skins |
| 133 | + if ( !( $skin instanceof SkinVector ) ) { |
| 134 | + return true; |
| 135 | + } |
| 136 | + |
| 137 | + // Add enabled modules |
| 138 | + foreach ( $wgVectorModules as $module => $enable ) { |
| 139 | + if ( self::isEnabled( $module ) ) { |
| 140 | + $out->addModules( self::$modules[$module]['name'] ); |
| 141 | + } |
| 142 | + } |
| 143 | + } |
| 144 | + |
| 145 | + /** |
| 146 | + * GetPreferences hook |
| 147 | + * |
| 148 | + * Adds Vector-releated items to the preferences |
| 149 | + * |
| 150 | + * @param $out User current user |
| 151 | + * @param $skin array list of default user preference controls |
| 152 | + */ |
| 153 | + public static function getPreferences( $user, &$defaultPreferences ) { |
| 154 | + global $wgVectorModules; |
| 155 | + |
| 156 | + foreach ( $wgVectorModules as $module => $enable ) { |
| 157 | + if ( $enable['user'] ) && isset( self::$modules['preferences'][$module]['ui'] ) ) { |
| 158 | + $defaultPreferences[self::$modules['preferences'][$module]['key']] = |
| 159 | + self::$modules['preferences'][$module]['ui']; |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + |
| 164 | + /** |
| 165 | + * MakeGlobalVariablesScript hook |
| 166 | + * |
| 167 | + * Adds enabled/disabled switches for Vector modules |
| 168 | + */ |
| 169 | + public static function makeGlobalVariablesScript( &$vars ) { |
| 170 | + $configurations = array(); |
| 171 | + foreach ( $wgVectorModules as $module => $enable ) { |
| 172 | + if ( |
| 173 | + isset( self::$modules[$module]['configurations'] ) && |
| 174 | + is_array( self::$modules[$module]['configurations'] ) |
| 175 | + ) { |
| 176 | + foreach ( self::$modules[$module]['configurations'] as $configuration ) { |
| 177 | + global $$configuration; |
| 178 | + $configurations[$configuration] = $$configuration; |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | + if ( count( $configurations ) ) { |
| 183 | + $vars = array_merge( $vars, $configurations ); |
| 184 | + } |
| 185 | + return true; |
| 186 | + } |
| 187 | + |
| 188 | + /* |
| 189 | + * ResourceLoaderRegisterModules hook |
| 190 | + * |
| 191 | + * Adds modules to ResourceLoader |
| 192 | + */ |
| 193 | + public static function resourceLoaderRegisterModules() { |
| 194 | + ResourceLoader::register( ); |
| 195 | + } |
| 196 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/Vector/Vector.hooks.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 197 | + native |