Version Description
(2013-03-16) =
- fixed deleting of events
- removed link to not available settings page in about page
- changed parameter values from numbers to a more significant wording
- added the options 'event_list_only' and 'single_event_only' for the shortcode attributes 'show_nav', 'show_location', 'show_details' and 'link_to_event'
- added shortcode attribute details_length to truncate details
Download this release
Release Info
Developer | mibuthu |
Plugin | Event List |
Version | 0.3.4 |
Comparing to | |
See all releases |
Code changes from version 0.3.3 to 0.3.4
- event-list.php +1 -1
- php/admin.php +5 -5
- php/admin_event_table.php +1 -72
- php/db.php +80 -2
- php/event-list_widget.php +12 -12
- php/sc_event-list.php +103 -60
- readme.txt +9 -1
- screenshot-3.png +0 -0
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.
|
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.4
|
7 |
Author: Michael Burtscher
|
8 |
Author URI: http://wordpress.org/extend/plugins/event-list/
|
9 |
License: GPLv2
|
php/admin.php
CHANGED
@@ -59,7 +59,7 @@ class el_admin {
|
|
59 |
}
|
60 |
// delete events if required
|
61 |
if( $action === 'delete' && isset( $_GET['id'] ) ) {
|
62 |
-
$this->event_action_error = !$this->db->delete_events( $_GET['id'] );
|
63 |
$this->event_action = 'deleted';
|
64 |
}
|
65 |
// automatically set order of table to date, if no manual sorting is set
|
@@ -184,9 +184,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 |
-
|
189 |
-
|
190 |
$out .= $this->html_atts();
|
191 |
echo $out;
|
192 |
}
|
@@ -457,7 +457,7 @@ class el_admin {
|
|
457 |
<div>
|
458 |
You have the possibility to modify the output if you add some of the following attributes to the shortcode.<br />
|
459 |
You can combine as much attributes as you want. E.g.the shortcode including the attributes "num_events" and "show_nav" would looks like this:
|
460 |
-
<p><code>[event-list num_events=10 show_nav=
|
461 |
<p>Below you can find a list of all supported attributes with their descriptions and available options:</p>';
|
462 |
$out .= $this->html_atts_table();
|
463 |
$out .= '
|
59 |
}
|
60 |
// delete events if required
|
61 |
if( $action === 'delete' && isset( $_GET['id'] ) ) {
|
62 |
+
$this->event_action_error = !$this->db->delete_events( explode(',', $_GET['id'] ) );
|
63 |
$this->event_action = 'deleted';
|
64 |
}
|
65 |
// automatically set order of table to date, if no manual sorting is set
|
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 |
}
|
457 |
<div>
|
458 |
You have the possibility to modify the output if you add some of the following attributes to the shortcode.<br />
|
459 |
You can combine as much attributes as you want. E.g.the shortcode including the attributes "num_events" and "show_nav" would looks like this:
|
460 |
+
<p><code>[event-list num_events=10 show_nav=false]</code></p>
|
461 |
<p>Below you can find a list of all supported attributes with their descriptions and available options:</p>';
|
462 |
$out .= $this->html_atts_table();
|
463 |
$out .= '
|
php/admin_event_table.php
CHANGED
@@ -32,7 +32,7 @@ class Admin_Event_Table extends WP_List_Table {
|
|
32 |
case 'date' :
|
33 |
return $this->format_event_date( $item->start_date, $item->end_date, $item->time );
|
34 |
case 'details' :
|
35 |
-
return '<div>'.$this->truncate( 80, $item->details ).'</div>';
|
36 |
case 'pub_user' :
|
37 |
return get_userdata( $item->pub_user )->user_login;
|
38 |
case 'pub_date' :
|
@@ -263,76 +263,5 @@ class Admin_Event_Table extends WP_List_Table {
|
|
263 |
$datetime = mysql2date( __( 'Y/m/d g:i:s A' ), $pub_date );
|
264 |
return '<abbr title="'.$datetime.'">'.$date.'</abbr>';
|
265 |
}
|
266 |
-
|
267 |
-
// function to truncate and shorten html text
|
268 |
-
/** ************************************************************************
|
269 |
-
* Function to truncate and shorten text
|
270 |
-
*
|
271 |
-
* @param int $max_length The length to which the text should be shortened
|
272 |
-
* @param string $html The html code which should be shortened
|
273 |
-
***************************************************************************/
|
274 |
-
private static function truncate( $max_length, $html ) {
|
275 |
-
if( strlen( $html ) > $max_length ) {
|
276 |
-
$printedLength = 0;
|
277 |
-
$position = 0;
|
278 |
-
$tags = array();
|
279 |
-
$out = '';
|
280 |
-
while ($printedLength < $max_length && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
|
281 |
-
list($tag, $tagPosition) = $match[0];
|
282 |
-
// Print text leading up to the tag
|
283 |
-
$str = substr($html, $position, $tagPosition - $position);
|
284 |
-
if ($printedLength + strlen($str) > $max_length) {
|
285 |
-
$out .= substr($str, 0, $max_length - $printedLength);
|
286 |
-
$printedLength = $max_length;
|
287 |
-
break;
|
288 |
-
}
|
289 |
-
$out .= $str;
|
290 |
-
$printedLength += strlen($str);
|
291 |
-
if ($tag[0] == '&') {
|
292 |
-
// Handle the entity
|
293 |
-
$out .= $tag;
|
294 |
-
$printedLength++;
|
295 |
-
}
|
296 |
-
else {
|
297 |
-
// Handle the tag
|
298 |
-
$tagName = $match[1][0];
|
299 |
-
if ($tag[1] == '/')
|
300 |
-
{
|
301 |
-
// This is a closing tag
|
302 |
-
$openingTag = array_pop($tags);
|
303 |
-
assert($openingTag == $tagName); // check that tags are properly nested
|
304 |
-
$out .= $tag;
|
305 |
-
}
|
306 |
-
else if ($tag[strlen($tag) - 2] == '/') {
|
307 |
-
// Self-closing tag
|
308 |
-
$out .= $tag;
|
309 |
-
}
|
310 |
-
else {
|
311 |
-
// Opening tag
|
312 |
-
$out .= $tag;
|
313 |
-
$tags[] = $tagName;
|
314 |
-
}
|
315 |
-
}
|
316 |
-
// Continue after the tag
|
317 |
-
$position = $tagPosition + strlen($tag);
|
318 |
-
}
|
319 |
-
// Print any remaining text
|
320 |
-
if ($printedLength < $max_length && $position < strlen($html)) {
|
321 |
-
$out .= substr($html, $position, $max_length - $printedLength);
|
322 |
-
}
|
323 |
-
// Print "..." if the html is not complete
|
324 |
-
if( strlen( $html) != $position ) {
|
325 |
-
$out .= ' ...';
|
326 |
-
}
|
327 |
-
// Close any open tags.
|
328 |
-
while (!empty($tags)) {
|
329 |
-
$out .= '</'.array_pop($tags).'>';
|
330 |
-
}
|
331 |
-
return $out;
|
332 |
-
}
|
333 |
-
else {
|
334 |
-
return $html;
|
335 |
-
}
|
336 |
-
}
|
337 |
}
|
338 |
|
32 |
case 'date' :
|
33 |
return $this->format_event_date( $item->start_date, $item->end_date, $item->time );
|
34 |
case 'details' :
|
35 |
+
return '<div>'.$this->db->truncate( 80, $item->details ).'</div>';
|
36 |
case 'pub_user' :
|
37 |
return get_userdata( $item->pub_user )->user_login;
|
38 |
case 'pub_date' :
|
263 |
$datetime = mysql2date( __( 'Y/m/d g:i:s A' ), $pub_date );
|
264 |
return '<abbr title="'.$datetime.'">'.$date.'</abbr>';
|
265 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
}
|
267 |
|
php/db.php
CHANGED
@@ -153,9 +153,16 @@ class el_db {
|
|
153 |
|
154 |
public function delete_events( $event_ids ) {
|
155 |
global $wpdb;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
// sql query
|
157 |
-
$num_deleted = (int) $wpdb->query(
|
158 |
-
if( $num_deleted == count(
|
159 |
return true;
|
160 |
}
|
161 |
else {
|
@@ -185,8 +192,79 @@ class el_db {
|
|
185 |
}
|
186 |
return date( $ret_format, $timestamp );
|
187 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
}
|
189 |
|
|
|
190 |
// Define "date_parse_from_format" (This is required for php versions < 5.3)
|
191 |
if( !function_exists('date_parse_from_format') ){
|
192 |
function date_parse_from_format($format, $date) {
|
153 |
|
154 |
public function delete_events( $event_ids ) {
|
155 |
global $wpdb;
|
156 |
+
// filter event_ids string to int values only
|
157 |
+
$filtered_ids = array_map( 'intval', $event_ids );
|
158 |
+
if( count( $event_ids ) != count( $filtered_ids ) )
|
159 |
+
{
|
160 |
+
// something is wrong with the event_ids array
|
161 |
+
return false;
|
162 |
+
}
|
163 |
// sql query
|
164 |
+
$num_deleted = (int) $wpdb->query( 'DELETE FROM '.$this->table.' WHERE id IN ('.implode( ',', $filtered_ids ).')' );
|
165 |
+
if( $num_deleted == count( $event_ids ) ) {
|
166 |
return true;
|
167 |
}
|
168 |
else {
|
192 |
}
|
193 |
return date( $ret_format, $timestamp );
|
194 |
}
|
195 |
+
|
196 |
+
/** ************************************************************************
|
197 |
+
* Function to truncate and shorten text
|
198 |
+
*
|
199 |
+
* @param int $max_length The length to which the text should be shortened
|
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();
|
207 |
+
$out = '';
|
208 |
+
while ($printedLength < $max_length && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
|
209 |
+
list($tag, $tagPosition) = $match[0];
|
210 |
+
// Print text leading up to the tag
|
211 |
+
$str = substr($html, $position, $tagPosition - $position);
|
212 |
+
if ($printedLength + strlen($str) > $max_length) {
|
213 |
+
$out .= substr($str, 0, $max_length - $printedLength);
|
214 |
+
$printedLength = $max_length;
|
215 |
+
break;
|
216 |
+
}
|
217 |
+
$out .= $str;
|
218 |
+
$printedLength += strlen($str);
|
219 |
+
if ($tag[0] == '&') {
|
220 |
+
// Handle the entity
|
221 |
+
$out .= $tag;
|
222 |
+
$printedLength++;
|
223 |
+
}
|
224 |
+
else {
|
225 |
+
// Handle the tag
|
226 |
+
$tagName = $match[1][0];
|
227 |
+
if ($tag[1] == '/')
|
228 |
+
{
|
229 |
+
// This is a closing tag
|
230 |
+
$openingTag = array_pop($tags);
|
231 |
+
assert($openingTag == $tagName); // check that tags are properly nested
|
232 |
+
$out .= $tag;
|
233 |
+
}
|
234 |
+
else if ($tag[strlen($tag) - 2] == '/') {
|
235 |
+
// Self-closing tag
|
236 |
+
$out .= $tag;
|
237 |
+
}
|
238 |
+
else {
|
239 |
+
// Opening tag
|
240 |
+
$out .= $tag;
|
241 |
+
$tags[] = $tagName;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
// Continue after the tag
|
245 |
+
$position = $tagPosition + strlen($tag);
|
246 |
+
}
|
247 |
+
// Print any remaining text
|
248 |
+
if ($printedLength < $max_length && $position < strlen($html)) {
|
249 |
+
$out .= substr($html, $position, $max_length - $printedLength);
|
250 |
+
}
|
251 |
+
// Print "..." if the html is not complete
|
252 |
+
if( strlen( $html) != $position ) {
|
253 |
+
$out .= ' ...';
|
254 |
+
}
|
255 |
+
// Close any open tags.
|
256 |
+
while (!empty($tags)) {
|
257 |
+
$out .= '</'.array_pop($tags).'>';
|
258 |
+
}
|
259 |
+
return $out;
|
260 |
+
}
|
261 |
+
else {
|
262 |
+
return $html;
|
263 |
+
}
|
264 |
+
}
|
265 |
}
|
266 |
|
267 |
+
|
268 |
// Define "date_parse_from_format" (This is required for php versions < 5.3)
|
269 |
if( !function_exists('date_parse_from_format') ){
|
270 |
function date_parse_from_format($format, $date) {
|
php/event-list_widget.php
CHANGED
@@ -33,13 +33,13 @@ class event_list_widget extends WP_Widget {
|
|
33 |
echo $before_title . $title . $after_title;
|
34 |
}
|
35 |
echo do_shortcode( '[event-list num_events="'.$instance['num_events'].'" '
|
36 |
-
.'show_nav=
|
37 |
-
.'show_details=
|
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(
|
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;
|
@@ -60,11 +60,11 @@ class event_list_widget extends WP_Widget {
|
|
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'] ) ?
|
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'] ) ?
|
67 |
-
$instance['link_to_page'] = (isset( $new_instance['link_to_page'] ) && 1==$new_instance['link_to_page'] ) ?
|
68 |
$instance['link_to_page_caption'] = strip_tags( $new_instance['link_to_page_caption'] );
|
69 |
return $instance;
|
70 |
}
|
@@ -79,15 +79,15 @@ class event_list_widget extends WP_Widget {
|
|
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
|
91 |
$out = '
|
92 |
<p>
|
93 |
<label for="'.$this->get_field_id( 'title' ).'">'.__( 'Title:' ).'</label>
|
33 |
echo $before_title . $title . $after_title;
|
34 |
}
|
35 |
echo do_shortcode( '[event-list num_events="'.$instance['num_events'].'" '
|
36 |
+
.'show_nav=false '
|
37 |
+
.'show_details=false '
|
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( 'true' === $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;
|
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'] ) ? 'true' : 'false';
|
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'] ) ? 'true' : 'false';
|
67 |
+
$instance['link_to_page'] = (isset( $new_instance['link_to_page'] ) && 1==$new_instance['link_to_page'] ) ? 'true' : 'false';
|
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'] : 'false';
|
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'] : 'false';
|
86 |
+
$link_to_page = isset( $instance['link_to_page'] ) ? $instance['link_to_page'] : 'false';
|
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 = 'true'===$show_location || 1==$show_location ? 'checked = "checked" ' : '';
|
89 |
+
$link_to_event_checked = 'true'===$link_to_event || 1==$link_to_event ? 'checked = "checked" ' : '';
|
90 |
+
$link_to_page_checked = 'true'===$link_to_page || 1==$link_to_page ? 'checked = "checked" ' : '';
|
91 |
$out = '
|
92 |
<p>
|
93 |
<label for="'.$this->get_field_id( 'title' ).'">'.__( 'Title:' ).'</label>
|
php/sc_event-list.php
CHANGED
@@ -8,6 +8,7 @@ class sc_event_list {
|
|
8 |
private $options;
|
9 |
private $atts;
|
10 |
private $num_sc_loaded;
|
|
|
11 |
|
12 |
public static function &get_instance() {
|
13 |
// Create class instance if required
|
@@ -25,56 +26,72 @@ class sc_event_list {
|
|
25 |
// All available attributes
|
26 |
$this->atts = array(
|
27 |
|
28 |
-
'initial_date'
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
-
'num_events'
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
'show_nav'
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
44 |
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
|
50 |
-
'
|
51 |
-
|
52 |
-
|
53 |
-
|
|
|
|
|
54 |
|
55 |
-
'
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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'
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
|
67 |
-
'sc_id_for_url'
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
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 ) {
|
@@ -113,10 +130,12 @@ class sc_event_list {
|
|
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;
|
@@ -147,38 +166,26 @@ class sc_event_list {
|
|
147 |
// }
|
148 |
|
149 |
// generate output
|
150 |
-
|
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");
|
159 |
-
// show the current year
|
160 |
-
$sql = "SELECT * FROM $mfgigcal_table WHERE (end_date >= '$this_year-01-01' AND start_date <= '$this_year-12-31') ORDER BY start_date ASC";
|
161 |
-
$events = $wpdb->get_results($sql);
|
162 |
-
if (empty($events)) {
|
163 |
-
$out .= "<p>" . $mfgigcal_settings['message'] . "</p>";
|
164 |
-
return $out;
|
165 |
-
}
|
166 |
-
}
|
167 |
-
*/
|
168 |
else {
|
169 |
-
//
|
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, $
|
175 |
}
|
176 |
$out .= '</ul>';
|
177 |
}
|
178 |
return $out;
|
179 |
}
|
180 |
|
181 |
-
private function html_event( &$event, &$a, $
|
182 |
$out = '
|
183 |
<li class="event">';
|
184 |
$out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
|
@@ -191,8 +198,8 @@ class sc_event_list {
|
|
191 |
$out .= ' multi-day';
|
192 |
}
|
193 |
$out .= '"><h3>';
|
194 |
-
if(
|
195 |
-
$out .= '<a href="'.$
|
196 |
}
|
197 |
else {
|
198 |
$out .= $event->title;
|
@@ -206,11 +213,17 @@ class sc_event_list {
|
|
206 |
}
|
207 |
$out .= '<span class="event-time">'.$event->time.'</span>';
|
208 |
}
|
209 |
-
if(
|
210 |
$out .= '<span class="event-location">'.$event->location.'</span>';
|
211 |
}
|
212 |
-
if(
|
213 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
$out .= '</div>
|
216 |
</li>';
|
@@ -255,11 +268,16 @@ class sc_event_list {
|
|
255 |
}
|
256 |
|
257 |
private function html_calendar_nav( &$a ) {
|
|
|
|
|
|
|
|
|
|
|
258 |
$first_year = $this->db->get_event_date( 'first' );
|
259 |
$last_year = $this->db->get_event_date( 'last' );
|
260 |
|
261 |
$url = $this->get_url( $a );
|
262 |
-
$out
|
263 |
if( is_numeric( $a['ytd'] ) || is_numeric( $a['event_id'] ) ) {
|
264 |
$ytd = isset( $a['initial_date'] ) && is_numeric( $a['initial_date'] ) ? 'ytd_'.$a['sc_id_for_url'].'=upcoming' : '';
|
265 |
$out .= '<a href="'.$url.'ytd_'.$a['sc_id_for_url'].'=upcoming">Upcoming</a>';
|
@@ -329,5 +347,30 @@ class sc_event_list {
|
|
329 |
}
|
330 |
return true;
|
331 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
}
|
333 |
?>
|
8 |
private $options;
|
9 |
private $atts;
|
10 |
private $num_sc_loaded;
|
11 |
+
private $single_event;
|
12 |
|
13 |
public static function &get_instance() {
|
14 |
// Create class instance if required
|
26 |
// All available attributes
|
27 |
$this->atts = array(
|
28 |
|
29 |
+
'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2013"',
|
30 |
+
'std_val' => 'upcoming',
|
31 |
+
'visible' => true,
|
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,
|
38 |
+
'desc' => 'This attribute specifies how many events should be displayed if upcoming events is selected.<br />
|
39 |
+
0 is the standard value which means that all events will be displayed.' ),
|
40 |
|
41 |
+
'show_nav' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
|
42 |
+
'std_val' => 'true',
|
43 |
+
'visible' => true,
|
44 |
+
'desc' => 'This attribute specifies if the calendar navigation should be displayed.<br />
|
45 |
+
Choose "false" to always hide and "true" to always show the navigation.<br />
|
46 |
+
With "event_list_only" the navigation is only visible in the event list and with "single_event_only" only for a single event'),
|
47 |
|
48 |
+
'show_location' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
|
49 |
+
'std_val' => 'true',
|
50 |
+
'visible' => true,
|
51 |
+
'desc' => 'This attribute specifies if the location is displayed in the event list.<br />
|
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,
|
58 |
+
'desc' => 'This attribute specifies if the details are displayed in the event list.<br />
|
59 |
+
Choose "false" to always hide and "true" to always show the details.<br />
|
60 |
+
With "event_list_only" the details are only visible in the event list and with "single_event_only" only for a single event'),
|
61 |
|
62 |
+
'details_length' => array( 'val' => 'number',
|
63 |
+
'std_val' => '0',
|
64 |
+
'visible' => true,
|
65 |
+
'desc' => 'This attribute specifies if the details should be truncate to the given number of character in the event list.<br />
|
66 |
+
With the standard value 0 the full details are displayed.<br />
|
67 |
+
This attribute has no influence if only a single event is shown.'),
|
68 |
+
|
69 |
+
'link_to_event' => array( 'val' => 'false<br />true<br />event_list_only<br />single_event_only',
|
70 |
+
'std_val' => 'event_list_only',
|
71 |
+
'visible' => true,
|
72 |
+
'desc' => 'This attribute specifies if a link to the single event should be added onto the event name in the event list.<br />
|
73 |
+
Choose "false" to never add and "true" to always add the link.<br />
|
74 |
+
With "event_list_only" the link is only added in the event list and with "single_event_only" only for a single event'),
|
75 |
// 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
|
76 |
+
'url_to_page' => array( 'val' => 'url',
|
77 |
+
'std_val' => '',
|
78 |
+
'visible' => false,
|
79 |
+
'desc' => 'This attribute specifies that the link should follow the given url.<br />
|
80 |
+
The standard is to leave this attribute empty, then the url will be calculated automatically from the actual page or post url.<br />
|
81 |
+
This is o.k. for the normal use of the shortcode. This attribute is normally only required for the event-list widget.' ),
|
82 |
|
83 |
+
'sc_id_for_url' => array( 'val' => 'number',
|
84 |
+
'std_val' => '',
|
85 |
+
'visible' => false,
|
86 |
+
'desc' => 'This attribute the specifies shortcode id of the used shortcode on the page specified with "url_to_page" attribute.<br />
|
87 |
+
The empty standard value is o.k. for the normal use. This attribute is normally only required for the event-list widget.' )
|
88 |
// Internal attributes: This parameters will be added by the script and are not available in the shortcode
|
89 |
// 'sc_id'
|
90 |
// 'ytd'
|
91 |
);
|
92 |
|
93 |
$this->num_sc_loaded = 0;
|
94 |
+
$this->single_event = false;
|
95 |
}
|
96 |
|
97 |
public function get_atts( $only_visible=true ) {
|
130 |
|
131 |
if( is_numeric( $a['event_id'] ) ) {
|
132 |
// show events details if event_id is set
|
133 |
+
$this->single_event = true;
|
134 |
$out = $this->html_event_details( $a );
|
135 |
}
|
136 |
else {
|
137 |
// show full event list
|
138 |
+
$this->single_event = false;
|
139 |
$out = $this->html_events( $a );
|
140 |
}
|
141 |
return $out;
|
166 |
// }
|
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
|
177 |
$out .= '
|
178 |
<ul class="event-list">';
|
179 |
$single_day_only = $this->is_single_day_only( $events );
|
180 |
foreach ($events as $event) {
|
181 |
+
$out .= $this->html_event( $event, $a, $single_day_only );
|
182 |
}
|
183 |
$out .= '</ul>';
|
184 |
}
|
185 |
return $out;
|
186 |
}
|
187 |
|
188 |
+
private function html_event( &$event, &$a, $single_day_only=false ) {
|
189 |
$out = '
|
190 |
<li class="event">';
|
191 |
$out .= $this->html_fulldate( $event->start_date, $event->end_date, $single_day_only );
|
198 |
$out .= ' multi-day';
|
199 |
}
|
200 |
$out .= '"><h3>';
|
201 |
+
if( $this->is_visible( $a['link_to_event'] ) ) {
|
202 |
+
$out .= '<a href="'.$this->get_url( $a ).'event_id_'.$a['sc_id_for_url'].'='.$event->id.'">'.$event->title.'</a>';
|
203 |
}
|
204 |
else {
|
205 |
$out .= $event->title;
|
213 |
}
|
214 |
$out .= '<span class="event-time">'.$event->time.'</span>';
|
215 |
}
|
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;
|
222 |
+
}
|
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>';
|
268 |
}
|
269 |
|
270 |
private function html_calendar_nav( &$a ) {
|
271 |
+
$out = '';
|
272 |
+
if( ! $this->is_visible( $a['show_nav'] ) ) {
|
273 |
+
// no calendar navigation required
|
274 |
+
return $out;
|
275 |
+
}
|
276 |
$first_year = $this->db->get_event_date( 'first' );
|
277 |
$last_year = $this->db->get_event_date( 'last' );
|
278 |
|
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>';
|
347 |
}
|
348 |
return true;
|
349 |
}
|
350 |
+
|
351 |
+
private function is_visible( $attribute_value ) {
|
352 |
+
switch ($attribute_value) {
|
353 |
+
case 'false':
|
354 |
+
return false;
|
355 |
+
case '0': // = 'false'
|
356 |
+
return false;
|
357 |
+
case 'event_list_only':
|
358 |
+
if( $this->single_event ) {
|
359 |
+
return false;
|
360 |
+
}
|
361 |
+
else {
|
362 |
+
return true;
|
363 |
+
}
|
364 |
+
case 'single_event_only':
|
365 |
+
if( $this->single_event ) {
|
366 |
+
return true;
|
367 |
+
}
|
368 |
+
else {
|
369 |
+
return false;
|
370 |
+
}
|
371 |
+
default: // 'true' or 1
|
372 |
+
return true;
|
373 |
+
}
|
374 |
+
}
|
375 |
}
|
376 |
?>
|
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.
|
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
|
@@ -64,6 +64,14 @@ Yes, you can create an instance of the "sc_event_list" class which located in "p
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
= 0.3.3 (2013-03-01) =
|
68 |
|
69 |
* fixed event creation/modification problem with php versions < 5.3
|
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
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 0.3.4 (2013-03-16) =
|
68 |
+
|
69 |
+
* fixed deleting of events
|
70 |
+
* removed link to not available settings page in about page
|
71 |
+
* changed parameter values from numbers to a more significant wording
|
72 |
+
* added the options 'event_list_only' and 'single_event_only' for the shortcode attributes 'show_nav', 'show_location', 'show_details' and 'link_to_event'
|
73 |
+
* added shortcode attribute details_length to truncate details
|
74 |
+
|
75 |
= 0.3.3 (2013-03-01) =
|
76 |
|
77 |
* fixed event creation/modification problem with php versions < 5.3
|
screenshot-3.png
CHANGED
Binary file
|