public static function load($object, $id = NULL, $alt_id = NULL, $required = NULL) { isset($object->_f) || isset($object->_d) and $a = $object->_f and isset($object->_d) && is_array($a) and $a = array_merge($a, $object->_d) and $a[] = '_d'; isset($object->_r) && $required == NULL and $_r = $object->_r and $required = $_r; // remove values that are not in the _f or _d lists if (is_object($object)) { foreach ($object as $key => $value) { if (is_array($a) && !in_array($key, $a)) { unset($object->{$key}); } } } if (isset($object->_d)) { // refers to 'hidden' variables, those used for forms or database identification foreach ($_POST as $k => $v) { in_array($k, $object->_d) and $object->{$k} = array("hidden:{$k}" => array('' => 'hidden')); } unset($object->_d); } // special directive processing based on field type... $select_array = array('select', 'checkbox', 'password', 'textarea', 'radio', 'sumbit', 'email', 'search', 'number', 'date', 'hidden', 'html'); if ($id != NULL) { $id = explode(':', $id, 2); count($id) == 2 and $a_id = $id[1]; $id = $id[0]; if ($id == 'html') { return $object; } if (is_array($object) && in_array($id, $select_array)) { if ($id == 'hidden') { return self::make_input($id, $alt_id, NULL, $_POST[$alt_id]) . "\n"; } return self::build_arr($object, $a_id ? $a_id : $alt_id, $id, $required); } elseif (!is_array($object) && !is_object($object)) { if ((!isset($_POST[$id]) || $_POST[$id] == '') && $object == 'file ') { $select_array[] = 'file'; } foreach ($select_array as $s) { if (!(strpos($object, "{$s} ") === false)) { // basically we have to make this do the block of code below .... hmmm return noClass_html::fieldset(self::labeler($id, $required) . self::make_input(trim($s), $id, '', '', $s)); } } // try to use new labler syntax for the make_input ? return noClass_html::fieldset(self::labeler($id, $required) . "\t\t" . self::make_input($object != 'file' ? 'text' : 'file', $id, '', $object != '0' || $object != '' ? isset($_POST[$id]) ? $_POST[$id] : NULL : NULL, ucwords(str_replace('_', ' ', $id)))); } } elseif (is_array($object)) { foreach ($object as $x => $y) { $r[$x] = self::load($y, $x, NULL, $required); } } elseif (is_object($object)) { foreach ($object as $x => $y) { // check to see if an entry is contained in the a parameter // to do validations or create drop down menus with values if (is_array($y) || is_object($y)) { foreach ($y as $a => $b) { $r[$x][$a] = self::load($b, $a, $x, $required); } } else { $r[$x] = self::load($y, $x, $x, $required); } } } return isset($r) ? array_reverse($r) : $object; }
public function __construct($container = NULL) { // do database check to see that a 'blog' db is present $this->categories(); parent::__construct($container); }