Event List - Version 0.2.2

Version Description

(2012-11-18) =

  • localization of date and time on the frontpage
  • changed and localized date and time view in the admin event list table
  • localization of date in the new event form
Download this release

Release Info

Developer mibuthu
Plugin Icon 128x128 Event List
Version 0.2.2
Comparing to
See all releases

Code changes from version 0.2.1 to 0.2.2

css/admin_main.css CHANGED
@@ -1,5 +1,5 @@
1
  .wp-list-table .column-date {
2
- width: 140px;
3
  }
4
  .wp-list-table .column-title {
5
  width: 35%;
@@ -11,10 +11,10 @@
11
  width: 40%;
12
  }
13
  .wp-list-table .column-pub_user {
14
- width: 90px;
15
  }
16
  .wp-list-table .column-pub_date {
17
- width: 150px;
18
  }
19
 
20
  span.time {
1
  .wp-list-table .column-date {
2
+ width: 105px;
3
  }
4
  .wp-list-table .column-title {
5
  width: 35%;
11
  width: 40%;
12
  }
13
  .wp-list-table .column-pub_user {
14
+ width: 105px;
15
  }
16
  .wp-list-table .column-pub_date {
17
+ width: 115px;
18
  }
19
 
20
  span.time {
event-list.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
- Version: 0.2.1
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
3
  Plugin Name: Event List
4
  Plugin URI: http://wordpress.org/extend/plugins/event-list/
5
  Description: Manage your events and show them in a list view on your site.
6
+ Version: 0.2.2
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
js/admin_new.js CHANGED
@@ -5,7 +5,7 @@ jQuery(document).ready(function( $ ) {
5
  // Read required config data from hidden field json_for_js
6
  var json = $("#json_for_js").val();
7
  var conf = eval('(' + json + ')');
8
-
9
  // Show or hide end_date
10
  if ($("#start_date").val() == $("#end_date").val()) {
11
  $("#end_date_area").hide();
@@ -13,10 +13,10 @@ jQuery(document).ready(function( $ ) {
13
  else {
14
  $("#multiday").attr('checked', true);
15
  }
16
-
17
  // Datepickers
18
  $("#start_date").datepicker( {
19
- dateFormat: "yy-mm-dd",
20
  firstDay: 1,
21
  changeMonth: true,
22
  changeYear: true,
@@ -33,7 +33,7 @@ jQuery(document).ready(function( $ ) {
33
  }
34
  });
35
  $("#end_date").datepicker( {
36
- dateFormat: "yy-mm-dd",
37
  firstDay: 1,
38
  changeMonth: true,
39
  changeYear: true,
@@ -43,7 +43,7 @@ jQuery(document).ready(function( $ ) {
43
  buttonImageOnly: true,
44
  constrainInput: true
45
  });
46
-
47
  // Toogle end_date visibility and insert the correct date
48
  $("#multiday").click(function() {
49
  var enddate = $("#start_date").datepicker("getDate");
@@ -59,4 +59,4 @@ jQuery(document).ready(function( $ ) {
59
  }
60
  $("#end_date").datepicker("setDate", enddate);
61
  });
62
- });
5
  // Read required config data from hidden field json_for_js
6
  var json = $("#json_for_js").val();
7
  var conf = eval('(' + json + ')');
8
+
9
  // Show or hide end_date
10
  if ($("#start_date").val() == $("#end_date").val()) {
11
  $("#end_date_area").hide();
13
  else {
14
  $("#multiday").attr('checked', true);
15
  }
16
+
17
  // Datepickers
18
  $("#start_date").datepicker( {
19
+ dateFormat: conf.el_date_format,
20
  firstDay: 1,
21
  changeMonth: true,
22
  changeYear: true,
33
  }
34
  });
35
  $("#end_date").datepicker( {
36
+ dateFormat: conf.el_date_format,
37
  firstDay: 1,
38
  changeMonth: true,
39
  changeYear: true,
43
  buttonImageOnly: true,
44
  constrainInput: true
45
  });
46
+
47
  // Toogle end_date visibility and insert the correct date
48
  $("#multiday").click(function() {
49
  var enddate = $("#start_date").datepicker("getDate");
59
  }
60
  $("#end_date").datepicker("setDate", enddate);
61
  });
62
+ });
php/admin.php CHANGED
@@ -194,6 +194,7 @@ class el_admin {
194
  }
195
 
196
  private static function edit_event() {
 
197
  $edit = false;
198
  if( isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
199
  // existing event
@@ -202,17 +203,18 @@ class el_admin {
202
  // editing of an existing event, if not it would be copy of an existing event
203
  $edit = true;
204
  }
205
- $start_date = $event->start_date;
206
- $end_date = $event->end_date;
207
  }
208
  else {
209
  //new event
210
- $start_date = date( 'Y-m-d', time()+1*24*60*60 );
211
  $end_date = $start_date;
212
  }
213
 
214
  // Add required data for javascript in a hidden field
215
- $json = json_encode( Array( 'el_url' => EL_URL ) );
 
216
  $out = "<input type='hidden' id='json_for_js' value='".$json."' />";
217
  $out .= '<form method="POST" action="?page=el_admin_main">';
218
  if( true === $edit ) {
@@ -225,7 +227,9 @@ class el_admin {
225
  </tr>
226
  <tr>
227
  <th><label>Event Date (required)</label></th>
228
- <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.$start_date.'" /><span id="end_date_area"> - <input type="text" class="text datepicker" name="end_date" id="end_date" value="'.$end_date.'" /></span> <label><input type="checkbox" name="multiday" id="multiday" value="1" /> Multi-Day Event</label></td>
 
 
229
  </tr>
230
  <tr>
231
  <th><label>Event Time</label></th>
@@ -261,19 +265,19 @@ class el_admin {
261
  // event added
262
  if( 'added' === self::$event_action ) {
263
  if( false === self::$event_action_error ) {
264
- $out .= '<div id="message" class=updated below-h2"><p>New Event "'.$_POST['title'].'" was added.</p></div>';
265
  }
266
  else {
267
- $out .= '<div id="message" class=error below-h2"><p>Error: New Event "'.$_POST['title'].'" could not be added.</p></div>';
268
  }
269
  }
270
  // event modified
271
  elseif( 'modified' === self::$event_action ) {
272
  if( false === self::$event_action_error ) {
273
- $out .= '<div id="message" class=updated below-h2"><p>Event "'.$_POST['title'].'" (id: '.$_POST['id'].') was modified.</p></div>';
274
  }
275
  else {
276
- $out .= '<div id="message" class=error below-h2"><p>Error: Event "'.$_POST['title'].'" (id: '.$_POST['id'].') could not be modified.</p></div>';
277
  }
278
  }
279
  // event deleted
@@ -284,10 +288,10 @@ class el_admin {
284
  $plural = 's';
285
  }
286
  if( false === self::$event_action_error ) {
287
- $out .= '<div id="message" class=updated below-h2"><p>'.$num_deleted.' Event'.$plural.' deleted (id'.$plural.': '.$_GET['id'].').</p></div>';
288
  }
289
  else {
290
- $out .= '<div id="message" class=error below-h2"><p>Error while deleting '.$num_deleted.' Event'.$plural.'.</p></div>';
291
  }
292
  }
293
  return $out;
@@ -376,5 +380,23 @@ class el_admin {
376
  <textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
377
  return $out;
378
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  }
380
  ?>
194
  }
195
 
196
  private static function edit_event() {
197
+ $date_format = __( 'Y/m/d' ); // similar date format than in list tables (e.g. post, pages, media)
198
  $edit = false;
199
  if( isset( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
200
  // existing event
203
  // editing of an existing event, if not it would be copy of an existing event
204
  $edit = true;
205
  }
206
+ $start_date = strtotime( $event->start_date );
207
+ $end_date = strtotime( $event->end_date );
208
  }
209
  else {
210
  //new event
211
+ $start_date = time()+1*24*60*60;
212
  $end_date = $start_date;
213
  }
214
 
215
  // Add required data for javascript in a hidden field
216
+ $json = json_encode( array( 'el_url' => EL_URL,
217
+ 'el_date_format' => self::datepicker_format( $date_format ) ) );
218
  $out = "<input type='hidden' id='json_for_js' value='".$json."' />";
219
  $out .= '<form method="POST" action="?page=el_admin_main">';
220
  if( true === $edit ) {
227
  </tr>
228
  <tr>
229
  <th><label>Event Date (required)</label></th>
230
+ <td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.date_i18n( $date_format, $start_date ).'" />
231
+ <span id="end_date_area"> - <input type="text" class="text datepicker" name="end_date" id="end_date" value="'.date_i18n( $date_format, $end_date ).'" /></span>
232
+ <label><input type="checkbox" name="multiday" id="multiday" value="1" /> Multi-Day Event</label></td>
233
  </tr>
234
  <tr>
235
  <th><label>Event Time</label></th>
265
  // event added
266
  if( 'added' === self::$event_action ) {
267
  if( false === self::$event_action_error ) {
268
+ $out .= '<div id="message" class="updated below-h2"><p><strong>New Event "'.$_POST['title'].'" was added.</strong></p></div>';
269
  }
270
  else {
271
+ $out .= '<div id="message" class="error below-h2"><p><strong>Error: New Event "'.$_POST['title'].'" could not be added.</strong></p></div>';
272
  }
273
  }
274
  // event modified
275
  elseif( 'modified' === self::$event_action ) {
276
  if( false === self::$event_action_error ) {
277
+ $out .= '<div id="message" class="updated below-h2"><p><strong>Event "'.$_POST['title'].'" (id: '.$_POST['id'].') was modified.</strong></p></div>';
278
  }
279
  else {
280
+ $out .= '<div id="message" class="error below-h2"><p><strong>Error: Event "'.$_POST['title'].'" (id: '.$_POST['id'].') could not be modified.</strong></p></div>';
281
  }
282
  }
283
  // event deleted
288
  $plural = 's';
289
  }
290
  if( false === self::$event_action_error ) {
291
+ $out .= '<div id="message" class="updated below-h2"><p><strong>'.$num_deleted.' Event'.$plural.' deleted (id'.$plural.': '.$_GET['id'].').</strong></p></div>';
292
  }
293
  else {
294
+ $out .= '<div id="message" class="error below-h2"><p><strong>Error while deleting '.$num_deleted.' Event'.$plural.'.</strong></p></div>';
295
  }
296
  }
297
  return $out;
380
  <textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
381
  return $out;
382
  }
383
+
384
+ /**
385
+ * Convert a date format to a jQuery UI DatePicker format
386
+ *
387
+ * @param string $format a date format
388
+ * @return string
389
+ */
390
+ private static function datepicker_format( $format ) {
391
+ $chars = array(
392
+ // Day
393
+ 'd' => 'dd', 'j' => 'd', 'l' => 'DD', 'D' => 'D',
394
+ // Month
395
+ 'm' => 'mm', 'n' => 'm', 'F' => 'MM', 'M' => 'M',
396
+ // Year
397
+ 'Y' => 'yy', 'y' => 'y',
398
+ );
399
+ return strtr((string)$format, $chars);
400
+ }
401
  }
402
  ?>
php/admin_event_table.php CHANGED
@@ -27,11 +27,13 @@ class Admin_Event_Table extends WP_List_Table {
27
  protected function column_default($item, $column_name) {
28
  switch($column_name){
29
  case 'date' :
30
- return $this->format_date( $item->start_date, $item->end_date, $item->time );
31
  case 'details' :
32
- return $this->truncate( 80, $item->details );
33
  case 'pub_user' :
34
- return get_userdata( $item->$column_name )->user_login;
 
 
35
  default :
36
  return $item->$column_name;
37
  }
@@ -225,43 +227,37 @@ class Admin_Event_Table extends WP_List_Table {
225
  * @param string $end_date The end date of the event
226
  * @param string $time The start time of the event
227
  ***************************************************************************/
228
- private function format_date( $start_date, $end_date, $start_time ) {
229
- $start_array = explode("-", $start_date);
230
- $start_date = mktime(0,0,0,$start_array[1],$start_array[2],$start_array[0]);
231
- $end_array = explode("-", $end_date);
232
- $end_date = mktime(0,0,0,$end_array[1],$end_array[2],$end_array[0]);
233
  $out = '<span style="white-space:nowrap;">';
234
- // one day event
235
- if( $start_date == $end_date ) {
236
- if ($start_array[2] == "00") {
237
- $start_date = mktime(0,0,0,$start_array[1],15,$start_array[0]);
238
- $out .= date("F, Y", $start_date);
239
- }
240
- else {
241
- $out .= date("M j, Y", $start_date);
242
- }
243
- }
244
- // multiday event with start and end date in the same year
245
- elseif( $start_array[0] == $end_array[0] ) {
246
- $out .= date("M j", $start_date).'-';
247
- // same start and end month
248
- if( $start_array[1] == $end_array[1] ) {
249
- $out .= date("j, Y", $end_date);
250
- }
251
- // different start and end month
252
- else {
253
- $out .= date("M j, Y", $end_date);
254
- }
255
  }
256
- // multiday event with different start and end year
257
- else {
258
- $out .= date("M j, Y", $start_date).'-<br />'.date("M j, Y", $end_date).'&nbsp;';
 
259
  }
260
- $out .= '<br />
261
- <span class="time">'.$start_time.'</span></span>';
262
  return $out;
263
  }
264
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  // function to truncate and shorten html text
266
  /** ************************************************************************
267
  * Function to truncate and shorten text
27
  protected function column_default($item, $column_name) {
28
  switch($column_name){
29
  case 'date' :
30
+ return $this->format_event_date( $item->start_date, $item->end_date, $item->time );
31
  case 'details' :
32
+ return '<span title="'.$item->details.'">'.$this->truncate( 80, $item->details ).'</span>';
33
  case 'pub_user' :
34
+ return get_userdata( $item->pub_user )->user_login;
35
+ case 'pub_date' :
36
+ return $this->format_pub_date( $item->pub_date );
37
  default :
38
  return $item->$column_name;
39
  }
227
  * @param string $end_date The end date of the event
228
  * @param string $time The start time of the event
229
  ***************************************************************************/
230
+ private function format_event_date( $start_date, $end_date, $start_time ) {
 
 
 
 
231
  $out = '<span style="white-space:nowrap;">';
232
+ // start date
233
+ $out .= mysql2date( __( 'Y/m/d' ), $start_date );
234
+ // end date for multiday event
235
+ if( $start_date !== $end_date ) {
236
+ $out .= ' -<br />'.mysql2date( __( 'Y/m/d' ), $end_date );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
  }
238
+ // event time
239
+ if( '' !== $start_time ) {
240
+ $out .= '<br />
241
+ <span class="time">'.mysql2date( get_option( 'time_format' ), $start_time ).'</span></span>';
242
  }
 
 
243
  return $out;
244
  }
245
 
246
+ private function format_pub_date( $pub_date ) {
247
+ // similar output than for post or pages
248
+ $timestamp = strtotime( $pub_date );
249
+ $time_diff = time() - $timestamp;
250
+ error_log( "time_diff: ".$time_diff );
251
+ if( $time_diff >= 0 && $time_diff < 24*60*60 ) {
252
+ $date = sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
253
+ }
254
+ else {
255
+ $date = mysql2date( __( 'Y/m/d' ), $pub_date );
256
+ }
257
+ $datetime = mysql2date( __( 'Y/m/d g:i:s A' ), $pub_date );
258
+ return '<abbr title="'.$datetime.'">'.$date.'</abbr>';
259
+ }
260
+
261
  // function to truncate and shorten html text
262
  /** ************************************************************************
263
  * Function to truncate and shorten text
php/sc_event-list.php CHANGED
@@ -30,7 +30,7 @@ class sc_event_list {
30
  }
31
  return $out;
32
  }
33
-
34
  private static function html_event_details( $event_id ) {
35
  $event = el_db::get_event( $event_id );
36
  $out = el_db::html_calendar_nav();
@@ -39,7 +39,7 @@ class sc_event_list {
39
  $out .= '</ul>';
40
  return $out;
41
  }
42
-
43
  private static function html_events( $a ) {
44
  // specify visible events
45
  if( isset( $_GET['ytd'] ) ) {
@@ -57,7 +57,7 @@ class sc_event_list {
57
  // (get_option('permalink_structure')) ? $feed_link = "/feed/events" : $feed_link = "/?feed=events";
58
  // $out .= "<a href=\"$feed_link\" class=\"rss-link\">RSS</a>";
59
  // }
60
-
61
  // generate output
62
  $out .= el_db::html_calendar_nav();
63
  // TODO: Setting missing
@@ -85,7 +85,7 @@ class sc_event_list {
85
  }
86
  }
87
  }
88
-
89
  // set html code
90
  $out .= '<ul id="eventlist">';
91
  foreach ($events as $event) {
@@ -96,7 +96,7 @@ class sc_event_list {
96
  }
97
  return $out;
98
  }
99
-
100
  private static function html_event( $event, $url=false ) {
101
  $out = '<li class="event">';
102
  $out .= self::html_fulldate( $event->start_date, $event->end_date );
@@ -109,21 +109,17 @@ class sc_event_list {
109
  }
110
  $out .= '</h3>';
111
  if( $event->time != '' ) {
112
- $out .= '<span class="time">'.$event->time.'</span>';
113
  }
114
  $out .= '<span class="location">'.$event->location.'</span>';
115
  $out .= '<span class="details">'.$event->details.'</span>';
116
  $out .= '</div></li>';
117
  return $out;
118
  }
119
-
120
  private static function html_fulldate( $start_date, $end_date ) {
121
- $startArray = explode("-", $start_date);
122
- $start_date = mktime(0,0,0,$startArray[1],$startArray[2],$startArray[0]);
123
- $endArray = explode("-", $end_date);
124
- $end_date = mktime(0,0,0,$endArray[1],$endArray[2],$endArray[0]);
125
  $out = '';
126
- if( $start_date == $end_date ) {
127
  // one day event
128
  $out .= '<div class="date">';
129
  $out .= '<div class="end-date">';
@@ -145,10 +141,10 @@ class sc_event_list {
145
  }
146
 
147
  private static function html_date( $date ) {
148
- $out = '<div class="weekday">'.date( 'D', $date ).'</div>';
149
- $out .= '<div class="day">'.date( 'd', $date ).'</div>';
150
- $out .= '<div class="month">'.date( 'M', $date ).'</div>';
151
- $out .= '<div class="year">'.date( 'Y', $date ).'</div>';
152
  return $out;
153
  }
154
  }
30
  }
31
  return $out;
32
  }
33
+
34
  private static function html_event_details( $event_id ) {
35
  $event = el_db::get_event( $event_id );
36
  $out = el_db::html_calendar_nav();
39
  $out .= '</ul>';
40
  return $out;
41
  }
42
+
43
  private static function html_events( $a ) {
44
  // specify visible events
45
  if( isset( $_GET['ytd'] ) ) {
57
  // (get_option('permalink_structure')) ? $feed_link = "/feed/events" : $feed_link = "/?feed=events";
58
  // $out .= "<a href=\"$feed_link\" class=\"rss-link\">RSS</a>";
59
  // }
60
+
61
  // generate output
62
  $out .= el_db::html_calendar_nav();
63
  // TODO: Setting missing
85
  }
86
  }
87
  }
88
+
89
  // set html code
90
  $out .= '<ul id="eventlist">';
91
  foreach ($events as $event) {
96
  }
97
  return $out;
98
  }
99
+
100
  private static function html_event( $event, $url=false ) {
101
  $out = '<li class="event">';
102
  $out .= self::html_fulldate( $event->start_date, $event->end_date );
109
  }
110
  $out .= '</h3>';
111
  if( $event->time != '' ) {
112
+ $out .= '<span class="time">'.mysql2date( get_option( 'time_format' ), $event->time ).'</span>';
113
  }
114
  $out .= '<span class="location">'.$event->location.'</span>';
115
  $out .= '<span class="details">'.$event->details.'</span>';
116
  $out .= '</div></li>';
117
  return $out;
118
  }
119
+
120
  private static function html_fulldate( $start_date, $end_date ) {
 
 
 
 
121
  $out = '';
122
+ if( $start_date === $end_date ) {
123
  // one day event
124
  $out .= '<div class="date">';
125
  $out .= '<div class="end-date">';
141
  }
142
 
143
  private static function html_date( $date ) {
144
+ $out = '<div class="weekday">'.mysql2date( 'D', $date ).'</div>';
145
+ $out .= '<div class="day">'.mysql2date( 'd', $date ).'</div>';
146
+ $out .= '<div class="month">'.mysql2date( 'M', $date ).'</div>';
147
+ $out .= '<div class="year">'.mysql2date( 'Y', $date ).'</div>';
148
  return $out;
149
  }
150
  }
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mibuthu
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W54LNZMWF9KW2
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
- Tested up to: 3.4.2
7
- Stable tag: 0.2.1
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -53,6 +53,12 @@ not available yet
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
 
56
  = 0.2.1 (2012-10-26) =
57
 
58
  * changed field order and align in new/edit event form
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W54LNZMWF9KW2
4
  Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
5
  Requires at least: 3.3
6
+ Tested up to: 3.5
7
+ Stable tag: 0.2.2
8
  Plugin URI: http://wordpress.org/extend/plugins/event-list
9
  Licence: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
53
 
54
  == Changelog ==
55
 
56
+ = 0.2.2 (2012-11-18) =
57
+
58
+ * localization of date and time on the frontpage
59
+ * changed and localized date and time view in the admin event list table
60
+ * localization of date in the new event form
61
+
62
  = 0.2.1 (2012-10-26) =
63
 
64
  * changed field order and align in new/edit event form