Changeset 993971
- Timestamp:
- 09/20/2014 05:09:58 PM (12 years ago)
- Location:
- wp-simile-timeline/trunk/inc
- Files:
-
- 2 edited
-
WPSimileTimelineDecorator.class.php (modified) (1 diff)
-
WPSimileTimelineHotzone.class.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-simile-timeline/trunk/inc/WPSimileTimelineDecorator.class.php
r993931 r993971 79 79 } 80 80 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); 83 91 } 84 92 } -
wp-simile-timeline/trunk/inc/WPSimileTimelineHotzone.class.php
r993931 r993971 37 37 38 38 function WPSimileTimelineHotzone(){ 39 // empty constructor39 // empty constructor 40 40 } 41 41 … … 45 45 function createTable(){ 46 46 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); 67 67 } 68 68 } … … 73 73 } 74 74 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); 81 85 } 82 86 } … … 86 90 */ 87 91 function save(){ 88 global $wpdb;92 global $wpdb; 89 93 90 if(isset($this->id) && $this->id != 'new'){91 // update existing hotzone92 $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=%d98 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 entry103 $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_id113 ),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 } 117 121 } 118 122
Note: See TracChangeset
for help on using the changeset viewer.