Extension:EditPageMultipleInputTextAreas
From MediaWiki.org
|
Editpage Multiple Input Textareas Release status: beta |
|
|---|---|
| Implementation | Page action |
| Description | Multiple inputboxes to be combined as one text |
| Author(s) | Boudewijn Vahrmeijer |
| Version | 0.5 (2007-11-04) |
| MediaWiki | >1.8.3, not yet tested on lower versions! |
| Download | see below Readme |
| Example | Testdemo |
| Hooks used |
EditPage::showEditForm:fields |
EditPageMultipleInputTextAreas is a new extension to get multiple input fields within the Editpage This extension is in 'progress', started from 19-9-2007.
See for support: http://www.leerwiki.nl/EditPageInputBox_Mediawiki
Contents |
[edit] What can it do
The Editforms extension is developed to enable different types of input for a Wiki. In this way a Wiki could be build up much faster, but also with more quality and clearer structure.
Features:
- Choice between tradional or custom structure
- Unlimited inputfields
- Automatic enlargement textarea when typing
[edit] Desired features
- Custom structure per page
[edit] Progress report / current status:
Latest version 04-11-2007
- 0.5 WORKING CODE!!
- fixed errors with button display
- fixed initial presentation
- fixed random errors with spaces within header names
- fixed errors with bullets (added "\n")
Previous working versions
- 0.4 Issues fixed with importing page without structure
- 0.3 Choice added to use template or not 21-09-2007
- 0.2 Including textarea expanding javascript 20-09-2007
- 0.1 Improved customization 19-09-2007
- 0.0.1 Combining and separating textareas working fine
[edit] Who's using it?
Please add your working-wiki here!
[edit] Code
<?php if ( ! defined( 'MEDIAWIKI' ) ) die(); //---------- Note Author--- 11-2007------------------- // The Editforms extension is developed to enable // different types of input for a Wiki. In this way // a Wiki could be build up much faster, but also // with more quality and clearer structure. // // See http://www.leerwiki.nl for either updates // or other extensions such as the Ajax Rating Script-, // Image shadow- or EditpageMultipleInputboxes extension. // good luck with your Wiki! // B.Vahrmeijer //---------------------------------------------------- $wgExtensionCredits['other'][] = array( 'name' => 'EditTextAreas', 'author' => 'Boudewijn Vahrmeijer', 'url' => 'http://www.mediawiki.org/wiki/Extension:EditPageMultipleInputTextAreas', 'version' => '0.5', 'description' => 'Extension to fasten article making and improve structure', ); //####### Choose parameters ############## $BoxNames=array('Introduction', 'Core', 'Conclusion'); //choose titles, minimum is ONE $Separator='.//.'; //Choose dummy separator for combining text input //####### Used Hooks ###################### $wgHooks['EditPage::showEditForm:fields'][] = 'TextareaDisplay'; $wgHooks['EditPage::attemptSave'][] = 'CombineBeforeSave'; $wgHooks['EditPage::showEditForm:initial'][] = 'OptionSetting'; $wgHooks['OutputPageBeforeHTML'][] = 'LastMinuteStyleChange'; //####### Formula preparation ############## $TotalTB=count($BoxNames); ########## Hook 1 ################# function TextareaDisplay(&$q, &$out) { global $TotalTB, $BoxNames, $Separator, $wgTitle; $title=$wgTitle; ######### HTML 1 ####### $out->addHTML(<<<END <script type="text/javascript"> function CUSTOM() { document.getElementById("div1").style.display = 'block'; document.getElementById("yes").style.display = 'none'; document.getElementById("no").style.display = 'block'; document.getElementById("wpStructure").value = 'CUSTOM'; } function TRADITIONAL() { document.getElementById("div1").style.display = 'none'; document.getElementById("yes").style.display = 'block'; document.getElementById("no").style.display = 'none'; document.getElementById("wpStructure").value = 'TRADITIONAL'; } </script> <script type="text/javascript"> function resizeTextarea(t) { n = navigator; nua = n.userAgent.toLowerCase(); a = t.value.split('\\n'); b=1; for (x=0;x < a.length; x++) { if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols); } b+= a.length; if (b > t.rows && nua.indexOf('opera') == -1) t.rows = b; } </script> <style> textarea { width: 550px; padding: .1em; }</style> END ); ############# CUT TEXT AND PUT IN BOXES ############# if(TotalTB>1) return true; $AllText=$q->textbox1; $ArrayTextTemp=explode($Separator,$AllText); if(count($ArrayTextTemp)>1){ $out->addHTML(" <div id='yes' style='display:none'><input type='button' value='CUSTOM STRUCTURE' OnClick='CUSTOM()'/></div> <div id='no' style='display:block'><input type='button' value='TRADITIONAL STRUCTURE' OnClick='TRADITIONAL()'/></div> <div id='div1' style='display:block'> <input value='CUSTOM' type='hidden' name='wpStructure' id='wpStructure'/>"); } else { $out->addHTML(" <div id='yes' style='display:block'><input type='button' value='CUSTOM STRUCTURE' OnClick='CUSTOM()'/></div> <div id='no' style='display:none'><input type='button' value='TRADITIONAL STRUCTURE' OnClick='TRADITIONAL()'/></div> <div id='div1' style='display:none'> <input value='TRADITIONAL' type='hidden' name='wpStructure' id='wpStructure'/>"); } for($i=0;$i<$TotalTB-1;$i++){ $out->addHTML($BoxNames[$i]."<br><textarea tabindex='1' onKeyUp='resizeTextarea(this)' accesskey=',' // display new textareas name='Box".$i."' id='Box".$i."' rows='4' cols='40'>".$ArrayTextTemp[$i+1]."</textarea><br>"); } $out->addHTML( $BoxNames[$TotalTB-1]."</div>"); if(count($ArrayTextTemp)>1){ $q->textbox1= $ArrayTextTemp[$TotalTB]; } return true; } ########## Hook 2 ################# function CombineBeforeSave(&$q) { global $wgRequest, $TotalTB, $BoxNames, $Separator; $request=$wgRequest; $q->Structure = $request->getVal( 'wpStructure' ); if($q->Structure=='CUSTOM'){ for($i=0;$i<$TotalTB-1;$i++){ $temp='Box'.$i; $allextraTB.= $Separator."\n".$q->safeUnicodeInput( $request, $temp )."\n"; } $q->textbox1 = $allextraTB.$Separator.$q->textbox1; } else{ $q->textbox1 = $q->textbox1; } return true; } ########## Hook 3 ################# function OptionSetting(&$q) { global $wgUser; $wgUser->setOption('rows',10); $wgUser->setOption('showtoolbar',0); return true; } ########## Hook 4 ################# function LastMinuteStyleChange(&$q,&$b) { global $Separator, $BoxNames, $wgTitle; $title=$wgTitle; if ($_GET['action'] != "") return true; //not the edit areas $k=explode($Separator,$b); if(count($k)<2) return true; //if no separator existing, no structure wanted $b=''; //clear dummy top ie. 11.//.22 for($i=1;$i<count($k);$i++){ $b.='<h2>'.$BoxNames[$i-1].'</h2>'.$k[$i].''; } return true; }

