コード例 #1
0
ファイル: dataapp.class.php プロジェクト: Esleelkartea/arotz
 function dataapp($table, $controller, $mastercolumn)
 {
     $this->name = $table;
     $identificator = $table . "_id";
     $this->controller = $controller;
     $action = $this->name . "_action";
     $this->message_insert_ok = getClassConfig($this, "message_insert_ok");
     $this->message_insert_failed = getClassConfig($this, "message_insert_failed");
     $this->message_update_ok = getClassConfig($this, "message_update_ok");
     $this->message_update_failed = getClassConfig($this, "message_update_failed");
     $this->message_delete_ok = getClassConfig($this, "message_delete_ok");
     $this->message_delete_failed = getClassConfig($this, "message_delete_failed");
     $this->message_delete_confirm = getClassConfig($this, "message_delete_confirm");
     $this->button_add = getClassConfig($this, "button_add");
     $this->button_update = getClassConfig($this, "button_update");
     $this->button_delete = getClassConfig($this, "button_delete");
     $this->button_list = getClassConfig($this, "button_list");
     $this->__scaffoldobject = new scaffold($table);
     $this->__gridobject = new datagrid($mastercolumn, $controller . (strpos($controller, "?") === false ? "?" : "&") . $action . "=view&");
     $this->__gridobject->name = $this->name;
     $this->__scaffoldobject->id = $r->{$identificator};
     if (file_exists("ui/" . $table . ".ui")) {
         $this->__formobject = new uiform($table . ".ui", $controller);
     } else {
         $this->__formobject = new dataform($this->controller);
     }
     $this->__formobject->name = $this->name;
 }
