pieforms-commit Mailing List for Pieforms
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
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
1
|
2
|
3
|
4
(4) |
5
|
6
|
7
|
8
|
9
(2) |
10
|
11
(4) |
12
|
13
|
14
(2) |
15
|
16
|
17
|
18
|
19
(5) |
20
|
21
|
22
|
23
|
24
|
25
|
26
|
27
(2) |
28
|
|
|
|
From: <ora...@us...> - 2007-02-04 23:00:06
|
Revision: 176 http://svn.sourceforge.net/pieforms/?rev=176&view=rev Author: oracleshinoda Date: 2007-02-04 15:00:03 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Merged fixes from trunk Modified Paths: -------------- pieforms-php5/branches/0.2.0/src/pieform/elements/fieldset.php pieforms-php5/branches/0.2.0/src/pieform/renderers/table.php pieforms-php5/branches/0.2.0/src/pieform.php Added Paths: ----------- pieforms-php5/branches/0.2.0/src/pieform/elements/bytes.php Copied: pieforms-php5/branches/0.2.0/src/pieform/elements/bytes.php (from rev 171, pieforms-php5/trunk/src/pieform/elements/bytes.php) =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform/elements/bytes.php (rev 0) +++ pieforms-php5/branches/0.2.0/src/pieform/elements/bytes.php 2007-02-04 23:00:03 UTC (rev 176) @@ -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'); +} + +?> Modified: pieforms-php5/branches/0.2.0/src/pieform/elements/fieldset.php =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform/elements/fieldset.php 2007-02-04 22:40:21 UTC (rev 175) +++ pieforms-php5/branches/0.2.0/src/pieform/elements/fieldset.php 2007-02-04 23:00:03 UTC (rev 176) @@ -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">'; Modified: pieforms-php5/branches/0.2.0/src/pieform/renderers/table.php =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform/renderers/table.php 2007-02-04 22:40:21 UTC (rev 175) +++ pieforms-php5/branches/0.2.0/src/pieform/renderers/table.php 2007-02-04 23:00:03 UTC (rev 176) @@ -39,8 +39,15 @@ if ($rawelement['type'] == 'fieldset') { // Add table tags to the build element, to preserve HTML compliance if (0 === strpos($builtelement, "\n<fieldset")) { - $closelegendpos = strpos($builtelement, '</legend>') + 9; - $builtelement = substr($builtelement, 0, $closelegendpos) . '<table>' . substr($builtelement, $closelegendpos); + $closelegendpos = strpos($builtelement, '</legend>'); + if ($closelegendpos !== false) { + $closelegendpos += 9; + $builtelement = substr($builtelement, 0, $closelegendpos) . '<table>' . substr($builtelement, $closelegendpos); + } + else { + $pos = strpos($builtelement, '>') + 1; + $builtelement = substr($builtelement, 0, $pos) . '<table>' . substr($builtelement, $pos); + } } else { $builtelement = substr($builtelement, 0, 11) . '<table>' . substr($builtelement, 11); Modified: pieforms-php5/branches/0.2.0/src/pieform.php =================================================================== --- pieforms-php5/branches/0.2.0/src/pieform.php 2007-02-04 22:40:21 UTC (rev 175) +++ pieforms-php5/branches/0.2.0/src/pieform.php 2007-02-04 23:00:03 UTC (rev 176) @@ -325,6 +325,22 @@ throw new PieformException('Forms must have a list of elements'); } + // Rename all the keys to have nice compliant names + // @todo: + // - This isn't done for elements inside fieldsets + // - There's no easy way for other things do do all this preprocessing if they + // need. It should be a method so that other things (like multirecord) + // can use it. + $elements = array(); + foreach ($this->data['elements'] as $name => $element) { + $newname = preg_replace('/[^a-zA-Z0-9_]/', '_', $name); + if (isset($elements[$name])) { + throw new PieformException('Element "' . $name . '" has a dangerous name that interferes with another element'); + } + $elements[$newname] = $element; + } + $this->data['elements'] = $elements; + // Remove elements to ignore foreach ($this->data['elements'] as $name => $element) { if (isset($element['type']) && $element['type'] == 'fieldset') { @@ -867,6 +883,12 @@ return $result; } + /** + * Builds the javascript for submitting the form. Note that the iframe is + * not hidden with display: none, as safari/konqueror/ns6 ignore things with + * display: none. Positioning it absolute and 'hidden' has the same effect + * without the breakage. + */ private function submit_js() { $strprocessingform = get_string('processingform'); @@ -885,9 +907,9 @@ if (!iframe) { iframe = createDOM('iframe', { 'name': '{$this->name}_iframe', - 'id' : '{$this->name}_iframe' + 'id' : '{$this->name}_iframe', + 'style': 'position: absolute; visibility: hidden;' }); - hideElement(iframe); insertSiblingNodesAfter($('{$this->name}'), iframe); window.pieformHandler_{$this->name} = function(data) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-02-04 22:40:21
|
Revision: 175 http://svn.sourceforge.net/pieforms/?rev=175&view=rev Author: oracleshinoda Date: 2007-02-04 14:40:21 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Handle having no legend better 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 2007-02-04 22:39:59 UTC (rev 174) +++ pieforms-php5/trunk/src/pieform/renderers/table.php 2007-02-04 22:40:21 UTC (rev 175) @@ -39,8 +39,15 @@ if ($rawelement['type'] == 'fieldset') { // Add table tags to the build element, to preserve HTML compliance if (0 === strpos($builtelement, "\n<fieldset")) { - $closelegendpos = strpos($builtelement, '</legend>') + 9; - $builtelement = substr($builtelement, 0, $closelegendpos) . '<table>' . substr($builtelement, $closelegendpos); + $closelegendpos = strpos($builtelement, '</legend>'); + if ($closelegendpos !== false) { + $closelegendpos += 9; + $builtelement = substr($builtelement, 0, $closelegendpos) . '<table>' . substr($builtelement, $closelegendpos); + } + else { + $pos = strpos($builtelement, '>') + 1; + $builtelement = substr($builtelement, 0, $pos) . '<table>' . substr($builtelement, $pos); + } } else { $builtelement = substr($builtelement, 0, 11) . '<table>' . substr($builtelement, 11); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ora...@us...> - 2007-02-04 22:39:59
|
Revision: 174 http://svn.sourceforge.net/pieforms/?rev=174&view=rev Author: oracleshinoda Date: 2007-02-04 14:39:59 -0800 (Sun, 04 Feb 2007) Log Message: ----------- Fixed the form submission support under safari, by hiding the iframe instead of removing it. Try to normalise the names of the elements if possible (although this does not check inside fieldsets and needs some work) Modified Paths: -------------- pieforms-php5/trunk/src/pieform.php Modified: pieforms-php5/trunk/src/pieform.php =================================================================== --- pieforms-php5/trunk/src/pieform.php 2007-02-04 22:38:38 UTC (rev 173) +++ pieforms-php5/trunk/src/pieform.php 2007-02-04 22:39:59 UTC (rev 174) @@ -325,6 +325,22 @@ throw new PieformException('Forms must have a list of elements'); } + // Rename all the keys to have nice compliant names + // @todo: + // - This isn't done for elements inside fieldsets + // - There's no easy way for other things do do all this preprocessing if they + // need. It should be a method so that other things (like multirecord) + // can use it. + $elements = array(); + foreach ($this->data['elements'] as $name => $element) { + $newname = preg_replace('/[^a-zA-Z0-9_]/', '_', $name); + if (isset($elements[$name])) { + throw new PieformException('Element "' . $name . '" has a dangerous name that interferes with another element'); + } + $elements[$newname] = $element; + } + $this->data['elements'] = $elements; + // Remove elements to ignore foreach ($this->data['elements'] as $name => $element) { if (isset($element['type']) && $element['type'] == 'fieldset') { @@ -867,6 +883,12 @@ return $result; } + /** + * Builds the javascript for submitting the form. Note that the iframe is + * not hidden with display: none, as safari/konqueror/ns6 ignore things with + * display: none. Positioning it absolute and 'hidden' has the same effect + * without the breakage. + */ private function submit_js() { $strprocessingform = get_string('processingform'); @@ -885,9 +907,9 @@ if (!iframe) { iframe = createDOM('iframe', { 'name': '{$this->name}_iframe', - 'id' : '{$this->name}_iframe' + 'id' : '{$this->name}_iframe', + 'style': 'position: absolute; visibility: hidden;' }); - hideElement(iframe); insertSiblingNodesAfter($('{$this->name}'), iframe); window.pieformHandler_{$this->name} = function(data) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |