pieforms-commit Mailing List for Pieforms (Page 7)
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...> - 2007-02-04 22:38:39
|
Revision: 173 http://svn.sourceforge.net/pieforms/?rev=173&view=rev Author: oracleshinoda Date: 2007-02-04 14:38:38 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Corrected spelling of 'collapsible'. Inform the user if a collapsible fieldset does not have a legend Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/fieldset.php Modified: pieforms-php5/trunk/src/pieform/elements/fieldset.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/fieldset.php 2007-01-25 23:11:58 UTC (rev 172) +++ pieforms-php5/trunk/src/pieform/elements/fieldset.php 2007-02-04 22:38:38 UTC (rev 173) @@ -34,8 +34,11 @@ */ function pieform_element_fieldset(Pieform $form, $element) { $result = "\n<fieldset"; - if (!empty($element['collapsable'])) { - $classes = array('collapsable'); + if (!empty($element['collapsible'])) { + if (!isset($element['legend']) || $element['legend'] === '') { + Pieform::info('Collapsible fieldsets should have a legend so they can be toggled'); + } + $classes = array('collapsible'); // Work out whether any of the children have errors on them $error = false; foreach ($element['elements'] as $subelement) { @@ -52,7 +55,7 @@ $result .= ">\n"; if (isset($element['legend'])) { $result .= '<legend'; - if (!empty($element['collapsable'])) { + if (!empty($element['collapsible'])) { $id = substr(md5(microtime()), 0, 4); $result .= ' id="' . $id . '">'; $result .= '<script type="text/javascript">'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-25 23:11:58
|
Revision: 172 http://svn.sourceforge.net/pieforms/?rev=172&view=rev Author: oracleshinoda Date: 2007-01-25 15:11:58 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Added 'confirm' to submit elements - giving a javascript confirmation dialog when clicked. (Martyn Smith) Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/submit.php Modified: pieforms-php5/trunk/src/pieform/elements/submit.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/submit.php 2007-01-20 08:05:44 UTC (rev 171) +++ pieforms-php5/trunk/src/pieform/elements/submit.php 2007-01-25 23:11:58 UTC (rev 172) @@ -32,6 +32,10 @@ * @return string The HTML for the element */ function pieform_element_submit(Pieform $form, $element) { + if (isset($element['confirm'])) { + $element['onclick'] = 'return confirm(' . json_encode($element['confirm']) . ');'; + } + return '<input type="submit"' . $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. |
From: <ora...@us...> - 2007-01-20 08:05:45
|
Revision: 171 http://svn.sourceforge.net/pieforms/?rev=171&view=rev Author: oracleshinoda Date: 2007-01-20 00:05:44 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Added an element to get a size in bytes. It allows the user to select kilobytes or megabytes as units as well Added Paths: ----------- pieforms-php5/trunk/src/pieform/elements/bytes.php Added: pieforms-php5/trunk/src/pieform/elements/bytes.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/bytes.php (rev 0) +++ pieforms-php5/trunk/src/pieform/elements/bytes.php 2007-01-20 08:05:44 UTC (rev 171) @@ -0,0 +1,151 @@ +<?php +/** + * This program is part of Pieforms + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * @package pieform + * @subpackage element + * @author Martyn Smith <ma...@ca...> + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL + * @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz + * + */ + +/** + * Provides a size chooser, with a text box for a number and a + * select box to choose the units, in bytes, kilobytes, or megabytes + * + * @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_element_bytes(Pieform $form, $element) { + $formname = $form->get_name(); + $result = ''; + $name = $element['name']; + if (!isset($element['defaultvalue'])) { + $element['defaultvalue'] = null; + } + + $global = ($form->get_property('method') == 'get') ? $_GET : $_POST; + + // Get the value of the element for rendering. + if (isset($element['value'])) { + $bytes = $element['value']; + $values = pieform_element_bytes_get_bytes_from_bytes($element['value']); + } + else if (isset($global[$element['name']]) + && isset($global[$element['name'] . '_units'])) { + $values = array('number' => $global[$element['name']], + 'units' => $global[$element['name'] . '_units']); + $bytes = $values['number'] * pieform_element_bytes_in($values['units']); + } + else if (isset($element['defaultvalue'])) { + $bytes = $element['defaultvalue']; + $values = pieform_element_bytes_get_bytes_from_bytes($bytes); + } + else { + $values = array('number' => '0', 'units' => 'bytes'); + $bytes = 0; + } + + // @todo probably create with an actual input element, as tabindex doesn't work here for one thing + // Same with the select. And do the events using mochikit signal instead of dom events + $numberinput = '<input'; + $numberinput .= ' type="text" size="8" 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="' . $formname . '_' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n"; + foreach (pieform_element_bytes_get_bytes_units() as $u) { + $uselect .= "\t<option value=\"$u\"" . (($values['units'] == $u) ? ' selected="selected"' : '') . '>' + . $form->i18n('element', 'bytes', $u, $element) . "</option>\n"; + } + $uselect .= "</select>\n"; + + return $numberinput . $uselect; +} + +/** + * Gets the value of the expiry element and converts it to a time in seconds. + * + * @param Pieform $form The form the element is attached to + * @param array $element The element to get the value for + * @return int The number of seconds until expiry + */ +function pieform_element_bytes_get_value(Pieform $form, $element) { + $name = $element['name']; + + $global = ($form->get_property('method') == 'get') ? $_GET : $_POST; + $unit = $global[$name . '_units']; + $allunits = pieform_element_bytes_get_bytes_units(); + $number = $global[$name]; + + if (!is_numeric($number)) { + $form->set_error($name, $form->i18n('element', 'bytes', 'invalidvalue', $element)); + } + + if (!in_array($unit,$allunits) || $number < 0) { + return null; + } + return $number * pieform_element_bytes_in($unit); +} + +function pieform_element_bytes_in($units) { + switch ($units) { + case 'megabytes': + return 1048576; + break; + case 'kilobytes': + return 1024; + break; + default: + return 1; + break; + }; +} + +function pieform_element_bytes_i18n() { + return array( + 'en.utf8' => array( + 'bytes' => 'Bytes', + 'kilobytes' => 'Kilobytes', + 'megabytes' => 'Megabytes', + 'invalidvalue' => 'Value must be a number', + ), + ); +} + +function pieform_element_bytes_get_bytes_units() { + return array('bytes', 'kilobytes', 'megabytes'); +} + +function pieform_element_bytes_get_bytes_from_bytes($bytes) { + if ($bytes == null) { + return array('number' => '0', 'units' => 'bytes'); + } + + foreach (array('megabytes', 'kilobytes') as $units) { + if ( $bytes > pieform_element_bytes_in($units) ) { + return array('number' => $bytes / pieform_element_bytes_in($units) , 'units' => $units); + } + } + + return array('number' => $bytes, 'units' => 'bytes'); +} + +?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-20 08:03:37
|
Revision: 170 http://svn.sourceforge.net/pieforms/?rev=170&view=rev Author: oracleshinoda Date: 2007-01-20 00:03:36 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Use the type of the element instead of the name when working out the custom rule function Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-01-20 08:03:05 UTC (rev 169) +++ pieforms-php5/trunk/src/pieform.php 2007-01-20 08:03:36 UTC (rev 170) @@ -815,7 +815,7 @@ if (!$this->get_error($element['name'])) { // See if this element has a function that describes // how this rule should apply to it - $function = 'pieform_element_' . $element['name'] . '_rule_' . $rule; + $function = 'pieform_element_' . $element['type'] . '_rule_' . $rule; if (!function_exists($function)) { // Try instead the default rule function $function = 'pieform_rule_' . $rule; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-20 08:03:04
|
Revision: 169 http://svn.sourceforge.net/pieforms/?rev=169&view=rev Author: oracleshinoda Date: 2007-01-20 00:03:05 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Re-added missing get_value function that actually works, so that checkboxes behave normally 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 2007-01-20 08:02:11 UTC (rev 168) +++ pieforms-php5/trunk/src/pieform/elements/checkbox.php 2007-01-20 08:03:05 UTC (rev 169) @@ -50,4 +50,26 @@ . '>'; } +function pieform_element_checkbox_get_value(Pieform $form, $element) { + $name = $element['name']; + $global = ($form->get_property('method') == 'get') ? $_GET : $_POST; + + if (isset($element['value'])) { + return $element['value']; + } + + if ($form->is_submitted()) { + if(isset($global[$name])) { + return true; + } + return false; + } + + if (isset($element['defaultvalue'])) { + return $element['defaultvalue']; + } + + return false; +} + ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-20 08:02:14
|
Revision: 168 http://svn.sourceforge.net/pieforms/?rev=168&view=rev Author: oracleshinoda Date: 2007-01-20 00:02:11 -0800 (Sat, 20 Jan 2007) Log Message: ----------- Allow the entries to be keyed by 'key' instead of title, just in case the title is not unique for some reason 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 2007-01-11 09:48:45 UTC (rev 167) +++ pieforms-php5/trunk/src/pieform/renderers/multicolumntable.php 2007-01-20 08:02:11 UTC (rev 168) @@ -102,14 +102,18 @@ 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(); - $this->elements[$rawelement['title']]['builtelements'] = array(); - $this->elements[$rawelement['title']]['settings'] = $rawelement; + + if (!isset($rawelement['key'])) { + $rawelement['key'] = $rawelement['title']; } - $this->elements[$rawelement['title']]['rawelements'][] = $rawelement; - $this->elements[$rawelement['title']]['builtelements'][] = $builtelement; + if (!array_key_exists($rawelement['key'], $this->elements)) { + $this->elements[$rawelement['key']] = array(); + $this->elements[$rawelement['key']]['rawelements'] = array(); + $this->elements[$rawelement['key']]['builtelements'] = array(); + $this->elements[$rawelement['key']]['settings'] = $rawelement; + } + $this->elements[$rawelement['key']]['rawelements'][] = $rawelement; + $this->elements[$rawelement['key']]['builtelements'][] = $builtelement; } function set_form(Pieform $form) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-11 09:48:45
|
Revision: 167 http://svn.sourceforge.net/pieforms/?rev=167&view=rev Author: oracleshinoda Date: 2007-01-11 01:48:45 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Merged changes from trunk Modified Paths: -------------- pieforms-php5/branches/0.2.0/src/pieform.php pieforms-php5/branches/0.2.0/src/static/core/pieforms.js Modified: pieforms-php5/branches/0.2.0/src/pieform.php =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform.php 2007-01-11 09:42:55 UTC (rev 166) +++ pieforms-php5/branches/0.2.0/src/pieform.php 2007-01-11 09:48:45 UTC (rev 167) @@ -285,7 +285,10 @@ 'rulei18n' => array(), // The tabindex for the form (managed automatically by Pieforms) - 'tabindex' => false + 'tabindex' => false, + + // Whether to add a class of the type of the element to each element + 'elementclasses' => false ); $data = array_merge($formdefaults, $formconfig, $data); $this->data = $data; @@ -1049,7 +1052,7 @@ * @param array $element The element to make an ID for * @return string The ID for the element */ - public static function make_id($element) { + public function make_id($element) { if (isset($element['id'])) { return self::hsc($element['id']); } @@ -1071,7 +1074,7 @@ * @param array $element The element to make a class for * @return string The class for an element */ - public static function make_class($element) { + public function make_class($element) { $classes = array(); if (isset($element['class'])) { $classes[] = $element['class']; @@ -1082,6 +1085,9 @@ if (!empty($element['error'])) { $classes[] = 'error'; } + if ($this->data['elementclasses']) { + $classes[] = $element['type']; + } // Please make sure that 'autofocus' is the last class added in this // method. Otherwise, improve the logic for removing 'autofocus' from // the elemnt class string in pieform_render_element @@ -1336,8 +1342,8 @@ throw new PieformException('No such form renderer function: "' . $rendererfunction . '"'); } - $element['id'] = Pieform::make_id($element); - $element['class'] = Pieform::make_class($element); + $element['id'] = $form->make_id($element); + $element['class'] = $form->make_class($element); $builtelement = $function($form, $element); // Remove the 'autofocus' class, because we only want it on the form input Modified: pieforms-php5/branches/0.2.0/src/static/core/pieforms.js =================================================================== --- pieforms-php5/branches/0.2.0/src/static/core/pieforms.js 2007-01-11 09:42:55 UTC (rev 166) +++ pieforms-php5/branches/0.2.0/src/static/core/pieforms.js 2007-01-11 09:48:45 UTC (rev 167) @@ -60,7 +60,7 @@ this.grippie.dimensions = getElementDimensions(this.grippie); // Set wrapper and textarea dimensions - setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1}); + setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1, 'w': this.dimensions.w}); setStyle(this.element, { 'margin-bottom': '0', 'width': '100%', @@ -82,7 +82,6 @@ this.grippie.style.width = '100%'; this.grippie.style.paddingLeft = '2px'; setStyle(this.grippie, { - 'width': '100%', 'padding-left': '2px' }); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-11 09:42:54
|
Revision: 166 http://svn.sourceforge.net/pieforms/?rev=166&view=rev Author: oracleshinoda Date: 2007-01-11 01:42:55 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Set the width of the wrapper to match the correct width, so that the grippie doesn't have to force the textarea to have 100% width Modified Paths: -------------- pieforms-php5/trunk/src/static/core/pieforms.js Modified: pieforms-php5/trunk/src/static/core/pieforms.js =================================================================== --- pieforms-php5/trunk/src/static/core/pieforms.js 2007-01-11 09:42:12 UTC (rev 165) +++ pieforms-php5/trunk/src/static/core/pieforms.js 2007-01-11 09:42:55 UTC (rev 166) @@ -60,7 +60,7 @@ this.grippie.dimensions = getElementDimensions(this.grippie); // Set wrapper and textarea dimensions - setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1}); + setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1, 'w': this.dimensions.w}); setStyle(this.element, { 'margin-bottom': '0', 'width': '100%', @@ -82,7 +82,6 @@ this.grippie.style.width = '100%'; this.grippie.style.paddingLeft = '2px'; setStyle(this.grippie, { - 'width': '100%', 'padding-left': '2px' }); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-11 09:42:13
|
Revision: 165 http://svn.sourceforge.net/pieforms/?rev=165&view=rev Author: oracleshinoda Date: 2007-01-11 01:42:12 -0800 (Thu, 11 Jan 2007) Log Message: ----------- Added 'elementclasses' option - if set, then each element is given a class matching the type of element that it is Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-01-07 21:12:16 UTC (rev 164) +++ pieforms-php5/trunk/src/pieform.php 2007-01-11 09:42:12 UTC (rev 165) @@ -285,7 +285,10 @@ 'rulei18n' => array(), // The tabindex for the form (managed automatically by Pieforms) - 'tabindex' => false + 'tabindex' => false, + + // Whether to add a class of the type of the element to each element + 'elementclasses' => false ); $data = array_merge($formdefaults, $formconfig, $data); $this->data = $data; @@ -1049,7 +1052,7 @@ * @param array $element The element to make an ID for * @return string The ID for the element */ - public static function make_id($element) { + public function make_id($element) { if (isset($element['id'])) { return self::hsc($element['id']); } @@ -1071,7 +1074,7 @@ * @param array $element The element to make a class for * @return string The class for an element */ - public static function make_class($element) { + public function make_class($element) { $classes = array(); if (isset($element['class'])) { $classes[] = $element['class']; @@ -1082,6 +1085,9 @@ if (!empty($element['error'])) { $classes[] = 'error'; } + if ($this->data['elementclasses']) { + $classes[] = $element['type']; + } // Please make sure that 'autofocus' is the last class added in this // method. Otherwise, improve the logic for removing 'autofocus' from // the elemnt class string in pieform_render_element @@ -1336,8 +1342,8 @@ throw new PieformException('No such form renderer function: "' . $rendererfunction . '"'); } - $element['id'] = Pieform::make_id($element); - $element['class'] = Pieform::make_class($element); + $element['id'] = $form->make_id($element); + $element['class'] = $form->make_class($element); $builtelement = $function($form, $element); // Remove the 'autofocus' class, because we only want it on the form input This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-07 21:12:15
|
Revision: 164 http://svn.sourceforge.net/pieforms/?rev=164&view=rev Author: oracleshinoda Date: 2007-01-07 13:12:16 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Merged pieform_validate patch to 0.2.0 branch Modified Paths: -------------- pieforms-php5/branches/0.2.0/src/pieform.php Modified: pieforms-php5/branches/0.2.0/src/pieform.php =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform.php 2007-01-07 21:05:58 UTC (rev 163) +++ pieforms-php5/branches/0.2.0/src/pieform.php 2007-01-07 21:12:16 UTC (rev 164) @@ -499,11 +499,6 @@ $values = $this->get_submitted_values(); // Perform general validation first $this->validate($values); - // Then user specific validation if a function is available for that - $function = $this->data['validatecallback']; - 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()) { @@ -805,6 +800,12 @@ * @param array $values The submitted values from the form */ private function validate($values) { + // Call the overall validation function if it is available + if (function_exists('pieform_validate')) { + pieform_validate($this, $values); + } + + // Perform rule validation foreach ($this->get_elements() as $element) { if (isset($element['rules']) && is_array($element['rules'])) { foreach ($element['rules'] as $rule => $data) { @@ -829,6 +830,12 @@ } } } + + // Then user specific validation if a function is available for that + $function = $this->data['validatecallback']; + if (is_callable($function)) { + call_user_func_array($function, array($this, $values)); + } } private function whichbutton_js() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-07 21:06:04
|
Revision: 163 http://svn.sourceforge.net/pieforms/?rev=163&view=rev Author: oracleshinoda Date: 2007-01-07 13:05:58 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Added support for calling a global validation function pieform_validate for every form. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-01-07 20:40:21 UTC (rev 162) +++ pieforms-php5/trunk/src/pieform.php 2007-01-07 21:05:58 UTC (rev 163) @@ -499,11 +499,6 @@ $values = $this->get_submitted_values(); // Perform general validation first $this->validate($values); - // Then user specific validation if a function is available for that - $function = $this->data['validatecallback']; - 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()) { @@ -805,6 +800,12 @@ * @param array $values The submitted values from the form */ private function validate($values) { + // Call the overall validation function if it is available + if (function_exists('pieform_validate')) { + pieform_validate($this, $values); + } + + // Perform rule validation foreach ($this->get_elements() as $element) { if (isset($element['rules']) && is_array($element['rules'])) { foreach ($element['rules'] as $rule => $data) { @@ -829,6 +830,12 @@ } } } + + // Then user specific validation if a function is available for that + $function = $this->data['validatecallback']; + if (is_callable($function)) { + call_user_func_array($function, array($this, $values)); + } } private function whichbutton_js() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-07 20:40:23
|
Revision: 162 http://svn.sourceforge.net/pieforms/?rev=162&view=rev Author: oracleshinoda Date: 2007-01-07 12:40:21 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Fix whitespace on trunk Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-01-07 11:31:25 UTC (rev 161) +++ pieforms-php5/trunk/src/pieform.php 2007-01-07 20:40:21 UTC (rev 162) @@ -488,7 +488,8 @@ $this->json_reply(PIEFORM_CANCEL, $element['goto']); } header('HTTP/1.1 303 See Other'); - header('Location:' . $element['goto']); exit; + header('Location:' . $element['goto']); + exit; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-07 11:31:28
|
Revision: 161 http://svn.sourceforge.net/pieforms/?rev=161&view=rev Author: oracleshinoda Date: 2007-01-07 03:31:25 -0800 (Sun, 07 Jan 2007) Log Message: ----------- Whitespace change Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-01-02 11:06:04 UTC (rev 160) +++ pieforms-php5/trunk/src/pieform.php 2007-01-07 11:31:25 UTC (rev 161) @@ -488,8 +488,7 @@ $this->json_reply(PIEFORM_CANCEL, $element['goto']); } header('HTTP/1.1 303 See Other'); - header('Location:' . $element['goto']); - exit; + header('Location:' . $element['goto']); exit; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-02 11:06:05
|
Revision: 160 http://svn.sourceforge.net/pieforms/?rev=160&view=rev Author: oracleshinoda Date: 2007-01-02 03:06:04 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Created 0.2.0 stable branch. Added Paths: ----------- pieforms-php5/branches/0.2.0/ Copied: pieforms-php5/branches/0.2.0 (from rev 159, pieforms-php5/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-02 08:50:49
|
Revision: 159 http://svn.sourceforge.net/pieforms/?rev=159&view=rev Author: oracleshinoda Date: 2007-01-02 00:50:50 -0800 (Tue, 02 Jan 2007) Log Message: ----------- Tagged release 0.2.0 Added Paths: ----------- pieforms-php5/tags/0.2.0/ Copied: pieforms-php5/tags/0.2.0 (from rev 158, pieforms-php5/trunk) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-02 01:23:31
|
Revision: 158 http://svn.sourceforge.net/pieforms/?rev=158&view=rev Author: oracleshinoda Date: 2007-01-01 17:23:28 -0800 (Mon, 01 Jan 2007) Log Message: ----------- Added a changelog file Added Paths: ----------- pieforms-php5/trunk/CHANGELOG Added: pieforms-php5/trunk/CHANGELOG =================================================================== --- pieforms-php5/trunk/CHANGELOG (rev 0) +++ pieforms-php5/trunk/CHANGELOG 2007-01-02 01:23:28 UTC (rev 158) @@ -0,0 +1,8 @@ + Pieforms - Advanced web forms made easy + + Nigel McNie - http://nigel.mcnie.name/ + (C) 2006 Catalyst IT Ltd - http://catalyst.net.nz/ + +For a list of changes between versions, please see the sourceforge release +notes and changes for the release you have downloaded. This contains both a +summary and a full SVN changelog between each version. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-01-02 01:17:35
|
Revision: 157 http://svn.sourceforge.net/pieforms/?rev=157&view=rev Author: oracleshinoda Date: 2007-01-01 17:17:32 -0800 (Mon, 01 Jan 2007) Log Message: ----------- Updated documentation for 0.2 release Modified Paths: -------------- pieforms-php5/trunk/INSTALL pieforms-php5/trunk/README Added Paths: ----------- pieforms-php5/trunk/doc/index.html Modified: pieforms-php5/trunk/INSTALL =================================================================== --- pieforms-php5/trunk/INSTALL 2006-12-27 12:54:07 UTC (rev 156) +++ pieforms-php5/trunk/INSTALL 2007-01-02 01:17:32 UTC (rev 157) @@ -12,7 +12,7 @@ Pieforms does not require the JSON extension, as it can use Services_JSON (included). However, for optimal performance, it is recommended that you have the native JSON extension for PHP available. This does not apply if you do not -wish to use the AJAX form submission support. +wish to use the JS form submission support. Pieforms requires the Base, Iter, Style, DOM and Async modules of MochiKit for AJAX form submission support. A packed version of MochiKit containing just @@ -24,14 +24,13 @@ To install Pieforms: 1) Copy the 'pieform.php' file and the 'pieform' directory to somewhere in - your application's include path (later versions will remove the requirement - that Pieforms be in your include path). Also copy the 'JSON' directory to the + your application's directory structure. Also copy the 'JSON' directory to the same place if you do not have the JSON extension for PHP available and want - to use the AJAX form submission support. + to use the JS form submission support. - 2) If you wish to use the AJAX form submission support, copy the - 'MochiKit.js' file to wherever you are placing your javascript files for your - application. If you are already using MochiKit, you can skip this step. + 2) If you wish to use the more advanced javascript widgets and JS form + submission, copy the 'static' directory (or the contents of it) to some place + where your pages can link in the appropriate javascript files. And you're done! @@ -40,7 +39,13 @@ On any page where a Pieform is to be made: - * Make sure that the MochiKit javascript file is sourced by a <script> tag in the output of the page. + * Make sure that the MochiKit javascript file is sourced by a <script> tag in + the output of the page. + * Some more advanced widgets use pieforms.js. Make sure to include this also + if you're after this support * Include the 'pieform.php' file + * You need to call pieform_get_headdata() somewhere. This will return an array + of <script> tags, <link> tags and other things that need to go in the <head> + of your document somewhere. -- Nigel McNie <ni...@ca...> Modified: pieforms-php5/trunk/README =================================================================== --- pieforms-php5/trunk/README 2006-12-27 12:54:07 UTC (rev 156) +++ pieforms-php5/trunk/README 2007-01-02 01:17:32 UTC (rev 157) @@ -28,10 +28,10 @@ encapsulate a myriad of functionality all by themselves, and once written you can reuse them for any form you write. -Pieforms supports many advanced features, that are as easy to use as flicking -a switch. For example, change one flag and instantly your forms are submitted -by AJAX - validation still works fine, just your forms are submitted a whole -lot faster! +Pieforms supports many advanced features, that are as easy to use as flicking a +switch. For example, change one flag and instantly your forms are submitted by +a hidden iframe (JS form submission) - validation still works fine, just your +forms are submitted a whole lot faster! Currently, Pieforms is under heavy development, but gains new features and bugfixes almost every day. While releases will be made regularly, it's Added: pieforms-php5/trunk/doc/index.html =================================================================== --- pieforms-php5/trunk/doc/index.html (rev 0) +++ pieforms-php5/trunk/doc/index.html 2007-01-02 01:17:32 UTC (rev 157) @@ -0,0 +1,8 @@ +<html> + <head> + <title>Documentation</title> + </head> + <body> + <p>Pieforms documentation will be coming soon... for now check <a href="https://eduforge.org/wiki/wiki/mahara/wiki?pagename=FormAPI">the Mahara wiki</a>. It's a bit out of date, but I will be providing new documentation soon.</p> + </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-27 12:54:11
|
Revision: 156 http://svn.sourceforge.net/pieforms/?rev=156&view=rev Author: oracleshinoda Date: 2006-12-27 04:54:07 -0800 (Wed, 27 Dec 2006) Log Message: ----------- Allow forms to specify an error message for jsforms. This is a small helper that stops the need to define a _error function if you want to send an error back. The message is completely optional Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-27 12:49:27 UTC (rev 155) +++ pieforms-php5/trunk/src/pieform.php 2006-12-27 12:54:07 UTC (rev 156) @@ -250,6 +250,11 @@ // unknown error code 'globaljserrorcallback' => '', + // The message to pass back as a reason for the form submission failing + // if the form is a jsform. This can be used by your application however + // you choose. + 'jserrormessage' => '', + // Whether this form can be cancelled, regardless of the presence of // 'cancel' buttons or form inputs mischeviously named as to behave // like cancel buttons @@ -558,7 +563,8 @@ foreach ($errors as $element) { $json[$element['name']] = $element['error']; } - $this->json_reply(PIEFORM_ERR, array('errors' => $json)); + $message = $this->get_property('jserrormessage'); + $this->json_reply(PIEFORM_ERR, array('message' => $message, 'errors' => $json)); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 12:49:27
|
Revision: 155 http://svn.sourceforge.net/pieforms/?rev=155&view=rev Author: oracleshinoda Date: 2006-12-27 04:49:27 -0800 (Wed, 27 Dec 2006) Log Message: ----------- Changed the i18n function name for the email rule to be correct Modified Paths: -------------- pieforms-php5/trunk/src/pieform/rules/email.php Modified: pieforms-php5/trunk/src/pieform/rules/email.php =================================================================== --- pieforms-php5/trunk/src/pieform/rules/email.php 2006-12-27 09:12:04 UTC (rev 154) +++ pieforms-php5/trunk/src/pieform/rules/email.php 2006-12-27 12:49:27 UTC (rev 155) @@ -42,7 +42,7 @@ } } -function pieform_i18n_rule_email() { +function pieform_rule_email_i18n() { return array( 'en.utf8' => array( 'email' => 'E-mail address is invalid' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 09:12:05
|
Revision: 154 http://svn.sourceforge.net/pieforms/?rev=154&view=rev Author: oracleshinoda Date: 2006-12-27 01:12:04 -0800 (Wed, 27 Dec 2006) Log Message: ----------- Added pieforms.js, which will contain pieforms-specific javascript. Currently includes support for resizable textareas Added Paths: ----------- pieforms-php5/trunk/src/static/core/pieforms.js Added: pieforms-php5/trunk/src/static/core/pieforms.js =================================================================== --- pieforms-php5/trunk/src/static/core/pieforms.js (rev 0) +++ pieforms-php5/trunk/src/static/core/pieforms.js 2006-12-27 09:12:04 UTC (rev 154) @@ -0,0 +1,132 @@ +/** + * Pieforms core javascript + * Author: Nigel McNie + * (C) 2006 Nigel McNie + * Released under the GNU GPL, see the COPYING file + * @todo pack this, provide a source version. Same with MochiKit + */ + +// The resizable textarea code is based on the code from Drupal (http://drupal.org/) + +/** + * Retrieves the absolute position of an element on the screen + * This function (C) 2006 Drupal + */ +function absolutePosition(el) { + var sLeft = 0, sTop = 0; + var isDiv = /^div$/i.test(el.tagName); + if (isDiv && el.scrollLeft) { + sLeft = el.scrollLeft; + } + if (isDiv && el.scrollTop) { + sTop = el.scrollTop; + } + var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop }; + if (el.offsetParent) { + var tmp = absolutePosition(el.offsetParent); + r.x += tmp.x; + r.y += tmp.y; + } + return r; +} + +addLoadEvent(function() { + forEach(getElementsByTagAndClassName('form', 'pieform'), function(form) { + forEach(getElementsByTagAndClassName('textarea', 'resizable', form), function (textarea) { + new TextArea(textarea); + }); + }); +}); + +/** + * This class based on Drupal's textArea class, which is (C) 2006 Drupal + * + * Provides a 'grippie' for resizing a textarea vertically. + */ +function TextArea(element) { + var self = this; + + this.element = element; + this.parent = this.element.parentNode; + this.dimensions = getElementDimensions(element); + + // Prepare wrapper + this.wrapper = DIV({'class':'resizable-textarea'}); + insertSiblingNodesBefore(this.element, this.wrapper); + + // Add grippie and measure it + this.grippie = DIV({'class': 'grippie'}); + appendChildNodes(this.wrapper, this.grippie); + this.grippie.dimensions = getElementDimensions(this.grippie); + + // Set wrapper and textarea dimensions + setElementDimensions(this.wrapper, {'h': this.dimensions.h + this.grippie.dimensions.h + 1}); + setStyle(this.element, { + 'margin-bottom': '0', + 'width': '100%', + 'height': this.dimensions.h + 'px' + }); + + // Wrap textarea + removeElement(this.element); + insertSiblingNodesBefore(this.grippie, this.element); + + // Measure difference between desired and actual textarea dimensions to account for padding/borders + this.widthOffset = getElementDimensions(this.wrapper).w - this.dimensions.w; + + // Make the grippie line up in various browsers + if (window.opera) { + setStyle(this.grippie, {'margin-right': '4px'}); + } + if (document.all && !window.opera) { + this.grippie.style.width = '100%'; + this.grippie.style.paddingLeft = '2px'; + setStyle(this.grippie, { + 'width': '100%', + 'padding-left': '2px' + }); + } + this.element.style.MozBoxSizing = 'border-box'; + + this.heightOffset = absolutePosition(this.grippie).y - absolutePosition(this.element).y - this.dimensions.h; + + + this.handleDrag = function (e) { + // Get coordinates relative to text area + var pos = absolutePosition(this.element); + var y = e.mouse().client.y - pos.y; + + // Set new height + var height = Math.max(32, y - this.dragOffset - this.heightOffset); + setStyle(this.wrapper, {'height': height + this.grippie.dimensions.h + 1 + 'px'}); + setStyle(this.element, {'height': height + 'px'}); + + // Avoid text selection + e.stop(); + } + + this.endDrag = function (e) { + disconnect(this.mouseMoveHandler); + disconnect(this.mouseUpHandler); + document.isDragging = false; + } + + this.beginDrag = function(e) { + if (document.isDragging) { + return; + } + document.isDragging = true; + + self.mouseMoveHandler = connect(document, 'onmousemove', self, 'handleDrag'); + self.mouseUpHandler = connect(document, 'onmouseup', self, 'endDrag'); + + // Store drag offset from grippie top + var pos = absolutePosition(this.grippie); + this.dragOffset = e.mouse().client.y - pos.y; + + // Process + this.handleDrag(e); + } + + connect(this.grippie, 'onmousedown', self, 'beginDrag'); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 09:09:44
|
Revision: 153 http://svn.sourceforge.net/pieforms/?rev=153&view=rev Author: oracleshinoda Date: 2006-12-27 01:09:43 -0800 (Wed, 27 Dec 2006) Log Message: ----------- Add 'class=pieform' to all pieforms, so they can be targetted by javascript routines. Add a class of 'resizable' to textareas if needed, so javascript can target them Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/textarea.php pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform/elements/textarea.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/textarea.php 2006-12-27 06:23:15 UTC (rev 152) +++ pieforms-php5/trunk/src/pieform/elements/textarea.php 2006-12-27 09:09:43 UTC (rev 153) @@ -55,6 +55,10 @@ Pieform::info('No value for cols or width specified for textarea "' . $element['name'] . '"'); } $element['style'] = (isset($element['style'])) ? $style . $element['style'] : $style; + + if (!empty($element['resizable'])) { + $element['class'] = (isset($element['class']) && $element['class']) ? $element['class'] . ' resizable' : 'resizable'; + } return '<textarea' . (($rows) ? ' rows="' . $rows . '"' : '') . (($cols) ? ' cols="' . $cols . '"' : '') Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-27 06:23:15 UTC (rev 152) +++ pieforms-php5/trunk/src/pieform.php 2006-12-27 09:09:43 UTC (rev 153) @@ -599,7 +599,7 @@ * @return string */ public function get_form_tag() { - $result = '<form'; + $result = '<form class="pieform"'; foreach (array('name', 'method', 'action') as $attribute) { $result .= ' ' . $attribute . '="' . $this->data[$attribute] . '"'; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 06:23:15
|
Revision: 152 http://svn.sourceforge.net/pieforms/?rev=152&view=rev Author: oracleshinoda Date: 2006-12-26 22:23:15 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Added tabindex to fieldset for keyboard navigation Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/fieldset.php Modified: pieforms-php5/trunk/src/pieform/elements/fieldset.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/fieldset.php 2006-12-27 05:38:39 UTC (rev 151) +++ pieforms-php5/trunk/src/pieform/elements/fieldset.php 2006-12-27 06:23:15 UTC (rev 152) @@ -56,7 +56,7 @@ $id = substr(md5(microtime()), 0, 4); $result .= ' id="' . $id . '">'; $result .= '<script type="text/javascript">'; - $result .= "var a = A({'href':''}, " . json_encode($element['legend']) . "); "; + $result .= "var a = A({'href':'', 'tabindex':{$form->get_property('tabindex')}}, " . json_encode($element['legend']) . "); "; $result .= "connect(a, 'onclick', function(e) { toggleElementClass('collapsed', $('{$id}').parentNode); e.stop(); });"; $result .= "replaceChildNodes('{$id}', a);</script>"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 05:38:53
|
Revision: 151 http://svn.sourceforge.net/pieforms/?rev=151&view=rev Author: oracleshinoda Date: 2006-12-26 21:38:39 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Ignore .swp files Property Changed: ---------------- pieforms-php5/trunk/src/static/core/ Property changes on: pieforms-php5/trunk/src/static/core ___________________________________________________________________ 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-27 05:37:33
|
Revision: 150 http://svn.sourceforge.net/pieforms/?rev=150&view=rev Author: oracleshinoda Date: 2006-12-26 21:37:33 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Removed some comments from the javascript output for jsform submissions, comments aren't needed (later on this stuff might be packed). Added a bit of code to handle expanding a fieldset if it contains elements with errors in them. Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2006-12-27 05:27:58 UTC (rev 149) +++ pieforms-php5/trunk/src/pieform.php 2006-12-27 05:37:33 UTC (rev 150) @@ -895,33 +895,33 @@ $result .= <<<EOF } 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); } + // @todo only output when fieldsets are present + forEach(getElementsByTagAndClassName('fieldset', 'collapsed', '{$this->name}'), function(fieldset) { + if (getFirstElementByTagAndClassName(null, 'error', fieldset)) { + removeElementClass(fieldset, 'collapsed'); + } + }); } if (data.returnCode == -1) { - // The request failed validation EOF; - - // @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'])) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2006-12-27 05:28:00
|
Revision: 149 http://svn.sourceforge.net/pieforms/?rev=149&view=rev Author: oracleshinoda Date: 2006-12-26 21:27:58 -0800 (Tue, 26 Dec 2006) Log Message: ----------- Added support for 'collapsable' fieldsets (doesn't depend on 'jsform'). Listens to 'collapsable' and 'collapsed' options. If there is an error with form submission in a collapsed fieldset it is expanded. Modified Paths: -------------- pieforms-php5/trunk/src/pieform/elements/fieldset.php Modified: pieforms-php5/trunk/src/pieform/elements/fieldset.php =================================================================== --- pieforms-php5/trunk/src/pieform/elements/fieldset.php 2006-12-27 04:58:00 UTC (rev 148) +++ pieforms-php5/trunk/src/pieform/elements/fieldset.php 2006-12-27 05:27:58 UTC (rev 149) @@ -33,9 +33,37 @@ * @return string The HTML for the element */ function pieform_element_fieldset(Pieform $form, $element) { - $result = "\n<fieldset>\n"; + $result = "\n<fieldset"; + if (!empty($element['collapsable'])) { + $classes = array('collapsable'); + // Work out whether any of the children have errors on them + $error = false; + foreach ($element['elements'] as $subelement) { + if (isset($subelement['error'])) { + $error = true; + break; + } + } + if (!empty($element['collapsed']) && !$error) { + $classes[] = 'collapsed'; + } + $result .= ' class="' . implode(' ', $classes) . '"'; + } + $result .= ">\n"; if (isset($element['legend'])) { - $result .= '<legend>' . Pieform::hsc($element['legend']) . "</legend>\n"; + $result .= '<legend'; + if (!empty($element['collapsable'])) { + $id = substr(md5(microtime()), 0, 4); + $result .= ' id="' . $id . '">'; + $result .= '<script type="text/javascript">'; + $result .= "var a = A({'href':''}, " . json_encode($element['legend']) . "); "; + $result .= "connect(a, 'onclick', function(e) { toggleElementClass('collapsed', $('{$id}').parentNode); e.stop(); });"; + $result .= "replaceChildNodes('{$id}', a);</script>"; + } + else { + $result .= '>' . Pieform::hsc($element['legend']); + } + $result .= "</legend>\n"; } foreach ($element['elements'] as $subname => $subelement) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |