diff --git a/Base.php b/Base.php
index eacb4ce..2a14d3b 100644
--- a/Base.php
+++ b/Base.php
@@ -33,7 +33,6 @@ public function configure(array $properties = null)
$method_reference = array();
foreach ($available as $method) {
-
$method_reference[strtolower($method)] = $method;
}
@@ -45,9 +44,13 @@ public function configure(array $properties = null)
/*If the appropriate class has a "set" method for the property provided, then
it is called instead or setting the property directly.*/
if (isset($method_reference["set" . $property])) {
- $this->$method_reference["set" . $property]($value);
+ $func = $method_reference["set" . $property];
+
+ $this->$func($value);
} elseif (isset($property_reference[$property])) {
- $this->$property_reference[$property] = $value;
+ $prop = $property_reference[$property];
+
+ $this->$prop = $value;
} else {
/*Entries that don't match an available class property are stored in the attributes
property if applicable. Typically, these entries will be element attributes such as
diff --git a/Element.php b/Element.php
index 1333de6..6822ad4 100644
--- a/Element.php
+++ b/Element.php
@@ -156,9 +156,9 @@ public function jQueryOptions()
/*Many of the included elements make use of the tag for display. These include the Hidden, Textbox,
Password, Date, Color, Button, Email, and File element classes. The project's other element classes will
override this method with their own implementation.*/
- public function render()
+ public function getInput()
{
- echo 'getAttributes(), '/>';
+ return 'getAttributes() . '/>';
}
/*If an element requires inline stylesheet definitions, this method is used send them to the browser before
diff --git a/Element/CKEditor.php b/Element/CKEditor.php
index b6e96b2..36a385b 100644
--- a/Element/CKEditor.php
+++ b/Element/CKEditor.php
@@ -17,11 +17,17 @@ class CKEditor extends Textarea
public function render()
{
- echo "";
+
+ return $html;
}
public function renderJS()
diff --git a/Element/Captcha.php b/Element/Captcha.php
index 02e0ace..05362cc 100644
--- a/Element/Captcha.php
+++ b/Element/Captcha.php
@@ -22,12 +22,12 @@ public function __construct($label = "", array $properties = null)
parent::__construct($label, "recaptcha_response_field", $properties);
}
- public function render()
+ public function getInput()
{
$this->validation[] = new ValidationCaptcha($this->privateKey);
require_once(__DIR__ . "/../Resources/recaptchalib.php");
- echo recaptcha_get_html($this->publicKey);
+ return recaptcha_get_html($this->publicKey);
}
}
diff --git a/Element/Checkbox.php b/Element/Checkbox.php
index 9064247..09f9366 100644
--- a/Element/Checkbox.php
+++ b/Element/Checkbox.php
@@ -16,8 +16,10 @@ class Checkbox extends OptionElement
protected $attributes = array("type" => "checkbox");
protected $inline;
- public function render()
+ public function getInput()
{
+ $html = '';
+
if (isset($this->attributes["value"])) {
if (!is_array($this->attributes["value"])) {
$this->attributes["value"] = array($this->attributes["value"]);
@@ -41,18 +43,20 @@ public function render()
foreach ($this->options as $value => $text) {
$value = $this->getOptionValue($value);
- echo ' ';
++$count;
}
+
+ return $html;
}
}
diff --git a/Element/Checksort.php b/Element/Checksort.php
index 914884d..c2f429e 100644
--- a/Element/Checksort.php
+++ b/Element/Checksort.php
@@ -14,8 +14,10 @@ class Checksort extends Sort
protected $attributes = array("type" => "checkbox");
protected $inline;
- public function render()
+ public function getInput()
{
+ $html = '';
+
if (isset($this->attributes["value"])) {
if (!is_array($this->attributes["value"])) {
$this->attributes["value"] = array($this->attributes["value"]);
@@ -41,19 +43,19 @@ public function render()
$value = $this->getOptionValue($value);
if (!empty($this->inline) && $count > 0) {
- echo ' ';
+ $html .= ' ';
}
-
- echo '
+
+ $html .= '
getAttributes(array("id", "value", "checked", "name", "onclick", "required")) .
' value="' . $this->filter($value) . '"';
if (in_array($value, $this->attributes["value"])) {
- echo ' checked="checked"';
+ $html .= ' checked="checked"';
}
-
- echo ' onclick="updateChecksort(this, \'' .
+
+ $html .= ' onclick="updateChecksort(this, \'' .
str_replace(array('"', "'"), array('"', "\'"), $text) . '\');"/>' . $text . '';
if (in_array($value, $this->attributes["value"])) {
@@ -65,7 +67,9 @@ public function render()
++$count;
}
- echo '
' . $existing . '
';
+ $html .= '
' . $existing . '
';
+
+ return $html;
}
public function renderJS()
diff --git a/Element/Color.php b/Element/Color.php
index 730bb31..a1162bf 100644
--- a/Element/Color.php
+++ b/Element/Color.php
@@ -16,6 +16,8 @@ class Color extends Textbox
public function render()
{
+ $html = '';
+
$this->attributes["pattern"] = "#[a-g0-9]{6}";
$this->attributes["title"] = "6-digit hexidecimal color (e.g. #000000)";
@@ -23,6 +25,8 @@ public function render()
$this->validation[] = new RegExp("/" . $this->attributes["pattern"] . "/", $msg);
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/Date.php b/Element/Date.php
index f038996..671e0de 100644
--- a/Element/Date.php
+++ b/Element/Date.php
@@ -27,12 +27,16 @@ public function __construct($label, $name, array $properties = null)
parent::__construct($label, $name, $properties);
}
- public function render()
+ public function getInput()
{
+ $html = '';
+
$msg = "Error: The %element% field must match the following date format: " . $this->attributes["title"];
$this->validation[] = new RegExp("/" . $this->attributes["pattern"] . "/", $msg);
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/Email.php b/Element/Email.php
index 0b3c2a9..f044aa0 100644
--- a/Element/Email.php
+++ b/Element/Email.php
@@ -17,8 +17,12 @@ class Email extends Textbox
public function render()
{
+ $html = '';
+
$this->validation[] = new ValidationEmail();
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/HTML.php b/Element/HTML.php
index f29f2b1..422bece 100644
--- a/Element/HTML.php
+++ b/Element/HTML.php
@@ -20,8 +20,8 @@ public function __construct($value)
parent::__construct("", "", $properties);
}
- public function render()
+ public function getInput()
{
- echo $this->attributes["value"];
+ return $this->attributes["value"];
}
}
diff --git a/Element/JQueryUIDate.php b/Element/JQueryUIDate.php
index 33f68ac..d0e5b5c 100644
--- a/Element/JQueryUIDate.php
+++ b/Element/JQueryUIDate.php
@@ -41,10 +41,14 @@ public function jQueryDocumentReady()
echo 'jQuery("#', $this->attributes["id"], '").datepicker(', $this->jQueryOptions(), ');';
}
- public function render()
+ public function getInput()
{
+ $html = '';
+
$this->validation[] = new Date;
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/Month.php b/Element/Month.php
index b263f2e..8341f6e 100644
--- a/Element/Month.php
+++ b/Element/Month.php
@@ -27,12 +27,16 @@ public function __construct($label, $name, array $properties = null)
parent::__construct($label, $name, $properties);
}
- public function render()
+ public function getInput()
{
- $msg = "Error: The %element% field must match the following date format: " . $this->attributes["title"];
+ $html = '';
+
+ $msg = "Error: The %element% field must match the following date format: " . $this->attributes["title"];
$this->validation[] = new RegExp("/" . $this->attributes["pattern"] . "/", $msg);
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/Number.php b/Element/Number.php
index 5af229a..b3b2229 100644
--- a/Element/Number.php
+++ b/Element/Number.php
@@ -17,8 +17,12 @@ class Number extends Textbox
public function render()
{
+ $html = '';
+
$this->validation[] = new Numeric;
- parent::render();
+ $html .= parent::getInput();
+
+ return $html;
}
}
diff --git a/Element/Radio.php b/Element/Radio.php
index 5adfa2b..51cabaf 100644
--- a/Element/Radio.php
+++ b/Element/Radio.php
@@ -16,8 +16,10 @@ class Radio extends OptionElement
protected $attributes = array("type" => "radio", "labelclass" => "");
protected $inline;
- public function render()
+ public function getInput()
{
+ $html = '';
+
$labelClass = $this->attributes["type"];
$labelClass .= " " . $this->attributes["labelclass"];
@@ -30,17 +32,19 @@ public function render()
foreach ($this->options as $value => $text) {
$value = $this->getOptionValue($value);
- echo '
+ $html .= '
getAttributes(array("id", "value", "checked")) . ' value="' . $this->filter($value) . '"';
if (isset($this->attributes["value"]) && $this->attributes["value"] == $value) {
- echo ' checked="checked"';
+ $html .= ' checked="checked"';
}
- echo '/> ' . $text . ' ';
+ $html .= '/> ' . $text . ' ';
++$count;
}
+
+ return $html;
}
}
diff --git a/Element/Select.php b/Element/Select.php
index 9271e13..ac07222 100644
--- a/Element/Select.php
+++ b/Element/Select.php
@@ -15,8 +15,10 @@ class Select extends OptionElement
protected $attributes = array();
- public function render()
+ public function getInput()
{
+ $html = '';
+
if (isset($this->attributes["value"])) {
if (!is_array($this->attributes["value"])) {
$this->attributes["value"] = array($this->attributes["value"]);
@@ -29,23 +31,25 @@ public function render()
$this->attributes["name"] .= "[]";
}
- echo '';
+
+ return $html;
}
}
diff --git a/Element/Sort.php b/Element/Sort.php
index b5a75a6..c077ceb 100644
--- a/Element/Sort.php
+++ b/Element/Sort.php
@@ -35,22 +35,27 @@ public function jQueryDocumentReady()
echo 'jQuery("#' . $this->attributes["id"] . '").disableSelection();';
}
- public function render()
+ public function getInput()
{
+ $html = '';
+
if (substr($this->attributes["name"], -2) != "[]") {
$this->attributes["name"] .= "[]";
}
- echo '