Parent =& $parent; $this->Forms = array(); $this->Dispatch = array(); } public function SetDefault($form) { $name = $form->Name; foreach ($this->Forms as $key => &$value) if ($value[0] == $name) $value[2] = 'true'; } public function Add($form) { $this->Forms[] = array($form->Name, $form, 'false'); } public function OnClick($form, $action, $newform) { $this->Dispatch[] = array($form->Name, $action, $newform); } public function Dispatch() { global $_FORM; if (!isset($_FORM)) foreach ($this->Forms as $key => $value) if ($value[2] == 'true') { $this->Display($value[1]); return; } foreach ($this->Forms as $fvalue) { if ($fvalue[0] == $_FORM['_FormName']) { foreach ($this->Dispatch as $dvalue) { if ($dvalue[0] == $_FORM['_FormName']) { if (in_array($dvalue[1], $_FORM)) { if ($fvalue[1]->Valid == false) { $this->Display($fvalue[1]); return; } $this->Display($dvalue[2]); return; } } } } } } private function Display($form) { if ($form instanceof Form) { $this->Parent->Data[] = $form; } else { $this->Parent->Data[] = $form; } } } ?>