Index: trunk/extensions/EtherpadLite/EtherpadLite.php |
— | — | @@ -56,23 +56,23 @@ |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Credits |
60 | | -$wgExtensionCredits['other'][] = array( |
| 60 | +$wgExtensionCredits['parserhook'][] = array( |
61 | 61 | 'path' => __FILE__, |
62 | 62 | 'name' => 'EtherpadLite', |
63 | 63 | 'author' => array( 'Thomas Gries' ), |
64 | | - 'version' => '1.00 20120211', |
65 | | - 'url' => '//www.mediawiki.org/wiki/Extension:EtherpadLite', |
| 64 | + 'version' => '1.01 20120212', |
| 65 | + 'url' => 'https://www.mediawiki.org/wiki/Extension:EtherpadLite', |
66 | 66 | 'descriptionmsg' => 'etherpadlite-desc', |
67 | 67 | ); |
68 | 68 | |
69 | 69 | $dir = dirname( __FILE__ ) . '/'; |
70 | 70 | |
71 | 71 | $wgExtensionMessagesFiles['EtherpadLite'] = $dir . 'EtherpadLite.i18n.php'; |
72 | | -$wgHooks['ParserFirstCallInit'][] = 'efEtherpadLiteParser_Initialize'; |
| 72 | +$wgHooks['ParserFirstCallInit'][] = 'wfEtherpadLiteParserInit'; |
73 | 73 | |
74 | 74 | // https://www.mediawiki.org/wiki/Manual:Tag_extensions |
75 | | -function efEtherpadLiteParser_Initialize( &$parser ) { |
76 | | - $parser->setHook('eplite', 'efEtherpadLiteParserFunction_Render'); |
| 75 | +function wfEtherpadLiteParserInit( $parser ) { |
| 76 | + $parser->setHook('eplite', 'wfEtherpadLiteRender'); |
77 | 77 | return true; |
78 | 78 | } |
79 | 79 | |
— | — | @@ -80,38 +80,46 @@ |
81 | 81 | # this server is used unless a distinct server is defined by pad-id="..." |
82 | 82 | $wgEtherpadLiteDefaultPadUrl = "http://www.example.com/p/"; |
83 | 83 | $wgEtherpadLiteDefaultWidth = "300px"; |
84 | | -$wgEtherpadLiteDefaultHeigth = "200px"; |
85 | | -$wgEtherpadLiteMonospacedFont = 'false'; |
86 | | -$wgEtherpadLiteShowControls = 'true'; |
87 | | -$wgEtherpadLiteShowLineNumbers = 'true'; |
88 | | -$wgEtherpadLiteShowChat = 'true'; |
89 | | -$wgEtherpadLiteShowAuthorColors = 'true'; |
| 84 | +$wgEtherpadLiteDefaultHeight = "200px"; |
| 85 | +$wgEtherpadLiteMonospacedFont = false; |
| 86 | +$wgEtherpadLiteShowControls = true; |
| 87 | +$wgEtherpadLiteShowLineNumbers = true; |
| 88 | +$wgEtherpadLiteShowChat = true; |
| 89 | +$wgEtherpadLiteShowAuthorColors = true; |
90 | 90 | |
91 | | -function efEtherpadLiteParserFunction_Render( $input, $args, $parser, $frame ) { |
| 91 | +function wfEtherpadLiteTestAndReturnBoolean( $var, $default ) { |
| 92 | + # http://www.php.net/manual/en/function.is-bool.php#104643 |
| 93 | + return ( isset( $var ) ) ? filter_var( $var, FILTER_VALIDATE_BOOLEAN ) : $default; |
| 94 | +} |
92 | 95 | |
| 96 | +function wfEtherpadLiteRender( $input, $args, $parser, $frame ) { |
| 97 | + |
93 | 98 | global $wgUser; |
94 | 99 | global $wgEtherpadLiteDefaultPadUrl, $wgEtherpadLiteDefaultWidth, $wgEtherpadLiteDefaultHeight, |
95 | 100 | $wgEtherpadLiteMonospacedFont, $wgEtherpadLiteShowControls, $wgEtherpadLiteShowLineNumbers, |
96 | 101 | $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors; |
97 | 102 | |
98 | | - $padId = ( !empty( $args['pad-id'] ) ) ? $args['pad-id'] : "" ; |
99 | | - $height = ( !empty( $args['height'] ) ) ? $args['height'] : $wgEtherpadLiteDefaultHeight; |
100 | | - $width = ( !empty( $args['width'] ) ) ? $args['width'] : $wgEtherpadLiteDefaultWidth; |
| 103 | + $padId = ( isset( $args['pad-id'] ) ) ? $args['pad-id'] : "" ; |
| 104 | + $height = ( isset( $args['height'] ) ) ? $args['height'] : $wgEtherpadLiteDefaultHeight; |
| 105 | + $width = ( isset( $args['width'] ) ) ? $args['width'] : $wgEtherpadLiteDefaultWidth; |
101 | 106 | |
102 | | - $useMonospaceFont = ( !empty( $args['monospaced-font'] ) ) ? $args['monospaced-font'] : $wgEtherpadLiteMonospacedFont; |
103 | | - $showControls = ( !empty( $args['show-controls'] ) ) ? $args['show-controls'] : $wgEtherpadLiteShowControls; |
104 | | - $showLineNumbers = ( !empty( $args['show-linenumbers'] ) ) ? $args['show-linenumbers'] : $wgEtherpadLiteShowLineNumbers; |
105 | | - $showChat = ( !empty( $args['show-chat'] ) ) ? $args['show-chat'] : $wgEtherpadLiteShowChat; |
106 | | - $noColors = ! ( ( !empty( $args['show-colors'] ) ) ? $args['show-colors'] : $wgEtherpadLiteShowAuthorColors ); |
| 107 | + $useMonospaceFont = wfEtherpadLiteTestAndReturnBoolean( $args['monospaced-font'], $wgEtherpadLiteMonospacedFont ); |
| 108 | + $showControls = wfEtherpadLiteTestAndReturnBoolean( $args['show-controls'], $wgEtherpadLiteShowControls ) ; |
| 109 | + $showLineNumbers = wfEtherpadLiteTestAndReturnBoolean( $args['show-linenumbers'], $wgEtherpadLiteShowLineNumbers ); |
| 110 | + $showChat = wfEtherpadLiteTestAndReturnBoolean( $args['show-chat'], $wgEtherpadLiteShowChat ); |
| 111 | + $noColors = ! ( wfEtherpadLiteTestAndReturnBoolean( $args['show-colors'], $wgEtherpadLiteShowAuthorColors ) ); |
107 | 112 | |
108 | 113 | $epliteHostUrl = Sanitizer::cleanUrl ( |
109 | | - ( !empty( $args['pad-url'] ) ) ? $args['pad-url'] : $wgEtherpadLiteDefaultPadUrl |
| 114 | + ( isset( $args['pad-url'] ) ) ? $args['pad-url'] : $wgEtherpadLiteDefaultPadUrl |
110 | 115 | ); |
111 | 116 | |
112 | 117 | // preset the pad username from MediaWiki username or IP |
| 118 | + |
113 | 119 | // attention: |
114 | | - // the pad username can currently be overwritten when editing the pad |
| 120 | + // 1. we must render the page for each visiting user to get their username |
| 121 | + // 2. the pad username can currently be overwritten when editing the pad |
115 | 122 | |
| 123 | + $parser->disableCache(); |
116 | 124 | $userName = $wgUser->getName(); |
117 | 125 | |
118 | 126 | $iframeAttributes = array( |
— | — | @@ -128,6 +136,6 @@ |
129 | 137 | |
130 | 138 | $output = Html::rawElement( 'iframe', $iframeAttributes ); |
131 | 139 | |
132 | | - wfDebug( "EtherpadLite:efEtherpadLiteParserFunction_Render $output\n" ); |
133 | | - return array( $output, 'noparse' => true, 'isHTML' => true ); |
| 140 | + wfDebug( "EtherpadLite:wfEtherpadLiteRender $output\n" ); |
| 141 | + return array( $output ); |
134 | 142 | } |