r111284 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111283‎ | r111284 | r111285 >
Date:07:42, 12 February 2012
Author:wikinaut
Status:deferred (Comments)
Tags:
Comment:
first follow-up r111263 . fixing issue 1 &, 2 empty, 4 'true', 7 (same padid=no problem), 8 fresh username, 10 parser tag hook return, 11 credits parserhook and a typo heigth height
Modified paths:
  • /trunk/extensions/EtherpadLite/EtherpadLite.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EtherpadLite/EtherpadLite.php
@@ -56,23 +56,23 @@
5757 }
5858
5959 // Credits
60 -$wgExtensionCredits['other'][] = array(
 60+$wgExtensionCredits['parserhook'][] = array(
6161 'path' => __FILE__,
6262 'name' => 'EtherpadLite',
6363 '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',
6666 'descriptionmsg' => 'etherpadlite-desc',
6767 );
6868
6969 $dir = dirname( __FILE__ ) . '/';
7070
7171 $wgExtensionMessagesFiles['EtherpadLite'] = $dir . 'EtherpadLite.i18n.php';
72 -$wgHooks['ParserFirstCallInit'][] = 'efEtherpadLiteParser_Initialize';
 72+$wgHooks['ParserFirstCallInit'][] = 'wfEtherpadLiteParserInit';
7373
7474 // 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');
7777 return true;
7878 }
7979
@@ -80,38 +80,46 @@
8181 # this server is used unless a distinct server is defined by pad-id="..."
8282 $wgEtherpadLiteDefaultPadUrl = "http://www.example.com/p/";
8383 $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;
9090
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+}
9295
 96+function wfEtherpadLiteRender( $input, $args, $parser, $frame ) {
 97+
9398 global $wgUser;
9499 global $wgEtherpadLiteDefaultPadUrl, $wgEtherpadLiteDefaultWidth, $wgEtherpadLiteDefaultHeight,
95100 $wgEtherpadLiteMonospacedFont, $wgEtherpadLiteShowControls, $wgEtherpadLiteShowLineNumbers,
96101 $wgEtherpadLiteShowChat, $wgEtherpadLiteShowAuthorColors;
97102
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;
101106
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 ) );
107112
108113 $epliteHostUrl = Sanitizer::cleanUrl (
109 - ( !empty( $args['pad-url'] ) ) ? $args['pad-url'] : $wgEtherpadLiteDefaultPadUrl
 114+ ( isset( $args['pad-url'] ) ) ? $args['pad-url'] : $wgEtherpadLiteDefaultPadUrl
110115 );
111116
112117 // preset the pad username from MediaWiki username or IP
 118+
113119 // 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
115122
 123+ $parser->disableCache();
116124 $userName = $wgUser->getName();
117125
118126 $iframeAttributes = array(
@@ -128,6 +136,6 @@
129137
130138 $output = Html::rawElement( 'iframe', $iframeAttributes );
131139
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 );
134142 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r111285follow-up r111284 r111263 . wfEtherpadLiteStringFromTestedBoolean now returns...wikinaut08:03, 12 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111263initial import of new extension EtherpadLitewikinaut21:33, 11 February 2012

Comments

#Comment by Wikinaut (talk | contribs)   07:49, 12 February 2012

oops, I forgot the convert the booleans to strings in the src attribute. Follows in next commit

Status & tagging log