コード例 #2
0
ファイル: ooentity.class.php プロジェクト: Esleelkartea/arotz
 function validate($errors = "")
 {
     $this->__invalid_data = getClassConfig(new ooentity(), "invalid_data");
     foreach ($this as $k => $v) {
         if (strpos("__", $k) === false) {
             for ($i = 0; $i < count($this->__validators[$k]); $i++) {
                 $function = $this->__validators[$k][$i];
                 if ($function == "is_checked") {
                     if ($v == "on") {
                         $this->{$k} = 1;
                     }
                     if ($v == "off") {
                         $this->{$k} = 0;
                     }
                 }
                 debug($this, "Validating " . $k . " with " . $function . " for value " . $v);
                 if ($function($v) === false) {
                     debug($this, "<font color=\"red\">Invalid field " . $k . " with value " . $v . "</font>");
                     $errors[] = $k;
                     $e = new errorobject($this, 1, $this->__invalid_data, $k);
                 } else {
                     debug($this, "<font color=\"green\">Valid field " . $k . " with value " . $v . "</font>");
                 }
             }
         }
     }
     if (count($errors) > 0) {
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: date.class.php プロジェクト: Esleelkartea/arotz
 function date($timestamp = "")
 {
     if ($timestamp) {
         $this->now = $timestamp;
     } else {
         $this->now = time();
     }
     //$this->timestamp = $this->now;
     $this->locale = getClassConfig($this, "locale");
 }
コード例 #4
0
ファイル: login.class.php プロジェクト: Esleelkartea/arotz
 function login($target, $logouttarget)
 {
     $this->target = $target;
     $this->logouttarget = $logouttarget;
     $this->username_caption = getClassConfig($this, "username_caption");
     $this->password_caption = getClassConfig($this, "password_caption");
     $this->realm_caption = getClassConfig($this, "realm_caption");
     $this->submit_caption = getClassConfig($this, "submit_caption");
     $this->logout_caption = getClassConfig($this, "logout_caption");
     $this->logged_in_caption = getClassConfig($this, "logged_in_caption");
     $this->logged_in_realm_caption = getClassConfig($this, "logged_in_realm_caption");
 }
コード例 #5
0
ファイル: database.class.php プロジェクト: Esleelkartea/arotz
 function database()
 {
     $this->accept("dataobject");
     $this->mysql_username = getClassConfig($this, "mysql_username");
     $this->mysql_password = getClassConfig($this, "mysql_password");
     $this->mysql_hostname = getClassConfig($this, "mysql_hostname");
     $this->mysql_database = getClassConfig($this, "mysql_database");
     $this->rowlimit = getClassConfig($this, "rowlimit");
     $this->link = mysql_pconnect($this->mysql_hostname, $this->mysql_username, $this->mysql_password);
     if (!$this->link) {
         ooerror(E_CODEERROR, "Could not connect to MySQL Database");
     }
     mysql_select_db($this->mysql_database, $this->link);
     mysql_select_db($database, $this->link);
 }
コード例 #6
0
 function dataobjectapp($object, $controller, $mastercolumn)
 {
     $this->controller = $controller;
     $this->message_insert_ok = getClassConfig($this, "message_insert_ok");
     $this->message_insert_failed = getClassConfig($this, "message_insert_failed");
     $this->message_update_ok = getClassConfig($this, "message_update_ok");
     $this->message_update_failed = getClassConfig($this, "message_update_failed");
     $this->message_delete_ok = getClassConfig($this, "message_delete_ok");
     $this->message_delete_failed = getClassConfig($this, "message_delete_failed");
     $this->button_add = getClassConfig($this, "button_add");
     $this->button_update = getClassConfig($this, "button_update");
     $this->button_delete = getClassConfig($this, "button_delete");
     $this->button_list = getClassConfig($this, "button_list");
     $this->__scaffoldobject = new $object();
     $this->__gridobject = new datagrid($mastercolumn, $controller . "?action=view");
     if (file_exists("ui/" . $table . ".ui")) {
         $this->__dataform = new uiform($table . ".ui", $controller);
     } else {
         $this->__dataform = new dataform($this->controller);
     }
 }
コード例 #7
0
 function boolwidget()
 {
     $this->true_text = getClassConfig($this, "true");
     $this->false_text = getClassConfig($this, "false");
 }
コード例 #8
0
ファイル: form.class.php プロジェクト: Esleelkartea/arotz
 function form($name, $action, $method = "POST")
 {
     $this->name = $name;
     $this->method = $method;
     $this->action = $action;
     $this->__submit = getClassConfig($this, "submit_caption");
 }
コード例 #9
0
ファイル: datagrid.class.php プロジェクト: Esleelkartea/arotz
 function drawWidget()
 {
     $object = $this->popMailbox();
     $r = new request();
     if (!$object) {
         return;
     }
     $filter = $this->name . "_filter";
     $filter_text = $filter . "_text";
     $filter_field = $filter . "_field";
     $out .= "<script src=\"oocommon/helpers/sorttable.js\" /></script>";
     if ($r->{$filter_text} != "") {
         if ($r->filter_match == 0) {
             $object->__query = "SELECT * FROM " . $object->__table . " WHERE " . $r->{$filter_field} . " LIKE '%" . $r->{$filter_text} . "%'";
         } else {
             $object->__query = "SELECT * FROM " . $object->__table . " WHERE " . $r->{$filter_field} . " ='" . $r->{$filter_text} . "'";
         }
         $rows = $object->getList();
     } else {
         $rows = $object->getList();
     }
     if (strpos($this->target, "?") != false) {
         $prepend = "?datagrid=1";
     }
     if ($this->toolbar) {
         if ($r->datagrid_window < 1) {
             $r->datagrid_window = 1;
         }
         $heout = "<table class=\"" . $this->__css_options . "\"><tr><td class=\"" . $this->__css_options . "\">\n\t\t\t\t" . ($r->datagrid_window > 1 ? "<button onclick=\"javascript:document.location='" . $_SERVER["PHP_SELF"] . "?datagrid_window=" . ($r->datagrid_window - 1) . ($r->{$filter_text} != "" ? "&" . $filter_text . "=" . $r->{$filter_text} . "&" . $filter_field . "=" . $r->{$filter_field} : "") . "'\"><img src=\"icons/16x16/actions/1leftarrow.png\">Anterior</button>" : "") . "\n \t\t\t\t" . ($r->datagrid_window * 20 < count($rows) ? "<button onclick=\"javascript:document.location='" . $_SERVER["PHP_SELF"] . "?datagrid_window=" . ($r->datagrid_window + 1) . ($r->{$filter_text} != "" ? "&" . $filter_text . "=" . $r->{$filter_text} . "&" . $filter_field . "=" . $r->{$filter_field} : "") . "'\">Siguiente <img src=\"icons/16x16/actions/1rightarrow.png\"></button>" : "") . "\n\t\t\t\t</td><td class=\"" . $this->__css_options . "\"> " . getClassConfig($this, "message_results") . " <b>" . ($r->datagrid_window * 20 - 20) . "</b> " . getClassConfig($this, "message_to") . " <b>" . ($r->datagrid_window * 20 > count($rows) ? count($rows) : $r->datagrid_window * 20) . " <b></b>  " . getClassConfig($this, "message_of") . "  <b>" . count($rows) . "</b> </td><td class=\"" . $this->__css_options . "\">";
         $heout .= count($rows) . " " . getClassConfig($this, "message_results");
         $heout .= "</td><td class=\"" . $this->__css_options . "\"><form method=\"post\" action=\"" . $_SERVER["PHP_SELF"] . "?datagrid=1&filter=1\"> ";
         $selector = getClassConfig($this, "message_filter") . "<select name=\"" . $this->name . "_filter_field\">";
         $fields = $object->getFields();
         for ($i = 0; $i < count($fields); $i++) {
             if (strpos($fields[$i], "id") === false && $this->__hidden[$fields[$i]] == "") {
                 $selector .= "<option " . ($r->{$filter_field} == $fields[$i] ? "selected" : "") . " value=\"" . $fields[$i] . "\">" . ($this->__headers[$fields[$i]] ? $this->__headers[$fields[$i]] : $fields[$i]) . "</option>";
             }
         }
         $selector .= "</select>";
         $selector_input = "<input type=\"text\" name=\"" . $this->name . "_filter_text\" value=\"" . $r->{$filter_text} . "\"><input type=\"submit\" value=\"" . getClassConfig($this, "message_filter") . "\">";
         $heout .= $selector . $selector_input . " " . ($r->{$filter_text} ? "<b>FILTRO ACTIVO</b>" : "") . "</form>";
         $heout .= "</td></tr></table>";
         $out .= $heout;
     }
     $tablename = md5(uniqid(rand()));
     $out .= "\n<table id=\"" . $tablename . "\" class=\"sortable\" >\n\t<tr>\n";
     if (is_array($rows[0])) {
         foreach ($rows[0] as $k => $v) {
             if ($k != "id" && !$this->__hidden[$k]) {
                 $out .= "\t\t<td id=\"" . $k . "\" onclick=\"javascript:sort('" . $tablename . "','" . $k . "');\" class=\"" . $this->__css_header . "\">" . ($this->__headers[$k] ? $this->__headers[$k] : $k) . "</td>\n";
             }
         }
     }
     $out .= "\t</tr>\n";
     if (count($rows > 20) || $r->datagrid_window < 1) {
         if ($r->datagrid_window != "") {
             $start = 20 * $r->datagrid_window - 20;
             $end = 22 * $r->datagrid_window;
         } else {
             $start = 0;
             $end = count($rows);
         }
     } else {
         $start = 0;
         $end = count($rows);
     }
     // CAMBIO LAGUN
     for ($i = 0; $i < count($rows); $i++) {
         $out .= "\t<tr class=\"" . $this->__css_mouseout . ($i % 2 == 0 ? "_odd" : "_even") . "\" onmouseover=\"javascript:this.className='" . $this->__css_mouseover . "'\" onmouseout=\"javascript:this.className='" . $this->__css_mouseout . ($i % 2 == 0 ? "_odd" : "_even") . "'\" onClick=\"javascript:document.location='" . $this->__target . ($this->slug ? "/" . $rows[$i]["id"] : $prepend . "" . $this->name . "_id=" . $rows[$i]["id"]) . ($r->{$filter_text} != "" ? "&" . $filter_text . "=" . $r->{$filter_text} . "&" . $filter_field . "=" . $r->{$filter_field} . ($r->filter_match ? "&filter_match=1" : "") : "") . "';\">\n";
         if ($rows[$i] != "") {
             foreach ($rows[$i] as $k => $v) {
                 unset($w);
                 if (!$this->__hidden[$k]) {
                     if (is_array($this->__fieldwidgets[$k])) {
                         if (is_object($this->__fieldwidgets[$k]["entity"]) === false) {
                             $ef = $this->__fieldwidgets[$k]["entityfield"];
                             $o = new $this->__fieldwidgets[$k]["entity"]();
                             $o->{$ef} = $v;
                             $w = new $this->__fieldwidgets[$k]["widget"]();
                             $w->drop($o);
                         } else {
                             $o = $this->__fieldwidgets[$k]["entity"];
                             $do = new dataobject();
                             foreach ($rows[$i] as $w => $s) {
                                 $do->{$w} = $s;
                             }
                             $o->drop($do);
                             $w = new $this->__fieldwidgets[$k]["widget"]();
                             $w->drop($o);
                         }
                         $out .= "<td class=\"" . $this->__css_field . "\">" . $w->draw() . "</td>";
                     } else {
                         if (is_array($this->__fieldobjects[$k]) && $v != "") {
                             $o = $this->__fieldobjects[$k]["object"];
                             if (is_object($o)) {
                                 $o->open($v);
                                 $key = $this->__fieldobjects[$k]["property"];
                                 $out .= "<td class=\"" . $this->__css_field . "\">" . $o->{$key} . "</td>";
                             }
                         } else {
                             if ($k != $this->__key && $k != "id") {
                                 $out .= "\t\t<td class=\"" . $this->__css_field . "\">" . $v . "&nbsp;</td>\n";
                             } else {
                                 if ($k != "id") {
                                     $out .= "\t\t<td class=\"" . $this->__css_field . "\"><a href=\"" . $this->__target . $prepend . "&" . $this->name . "_id=" . $rows[$i]["id"] . ($r->{$filter_text} != "" ? "&" . $filter_text . "=" . $r->{$filter_text} . "&" . $filter_field . "=" . $r->{$filter_field} . ($r->filter_match ? "&filter_match=1" : "") : "") . "\">" . $v . "</a></td>\n";
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $out .= "\t</tr>\n";
     }
     $out .= "</table>";
     return $out;
 }
コード例 #10
0
ファイル: user.class.php プロジェクト: Esleelkartea/arotz
 function user($id)
 {
     $table = getClassConfig($this, "users_table");
     $this->scaffold($table);
     $this->open($id);
 }
コード例 #11
0
ファイル: session.class.php プロジェクト: Esleelkartea/arotz
 function __install()
 {
     // Toma kludge!
     $db = new database();
     $db->query("SHOW TABLES");
     $exists = false;
     $__sessions_table = getClassConfig(new session(-1), "sessions_table");
     $__sessions_acl_table = getClassConfig(new session(-1), "sessions_acl_table");
     $__sessions_objects_table = getClassConfig(new session(-1), "sessions_objects_table");
     $__users_table = getClassConfig(new session(-1), "users_table");
     for ($i = 0; $i < count($db->rows); $i++) {
         if ($db->rows[$i]["Tables_in_" . $db->mysql_database] == $__users_table) {
             $exists = true;
         }
     }
     if ($exists == true) {
         return;
     }
     $db->query("\n\t\t\t\tCREATE TABLE " . $__sessions_table . " (id int(10) unsigned not null auto_increment,\n\t\t\t\tsid varchar(32),timestamp int(12),iduser int(10), PRIMARY KEY(id));");
     $db->query("\n\t\t\t\tCREATE TABLE " . $__users_table . " (id int(10) unsigned not null auto_increment,\n\t\t\t\tusername varchar(16), password varchar(32), misc text, timestamp int(12),lastsid varchar(32), PRIMARY KEY(id));");
     $db->query("\n\t\t\t\tCREATE TABLE " . $__sessions_objects_table . " (id int(10) unsigned not null auto_increment,\n\t\t\t\tsid varchar(32), o text, PRIMARY KEY(id));");
     $db->query("\n\t\t\t\tCREATE TABLE " . $__sessions_acl_table . " (id int(10) unsigned not null auto_increment,\n\t\t\t\tiduser int(10), object varchar(32), method varchar(32), PRIMARY KEY(id));");
 }