function predrawWidget() { $identificator = $this->name; $action = $this->name . "_action"; $_identificator = $this->name . "_id"; $r = new request(); if ($r->filter_text) { if (strpos($this->controller, "?") === false) { $this->controller .= "?prepend=1"; } $this->controller .= "&filter_text=" . $r->filter_text . "&filter_field=" . $r->filter_field; if ($r->filter_match) { $this->controller .= "&filter_match=1"; } } if ($r->{$_identificator}) { $this->__scaffoldobject->open($r->{$_identificator}); } $this->__gridobject->drop($this->__scaffoldobject); if ($r->{$action} == "insert") { $this->__scaffoldobject->fromObject($r); } $this->__formobject->drop($this->__scaffoldobject); switch ($r->{$action}) { default: $button_add = new button($this->button_add, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=add", "add"); $b = new box($this->name ? $this->name : "List", $this->__gridobject); if (!$this->__disable_add) { $b->addWidget($button_add); } return $b; break; case "add": $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=insert"; $this->__formobject->submit = $this->button_add; $this->__formobject->__target = $this->__formobject->action; return new box($this->name ? $this->name : "Add", $this->__formobject); break; case "insert": $this->__scaffoldobject->fromObject($r); if (is_array($this->__composites)) { foreach ($this->__composites as $k => $v) { $entity = $this->__composites[$k]["entity"]; $efield = $this->__composites[$k]["efield"]; $this->__scaffoldobject->composeField($k, $entity, $efield); } } if ($this->__scaffoldobject->insert()) { $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_ok)); $t = new toolbar(); $b->addWidget(html::write("<script>setTimeout(\"document.location='" . $this->controller . "'\",1000);</script>")); $b->addWidget($t); return $b; } else { $w = new oowidget(); $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_failed)); $b->addWidget(errorobject::errorList()); $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=insert"; $this->__formobject->submit = $this->button_add; $this->__formobject->__target = $this->__formobject->action; $b2 = new box($this->name ? $this->name : "Add", $this->__formobject); $w->addWidget($b); $w->addWidget($b2); $b->addWidget(new button($this->button_list, $this->controller)); return $w; } break; case "update": $tmpsf = $this->__scaffoldobject; $this->__scaffoldobject = new scaffold($this->name); $this->__scaffoldobject->__validators = $tmpsf->__validators; $this->__scaffoldobject->fromObject($r); if (is_array($this->__composites)) { foreach ($this->__composites as $k => $v) { $entity = $this->__composites[$k]["entity"]; $efield = $this->__composites[$k]["efield"]; $this->__scaffoldobject->composeField($k, $entity, $efield); } } if ($this->__scaffoldobject->update()) { $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_ok)); $t = new toolbar(); //$b->addWidget(new button($this->button_list, $this->controller)); $b->addWidget(html::write("<script>setTimeout(\"document.location='" . $this->controller . "'\",1000);</script>")); return $b; } else { $w = new oowidget(); $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=update&" . $this->name . "_id=" . $r->{$_identificator}; $this->__formobject->__target = $this->__formobject->action; $this->__formobject->submit = $this->button_update; $b2 = new box($this->name ? $this->name : "View", $this->__formobject); $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_failed)); $b->addWidget(errorobject::errorList()); $b->addWidget(new button($this->button_list, $this->controller)); $w->addWidget($b); $w->addWidget($b2); $b->addWidget(new button($this->button_list, $this->controller)); return $w; return $b; } break; case "view": $this->__formobject->action = $this->__formobject->action . (strpos($this->__formobject->action, "?") === false ? "?" : "&") . $action . "=update&" . $this->name . "_id=" . $r->{$_identificator}; $this->__formobject->__target = $this->__formobject->action; $this->__formobject->submit = $this->button_update; $b = new box($this->name ? $this->name : "View", $this->__formobject); for ($i = 0; $i < count($this->__additionalwidgets); $i++) { $b->addWidget($this->__additionalwidgets[$i]); } $t = new toolbar(); $t->addWidget(new button($this->button_list, $this->controller, "book_previous")); $t->addWidget(new button($this->button_delete, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=delete&" . $_identificator . "=" . $r->{$_identificator}, "delete")); $b->addWidget($t); return $b; break; case "delete": $b = new box($this->name ? $this->name : "Delete"); $b->addWidget(html::write($this->message_delete_confirm)); $t = new toolbar(); $t->addWidget(new button($this->button_delete, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=delete_confirm&" . $_identificator . "=" . $r->{$_identificator}, "delete")); $t->addWidget(new button($this->button_list, $this->controller . (strpos($this->controller, "?") === false ? "?" : "&") . $action . "=&" . $_identificator . "=" . $r->{$_identificator}, "book_previous")); $b->addWidget($t); return $b; break; case "delete_confirm": $this->__scaffoldobject->open($r->{$_identificator}); if ($this->__scaffoldobject->delete()) { $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_ok)); $t = new toolbar(); $t->addWidget(new button($this->button_list, $this->controller)); $t->addWidget(html::write("<meta http-equiv=\"refresh\" content=\"1; url=" . $this->controller . "\" />")); $b->addWidget($t); return $b; } else { $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_failed)); $b->addWidget(errorobject::errorList()); $b->addWidget(new button($this->button_list, $this->controller)); return $b; } break; } }