/**
* The required files
*/
if (defined('HTML_DB_COLUMNS_RESOURCE_PATH')) {
require_once(HTML_DB_COLUMNS_RESOURCE_PATH.'/Define.php');
}
/**
* The Fields is used to return the field attribute for a given key
* like i.e. a Field Len object
* The purpose of this clas is to simulate the meta information from a database
* <code>
* Usage:
* $header = array(
* 'firstname'=>array('fieldName'=>'firstname', 'fieldLen'=>100, 'fieldType'=>'', 'fieldFlags'=>'', 'fieldTable'=>''),
* 'lastname'=>'array('fieldName'=>'lastname' , 'fieldLen'=>100, 'fieldType'=>'', 'fieldFlags'=>'', 'fieldTable'=>''),
* );
*
* $fields = new Fields();
* $name = $fields->value($key, $header, $select);
* Or
* $name = Fields::value($key, $header, $select);
* </code>
* @package dto
*/
class Fields {
/**
* Constructor
*/
function Fields() {
}
/**
* The GLOBALS array $select contain the $key=>fieldValue
* Get the Name of the field from the specified key
* @param String $key The key to use, i.e. SELECT_PRICE
* @param array $header The header meta data i.e. custom meta data
* @param String $select The select value to use, i.e. SELECT_FIELD_TYPE_BASKET
* @return String The value of the field, i.e. FLOAT
*/
function value($key, $header='', $select='x') {
$value = ''; //$key;
// Default value selected
if ($select!='') {
if (is_array($GLOBALS[$select]) && array_key_exists($key,$GLOBALS[$select])) {
$value = $GLOBALS[$select][$key];
}
} else {
die("Fields::value(key, header, select) The select key must NOT be empty");
}
// Is header array specified?
if ($header!='' && is_array($header)) {
$meta = '';
if (array_key_exists($key,$header)) {
$meta = $header[$key];
if (is_array($meta)&& array_key_exists($select,$meta)) {
$value = $meta[$select];
} else {
// Ignore
//$msg = "$key 2<br />\r\n";
// Message::add($msg,__FILE__,__LINE__);
}
} else {
// Ignore
//$msg = "$key 1<br />\r\n";
// Message::add($msg,__FILE__,__LINE__);
}
}
return $value;
}
/**
* Get the html code
* @return String The html code
*/
function getHtml() {
return Fields::value('test','test','test');
}
}
?>