Beispiel #1
0
 function drawWidget()
 {
     $s = new session();
     if (session::check() != false) {
         $w = new box($this->logged_in_realm_caption);
         $w->css_box = "login";
         $w->addWidget(html::write($this->logged_in_caption . $s->user->username));
         $w->addWidget(new button($this->logout_caption, $this->logouttarget . "?logout=1"));
         return $w->draw();
     }
     $h = new html();
     $h->html .= "\n\t\t\t\t\t\n\t\t\t\t\t<form method=\"post\" action=\"" . $this->target . "\">\n\t\t\t\t\t<table>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td colspan=\"2\">\n\t\t\t\t\t\t\t" . $this->realm_caption . "\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t<tr><td>" . $this->username_caption . "</td><td><input type=\"text\" name=\"username\"></td></tr>\t\t\t\n\t\t\t\t\t\t<tr><td>" . $this->password_caption . "</td><td><input type=\"password\" name=\"password\"></td></tr>\n\t\t\t\t\t\t<tr><td><input type=\"submit\" value=\"" . $this->submit_caption . "\"></td></tr></table></form>";
     $b = new box($this->realm_caption, $h);
     $b->css_box = "login";
     return $b->draw();
 }
 function predrawWidget()
 {
     $r = new request();
     if ($r->id) {
         $this->__scaffoldobject->open($r->id);
     }
     $this->__gridobject->drop($this->__scaffoldobject);
     $this->__dataform->drop($this->__scaffoldobject);
     switch ($r->action) {
         default:
             $button_add = new button($this->button_add, $this->controller . "?action=add");
             $b = new box($this->name ? $this->name : "List", $this->__gridobject);
             $b->addWidget($button_add);
             return $b;
             break;
         case "add":
             $this->__dataform->action = $this->__dataform->action . "?action=insert";
             $this->__dataform->submit = $this->button_add;
             $this->__dataform->__target = $this->__dataform->action;
             return new box($this->name ? $this->name : "Add", $this->__dataform);
             break;
         case "insert":
             $this->__scaffoldobject->fromObject($r);
             if ($this->__scaffoldobject->insert()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_ok));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             } else {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_insert_failed));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             }
             break;
         case "update":
             $this->__scaffoldobject->open($r->id);
             $this->__scaffoldobject->fromObject($r);
             if ($this->__scaffoldobject->update()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_ok));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             } else {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_update_failed));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             }
             break;
         case "view":
             $this->__dataform->action = $this->__dataform->action . "?action=update&id=" . $r->id;
             $this->__dataform->__target = $this->__dataform->action;
             $this->__dataform->submit = $this->button_update;
             $b = new box($this->name ? $this->name : "View", $this->__dataform);
             $b->addWidget(new button($this->button_list, $this->controller));
             $b->addWidget(new button($this->button_delete, $this->controller . "?action=delete&id=" . $r->id));
             return $b;
             break;
         case "delete":
             $this->__scaffoldobject->open($r->id);
             if ($this->__scaffoldobject->delete()) {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_ok));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             } else {
                 $b = new box($this->name ? $this->name : "Message", html::write($this->message_delete_failed));
                 $b->addWidget(new button($this->button_list, $this->controller));
                 return $b;
             }
             break;
     }
 }
Beispiel #3
0
 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;
     }
 }