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

Revision: 56227
Author:   raymond
Date:     2009-09-12 11:36:19 +0000 (Sat, 12 Sep 2009)

Log Message:
-----------
Run code through stylize.php
Update extension credits
Add i18n file
Add extension to translatewiki.net

Modified Paths:
--------------
    trunk/extensions/ConditionalShowSection/ConditionalShowSection.php
    trunk/extensions/Translate/groups/mediawiki-defines.txt

Added Paths:
-----------
    trunk/extensions/ConditionalShowSection/ConditionalShowSection.i18n.php

Added: trunk/extensions/ConditionalShowSection/ConditionalShowSection.i18n.php
===================================================================
--- trunk/extensions/ConditionalShowSection/ConditionalShowSection.i18n.php     
                        (rev 0)
+++ trunk/extensions/ConditionalShowSection/ConditionalShowSection.i18n.php     
2009-09-12 11:36:19 UTC (rev 56227)
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Internationalization for ConditionalShowSection extension
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author Jean-Lou Dupont
+ */
+$messages['en'] = array(
+       'conditionalshowsection-desc' => 'Adding the <cshow> tag to 
conditionally show/hide a section of wikitext',
+);
+


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

Modified: trunk/extensions/ConditionalShowSection/ConditionalShowSection.php
===================================================================
--- trunk/extensions/ConditionalShowSection/ConditionalShowSection.php  
2009-09-12 10:49:24 UTC (rev 56226)
+++ trunk/extensions/ConditionalShowSection/ConditionalShowSection.php  
2009-09-12 11:36:19 UTC (rev 56227)
@@ -1,16 +1,16 @@
 <?php
-/*
+/**
  * ConditionalShowSection MediaWiki extension
  *
  * @author Jean-Lou Dupont
  * @package MediaWiki
  * @subpackage Extensions
- * @licence GNU General Public Licence 2.0
+ * @license GNU General Public Licence 2.0
  * This extension enables to conditionally show/hide a section
  * of wikitext that appears between the <cshow> </cshow> tags.
  *
  * Add to LocalSettings.php
- * with: 
require_once("extensions/ConditionalShowSection/ConditionalShowSection.php");
+ * with: require_once( 
"$IP/extensions/conditionalshowsection/conditionalshowsection.php" );
  *
  * HISTORY:
  * 1.1: corrected bug when "ingroup" option not present, wrong results.
@@ -20,14 +20,18 @@
  *      to the implicit '*' group and the default group for logged users 
'user'.
  * 1.5: Allow to check multiple groups - separated by ","
  */
-$wgExtensionCredits['other'][] = array(
-       'name'   => "ConditionalShowSection [http://www.bluecortex.com]";,
-       'url'    => 'http://www.mediawiki.org/wiki/Extension:ConditionalShow',
-       'version'=> '1.5',
-       'author' => 'Jean-Lou Dupont [http://www.bluecortex.com]' 
+$wgExtensionCredits['parserhook'][] = array(
+       'path' => __FILE__,
+       'name' => 'ConditionalShowSection',
+       'url' => 'http://www.mediawiki.org/wiki/Extension:ConditionalShow',
+       'version' => '1.5',
+       'author' => '[http://www.bluecortex.com Jean-Lou Dupont]',
+       'descriptionmsg' => 'conditionalshowsection-desc',
 );
- 
 
+$dir = dirname( __FILE__ ) . '/';
+$wgExtensionMessagesFiles['ConditionalShowSection'] = $dir . 
'ConditionalShowSection.i18n.php';
+
 if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
        $wgHooks['ParserFirstCallInit'][] = 'wfConditionalShowSection';
 } else { // Otherwise do things the old fashioned way
@@ -39,62 +43,61 @@
     $wgParser->setHook( "cshow", "ConditionalShowSection" );
     return true;
 }
- 
+
 function ConditionalShowSection( $input, $argv, &$parser ) {
-    #
-    # By default, the section is HIDDEN unless the following conditions are 
met:
-    # Argument: Logged = '1' or '0'  
-    # Argument: InGroup = 'group XYZ'
-    #
-    # If no arguments are provided for:
-    # - Logged   --> assume 'don't care' 
-    # - InGroup  --> assume ''           (no group)
        #
+       # By default, the section is HIDDEN unless the following conditions are 
met:
+       # Argument: Logged = '1' or '0'  
+       # Argument: InGroup = 'group XYZ'
+       #
+       # If no arguments are provided for:
+       # - Logged   --> assume 'don't care' 
+       # - InGroup  --> assume ''           (no group)
+       #
        # In other words, if no 'ingroup' parameter is given,
        # then the condition 'ingroup' is never met.
-    #
+       #
        # If no "logged" parameter is given, then this condition is always met.
-    # 
-    # Examples: <cshow Logged="1" InGroup="sysop"> text to show upon 
conditions met </cshow>
-    # if the user viewing the page is LOGGED and part of the SYSOP group then 
show the section.
        #
+       # Examples: <cshow Logged="1" InGroup="sysop"> text to show upon 
conditions met </cshow>
+       # if the user viewing the page is LOGGED and part of the SYSOP group 
then show the section.
+       #
        # <cshow ingroup='user'> Test </cshow>
        # shows 'Test' if the user viewing the page is logged and by default 
part of the 'user' group. 
-    #
+       #
        global $wgUser;
- 
+
        $userReqLogged = null;   # default is "don't care"
        $userReqGroup  = "" ;    # assuming no group membership required
        $output = "";            # assuming the section is hidden by default.
 
-       $cond1 = false;                  
-       $cond2 = false;                  # by default, don't show the section 
to just anybody
-     
+       $cond1 = false;
+       $cond2 = false;          # by default, don't show the section to just 
anybody
+
        # Extract the parameters passed
        # the parser lowers the case of all the parameters passed...
-       if (isset($argv["logged"]))
+       if ( isset( $argv["logged"] ) )
        {
                $userReqLogged = $argv["logged"];
+
+               if ( $userReqLogged === "1" && ( $wgUser->isLoggedIn() === true 
) )
+                       $cond1 = true;
  
-               if ($userReqLogged==="1" && ($wgUser->isLoggedIn()===true)) 
-                       $cond1=true;
- 
-               if ($userReqLogged==="0" && ($wgUser->isLoggedIn()===false))
-                       $cond1=true;
-       } else $cond1=true;
-       if (isset($argv["ingroup"]))
+               if ( $userReqLogged === "0" && ( $wgUser->isLoggedIn() === 
false ) )
+                       $cond1 = true;
+       } else $cond1 = true;
+       if ( isset( $argv["ingroup"] ) )
        {
-               $userReqGroup  = explode(',',$argv["ingroup"]);
+               $userReqGroup  = explode( ',', $argv["ingroup"] );
                # which groups is the user part of?
                $ugroups = $wgUser->getEffectiveGroups();  // changed in v1.4
-               if(array_intersect($userReqGroup,$ugroups))
-                       $cond2=true;
-       } else $cond1=true;
+               if ( array_intersect( $userReqGroup, $ugroups ) )
+                       $cond2 = true;
+       } else $cond1 = true;
        # if both conditions are met, then SHOW else HIDE
-       if (($cond1===true) and ($cond2===true)){
-               $output=$parser->recursiveTagParse($input);
+       if ( ( $cond1 === true ) and ( $cond2 === true ) ) {
+               $output = $parser->recursiveTagParse( $input );
        }
- 
+
        return $output;
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: trunk/extensions/Translate/groups/mediawiki-defines.txt
===================================================================
--- trunk/extensions/Translate/groups/mediawiki-defines.txt     2009-09-12 
10:49:24 UTC (rev 56226)
+++ trunk/extensions/Translate/groups/mediawiki-defines.txt     2009-09-12 
11:36:19 UTC (rev 56227)
@@ -195,6 +195,8 @@
 Community Voice
 aliasfile = CommunityVoice/CommunityVoice.alias.php
 
+Conditional Show Section
+
 Configure
 aliasfile = Configure/Configure.alias.php
 optional = configure-section-html, configure-section-ajax



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

Reply via email to