r88599 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88598‎ | r88599 | r88600 >
Date:19:48, 22 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added hooks to allow other extensions (like CKeditor/WYSIWYG) to add their own Javascript to the form; cosmetic changes
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -58,12 +58,13 @@
5959 /**
6060 * Register all information about the passed-in form input class.
6161 *
62 - * @param Class $inputTypeClass The class representing the new input. Must be derived from SFFormInput.
 62+ * @param Class $inputTypeClass The class representing the new input.
 63+ * Must be derived from SFFormInput.
6364 */
6465 public function registerInputType( $inputTypeClass ) {
6566 global $smwgContLang;
6667 global $sfgInitJSFunctions, $sfgValidationJSFunctions;
67 -
 68+
6869 $inputTypeName = call_user_func( array( $inputTypeClass, 'getName' ) );
6970 $this->mInputTypeClasses[$inputTypeName] = $inputTypeClass;
7071 $this->setInputTypeHook( $inputTypeName, array( $inputTypeClass, 'getHTML' ), array() );
@@ -362,7 +363,7 @@
363364 $wgParser = unserialize( serialize( $oldParser ) ); // deep clone of parser
364365 $wgParser->clearState();
365366
366 - // Get the form definition from the cache, if we're using caching and it's
 367+ // Get the form definition from the cache, if we're using caching and it's
367368 // there.
368369 // $got_form_def_from_cache = false;
369370 // global $sfgCacheFormDefinitions;
@@ -1359,6 +1360,8 @@
13601361 $free_text = trim( $free_text );
13611362 $data_text = str_replace( '!free_text!', '<onlyinclude>!free_text!</onlyinclude>', $data_text );
13621363 }
 1364+
 1365+ wfRunHooks( 'sfModifyFreeTextField', array( &$free_text, $existing_page_content ) );
13631366 // if the FCKeditor extension is installed, use that for the free text input
13641367 global $wgFCKEditorDir;
13651368 if ( $wgFCKEditorDir && strpos( $existing_page_content, '__NORICHEDITOR__' ) === false ) {
@@ -1374,8 +1377,8 @@
13751378 $form_text = str_replace( '!free_text!', $escaped_free_text, $form_text );
13761379 $data_text = str_replace( '!free_text!', $free_text, $data_text );
13771380
1378 - // add a warning in, if we're editing an existing page and that page
1379 - // appears to not have been created with this form
 1381+ // Add a warning in, if we're editing an existing page and that
 1382+ // page appears to not have been created with this form.
13801383 if ( $this->mPageTitle->exists() && ( $existing_page_content != '' ) && ! $source_page_matches_this_form ) {
13811384 $form_text = "\t" . '<div class="warningMessage">' . wfMsg( 'sf_formedit_formwarning', $this->mPageTitle->getFullURL() ) . "</div>\n" . $form_text;
13821385 }
@@ -1396,10 +1399,14 @@
13971400 }
13981401 $form_text .= "\t</form>\n";
13991402
1400 - // add Javascript code for form-wide use
 1403+ // Add general Javascript code.
 1404+ wfRunHooks( 'sfAddJavascriptToForm', array( &$javascript_text ) );
 1405+
 1406+ // @TODO The FCKeditor Javascript should be handled within
 1407+ // the FCKeditor extension itself, using the hook.
14011408 $javascript_text = "";
14021409 if ( $free_text_was_included && $showFCKEditor > 0 ) {
1403 - $javascript_text .= SFFormUtils::mainFCKJavascript( $showFCKEditor );
 1410+ $javascript_text .= SFFormUtils::mainFCKJavascript( $showFCKEditor, $field_args );
14041411 if ( $showFCKEditor & ( RTE_TOGGLE_LINK | RTE_POPUP ) ) {
14051412 $javascript_text .= SFFormUTils::FCKToggleJavascript();
14061413 }
@@ -1408,8 +1415,8 @@
14091416 }
14101417 }
14111418
1412 - // Send the autocomplete values to the browser, along with the mappings
1413 - // of which values should apply to which fields.
 1419+ // Send the autocomplete values to the browser, along with the
 1420+ // mappings of which values should apply to which fields.
14141421 // If doing a replace, the data text is actually the modified original page
14151422 if ( $wgRequest->getCheck( 'partial' ) )
14161423 $data_text = $existing_page_content;