aboutsummaryrefslogtreecommitdiff
path: root/h-source/Library/Form/Entry.php
diff options
context:
space:
mode:
authorAntonio Gallo <tonicucoz@gmail.com>2011-07-28 20:27:23 +0000
committerAntonio Gallo <tonicucoz@gmail.com>2011-07-28 20:27:23 +0000
commite7b3717614621f14695ab6ca6dda6dd17ba3d65c (patch)
treec8e6061aef3ff7bad5a17e1aecaf441d35e282cb /h-source/Library/Form/Entry.php
parent0de74c6879d263645770de3d6b3ce7123f5241d6 (diff)
added new easygiant library
Diffstat (limited to 'h-source/Library/Form/Entry.php')
-rwxr-xr-xh-source/Library/Form/Entry.php42
1 files changed, 40 insertions, 2 deletions
diff --git a/h-source/Library/Form/Entry.php b/h-source/Library/Form/Entry.php
index 440ee2d..305f55f 100755
--- a/h-source/Library/Form/Entry.php
+++ b/h-source/Library/Form/Entry.php
@@ -32,6 +32,7 @@ abstract class Form_Entry {
public $options = array(); //options (if the entry is a <select> entry or a radio button). Associative array or comma-divided list.
public $defaultValue = '';
public $wrap = array();
+ public $deleteButton = null;
public $type = null; //the type of the entry
//create the label of each entry of the form
@@ -44,7 +45,32 @@ abstract class Form_Entry {
//get the class of the entry
public function getEntryClass()
{
- return isset($this->entryClass) ? $this->entryClass : 'formEntry';
+ if (isset($this->entryClass))
+ {
+ $class = $this->entryClass;
+ }
+ else
+ {
+ switch($this->type)
+ {
+ case 'InputText':
+ $class = 'form_input_text';
+ break;
+ case 'File':
+ $class = 'form_input_file';
+ break;
+ case 'Textarea':
+ $class = 'form_textarea';
+ break;
+ case 'Password':
+ $class = 'form_input_text form_input_password';
+ break;
+ default:
+ $class = 'form_input_text';
+ break;
+ }
+ }
+ return $class;
}
public function getWrapElements($value = null)
@@ -52,7 +78,19 @@ abstract class Form_Entry {
//replace the ;;value;; variable
for ($i = 0; $i < count($this->wrap); $i++)
{
- $this->wrap[$i] = str_replace(';;value;;',$value,$this->wrap[$i]);
+ if ( preg_match('/;;(.*)\|value;;/',$this->wrap[$i],$m) )
+ {
+ if (!function_exists($m[1])) {
+ throw new Exception('Error in <b>'.__METHOD__.'</b>: function <b>'.$m[1].'</b> does not exists..');
+ }
+ //apply the function
+ $v = call_user_func($m[1],$value);
+ $this->wrap[$i] = str_replace(";;".$m[1]."|value;;",$v,$this->wrap[$i]);
+ }
+ else if ( preg_match('/;;value;;/',$this->wrap[$i]) )
+ {
+ $this->wrap[$i] = str_replace(';;value;;',$value,$this->wrap[$i]);
+ }
}
$wrap[0] = isset($this->wrap[0]) ? $this->wrap[0] : null;