summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/WikiEditor.hooks.php
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/WikiEditor.hooks.php')
-rw-r--r--extensions/WikiEditor/WikiEditor.hooks.php61
1 files changed, 34 insertions, 27 deletions
diff --git a/extensions/WikiEditor/WikiEditor.hooks.php b/extensions/WikiEditor/WikiEditor.hooks.php
index 1a8a251f..7a2c2e41 100644
--- a/extensions/WikiEditor/WikiEditor.hooks.php
+++ b/extensions/WikiEditor/WikiEditor.hooks.php
@@ -1,19 +1,19 @@
<?php
/**
* Hooks for WikiEditor extension
- *
+ *
* @file
* @ingroup Extensions
*/
class WikiEditorHooks {
-
+
/* Protected Static Members */
-
+
protected static $features = array(
-
+
/* Beta Features */
-
+
'toolbar' => array(
'preferences' => array(
// Ideally this key would be 'wikieditor-toolbar'
@@ -63,9 +63,9 @@ class WikiEditorHooks {
'ext.wikiEditor.toolbar.hideSig',
),
),
-
+
/* Labs Features */
-
+
'templateEditor' => array(
'preferences' => array(
'wikieditor-template-editor' => array(
@@ -158,20 +158,21 @@ class WikiEditorHooks {
),
),
);
-
+
/* Static Methods */
-
+
/**
* Checks if a certain option is enabled
*
* This method is public to allow other extensions that use WikiEditor to use the
* same configuration as WikiEditor itself
*
- * @param $name Name of the feature, should be a key of $features
+ * @param $name string Name of the feature, should be a key of $features
+ * @return bool
*/
public static function isEnabled( $name ) {
global $wgWikiEditorFeatures, $wgUser;
-
+
// Features with global set to true are always enabled
if ( !isset( $wgWikiEditorFeatures[$name] ) || $wgWikiEditorFeatures[$name]['global'] ) {
return true;
@@ -188,20 +189,21 @@ class WikiEditorHooks {
}
return true;
}
- // Features controlled by $wgWikiEditorFeatures with both global and user set to false are awlways disabled
+ // Features controlled by $wgWikiEditorFeatures with both global and user set to false are awlways disabled
return false;
}
-
+
/**
* EditPage::showEditForm:initial hook
- *
+ *
* Adds the modules to the edit form
- *
+ *
* @param $toolbar array list of toolbar items
+ * @return bool
*/
public static function editPageShowEditFormInitial( &$toolbar ) {
global $wgOut;
-
+
// Add modules for enabled features
foreach ( self::$features as $name => $feature ) {
if ( isset( $feature['modules'] ) && self::isEnabled( $name ) ) {
@@ -210,18 +212,19 @@ class WikiEditorHooks {
}
return true;
}
-
+
/**
* GetPreferences hook
- *
+ *
* Adds WikiEditor-releated items to the preferences
- *
+ *
* @param $user User current user
* @param $defaultPreferences array list of default user preference controls
+ * @return bool
*/
public static function getPreferences( $user, &$defaultPreferences ) {
global $wgWikiEditorFeatures;
-
+
foreach ( self::$features as $name => $feature ) {
if (
isset( $feature['preferences'] ) &&
@@ -234,15 +237,17 @@ class WikiEditorHooks {
}
return true;
}
-
+
/**
* MakeGlobalVariablesScript hook
- *
+ *
* Adds enabled/disabled switches for WikiEditor modules
+ * @param $vars array
+ * @return bool
*/
public static function resourceLoaderGetConfigVars( &$vars ) {
global $wgWikiEditorFeatures;
-
+
$configurations = array();
foreach ( self::$features as $name => $feature ) {
if (
@@ -260,16 +265,18 @@ class WikiEditorHooks {
}
return true;
}
-
+
+ /**
+ * @param $vars array
+ * @return bool
+ */
public static function makeGlobalVariablesScript( &$vars ) {
- global $wgWikiEditorFeatures;
-
// Build and export old-style wgWikiEditorEnabledModules object for back compat
$enabledModules = array();
foreach ( self::$features as $name => $feature ) {
$enabledModules[$name] = self::isEnabled( $name );
}
-
+
$vars['wgWikiEditorEnabledModules'] = $enabledModules;
return true;
}