Index: trunk/extensions/EtherpadLite/EtherpadLite.php |
— | — | @@ -0,0 +1,135 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * EtherpadLite extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + * |
| 9 | + * The extension adds a tag "eplite" to the MediaWiki parser and |
| 10 | + * provides a method to embed Etherpad Lite pads on MediaWiki pages. |
| 11 | + * The Etherpad Lite server is not part of the extension. |
| 12 | + * |
| 13 | + * Usage: |
| 14 | + * |
| 15 | + * <eplite pad-id="padid" /> |
| 16 | + * <eplite pad-id="myPseudoSecretPadHash-7ujHvhq06g" /> |
| 17 | + * <eplite pad-id="padid" height="200px" width="600px" /> |
| 18 | + * |
| 19 | + * Installation: |
| 20 | + * |
| 21 | + * Add the following lines in LocalSettings.php: |
| 22 | + * |
| 23 | + * require_once( "$IP/extensions/EtherpadLite/EtherpadLite.php" ); |
| 24 | + * $wgEtherpadLiteDefaultPadUrl = "http://www.your-pad-server.org/p/"; |
| 25 | + * $wgEtherpadLiteDefaultWidth = "600px"; |
| 26 | + * $wgEtherpadLiteDefaultHeigth = "400px"; |
| 27 | + * |
| 28 | + * Prerequisite: |
| 29 | + * |
| 30 | + * Etherpad Lite host server (example) |
| 31 | + * $wgEtherpadLiteDefaultPadUrl = "http://www.example.com/p/"; |
| 32 | + * |
| 33 | + * For setting up your own Etherpad Lite server (based on node.js) see |
| 34 | + * Etherpad Lite homepage https://github.com/Pita/etherpad-lite |
| 35 | + * |
| 36 | + * This extension is based on: |
| 37 | + * |
| 38 | + * https://github.com/johnyma22/etherpad-lite-jquery-plugin |
| 39 | + * https://github.com/Pita/etherpad-lite/wiki/Embed-Parameters |
| 40 | + * |
| 41 | + * The present MediaWiki extension does not require jquery. It adds an iframe. |
| 42 | + * |
| 43 | + * @author Thomas Gries |
| 44 | + * @license GPL v2 |
| 45 | + * @license MIT |
| 46 | + * |
| 47 | + * Dual licensed under the MIT and GPL licenses: |
| 48 | + * http://www.opensource.org/licenses/mit-license.php |
| 49 | + * http://www.gnu.org/licenses/gpl.html |
| 50 | + * |
| 51 | + */ |
| 52 | + |
| 53 | +// Check environment |
| 54 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 55 | + echo( "This is an extension to MediaWiki and cannot be run standalone.\n" ); |
| 56 | + die( - 1 ); |
| 57 | +} |
| 58 | + |
| 59 | +// Credits |
| 60 | +$wgExtensionCredits['other'][] = array( |
| 61 | + 'path' => __FILE__, |
| 62 | + 'name' => 'EtherpadLite', |
| 63 | + 'author' => array( 'Thomas Gries' ), |
| 64 | + 'version' => '1.00 20120211', |
| 65 | + 'url' => '//www.mediawiki.org/wiki/Extension:EtherpadLite', |
| 66 | + 'descriptionmsg' => 'etherpadlite-desc', |
| 67 | +); |
| 68 | + |
| 69 | +$dir = dirname( __FILE__ ) . '/'; |
| 70 | + |
| 71 | +$wgExtensionMessagesFiles['EtherpadLite'] = $dir . 'EtherpadLite.i18n.php'; |
| 72 | +$wgHooks['ParserFirstCallInit'][] = 'efEtherpadLiteParser_Initialize'; |
| 73 | + |
| 74 | +// https://www.mediawiki.org/wiki/Manual:Tag_extensions |
| 75 | +function efEtherpadLiteParser_Initialize( &$parser ) { |
| 76 | + $parser->setHook('eplite', 'efEtherpadLiteParserFunction_Render'); |
| 77 | + return true; |
| 78 | +} |
| 79 | + |
| 80 | +# Define a default Etherpad Lite server Url and base path |
| 81 | +# this server is used unless a distinct server is defined by pad-id="..." |
| 82 | +$wgEtherpadLiteDefaultPadUrl = "http://www.example.com/p/"; |
| 83 | +$wgEtherpadLiteDefaultWidth = "300px"; |
| 84 | +$wgEtherpadLiteDefaultHeigth = "200px"; |
| 85 | +$wgEtherpadLiteMonospacedFont = 'false'; |
| 86 | +$wgEtherpadLiteShowControls = 'true'; |
| 87 | +$wgEtherpadLiteShowLineNumbers = 'true'; |
| 88 | +$wgEtherpadLiteShowChat = 'true'; |
| 89 | +$wgEtherpadLiteShowAuthorColors = 'true'; |
| 90 | + |
| 91 | +function efEtherpadLiteParserFunction_Render( $input, $args, $parser, $frame ) { |
| 92 | + |
| 93 | + global $wgUser; |
| 94 | + global $wgEtherpadLiteDefaultPadUrl,$wgEtherpadLiteDefaultWidth, |
| 95 | + $wgEtherpadLiteDefaultHeigth,$wgEtherpadLiteMonospacedFont,$wgEtherpadLiteShowControls, |
| 96 | + $wgEtherpadLiteShowLineNumbers,$wgEtherpadLiteShowChat,$wgEtherpadLiteUserName, |
| 97 | + $wgEtherpadLiteShowAuthorColors; |
| 98 | + |
| 99 | + $padId = ( !empty( $args['pad-id'] ) ) ? $args['pad-id'] : "" ; |
| 100 | + $height = ( !empty( $args['height'] ) ) ? $args['height'] : $wgEtherpadLiteDefaultHeight; |
| 101 | + $width = ( !empty( $args['width'] ) ) ? $args['width'] : $wgEtherpadLiteDefaultWidth; |
| 102 | + |
| 103 | + $useMonospaceFont = ( !empty( $args['monospaced-font'] ) ) ? $args['monospaced-font'] : $wgEtherpadLiteMonospacedFont; |
| 104 | + $showControls = ( !empty( $args['show-controls'] ) ) ? $args['show-controls'] : $wgEtherpadLiteShowControls; |
| 105 | + $showLineNumbers = ( !empty( $args['show-linenumbers'] ) ) ? $args['show-linenumbers'] : $wgEtherpadLiteShowLineNumbers; |
| 106 | + $showChat = ( !empty( $args['show-chat'] ) ) ? $args['show-chat'] : $wgEtherpadLiteShowChat; |
| 107 | + $noColors = ! ( ( !empty( $args['show-colors'] ) ) ? $args['show-colors'] : $wgEtherpadLiteShowAuthorColors ); |
| 108 | + |
| 109 | + $epliteHostUrl = Sanitizer::cleanUrl ( |
| 110 | + ( !empty( $args['pad-url'] ) ) ? $args['pad-url'] : $wgEtherpadLiteDefaultPadUrl |
| 111 | + ); |
| 112 | + |
| 113 | + // preset the pad username from MediaWiki username or IP |
| 114 | + // attention: |
| 115 | + // the pad username can currently be overwritten when editing the pad |
| 116 | + |
| 117 | + $userName = $wgUser->getName(); |
| 118 | + |
| 119 | + $iframeAttributes = array( |
| 120 | + "style" => "width:$width;height:$height", |
| 121 | + "id" => "epframe$padId", |
| 122 | + "src" => "$epliteHostUrl/$padId" . |
| 123 | + "?showControls=$showControls" . |
| 124 | + "&showChat=$showChat" . |
| 125 | + "&showLineNumbers=$showLineNumbers" . |
| 126 | + "&useMonospaceFont=$useMonospaceFont" . |
| 127 | + "&userName=$userName" . |
| 128 | + "&noColors=$noColors" |
| 129 | + ); |
| 130 | + |
| 131 | + $output = Html::rawElement( 'iframe', $iframeAttributes ); |
| 132 | + |
| 133 | + wfDebug( "EtherpadLite:efEtherpadLiteParserFunction_Render $output\n" ); |
| 134 | + return array( $output, 'noparse' => true, 'isHTML' => true ); |
| 135 | + |
| 136 | +} |
Property changes on: trunk/extensions/EtherpadLite/EtherpadLite.php |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 137 | + text/x-php |
Added: svn:keywords |
2 | 138 | + Author Date Id Rev URL |
Added: svn:eol-style |
3 | 139 | + native |
Index: trunk/extensions/EtherpadLite/EtherpadLite.i18n.php |
— | — | @@ -0,0 +1,16 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Internationalisation file for extension EtherpadLite |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$messages = array(); |
| 11 | + |
| 12 | +/** English |
| 13 | + * @author Thomas Gries |
| 14 | + */ |
| 15 | +$messages['en'] = array( |
| 16 | + 'etherpadlite-desc' => 'Provides a method to embed one or many Etherpad Lite pads (which are hosted on local or external Etherpad Lite server/s) on MediaWiki pages. It adds an <eplite> parser tag.', |
| 17 | +); |
Property changes on: trunk/extensions/EtherpadLite/EtherpadLite.i18n.php |
___________________________________________________________________ |
Added: svn:mime-type |
1 | 18 | + text/x-php |
Added: svn:keywords |
2 | 19 | + Author Date Id Rev URL |
Added: svn:eol-style |
3 | 20 | + native |