Event List - Version 0.3.1

Version Description

(2013-01-03) =

  • added widget option "show_location"
  • fixed wrong url for single event page link
  • fixed issue with different shortcodes on one page or post
  • changed required prevelegs for admin about page
  • updated help messages on admin about page
  • small style changes on frontpage
Download this release

Release Info

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

Code changes from version 0.3.0 to 0.3.1

css/event-list.css CHANGED
@@ -72,7 +72,7 @@ li.event {
72
  text-align: center;
73
  width: 3.2em;
74
  border-radius: 5px;
75
- background-color: rgb(220,220,220);
76
  overflow: hidden;
77
  }
78
 
72
  text-align: center;
73
  width: 3.2em;
74
  border-radius: 5px;
75
+ background-color: rgb(230,230,230);
76
  overflow: hidden;
77
  }
78
 
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.3.0
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.3.1
7
  Author: Michael Burtscher
8
  Author URI: http://wordpress.org/extend/plugins/event-list/
9
  License: GPLv2
php/admin.php CHANGED
@@ -30,7 +30,7 @@ class el_admin {
30
  $page = add_submenu_page( 'el_admin_main', 'Add New Event', 'Add New', 'edit_posts', 'el_admin_new', array( &$this, 'show_new' ) );
31
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_new_scripts' ) );
32
  add_submenu_page( 'el_admin_main', 'Event List Settings', 'Settings', 'manage_options', 'el_admin_settings', array( &$this, 'show_settings' ) );
33
- $page = add_submenu_page( 'el_admin_main', 'About Event List', 'About', 'manage_options', 'el_admin_about', array( &$this, 'show_about' ) );
34
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_about_scripts' ) );
35
  }
36
 
@@ -173,8 +173,14 @@ class el_admin {
173
  <p>To show the events on your site you have two possibilities:
174
  <ul class="el-show-event-options"><li>you can place the <strong>shortcode</strong> <code>[event-list]</code> on any page or post</li>
175
  <li>you can add the <strong>widget</strong> "Event List" in your sidebars</li></ul>
176
- The the displayed events and their style can be modified with the available widget settings and the available attributes for the shortcode.<br />
177
- A list of all available shortcode attributes with their description can be found below.
 
 
 
 
 
 
178
  </p>
179
  <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>
180
  </div>';
30
  $page = add_submenu_page( 'el_admin_main', 'Add New Event', 'Add New', 'edit_posts', 'el_admin_new', array( &$this, 'show_new' ) );
31
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_new_scripts' ) );
32
  add_submenu_page( 'el_admin_main', 'Event List Settings', 'Settings', 'manage_options', 'el_admin_settings', array( &$this, 'show_settings' ) );
33
+ $page = add_submenu_page( 'el_admin_main', 'About Event List', 'About', 'edit_posts', 'el_admin_about', array( &$this, 'show_about' ) );
34
  add_action( 'admin_print_scripts-'.$page, array( &$this, 'embed_admin_about_scripts' ) );
35
  }
36
 
173
  <p>To show the events on your site you have two possibilities:
174
  <ul class="el-show-event-options"><li>you can place the <strong>shortcode</strong> <code>[event-list]</code> on any page or post</li>
175
  <li>you can add the <strong>widget</strong> "Event List" in your sidebars</li></ul>
176
+ The displayed events and their style can be modified with the available widget settings and the available attributes for the shortcode.<br />
177
+ A list of all available shortcode attributes with their description is listed below.<br />
178
+ The most available options of the widget should be clear by there description.<br />
179
+ It is important to know that you have to insert an URL to the linked event-list page if you enable one of the links options ("Add links to the single events" or "Add a link to an event page").
180
+ This is required because the widget didn´t know in which page or post you have insert the shortcode.<br />
181
+ 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.
182
+ 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.
183
+ The ID is given behind the "_" (e.g. <i>http://www.your-homepage.com/?page_id=99&event_id_<strong>1</strong>=11</i>).
184
  </p>
185
  <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>
186
  </div>';
php/db.php CHANGED
@@ -53,20 +53,21 @@ class el_db {
53
  global $wpdb;
54
 
55
  // set date for data base query
56
- if( 'all' === $date_range ) {
 
 
 
 
 
57
  // get all events
58
  $range_start = '0000-01-01';
59
  $range_end = '9999-12-31';
60
  }
61
- elseif( 'upcoming' === $date_range ) {
62
  // get only events in the future
63
  $range_start = date( 'Y-m-d' );
64
  $range_end = '9999-12-31';
65
  }
66
- else {
67
- $range_start = $date_range.'-01-01';
68
- $range_end = $date_range.'-12-31';
69
- }
70
  $sql = 'SELECT * FROM '.$this->table.' WHERE (end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'") ORDER BY '.implode( ', ', $sort_array );
71
  if( 'upcoming' === $date_range && is_numeric($num_events) && 0 < $num_events ) {
72
  $sql .= ' LIMIT '.$num_events;
53
  global $wpdb;
54
 
55
  // set date for data base query
56
+ if( is_numeric( $date_range ) ) {
57
+ // get events of a specific year
58
+ $range_start = $date_range.'-01-01';
59
+ $range_end = $date_range.'-12-31';
60
+ }
61
+ elseif( 'all' === $date_range ) {
62
  // get all events
63
  $range_start = '0000-01-01';
64
  $range_end = '9999-12-31';
65
  }
66
+ else { // upcoming
67
  // get only events in the future
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;
php/event-list_widget.php CHANGED
@@ -11,7 +11,7 @@ class event_list_widget extends WP_Widget {
11
  parent::__construct(
12
  'event_list_widget', // Base ID
13
  'Event List', // Name
14
- array( 'description' => __( 'This widget displays a list of upcoming events.', 'text_domain' ), ) // Args
15
  );
16
  }
17
 
@@ -32,9 +32,15 @@ class event_list_widget extends WP_Widget {
32
  {
33
  echo $before_title . $title . $after_title;
34
  }
35
- echo do_shortcode( '[event-list num_events="'.$instance['num_events'].'" show_nav=0 show_details=0 show_location=0 link_to_event='.$instance['link_to_event'].']' );
 
 
 
 
 
 
36
  if( 1 == $instance['link_to_page'] ) {
37
- echo '<div style="clear:both"><a title="'.$instance['link_to_page_caption'].'" href="'.$instance[ 'link_to_page_url'].'">'.$instance['link_to_page_caption'].'</a></div>';
38
  }
39
  echo $after_widget;
40
  extract( $args );
@@ -54,9 +60,11 @@ class event_list_widget extends WP_Widget {
54
  $instance = array();
55
  $instance['title'] = strip_tags( $new_instance['title'] );
56
  $instance['num_events'] = strip_tags( $new_instance['num_events'] );
 
 
 
57
  $instance['link_to_event'] = (isset( $new_instance['link_to_event'] ) && 1==$new_instance['link_to_event'] ) ? 1 : 0;
58
  $instance['link_to_page'] = (isset( $new_instance['link_to_page'] ) && 1==$new_instance['link_to_page'] ) ? 1 : 0;
59
- $instance['link_to_page_url'] = strip_tags( $new_instance['link_to_page_url'] );
60
  $instance['link_to_page_caption'] = strip_tags( $new_instance['link_to_page_caption'] );
61
  return $instance;
62
  }
@@ -71,10 +79,13 @@ class event_list_widget extends WP_Widget {
71
  public function form( $instance ) {
72
  $title = isset( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' );
73
  $num_events = isset( $instance['num_events'] ) ? $instance['num_events'] : '3';
74
- $link_to_event = isset( $instance['link_to_event'] ) ? $instance['link_to_event'] : '1';
 
 
 
75
  $link_to_page = isset( $instance['link_to_page'] ) ? $instance['link_to_page'] : '';
76
- $link_to_page_url = isset( $instance['link_to_page_url'] ) ? $instance['link_to_page_url'] : '';
77
  $link_to_page_caption = isset( $instance['link_to_page_caption'] ) ? $instance['link_to_page_caption'] : __( 'show event-list page', 'text_domain' );
 
78
  $link_to_event_checked = 1==$link_to_event ? 'checked = "checked" ' : '';
79
  $link_to_page_checked = 1==$link_to_page ? 'checked = "checked" ' : '';
80
  $out = '
@@ -83,22 +94,29 @@ class event_list_widget extends WP_Widget {
83
  <input class="widefat" id="'.$this->get_field_id( 'title' ).'" name="'.$this->get_field_name( 'title' ).'" type="text" value="'.esc_attr( $title ).'" />
84
  </p>
85
  <p>
86
- <label for="'.$this->get_field_id( 'num_events' ).'">'.__( 'Number of events:' ).'</label>
87
- <input style="width:30px" class="widefat" id="'.$this->get_field_id( 'num_events' ).'" name="'.$this->get_field_name( 'num_events' ).'" type="text" value="'.esc_attr( $num_events ).'">
88
  </p>
89
  <p>
90
- <label><input class="widefat" id="'.$this->get_field_id( 'link_to_event' ).'" name="'.$this->get_field_name( 'link_to_event' ).'" type="checkbox" '.$link_to_event_checked.'value="1"> '.__( 'Add links to the single events' ).'</input></label>
 
 
 
 
91
  </p>
92
  <p>
93
- <label><input class="widefat" id="'.$this->get_field_id( 'link_to_page' ).'" name="'.$this->get_field_name( 'link_to_page' ).'" type="checkbox" '.$link_to_page_checked.'value="1"> '.__( 'Add a link to a page:' ).'</input></label>
94
- <p>
95
- <label for="'.$this->get_field_id( 'link_to_page_url' ).'">'.__( 'URL of the linked page:' ).'</label>
96
- <input class="widefat" id="'.$this->get_field_id( 'link_to_page_url' ).'" name="'.$this->get_field_name( 'link_to_page_url' ).'" type="text" value="'.esc_attr( $link_to_page_url ).'" />
97
- </p>
98
- <p>
99
- <label for="'.$this->get_field_id( 'link_to_page_caption' ).'">'.__( 'Caption for the link:' ).'</label>
100
- <input class="widefat" id="'.$this->get_field_id( 'link_to_page_caption' ).'" name="'.$this->get_field_name( 'link_to_page_caption' ).'" type="text" value="'.esc_attr( $link_to_page_caption ).'" />
101
- </p>
 
 
 
102
  </p>';
103
  echo $out;
104
  }
11
  parent::__construct(
12
  'event_list_widget', // Base ID
13
  'Event List', // Name
14
+ array( 'description' => __( 'This widget displays a list of upcoming events. If you want to enable a link to the events or to the event page you have to insert a link to the event-list page or post.', 'text_domain' ), ) // Args
15
  );
16
  }
17
 
32
  {
33
  echo $before_title . $title . $after_title;
34
  }
35
+ echo do_shortcode( '[event-list num_events="'.$instance['num_events'].'" '
36
+ .'show_nav=0 '
37
+ .'show_details=0 '
38
+ .'show_location='.$instance['show_location'].' '
39
+ .'link_to_event='.$instance['link_to_event'].' '
40
+ .'url_to_page="'.$instance['url_to_page'].'" '
41
+ .'sc_id_for_url="'.$instance['sc_id_for_url'].'"]' );
42
  if( 1 == $instance['link_to_page'] ) {
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 );
60
  $instance = array();
61
  $instance['title'] = strip_tags( $new_instance['title'] );
62
  $instance['num_events'] = strip_tags( $new_instance['num_events'] );
63
+ $instance['show_location'] = (isset( $new_instance['show_location'] ) && 1==$new_instance['show_location'] ) ? 1 : 0;
64
+ $instance['url_to_page'] = strip_tags( $new_instance['url_to_page'] );
65
+ $instance['sc_id_for_url'] = strip_tags( $new_instance['sc_id_for_url'] );
66
  $instance['link_to_event'] = (isset( $new_instance['link_to_event'] ) && 1==$new_instance['link_to_event'] ) ? 1 : 0;
67
  $instance['link_to_page'] = (isset( $new_instance['link_to_page'] ) && 1==$new_instance['link_to_page'] ) ? 1 : 0;
 
68
  $instance['link_to_page_caption'] = strip_tags( $new_instance['link_to_page_caption'] );
69
  return $instance;
70
  }
79
  public function form( $instance ) {
80
  $title = isset( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' );
81
  $num_events = isset( $instance['num_events'] ) ? $instance['num_events'] : '3';
82
+ $show_location = isset( $instance['show_location'] ) ? $instance['show_location'] : '';
83
+ $url_to_page = isset( $instance['url_to_page'] ) ? $instance['url_to_page'] : '';
84
+ $sc_id_for_url = isset( $instance['sc_id_for_url'] ) ? $instance['sc_id_for_url'] : '1';
85
+ $link_to_event = isset( $instance['link_to_event'] ) ? $instance['link_to_event'] : '';
86
  $link_to_page = isset( $instance['link_to_page'] ) ? $instance['link_to_page'] : '';
 
87
  $link_to_page_caption = isset( $instance['link_to_page_caption'] ) ? $instance['link_to_page_caption'] : __( 'show event-list page', 'text_domain' );
88
+ $show_location_checked = 1==$show_location ? 'checked = "checked" ' : '';
89
  $link_to_event_checked = 1==$link_to_event ? 'checked = "checked" ' : '';
90
  $link_to_page_checked = 1==$link_to_page ? 'checked = "checked" ' : '';
91
  $out = '
94
  <input class="widefat" id="'.$this->get_field_id( 'title' ).'" name="'.$this->get_field_name( 'title' ).'" type="text" value="'.esc_attr( $title ).'" />
95
  </p>
96
  <p>
97
+ <label for="'.$this->get_field_id( 'num_events' ).'">'.__( 'Number of upcoming events:' ).'</label>
98
+ <input style="width:30px" class="widefat" id="'.$this->get_field_id( 'num_events' ).'" name="'.$this->get_field_name( 'num_events' ).'" type="text" value="'.esc_attr( $num_events ).'" />
99
  </p>
100
  <p>
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>
108
+ <label for="'.$this->get_field_id( 'sc_id_for_url' ).'">'.__( 'Shortcode ID on linked page:' ).'</label>
109
+ <input style="width:30px;" class="widefat" id="'.$this->get_field_id( 'sc_id_for_url' ).'" name="'.$this->get_field_name( 'sc_id_for_url' ).'" type="text" value="'.esc_attr( $sc_id_for_url ).'" />
110
+ </p>
111
+ <p style="margin-left:0.8em">
112
+ <label><input class="widefat" id="'.$this->get_field_id( 'link_to_event' ).'" name="'.$this->get_field_name( 'link_to_event' ).'" type="checkbox" '.$link_to_event_checked.'value="1" /> '.__( 'Add links to the single events' ).'</label>
113
+ </p>
114
+ <p style="margin:0 0 0.2em 0.8em">
115
+ <label><input class="widefat" id="'.$this->get_field_id( 'link_to_page' ).'" name="'.$this->get_field_name( 'link_to_page' ).'" type="checkbox" '.$link_to_page_checked.'value="1" /> '.__( 'Add a link to an event page' ).'</label>
116
+ </p>
117
+ <p style="margin:0 0 1em 2.5em">
118
+ <label for="'.$this->get_field_id( 'link_to_page_caption' ).'">'.__( 'Caption for the link:' ).'</label>
119
+ <input class="widefat" id="'.$this->get_field_id( 'link_to_page_caption' ).'" name="'.$this->get_field_name( 'link_to_page_caption' ).'" type="text" value="'.esc_attr( $link_to_page_caption ).'" />
120
  </p>';
121
  echo $out;
122
  }
php/sc_event-list.php CHANGED
@@ -7,6 +7,7 @@ class sc_event_list {
7
  private $db;
8
  private $options;
9
  private $atts;
 
10
 
11
  public static function &get_instance() {
12
  // Create class instance if required
@@ -19,83 +20,125 @@ class sc_event_list {
19
 
20
  private function __construct() {
21
  $this->db = el_db::get_instance();
22
- //$this->options = &lv_options::get_instance();
23
 
24
  // All available attributes
25
  $this->atts = array(
26
 
27
  'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2012"',
28
  'std_val' => 'upcoming',
 
29
  'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
30
  Specify a year e.g. "2012" to change this behavior.' ),
31
 
32
  'num_events' => array( 'val' => 'number',
33
  'std_val' => '0',
 
34
  'desc' => 'This attribute specifies how many events should be displayed if upcoming events is selected.<br />
35
  0 is the standard value which means that all events will be displayed.' ),
36
 
37
  'show_nav' => array( 'val' => '0..false<br />1..true',
38
  'std_val' => '1',
 
39
  'desc' => 'This attribute specifies if the calendar navigation should be displayed.'),
40
 
41
  'show_details' => array( 'val' => '0..false<br />1..true',
42
  'std_val' => '1',
 
43
  'desc' => 'This attribute specifies if the details are displayed in the event list.'),
44
 
45
  'show_location' => array( 'val' => '0..false<br />1..true',
46
  'std_val' => '1',
 
47
  'desc' => 'This attribute specifies if the location is displayed in the event list.'),
48
 
49
  'link_to_event' => array( 'val' => '0..false<br />1..true',
50
  'std_val' => '1',
51
- 'desc' => 'This attribute specifies if a link to the single event should be added onto the event name in the event list.')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  );
 
 
53
  }
54
 
55
- public function get_atts() {
56
- return $this->atts;
 
 
 
 
 
 
 
 
 
 
 
57
  }
58
 
59
  // main function to show the rendered HTML output
60
  public function show_html( $atts ) {
61
- // check attributes
 
 
62
  $std_values = array();
63
  foreach( $this->atts as $aname => $attribute ) {
64
  $std_values[$aname] = $attribute['std_val'];
65
  }
66
  $a = shortcode_atts( $std_values, $atts );
 
 
 
 
 
 
 
 
67
 
68
- if( isset( $_GET['event_id'] ) ) {
69
- $out = $this->html_event_details( $_GET['event_id'] );
 
70
  }
71
  else {
 
72
  $out = $this->html_events( $a );
73
  }
74
  return $out;
75
  }
76
 
77
- private function html_event_details( $event_id ) {
78
- $event = $this->db->get_event( $event_id );
79
- $out = $this->html_calendar_nav();
80
  $out .= '
81
  <h2>Event Information:</h2>
82
  <ul class="event-list">';
83
- $out .= $this->html_event( $event );
84
  $out .= '</ul>';
85
  return $out;
86
  }
87
 
88
- private function html_events( $a ) {
89
- // specify visible events
90
- if( isset( $_GET['ytd'] ) ) {
91
- $events = $this->db->get_events( $_GET['ytd'] );
92
- }
93
- elseif( 'upcoming' !== $a['initial_date'] ) {
94
- $events = $this->db->get_events( $a['initial_date'] );
95
- }
96
- else {
97
- $events = $this->db->get_events( 'upcoming', $a['num_events'] );
98
  }
 
99
  $out = '';
100
  // TODO: add rss feed
101
  // if ($mfgigcal_settings['rss']) {
@@ -105,12 +148,11 @@ class sc_event_list {
105
 
106
  // generate output
107
  if( 0 != $a['show_nav'] ) {
108
- $out .= $this->html_calendar_nav();
109
  }
110
  // TODO: Setting missing
111
  if( empty( $events ) /*&& $mfgigcal_settings['no-events'] == "text"*/ ) {
112
  $out .= "<p>" . 'no event' /*$mfgigcal_settings['message'] */. "</p>";
113
- return $out;
114
  }
115
  /* else if (empty($events)) {
116
  $this_year = date("Y");
@@ -124,29 +166,19 @@ class sc_event_list {
124
  }
125
  */
126
  else {
127
- $url = get_permalink();
128
- if( !get_option( 'permalink_structure' ) ) {
129
- foreach( $_GET as $k => $v ) {
130
- if( 'ytd' !== $k && 'event_id' !== $k ) {
131
- $url .= $k.'='.$v.'&amp;';
132
- }
133
- }
134
- }
135
-
136
  // set html code
137
  $out .= '
138
  <ul class="event-list">';
139
  $single_day_only = $this->is_single_day_only( $events );
140
  foreach ($events as $event) {
141
- $out .= $this->html_event( $event, $a, $url, $single_day_only );
142
  }
143
  $out .= '</ul>';
144
- return $out;
145
  }
146
  return $out;
147
  }
148
 
149
- private function html_event( $event, $a=null, $url=null, $single_day_only=false ) {
150
  $out = '
151
  <li class="event">';
152
  $out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
@@ -159,8 +191,8 @@ class sc_event_list {
159
  $out .= ' multi-day';
160
  }
161
  $out .= '"><h3>';
162
- if( null !== $url && ( null !== $a && 0 != $a['link_to_event'] ) ) {
163
- $out .= '<a href="'.$url.'event_id='.$event->id.'">'.$event->title.'</a>';
164
  }
165
  else {
166
  $out .= $event->title;
@@ -217,41 +249,73 @@ class sc_event_list {
217
  return $out;
218
  }
219
 
220
- private function html_calendar_nav() {
221
  $first_year = $this->db->get_event_date( 'first' );
222
  $last_year = $this->db->get_event_date( 'last' );
223
 
224
- $url = get_permalink();
225
- if( !get_option( 'permalink_structure' ) ) {
226
- foreach( $_GET as $k => $v ) {
227
- if( 'ytd' !== $k && 'event_id' !== $k ) {
228
- $url .= $k.'='.$v.'&amp;';
229
- }
230
- }
231
- }
232
- else {
233
- $url .= '?';
234
- }
235
  $out = '<div class="subsubsub">';
236
- if( isset( $_GET['ytd'] ) || isset( $_GET['event_id'] ) ) {
237
- $out .= '<a href="'.$url.'">Upcoming</a>';
 
238
  }
239
  else {
240
  $out .= '<strong>Upcoming</strong>';
241
  }
242
  for( $year=$last_year; $year>=$first_year; $year-- ) {
243
  $out .= ' | ';
244
- if( isset( $_GET['ytd'] ) && $year == $_GET['ytd'] ) {
245
  $out .= '<strong>'.$year.'</strong>';
246
  }
247
  else {
248
- $out .= '<a href="'.$url.'ytd='.$year.'">'.$year.'</a>';
249
  }
250
  }
251
  $out .= '</div><br />';
252
  return $out;
253
  }
254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
  private function is_single_day_only( &$events ) {
256
  foreach( $events as $event ) {
257
  if( $event->start_date !== $event->end_date ) {
7
  private $db;
8
  private $options;
9
  private $atts;
10
+ private $num_sc_loaded;
11
 
12
  public static function &get_instance() {
13
  // Create class instance if required
20
 
21
  private function __construct() {
22
  $this->db = el_db::get_instance();
23
+ //$this->options = &el_options::get_instance();
24
 
25
  // All available attributes
26
  $this->atts = array(
27
 
28
  'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2012"',
29
  'std_val' => 'upcoming',
30
+ 'visible' => true,
31
  'desc' => 'This attribute specifies which events are initially shown. The standard is to show the upcoming events.<br />
32
  Specify a year e.g. "2012" to change this behavior.' ),
33
 
34
  'num_events' => array( 'val' => 'number',
35
  'std_val' => '0',
36
+ 'visible' => true,
37
  'desc' => 'This attribute specifies how many events should be displayed if upcoming events is selected.<br />
38
  0 is the standard value which means that all events will be displayed.' ),
39
 
40
  'show_nav' => array( 'val' => '0..false<br />1..true',
41
  'std_val' => '1',
42
+ 'visible' => true,
43
  'desc' => 'This attribute specifies if the calendar navigation should be displayed.'),
44
 
45
  'show_details' => array( 'val' => '0..false<br />1..true',
46
  'std_val' => '1',
47
+ 'visible' => true,
48
  'desc' => 'This attribute specifies if the details are displayed in the event list.'),
49
 
50
  'show_location' => array( 'val' => '0..false<br />1..true',
51
  'std_val' => '1',
52
+ 'visible' => true,
53
  'desc' => 'This attribute specifies if the location is displayed in the event list.'),
54
 
55
  'link_to_event' => array( 'val' => '0..false<br />1..true',
56
  'std_val' => '1',
57
+ 'visible' => true,
58
+ 'desc' => 'This attribute specifies if a link to the single event should be added onto the event name in the event list.'),
59
+ // Invisible attributes ('visibe' = false): This attributes are required for the widget but will not be listed in the attributes table on the admin info page
60
+ 'url_to_page' => array( 'val' => 'url',
61
+ 'std_val' => '',
62
+ 'visible' => false,
63
+ 'desc' => 'This attribute specifies that the link should follow the given url.<br />
64
+ The standard is to leave this attribute empty, then the url will be calculated automatically from the actual page or post url.<br />
65
+ This is o.k. for the normal use of the shortcode. This attribute is normally only required for the event-list widget.' ),
66
+
67
+ 'sc_id_for_url' => array( 'val' => 'number',
68
+ 'std_val' => '',
69
+ 'visible' => false,
70
+ 'desc' => 'This attribute the specifies shortcode id of the used shortcode on the page specified with "url_to_page" attribute.<br />
71
+ The empty standard value is o.k. for the normal use. This attribute is normally only required for the event-list widget.' )
72
+ // Internal attributes: This parameters will be added by the script and are not available in the shortcode
73
+ // 'sc_id'
74
+ // 'ytd'
75
  );
76
+
77
+ $this->num_sc_loaded = 0;
78
  }
79
 
80
+ public function get_atts( $only_visible=true ) {
81
+ if( $only_visible ) {
82
+ $atts = null;
83
+ foreach( $this->atts as $aname => $attr ) {
84
+ if( true === $attr['visible'] ) {
85
+ $atts[$aname] = $attr;
86
+ }
87
+ }
88
+ return $atts;
89
+ }
90
+ else {
91
+ return $this->atts;
92
+ }
93
  }
94
 
95
  // main function to show the rendered HTML output
96
  public function show_html( $atts ) {
97
+ // change number of shortcodes
98
+ $this->num_sc_loaded++;
99
+ // check shortcode attributes
100
  $std_values = array();
101
  foreach( $this->atts as $aname => $attribute ) {
102
  $std_values[$aname] = $attribute['std_val'];
103
  }
104
  $a = shortcode_atts( $std_values, $atts );
105
+ // add internal attributes
106
+ $a['sc_id'] = $this->num_sc_loaded;
107
+ $a['event_id'] = isset( $_GET['event_id_'.$a['sc_id']] ) ? (integer)$_GET['event_id_'.$a['sc_id']] : null;
108
+ $a['ytd'] = $this->get_ytd( $a );
109
+ // fix sc_id_for_url if required
110
+ if( !is_numeric( $a['sc_id_for_url'] ) ) {
111
+ $a['sc_id_for_url'] = $a['sc_id'];
112
+ }
113
 
114
+ if( is_numeric( $a['event_id'] ) ) {
115
+ // show events details if event_id is set
116
+ $out = $this->html_event_details( $a );
117
  }
118
  else {
119
+ // show full event list
120
  $out = $this->html_events( $a );
121
  }
122
  return $out;
123
  }
124
 
125
+ private function html_event_details( &$a ) {
126
+ $event = $this->db->get_event( $a['event_id'] );
127
+ $out = $this->html_calendar_nav( $a );
128
  $out .= '
129
  <h2>Event Information:</h2>
130
  <ul class="event-list">';
131
+ $out .= $this->html_event( $event, $a );
132
  $out .= '</ul>';
133
  return $out;
134
  }
135
 
136
+ private function html_events( &$a ) {
137
+ // specify to show all events if not upcoming is selected
138
+ if( is_numeric( $a['ytd'] ) ) {
139
+ $a['num_events'] = 0;
 
 
 
 
 
 
140
  }
141
+ $events = $this->db->get_events( $a['ytd'], $a['num_events'] );
142
  $out = '';
143
  // TODO: add rss feed
144
  // if ($mfgigcal_settings['rss']) {
148
 
149
  // generate output
150
  if( 0 != $a['show_nav'] ) {
151
+ $out .= $this->html_calendar_nav( $a );
152
  }
153
  // TODO: Setting missing
154
  if( empty( $events ) /*&& $mfgigcal_settings['no-events'] == "text"*/ ) {
155
  $out .= "<p>" . 'no event' /*$mfgigcal_settings['message'] */. "</p>";
 
156
  }
157
  /* else if (empty($events)) {
158
  $this_year = date("Y");
166
  }
167
  */
168
  else {
 
 
 
 
 
 
 
 
 
169
  // set html code
170
  $out .= '
171
  <ul class="event-list">';
172
  $single_day_only = $this->is_single_day_only( $events );
173
  foreach ($events as $event) {
174
+ $out .= $this->html_event( $event, $a, $this->get_url( $a ), $single_day_only );
175
  }
176
  $out .= '</ul>';
 
177
  }
178
  return $out;
179
  }
180
 
181
+ private function html_event( &$event, &$a, $url=null, $single_day_only=false ) {
182
  $out = '
183
  <li class="event">';
184
  $out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
191
  $out .= ' multi-day';
192
  }
193
  $out .= '"><h3>';
194
+ if( null !== $url && 0 != $a['link_to_event'] ) {
195
+ $out .= '<a href="'.$url.'event_id_'.$a['sc_id_for_url'].'='.$event->id.'">'.$event->title.'</a>';
196
  }
197
  else {
198
  $out .= $event->title;
249
  return $out;
250
  }
251
 
252
+ private function html_calendar_nav( &$a ) {
253
  $first_year = $this->db->get_event_date( 'first' );
254
  $last_year = $this->db->get_event_date( 'last' );
255
 
256
+ $url = $this->get_url( $a );
 
 
 
 
 
 
 
 
 
 
257
  $out = '<div class="subsubsub">';
258
+ if( is_numeric( $a['ytd'] ) || is_numeric( $a['event_id'] ) ) {
259
+ $ytd = isset( $a['initial_date'] ) && is_numeric( $a['initial_date'] ) ? 'ytd_'.$a['sc_id_for_url'].'=upcoming' : '';
260
+ $out .= '<a href="'.$url.'ytd_'.$a['sc_id_for_url'].'=upcoming">Upcoming</a>';
261
  }
262
  else {
263
  $out .= '<strong>Upcoming</strong>';
264
  }
265
  for( $year=$last_year; $year>=$first_year; $year-- ) {
266
  $out .= ' | ';
267
+ if( $year == $a['ytd'] ) {
268
  $out .= '<strong>'.$year.'</strong>';
269
  }
270
  else {
271
+ $out .= '<a href="'.$url.'ytd_'.$a['sc_id_for_url'].'='.$year.'">'.$year.'</a>';
272
  }
273
  }
274
  $out .= '</div><br />';
275
  return $out;
276
  }
277
 
278
+ private function get_ytd( &$a ) {
279
+ if( isset( $_GET['ytd_'.$a['sc_id']] ) && 'upcoming' === $_GET['ytd_'.$a['sc_id']] ){
280
+ // ytd is 'upcoming'
281
+ $ytd = 'upcoming';
282
+ }
283
+ elseif( isset( $_GET['ytd_'.$a['sc_id']] ) && is_numeric( $_GET['ytd_'.$a['sc_id']] ) ) {
284
+ // ytd is a year
285
+ $ytd = (int)$_GET['ytd_'.$a['sc_id']];
286
+ }
287
+ elseif( isset( $a['initial_date'] ) && is_numeric( $a['initial_date'] ) && !is_numeric( $a['event_id'] ) && !isset( $_GET['link_'.$a['sc_id']] ) ) {
288
+ // initial_date attribute is set
289
+ $ytd = (int)$a['initial_date'];
290
+ }
291
+ else {
292
+ $ytd = 'upcoming';
293
+ }
294
+ return $ytd;
295
+ }
296
+
297
+ private function get_url( &$a ) {
298
+ if( '' !== $a['url_to_page'] ) {
299
+ // use given url
300
+ $url = $a['url_to_page'];
301
+ $url .= get_option( 'permalink_structure' ) ? '?' : '&amp;';
302
+ }
303
+ elseif( get_option( 'permalink_structure' ) ) {
304
+ // permalink structure
305
+ $url = get_permalink().'?';
306
+ }
307
+ else {
308
+ // no permalink structure
309
+ $url ='?';
310
+ foreach( $_GET as $k => $v ) {
311
+ if( 'ytd_'.$a['sc_id'] !== $k && 'event_id_'.$a['sc_id'] !== $k && 'link_'.$a['sc_id'] !== $k ) {
312
+ $url .= $k.'='.$v.'&amp;';
313
+ }
314
+ }
315
+ }
316
+ return $url;
317
+ }
318
+
319
  private function is_single_day_only( &$events ) {
320
  foreach( $events as $event ) {
321
  if( $event->start_date !== $event->end_date ) {
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
7
- Stable tag: 0.3.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
@@ -60,6 +60,16 @@ Event List uses the built-in Wordpress WYSIWYG editor. It's exactly the same pro
60
 
61
  == Changelog ==
62
 
 
 
 
 
 
 
 
 
 
 
63
  = 0.3.0 (2012-12-31) =
64
 
65
  * added a widget to show upcoming events in a sidebar
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.3.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
60
 
61
  == Changelog ==
62
 
63
+ = 0.3.1 (2013-01-03) =
64
+
65
+ * added widget option "show_location"
66
+ * fixed wrong url for single event page link
67
+ * fixed issue with different shortcodes on one page or post
68
+ * changed required prevelegs for admin about page
69
+ * updated help messages on admin about page
70
+ * small style changes on frontpage
71
+
72
+
73
  = 0.3.0 (2012-12-31) =
74
 
75
  * added a widget to show upcoming events in a sidebar
screenshot-3.png CHANGED
Binary file
screenshot-4.png CHANGED
Binary file