r111872 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111871‎ | r111872 | r111873 >
Date:17:06, 19 February 2012
Author:yaron
Status:deferred
Tags:
Comment:
Changed name and ID of free text input from 'free_text' to 'sf_free_text', to minimize the chance of a collision with a section header, if FCKeditor is being used
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -359,8 +359,8 @@
360360 $original_page_content = $existing_page_content;
361361 } else {
362362 $original_page_content = null;
363 - if ( $wgRequest->getCheck( 'free_text' ) ) {
364 - $existing_page_content = $wgRequest->getVal( 'free_text' );
 363+ if ( $wgRequest->getCheck( 'sf_free_text' ) ) {
 364+ $existing_page_content = $wgRequest->getVal( 'sf_free_text' );
365365 $form_is_partial = true;
366366 }
367367 }
@@ -951,7 +951,7 @@
952952 // the page, using <free_text> tags - once all the free text
953953 // is known (at the end), it will get substituted in.
954954 if ( $is_hidden ) {
955 - $new_text = Html::hidden( 'free_text', '!free_text!' );
 955+ $new_text = Html::hidden( 'sf_free_text', '!free_text!' );
956956 } else {
957957 $sfgTabIndex++;
958958 $sfgFieldNum++;
@@ -970,7 +970,7 @@
971971 }
972972 }
973973 }
974 - $new_text = SFTextAreaInput::getHTML( $default_value, 'free_text', false, ( $form_is_disabled || $is_restricted ), $field_args );
 974+ $new_text = SFTextAreaInput::getHTML( $default_value, 'sf_free_text', false, ( $form_is_disabled || $is_restricted ), $field_args );
975975 if ( in_array( 'edittools', $free_text_components ) ) {
976976 // borrowed from EditPage::showEditTools()
977977 $options[] = 'parse';
@@ -1228,7 +1228,7 @@
12291229 // reason don't submit their value.
12301230 if ( $form_field->isDisabled() ) {
12311231 if ( $field_name == 'free text' || $field_name == '<freetext>' ) {
1232 - $new_text .= Html::hidden( 'free_text', '!free_text!' );
 1232+ $new_text .= Html::hidden( 'sf_free_text', '!free_text!' );
12331233 } else {
12341234 $new_text .= Html::hidden( $input_name, $cur_value );
12351235 }
@@ -1463,7 +1463,7 @@
14641464 // if it wasn't included in the form definition, add the
14651465 // 'free text' input as a hidden field at the bottom
14661466 if ( ! $free_text_was_included ) {
1467 - $form_text .= Html::hidden( 'free_text', '!free_text!' );
 1467+ $form_text .= Html::hidden( 'sf_free_text', '!free_text!' );
14681468 }
14691469 // Get free text, and add to page data, as well as retroactively
14701470 // inserting it into the form.
@@ -1487,8 +1487,8 @@
14881488 // page hasn't already been inserted into the form
14891489 $free_text = trim( $existing_page_content );
14901490 // or get it from a form submission
1491 - } elseif ( $wgRequest->getCheck( 'free_text' ) ) {
1492 - $free_text = $wgRequest->getVal( 'free_text' );
 1491+ } elseif ( $wgRequest->getCheck( 'sf_free_text' ) ) {
 1492+ $free_text = $wgRequest->getVal( 'sf_free_text' );
14931493 if ( ! $free_text_was_included ) {
14941494 $data_text .= "!free_text!";
14951495 }
Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -443,7 +443,7 @@
444444 }
445445
446446 $javascript_text .= <<<END
447 -var oFCKeditor = new FCKeditor( "free_text" );
 447+var oFCKeditor = new FCKeditor( "sf_free_text" );
448448
449449 //Set config
450450 oFCKeditor.BasePath = '$wgScriptPath/$wgFCKEditorDir';
@@ -478,7 +478,7 @@
479479 return y;
480480 }
481481 function getWindowHeight4editor() {
482 - var fsize = getFontSize('free_text');
 482+ var fsize = getFontSize('sf_free_text');
483483 // if value was not determined, return default val from $wgFCKEditorHeight
484484 if (!fsize) return $FCKEditorHeight;
485485 if (fsize.indexOf('px') == -1) // we didn't get pixels
@@ -495,7 +495,7 @@
496496 if (!(showFCKEditor & RTE_VISIBLE))
497497 showFCKEditor += RTE_VISIBLE;
498498 firstLoad = false;
499 - realTextarea = document.getElementById('free_text');
 499+ realTextarea = document.getElementById('sf_free_text');
500500 if ( realTextarea )
501501 {
502502 // Create the editor instance and replace the textarea.
@@ -522,7 +522,7 @@
523523 // if we have FCK enabled, behave differently...
524524 if ( showFCKEditor & RTE_VISIBLE )
525525 {
526 - SRCiframe = oDoc.getElementById ('free_text___Frame') ;
 526+ SRCiframe = oDoc.getElementById ('sf_free_text___Frame') ;
527527 if ( SRCiframe )
528528 {
529529 if (window.frames[SRCiframe])
@@ -545,7 +545,7 @@
546546 }
547547 else
548548 {
549 - txtarea = oDoc.editform.free_text ;
 549+ txtarea = oDoc.editform.sf_free_text ;
550550 }
551551 }
552552 else
@@ -642,24 +642,24 @@
643643 }
644644 function initEditor()
645645 {
646 - var toolbar = document.getElementById('free_text');
 646+ var toolbar = document.getElementById('sf_free_text');
647647 //show popup or toogle link
648648 if (showFCKEditor & (RTE_POPUP|RTE_TOGGLE_LINK)){
649649 var fckTools = document.createElement('div');
650650 fckTools.setAttribute('id', 'fckTools');
651651
652 - var SRCtextarea = document.getElementById( "free_text" ) ;
 652+ var SRCtextarea = document.getElementById( "sf_free_text" ) ;
653653 if (showFCKEditor & RTE_VISIBLE) SRCtextarea.style.display = "none";
654654 }
655655
656656 if (showFCKEditor & RTE_TOGGLE_LINK)
657657 {
658 - fckTools.innerHTML='[<a class="fckToogle" id="toggle_free_text" href="javascript:void(0)" onclick="ToggleFCKEditor(\'toggle\',\'free_text\')">'+ editorLink +'</a>] ';
 658+ fckTools.innerHTML='[<a class="fckToogle" id="toggle_sf_free_text" href="javascript:void(0)" onclick="ToggleFCKEditor(\'toggle\',\'sf_free_text\')">'+ editorLink +'</a>] ';
659659 }
660660 if (showFCKEditor & RTE_POPUP)
661661 {
662662 var style = (showFCKEditor & RTE_VISIBLE) ? 'style="display:none"' : "";
663 - fckTools.innerHTML+='<span ' + style + ' id="popup_free_text">[<a class="fckPopup" href="javascript:void(0)" onclick="ToggleFCKEditor(\'popup\',\'free_text\')">{$newWinMsg}</a>]</span>';
 663+ fckTools.innerHTML+='<span ' + style + ' id="popup_sf_free_text">[<a class="fckPopup" href="javascript:void(0)" onclick="ToggleFCKEditor(\'popup\',\'sf_free_text\')">{$newWinMsg}</a>]</span>';
664664 }
665665
666666 if (showFCKEditor & (RTE_POPUP|RTE_TOGGLE_LINK)){
Index: trunk/extensions/SemanticForms/includes/SF_ParserFunctions.php
@@ -137,6 +137,7 @@
138138
139139 $parser->setFunctionHook( 'forminput', array( 'SFParserFunctions', 'renderFormInput' ) );
140140 $parser->setFunctionHook( 'formlink', array( 'SFParserFunctions', 'renderFormLink' ) );
 141+ $parser->setFunctionHook( 'queryformlink', array( 'SFParserFunctions', 'renderQueryFormLink' ) );
141142 if ( defined( get_class( $parser ) . '::SFH_OBJECT_ARGS' ) ) {
142143 $parser->setFunctionHook( 'arraymap', array( 'SFParserFunctions', 'renderArrayMapObj' ), SFH_OBJECT_ARGS );
143144 $parser->setFunctionHook( 'arraymaptemplate', array( 'SFParserFunctions', 'renderArrayMapTemplateObj' ), SFH_OBJECT_ARGS );
@@ -156,7 +157,6 @@
157158 }
158159
159160 static function renderFormLink ( &$parser ) {
160 -
161161 $params = func_get_args();
162162 array_shift( $params ); // We don't need the parser.
163163
@@ -165,6 +165,15 @@
166166 return $parser->insertStripItem( SFUtils::createFormLink( $parser, 'FormEdit', $params ), $parser->mStripState );
167167 }
168168
 169+ static function renderQueryFormLink ( &$parser ) {
 170+ $params = func_get_args();
 171+ array_shift( $params ); // We don't need the parser.
 172+
 173+ // hack to remove newline from beginning of output, thanks to
 174+ // http://jimbojw.com/wiki/index.php?title=Raw_HTML_Output_from_a_MediaWiki_Parser_Function
 175+ return $parser->insertStripItem( SFUtils::createFormLink( $parser, 'RunQuery', $params ), $parser->mStripState );
 176+ }
 177+
169178 static function renderFormInput ( &$parser ) {
170179 global $wgVersion;
171180
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
@@ -36,7 +36,7 @@
3737 global $sfgTabIndex, $sfgFieldNum;
3838
3939 // Use a special ID for the free text field, for FCK's needs.
40 - $input_id = $input_name == 'free_text' ? 'free_text' : "input_$sfgFieldNum";
 40+ $input_id = $input_name == 'sf_free_text' ? 'sf_free_text' : "input_$sfgFieldNum";
4141
4242 if ( array_key_exists( 'editor', $other_args ) &&
4343 $other_args['editor'] == 'wikieditor' &&

Sign-offs

UserFlagDate
Nikerabbitinspected07:20, 20 February 2012

Follow-up revisions

RevisionCommit summaryAuthorDate
r111940Changed popup link to not include an 'additional query' form in resulting Spe...yaron17:20, 20 February 2012
r112134Follow-up to r111872 - another change of 'free_text' to 'sf_free_text'yaron19:06, 22 February 2012
r112191Trying to fix Error: invalid magic word 'queryformlink'...nikerabbit08:02, 23 February 2012