Plugin Directory

Changeset 993971


Ignore:
Timestamp:
09/20/2014 05:09:58 PM (12 years ago)
Author:
freshlabs
Message:

Fixed array index errors for dates on page load (1-dimensional) and submit (multidimensional)

Location:
wp-simile-timeline/trunk/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wp-simile-timeline/trunk/inc/WPSimileTimelineDecorator.class.php

    r993931 r993971  
    7979            }
    8080            if(is_array($data)){
    81                 $this->start_date = adodb_date2('Y-m-d H:i:s', $data['start_date']);
    82                 $this->end_date = adodb_date2('Y-m-d H:i:s', $data['end_date']);
     81                if(sizeof($data['start_date']) > 1){
     82                    $ds1 = $data['start_date']['year'].'-'.$data['start_date']['month'].'-'.$data['start_date']['day'].' '.$data['start_date']['hour'].':'.$data['start_date']['minute'].':'.$data['start_date']['second'];
     83                    $ds2 = $data['end_date']['year']  .'-'.$data['end_date']['month']  .'-'.$data['end_date']['day']  .' '.$data['end_date']['hour']  .':'.$data['end_date']['minute']  .':'.$data['end_date']['second'];
     84                }
     85                else{
     86                    $ds1 = $data['start_date'];
     87                    $ds2 = $data['end_date'];
     88                }
     89                $this->start_date = adodb_date2('Y-m-d H:i:s', $ds1);
     90                $this->end_date = adodb_date2('Y-m-d H:i:s', $ds2);
    8391            }
    8492    }
  • wp-simile-timeline/trunk/inc/WPSimileTimelineHotzone.class.php

    r993931 r993971  
    3737   
    3838    function WPSimileTimelineHotzone(){
    39             // empty constructor
     39        // empty constructor
    4040    }
    4141   
     
    4545    function createTable(){
    4646           
    47             global $wpdb;
    48 
    49             $hotzone_object = new WPSimileTimelineHotzone();
    50             $table_name = $wpdb->prefix . $hotzone_object->table_name;
    51             if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
    52 
    53                     $sql = "CREATE TABLE " . $table_name . " (
    54                               `id` int(11) NOT NULL auto_increment,
    55                               `name` varchar(210) NOT NULL,
    56                               `stl_timeline_band_id` int(11) NOT NULL,
    57                               `start_date` datetime NOT NULL,
    58                               `end_date` datetime NOT NULL,
    59                               `magnify` int(11) NOT NULL,
    60                               `multiple` int(11) NOT NULL,
    61                               `unit` int(11) NOT NULL,
    62                               PRIMARY KEY  (`id`)
    63                             );";
    64 
    65                     require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    66                     dbDelta($sql);
     47        global $wpdb;
     48       
     49        $hotzone_object = new WPSimileTimelineHotzone();
     50        $table_name = $wpdb->prefix . $hotzone_object->table_name;
     51        if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
     52   
     53            $sql = "CREATE TABLE " . $table_name . " (
     54                  `id` int(11) NOT NULL auto_increment,
     55                  `name` varchar(210) NOT NULL,
     56                  `stl_timeline_band_id` int(11) NOT NULL,
     57                  `start_date` datetime NOT NULL,
     58                  `end_date` datetime NOT NULL,
     59                  `magnify` int(11) NOT NULL,
     60                  `multiple` int(11) NOT NULL,
     61                  `unit` int(11) NOT NULL,
     62                  PRIMARY KEY  (`id`)
     63                );";
     64   
     65            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
     66            dbDelta($sql);
    6767       }
    6868    }
     
    7373            }
    7474            if(is_array($data)){
    75                 /*
    76                 $ds1 = $data['start_date']['year'].'-'.$data['start_date']['month'].'-'.$data['start_date']['day'].' '.$data['start_date']['hour'].':'.$data['start_date']['minute'].':'.$data['start_date']['second'];
    77                 $ds2 = $data['end_date']['year']  .'-'.$data['end_date']['month']  .'-'.$data['end_date']['day']  .' '.$data['end_date']['hour']  .':'.$data['end_date']['minute']  .':'.$data['end_date']['second'];
    78                 */
    79                 $this->start_date = adodb_date2('Y-m-d H:i:s', $date['start_date']);
    80                 $this->end_date = adodb_date2('Y-m-d H:i:s', $date['end_date']);
     75                if(sizeof($data['start_date']) > 1){
     76                    $ds1 = $data['start_date']['year'].'-'.$data['start_date']['month'].'-'.$data['start_date']['day'].' '.$data['start_date']['hour'].':'.$data['start_date']['minute'].':'.$data['start_date']['second'];
     77                    $ds2 = $data['end_date']['year']  .'-'.$data['end_date']['month']  .'-'.$data['end_date']['day']  .' '.$data['end_date']['hour']  .':'.$data['end_date']['minute']  .':'.$data['end_date']['second'];
     78                }
     79                else{
     80                    $ds1 = $data['start_date'];
     81                    $ds2 = $data['end_date'];
     82                }
     83                $this->start_date = adodb_date2('Y-m-d H:i:s', $ds1);
     84                $this->end_date = adodb_date2('Y-m-d H:i:s', $ds2);
    8185            }
    8286    }
     
    8690     */
    8791    function save(){
    88             global $wpdb;
     92        global $wpdb;
    8993
    90             if(isset($this->id) && $this->id != 'new'){
    91                     // update existing hotzone
    92                     $query = "UPDATE ".$wpdb->prefix. $this->table_name .
    93                     " SET name=%s, unit=%d,
    94                     start_date=%s,
    95                     end_date=%s,
    96                     magnify=%d,
    97                     multiple=%d
    98                     WHERE id=%d";
    99                     $wpdb->query($wpdb->prepare($query, $this->name, $this->unit, $this->start_date, $this->end_date, $this->magnify, $this->multiple, $this->id));
    100             }
    101             else{
    102                     // insert new hotzone entry
    103                     $wpdb->insert(
    104                             $wpdb->prefix. $this->table_name,
    105                             array(
    106                                     'name' => $this->name,
    107                                     'unit' => $this->unit,
    108                                     'start_date' => $this->start_date,
    109                                     'end_date' => $this->end_date,
    110                                     'magnify' => $this->magnify,
    111                                     'multiple' => $this->multiple,
    112                                     'stl_timeline_band_id' => $this->stl_timeline_band_id
    113                             ),
    114                             array('%s','%d','%s','%s','%d','%d','%d')
    115                     );
    116             }
     94        if(isset($this->id) && $this->id != 'new'){
     95            // update existing hotzone
     96            $query = "UPDATE ".$wpdb->prefix. $this->table_name .
     97            " SET name=%s, unit=%d,
     98            start_date=%s,
     99            end_date=%s,
     100            magnify=%d,
     101            multiple=%d
     102            WHERE id=%d";
     103            $wpdb->query($wpdb->prepare($query, $this->name, $this->unit, $this->start_date, $this->end_date, $this->magnify, $this->multiple, $this->id));
     104        }
     105        else{
     106            // insert new hotzone entry
     107            $wpdb->insert(
     108                $wpdb->prefix. $this->table_name,
     109                array(
     110                    'name' => $this->name,
     111                    'unit' => $this->unit,
     112                    'start_date' => $this->start_date,
     113                    'end_date' => $this->end_date,
     114                    'magnify' => $this->magnify,
     115                    'multiple' => $this->multiple,
     116                    'stl_timeline_band_id' => $this->stl_timeline_band_id
     117                ),
     118                array('%s','%d','%s','%s','%d','%d','%d')
     119            );
     120        }
    117121    }
    118122   
Note: See TracChangeset for help on using the changeset viewer.