r46854 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46853‎ | r46854 | r46855 >
Date:17:13, 5 February 2009
Author:yaron
Status:deferred
Tags:
Comment:
Added addUnhandledFields() and unhandledFieldsHTML() methods
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormUtils.inc (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormUtils.inc
@@ -63,6 +63,10 @@
6464 return $javascript_text;
6565 }
6666
 67+ /**
 68+ * All the Javascript calls to validate both the type of each
 69+ * form field and their presence, for mandatory fields
 70+ */
6771 static function validationJavascript() {
6872 global $sfgJSValidationCalls;
6973
@@ -394,6 +398,39 @@
395399 return $text;
396400 }
397401
 402+ /**
 403+ * Add a hidden input for each field in the template call that's
 404+ * not handled by the form itself
 405+ */
 406+ static function unhandledFieldsHTML($template_contents) {
 407+ $text = "";
 408+ foreach ($template_contents as $key => $value) {
 409+ if ($key != '' && !is_numeric($key)) {
 410+ $text .=<<<END
 411+ <input type="hidden" name="_unhandled_$key" value="$value" />
 412+
 413+END;
 414+ }
 415+ }
 416+ return $text;
 417+ }
 418+
 419+ /**
 420+ * Add unhandled fields back into the template call that the form
 421+ * generates, so that editing with a form will have no effect on them
 422+ */
 423+ static function addUnhandledFields() {
 424+ global $wgRequest;
 425+ $additional_template_text = "";
 426+ foreach ($wgRequest->getValues() as $key => $value) {
 427+ if (substr($key, 0, 11) == '_unhandled_') {
 428+ $field_name = substr($key, 11);
 429+ $additional_template_text .= "|$field_name=$value\n";
 430+ }
 431+ }
 432+ return $additional_template_text;
 433+ }
 434+
398435 static function summaryInputHTML($is_disabled, $label = null) {
399436 global $sfgTabIndex;
400437

Status & tagging log