[MediaWiki-commits] [Gerrit] Add option to disable CodeMirror frontend - change (mediawiki...CodeMirror)

2015-04-02 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Add option to disable CodeMirror frontend
..


Add option to disable CodeMirror frontend

So CodeMirror only provides it's libraries to use in other code.

Change-Id: I6832f4d82ae0497b92ba210ac7960052e4e12143
---
M CodeMirror.hooks.php
M CodeMirror.php
2 files changed, 21 insertions(+), 8 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php
index 5683ce7..cde1824 100644
--- a/CodeMirror.hooks.php
+++ b/CodeMirror.hooks.php
@@ -66,13 +66,16 @@
 * @return boolean
 */
private static function isCodeMirrorEnabled( IContextSource $context ) {
+   global $wgCodeMirrorEnableFrontend;
+
// Check, if we already checked, if page action is editing, if 
not, do it now
if ( is_null( self::$isEnabled ) ) {
// edit can be 'edit' and 'submit'
-   self::$isEnabled = in_array(
-   Action::getActionName( $context ),
-   array( 'edit', 'submit' )
-   );
+   self::$isEnabled = $wgCodeMirrorEnableFrontend 
+   in_array(
+   Action::getActionName( $context ),
+   array( 'edit', 'submit' )
+   );
}
 
return self::$isEnabled;
@@ -176,10 +179,12 @@
 * @return bool Always true
 */
public static function onGetPreferences( User $user, 
$defaultPreferences ) {
-   $defaultPreferences['usecodemirror'] = array(
-   'type' = 'api',
-   'default' = '1',
-   );
+   if ( self::isCodeMirrorEnabled( RequestContext::getMain() ) ) {
+   $defaultPreferences['usecodemirror'] = array(
+   'type' = 'api',
+   'default' = '1',
+   );
+   }
return true;
}
 }
diff --git a/CodeMirror.php b/CodeMirror.php
index 3e5d0f0..9e4b64e 100644
--- a/CodeMirror.php
+++ b/CodeMirror.php
@@ -71,3 +71,11 @@
'group' = 'ext.CodeMirror',
'targets' = array( 'mobile', 'desktop' ),
 );
+
+// Configuration options
+
+/**
+ * Specify, if CodeMirror extension should integrate CodeMirror in MediaWiki's 
editor (or WikiEditor), or if
+ * it should work as a library provider for other extensions.
+ */
+$wgCodeMirrorEnableFrontend = true;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6832f4d82ae0497b92ba210ac7960052e4e12143
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow florian.schmidt.wel...@t-online.de
Gerrit-Reviewer: Jdlrobson jrob...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Add option to disable CodeMirror frontend - change (mediawiki...CodeMirror)

2015-03-26 Thread Florianschmidtwelzow (Code Review)
Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/199941

Change subject: Add option to disable CodeMirror frontend
..

Add option to disable CodeMirror frontend

So CodeMirror only provides it's libraries to use in other code.

Change-Id: I6832f4d82ae0497b92ba210ac7960052e4e12143
---
M CodeMirror.hooks.php
M CodeMirror.php
2 files changed, 21 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CodeMirror 
refs/changes/41/199941/1

diff --git a/CodeMirror.hooks.php b/CodeMirror.hooks.php
index 5683ce7..cde1824 100644
--- a/CodeMirror.hooks.php
+++ b/CodeMirror.hooks.php
@@ -66,13 +66,16 @@
 * @return boolean
 */
private static function isCodeMirrorEnabled( IContextSource $context ) {
+   global $wgCodeMirrorEnableFrontend;
+
// Check, if we already checked, if page action is editing, if 
not, do it now
if ( is_null( self::$isEnabled ) ) {
// edit can be 'edit' and 'submit'
-   self::$isEnabled = in_array(
-   Action::getActionName( $context ),
-   array( 'edit', 'submit' )
-   );
+   self::$isEnabled = $wgCodeMirrorEnableFrontend 
+   in_array(
+   Action::getActionName( $context ),
+   array( 'edit', 'submit' )
+   );
}
 
return self::$isEnabled;
@@ -176,10 +179,12 @@
 * @return bool Always true
 */
public static function onGetPreferences( User $user, 
$defaultPreferences ) {
-   $defaultPreferences['usecodemirror'] = array(
-   'type' = 'api',
-   'default' = '1',
-   );
+   if ( self::isCodeMirrorEnabled( RequestContext::getMain() ) ) {
+   $defaultPreferences['usecodemirror'] = array(
+   'type' = 'api',
+   'default' = '1',
+   );
+   }
return true;
}
 }
diff --git a/CodeMirror.php b/CodeMirror.php
index 3e5d0f0..9e4b64e 100644
--- a/CodeMirror.php
+++ b/CodeMirror.php
@@ -71,3 +71,11 @@
'group' = 'ext.CodeMirror',
'targets' = array( 'mobile', 'desktop' ),
 );
+
+// Configuration options
+
+/**
+ * Specify, if CodeMirror extension should integrate CodeMirror in MediaWiki's 
editor (or WikiEditor), or if
+ * it should work as a library provider for other extensions.
+ */
+$wgCodeMirrorEnableFrontend = true;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6832f4d82ae0497b92ba210ac7960052e4e12143
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CodeMirror
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow florian.schmidt.wel...@t-online.de

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits