http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73353
Revision: 73353
Author: sergeychernyshev
Date: 2010-09-19 23:39:47 +0000 (Sun, 19 Sep 2010)
Log Message:
-----------
Some code structure changes and fix to a bug 25219
Added Paths:
-----------
tags/extensions/Widgets/REL_0_9_1/
tags/extensions/Widgets/REL_0_9_1/Widgets.php
tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
Removed Paths:
-------------
tags/extensions/Widgets/REL_0_9_1/Widgets.php
tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
Deleted: tags/extensions/Widgets/REL_0_9_1/Widgets.php
===================================================================
--- trunk/extensions/Widgets/Widgets.php 2010-09-19 22:42:40 UTC (rev
73346)
+++ tags/extensions/Widgets/REL_0_9_1/Widgets.php 2010-09-19 23:39:47 UTC
(rev 73353)
@@ -1,105 +0,0 @@
-<?php
-/**
- *
- * {{#widget:<WidgetName>|<name1>=<value1>|<name2>=<value2>}}
- *
- * @author Sergey Chernyshev
- * @version $Id: Widgets.php 15 2008-06-25 21:22:40Z sergey.chernyshev $
- */
-
-if ( !defined( 'MEDIAWIKI' ) ) {
- echo "This file is not a valid entry point.";
- exit( 1 );
-}
-
-$wgExtensionCredits['parserhook'][] = array(
- 'path' => __FILE__,
- 'name' => 'Widgets',
- 'descriptionmsg' => 'widgets-desc',
- 'version' => '0.9.1-dev',
- 'author' => '[http://www.sergeychernyshev.com Sergey Chernyshev]',
- 'url' => 'http://www.mediawiki.org/wiki/Extension:Widgets'
-);
-
-/**
- * Set this to the index of the Widget namespace
- */
-if ( !defined( 'NS_WIDGET' ) ) {
- define( 'NS_WIDGET', 274 );
-}
-if ( !defined( 'NS_WIDGET_TALK' ) ) {
- define( 'NS_WIDGET_TALK', NS_WIDGET + 1 );
-} elseif ( NS_WIDGET_TALK != NS_WIDGET + 1 ) {
- throw new MWException( 'Configuration error. Do not define NS_WIDGET_TALK,
it is automatically set based on NS_WIDGET.' );
-}
-
-// Define new namespaces
-$wgExtraNamespaces[NS_WIDGET] = 'Widget';
-$wgExtraNamespaces[NS_WIDGET_TALK] = 'Widget_talk';
-
-// Support subpages only for talk pages by default
-$wgNamespacesWithSubpages[NS_WIDGET_TALK] = true;
-
-// Define new right
-$wgAvailableRights[] = 'editwidgets';
-
-// Set this to true to use FlaggedRevs extension's stable version for widget
security
-$wgWidgetsUseFlaggedRevs = false;
-
-$dir = dirname( __FILE__ ) . '/';
-
-// Initialize Smarty
-require_once( $dir . 'smarty/Smarty.class.php' );
-$wgExtensionMessagesFiles['Widgets'] = $dir . 'Widgets.i18n.php';
-$wgAutoloadClasses['WidgetRenderer'] = $dir . 'WidgetRenderer.php';
-
-if( defined('MW_SUPPORTS_LOCALISATIONCACHE') ) {
- $wgExtensionMessagesFiles['WidgetsMagic'] = $dir .
'Widgets.i18n.magic.php';
-} else {
- // Pre 1.16alpha backward compatibility for magic words
- $wgHooks['LanguageGetMagic'][] = 'widgetLanguageGetMagic';
-}
-
-function widgetLanguageGetMagic( &$magicWords, $langCode = 'en' ) {
- switch ( $langCode ) {
- default:
- $magicWords['widget'] = array ( 0, 'widget' );
- }
- return true;
-}
-
-// Parser function registration
-$wgExtensionFunctions[] = 'widgetNamespacesInit';
-$wgHooks['ParserFirstCallInit'][] = 'widgetParserFunctions';
-$wgHooks['ParserAfterTidy'][] = 'processEncodedWidgetOutput';
-
-function widgetParserFunctions( &$parser ) {
- $parser->setFunctionHook( 'widget', array( 'WidgetRenderer',
'renderWidget' ) );
-
- return true;
-}
-
-function processEncodedWidgetOutput( &$out, &$text ) {
- // Find all hidden content and restore to normal
- $text = preg_replace(
- '/ENCODED_CONTENT ([0-9a-zA-Z\/+]+=*)* END_ENCODED_CONTENT/esm',
- 'base64_decode("$1")',
- $text
- );
-
- return true;
-}
-
-function widgetNamespacesInit() {
- global $wgGroupPermissions, $wgNamespaceProtection,
$wgWidgetsUseFlaggedRevs;
-
- if (!$wgWidgetsUseFlaggedRevs)
- {
- // Assign editing to widgeteditor group only (widgets can be
dangerous so we do it here, not in LocalSettings)
- $wgGroupPermissions['*']['editwidgets'] = false;
- $wgGroupPermissions['widgeteditor']['editwidgets'] = true;
-
- // Setting required namespace permission rights
- $wgNamespaceProtection[NS_WIDGET] = array( 'editwidgets' );
- }
-}
Copied: tags/extensions/Widgets/REL_0_9_1/Widgets.php (from rev 73352,
trunk/extensions/Widgets/Widgets.php)
===================================================================
--- tags/extensions/Widgets/REL_0_9_1/Widgets.php
(rev 0)
+++ tags/extensions/Widgets/REL_0_9_1/Widgets.php 2010-09-19 23:39:47 UTC
(rev 73353)
@@ -0,0 +1,105 @@
+<?php
+/**
+ *
+ * {{#widget:<WidgetName>|<name1>=<value1>|<name2>=<value2>}}
+ *
+ * @author Sergey Chernyshev
+ * @version $Id: Widgets.php 15 2008-06-25 21:22:40Z sergey.chernyshev $
+ */
+
+if ( !defined( 'MEDIAWIKI' ) ) {
+ echo "This file is not a valid entry point.";
+ exit( 1 );
+}
+
+$wgExtensionCredits['parserhook'][] = array(
+ 'path' => __FILE__,
+ 'name' => 'Widgets',
+ 'descriptionmsg' => 'widgets-desc',
+ 'version' => '0.9.1',
+ 'author' => '[http://www.sergeychernyshev.com Sergey Chernyshev]',
+ 'url' => 'http://www.mediawiki.org/wiki/Extension:Widgets'
+);
+
+/**
+ * Set this to the index of the Widget namespace
+ */
+if ( !defined( 'NS_WIDGET' ) ) {
+ define( 'NS_WIDGET', 274 );
+}
+if ( !defined( 'NS_WIDGET_TALK' ) ) {
+ define( 'NS_WIDGET_TALK', NS_WIDGET + 1 );
+} elseif ( NS_WIDGET_TALK != NS_WIDGET + 1 ) {
+ throw new MWException( 'Configuration error. Do not define NS_WIDGET_TALK,
it is automatically set based on NS_WIDGET.' );
+}
+
+// Define new namespaces
+$wgExtraNamespaces[NS_WIDGET] = 'Widget';
+$wgExtraNamespaces[NS_WIDGET_TALK] = 'Widget_talk';
+
+// Support subpages only for talk pages by default
+$wgNamespacesWithSubpages[NS_WIDGET_TALK] = true;
+
+// Define new right
+$wgAvailableRights[] = 'editwidgets';
+
+// Set this to true to use FlaggedRevs extension's stable version for widget
security
+$wgWidgetsUseFlaggedRevs = false;
+
+$dir = dirname( __FILE__ ) . '/';
+
+// Initialize Smarty
+require_once( $dir . 'smarty/Smarty.class.php' );
+$wgExtensionMessagesFiles['Widgets'] = $dir . 'Widgets.i18n.php';
+$wgAutoloadClasses['WidgetRenderer'] = $dir . 'WidgetRenderer.php';
+
+if( defined('MW_SUPPORTS_LOCALISATIONCACHE') ) {
+ $wgExtensionMessagesFiles['WidgetsMagic'] = $dir .
'Widgets.i18n.magic.php';
+} else {
+ // Pre 1.16alpha backward compatibility for magic words
+ $wgHooks['LanguageGetMagic'][] = 'widgetLanguageGetMagic';
+}
+
+function widgetLanguageGetMagic( &$magicWords, $langCode = 'en' ) {
+ switch ( $langCode ) {
+ default:
+ $magicWords['widget'] = array ( 0, 'widget' );
+ }
+ return true;
+}
+
+// Parser function registration
+$wgExtensionFunctions[] = 'widgetNamespacesInit';
+$wgHooks['ParserFirstCallInit'][] = 'widgetParserFunctions';
+$wgHooks['ParserAfterTidy'][] = 'processEncodedWidgetOutput';
+
+function widgetParserFunctions( &$parser ) {
+ $parser->setFunctionHook( 'widget', array( 'WidgetRenderer',
'renderWidget' ) );
+
+ return true;
+}
+
+function processEncodedWidgetOutput( &$out, &$text ) {
+ // Find all hidden content and restore to normal
+ $text = preg_replace(
+ '/ENCODED_CONTENT ([0-9a-zA-Z\/+]+=*)* END_ENCODED_CONTENT/esm',
+ 'base64_decode("$1")',
+ $text
+ );
+
+ return true;
+}
+
+function widgetNamespacesInit() {
+ global $wgGroupPermissions, $wgNamespaceProtection,
$wgWidgetsUseFlaggedRevs;
+
+ if (!$wgWidgetsUseFlaggedRevs)
+ {
+ // Assign editing to widgeteditor group only (widgets can be
dangerous so we do it here, not in LocalSettings)
+ $wgGroupPermissions['*']['editwidgets'] = false;
+ $wgGroupPermissions['widgeteditor']['editwidgets'] = true;
+
+ // Setting required namespace permission rights
+ $wgNamespaceProtection[NS_WIDGET] = array( 'editwidgets' );
+ }
+}
Deleted: tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
===================================================================
--- trunk/extensions/Widgets/smarty_plugins/modifier.validate.php
2010-09-19 22:42:40 UTC (rev 73346)
+++ tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
2010-09-19 23:39:47 UTC (rev 73353)
@@ -1,31 +0,0 @@
-<?php
-/*
- * Smarty plugin
- * -------------------------------------------------------------
- * File: modifier.validate.php
- * Type: modifier
- * Name: validate
- * Purpose: Validates parameter format ('url' by default).
- * Useful when you need to validate but not escape.
- * -------------------------------------------------------------
- */
-function smarty_modifier_validate($string, $type='url')
-{
- // mapping for PHP filters
(http://us2.php.net/manual/en/filter.constants.php)
- $filters = array(
- 'url' => FILTER_VALIDATE_URL,
- 'int' => FILTER_VALIDATE_INT,
- 'boolean' => FILTER_VALIDATE_BOOLEAN,
- 'float' => FILTER_VALIDATE_FLOAT,
- 'email' => FILTER_VALIDATE_EMAIL,
- 'ip' => FILTER_VALIDATE_IP
- );
-
- if (array_key_exists($type, $filters) && filter_var($string,
$filters[$type]))
- {
- return $string;
- }
-
- // unless it matched some validation rule, it's not valid
- return '';
-}
Copied: tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
(from rev 73350, trunk/extensions/Widgets/smarty_plugins/modifier.validate.php)
===================================================================
--- tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
(rev 0)
+++ tags/extensions/Widgets/REL_0_9_1/smarty_plugins/modifier.validate.php
2010-09-19 23:39:47 UTC (rev 73353)
@@ -0,0 +1,31 @@
+<?php
+/*
+ * Smarty plugin
+ * -------------------------------------------------------------
+ * File: modifier.validate.php
+ * Type: modifier
+ * Name: validate
+ * Purpose: Validates parameter format ('url' by default).
+ * Useful when you need to validate but not escape.
+ * -------------------------------------------------------------
+ */
+function smarty_modifier_validate($string, $type='url')
+{
+ // mapping for PHP filters
(http://us2.php.net/manual/en/filter.constants.php)
+ $filters = array(
+ 'url' => FILTER_VALIDATE_URL,
+ 'int' => FILTER_VALIDATE_INT,
+ 'boolean' => FILTER_VALIDATE_BOOLEAN,
+ 'float' => FILTER_VALIDATE_FLOAT,
+ 'email' => FILTER_VALIDATE_EMAIL,
+ 'ip' => FILTER_VALIDATE_IP
+ );
+
+ if (array_key_exists($type, $filters) && filter_var($string,
$filters[$type]) !== FALSE)
+ {
+ return $string;
+ }
+
+ // unless it matched some validation rule, it's not valid
+ return '';
+}
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs