Event List - Version 0.4.0

Version Description

(2013-05-04) =

  • added category support
  • added settings page
  • small changes in add/edit event admin page
  • added settings page
  • added option "no_event_text"
  • execute shortcodes in event details field on front page
  • change of plugin folder structure and file names
  • small fixes in widget code
Download this release

Release Info

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

Code changes from version 0.3.4 to 0.4.0

Files changed (39) hide show
  1. {php → admin}/admin.php +271 -129
  2. {css → admin/css}/admin_about.css +0 -0
  3. {css → admin/css}/admin_main.css +0 -0
  4. {css → admin/css}/admin_new.css +2 -2
  5. {css → admin/css}/datepicker/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  6. {css → admin/css}/datepicker/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  7. {css → admin/css}/datepicker/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  8. {css → admin/css}/datepicker/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  9. {css → admin/css}/datepicker/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  10. {css → admin/css}/datepicker/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  11. {css → admin/css}/datepicker/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  12. {css → admin/css}/datepicker/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  13. {css → admin/css}/datepicker/images/ui-icons_222222_256x240.png +0 -0
  14. {css → admin/css}/datepicker/images/ui-icons_2e83ff_256x240.png +0 -0
  15. {css → admin/css}/datepicker/images/ui-icons_454545_256x240.png +0 -0
  16. {css → admin/css}/datepicker/images/ui-icons_888888_256x240.png +0 -0
  17. {css → admin/css}/datepicker/images/ui-icons_cd0a0a_256x240.png +0 -0
  18. {css → admin/css}/datepicker/jquery-ui-datepicker.css +0 -0
  19. {images → admin/images}/calendar-icon.png +0 -0
  20. admin/includes/category_table.php +186 -0
  21. php/admin_event_table.php → admin/includes/event_table.php +19 -14
  22. {js → admin/js}/admin_main.js +0 -0
  23. {js → admin/js}/admin_new.js +0 -0
  24. admin/js/admin_settings.js +8 -0
  25. event-list.php +13 -13
  26. includes/categories.php +99 -0
  27. {css → includes/css}/event-list.css +5 -0
  28. {php → includes}/db.php +48 -19
  29. {images → includes/images}/date-separator.png +0 -0
  30. includes/options.php +75 -0
  31. {php → includes}/sc_event-list.php +30 -11
  32. php/event-list_widget.php → includes/widget.php +2 -3
  33. readme.txt +19 -6
  34. screenshot-1.png +0 -0
  35. screenshot-2.png +0 -0
  36. screenshot-3.png +0 -0
  37. screenshot-4.png +0 -0
  38. screenshot-5.png +0 -0
  39. screenshot-6.png +0 -0
{php → admin}/admin.php RENAMED
@@ -1,22 +1,25 @@
1
  <?php
2
- //require_once( EL_PATH.'php/options.php' );
3
- require_once( EL_PATH.'php/db.php' );
4
- require_once( EL_PATH.'php/sc_event-list.php' );
5
- require_once( EL_PATH.'php/admin_event_table.php' );
 
6
 
7
  // This class handles all available admin pages
8
- class el_admin {
9
  private $db;
10
  private $options;
11
  private $shortcode;
 
12
  private $dateformat;
13
  private $event_action = false;
14
  private $event_action_error = false;
15
 
16
  public function __construct() {
17
- $this->db = el_db::get_instance();
18
- //$this->options = &el_options::get_instance();
19
- $this->shortcode = &sc_event_list::get_instance();
 
20
  $this->dateformat = __( 'Y/m/d' ); // similar date format than in list tables (e.g. post, pages, media)
21
  // $this->dateformat = 'd/m/Y'; // for debugging only
22
  $this->event_action = null;
@@ -32,7 +35,8 @@ class el_admin {
32
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_main_scripts' ) );
33
  $page = add_submenu_page( 'el_admin_main', 'Add New Event', 'Add New', 'edit_posts', 'el_admin_new', array( &$this, 'show_new' ) );
34
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_new_scripts' ) );
35
- //add_submenu_page( 'el_admin_main', 'Event List Settings', 'Settings', 'manage_options', 'el_admin_settings', array( &$this, 'show_settings' ) );
 
36
  $page = add_submenu_page( 'el_admin_main', 'About Event List', 'About', 'edit_posts', 'el_admin_about', array( &$this, 'show_about' ) );
37
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_about_scripts' ) );
38
  }
@@ -82,9 +86,7 @@ class el_admin {
82
 
83
  public function show_new() {
84
  $out = '<div class="wrap">
85
- <div class="wrap nosubsub" style="padding-bottom:15px">
86
- <div id="icon-edit-pages" class="icon32"><br /></div><h2>Add New Event</h2>
87
- </div>';
88
  $out .= $this->edit_event();
89
  $out .= '</div>';
90
  echo $out;
@@ -92,14 +94,12 @@ class el_admin {
92
 
93
  private function show_edit() {
94
  $out = '<div class="wrap">
95
- <div class="wrap nosubsub" style="padding-bottom:15px">
96
- <div id="icon-edit-pages" class="icon32"><br /></div><h2>Edit Event</h2>
97
- </div>';
98
  $out .= $this->edit_event();
99
  $out .= '</div>';
100
  echo $out;
101
  }
102
- /*
103
  public function show_settings () {
104
  if (!current_user_can('manage_options')) {
105
  wp_die( __('You do not have sufficient permissions to access this page.') );
@@ -110,67 +110,44 @@ class el_admin {
110
  <p><strong>'.__( 'Settings saved.' ).'</strong></p>
111
  </div>';
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  $out.= '<div class="wrap">
114
- <div class="wrap nosubsub" style="padding-bottom:15px">
115
- <div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List Settings</h2>
116
- </div>
117
- <form method="post" action="options.php">
118
- Not available yet';
119
- // TODO: Add settings to settings page
120
- // $out .= settings_fields( 'mfgigcal_settings' );
121
- // $out .= do_settings_sections('mfgigcal');
122
- // $out .= '<input name="Submit" type="submit" value="'.esc_attr__( 'Save Changes' ).'" />
123
- // </form>
124
- // </div>';
125
- /*
126
- <h3>Comment Guestbook Settings</h3>';
127
  if( !isset( $_GET['tab'] ) ) {
128
- $_GET['tab'] = 'general';
129
  }
130
- $out .= cgb_admin::create_tabs( $_GET['tab'] );
131
  $out .= '<div id="posttype-page" class="posttypediv">';
 
132
  $out .= '
133
- <form method="post" action="options.php">
134
- ';
135
- ob_start();
136
- settings_fields( 'cgb_'.$_GET['tab'] );
137
- $out .= ob_get_contents();
138
- ob_end_clean();
139
- $out .= '
140
- <div style="padding:0 10px">';
141
- switch( $_GET['tab'] ) {
142
- case 'comment_list' :
143
- $out .= '
144
- <table class="form-table">';
145
- $out .= cgb_admin::show_options( 'comment_list' );
146
- $out .= '
147
- </table>';
148
- break;
149
- default : // 'general'
150
- $out .= '
151
- <table class="form-table">';
152
- $out .= cgb_admin::show_options( 'general' );
153
- $out .= '
154
- </table>';
155
- break;
156
- }
157
- $out .=
158
- '</div>';
159
- ob_start();
160
- submit_button();
161
- $out .= ob_get_contents();
162
- ob_end_clean();
163
- $out .='
164
- </form>
165
- </div>';
166
  echo $out;
167
  }
168
- */
169
  public function show_about() {
170
  $out = '<div class="wrap">
171
- <div class="wrap nosubsub" style="padding-bottom:15px">
172
- <div id="icon-edit-pages" class="icon32"><br /></div><h2>About Event List</h2>
173
- </div>
174
  <h3>Help and Instructions</h3>
175
  <p>You can manage your events <a href="admin.php?page=el_admin_main">here</a>.</p>
176
  <p>To show the events on your site you have two possibilities:
@@ -184,9 +161,9 @@ class el_admin {
184
  Additonally you have to insert the correct Shortcode ID on the linked page. This ID describes which shortcode should be used on the given page or post if you have more than one.
185
  So the standard value "1" is normally o.k., but you can check the ID if you have a look into the URL of an event link on your linked page or post.
186
  The ID is given behind the "_" (e.g. <i>http://www.your-homepage.com/?page_id=99&event_id_<strong>1</strong>=11</i>).
187
- </p>';
188
- //<p>Be sure to also check the <a href="admin.php?page=el_admin_settings">settings page</a> to get Event List behaving just the way you want.</p>
189
- $out .= '</div>';
190
  $out .= $this->html_atts();
191
  echo $out;
192
  }
@@ -198,19 +175,24 @@ class el_admin {
198
  }
199
  else {
200
  // Proceed with embedding for admin_main
201
- wp_enqueue_script( 'eventlist_admin_main_js', EL_URL.'js/admin_main.js' );
202
- wp_enqueue_style( 'eventlist_admin_main', EL_URL.'css/admin_main.css' );
203
  }
204
  }
205
 
206
  public function embed_admin_new_scripts() {
207
- wp_print_scripts( 'jquery-ui-datepicker' );
208
- wp_enqueue_script( 'eventlist_admin_new_js', EL_URL.'js/admin_new.js' );
209
- wp_enqueue_style( 'eventlist_admin_new', EL_URL.'css/admin_new.css' );
 
 
 
 
 
210
  }
211
 
212
  public function embed_admin_about_scripts() {
213
- wp_enqueue_style( 'eventlist_admin_about', EL_URL.'css/admin_about.css' );
214
  }
215
 
216
  private function list_events() {
@@ -226,7 +208,7 @@ class el_admin {
226
  $out .= '<form id="event-filter" method="get">
227
  <input type="hidden" name="page" value="'.$_REQUEST['page'].'" />';
228
  // show table
229
- $table = new Admin_Event_Table();
230
  $table->prepare_items( $date_range );
231
  ob_start();
232
  $table->display();
@@ -257,8 +239,18 @@ class el_admin {
257
  // Add required data for javascript in a hidden field
258
  $json = json_encode( array( 'el_url' => EL_URL,
259
  'el_date_format' => $this->datepicker_format( $this->dateformat ) ) );
260
- $out = "<input type='hidden' id='json_for_js' value='".$json."' />";
261
- $out .= '<form method="POST" action="?page=el_admin_main">';
 
 
 
 
 
 
 
 
 
 
262
  if( true === $edit ) {
263
  $out .= '<input type="hidden" name="id" value="'.$_GET['id'].'" />';
264
  }
@@ -286,11 +278,7 @@ class el_admin {
286
  <td>';
287
  $editor_settings = array( 'media_buttons' => true,
288
  'wpautop' => false,
289
- 'tinymce' => array( 'height' => '400',
290
- 'force_br_newlines' => false,
291
- 'force_p_newlines' => true,
292
- 'convert_newlines_to_brs' => false ),
293
- 'quicktags' => true );
294
  ob_start();
295
  wp_editor( isset( $event->details ) ? $event->details : '', 'details', $editor_settings);
296
  $out .= ob_get_contents();
@@ -298,7 +286,23 @@ class el_admin {
298
  $out .= '<p class="note">NOTE: In the text editor, use RETURN to start a new paragraph - use SHIFT-RETURN to start a new line.</p></td>
299
  </tr>
300
  </table>';
301
- $out .= '<p class="submit"><input type="submit" class="button-primary" name="publish" value="Publish" id="submitbutton"> <a href="?page=el_admin_main" class="button-secondary">Cancel</a></p></form>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
  return $out;
303
  }
304
 
@@ -367,61 +371,72 @@ class el_admin {
367
  return $out;
368
  }
369
 
370
- // TODO: Function "create_tabs" not required yet, can be removed probably
371
- private function create_tabs( $current = 'general' ) {
372
- $tabs = array( 'general' => 'General settings', 'comment_list' => 'Comment-list settings', 'comment_form' => 'Comment-form settings',
373
- 'comment_form_html' => 'Comment-form html code', 'comment_html' => 'Comment html code' );
374
  $out = '<h3 class="nav-tab-wrapper">';
375
  foreach( $tabs as $tab => $name ){
376
  $class = ( $tab == $current ) ? ' nav-tab-active' : '';
377
- $out .= "<a class='nav-tab$class' href='?page=cgb_admin_main&amp;tab=$tab'>$name</a>";
378
  }
379
  $out .= '</h3>';
380
  return $out;
381
  }
382
 
383
- // $desc_pos specifies where the descpription will be displayed.
384
- // available options: 'right' ... description will be displayed on the right side of the option (standard value)
385
- // 'newline' ... description will be displayed below the option
386
- private function show_options( $section, $desc_pos='right' ) {
387
  $out = '';
388
- foreach( $this->options as $oname => $o ) {
389
- if( $o['section'] == $section ) {
390
- $out .= '
391
- <tr valign="top">
392
- <th scope="row">';
393
- if( $o['label'] != '' ) {
394
- $out .= '<label for="'.$oname.'">'.$o['label'].':</label>';
395
- }
396
- $out .= '</th>
397
- <td>';
398
- switch( $o['type'] ) {
399
- case 'checkbox':
400
- $out .= cgb_admin::show_checkbox( $oname, $this->get( $oname ), $o['caption'] );
401
- break;
402
- case 'text':
403
- $out .= cgb_admin::show_text( $oname, $this->get( $oname ) );
404
- break;
405
- case 'textarea':
406
- $out .= cgb_admin::show_textarea( $oname, $this->get( $oname ) );
407
- break;
408
- }
409
- $out .= '
410
- </td>';
411
- if( $desc_pos == 'newline' ) {
412
  $out .= '
413
- </tr>
414
- <tr>
415
- <td></td>';
416
- }
417
- $out .= '
418
- <td class="description">'.$o['desc'].'</td>
419
- </tr>';
420
- if( $desc_pos == 'newline' ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  $out .= '
422
- <tr><td></td></tr>';
 
 
423
  }
424
  }
 
 
 
 
 
 
 
 
 
425
  }
426
  return $out;
427
  }
@@ -439,6 +454,23 @@ class el_admin {
439
  return $out;
440
  }
441
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  private function show_text( $name, $value ) {
443
  $out = '
444
  <input name="'.$name.'" type="text" id="'.$name.'" value="'.$value.'" />';
@@ -447,10 +479,120 @@ class el_admin {
447
 
448
  private function show_textarea( $name, $value ) {
449
  $out = '
450
- <textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
451
  return $out;
452
  }
453
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
454
  private function html_atts() {
455
  $out = '
456
  <h3 class="el-headline">Available Shortcode Attributes</h3>
1
  <?php
2
+ require_once( EL_PATH.'includes/db.php' );
3
+ require_once( EL_PATH.'includes/options.php' );
4
+ require_once( EL_PATH.'includes/sc_event-list.php' );
5
+ require_once( EL_PATH.'includes/categories.php' );
6
+ require_once( EL_PATH.'admin/includes/event_table.php' );
7
 
8
  // This class handles all available admin pages
9
+ class EL_Admin {
10
  private $db;
11
  private $options;
12
  private $shortcode;
13
+ private $categories;
14
  private $dateformat;
15
  private $event_action = false;
16
  private $event_action_error = false;
17
 
18
  public function __construct() {
19
+ $this->db = &EL_Db::get_instance();
20
+ $this->options = &EL_Options::get_instance();
21
+ $this->shortcode = &SC_Event_List::get_instance();
22
+ $this->categories = &EL_Categories::get_instance();
23
  $this->dateformat = __( 'Y/m/d' ); // similar date format than in list tables (e.g. post, pages, media)
24
  // $this->dateformat = 'd/m/Y'; // for debugging only
25
  $this->event_action = null;
35
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_main_scripts' ) );
36
  $page = add_submenu_page( 'el_admin_main', 'Add New Event', 'Add New', 'edit_posts', 'el_admin_new', array( &$this, 'show_new' ) );
37
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_new_scripts' ) );
38
+ $page = add_submenu_page( 'el_admin_main', 'Event List Settings', 'Settings', 'manage_options', 'el_admin_settings', array( &$this, 'show_settings' ) );
39
+ add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_settings_scripts' ) );
40
  $page = add_submenu_page( 'el_admin_main', 'About Event List', 'About', 'edit_posts', 'el_admin_about', array( &$this, 'show_about' ) );
41
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_about_scripts' ) );
42
  }
86
 
87
  public function show_new() {
88
  $out = '<div class="wrap">
89
+ <div id="icon-edit-pages" class="icon32"><br /></div><h2>Add New Event</h2>';
 
 
90
  $out .= $this->edit_event();
91
  $out .= '</div>';
92
  echo $out;
94
 
95
  private function show_edit() {
96
  $out = '<div class="wrap">
97
+ <div id="icon-edit-pages" class="icon32"><br /></div><h2>Edit Event</h2>';
 
 
98
  $out .= $this->edit_event();
99
  $out .= '</div>';
100
  echo $out;
101
  }
102
+
103
  public function show_settings () {
104
  if (!current_user_can('manage_options')) {
105
  wp_die( __('You do not have sufficient permissions to access this page.') );
110
  <p><strong>'.__( 'Settings saved.' ).'</strong></p>
111
  </div>';
112
  }
113
+
114
+ // get action
115
+ $action = '';
116
+ if( isset( $_GET['action'] ) ) {
117
+ $action = $_GET['action'];
118
+ }
119
+ // delete categories if required
120
+ if( $action === 'delete' && isset( $_GET['slug'] ) ) {
121
+ $slug_array = explode(', ', $_GET['slug'] );
122
+ $num_affected_events = $this->db->remove_category_in_events( $slug_array );
123
+ require_once( EL_PATH.'admin/includes/category_table.php' );
124
+ if( $this->categories->remove_category( $slug_array ) ) {
125
+ $out .= '<div id="message" class="updated">
126
+ <p><strong>'.sprintf( __( 'Category %s was deleted).<br />This Category was also removed in %d events.' ), $_GET['slug'], $num_affected_events ).'</strong></p>
127
+ </div>';
128
+ }
129
+ else {
130
+ $out .= '<div id="message" class="error below-h2"><p><strong>Error while deleting category "'.$_GET['slug'].'".</strong></p></div>';
131
+ }
132
+ }
133
+
134
  $out.= '<div class="wrap">
135
+ <div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List Settings</h2>';
 
 
 
 
 
 
 
 
 
 
 
 
136
  if( !isset( $_GET['tab'] ) ) {
137
+ $_GET['tab'] = 'category';
138
  }
139
+ $out .= $this->show_tabs( $_GET['tab'] );
140
  $out .= '<div id="posttype-page" class="posttypediv">';
141
+ $out .= $this->show_options( $_GET['tab'] );
142
  $out .= '
143
+ </div>
144
+ </div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  echo $out;
146
  }
147
+
148
  public function show_about() {
149
  $out = '<div class="wrap">
150
+ <div id="icon-edit-pages" class="icon32"><br /></div><h2>About Event List</h2>
 
 
151
  <h3>Help and Instructions</h3>
152
  <p>You can manage your events <a href="admin.php?page=el_admin_main">here</a>.</p>
153
  <p>To show the events on your site you have two possibilities:
161
  Additonally you have to insert the correct Shortcode ID on the linked page. This ID describes which shortcode should be used on the given page or post if you have more than one.
162
  So the standard value "1" is normally o.k., but you can check the ID if you have a look into the URL of an event link on your linked page or post.
163
  The ID is given behind the "_" (e.g. <i>http://www.your-homepage.com/?page_id=99&event_id_<strong>1</strong>=11</i>).
164
+ </p>
165
+ <p>Be sure to also check the <a href="admin.php?page=el_admin_settings">settings page</a> to get Event List behaving just the way you want.</p>
166
+ </div>';
167
  $out .= $this->html_atts();
168
  echo $out;
169
  }
175
  }
176
  else {
177
  // Proceed with embedding for admin_main
178
+ wp_enqueue_script( 'eventlist_admin_main_js', EL_URL.'admin/js/admin_main.js' );
179
+ wp_enqueue_style( 'eventlist_admin_main', EL_URL.'admin/css/admin_main.css' );
180
  }
181
  }
182
 
183
  public function embed_admin_new_scripts() {
184
+ wp_enqueue_script( 'jquery-ui-datepicker' );
185
+ wp_enqueue_script( 'link' );
186
+ wp_enqueue_script( 'eventlist_admin_new_js', EL_URL.'admin/js/admin_new.js' );
187
+ wp_enqueue_style( 'eventlist_admin_new', EL_URL.'admin/css/admin_new.css' );
188
+ }
189
+
190
+ public function embed_admin_settings_scripts() {
191
+ wp_enqueue_script( 'eventlist_admin_settings_js', EL_URL.'admin/js/admin_settings.js' );
192
  }
193
 
194
  public function embed_admin_about_scripts() {
195
+ wp_enqueue_style( 'eventlist_admin_about', EL_URL.'admin/css/admin_about.css' );
196
  }
197
 
198
  private function list_events() {
208
  $out .= '<form id="event-filter" method="get">
209
  <input type="hidden" name="page" value="'.$_REQUEST['page'].'" />';
210
  // show table
211
+ $table = new EL_Event_Table();
212
  $table->prepare_items( $date_range );
213
  ob_start();
214
  $table->display();
239
  // Add required data for javascript in a hidden field
240
  $json = json_encode( array( 'el_url' => EL_URL,
241
  'el_date_format' => $this->datepicker_format( $this->dateformat ) ) );
242
+ $out = '
243
+ <form method="POST" action="?page=el_admin_main">';
244
+ $out .= "
245
+ <input type='hidden' id='json_for_js' value='".$json."' />"; // single quote required for value due to json layout
246
+ // TODO: saving changed metabox status and order is not working yet
247
+ $out .= wp_nonce_field('autosavenonce', 'autosavenonce', false, false );
248
+ $out .= wp_nonce_field('closedpostboxesnonce', 'closedpostboxesnonce', false, false );
249
+ $out .= wp_nonce_field('meta-box-order-nonce', 'meta-box-order-nonce', false, false );
250
+ $out .= '
251
+ <div id="poststuff">
252
+ <div id="post-body" class="metabox-holder columns-2">
253
+ <div id="post-body-content">';
254
  if( true === $edit ) {
255
  $out .= '<input type="hidden" name="id" value="'.$_GET['id'].'" />';
256
  }
278
  <td>';
279
  $editor_settings = array( 'media_buttons' => true,
280
  'wpautop' => false,
281
+ 'textarea_rows' => 20 );
 
 
 
 
282
  ob_start();
283
  wp_editor( isset( $event->details ) ? $event->details : '', 'details', $editor_settings);
284
  $out .= ob_get_contents();
286
  $out .= '<p class="note">NOTE: In the text editor, use RETURN to start a new paragraph - use SHIFT-RETURN to start a new line.</p></td>
287
  </tr>
288
  </table>';
289
+ $out .= '
290
+ </div>
291
+ <div id="postbox-container-1" class="postbox-container">
292
+ <div id="side-sortables" class="meta-box-sortables ui-sortable">';
293
+ add_meta_box( 'event-publish', __( 'Publish' ), array( &$this, 'render_publish_metabox' ), 'event-list' );
294
+ $metabox_args = isset( $event->categories ) ? array( 'event_cats' => $event->categories ) : null;
295
+ add_meta_box( 'event-categories', __( 'Categories' ), array( &$this, 'render_category_metabox' ), 'event-list', 'advanced', 'default', $metabox_args );
296
+ ob_start();
297
+ do_meta_boxes('event-list', 'advanced', null);
298
+ $out .= ob_get_contents();
299
+ ob_end_clean();
300
+ $out .= '
301
+ </div>
302
+ </div>
303
+ </div>
304
+ </div>
305
+ </form>';
306
  return $out;
307
  }
308
 
371
  return $out;
372
  }
373
 
374
+ private function show_tabs( $current = 'category' ) {
375
+ $tabs = array( 'category' => 'Categories', 'general' => 'General' );
 
 
376
  $out = '<h3 class="nav-tab-wrapper">';
377
  foreach( $tabs as $tab => $name ){
378
  $class = ( $tab == $current ) ? ' nav-tab-active' : '';
379
+ $out .= "<a class='nav-tab$class' href='?page=el_admin_settings&amp;tab=$tab'>$name</a>";
380
  }
381
  $out .= '</h3>';
382
  return $out;
383
  }
384
 
385
+ private function show_options( $section ) {
 
 
 
386
  $out = '';
387
+ if( 'category' === $section ) {
388
+ $out .= $this->show_category();
389
+ }
390
+ else {
391
+ $out .= '
392
+ <form method="post" action="options.php">
393
+ ';
394
+ ob_start();
395
+ settings_fields( 'el_'.$_GET['tab'] );
396
+ $out .= ob_get_contents();
397
+ ob_end_clean();
398
+ $out .= '
399
+ <div style="padding:0 10px">
400
+ <table class="form-table">';
401
+ foreach( $this->options->options as $oname => $o ) {
402
+ if( $o['section'] == $section ) {
 
 
 
 
 
 
 
 
403
  $out .= '
404
+ <tr style="vertical-align:top;">
405
+ <th>';
406
+ if( $o['label'] != '' ) {
407
+ $out .= '<label for="'.$oname.'">'.$o['label'].':</label>';
408
+ }
409
+ $out .= '</th>
410
+ <td>';
411
+ switch( $o['type'] ) {
412
+ case 'checkbox':
413
+ $out .= $this->show_checkbox( $oname, $this->options->get( $oname ), $o['caption'] );
414
+ break;
415
+ case 'radio':
416
+ $out .= $this->show_radio( $oname, $this->options->get( $oname ), $o['caption'] );
417
+ break;
418
+ case 'text':
419
+ $out .= $this->show_text( $oname, $this->options->get( $oname ) );
420
+ break;
421
+ case 'textarea':
422
+ $out .= $this->show_textarea( $oname, $this->options->get( $oname ) );
423
+ break;
424
+ }
425
  $out .= '
426
+ </td>
427
+ <td class="description">'.$o['desc'].'</td>
428
+ </tr>';
429
  }
430
  }
431
+ $out .= '
432
+ </table>
433
+ </div>';
434
+ ob_start();
435
+ submit_button();
436
+ $out .= ob_get_contents();
437
+ ob_end_clean();
438
+ $out .='
439
+ </form>';
440
  }
441
  return $out;
442
  }
454
  return $out;
455
  }
456
 
457
+ private function show_radio( $name, $value, $caption ) {
458
+ $out = '
459
+ <fieldset>';
460
+ foreach( $caption as $okey => $ocaption ) {
461
+ $checked = ($value === $okey) ? 'checked="checked" ' : '';
462
+ $out .= '
463
+ <label title="'.$ocaption.'">
464
+ <input type="radio" '.$checked.'value="'.$okey.'" name="'.$name.'">
465
+ <span>'.$ocaption.'</span>
466
+ </label>
467
+ <br />';
468
+ }
469
+ $out .= '
470
+ </fieldset>';
471
+ return $out;
472
+ }
473
+
474
  private function show_text( $name, $value ) {
475
  $out = '
476
  <input name="'.$name.'" type="text" id="'.$name.'" value="'.$value.'" />';
479
 
480
  private function show_textarea( $name, $value ) {
481
  $out = '
482
+ <textarea name="'.$name.'" id="'.$name.'" rows="5" class="large-text code">'.$value.'</textarea>';
483
  return $out;
484
  }
485
 
486
+ private function show_category() {
487
+ $out = '';
488
+ // Check if a category was added
489
+ if( !empty( $_POST ) ) {
490
+ if( $this->categories->add_category( $_POST ) ) {
491
+ $out .= '<div id="message" class="updated below-h2"><p><strong>New Category "'.$_POST['name'].'" was added.</strong></p></div>';
492
+ }
493
+ else {
494
+ $out .= '<div id="message" class="error below-h2"><p><strong>Error: New Category "'.$_POST['name'].'" could not be added.</strong></p></div>';
495
+ }
496
+ }
497
+ // show category table
498
+ $out .= '
499
+ <div id="col-container">
500
+ <div id="col-right">
501
+ <div class="col-wrap">
502
+ <form id="category-filter" method="get">
503
+ <input type="hidden" name="page" value="'.$_REQUEST['page'].'" />';
504
+ // show table
505
+ require_once( EL_PATH.'admin/includes/category_table.php' );
506
+ $category_table = new EL_Category_Table();
507
+ $category_table->prepare_items();
508
+ ob_start();
509
+ $category_table->display();
510
+ $out .= ob_get_contents();
511
+ ob_end_clean();
512
+ $out .= '
513
+ </form>
514
+ </div>
515
+ </div>';
516
+ // show add category form
517
+ $out .= '
518
+ <div id="col-left">
519
+ <div class="col-wrap">
520
+ <div class="form-wrap">
521
+ <h3>'.__( 'Add New Category' ).'</h3>
522
+ <form id="addtag" method="POST" action="?page=el_admin_settings&amp;tab=category">';
523
+ $out .= '
524
+ <div class="form-field form-required"><label for="name">Name: </label>';
525
+ $out .= $this->show_text( 'name', '' );
526
+ $out .= '<p>'.__( 'The name is how it appears on your site.' ).'</p></div>
527
+ <div class="form-field"><label for="name">Slug: </label>';
528
+ $out .= $this->show_text( 'slug', '' );
529
+ $out .= '<p>'.__( 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.' ).'</p></div>
530
+ <div class="form-field"><label for="name">Description: </label>';
531
+ $out .= $this->show_textarea( 'desc', '' );
532
+ $out .= '</div>
533
+ <p class="submit"><input type="submit" class="button-primary" name="add_cat" value="'.__( 'Add New Category' ).'" id="submitbutton"></p>';
534
+ $out .= '
535
+ </form>
536
+ </div>
537
+ </div>
538
+ </div>
539
+ </div>';
540
+ return $out;
541
+ }
542
+
543
+ public function render_publish_metabox() {
544
+ $out = '<div class="submitbox">
545
+ <div id="delete-action"><a href="?page=el_admin_main" class="submitdelete deletion">'.__( 'Cancel' ).'</a></div>
546
+ <div id="publishing-action"><input type="submit" class="button button-primary button-large" name="publish" value="'.__( 'Publish' ).'" id="publish"></div>
547
+ <div class="clear"></div>
548
+ </div>';
549
+ echo $out;
550
+ }
551
+
552
+ public function render_category_metabox( $post, $metabox ) {
553
+ $out = '
554
+ <div id="taxonomy-category" class="categorydiv">
555
+ <div id="category-all" class="tabs-panel">';
556
+ $cat_array = (array) $this->options->get( 'el_categories' );
557
+ if( empty( $cat_array ) ) {
558
+ $out .= __( 'No categories available.' );
559
+ }
560
+ else {
561
+ $out .= '
562
+ <ul id="categorychecklist" class="categorychecklist form-no-clear">';
563
+ $event_cats = explode( '|', substr($metabox['args']['event_cats'], 1, -1 ) );
564
+ foreach( $cat_array as $cat ) {
565
+ $checked = in_array( $cat['slug'], $event_cats ) ? 'checked="checked" ' : '';
566
+ $out .= '
567
+ <li id="'.$cat['slug'].'" class="popular-catergory">
568
+ <label class="selectit">
569
+ <input value="'.$cat['slug'].'" type="checkbox" name="categories[]" id="categories" '.$checked.'/> '.$cat['name'].'
570
+ </label>
571
+ </li>';
572
+ }
573
+ $out .= '
574
+ </ul>';
575
+ }
576
+
577
+ $out .= '
578
+ </div>';
579
+ // TODO: Adding new categories in edit event form
580
+ /* <div id="category-adder" class="wp-hidden-children">
581
+ <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js">'.__( '+ Add New Category' ).'</a></h4>
582
+ <p id="category-add" class="category-add wp-hidden-child">
583
+ <label class="screen-reader-text" for="newcategory">'.__( 'Category Name' ).'</label>
584
+ <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="" aria-required="true"/>
585
+ <input type="button" id="category-add-submit" class="button category-add-submit" value="'.__( 'Add Category' ).'" />
586
+ </p>
587
+ </div>*/
588
+ $out .= '
589
+ <div id="category-manager">
590
+ <a id="category-manage-link" href="?page=el_admin_settings&amp;tab=category">'.__( 'Goto Category Settings' ).'</a>
591
+ </div>
592
+ </div>';
593
+ echo $out;
594
+ }
595
+
596
  private function html_atts() {
597
  $out = '
598
  <h3 class="el-headline">Available Shortcode Attributes</h3>
{css → admin/css}/admin_about.css RENAMED
File without changes
{css → admin/css}/admin_main.css RENAMED
File without changes
{css → admin/css}/admin_new.css RENAMED
@@ -17,6 +17,6 @@ p.note {
17
  font-style: italic;
18
  }
19
 
20
- p.submit {
21
- text-align: center;
22
  }
17
  font-style: italic;
18
  }
19
 
20
+ div#postbox-container-1 {
21
+ width: 260px !important;
22
  }
{css → admin/css}/datepicker/images/ui-bg_flat_0_aaaaaa_40x100.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_flat_75_ffffff_40x100.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_glass_55_fbf9ee_1x400.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_glass_65_ffffff_1x400.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_glass_75_dadada_1x400.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_glass_75_e6e6e6_1x400.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_glass_95_fef1ec_1x400.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-bg_highlight-soft_75_cccccc_1x100.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-icons_222222_256x240.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-icons_2e83ff_256x240.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-icons_454545_256x240.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-icons_888888_256x240.png RENAMED
File without changes
{css → admin/css}/datepicker/images/ui-icons_cd0a0a_256x240.png RENAMED
File without changes
{css → admin/css}/datepicker/jquery-ui-datepicker.css RENAMED
File without changes
{images → admin/images}/calendar-icon.png RENAMED
File without changes
admin/includes/category_table.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // load the base class (WP_List_Table class isn't automatically available)
3
+ if(!class_exists('WP_List_Table')){
4
+ require_once( ABSPATH.'wp-admin/includes/class-wp-list-table.php' );
5
+ }
6
+ require_once( EL_PATH.'includes/options.php' );
7
+ require_once( EL_PATH.'includes/db.php' );
8
+ require_once( EL_PATH.'includes/categories.php' );
9
+
10
+ class EL_Category_Table extends WP_List_Table {
11
+ private $options;
12
+ private $db;
13
+ private $categories;
14
+
15
+ public function __construct() {
16
+ $this->options = &EL_Options::get_instance();
17
+ $this->db = &EL_Db::get_instance();
18
+ $this->categories = &EL_Categories::get_instance();
19
+ //global $status, $page;
20
+ //Set parent defaults
21
+ parent::__construct( array(
22
+ 'singular' => 'event', //singular name of the listed records
23
+ 'plural' => 'events', //plural name of the listed records
24
+ 'ajax' => false //does this table support ajax?
25
+ ) );
26
+ }
27
+
28
+ /** ************************************************************************
29
+ * This method is called when the parent class can't find a method
30
+ * specifically build for a given column.
31
+ *
32
+ * @param array $item A singular item (one full row's worth of data)
33
+ * @param array $column_name The name/slug of the column to be processed
34
+ * @return string Text or HTML to be placed inside the column <td>
35
+ ***************************************************************************/
36
+ protected function column_default($item, $column_name) {
37
+ switch($column_name){
38
+ case 'name' :
39
+ return $item[$column_name];
40
+ case 'desc' :
41
+ return '<div>'.$item[$column_name].'</div>';
42
+ case 'slug' :
43
+ return $item[$column_name];
44
+ case 'num_events' :
45
+ return $this->db->count_events( $item['slug'] );
46
+ default :
47
+ echo $column_name;
48
+ return $item[$column_name];
49
+ }
50
+ }
51
+
52
+ /** ************************************************************************
53
+ * This is a custom column method and is responsible for what is
54
+ * rendered in any column with a name/slug of 'name'.
55
+ *
56
+ * @see WP_List_Table::::single_row_columns()
57
+ * @param array $item A singular item (one full row's worth of data)
58
+ * @return string Text to be placed inside the column <td> (movie title only)
59
+ ***************************************************************************/
60
+ protected function column_name($item) {
61
+ //Prepare Columns
62
+ $actions = array(
63
+ // TODO: edit category not implemented yet
64
+ /*'edit' => '<a href="?page='.$_REQUEST['page'].'&amp;id='.$item['slug'].'&amp;action=edit">Edit</a>',*/
65
+ 'delete' => '<a href="#" onClick="eventlist_deleteCategory(\''.$item['slug'].'\');return false;">Delete</a>'
66
+ );
67
+ //Return the title contents
68
+ return '<b>'.$item['name'].'</b>'.$this->row_actions( $actions );
69
+ }
70
+
71
+ /** ************************************************************************
72
+ * Required if displaying checkboxes or using bulk actions! The 'cb' column
73
+ * is given special treatment when columns are processed.
74
+ *
75
+ * @see WP_List_Table::::single_row_columns()
76
+ * @param array $item A singular item (one full row's worth of data)
77
+ * @return string Text to be placed inside the column <td> (movie title only)
78
+ ***************************************************************************/
79
+ protected function column_cb($item) {
80
+ //Let's simply repurpose the table's singular label ("event")
81
+ //The value of the checkbox should be the record's id
82
+ return '<input type="checkbox" name="slug[]" value="'.$item['slug'].'" />';
83
+ }
84
+
85
+ /** ************************************************************************
86
+ * This method dictates the table's columns and titles. This should returns
87
+ * an array where the key is the column slug (and class) and the value is
88
+ * the column's title text.
89
+ *
90
+ * @see WP_List_Table::::single_row_columns()
91
+ * @return array An associative array containing column information: 'slugs'=>'Visible Titles'
92
+ ***************************************************************************/
93
+ public function get_columns() {
94
+ return array(
95
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
96
+ 'name' => 'Name',
97
+ 'desc' => 'Description',
98
+ 'slug' => 'Slug',
99
+ 'num_events' => 'Events'
100
+ );
101
+ }
102
+
103
+ /** ************************************************************************
104
+ * If you want one or more columns to be sortable (ASC/DESC toggle), you
105
+ * will need to register it here. This should return an array where the key
106
+ * is the column that needs to be sortable, and the value is db column to
107
+ * sort by.
108
+ *
109
+ * @return array An associative array containing all the columns that should be sortable: 'slugs'=>array('data_values',bool)
110
+ ***************************************************************************/
111
+ public function get_sortable_columns() {
112
+ $sortable_columns = array(
113
+ 'name' => array( 'name', true ), //true means its already sorted
114
+ 'desc' => array( 'desc', false ),
115
+ 'slug' => array( 'slug', false ),
116
+ 'num_events' => array( 'num_events', false )
117
+ );
118
+ // TODO: sorting of tables
119
+ //return $sortable_columns;
120
+ return array();
121
+ }
122
+
123
+ /** ************************************************************************
124
+ * Optional. If you need to include bulk actions in your list table, this is
125
+ * the place to define them. Bulk actions are an associative array in the format
126
+ * 'slug'=>'Visible Title'
127
+ * If this method returns an empty value, no bulk action will be rendered.
128
+ *
129
+ * @return array An associative array containing all the bulk actions: 'slugs'=>'Visible Titles'
130
+ ****************************************************************************/
131
+ public function get_bulk_actions() {
132
+ $actions = array(
133
+ 'delete_bulk' => 'Delete'
134
+ );
135
+ return $actions;
136
+ }
137
+
138
+ /** ************************************************************************
139
+ * Function to handle the process of the bulk actions.
140
+ *
141
+ * @see $this->prepare_items()
142
+ ***************************************************************************/
143
+ private function process_bulk_action() {
144
+ //Detect when a bulk action is being triggered...
145
+ if( 'delete_bulk' === $this->current_action() ) {
146
+ // Show confirmation window before deleting
147
+ echo '<script language="JavaScript">eventlist_deleteCategory ("'.implode( ', ', $_GET['slug'] ).'");</script>';
148
+ }
149
+ }
150
+
151
+ /** ************************************************************************
152
+ * In this function the data for the display is prepared.
153
+ *
154
+ * @param string $date_range Date range for displaying the events
155
+ * @uses $this->_column_headers
156
+ * @uses $this->items
157
+ * @uses $this->get_columns()
158
+ * @uses $this->get_sortable_columns()
159
+ * @uses $this->get_pagenum()
160
+ * @uses $this->set_pagination_args()
161
+ ***************************************************************************/
162
+ public function prepare_items() {
163
+ $per_page = 15;
164
+ // define column headers
165
+ $columns = $this->get_columns();
166
+ $hidden = array();
167
+ $sortable = $this->get_sortable_columns();
168
+ $this->_column_headers = array( $columns, $hidden, $sortable );
169
+ // handle the bulk actions
170
+ $this->process_bulk_action();
171
+ // get the required event data
172
+ $data = $this->categories->get_cat_array();
173
+ // setup pagination
174
+ $current_page = $this->get_pagenum();
175
+ $total_items = count( $data );
176
+ $data = array_slice( $data, ( ( $current_page-1 )*$per_page ), $per_page );
177
+ $this->set_pagination_args( array(
178
+ 'total_items' => $total_items,
179
+ 'per_page' => $per_page,
180
+ 'total_pages' => ceil($total_items/$per_page)
181
+ ) );
182
+ // setup items which are used by the rest of the class
183
+ $this->items = $data;
184
+ }
185
+ }
186
+
php/admin_event_table.php → admin/includes/event_table.php RENAMED
@@ -1,15 +1,19 @@
1
  <?php
2
  // load the base class (WP_List_Table class isn't automatically available)
3
  if(!class_exists('WP_List_Table')){
4
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
5
  }
6
- require_once( EL_PATH.'php/db.php' );
 
7
 
8
- class Admin_Event_Table extends WP_List_Table {
9
  private $db;
 
10
 
11
  public function __construct() {
12
- $this->db = el_db::get_instance();
 
 
13
  global $status, $page;
14
  //Set parent defaults
15
  parent::__construct( array(
@@ -37,6 +41,8 @@ class Admin_Event_Table extends WP_List_Table {
37
  return get_userdata( $item->pub_user )->user_login;
38
  case 'pub_date' :
39
  return $this->format_pub_date( $item->pub_date );
 
 
40
  default :
41
  return $item->$column_name;
42
  }
@@ -90,13 +96,14 @@ class Admin_Event_Table extends WP_List_Table {
90
  ***************************************************************************/
91
  public function get_columns() {
92
  return array(
93
- 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
94
- 'date' => 'Date',
95
- 'title' => 'Event',
96
- 'location' => 'Location',
97
- 'details' => 'Details',
98
- 'pub_user' => 'Author',
99
- 'pub_date' => 'Published'
 
100
  );
101
  }
102
 
@@ -117,8 +124,6 @@ class Admin_Event_Table extends WP_List_Table {
117
  'pub_date' => array( 'pub_date', false )
118
  );
119
  return $sortable_columns;
120
-
121
- return array();
122
  }
123
 
124
  /** ************************************************************************
@@ -218,7 +223,7 @@ class Admin_Event_Table extends WP_List_Table {
218
  break;
219
  }
220
  // get and return events in the correct order
221
- return $this->db->get_events( $date_range, 0, $sort_array );
222
  }
223
 
224
  /** ************************************************************************
1
  <?php
2
  // load the base class (WP_List_Table class isn't automatically available)
3
  if(!class_exists('WP_List_Table')){
4
+ require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
5
  }
6
+ require_once( EL_PATH.'includes/db.php' );
7
+ require_once( EL_PATH.'includes/categories.php' );
8
 
9
+ class EL_Event_Table extends WP_List_Table {
10
  private $db;
11
+ private $categories;
12
 
13
  public function __construct() {
14
+ $this->db = &EL_Db::get_instance();
15
+ $this->categories = &EL_Categories::get_instance();
16
+
17
  global $status, $page;
18
  //Set parent defaults
19
  parent::__construct( array(
41
  return get_userdata( $item->pub_user )->user_login;
42
  case 'pub_date' :
43
  return $this->format_pub_date( $item->pub_date );
44
+ case 'categories' :
45
+ return $this->categories->get_category_string( $item->$column_name );
46
  default :
47
  return $item->$column_name;
48
  }
96
  ***************************************************************************/
97
  public function get_columns() {
98
  return array(
99
+ 'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
100
+ 'date' => __( 'Date' ),
101
+ 'title' => __( 'Event' ),
102
+ 'location' => __( 'Location' ),
103
+ 'details' => __( 'Details' ),
104
+ 'categories' => __( 'Categories' ),
105
+ 'pub_user' => __( 'Author' ),
106
+ 'pub_date' => __( 'Published' )
107
  );
108
  }
109
 
124
  'pub_date' => array( 'pub_date', false )
125
  );
126
  return $sortable_columns;
 
 
127
  }
128
 
129
  /** ************************************************************************
223
  break;
224
  }
225
  // get and return events in the correct order
226
+ return $this->db->get_events( $date_range, 0, null, $sort_array );
227
  }
228
 
229
  /** ************************************************************************
{js → admin/js}/admin_main.js RENAMED
File without changes
{js → admin/js}/admin_new.js RENAMED
File without changes
admin/js/admin_settings.js ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ // Javascript functions for event-list admin_settings page
2
+
3
+ // Confirmation for event deletion
4
+ function eventlist_deleteCategory (id) {
5
+ if (confirm("Are you sure you want to delete this event category? This is a permanent action.")) {
6
+ document.location.href = "?page=el_admin_settings&slug=" + id + "&action=delete";
7
+ }
8
+ }
event-list.php CHANGED
@@ -3,13 +3,13 @@
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.3.4
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
10
 
11
  A plugin for the blogging MySQL/PHP-based WordPress.
12
- Copyright 2012 Michael Burtscher
13
 
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNUs General Public License
@@ -31,7 +31,7 @@ define( 'EL_PATH', plugin_dir_path( __FILE__ ) );
31
 
32
 
33
  // MAIN PLUGIN CLASS
34
- class event_list {
35
  private $shortcode;
36
 
37
  /**
@@ -50,8 +50,8 @@ class event_list {
50
  // ADMIN PAGE:
51
  if ( is_admin() ) {
52
  // Include required php-files and initialize required objects
53
- require_once( 'php/admin.php' );
54
- $admin = new el_admin();
55
  // Register actions
56
  add_action( 'admin_menu', array( &$admin, 'register_pages' ) );
57
  add_action( 'plugins_loaded', array( &$this, 'db_upgrade_check' ) );
@@ -66,31 +66,31 @@ class event_list {
66
 
67
  public function shortcode_event_list( $atts ) {
68
  if( NULL == $this->shortcode ) {
69
- require_once( 'php/sc_event-list.php' );
70
- $this->shortcode = sc_event_list::get_instance();
71
  }
72
  return $this->shortcode->show_html( $atts );
73
  }
74
 
75
  public function widget_init() {
76
  // Widget "event-list"
77
- require_once( 'php/event-list_widget.php' );
78
- return register_widget( 'event_list_widget' );
79
  }
80
 
81
  public function print_styles() {
82
- wp_register_style('event-list_css', EL_URL.'css/event-list.css');
83
  wp_enqueue_style( 'event-list_css');
84
  }
85
 
86
  public function db_upgrade_check() {
87
- require_once( 'php/db.php' );
88
- $db = el_db::get_instance();
89
  $db->upgrade_check();
90
  }
91
  } // end class linkview
92
 
93
 
94
  // create a class instance
95
- $event_list = new event_list();
96
  ?>
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.4.0
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
10
 
11
  A plugin for the blogging MySQL/PHP-based WordPress.
12
+ Copyright 2012-2013 Michael Burtscher
13
 
14
  This program is free software; you can redistribute it and/or
15
  modify it under the terms of the GNUs General Public License
31
 
32
 
33
  // MAIN PLUGIN CLASS
34
+ class Event_List {
35
  private $shortcode;
36
 
37
  /**
50
  // ADMIN PAGE:
51
  if ( is_admin() ) {
52
  // Include required php-files and initialize required objects
53
+ require_once( EL_PATH.'admin/admin.php' );
54
+ $admin = new EL_Admin();
55
  // Register actions
56
  add_action( 'admin_menu', array( &$admin, 'register_pages' ) );
57
  add_action( 'plugins_loaded', array( &$this, 'db_upgrade_check' ) );
66
 
67
  public function shortcode_event_list( $atts ) {
68
  if( NULL == $this->shortcode ) {
69
+ require_once( EL_PATH.'includes/sc_event-list.php' );
70
+ $this->shortcode = SC_Event_List::get_instance();
71
  }
72
  return $this->shortcode->show_html( $atts );
73
  }
74
 
75
  public function widget_init() {
76
  // Widget "event-list"
77
+ require_once( EL_PATH.'includes/widget.php' );
78
+ return register_widget( 'EL_Widget' );
79
  }
80
 
81
  public function print_styles() {
82
+ wp_register_style('event-list_css', EL_URL.'/includes/css/event-list.css');
83
  wp_enqueue_style( 'event-list_css');
84
  }
85
 
86
  public function db_upgrade_check() {
87
+ require_once( EL_PATH.'includes/db.php' );
88
+ $db = EL_Db::get_instance();
89
  $db->upgrade_check();
90
  }
91
  } // end class linkview
92
 
93
 
94
  // create a class instance
95
+ $event_list = new Event_List();
96
  ?>
includes/categories.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once( EL_PATH.'includes/options.php' );
3
+
4
+ // Class to manage categories
5
+ class EL_Categories {
6
+ private static $instance;
7
+ private $options;
8
+ private $db;
9
+ private $cat_array;
10
+
11
+ public static function &get_instance() {
12
+ // Create class instance if required
13
+ if( !isset( self::$instance ) ) {
14
+ self::$instance = new EL_Categories();
15
+ }
16
+ // Return class instance
17
+ return self::$instance;
18
+ }
19
+
20
+ private function __construct() {
21
+ $this->options = &EL_Options::get_instance();
22
+ $this->db = &EL_Db::get_instance();
23
+ $this->initalize_cat_array();
24
+ }
25
+
26
+ private function initalize_cat_array() {
27
+ $cat_array = (array) $this->options->get( 'el_categories' );
28
+ $this->cat_array = array();
29
+ foreach( $cat_array as $cat ) {
30
+ $this->cat_array[$cat['slug']] = $cat;
31
+ }
32
+ }
33
+
34
+ public function add_category( $cat_data ) {
35
+ // check if name was set
36
+ if( !isset( $cat_data['name'] ) || '' == $cat_data['name'] ) {
37
+ return false;
38
+ }
39
+ // check if name already exists
40
+ foreach( $this->cat_array as $cat ) {
41
+ if( $cat['name'] == $cat_data['name'] ) {
42
+ return false;
43
+ }
44
+ }
45
+ if( !isset( $cat_data['slug'] ) || '' == $cat_data['slug'] ) {
46
+ $cat_data['slug'] = $cat_data['name'];
47
+ }
48
+ $cat['name'] = trim( $cat_data['name'] );
49
+ $cat['desc'] = isset( $cat_data['desc'] ) ? trim( $cat_data['desc'] ) : '';
50
+ // make slug unique
51
+ $cat['slug'] = $slug = sanitize_title( $cat_data['slug'] );
52
+ $num = 1;
53
+ while( isset( $this->cat_array[$cat['slug']] ) ) {
54
+ $num++;
55
+ $cat['slug'] = $slug.'-'.$num;
56
+ }
57
+ $this->cat_array[$cat['slug']] = $cat;
58
+ return $this->safe_categories();
59
+ }
60
+
61
+ public function remove_categories( $slugs ) {
62
+ foreach( $slugs as $slug ) {
63
+ unset( $this->cat_array[$slug] );
64
+ }
65
+ return $this->safe_categories();
66
+ }
67
+
68
+ //TODO: missing function: edit_category
69
+ /*
70
+ public function edit_category( $slug, $item ) {
71
+
72
+ }*/
73
+
74
+ private function safe_categories() {
75
+ if( !sort( $this->cat_array ) ) {
76
+ return false;
77
+ }
78
+ if( !$this->options->set( 'el_categories', $this->cat_array ) ) {
79
+ return false;
80
+ }
81
+ return true;
82
+ }
83
+
84
+ public function get_cat_array() {
85
+ return $this->cat_array;
86
+ }
87
+
88
+ public function get_category_string( $slugs ) {
89
+ if( 2 >= strlen( $slugs ) ) {
90
+ return '';
91
+ }
92
+ $slug_array = explode( '|', substr( $slugs, 1, -1 ) );
93
+ $name_array = array();
94
+ foreach( $slug_array as $slug ) {
95
+ $name_array[] = $this->cat_array[$slug]['name'];
96
+ }
97
+ return implode( ', ', $name_array );
98
+ }
99
+ }
{css → includes/css}/event-list.css RENAMED
@@ -28,6 +28,7 @@
28
  <h3 class="event-title"></h3>
29
  <span class="event-time"></span>
30
  <span class="event-location"></span>
 
31
  <div class="event-details"></div>
32
  </div>
33
  </li>
@@ -127,6 +128,10 @@ li.event {
127
  padding-right: 0.8em;
128
  }
129
 
 
 
 
 
130
  .event-details {
131
  font-size: 0.8em;
132
  }
28
  <h3 class="event-title"></h3>
29
  <span class="event-time"></span>
30
  <span class="event-location"></span>
31
+ <div class="event-cat"></div>
32
  <div class="event-details"></div>
33
  </div>
34
  </li>
128
  padding-right: 0.8em;
129
  }
130
 
131
+ .event-cat {
132
+ font-size: 0.95em;
133
+ }
134
+
135
  .event-details {
136
  font-size: 0.8em;
137
  }
{php → includes}/db.php RENAMED
@@ -1,10 +1,10 @@
1
  <?php
2
- //require_once( EL_PATH.'php/options.php' );
3
 
4
  // Class for database access via wordpress functions
5
- class el_db {
6
- const VERSION = "0.1";
7
- const TABLE_NAME = "event_list";
8
  private static $instance;
9
  private $table;
10
  private $options;
@@ -12,7 +12,7 @@ class el_db {
12
  public static function &get_instance() {
13
  // Create class instance if required
14
  if( !isset( self::$instance ) ) {
15
- self::$instance = new el_db();
16
  }
17
  // Return class instance
18
  return self::$instance;
@@ -21,13 +21,12 @@ class el_db {
21
  private function __construct() {
22
  global $wpdb;
23
  $this->table = $wpdb->prefix.self::TABLE_NAME;
24
- //$this->options = &lv_options::get_instance();
25
  }
26
 
27
  // UPDATE DB
28
  public function upgrade_check() {
29
- // TODO: added version checking
30
- // if( el_options::get( 'el_db_version' ) != self::VERSION) {
31
  $sql = 'CREATE TABLE '.$this->table.' (
32
  id int(11) NOT NULL AUTO_INCREMENT,
33
  pub_user bigint(20) NOT NULL,
@@ -38,18 +37,17 @@ class el_db {
38
  title text NOT NULL,
39
  location text,
40
  details text,
 
41
  history text,
42
  PRIMARY KEY (id) )
43
  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
44
-
45
  require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
46
  dbDelta( $sql );
47
-
48
- // el_options::set( 'el_db_version', self::VERSION );
49
- // }
50
  }
51
 
52
- public function get_events( $date_range='all', $num_events=0, $sort_array=array( 'start_date ASC', 'time ASC', 'end_date ASC') ) {
53
  global $wpdb;
54
 
55
  // set date for data base query
@@ -68,7 +66,9 @@ class el_db {
68
  $range_start = date( 'Y-m-d' );
69
  $range_end = '9999-12-31';
70
  }
71
- $sql = 'SELECT * FROM '.$this->table.' WHERE (end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'") ORDER BY '.implode( ', ', $sort_array );
 
 
72
  if( 'upcoming' === $date_range && is_numeric($num_events) && 0 < $num_events ) {
73
  $sql .= ' LIMIT '.$num_events;
74
  }
@@ -108,9 +108,9 @@ class el_db {
108
  // prepare and validate sqldata
109
  $sqldata = array();
110
  //pub_user
111
- $sqldata['pub_user'] = wp_get_current_user()->ID;
112
  //pub_date
113
- $sqldata['pub_date'] = date( "Y-m-d H:i:s" );
114
  //start_date
115
  if( !isset( $event_data['start_date']) ) { return false; }
116
  $start_timestamp = 0;
@@ -139,9 +139,11 @@ class el_db {
139
  //details
140
  if( !isset( $event_data['details'] ) ) { $sqldata['details'] = ''; }
141
  else { $sqldata['details'] = stripslashes ($event_data['details'] ); }
 
 
 
142
  //types for sql data
143
- $sqltypes = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' );
144
-
145
  if( isset( $event_data['id'] ) ) { // update event
146
  $wpdb->update( $this->table, $sqldata, array( 'id' => $event_data['id'] ), $sqltypes );
147
  }
@@ -170,6 +172,33 @@ class el_db {
170
  }
171
  }
172
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  private function extract_date( $datestring, $ret_format, $dateformat=NULL, &$ret_timestamp=NULL, &$ret_datearray=NULL ) {
174
  if( NULL === $dateformat ) {
175
  $date_array = date_parse( $datestring );
@@ -200,7 +229,7 @@ class el_db {
200
  * @param string $html The html code which should be shortened
201
  ***************************************************************************/
202
  public function truncate( $max_length, $html ) {
203
- if( strlen( $html ) > $max_length ) {
204
  $printedLength = 0;
205
  $position = 0;
206
  $tags = array();
1
  <?php
2
+ require_once( EL_PATH.'includes/options.php' );
3
 
4
  // Class for database access via wordpress functions
5
+ class EL_Db {
6
+ const VERSION = '0.2';
7
+ const TABLE_NAME = 'event_list';
8
  private static $instance;
9
  private $table;
10
  private $options;
12
  public static function &get_instance() {
13
  // Create class instance if required
14
  if( !isset( self::$instance ) ) {
15
+ self::$instance = new EL_Db();
16
  }
17
  // Return class instance
18
  return self::$instance;
21
  private function __construct() {
22
  global $wpdb;
23
  $this->table = $wpdb->prefix.self::TABLE_NAME;
24
+ $this->options = &EL_Options::get_instance();
25
  }
26
 
27
  // UPDATE DB
28
  public function upgrade_check() {
29
+ if( $this->options->get( 'el_db_version' ) != self::VERSION ) {
 
30
  $sql = 'CREATE TABLE '.$this->table.' (
31
  id int(11) NOT NULL AUTO_INCREMENT,
32
  pub_user bigint(20) NOT NULL,
37
  title text NOT NULL,
38
  location text,
39
  details text,
40
+ categories text,
41
  history text,
42
  PRIMARY KEY (id) )
43
  DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
 
44
  require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
45
  dbDelta( $sql );
46
+ $this->options->set( 'el_db_version', self::VERSION );
47
+ }
 
48
  }
49
 
50
+ public function get_events( $date_range='all', $num_events=0, $cat_filter=null, $sort_array=array( 'start_date ASC', 'time ASC', 'end_date ASC') ) {
51
  global $wpdb;
52
 
53
  // set date for data base query
66
  $range_start = date( 'Y-m-d' );
67
  $range_end = '9999-12-31';
68
  }
69
+ // set category filter
70
+ $sql_cat_filter = empty( $cat_filter ) ? '' : ' AND ( categories LIKE "%|'.implode( '|%" OR categories LIKE "%|', $cat_filter ).'|%" )';
71
+ $sql = 'SELECT * FROM '.$this->table.' WHERE end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'"'.$sql_cat_filter.' ORDER BY '.implode( ', ', $sort_array );
72
  if( 'upcoming' === $date_range && is_numeric($num_events) && 0 < $num_events ) {
73
  $sql .= ' LIMIT '.$num_events;
74
  }
108
  // prepare and validate sqldata
109
  $sqldata = array();
110
  //pub_user
111
+ $sqldata['pub_user'] = isset( $event_data['pub_user'] ) ? $event_data['pub_user'] : wp_get_current_user()->ID;
112
  //pub_date
113
+ $sqldata['pub_date'] = isset( $event_data['pub_date'] ) ? $event_data['pub_date'] : date( "Y-m-d H:i:s" );
114
  //start_date
115
  if( !isset( $event_data['start_date']) ) { return false; }
116
  $start_timestamp = 0;
139
  //details
140
  if( !isset( $event_data['details'] ) ) { $sqldata['details'] = ''; }
141
  else { $sqldata['details'] = stripslashes ($event_data['details'] ); }
142
+ //categories
143
+ if( !isset( $event_data['categories'] ) || !is_array( $event_data['categories'] ) || empty( $event_data['categories'] ) ) { $sqldata['categories'] = ''; }
144
+ else { $sqldata['categories'] = '|'.implode( '|', $event_data['categories'] ).'|'; }
145
  //types for sql data
146
+ $sqltypes = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' );
 
147
  if( isset( $event_data['id'] ) ) { // update event
148
  $wpdb->update( $this->table, $sqldata, array( 'id' => $event_data['id'] ), $sqltypes );
149
  }
172
  }
173
  }
174
 
175
+ public function remove_category_in_events( $category_slugs ) {
176
+ global $wpdb;
177
+ $sql = 'SELECT * FROM '.$this->table.' WHERE categories LIKE "%|'.implode( '|%" OR categories LIKE "%|', $category_slugs ).'|%"';
178
+ $affected_events = $wpdb->get_results($sql, ARRAY_A);
179
+ foreach( $affected_events as $event ) {
180
+ // remove category from categorystring
181
+ foreach( $category_slugs as $slug ) {
182
+ $event['categories'] = str_replace('|'.$slug, '', $event['categories']);
183
+ }
184
+ if( 3 > strlen( $event['categories'] ) ) {
185
+ $event['categories'] = '';
186
+ }
187
+ else {
188
+ $event['categories'] = explode( '|', substr($event['categories'], 1, -1 ) );
189
+ }
190
+ print_r( $event['categories']);
191
+ $this->update_event( $event );
192
+ }
193
+ return count( $affected_events );
194
+ }
195
+
196
+ public function count_events( $slug ) {
197
+ global $wpdb;
198
+ $sql = 'SELECT COUNT(*) FROM '.$this->table.' WHERE categories LIKE "%|'.$slug.'|%"';
199
+ return $wpdb->get_var( $sql );
200
+ }
201
+
202
  private function extract_date( $datestring, $ret_format, $dateformat=NULL, &$ret_timestamp=NULL, &$ret_datearray=NULL ) {
203
  if( NULL === $dateformat ) {
204
  $date_array = date_parse( $datestring );
229
  * @param string $html The html code which should be shortened
230
  ***************************************************************************/
231
  public function truncate( $max_length, $html ) {
232
+ if( $max_length > 0 && strlen( $html ) > $max_length ) {
233
  $printedLength = 0;
234
  $position = 0;
235
  $tags = array();
{images → includes/images}/date-separator.png RENAMED
File without changes
includes/options.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // This class handles all available options
4
+ class EL_Options {
5
+
6
+ private static $instance;
7
+ public $group;
8
+ public $options;
9
+
10
+ public static function &get_instance() {
11
+ // Create class instance if required
12
+ if( !isset( self::$instance ) ) {
13
+ self::$instance = new EL_Options();
14
+ self::$instance->init();
15
+ }
16
+ // Return class instance
17
+ return self::$instance;
18
+ }
19
+
20
+ public function __construct() {
21
+ $this->group = 'event-list';
22
+
23
+ $this->options = array(
24
+ 'el_db_version' => array( 'section' => 'system',
25
+ 'type' => 'text',
26
+ 'std_val' => '',
27
+ 'label' => '',
28
+ 'caption' => '',
29
+ 'desc' => 'Database version' ),
30
+
31
+ 'el_categories' => array( 'section' => 'categories',
32
+ 'type' => 'category',
33
+ 'std_val' => null,
34
+ 'label' => 'Event Categories',
35
+ 'caption' => '',
36
+ 'desc' => 'This option specifies all event category data.' ),
37
+
38
+ 'el_no_event_text' => array( 'section' => 'general',
39
+ 'type' => 'text',
40
+ 'std_val' => 'no event',
41
+ 'label' => 'Text for no events',
42
+ 'caption' => '',
43
+ 'desc' => 'This option defines the text which is displayed if no events are available for the selected view.' )
44
+ );
45
+ }
46
+
47
+ public function init() {
48
+ add_action( 'admin_init', array( &$this, 'register' ) );
49
+ }
50
+
51
+ public function register() {
52
+ foreach( $this->options as $oname => $o ) {
53
+ register_setting( 'el_'.$o['section'], $oname );
54
+ }
55
+ }
56
+
57
+ public function set( $name, $value ) {
58
+ if( isset( $this->options[$name] ) ) {
59
+ return update_option( $name, $value );
60
+ }
61
+ else {
62
+ return false;
63
+ }
64
+ }
65
+
66
+ public function get( $name ) {
67
+ if( isset( $this->options[$name] ) ) {
68
+ return get_option( $name, $this->options[$name]['std_val'] );
69
+ }
70
+ else {
71
+ return null;
72
+ }
73
+ }
74
+ }
75
+ ?>
{php → includes}/sc_event-list.php RENAMED
@@ -1,11 +1,14 @@
1
  <?php
2
- require_once( EL_PATH.'php/db.php' );
 
 
3
 
4
  // This class handles the shortcode [event-list]
5
- class sc_event_list {
6
  private static $instance;
7
  private $db;
8
  private $options;
 
9
  private $atts;
10
  private $num_sc_loaded;
11
  private $single_event;
@@ -13,15 +16,16 @@ class sc_event_list {
13
  public static function &get_instance() {
14
  // Create class instance if required
15
  if( !isset( self::$instance ) ) {
16
- self::$instance = new sc_event_list();
17
  }
18
  // Return class instance
19
  return self::$instance;
20
  }
21
 
22
  private function __construct() {
23
- $this->db = el_db::get_instance();
24
- //$this->options = &el_options::get_instance();
 
25
 
26
  // All available attributes
27
  $this->atts = array(
@@ -32,6 +36,12 @@ class sc_event_list {
32
  'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
33
  Specify a year e.g. "2013" to change this behavior.' ),
34
 
 
 
 
 
 
 
35
  'num_events' => array( 'val' => 'number',
36
  'std_val' => '0',
37
  'visible' => true,
@@ -52,6 +62,13 @@ class sc_event_list {
52
  Choose "false" to always hide and "true" to always show the location.<br />
53
  With "event_list_only" the location is only visible in the event list and with "single_event_only" only for a single event'),
54
 
 
 
 
 
 
 
 
55
  'show_details' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
56
  'std_val' => 'true',
57
  'visible' => true,
@@ -157,7 +174,8 @@ class sc_event_list {
157
  if( is_numeric( $a['ytd'] ) ) {
158
  $a['num_events'] = 0;
159
  }
160
- $events = $this->db->get_events( $a['ytd'], $a['num_events'] );
 
161
  $out = '';
162
  // TODO: add rss feed
163
  // if ($mfgigcal_settings['rss']) {
@@ -167,10 +185,9 @@ class sc_event_list {
167
 
168
  // generate output
169
  $out .= $this->html_calendar_nav( $a );
170
- // TODO: Setting missing
171
- if( empty( $events ) /*&& $mfgigcal_settings['no-events'] == "text"*/ ) {
172
  // no events found
173
- $out .= "<p>" . 'no event' /*$mfgigcal_settings['message'] */. "</p>";
174
  }
175
  else {
176
  // print available events
@@ -216,6 +233,9 @@ class sc_event_list {
216
  if( $this->is_visible( $a['show_location'] ) ) {
217
  $out .= '<span class="event-location">'.$event->location.'</span>';
218
  }
 
 
 
219
  if( $this->is_visible( $a['show_details'] ) ) {
220
  if( is_numeric( $a['event_id'] ) || 0 >= $a['details_length'] ) {
221
  $details = $event->details;
@@ -223,7 +243,7 @@ class sc_event_list {
223
  else {
224
  $details = $this->db->truncate( $a['details_length'], $event->details );
225
  }
226
- $out .= '<div class="event-details">'.$details.'</div>';
227
  }
228
  $out .= '</div>
229
  </li>';
@@ -279,7 +299,6 @@ class sc_event_list {
279
  $url = $this->get_url( $a );
280
  $out .= '<div class="subsubsub">';
281
  if( is_numeric( $a['ytd'] ) || is_numeric( $a['event_id'] ) ) {
282
- $ytd = isset( $a['initial_date'] ) && is_numeric( $a['initial_date'] ) ? 'ytd_'.$a['sc_id_for_url'].'=upcoming' : '';
283
  $out .= '<a href="'.$url.'ytd_'.$a['sc_id_for_url'].'=upcoming">Upcoming</a>';
284
  }
285
  else {
1
  <?php
2
+ require_once( EL_PATH.'includes/db.php' );
3
+ require_once( EL_PATH.'includes/options.php' );
4
+ require_once( EL_PATH.'includes/categories.php' );
5
 
6
  // This class handles the shortcode [event-list]
7
+ class SC_Event_List {
8
  private static $instance;
9
  private $db;
10
  private $options;
11
+ private $categories;
12
  private $atts;
13
  private $num_sc_loaded;
14
  private $single_event;
16
  public static function &get_instance() {
17
  // Create class instance if required
18
  if( !isset( self::$instance ) ) {
19
+ self::$instance = new SC_Event_List();
20
  }
21
  // Return class instance
22
  return self::$instance;
23
  }
24
 
25
  private function __construct() {
26
+ $this->db = &EL_Db::get_instance();
27
+ $this->options = &EL_Options::get_instance();
28
+ $this->categories = &EL_Categories::get_instance();
29
 
30
  // All available attributes
31
  $this->atts = array(
36
  'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
37
  Specify a year e.g. "2013" to change this behavior.' ),
38
 
39
+ 'cat_filter' => array( 'val' => 'none<br />category slug',
40
+ 'std_val' => 'none',
41
+ 'visible' => true,
42
+ 'desc' => 'This attribute specifies events of which categories are shown. The standard is "none" to show all events.<br />
43
+ Specify a category slug or a list of category slugs separated by a comma "," e.g. "tennis,hockey" to only show events of the specified categories.' ),
44
+
45
  'num_events' => array( 'val' => 'number',
46
  'std_val' => '0',
47
  'visible' => true,
62
  Choose "false" to always hide and "true" to always show the location.<br />
63
  With "event_list_only" the location is only visible in the event list and with "single_event_only" only for a single event'),
64
 
65
+ 'show_cat' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
66
+ 'std_val' => 'false',
67
+ 'visible' => true,
68
+ 'desc' => 'This attribute specifies if the categories are displayed in the event list.<br />
69
+ Choose "false" to always hide and "true" to always show the category.<br />
70
+ With "event_list_only" the categories are only visible in the event list and with "single_event_only" only for a single event'),
71
+
72
  'show_details' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
73
  'std_val' => 'true',
74
  'visible' => true,
174
  if( is_numeric( $a['ytd'] ) ) {
175
  $a['num_events'] = 0;
176
  }
177
+ $cat_filter = 'none' === $a['cat_filter'] ? null : explode( ',', $a['cat_filter'] );
178
+ $events = $this->db->get_events( $a['ytd'], $a['num_events'], $cat_filter );
179
  $out = '';
180
  // TODO: add rss feed
181
  // if ($mfgigcal_settings['rss']) {
185
 
186
  // generate output
187
  $out .= $this->html_calendar_nav( $a );
188
+ if( empty( $events ) ) {
 
189
  // no events found
190
+ $out .= '<p>'.$this->options->get( 'el_no_event_text' ).'</p>';
191
  }
192
  else {
193
  // print available events
233
  if( $this->is_visible( $a['show_location'] ) ) {
234
  $out .= '<span class="event-location">'.$event->location.'</span>';
235
  }
236
+ if( $this->is_visible( $a['show_cat'] ) ) {
237
+ $out .= '<div class="event-cat">'.$this->categories->get_category_string( $event->categories ).'</div>';
238
+ }
239
  if( $this->is_visible( $a['show_details'] ) ) {
240
  if( is_numeric( $a['event_id'] ) || 0 >= $a['details_length'] ) {
241
  $details = $event->details;
243
  else {
244
  $details = $this->db->truncate( $a['details_length'], $event->details );
245
  }
246
+ $out .= '<div class="event-details">'.do_shortcode( $details ).'</div>';
247
  }
248
  $out .= '</div>
249
  </li>';
299
  $url = $this->get_url( $a );
300
  $out .= '<div class="subsubsub">';
301
  if( is_numeric( $a['ytd'] ) || is_numeric( $a['event_id'] ) ) {
 
302
  $out .= '<a href="'.$url.'ytd_'.$a['sc_id_for_url'].'=upcoming">Upcoming</a>';
303
  }
304
  else {
php/event-list_widget.php → includes/widget.php RENAMED
@@ -2,7 +2,7 @@
2
  /**
3
  * Event List Widget
4
  */
5
- class event_list_widget extends WP_Widget {
6
 
7
  /**
8
  * Register widget with WordPress.
@@ -43,7 +43,6 @@ class event_list_widget extends WP_Widget {
43
  echo '<div style="clear:both"><a title="'.$instance['link_to_page_caption'].'" href="'.$instance[ 'url_to_page'].'">'.$instance['link_to_page_caption'].'</a></div>';
44
  }
45
  echo $after_widget;
46
- extract( $args );
47
  }
48
 
49
  /**
@@ -101,7 +100,7 @@ class event_list_widget extends WP_Widget {
101
  <label><input class="widefat" id="'.$this->get_field_id( 'show_location' ).'" name="'.$this->get_field_name( 'show_location' ).'" type="checkbox" '.$show_location_checked.'value="1" /> '.__( 'Show location' ).'</label>
102
  </p>
103
  <p style="margin:0 0 0.4em 0">
104
- <label for="'.$this->get_field_id( 'link_to_page_url' ).'">'.__( 'URL to the linked eventlist page:' ).'</label>
105
  <input class="widefat" id="'.$this->get_field_id( 'url_to_page' ).'" name="'.$this->get_field_name( 'url_to_page' ).'" type="text" value="'.esc_attr( $url_to_page ).'" />
106
  </p>
107
  <p>
2
  /**
3
  * Event List Widget
4
  */
5
+ class EL_Widget extends WP_Widget {
6
 
7
  /**
8
  * Register widget with WordPress.
43
  echo '<div style="clear:both"><a title="'.$instance['link_to_page_caption'].'" href="'.$instance[ 'url_to_page'].'">'.$instance['link_to_page_caption'].'</a></div>';
44
  }
45
  echo $after_widget;
 
46
  }
47
 
48
  /**
100
  <label><input class="widefat" id="'.$this->get_field_id( 'show_location' ).'" name="'.$this->get_field_name( 'show_location' ).'" type="checkbox" '.$show_location_checked.'value="1" /> '.__( 'Show location' ).'</label>
101
  </p>
102
  <p style="margin:0 0 0.4em 0">
103
+ <label for="'.$this->get_field_id( 'url_to_page' ).'">'.__( 'URL to the linked eventlist page:' ).'</label>
104
  <input class="widefat" id="'.$this->get_field_id( 'url_to_page' ).'" name="'.$this->get_field_name( 'url_to_page' ).'" type="text" value="'.esc_attr( $url_to_page ).'" />
105
  </p>
106
  <p>
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
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.1
7
- Stable tag: 0.3.4
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
@@ -23,6 +23,7 @@ The purpose of this plugin is to to show a list of events with date, time, descr
23
  * Wordpress's WYSIWYG editor for the event details. So you can include styled text, links, images and other media in your event list.
24
  * A duplicate function for events
25
  * Event navigation to view only upcoming events or past/future events filtered by year
 
26
 
27
  The event list can be placed in any page or post on your Wordpress site. Just include the following short code where you want the calendar to appear:
28
 
@@ -50,20 +51,32 @@ Insert the shortcode [event-list] in your page.
50
  Event List uses the built-in Wordpress WYSIWYG editor. It's exactly the same process you use when creating Posts or Pages.
51
 
52
  = Can I call the shortcode directly via php e.g. for my own template, theme or plugin? =
53
- Yes, you can create an instance of the "sc_event_list" class which located in "php/sc_event-list.php" in the plugin folder and call the function show_html($atts).With $atts you can specify all the shortcode attributes you require. Another possibility would be to call the wordpress function "do_shortcode()".
54
 
55
 
56
  == Screenshots ==
57
 
58
  1. Admin page: Main page with the event list table
59
- 2. Admin page: New event form
60
- 3. Admin page: About page with help and available attributes list
61
- 4. Admin page: Widget with the available options
62
- 5. Example page created with [event-list] shortcode
 
63
 
64
 
65
  == Changelog ==
66
 
 
 
 
 
 
 
 
 
 
 
 
67
  = 0.3.4 (2013-03-16) =
68
 
69
  * fixed deleting of events
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.1
7
+ Stable tag: 0.4.0
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
23
  * Wordpress's WYSIWYG editor for the event details. So you can include styled text, links, images and other media in your event list.
24
  * A duplicate function for events
25
  * Event navigation to view only upcoming events or past/future events filtered by year
26
+ * Event categories
27
 
28
  The event list can be placed in any page or post on your Wordpress site. Just include the following short code where you want the calendar to appear:
29
 
51
  Event List uses the built-in Wordpress WYSIWYG editor. It's exactly the same process you use when creating Posts or Pages.
52
 
53
  = Can I call the shortcode directly via php e.g. for my own template, theme or plugin? =
54
+ Yes, you can create an instance of the "SC_Event_List" class which located in "php/sc_event-list.php" in the plugin folder and call the function show_html($atts).With $atts you can specify all the shortcode attributes you require. Another possibility would be to call the wordpress function "do_shortcode()".
55
 
56
 
57
  == Screenshots ==
58
 
59
  1. Admin page: Main page with the event list table
60
+ 2. Admin page: New/edit event form
61
+ 3. Admin page: Settings page (category tab)
62
+ 4. Admin page: About page with help and shortcode attributes list
63
+ 5. Admin page: Widget with the available options
64
+ 6. Example page created with [event-list] shortcode
65
 
66
 
67
  == Changelog ==
68
 
69
+ = 0.4.0 (2013-05-04) =
70
+
71
+ * added category support
72
+ * added settings page
73
+ * small changes in add/edit event admin page
74
+ * added settings page
75
+ * added option "no_event_text"
76
+ * execute shortcodes in event details field on front page
77
+ * change of plugin folder structure and file names
78
+ * small fixes in widget code
79
+
80
  = 0.3.4 (2013-03-16) =
81
 
82
  * fixed deleting of events
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file
screenshot-5.png CHANGED
Binary file
screenshot-6.png ADDED
Binary file