r68345 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68344‎ | r68345 | r68346 >
Date:02:16, 21 June 2010
Author:yaron
Status:deferred
Tags:
Comment:
Removed Javascript related to "choosers" feature (now gone), added handling for FCKeditor when used with "Cite" extension
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.php
@@ -10,59 +10,6 @@
1111
1212 class SFFormUtils {
1313
14 - static function chooserJavascript() {
15 - $javascript_text = <<<END
16 -<script type="text/javascript">/* <![CDATA[ */
17 -
18 -function updatechooserbutton(f,n)
19 -{
20 - document.getElementById(n).disabled = (f.options[f.selectedIndex].value=="invalid");
21 -}
22 -
23 -function addInstanceFromChooser(chooserid)
24 -{
25 - var chooser = document.getElementById(chooserid);
26 - var optionstring = chooser.options[chooser.selectedIndex].value;
27 - var pos = optionstring.indexOf(",");
28 - var tabindex = optionstring.substr(0,pos);
29 - var chooservalue = optionstring.substr(pos+1);
30 - addInstance('starter_' + chooservalue, 'main_' + chooservalue, parseInt(tabindex));
31 -}
32 -
33 -//The fieldset containing the given element was just updated. If the fieldset is associated with a chooser,
34 -//ensure that the fieldset is hidden if and only if there are no template instances inside.
35 -function hideOrShowFieldset(element)
36 -{
37 - //Find fieldset
38 - while (element.tagName.toLowerCase() != "fieldset")
39 - element = element.parentNode;
40 - //Bail out if fieldset is not part of chooser
41 - if (!element.getAttribute("haschooser"))
42 - return;
43 - //Now look for "input" or "select" tags that don't look like they're part of the starter template
44 - var inputs = element.getElementsByTagName("input");
45 - var x;
46 - var show = false;
47 - for (x=0;x<inputs.length;x++)
48 - {
49 - if (inputs[x].type=="text" && inputs[x].name.indexOf("[num]") == -1)
50 - show = true;
51 - }
52 - var selects = element.getElementsByTagName("select");
53 - for (x=0;x<selects.length;x++)
54 - {
55 - if (selects[x].name.indexOf("[num]") == -1)
56 - show = true;
57 - }
58 - //Now show or hide fieldset
59 - element.style.display = (show?"block":"none");
60 -}
61 -/* ]]> */ </script>
62 -
63 -END;
64 - return $javascript_text;
65 - }
66 -
6714 /**
6815 * All the Javascript calls to validate both the type of each
6916 * form field and their presence, for mandatory fields
@@ -243,7 +190,7 @@
244191 return $javascript_text;
245192 }
246193
247 - static function instancesJavascript( $using_choosers ) {
 194+ static function instancesJavascript() {
248195 $remove_text = wfMsg( 'sf_formedit_remove' );
249196 $javascript_text = <<<END
250197
@@ -311,9 +258,6 @@
312259
313260 //In order to add the new instances in multiple floatBox (multiple templates)
314261 fb.tagAnchors(self.document);
315 - if ($using_choosers) {
316 - hideOrShowFieldset(new_div);
317 - }
318262 }
319263
320264 function removeInstanceEventHandler(this_div_id)
@@ -327,8 +271,6 @@
328272 var olddiv = document.getElementById(div_id);
329273 var parent = olddiv.parentNode;
330274 parent.removeChild(olddiv);
331 - if ($using_choosers)
332 - hideOrShowFieldset(parent);
333275 }
334276
335277 END;
@@ -752,6 +694,7 @@
753695
754696 static function mainFCKJavascript( $showFCKEditor ) {
755697 global $wgUser, $wgScriptPath, $wgFCKEditorExtDir, $wgFCKEditorDir, $wgFCKEditorToolbarSet, $wgFCKEditorHeight;
 698+ global $wgHooks, $wgExtensionFunctions;
756699
757700 $newWinMsg = wfMsg( 'rich_editor_new_window' );
758701 $javascript_text = '
@@ -766,6 +709,17 @@
767710 var RTE_TOGGLE_LINK = ' . RTE_TOGGLE_LINK . ';
768711 var RTE_POPUP = ' . RTE_POPUP . ';
769712 ';
 713+
 714+ $showRef = 'false';
 715+ if ( (isset($wgHooks['ParserFirstCallInit']) && in_array('wfCite',$wgHooks['ParserFirstCallInit'])) || (isset($wgExtensionFunctions) && in_array('wfCite',$wgExtensionFunctions)) ) {
 716+ $showRef = 'true';
 717+ }
 718+
 719+ $showSource = 'false';
 720+ if ( (isset ($wgHooks['ParserFirstCallInit']) && in_array('efSyntaxHighlight_GeSHiSetup', $wgHooks['ParserFirstCallInit']))
 721+ || (isset ($wgExtensionFunctions) && in_array('efSyntaxHighlight_GeSHiSetup', $wgExtensionFunctions)) ) {
 722+ $showSource = 'true';
 723+ }
770724
771725 $javascript_text .= <<<END
772726 var oFCKeditor = new FCKeditor( "free_text" );
@@ -774,6 +728,8 @@
775729 oFCKeditor.BasePath = '$wgScriptPath/$wgFCKEditorDir/';
776730 oFCKeditor.Config["CustomConfigurationsPath"] = "$wgScriptPath/$wgFCKEditorExtDir/fckeditor_config.js" ;
777731 oFCKeditor.Config["EditorAreaCSS"] = "$wgScriptPath/$wgFCKEditorExtDir/css/fckeditor.css" ;
 732+oFCKeditor.Config["showreferences"] = '$showRef';
 733+oFCKeditor.Config["showsource"] = '$showSource';
778734 oFCKeditor.ToolbarSet = "$wgFCKEditorToolbarSet" ;
779735 oFCKeditor.ready = true;
780736

Status & tagging log