r101069 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101068‎ | r101069 | r101070 >
Date:21:52, 27 October 2011
Author:foxtrott
Status:deferred (Comments)
Tags:
Comment:
provide wikieditor for textareas

TODO:
* CSS
* free text
Modified paths:
  • /trunk/extensions/SemanticForms/SemanticForms.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_wikieditor.js (added) (history)
  • /trunk/extensions/SemanticForms/specials/SF_FormEdit.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/SemanticForms.php
@@ -229,6 +229,11 @@
230230 'styles' => 'skins/SF_collapsible.css',
231231 'dependencies' => array( 'jquery' ),
232232 ),
 233+ 'ext.semanticforms.wikieditor' => $sfgResourceTemplate + array(
 234+ 'scripts' => 'libs/SF_wikieditor.js',
 235+// 'styles' => 'skins/SF_wikieditor.css', // no styles necessary?
 236+ 'dependencies' => array('jquery.wikiEditor'),
 237+ ),
233238 );
234239 }
235240
Index: trunk/extensions/SemanticForms/specials/SF_FormEdit.php
@@ -90,6 +90,7 @@
9191 static function printForm( &$form_name, &$target_name, $alt_forms = array(), $redirectOnError = false ) {
9292 global $wgOut, $wgRequest, $wgUser, $sfgFormPrinter;
9393
 94+ wfRunHooks( 'EditPage::showEditForm:initial', array( &$this ) );
9495 SFUtils::loadMessages();
9596
9697 // If we have no form name we might as well stop right away
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaWithAutocompleteInput.php
@@ -117,6 +117,20 @@
118118 }
119119 $text = "\n" . Xml::tags( 'span', array( 'class' => $spanClass ), $text );
120120
 121+
 122+ if ( array_key_exists( 'wikieditor', $other_args ) &&
 123+ array_search( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) !== FALSE ) {
 124+
 125+ $wgOut->addModules( 'ext.semanticforms.wikieditor' );
 126+
 127+ $jstext = <<<JAVASCRIPT
 128+jQuery(function(){ jQuery('#input_$sfgFieldNum').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
 129+JAVASCRIPT;
 130+
 131+ // write JS code directly to the page's code
 132+ $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
 133+ }
 134+
121135 return $text;
122136 }
123137
Index: trunk/extensions/SemanticForms/includes/forminputs/SF_TextAreaInput.php
@@ -29,6 +29,7 @@
3030 }
3131
3232 public static function getHTML( $cur_value, $input_name, $is_mandatory, $is_disabled, $other_args ) {
 33+ global $wgOut;
3334 global $sfgTabIndex, $sfgFieldNum;
3435
3536 $className = ( $is_mandatory ) ? 'mandatoryField' : 'createboxInput';
@@ -99,6 +100,20 @@
100101 $spanClass .= ' mandatoryFieldSpan';
101102 }
102103 $text = Xml::tags( 'span', array( 'class' => $spanClass ), $text );
 104+
 105+ if ( array_key_exists( 'wikieditor', $other_args ) &&
 106+ array_search( 'jquery.wikiEditor', $wgOut->getResourceLoader()->getModuleNames() ) !== FALSE ) {
 107+
 108+ $wgOut->addModules( 'ext.semanticforms.wikieditor' );
 109+
 110+ $jstext = <<<JAVASCRIPT
 111+jQuery(function(){ jQuery('#input_$sfgFieldNum').SemanticForms_registerInputInit( ext.wikieditor.init, null ); });
 112+JAVASCRIPT;
 113+
 114+ // write JS code directly to the page's code
 115+ $wgOut->addScript( '<script type="text/javascript">' . $jstext . '</script>' );
 116+ }
 117+
103118 return $text;
104119 }
105120
Index: trunk/extensions/SemanticForms/libs/SF_wikieditor.js
@@ -0,0 +1,31 @@
 2+// setup wikieditor functionality
 3+jQuery(function(){
 4+ ext.wikieditor.setup();
 5+});
 6+
 7+// create ext if it does not exist yet
 8+if ( typeof( window[ 'ext' ] ) == "undefined" ) {
 9+ window[ 'ext' ] = {};
 10+}
 11+
 12+window.ext.wikieditor = new function(){
 13+
 14+ var config;
 15+
 16+ // common setup for all editor instances
 17+ function setup () {
 18+ config = jQuery.wikiEditor.modules.toolbar.config.getDefaultConfig();
 19+ config.toolbar.advanced.groups.insert.tools.table.filters = ['textarea:not(#wpTextbox1):not(.toolbar-dialogs)'];
 20+ }
 21+
 22+ // initialize the wikieditor on the specified element
 23+ function init ( input_id, params ) {
 24+ var input = jQuery( '#' + input_id );
 25+ input.wikiEditor( 'addModule', config );
 26+ }
 27+
 28+ // export public funcitons
 29+ this.setup = setup;
 30+ this.init = init;
 31+
 32+};
Property changes on: trunk/extensions/SemanticForms/libs/SF_wikieditor.js
___________________________________________________________________
Added: svn:eol-style
133 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r101075followup r101069: CSS and free text workfoxtrott22:35, 27 October 2011
r101172followup r101069: bugfix (calling hook causes fatal error), Html::inlineScrip...foxtrott19:09, 28 October 2011

Comments

#Comment by Nikerabbit (talk | contribs)   07:29, 28 October 2011

Html::inlineScript can be used on line with $wgOut->addScript.

#Comment by Nikerabbit (talk | contribs)   12:13, 28 October 2011

The hook your added causes the following fatal error: HP Catchable fatal error: Argument 1 passed to TranslateEditAddons::addTools() must be an instance of EditPage, null given in /www/w/extensions/Translate/TranslateEditAddons.php on line 143

Please fix it as soon as possible!

#Comment by F.trott (talk | contribs)   19:15, 28 October 2011

Both fixed in r101172.

Status & tagging log