[Pieforms-commit] SF.net SVN: pieforms: [2] pieforms/src/pieform.php
Status: Alpha
Brought to you by:
oracleshinoda
|
From: <ora...@us...> - 2006-11-18 09:30:45
|
Revision: 2
http://svn.sourceforge.net/pieforms/?rev=2&view=rev
Author: oracleshinoda
Date: 2006-11-18 01:30:45 -0800 (Sat, 18 Nov 2006)
Log Message:
-----------
* Fixed default method to be 'get'
* Make sure forms have at least one element
* Change hsc() calls to self::hsc, and implement that
This commit is a bit messy, but I'm slowly getting it all working.
Modified Paths:
--------------
pieforms/src/pieform.php
Modified: pieforms/src/pieform.php
===================================================================
--- pieforms/src/pieform.php 2006-11-17 13:01:30 UTC (rev 1)
+++ pieforms/src/pieform.php 2006-11-18 09:30:45 UTC (rev 2)
@@ -287,10 +287,13 @@
}
}
}
+ else {
+ $formconfig = array();
+ }
// Assign defaults for the form
$formdefaults = array(
- 'method' => 'post',
+ 'method' => 'get',
'action' => '',
'onsubmit' => '',
'ajaxpost' => false,
@@ -352,7 +355,7 @@
$this->iscancellable = (isset($data['iscancellable']) && !$data['iscancellable']) ? false : true;
- if (!is_array($data['elements'])) {
+ if (!is_array($data['elements']) || count($data['elements']) == 0) {
throw new PieformException('Forms must have a list of elements');
}
$this->elements = $data['elements'];
@@ -588,6 +591,7 @@
// @todo masks attempts in pieform_render_element, including the error handling there
@include_once('pieform/renderers/' . $this->renderer . '.php');
+
// Form header
$function = 'pieform_renderer_' . $this->renderer . '_header';
if (function_exists($function)) {
@@ -939,10 +943,10 @@
*/
public static function make_id($element) {
if (isset($element['id'])) {
- return hsc($element['id']);
+ return self::hsc($element['id']);
}
if (isset($element['name'])) {
- return hsc($element['name']);
+ return self::hsc($element['name']);
}
return substr(md5(mt_rand()), 0, 4);
}
@@ -1008,7 +1012,7 @@
$result = '';
foreach ($elementattributes as $attribute) {
if (isset($element[$attribute]) && $element[$attribute] !== '') {
- $result .= ' ' . $attribute . '="' . hsc($element[$attribute]) . '"';
+ $result .= ' ' . $attribute . '="' . self::hsc($element[$attribute]) . '"';
}
}
@@ -1059,6 +1063,16 @@
}
/**
+ * HTML-escapes the given value
+ *
+ * @param string $text The text to escape
+ * @return string The text, HTML escaped
+ */
+ public static function hsc($text) {
+ return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
+ }
+
+ /**
* Returns elements with errors on them
*
* @return array An array of elements with errors on them, the empty array
@@ -1098,6 +1112,7 @@
}
}
}
+
}
@@ -1126,18 +1141,18 @@
// Make sure that the function to render the element type is available
$function = 'pieform_render_' . $element['type'];
- if (!function_exists($function)) {
- @include('pieform/elements/' . $element['type'] . '.php');
- if (!function_exists($function)) {
- throw new PieformException('No such form element: ' . $element['type']);
- }
- }
+ //if (!function_exists($function)) {
+ // @include('pieform/elements/' . $element['type'] . '.php');
+ // if (!function_exists($function)) {
+ // throw new PieformException('No such form element: ' . $element['type']);
+ // }
+ //}
// Work out the renderer function required and make sure it exists
if ($renderer = $form->get_renderer()) {
$rendererfunction = 'pieform_renderer_' . $renderer;
if (!function_exists($rendererfunction)) {
- @include('pieform/renderers/' . $renderer . '.php');
+ include('pieform/renderers/' . $renderer . '.php');
if (!function_exists($rendererfunction)) {
throw new PieformException('No such form renderer: "' . $renderer . '"');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|