Exemple #1
0
 protected function Processing()
 {
     if (!self::$user_func_result) {
         return false;
     }
     if (isset($this->user_func) && $this->user_func != '') {
         if (call_user_func($this->user_func)) {
             return true;
         } else {
             self::$user_func_result = false;
             return false;
         }
     }
     return true;
 }
Exemple #2
0
 protected function Processing()
 {
     if (count($_GET) == 0 || !parent::Processing()) {
         return false;
     }
     $join_id = $this->join_sql->SelectArray();
     $join_id = $join_id[0];
     $new_join_array = array();
     $delete_sql = '';
     foreach ($this->elements as $name => $element) {
         if (!isset($_GET[$name])) {
             $element->SetValue(false);
             continue;
         }
         $pos = strrpos($name, "_");
         $id = substr($name, $pos + 1);
         $new_join_array[] = $id;
         $element->SetURLValue(true);
         $delete_sql .= $join_id . "!='" . $id . "' AND ";
     }
     if (!$this->inserted) {
         if (strlen($delete_sql) > 0) {
             $delete_sql = substr($delete_sql, 0, -5);
         }
         $delete_sql = "DELETE FROM " . $this->join_sql->FromString() . " WHERE " . $this->join_sql->WhereString() . (strlen($delete_sql) > 0 ? " AND " . $delete_sql : '');
         //echo $delete_sql."<BR />";
         $this->db->Query($delete_sql);
     }
     if (count($new_join_array) == 0) {
         return;
     }
     if ($this->inserted) {
         if (!($insert_id = $this->db->Insert_ID())) {
             throw new Exception("Ошибка определения последней добавленной записи в БД");
         }
     } else {
         $insert_id = $this->where_array[1];
     }
     foreach ($new_join_array as $jid) {
         if (isset($this->join_array[$jid])) {
             continue;
         }
         $insert_sql = "INSERT INTO " . $this->join_sql->FromString() . " (" . $this->where_array[0] . ", " . $join_id . ") " . "VALUES ('" . $insert_id . "', '" . $jid . "')";
         //echo $insert_sql."<BR />";
         $this->db->Query($insert_sql);
     }
     return true;
 }
Exemple #3
0
 protected function Processing()
 {
     if (count($_GET) == 0 || !parent::Processing()) {
         return false;
     }
     $insert_sql = '';
     $cols = $this->sql->InsertArray();
     foreach ($cols as $cname) {
         if (is_a($this->elements[$cname], "FCheckbox")) {
             $this->elements[$cname]->SetValue(isset($_GET[$this->elements[$cname]->GetName()]) ? true : false);
         } else {
             $this->elements[$cname]->SetURLValue(isset($_GET[$this->elements[$cname]->GetName()]) ? $_GET[$this->elements[$cname]->GetName()] : '');
         }
         $insert_sql .= "'" . $this->elements[$cname]->GetValue() . "', ";
     }
     $insert_sql = substr($insert_sql, 0, -2);
     // убираем лишнюю запятую
     $sql = "INSERT INTO " . $this->sql->InsertIntoString() . " VALUES (" . $insert_sql . ")";
     //		echo $sql."<br />";
     $this->db->Query($sql);
     return true;
 }
Exemple #4
0
 protected function Processing()
 {
     if (count($_GET) == 0 || !parent::Processing()) {
         return false;
     }
     $sql_set = '';
     $cols = array_flip($this->sql->SelectArray());
     foreach ($this->elements as $name => $element) {
         if (!isset($_GET[$element->GetName()])) {
             continue;
         }
         $element->SetURLValue($_GET[$element->GetName()]);
         if (!isset($cols[$name]) || !$element->Changed()) {
             continue;
         }
         $sql_set .= $name . "='" . $element->GetValue() . "', ";
     }
     foreach ($this->checkboxs as $name => $cbx) {
         if ($cbx->Changed() || isset($_GET[$cbx->GetName()])) {
             continue;
         }
         $cbx->SetURLValue(false);
         if (!$cbx->Changed()) {
             continue;
         }
         $sql_set .= $name . "='" . $cbx->GetValue() . "', ";
     }
     if (strlen($sql_set) == 0) {
         return;
     }
     $sql_set = substr($sql_set, 0, -2);
     // убираем лишнюю запятую
     $sql = "UPDATE " . $this->sql->FromString() . " SET " . $sql_set . " " . "WHERE " . $this->sql->WhereString();
     //echo $sql;
     $this->db->Query($sql);
     return true;
 }
 final function __toString()
 {
     $html = $this->open();
     $html .= parent::__toString();
     $html .= $this->close();
     return $html;
 }
Exemple #6
0
 function AsString()
 {
     $this->elements[] = new FBlock($this->custom_buttons . "<input " . (!$this->goback ? "id=\"t_serv\" " : '') . "type='submit' value='" . ($this->submit_text == '' ? SUBMITTEXT : $this->submit_text) . "'>\n");
     $str = "<form id='" . $this->id . "' action='' method='GET'>\n" . parent::AsString() . "</form>";
     return $str;
 }