<?php ## Form Extensions for PmWiki by Ben Stallings, 2008-06-14 ## no license: modify and distribute freely Markup('fieldset', '>input', '/\\(:fieldset\\s+(.*?):\\)/i', "InputFieldSet"); Markup('fieldsetend', 'inline', '/\\(:fieldsetend:\\)/i', "</fieldset>"); Markup('label', '>input', '/\\(:label\\s+(\\w+)(.*?):\\)/i', "InputLabel"); Markup('toggleboxes', '>input', '/\\(:toggleboxes\\s?(.*?):\\)/i', "ToggleBoxes"); function InputFieldSet($matches) { $legend = $matches[1]; return "<fieldset>\n".($legend ? "<legend>".trim($legend, "'\" ")."</legend>\n" : ""); } function InputLabel($matches) { $id = $matches[1]; $label = $matches[2]; return "<label for='$id'>".trim($label, "'\" ")."</label>"; } function ToggleBoxes() { return "<input type='button' value='Toggle Checkboxes' onClick='toggleCheckboxes();' />\n <script type='text/javascript'> function toggleCheckboxes() { // written by Daniel P 3/21/07 // toggle all checkboxes found on the page var inputlist = document.getElementsByTagName(\"input\"); for (i = 0; i < inputlist.length; i++) { if ( inputlist[i].getAttribute(\"type\") == 'checkbox' ) { // look only at input elements that are checkboxes if (inputlist[i].checked) inputlist[i].checked = false else inputlist[i].checked = true; } } }</script>\n"; }