pieforms-commit Mailing List for Pieforms (Page 8)
Status: Alpha
Brought to you by:
oracleshinoda
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(73) |
Dec
(83) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(16) |
Feb
(19) |
Mar
(12) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
(14) |
Sep
(2) |
Oct
(1) |
Nov
(2) |
Dec
(45) |
2008 |
Jan
(20) |
Feb
(3) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(1) |
2009 |
Jan
(2) |
Feb
(2) |
Mar
|
Apr
(2) |
May
(1) |
Jun
(5) |
Jul
(1) |
Aug
(2) |
Sep
(1) |
Oct
|
Nov
(7) |
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ora...@us...> - 2006-12-27 04:58:00
|
Revision: 148 http://svn.sourceforge.net/pieforms/?rev=148&view=rev Author: oracleshinoda Date: 2006-12-26 20:58:00 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Loosened the check for fieldsets a little bit so that classes can be added to the fieldset. Required for collapsable fieldset support Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/table.php Modified: pieforms-php5/trunk/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-26 00:28:16 UTC (rev 147) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-27 04:58:00 UTC (rev 148) @@ -38,7 +38,7 @@ $formname = $form->get_name(); if ($rawelement['type'] == 'fieldset') { // Add table tags to the build element, to preserve HTML compliance - if (0 === strpos($builtelement, "\n<fieldset>\n<legend>")) { + if (0 === strpos($builtelement, "\n<fieldset")) { $closelegendpos = strpos($builtelement, '</legend>') + 9; $builtelement = substr($builtelement, 0, $closelegendpos) . '<table>' . substr($builtelement, $closelegendpos); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-26 00:28:18
|
Revision: 147 http://svn.sourceforge.net/pieforms/?rev=147&view=rev Author: oracleshinoda Date: 2006-12-25 16:28:16 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Moved MochiKit stuff to the core/ directory Added Paths: ----------- pieforms-php5/trunk/src/static/core/MochiKit/ Removed Paths: ------------- pieforms-php5/trunk/src/static/MochiKit/ Copied: pieforms-php5/trunk/src/static/core/MochiKit (from rev 146, pieforms-php5/trunk/src/static/MochiKit) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-26 00:27:26
|
Revision: 146 http://svn.sourceforge.net/pieforms/?rev=146&view=rev Author: oracleshinoda Date: 2006-12-25 16:27:24 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Moved js/ to static/ Added Paths: ----------- pieforms-php5/trunk/src/static/ pieforms-php5/trunk/src/static/MochiKit/ pieforms-php5/trunk/src/static/core/ pieforms-php5/trunk/src/static/jscalendar/ Removed Paths: ------------- pieforms-php5/trunk/src/static/MochiKit/ pieforms-php5/trunk/src/static/jscalendar/ Copied: pieforms-php5/trunk/src/static (from rev 140, pieforms-php5/trunk/src/js) Copied: pieforms-php5/trunk/src/static/MochiKit (from rev 144, pieforms-php5/trunk/src/js/MochiKit) Copied: pieforms-php5/trunk/src/static/jscalendar (from rev 144, pieforms-php5/trunk/src/js/jscalendar) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-26 00:18:05
|
Revision: 145 http://svn.sourceforge.net/pieforms/?rev=145&view=rev Author: oracleshinoda Date: 2006-12-25 16:18:04 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Moved js/ to static/, as CSS, images and other things may find their way into that directory Removed Paths: ------------- pieforms-php5/trunk/src/js/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-25 23:45:27
|
Revision: 144 http://svn.sourceforge.net/pieforms/?rev=144&view=rev Author: oracleshinoda Date: 2006-12-25 15:45:25 -0800 (Mon, 25 Dec 2006) Log Message: ----------- Forms will now die if execution is continuing after the submit function is called, however this behaviour can be turned off if necessary (the transient login page in Mahara requires it to be off) Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-24 06:29:24 UTC (rev 143) +++ pieforms-php5/trunk/src/pieform.php 2006-12-25 23:45:25 UTC (rev 144) @@ -255,6 +255,12 @@ // like cancel buttons 'iscancellable' => true, + // Whether Pieforms should die after calling a submit function. Generally + // this is a good idea, as it forces the user to reply to the form + // submission. However, there are occasions where you might want to let + // it continue, so this behaviour can be turned off + 'dieaftersubmit' => true, + // Whether to auto-focus either the first field (if the value is true, // or the named field (if the value is a string) when the form is // displayed. If this has any value other than false and the form has @@ -514,14 +520,20 @@ // finished processing the form. // @todo maybe it should do just that... call_user_func_array($function, array($this, $values)); - // This will only work if I can make the login_submit function stuff work in login_validate - //if ($this->ajaxpost) { - // $message = 'Your ' . $this->name . '_submit function should output some json and exit'; - //} - //else { - // $message = 'Your ' . $this->name . '_submit function should redirect when it is finished'; - //} - //throw new PieformException($message); + if ($this->data['dieaftersubmit']) { + // This will only work if I can make the login_submit function stuff work in login_validate + if ($this->data['jsform']) { + $message = 'Your ' . $this->name . '_submit function should use $form->json_reply to send a response'; + } + else { + $message = 'Your ' . $this->name . '_submit function should redirect or exit when it is done'; + } + throw new PieformException($message); + } + else { + // Successful submission, and the user doesn't care about replying, so... + return; + } } else if (!$submitted) { throw new PieformException('No function registered to handle form submission for form "' . $this->name . '"'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 06:29:28
|
Revision: 143 http://svn.sourceforge.net/pieforms/?rev=143&view=rev Author: oracleshinoda Date: 2006-12-23 22:29:24 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Renumbered response constants to be negative numbers, to allow application developers to use the positive numbers Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-24 05:12:32 UTC (rev 142) +++ pieforms-php5/trunk/src/pieform.php 2006-12-24 06:29:24 UTC (rev 143) @@ -26,6 +26,13 @@ $GLOBALS['_PIEFORM_REGISTRY'] = array(); +/** The form was processed successfully */ +define('PIEFORM_OK', 0); +/** The form failed processing/validating */ +define('PIEFORM_ERR', -1); +/** A cancel button was pressed */ +define('PIEFORM_CANCEL', -2); + /** * Builds, validates and processes a form. * @@ -877,7 +884,7 @@ } else { // Redirect if the form is being cancelled - if (data.returnCode == 2) { + if (data.returnCode == -2) { window.location = data.message; return; } @@ -890,7 +897,7 @@ } } - if (data.returnCode == 1) { + if (data.returnCode == -1) { // The request failed validation EOF; @@ -1330,8 +1337,4 @@ return array_unique($htmlelements); } -define('PIEFORM_OK', 0); -define('PIEFORM_ERR', 1); -define('PIEFORM_CANCEL', 2); - ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 05:12:34
|
Revision: 142 http://svn.sourceforge.net/pieforms/?rev=142&view=rev Author: oracleshinoda Date: 2006-12-23 21:12:32 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Renamed the *_messages_js functions to *_get_js, which is more appropriate Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/div.php pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php pieforms-php5/trunk/src/pieform/renderers/table.php pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform/renderers/div.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/div.php 2006-12-24 02:32:29 UTC (rev 141) +++ pieforms-php5/trunk/src/pieform/renderers/div.php 2006-12-24 05:12:32 UTC (rev 142) @@ -78,8 +78,7 @@ } -// @todo needs updating again... need to replace remove_error with remove_all_errors -function pieform_renderer_div_messages_js($id) { +function pieform_renderer_div_get_js($id) { $result = <<<EOF // Given a message and form element name, should set an error on the element function {$id}_set_error(message, element) { Modified: pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php 2006-12-24 02:32:29 UTC (rev 141) +++ pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php 2006-12-24 05:12:32 UTC (rev 142) @@ -46,8 +46,7 @@ $formrenderermct->set_form($form); } -function pieform_renderer_multicolumntable_messages_js($id) { - //return pieform_renderer_table_messages_js($id); +function pieform_renderer_multicolumntable_get_js($id) { return <<<EOF function {$id}_set_error (message, element) { element = '{$id}_' + element; Modified: pieforms-php5/trunk/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-24 02:32:29 UTC (rev 141) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-24 05:12:32 UTC (rev 142) @@ -106,7 +106,7 @@ return "</tbody></table>\n"; } -function pieform_renderer_table_messages_js($id) { +function pieform_renderer_table_get_js($id) { $result = <<<EOF function {$id}_set_error(message, element) { element = $('{$id}_' + element + '_container'); Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-24 02:32:29 UTC (rev 141) +++ pieforms-php5/trunk/src/pieform.php 2006-12-24 05:12:32 UTC (rev 142) @@ -928,7 +928,7 @@ EOF; $result .= "});\n\n"; - $function = 'pieform_renderer_' . $this->data['renderer'] . '_messages_js'; + $function = 'pieform_renderer_' . $this->data['renderer'] . '_get_js'; if (!function_exists($function)) { throw new PieformException('No renderer message function "' . $function . '"'); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 02:32:38
|
Revision: 141 http://svn.sourceforge.net/pieforms/?rev=141&view=rev Author: oracleshinoda Date: 2006-12-23 18:32:29 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Insert empty table cells in gaps to preserve HTML validation. Disable fieldsets from working, they just make a mess. Fixed up the javascript for inserting errors so it actually works Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php Modified: pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php 2006-12-24 00:25:05 UTC (rev 140) +++ pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php 2006-12-24 02:32:29 UTC (rev 141) @@ -42,15 +42,47 @@ */ function pieform_renderer_multicolumntable(Pieform $form, $builtelement, $rawelement) { global $formrenderermct; - // Used by the messages javascript function - $form->include_plugin('renderer', 'table'); $formrenderermct->add_element($builtelement, $rawelement); $formrenderermct->set_form($form); } function pieform_renderer_multicolumntable_messages_js($id) { - return pieform_renderer_table_messages_js($id); + //return pieform_renderer_table_messages_js($id); + return <<<EOF +function {$id}_set_error (message, element) { + element = '{$id}_' + element; + var parentRow = $(element + '_container').parentNode; + var nextRow = parentRow.nextSibling; + if (!(nextRow && hasElementClass(nextRow, 'errorRow'))) { + var errorRow = TR({'class': 'errorRow'}); + log(parentRow.cells.length); + for (var i = 0; i < parentRow.cells.length; i++) { + var attrs = null; + if (parentRow.cells[i].id) { + attrs = { + 'id': parentRow.cells[i].id.replace(/_container$/, '_error'), + 'class': 'error' + }; + } + appendChildNodes(errorRow, TD(attrs)); + } + insertSiblingNodesAfter($(element + '_container').parentNode, errorRow); + } + + appendChildNodes(element + '_error', message); + addElementClass(element, 'error'); + addElementClass( element + '_container', 'error'); } +function {$id}_remove_all_errors() { + forEach(getElementsByTagAndClassName('TR', 'errorRow', '{$id}'), function(row) { + removeElement(row); + }); + forEach(getElementsByTagAndClassName(null, 'error', '{$id}'), function(item) { + removeElementClass(item, 'error'); + }); +} +EOF; +} function pieform_renderer_multicolumntable_header() { global $formrenderermct; @@ -68,6 +100,9 @@ private $form; function add_element($builtelement, $rawelement) { + if ($rawelement['type'] == 'fieldset') { + throw new PieformException('The multicolumntable renderer does not support fieldsets'); + } if (!array_key_exists($rawelement['title'], $this->elements)) { $this->elements[$rawelement['title']] = array(); $this->elements[$rawelement['title']]['rawelements'] = array(); @@ -83,6 +118,11 @@ } function build() { + // Find out the maximum number of columns + $columns = 0; + foreach ($this->elements as $data) { + $columns = max($columns, count($data['builtelements'])); + } $result = "<table cellspacing=\"0\" border=\"0\"><tbody>\n"; foreach ($this->elements as $title => $data) { $result .= "\t<tr"; @@ -120,6 +160,9 @@ // @todo description... } + for ($i = count($data['builtelements']); $i < $columns; $i++) { + $result .= "\t<td></td>\n\t"; + } $result .= "</tr>\n"; } $result .= "</tbody></table>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 00:26:03
|
Revision: 140 http://svn.sourceforge.net/pieforms/?rev=140&view=rev Author: oracleshinoda Date: 2006-12-23 16:25:05 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Ignore vim .swp files Property Changed: ---------------- pieforms-php5/trunk/src/js/MochiKit/ pieforms-php5/trunk/src/js/jscalendar/ pieforms-php5/trunk/src/js/jscalendar/lang/ pieforms-php5/trunk/src/js/jscalendar/skins/ pieforms-php5/trunk/src/js/jscalendar/skins/aqua/ pieforms-php5/trunk/src/pieform/elements/ pieforms-php5/trunk/src/pieform/renderers/ pieforms-php5/trunk/src/pieform/rules/ Property changes on: pieforms-php5/trunk/src/js/MochiKit ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/js/jscalendar ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/js/jscalendar/lang ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/js/jscalendar/skins ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/js/jscalendar/skins/aqua ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/pieform/elements ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/pieform/renderers ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/pieform/rules ___________________________________________________________________ Name: svn:ignore + *.swp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 00:25:23
|
Revision: 139 http://svn.sourceforge.net/pieforms/?rev=139&view=rev Author: oracleshinoda Date: 2006-12-23 16:23:51 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Ignore vim .swp files Property Changed: ---------------- pieforms-php5/trunk/src/ pieforms-php5/trunk/src/JSON/ pieforms-php5/trunk/src/js/ pieforms-php5/trunk/src/pieform/ Property changes on: pieforms-php5/trunk/src ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/JSON ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/js ___________________________________________________________________ Name: svn:ignore + *.swp Property changes on: pieforms-php5/trunk/src/pieform ___________________________________________________________________ Name: svn:ignore + *.swp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 00:22:21
|
Revision: 138 http://svn.sourceforge.net/pieforms/?rev=138&view=rev Author: oracleshinoda Date: 2006-12-23 16:20:47 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Updated the expiry element to work with the error javascript stuff. Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/expiry.php Modified: pieforms-php5/trunk/src/pieform/elements/expiry.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/expiry.php 2006-12-24 00:19:12 UTC (rev 137) +++ pieforms-php5/trunk/src/pieform/elements/expiry.php 2006-12-24 00:20:47 UTC (rev 138) @@ -33,6 +33,7 @@ * @return string The HTML for the element */ function pieform_element_expiry(Pieform $form, $element) { + $formname = $form->get_name(); $result = ''; $name = $element['name']; if (!isset($element['defaultvalue'])) { @@ -46,9 +47,9 @@ $seconds = $element['value']; $values = pieform_element_expiry_get_expiry_from_seconds($element['value']); } - else if (isset($global[$element['name'] . '_number']) + else if (isset($global[$element['name']]) && isset($global[$element['name'] . '_units'])) { - $values = array('number' => $global[$element['name'] . '_number'], + $values = array('number' => $global[$element['name']], 'units' => $global[$element['name'] . '_units']); $seconds = $values['number'] * pieform_element_expiry_seconds_in($values['units']); } @@ -65,11 +66,12 @@ // Same with the select. And do the events using mochikit signal instead of dom events $numberinput = '<input'; $numberinput .= ($values['units'] == 'noenddate' && empty($element['rules']['required'])) ? ' disabled="disabled"' : ''; - $numberinput .= ' type="text" size="4" name="' . $name . '_number"'; - $numberinput .= ' id="' . $name . '_number" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . "\">\n"; + $numberinput .= ' type="text" size="4" name="' . $name . '"'; + $numberinput .= ' id="' . $formname . '_' . $name . '" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . '"'; + $numberinput .= (isset($element['error']) ? ' class="error"' : '') . ">\n"; $uselect = '<select onchange="' . $name . '_change()" '; - $uselect .= 'name="' . $name . '_units" id="' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n"; + $uselect .= 'name="' . $name . '_units" id="' . $formname . '_' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n"; foreach (pieform_element_expire_get_expiry_units() as $u) { // Don't allow 'no end date' if the element is required if ($u == 'noenddate' && !empty($element['rules']['required'])) { @@ -85,11 +87,11 @@ $script = <<<EOJS <script type="text/javascript" language="javascript"> function {$name}_change() { - if ($('{$name}_units').value == 'noenddate') { - $('{$name}_number').disabled = true; + if ($('{$formname}_{$name}_units').value == 'noenddate') { + $('{$formname}_{$name}').disabled = true; } else { - $('{$name}_number').disabled = false; + $('{$formname}_{$name}').disabled = false; } } </script> @@ -113,7 +115,7 @@ return null; } $allunits = pieform_element_expire_get_expiry_units(); - $number = $global[$name . '_number']; + $number = $global[$name]; if (!in_array($unit,$allunits) || $number < 0) { return null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 00:19:37
|
Revision: 137 http://svn.sourceforge.net/pieforms/?rev=137&view=rev Author: oracleshinoda Date: 2006-12-23 16:19:12 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Slight improvements to the javascript for the table renderer Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/table.php Modified: pieforms-php5/trunk/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-24 00:18:11 UTC (rev 136) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-24 00:19:12 UTC (rev 137) @@ -109,11 +109,11 @@ function pieform_renderer_table_messages_js($id) { $result = <<<EOF function {$id}_set_error(message, element) { - element = '{$id}_' + element + '_container'; - var container = getFirstElementByTagAndClassName('TD', null, $(element)); + element = $('{$id}_' + element + '_container'); + var container = getFirstElementByTagAndClassName('TD', null, element); addElementClass(container, 'error'); addElementClass(container.firstChild, 'error'); - insertSiblingNodesAfter($(element), TR({'id': '{$id}_error_' + element}, TD({'colspan': 2, 'class': 'errmsg'}, message))); + insertSiblingNodesAfter(element, TR(null, TD({'colspan': 2, 'class': 'errmsg'}, message))); } function {$id}_remove_all_errors() { forEach(getElementsByTagAndClassName('TD', 'errmsg', $('$id')), function(item) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-24 00:18:47
|
Revision: 136 http://svn.sourceforge.net/pieforms/?rev=136&view=rev Author: oracleshinoda Date: 2006-12-23 16:18:11 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Updated the div javascript for the recent changes made Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/div.php Modified: pieforms-php5/trunk/src/pieform/renderers/div.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/div.php 2006-12-23 13:23:23 UTC (rev 135) +++ pieforms-php5/trunk/src/pieform/renderers/div.php 2006-12-24 00:18:11 UTC (rev 136) @@ -81,38 +81,21 @@ // @todo needs updating again... need to replace remove_error with remove_all_errors function pieform_renderer_div_messages_js($id) { $result = <<<EOF - // Given a message and form element name, should set an error on the element function {$id}_set_error(message, element) { - {$id}_remove_error(element); - element += '_container'; - // @todo set error class on input elements... - insertSiblingNodesBefore(DIV({'id': '{$id}_error_' + element, 'class': 'errmsg'}, message), $(element)); + element = '{$id}_' + element; + addElementClass(element + '_container', 'error'); + addElementClass(element, 'error'); + insertSiblingNodesAfter(element + '_container', DIV({'class': 'errmsg'}, message)); } -function {$id}_remove_error(element) { - element += '_container'; - var elem = $('{$id}_error_' + element); - if (elem) { - removeElement(elem); - } +function {$id}_remove_all_errors() { + forEach(getElementsByTagAndClassName('DIV', 'errmsg', '{$id}'), function(div) { + removeElement(div); + }); + forEach(getElementsByTagAndClassName(null, 'error', '{$id}'), function(div) { + removeElementClass(div, 'error'); + }); } -function {$id}_message(message, type) { - var elem = $('{$id}_pieform_message'); - var msg = DIV({'id': '{$id}_pieform_message', 'class': type}, message); - if (elem) { - swapDOM(elem, msg); - } - else { - insertSiblingNodesAfter($('{$id}_' + {$id}_btn + '_container'), msg); - } -} -function {$id}_remove_message() { - var elem = $('{$id}_message'); - if (elem) { - removeElement(elem); - } -} - EOF; return $result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 13:23:23
|
Revision: 135 http://svn.sourceforge.net/pieforms/?rev=135&view=rev Author: oracleshinoda Date: 2006-12-23 05:23:23 -0800 (Sat, 23 Dec 2006) Log Message: ----------- * You can now have a javascript presubmit function non javascript forms. * A bunch of the callbacks have had their names changed for yet more consistency. * Forms that use a hidden iframe to submit to are now known as 'javascript forms' or 'jsforms', not AJAX forms, because they're not using AJAX. A bunch of the callbacks have been renamed based on this. * Support has been added for a PHP callback if a form fails to validate, and a javascript callback if the returnCode is not recognised. * Some function calls were changed to use call_user_func_array, which allows the possibility that they're not just strings (i.e. they could be class/method array pairs) * Reduced the number of parameters for json_reply to two, now the 'errors' index of the 'message' data holds any errors specific to form elements. * The errors sent back will now be set for any nonzero return code. * Broke out the javascript for detecting which button was pressed last into its own method. * Unset the detected last pressed submit button just before the form callback finishes, which prevents randomness when pressing cancel buttons later * Made the get_errors method public, someone else may want access to it. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-23 13:13:02 UTC (rev 134) +++ pieforms-php5/trunk/src/pieform.php 2006-12-23 13:23:23 UTC (rev 135) @@ -73,7 +73,6 @@ // stuff much easier (form_validate_email, form_validate_date etc). // - Collapsible js for fieldsets // - Grippie for textareas - // - javascript validation (probably won't be done as ajax validation is pretty good) // - handle multipage forms? // - handle a tabbed interface type of form? // @@ -188,24 +187,86 @@ // Assign defaults for the form $formdefaults = array( - 'method' => 'get', - 'action' => '', - 'elements' => array(), - 'renderer' => 'table', - 'ajaxform' => false, - 'preajaxsubmitcallback' => '', - 'postajaxsubmitcallback' => '', - 'ajaxsuccesscallback' => '', - 'ajaxfailurecallback' => '', - 'validate' => true, - 'submit' => true, + // The method used to submit the form, should always be 'get' or 'post' + 'method' => 'get', + + // The form target. The vast majority of the time this should be blank, + // as the functions that handle the submit should be in the same script + // as the form definition + 'action' => '', + + // The form elements + 'elements' => array(), + + // The form renderer (see the pieform/renderers directory) + 'renderer' => 'table', + + // Whether to validate the form. Non validated forms have none of the + // validate, success or error callbacks called on them + 'validate' => true, + + // Whether to process the submission of this form. The form will still + // be validated. Handy if the code handling the submission is elsewhere + 'submit' => true, + + // The PHP callback called to validate the form. Optional 'validatecallback' => '', - 'submitcallback' => '', - 'iscancellable' => true, + + // The PHP callback called to process the submission of the form. + // Required, unless a success function is provided for each submit + // button in the form + 'successcallback' => '', + + // The PHP callback called if there is any validation error. Optional + 'errorcallback' => '', + + // Whether this form should submit to a hidden iframe and use DOM + // manipulation to insert error messages (faster than a normal submit, + // supported in less browsers. Most modern browsers should be fine) + 'jsform' => false, + + // The javascript function called before submission of a form + // (regardless of whether the form is a jsform) + 'presubmitcallback' => '', + + // The javascript function called after submission of a form. As non-js + // forms will trigger a page load on submit, this has no effect for them. + 'postsubmitcallback' => '', + + // The javascript function called if the form submission was successful + 'jssuccesscallback' => '', + + // The javascript function called if the form submission was unsuccessful + 'jserrorcallback' => '', + + // The javascript function called if the form submission returned an + // unknown error code + 'globaljserrorcallback' => '', + + // Whether this form can be cancelled, regardless of the presence of + // 'cancel' buttons or form inputs mischeviously named as to behave + // like cancel buttons + 'iscancellable' => true, + + // Whether to auto-focus either the first field (if the value is true, + // or the named field (if the value is a string) when the form is + // displayed. If this has any value other than false and the form has + // been submitted with an error, the first field with an error will + // be focussed. 'autofocus' => false, + + // The directories to search for additional elements, renderers and + // rules 'configdirs' => array(), + + // The language to use for any form strings, such as those found in + // rules. 'language' => 'en.utf8', + + // Any overriding language strings for rules 'rulei18n' => array(), + + // The tabindex for the form (managed automatically by Pieforms) 'tabindex' => false ); $data = array_merge($formdefaults, $formconfig, $data); @@ -218,7 +279,7 @@ } // Make sure that the javascript callbacks are valid - if ($this->data['ajaxform']) { + if ($this->data['jsform']) { $this->validate_js_callbacks(); } @@ -226,8 +287,8 @@ $this->data['validatecallback'] = $this->name . '_validate'; } - if (!$this->data['submitcallback']) { - $this->data['submitcallback'] = $this->name . '_submit'; + if (!$this->data['successcallback']) { + $this->data['successcallback'] = $this->name . '_submit'; } $this->data['configdirs'] = array_map( @@ -405,7 +466,7 @@ if (!isset($element['goto'])) { throw new PieformException('Cancel element "' . $element['name'] . '" has no page to go to'); } - if ($this->data['ajaxform']) { + if ($this->data['jsform']) { $this->json_reply(PIEFORM_CANCEL, $element['goto']); } header('HTTP/1.1 303 See Other'); @@ -422,15 +483,15 @@ $this->validate($values); // Then user specific validation if a function is available for that $function = $this->data['validatecallback']; - if (function_exists($function)) { - $function($this, $values); + if (is_callable($function)) { + call_user_func_array($function, array($this, $values)); } // Submit the form if things went OK if ($this->data['submit'] && !$this->has_errors()) { $submitted = false; foreach ($this->get_elements() as $element) { - if (!empty($element['submitelement']) == true && isset($global[$element['name']])) { + if (!empty($element['submitelement']) && isset($global[$element['name']])) { $function = "{$this->name}_submit_{$element['name']}"; if (function_exists($function)) { $function($this, $values); @@ -439,13 +500,13 @@ } } } - $function = $this->data['submitcallback']; - if (!$submitted && function_exists($function)) { + $function = $this->data['successcallback']; + if (!$submitted && is_callable($function)) { // Call the user defined function for processing a submit // This function should really redirect/exit after it has // finished processing the form. // @todo maybe it should do just that... - $function($this, $values); + call_user_func_array($function, array($this, $values)); // This will only work if I can make the login_submit function stuff work in login_validate //if ($this->ajaxpost) { // $message = 'Your ' . $this->name . '_submit function should output some json and exit'; @@ -464,15 +525,21 @@ if ($this->data['autofocus'] !== false) { $this->auto_focus_first_error(); } + + // Call the user-defined PHP error function, if it exists + $function = $this->data['errorcallback']; + if (is_callable($function)) { + call_user_func_array($function, array($this)); + } - // If the form has been submitted by ajax, return ajax - if ($this->data['ajaxform']) { + // If the form has been submitted by javascript, return json + if ($this->data['jsform']) { $errors = $this->get_errors(); $json = array(); foreach ($errors as $element) { $json[$element['name']] = $element['error']; } - $this->json_reply(PIEFORM_ERR, '@todo allow forms to specify a local error message', $json); + $this->json_reply(PIEFORM_ERR, array('errors' => $json)); } } } @@ -580,9 +647,18 @@ $result .= "</form>\n"; } - if ($this->data['ajaxform']) { + if ($this->data['jsform'] || $this->data['presubmitcallback']) { $result .= '<script type="text/javascript">'; - $result .= "\n" . $this->submit_js(); + $result .= "\n" . $this->whichbutton_js(); + } + if ($this->data['jsform']) { + $result .= $this->submit_js(); + } + else if ($this->data['presubmitcallback']) { + $result .= 'connect(\'' . $this->name . '\', \'onsubmit\', ' + . 'function() { ' . $this->data['presubmitcallback'] . "('{$this->name}', {$this->name}_btn); });"; + } + if ($this->data['jsform'] || $this->data['presubmitcallback']) { $result .= "\n</script>\n"; } @@ -730,9 +806,7 @@ } } - private function submit_js() { - $strprocessingform = get_string('processingform'); - + private function whichbutton_js() { $result = "var {$this->name}_btn = null;\n"; $connecteventadded = false; @@ -742,20 +816,32 @@ $result .= "addLoadEvent(function() {\n"; $connecteventadded = true; } - $result .= " connect($('{$this->name}_{$element['name']}'), 'onclick', function() { {$this->name}_btn = '{$element['name']}'; });\n"; + if (!empty($element['cancelelement'])) { + $cancelstr = 'cancel_'; + } + else { + $cancelstr = ''; + } + $result .= " connect($('{$cancelstr}{$this->name}_{$element['name']}'), 'onclick', function() { {$this->name}_btn = '{$cancelstr}{$this->name}_{$element['name']}'; });\n"; } } if ($connecteventadded) { $result .= "});\n"; } - $result .= <<<EOF + return $result; + } + + private function submit_js() { + $strprocessingform = get_string('processingform'); + + $result = <<<EOF connect($('{$this->name}'), 'onsubmit', function(e) { if (typeof(tinyMCE) != 'undefined') { tinyMCE.triggerSave(); } EOF; - if (!empty($this->data['preajaxsubmitcallback'])) { - $result .= " {$this->data['preajaxsubmitcallback']}();\n"; + if (!empty($this->data['presubmitcallback'])) { + $result .= " {$this->data['presubmitcallback']}('{$this->name}', {$this->name}_btn);\n"; } $result .= <<<EOF @@ -770,60 +856,78 @@ insertSiblingNodesAfter($('{$this->name}'), iframe); window.pieformHandler_{$this->name} = function(data) { - {$this->name}_remove_all_errors(); + +EOF; + if (isset($this->data['processingstopcallback'])) { + $result .= " {$this->data['processingstopcallback']}('{$this->name}', {$this->name}_btn);\n"; + } + + $result .= <<<EOF evalJSONRequest(data); if (data.returnCode == 0) { + {$this->name}_remove_all_errors(); // The request completed successfully - {$this->name}_message(data.message, 'ok'); EOF; - - if (!empty($this->data['ajaxsuccesscallback'])) { - $result .= " {$this->data['ajaxsuccesscallback']}(data);\n"; + if (!empty($this->data['jssuccesscallback'])) { + $result .= " {$this->data['jssuccesscallback']}('{$this->name}', data);\n"; } - $result .= <<<EOF } - else if (data.returnCode == 1) { - // The request failed validation - {$this->name}_message(data.message, 'error'); - for (error in data.errors) { - {$this->name}_set_error(data.errors[error], error); + else { + // Redirect if the form is being cancelled + if (data.returnCode == 2) { + window.location = data.message; + return; } + + // Set errors if there are any + {$this->name}_remove_all_errors(); + if (data.message.errors) { + for (error in data.message.errors) { + {$this->name}_set_error(data.message.errors[error], error); + } + } + if (data.returnCode == 1) { + // The request failed validation + EOF; - if (!empty($this->data['ajaxfailurecallback'])) { - $result .= " {$this->data['ajaxfailurecallback']}(data);\n"; + // @todo: renumber the PIEFORM_* flags to be 0, -1, -2 to allow users to have the positive numbers to themselves + if (!empty($this->data['jserrorcallback'])) { + $result .= " {$this->data['jserrorcallback']}('{$this->name}', data);\n"; } $result .= <<<EOF + } + else { + // A return code we don't know about + +EOF; + if (!empty($this->data['globaljserrorcallback'])) { + $result .= " {$this->data['globaljserrorcallback']}('{$this->name}', data);\n"; + } + else { + $result .= " alert('Developer: got error code ' + data.returnCode + + ', either fix your form to not use this code or define a global js error handler');\n"; + } + $result .= <<<EOF + } } - else if (data.returnCode == 2) { - window.location = data.message; - } - else { - // A return code we don't know about - // @todo call some predefined function passing the data - alert('an unknown error occured (if you are a mahara dev, see Nigel)'); - } EOF; - if (!empty($this->data['postajaxsubmitcallback'])) { - $result .= " {$this->data['postajaxsubmitcallback']}();\n"; + if (!empty($this->data['postsubmitcallback'])) { + $result .= " {$this->data['postsubmitcallback']}('{$this->name}', {$this->name}_btn);\n"; } $result .= <<<EOF + {$this->name}_btn = null; } } - if ({$this->name}_btn) { - {$this->name}_message('{$strprocessingform}', 'info'); - } -}); - - EOF; + $result .= "});\n\n"; $function = 'pieform_renderer_' . $this->data['renderer'] . '_messages_js'; if (!function_exists($function)) { throw new PieformException('No renderer message function "' . $function . '"'); @@ -832,14 +936,11 @@ return $result . $function($this->name); } - public function json_reply($returncode, $message=null, $errors=null) { + public function json_reply($returncode, $message=null) { $data = array( 'returnCode' => intval($returncode), 'message' => $message ); - if ($errors) { - $data['errors'] = $errors; - } $result = json_encode($data); echo <<<EOF @@ -1117,11 +1218,12 @@ } /** - * Makes sure that the ajax callbacks for this form are valid javascript + * Makes sure that the javascript callbacks for this form are valid javascript * function names. */ private function validate_js_callbacks() { - foreach (array('preajaxsubmitcallback', 'postajaxsubmitcallback', 'ajaxsuccesscallback', 'ajaxfailurecallback') as $callback) { + foreach (array('presubmitcallback', 'postsubmitcallback', 'jssuccesscallback', + 'jserrorcallback', 'globaljserrorcallback') as $callback) { if ($this->data[$callback] != '' && !preg_match('/^[a-zA-Z][a-zA-Z0-9_]*$/', $this->data[$callback])) { throw new PieformException("'{$this->data[$callback]}' is not a valid javascript callback name for callback '$callback'"); } @@ -1134,7 +1236,7 @@ * @return array An array of elements with errors on them, the empty array * in the result of no errors. */ - private function get_errors() { + public function get_errors() { $result = array(); foreach ($this->get_elements() as $element) { if (isset($element['error'])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 13:13:06
|
Revision: 134 http://svn.sourceforge.net/pieforms/?rev=134&view=rev Author: oracleshinoda Date: 2006-12-23 05:13:02 -0800 (Sat, 23 Dec 2006) Log Message: ----------- Removed the messages functions, they are no longer needed. The function itself will later be renamed Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/table.php Modified: pieforms-php5/trunk/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-23 05:13:18 UTC (rev 133) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-23 13:13:02 UTC (rev 134) @@ -124,22 +124,6 @@ removeElementClass(item.firstChild, 'error'); }); } -function {$id}_message(message, type) { - var elem = $('{$id}_pieform_message'); - var msg = TR({'id': '{$id}_pieform_message'}, TD({'colspan': 2, 'class': type}, message)); - if (elem) { - swapDOM(elem, msg); - } - else if ({$id}_btn) { - insertSiblingNodesAfter($('{$id}_' + {$id}_btn + '_container'), msg); - } -} -function {$id}_remove_message() { - var elem = $('{$id}_pieform_message'); - if (elem) { - removeElement(elem); - } -} EOF; return $result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:13:18
|
Revision: 133 http://svn.sourceforge.net/pieforms/?rev=133&view=rev Author: oracleshinoda Date: 2006-12-22 21:13:18 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Removed mahara-isms that would have prevented anyone else from using it from svnhead Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-23 05:10:44 UTC (rev 132) +++ pieforms-php5/trunk/src/pieform.php 2006-12-23 05:13:18 UTC (rev 133) @@ -674,7 +674,6 @@ private function get_submitted_values() { $result = array(); $global = ($this->data['method'] == 'get') ? $_GET : $_POST; - log_debug($global); foreach ($this->get_elements() as $element) { if ($element['type'] != 'markup') { if ( @@ -842,7 +841,6 @@ $data['errors'] = $errors; } $result = json_encode($data); - log_debug($result); echo <<<EOF <html><head><script type="text/javascript">function sendResult() { parent.pieformHandler_{$this->name}($result); }</script></head><body onload="sendResult(); "></body></html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:10:44
|
Revision: 132 http://svn.sourceforge.net/pieforms/?rev=132&view=rev Author: oracleshinoda Date: 2006-12-22 21:10:44 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Make sure the 'error' class is removed from elements when all errors are being removed Modified Paths: -------------- pieforms-php5/trunk/src/pieform/renderers/table.php Modified: pieforms-php5/trunk/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-23 05:09:20 UTC (rev 131) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2006-12-23 05:10:44 UTC (rev 132) @@ -119,6 +119,10 @@ forEach(getElementsByTagAndClassName('TD', 'errmsg', $('$id')), function(item) { removeElement(item.parentNode); }); + forEach(getElementsByTagAndClassName('TD', 'error', $('$id')), function(item) { + removeElementClass(item, 'error'); + removeElementClass(item.firstChild, 'error'); + }); } function {$id}_message(message, type) { var elem = $('{$id}_pieform_message'); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:09:19
|
Revision: 131 http://svn.sourceforge.net/pieforms/?rev=131&view=rev Author: oracleshinoda Date: 2006-12-22 21:09:20 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Fix silly parse error Modified Paths: -------------- pieforms-php5/trunk/src/pieform/rules/required.php Modified: pieforms-php5/trunk/src/pieform/rules/required.php =================================================================== --- pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-23 05:07:25 UTC (rev 130) +++ pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-23 05:09:20 UTC (rev 131) @@ -35,8 +35,7 @@ */ function pieform_rule_required(Pieform $form, $value, $element, $check) { if ($check && $value == '') { - return $form->i18n('rule', 'required', 'required', $element); - } + return $form->i18n('rule', 'required', 'required', $element); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:07:24
|
Revision: 130 http://svn.sourceforge.net/pieforms/?rev=130&view=rev Author: oracleshinoda Date: 2006-12-22 21:07:25 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Removed the references to form_is_empty_ in the required rule, there's a more generic way to do this now Modified Paths: -------------- pieforms-php5/trunk/src/pieform/rules/required.php Modified: pieforms-php5/trunk/src/pieform/rules/required.php =================================================================== --- pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-23 05:06:21 UTC (rev 129) +++ pieforms-php5/trunk/src/pieform/rules/required.php 2006-12-23 05:07:25 UTC (rev 130) @@ -34,16 +34,7 @@ * @return string The error message, if the value is invalid. */ function pieform_rule_required(Pieform $form, $value, $element, $check) { - if ($check) { - $function = 'form_is_empty_' . $element['type']; - if (function_exists($function)) { - if ($function($value, $element)) { - return $form->i18n('rule', 'required', 'required', $element); - } - return; - } - - if ($value == '') { + if ($check && $value == '') { return $form->i18n('rule', 'required', 'required', $element); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:06:21
|
Revision: 129 http://svn.sourceforge.net/pieforms/?rev=129&view=rev Author: oracleshinoda Date: 2006-12-22 21:06:21 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Cancel element now identifies itself as such Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/cancel.php Modified: pieforms-php5/trunk/src/pieform/elements/cancel.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 05:05:49 UTC (rev 128) +++ pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 05:06:21 UTC (rev 129) @@ -47,7 +47,7 @@ } function pieform_element_cancel_set_attributes($element) { - $element['submitelement'] = true; + $element['cancelelement'] = true; return $element; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:05:52
|
Revision: 128 http://svn.sourceforge.net/pieforms/?rev=128&view=rev Author: oracleshinoda Date: 2006-12-22 21:05:49 -0800 (Fri, 22 Dec 2006) Log Message: ----------- pieform_is_empty_file is not needed anymore, the get_value stuff has been doing this for a while so the 'required' rule is behaving correctly Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/file.php Modified: pieforms-php5/trunk/src/pieform/elements/file.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/file.php 2006-12-23 05:03:37 UTC (rev 127) +++ pieforms-php5/trunk/src/pieform/elements/file.php 2006-12-23 05:05:49 UTC (rev 128) @@ -45,11 +45,4 @@ } } -function pieform_is_empty_file($value, $element) { - if (isset($_FILES[$element['name']]) && !$_FILES[$element['name']]['error']) { - return false; - } - return true; -} - ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 05:03:38
|
Revision: 127 http://svn.sourceforge.net/pieforms/?rev=127&view=rev Author: oracleshinoda Date: 2006-12-22 21:03:37 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Added a new flag, 'cancelelement', so that erraneous javascript is not added for them, and their value can still be quashed when the post data is sent. Also, allow elements to specify a function that describes how a rule applies to them, which can be very useful when the way that the rule works is 'almost' right, but you don't want to make a new rule Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-23 04:35:31 UTC (rev 126) +++ pieforms-php5/trunk/src/pieform.php 2006-12-23 05:03:37 UTC (rev 127) @@ -677,8 +677,13 @@ log_debug($global); foreach ($this->get_elements() as $element) { if ($element['type'] != 'markup') { - if (empty($element['submitelement']) || - !empty($element['submitelement']) && isset($global[$element['name']])) { + if ( + (empty($element['submitelement']) && empty($element['cancelelement'])) || + ( + (!empty($element['submitelement']) || !empty($element['cancelelement'])) + && isset($global[$element['name']]) + ) + ) { $result[$element['name']] = $this->get_value($element); } } @@ -704,12 +709,17 @@ if (isset($element['rules']) && is_array($element['rules'])) { foreach ($element['rules'] as $rule => $data) { if (!$this->get_error($element['name'])) { - // Get the rule - $function = 'pieform_rule_' . $rule; + // See if this element has a function that describes + // how this rule should apply to it + $function = 'pieform_element_' . $element['name'] . '_rule_' . $rule; if (!function_exists($function)) { - $this->include_plugin('rule', $rule); + // Try instead the default rule function + $function = 'pieform_rule_' . $rule; if (!function_exists($function)) { - throw new PieformException('No such form rule "' . $rule . '"'); + $this->include_plugin('rule', $rule); + if (!function_exists($function)) { + throw new PieformException('No such form rule "' . $rule . '"'); + } } } if ($error = $function($this, $values[$element['name']], $element, $data)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 04:35:33
|
Revision: 126 http://svn.sourceforge.net/pieforms/?rev=126&view=rev Author: oracleshinoda Date: 2006-12-22 20:35:31 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Renamed the 'ajaxmessages' flag to 'submitelement', as it's used for more than just where to put ajax submit messages Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/cancel.php pieforms-php5/trunk/src/pieform/elements/image.php pieforms-php5/trunk/src/pieform/elements/submit.php pieforms-php5/trunk/src/pieform/elements/submitcancel.php pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform/elements/cancel.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 04:09:58 UTC (rev 125) +++ pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 04:35:31 UTC (rev 126) @@ -47,7 +47,7 @@ } function pieform_element_cancel_set_attributes($element) { - $element['ajaxmessages'] = true; + $element['submitelement'] = true; return $element; } Modified: pieforms-php5/trunk/src/pieform/elements/image.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/image.php 2006-12-23 04:09:58 UTC (rev 125) +++ pieforms-php5/trunk/src/pieform/elements/image.php 2006-12-23 04:35:31 UTC (rev 126) @@ -44,7 +44,7 @@ } function pieform_element_image_set_attributes($element) { - $element['ajaxmessages'] = true; + $element['submitelement'] = true; return $element; } Modified: pieforms-php5/trunk/src/pieform/elements/submit.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/submit.php 2006-12-23 04:09:58 UTC (rev 125) +++ pieforms-php5/trunk/src/pieform/elements/submit.php 2006-12-23 04:35:31 UTC (rev 126) @@ -38,7 +38,7 @@ } function pieform_element_submit_set_attributes($element) { - $element['ajaxmessages'] = true; + $element['submitelement'] = true; return $element; } Modified: pieforms-php5/trunk/src/pieform/elements/submitcancel.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/submitcancel.php 2006-12-23 04:09:58 UTC (rev 125) +++ pieforms-php5/trunk/src/pieform/elements/submitcancel.php 2006-12-23 04:35:31 UTC (rev 126) @@ -46,7 +46,7 @@ } function pieform_element_submitcancel_set_attributes($element) { - $element['ajaxmessages'] = true; + $element['submitelement'] = true; return $element; } Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-23 04:09:58 UTC (rev 125) +++ pieforms-php5/trunk/src/pieform.php 2006-12-23 04:35:31 UTC (rev 126) @@ -430,8 +430,7 @@ if ($this->data['submit'] && !$this->has_errors()) { $submitted = false; foreach ($this->get_elements() as $element) { - // @todo Rename 'ajaxmessages' to 'submitelement' - if (!empty($element['ajaxmessages']) == true && isset($global[$element['name']])) { + if (!empty($element['submitelement']) == true && isset($global[$element['name']])) { $function = "{$this->name}_submit_{$element['name']}"; if (function_exists($function)) { $function($this, $values); @@ -678,8 +677,8 @@ log_debug($global); foreach ($this->get_elements() as $element) { if ($element['type'] != 'markup') { - if (empty($element['ajaxmessages']) || - !empty($element['ajaxmessages']) && isset($global[$element['name']])) { + if (empty($element['submitelement']) || + !empty($element['submitelement']) && isset($global[$element['name']])) { $result[$element['name']] = $this->get_value($element); } } @@ -729,7 +728,7 @@ $connecteventadded = false; foreach ($this->get_elements() as $element) { - if (!empty($element['ajaxmessages'])) { + if (!empty($element['submitelement'])) { if (!$connecteventadded) { $result .= "addLoadEvent(function() {\n"; $connecteventadded = true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 04:09:58
|
Revision: 125 http://svn.sourceforge.net/pieforms/?rev=125&view=rev Author: oracleshinoda Date: 2006-12-22 20:09:58 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Updated to use new APIs. Now responds to 'defaultvalue' instead of 'checked', like most other elements Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/checkbox.php Modified: pieforms-php5/trunk/src/pieform/elements/checkbox.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/checkbox.php 2006-12-23 04:09:15 UTC (rev 124) +++ pieforms-php5/trunk/src/pieform/elements/checkbox.php 2006-12-23 04:09:58 UTC (rev 125) @@ -27,21 +27,20 @@ /** * Provides a basic checkbox input. * - * @param array $element The element to render * @param Pieform $form The form to render the element for + * @param array $element The element to render * @return string The HTML for the element */ -function pieform_render_checkbox($element, Pieform $form) { +function pieform_element_checkbox(Pieform $form, $element) { $checked = false; - // @todo use of 'value' and 'checked' here is ambiguous, need to write - // test cases and pick just one of them if (!empty($element['value'])) { $checked = true; } - if ($form->get_value($element)) { + $global = ($form->get_property('method') == 'get') ? $_GET : $_POST; + if (isset($global[$element['name']])) { $checked = true; } - else if (!$form->is_submitted() && !empty($element['checked'])) { + else if (!$form->is_submitted() && !empty($element['defaultvalue'])) { $checked = true; } @@ -51,16 +50,4 @@ . '>'; } -function pieform_get_value_js_checkbox($element, Pieform $form) { - $formname = $form->get_name(); - $name = $element['name']; - return <<<EOF - if (document.forms['$formname'].elements['$name'].checked) { - data['$name'] = 'on'; - } - -EOF; -} - - ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-23 04:09:14
|
Revision: 124 http://svn.sourceforge.net/pieforms/?rev=124&view=rev Author: oracleshinoda Date: 2006-12-22 20:09:15 -0800 (Fri, 22 Dec 2006) Log Message: ----------- Updated to use new APIs. Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/cancel.php pieforms-php5/trunk/src/pieform/elements/text.php Modified: pieforms-php5/trunk/src/pieform/elements/cancel.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 04:08:19 UTC (rev 123) +++ pieforms-php5/trunk/src/pieform/elements/cancel.php 2006-12-23 04:09:15 UTC (rev 124) @@ -29,11 +29,11 @@ * normal submit buttons, only their name is changed (for use by the Pieform * class internally). * - * @param array $element The element to render * @param Pieform $form The form to render the element for + * @param array $element The element to render * @return string The HTML for the element */ -function pieform_render_cancel($element, Pieform $form) { +function pieform_element_cancel(Pieform $form, $element) { if (!isset($element['value'])) { throw new PieformException('Cancel elements must have a value'); } @@ -46,14 +46,9 @@ . ' value="' . Pieform::hsc($element['value']) . '">'; } -// @todo how to support cancel buttons for ajax post? Possibly do a full post regardless... -// or allow the user to specify a javascript function to run... it could do document.location= -// @todo also, cancel buttons don't need to be sent around via js... maybe make this return empty string -function pieform_get_value_js_cancel($element, Pieform $form) { - //$formname = $form->get_name(); - //$name = $element['name']; - //return " data['{$name}_cancel'] = document.forms['$formname'].elements['{$name}_cancel'].value;\n"; - return ''; +function pieform_element_cancel_set_attributes($element) { + $element['ajaxmessages'] = true; + return $element; } ?> Modified: pieforms-php5/trunk/src/pieform/elements/text.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/text.php 2006-12-23 04:08:19 UTC (rev 123) +++ pieforms-php5/trunk/src/pieform/elements/text.php 2006-12-23 04:09:15 UTC (rev 124) @@ -27,11 +27,11 @@ /** * Provides a basic text field input. * + * @param Pieform $form The form to render the element for * @param array $element The element to render - * @param Pieform $form The form to render the element for * @return string The HTML for the element */ -function pieform_render_text($element, $form) { +function pieform_element_text(Pieform $form, $element) { return '<input type="text"' . $form->element_attributes($element) . ' value="' . Pieform::hsc($form->get_value($element)) . '">'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |