Ignore:
Timestamp:
12/10/2008 04:45:22 PM (3 years ago)
Author:
Ernest0x
Message:

PHP 5.x fixes (mostly fixes for warnings and notices)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/globals/classes/form.php

    r6 r187  
    7373                                $this->data[$i]['Pickup_url'] = makelink(array("page" => "pickup", "subpage" => $subpage, "object" => $this->info['FORM_NAME'].".elements['".str_replace(".", "__", $data_field).($multi==FALSE?'':"[]")."']")); 
    7474                                if ($multi == FALSE) { 
    75                                         $this->data[$i]['Type_Pickup'] = $values[0]; 
     75                                        $this->data[$i]['Type_Pickup'] = (isset($values[0])?$values[0]:''); 
    7676                                } else { 
    7777                                        $this->data[$i]['Type_Pickup'] = $values; 
     
    9191                        for($i=0;$i<count($this->data);$i++) { 
    9292                                $key = explode("__", $this->data[$i]['fullField']); 
    93                                 if ($key[1] != '') { 
     93                                if (isset($key[1])) { 
    9494                                        if ($ckey == $key[0]) { 
    95                                                 $this->data[$i]['value'] = $db_data[0][$key[1]]; 
     95                                                $this->data[$i]['value'] = (isset($db_data[0][$key[1]])?$db_data[0][$key[1]]:""); 
    9696                                        } 
    9797                                } 
     
    125125                for ($i=0;$i<count($this->data);$i++) { 
    126126                        if (isset($this->data[$i])) { 
    127                                 $this->data[$i]['value'] = (isset($_POST[$this->data[$i]['fullField']]) ? $_POST[$this->data[$i]['fullField']] : $sc[$this->data[$i]['fullField']]); 
     127                                if (isset($sc[$this->data[$i]['fullField']])) { 
     128                                        $sc_dati_ff = $sc[$this->data[$i]['fullField']]; 
     129                                } 
     130                                else {  
     131                                        $sc_dati_ff = '';  
     132                                } 
     133                                $this->data[$i]['value'] = (isset($_POST[$this->data[$i]['fullField']]) ? $_POST[$this->data[$i]['fullField']] : $sc_dati_ff); 
    128134                                if (isset($this->data[$i]['Compare'])) { 
    129                                         $this->data[$i]['Compare_value'] = (isset($_POST[$this->data[$i]['fullField'].'_compare']) ? $_POST[$this->data[$i]['fullField'].'_compare'] : $sc[$this->data[$i]['fullField'].'_compare']); 
     135                                        if (isset($sc[$this->data[$i]['fullField'].'_compare'])) { 
     136                                            $sc_dati_ff_cmp = $sc[$this->data[$i]['fullField'].'_compare']; 
     137                                        } 
     138                                        else { 
     139                                            $sc_dati_ff_cmp = ''; 
     140                                        } 
     141                                        $this->data[$i]['Compare_value'] = (isset($_POST[$this->data[$i]['fullField'].'_compare']) ? $_POST[$this->data[$i]['fullField'].'_compare'] : $sc_dati_ff_cmp); 
    130142                                } 
    131143                                $this->data[$i]['Null'] = 'YES'; 
     
    136148        // get the where string for SQL. $extra[_fieldname_]: '=' | 'starts_with' | 'ends_with' | 'contains' | 'exclude' 
    137149        function db_data_where($extra="") { 
     150                $where = ""; 
    138151                for ($i=0;$i<count($this->data);$i++) { 
    139152                        if (isset($this->data[$i])) { 
     
    143156                                } 
    144157                                $value = $this->data[$i]['value']; 
    145                                 switch ($extra[$item]) { 
     158                                switch (isset($extra[$item])?$extra[$item]:'') { 
    146159                                        case '': 
    147160                                        case '=': 
     
    183196                global $db; 
    184197                if (!is_array($pdata)) $pdata = array(); 
     198                $ret = TRUE; 
     199                $args = func_get_args(); 
     200                for ($carg=1;$carg<func_num_args() || $carg==1;$carg=$carg+3) { 
     201                        $ckey = isset($args[$carg])?$args[$carg]:''; 
     202                        unset($data); 
     203                        $cpost = $this->correct_datetime_data($_POST); 
     204                        for($i=0;$i<count($this->data);$i++) { 
     205                                $key = explode("__", $this->data[$i]['fullField']); 
     206                                if (isset($key[1])) { 
     207                                        if ($ckey == '') $ckey = $key[0]; 
     208                                        if ($ckey == $key[0]) { 
     209                                                if (isset($cpost[$this->data[$i]['fullField']])) { 
     210                                                    if (!is_array($cpost[$this->data[$i]['fullField']])) { 
     211                                                                $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 
     212                                                    } 
     213                                                } 
     214                                        } 
     215                                } 
     216                        } 
     217                        reset($pdata); 
     218                        while (list($key, $value) = each($pdata)) { 
     219                                $key = explode(".", $key); 
     220                                if ($ckey == $key[0] || !isset($key[1])) { 
     221                                        $data[(isset($key[1])?$key[1]:$key[0])] = $value; 
     222                                } 
     223                        } 
     224                        $field = isset($args[$carg+1])?$args[$carg+1]:''; 
     225                        $value = isset($args[$carg+2])?$args[$carg+2]:''; 
     226                        if ($field == '' || $value == '' || $value == 'add') { 
     227                                $ret = $ret && $db->add($ckey, $data); 
     228                        } else { 
     229                                $ret = $ret && $db->set($ckey, $data, "$field = '$value'"); 
     230                        } 
     231                } 
     232                return $ret; 
     233        } 
     234         
     235        // pdata: extra data, args: [[table], [key] [value] ...] 
     236        function db_set_multi($pdata=array()) {  
     237                global $db; 
    185238                $ret = TRUE; 
    186239                $args = func_get_args(); 
     
    191244                        for($i=0;$i<count($this->data);$i++) { 
    192245                                $key = explode("__", $this->data[$i]['fullField']); 
    193                                 if ($key[1] != '') { 
     246                                if (isset($key[1])) { 
    194247                                        if ($ckey == '') $ckey = $key[0]; 
    195248                                        if ($ckey == $key[0]) { 
    196                                                 if (!is_array($cpost[$this->data[$i]['fullField']])) { 
    197                                                         $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 
    198                                                 } 
     249                                                $data[$key[1]] = (isset($cpost[$this->data[$i]['fullField']]))?$cpost[$this->data[$i]['fullField']]:NULL; 
    199250                                        } 
    200251                                } 
     
    203254                        while (list($key, $value) = each($pdata)) { 
    204255                                $key = explode(".", $key); 
    205                                 if ($ckey == $key[0] || $key[1] == '') { 
    206                                         $data[($key[1]==''?$key[0]:$key[1])] = $value; 
    207                                 } 
    208                         } 
    209                         $field = $args[$carg+1]; 
    210                         $value = $args[$carg+2]; 
    211                         if ($field == '' || $value == '' || $value == 'add') { 
    212                                 $ret = $ret && $db->add($ckey, $data); 
    213                         } else { 
    214                                 $ret = $ret && $db->set($ckey, $data, "$field = '$value'"); 
    215                         } 
    216                 } 
    217                 return $ret; 
    218         } 
    219          
    220         // pdata: extra data, args: [[table], [key] [value] ...] 
    221         function db_set_multi($pdata=array()) {  
    222                 global $db; 
    223                 $ret = TRUE; 
    224                 $args = func_get_args(); 
    225                 for ($carg=1;$carg<func_num_args() || $carg==1;$carg=$carg+3) { 
    226                         $ckey = $args[$carg]; 
    227                         unset($data); 
    228                         $cpost = $this->correct_datetime_data($_POST); 
    229                         for($i=0;$i<count($this->data);$i++) { 
    230                                 $key = explode("__", $this->data[$i]['fullField']); 
    231                                 if ($key[1] != '') { 
    232                                         if ($ckey == '') $ckey = $key[0]; 
    233                                         if ($ckey == $key[0]) { 
    234                                                 $data[$key[1]] = $cpost[$this->data[$i]['fullField']]; 
    235                                         } 
    236                                 } 
    237                         } 
    238                         reset($pdata); 
    239                         while (list($key, $value) = each($pdata)) { 
    240                                 $key = explode(".", $key); 
    241                                 if ($ckey == $key[0] || $key[1] == '') { 
    242                                         $data[($key[1]==''?$key[0]:$key[1])] = $value; 
     256                                if ($ckey == $key[0] || !isset($key[1])) { 
     257                                        $data[(!isset($key[1])?$key[0]:$key[1])] = $value; 
    243258                                } 
    244259                        } 
     
    253268                        } 
    254269                        $ret = $ret && $db->del($ckey, $args[$carg+1]." = '".$args[$carg+2]."'"); 
    255                         for ($i=0;$i<count($data_f);$i++) { 
    256                                 $data_f[$i][$args[$carg+1]] = $args[$carg+2]; 
    257                                 $ret = $ret && $db->add($ckey, $data_f[$i]); 
     270                        if (isset($data_f)) { 
     271                                for ($i=0;$i<count($data_f);$i++) { 
     272                                        $data_f[$i][$args[$carg+1]] = $args[$carg+2]; 
     273                                        $ret = $ret && $db->add($ckey, $data_f[$i]); 
     274                                } 
    258275                        } 
    259276                } 
Note: See TracChangeset for help on using the changeset viewer.