Version Description
(2012-09-08) =
- Initial release
Download this release
Release Info
Developer | mibuthu |
Plugin | Event List |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- css/event-list.css +132 -0
- event-list.php +92 -0
- images/date-separator.png +0 -0
- js/admin.js +45 -0
- php/admin.php +453 -0
- php/db.php +188 -0
- php/sc_event-list.php +155 -0
- readme.txt +58 -0
css/event-list.css
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
===================
|
3 |
+
Event List Layout
|
4 |
+
===================
|
5 |
+
|
6 |
+
<ul id="cal">
|
7 |
+
|
8 |
+
<li class="event">
|
9 |
+
<div class="date">
|
10 |
+
|
11 |
+
<!-- ONLY OUTPUT FOR MULTI-DAY EVENTS -->
|
12 |
+
<div class="start-date">
|
13 |
+
<div class="weekday"></div>
|
14 |
+
<div class="day"></div>
|
15 |
+
<div class="month"></div>
|
16 |
+
<div class="year"></div>
|
17 |
+
</div>
|
18 |
+
<!-- ONLY OUTPUT FOR MULTI-DAY EVENTS -->
|
19 |
+
|
20 |
+
<div class="end-date">
|
21 |
+
<div class="weekday"></div>
|
22 |
+
<div class="day"></div>
|
23 |
+
<div class="month"></div>
|
24 |
+
<div class="year"></div>
|
25 |
+
</div>
|
26 |
+
</div>
|
27 |
+
<div class="info_block">
|
28 |
+
<h3>[Event Title]</h3>
|
29 |
+
<span class="time"></span>
|
30 |
+
[Event Location]
|
31 |
+
[Event Details]
|
32 |
+
</div>
|
33 |
+
</li>
|
34 |
+
|
35 |
+
</ul>
|
36 |
+
|
37 |
+
=======================================
|
38 |
+
*/
|
39 |
+
/*
|
40 |
+
a.rss-link {
|
41 |
+
display:block;
|
42 |
+
height:16px;
|
43 |
+
float:right;
|
44 |
+
background:transparent url(images/icon-rss.png) right top no-repeat;
|
45 |
+
padding-right:20px;
|
46 |
+
line-height:16px;
|
47 |
+
}
|
48 |
+
*/
|
49 |
+
#eventlist_nav {
|
50 |
+
font-size: 1.2em;
|
51 |
+
margin-bottom: 0.3em;
|
52 |
+
}
|
53 |
+
|
54 |
+
ul#eventlist {
|
55 |
+
list-style: none;
|
56 |
+
margin: 1em 0 1.5em 0;
|
57 |
+
padding: 0;
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
#eventlist li.event {
|
62 |
+
clear: both;
|
63 |
+
}
|
64 |
+
|
65 |
+
#eventlist .date {
|
66 |
+
white-space: nowrap;
|
67 |
+
float: left;
|
68 |
+
margin-bottom: 1.5em;
|
69 |
+
}
|
70 |
+
|
71 |
+
#eventlist .multi-date {
|
72 |
+
background: url(../images/date-separator.png) center no-repeat;
|
73 |
+
}
|
74 |
+
|
75 |
+
#eventlist .start-date, #eventlist .end-date {
|
76 |
+
text-align: center;
|
77 |
+
width: 3.2em;
|
78 |
+
border-radius: 5px;
|
79 |
+
background-color: rgb(220,220,220);
|
80 |
+
overflow: hidden;
|
81 |
+
}
|
82 |
+
|
83 |
+
#eventlist .start-date {
|
84 |
+
float: left;
|
85 |
+
}
|
86 |
+
|
87 |
+
#eventlist .end-date {
|
88 |
+
margin-left: 3.8em;
|
89 |
+
}
|
90 |
+
|
91 |
+
#eventlist .weekday {
|
92 |
+
font-size: 0.9em;
|
93 |
+
text-transform: uppercase;
|
94 |
+
}
|
95 |
+
|
96 |
+
#eventlist .day {
|
97 |
+
font-size: 1.3em;
|
98 |
+
font-weight: bold;
|
99 |
+
line-height: 1em;
|
100 |
+
margin-bottom: -0.2em;
|
101 |
+
}
|
102 |
+
|
103 |
+
#eventlist .month {
|
104 |
+
text-transform: uppercase;
|
105 |
+
font-size: 0.9em;
|
106 |
+
line-height: 1em;
|
107 |
+
padding: 0.4em 0 0.4em 0;
|
108 |
+
}
|
109 |
+
|
110 |
+
#eventlist .year {
|
111 |
+
font-size: 0.8em;
|
112 |
+
line-height: 0.8em;
|
113 |
+
letter-spacing: 0.1em;
|
114 |
+
padding-bottom: 0.3em;
|
115 |
+
}
|
116 |
+
|
117 |
+
#eventlist .info_block {
|
118 |
+
margin: 0 0 0 7.5em;
|
119 |
+
}
|
120 |
+
|
121 |
+
#eventlist .info_block h3 {
|
122 |
+
clear: none;
|
123 |
+
}
|
124 |
+
|
125 |
+
#eventlist .time {
|
126 |
+
font-weight: bold;
|
127 |
+
padding-right: 0.8em;
|
128 |
+
}
|
129 |
+
|
130 |
+
#eventlist .details {
|
131 |
+
font-size: 0.8em;
|
132 |
+
}
|
event-list.php
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
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.1.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 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
|
16 |
+
as published by the Free Software Foundation; either version 2
|
17 |
+
of the License, or (at your option) any later version.
|
18 |
+
|
19 |
+
This program is distributed in the hope that it will be useful,
|
20 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
21 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
22 |
+
GNU General Public License for more details.
|
23 |
+
|
24 |
+
You can view a copy of the HTML version of the GNU General Public
|
25 |
+
License at http://www.gnu.org/copyleft/gpl.html
|
26 |
+
*/
|
27 |
+
|
28 |
+
// general definitions
|
29 |
+
define( 'EL_URL', plugin_dir_url( __FILE__ ) );
|
30 |
+
define( 'EL_PATH', plugin_dir_path( __FILE__ ) );
|
31 |
+
|
32 |
+
|
33 |
+
// ADD HOOKS, ACTIONS AND SHORTCODES:
|
34 |
+
|
35 |
+
// FOR ADMIN AND FRONTPAGE:
|
36 |
+
// TODO: Check the following hooks
|
37 |
+
//register_activation_hook( 'php/db.php', array( 'el_db', 'upgrade_check' ) );
|
38 |
+
//register_activation_hook( 'php/options.php', array( 'el_options', 'upgrade' ) );
|
39 |
+
add_action( 'plugins_loaded', 'on_el_plugin_loaded' );
|
40 |
+
// TODO: Add widget
|
41 |
+
//add_action( 'widgets_init', 'on_el_widgets' );
|
42 |
+
|
43 |
+
// ADMIN PAGE:
|
44 |
+
if ( is_admin() ) {
|
45 |
+
add_action( 'admin_menu', 'on_el_admin' ); // add admin pages in admin menu
|
46 |
+
// add_action( 'admin_init', 'on_el_register_settings' ); // register settings
|
47 |
+
}
|
48 |
+
|
49 |
+
// FRONT PAGE:
|
50 |
+
else {
|
51 |
+
add_shortcode( 'event-list', 'on_el_sc_event_list' ); // add shortcode [event-list]
|
52 |
+
// Stylesheet for display
|
53 |
+
add_action('wp_print_styles', 'on_el_styles');
|
54 |
+
}
|
55 |
+
|
56 |
+
function on_el_plugin_loaded() {
|
57 |
+
require_once( 'php/db.php' );
|
58 |
+
el_db::update_check();
|
59 |
+
}
|
60 |
+
|
61 |
+
function on_el_admin() {
|
62 |
+
require_once( 'php/admin.php' );
|
63 |
+
$page = add_menu_page('Event List', 'Event List', 'edit_posts', 'el_admin_main', array( 'el_admin', 'show_main' ) );
|
64 |
+
add_action( 'admin_head-'.$page, array( 'el_admin', 'embed_admin_js' ) );
|
65 |
+
$page = add_submenu_page('el_admin_main', 'New Event', 'New Event', 'edit_posts', 'el_admin_new', array( 'el_admin', 'show_new' ) );
|
66 |
+
add_action( 'admin_head-'.$page, array( 'el_admin', 'embed_admin_js' ) );
|
67 |
+
add_submenu_page( 'el_admin_main', 'Event List Settings', 'Settings', 'manage_options', 'el_admin_settings', array( 'el_admin', 'show_settings' ) );
|
68 |
+
add_submenu_page( 'el_admin_main', 'About Event List', 'About', 'manage_options', 'el_admin_about', array( 'el_admin', 'show_about' ) );
|
69 |
+
}
|
70 |
+
/*
|
71 |
+
function on_el_register_settings() {
|
72 |
+
require_once( 'php/options.php' );
|
73 |
+
el_options::register();
|
74 |
+
}
|
75 |
+
*/
|
76 |
+
function on_el_sc_event_list( $atts ) {
|
77 |
+
require_once( 'php/sc_event-list.php' );
|
78 |
+
return sc_event_list::show_html( $atts );
|
79 |
+
}
|
80 |
+
|
81 |
+
function on_el_styles() {
|
82 |
+
wp_register_style('event-list_css', EL_URL.'css/event-list.css');
|
83 |
+
wp_enqueue_style( 'event-list_css');
|
84 |
+
}
|
85 |
+
|
86 |
+
/*
|
87 |
+
function on_el_widgets() {
|
88 |
+
require_once( 'php/event-list_widget.php' );
|
89 |
+
return register_widget( 'event_list_widget' );
|
90 |
+
}
|
91 |
+
*/
|
92 |
+
?>
|
images/date-separator.png
ADDED
Binary file
|
js/admin.js
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Date helpers
|
2 |
+
jQuery(document).ready(function( $ ) {
|
3 |
+
// $(".datepicker").datepick({
|
4 |
+
// dateFormat: 'yyyy-mm-dd',
|
5 |
+
// onSelect: function(dates) {
|
6 |
+
// if ($("#multi").is(':checked')) {
|
7 |
+
// check the end day is greater
|
8 |
+
// if ($("#start_date").val() > $("#end_date").val()) {
|
9 |
+
// $("#end_date").val($("#start_date").val());
|
10 |
+
// }
|
11 |
+
// }
|
12 |
+
// else {
|
13 |
+
// single day! make em match
|
14 |
+
// $("#end_date").val($("#start_date").val());
|
15 |
+
// }
|
16 |
+
// }
|
17 |
+
// });
|
18 |
+
|
19 |
+
if ($("#start_date").val() == $("#end_date").val()) {
|
20 |
+
$("#end_date_row").hide();
|
21 |
+
}
|
22 |
+
else {
|
23 |
+
$("#multi").attr('checked', true);
|
24 |
+
}
|
25 |
+
|
26 |
+
$("#multi").click(function() {
|
27 |
+
if (this.checked) {
|
28 |
+
$("#end_date").val($("#start_date").val());
|
29 |
+
$("#end_date_row").fadeIn();
|
30 |
+
}
|
31 |
+
else {
|
32 |
+
$("#end_date_row").fadeOut();
|
33 |
+
$("#end_date").val($("#start_date").val());
|
34 |
+
}
|
35 |
+
});
|
36 |
+
|
37 |
+
|
38 |
+
});
|
39 |
+
|
40 |
+
// Confirmation for event deletion
|
41 |
+
function eventlist_deleteEvent (id) {
|
42 |
+
if (confirm("Are you sure you want to delete this event from you the database? This is a permanent action.")) {
|
43 |
+
document.location.href = "?page=el_admin_main&id=" + id + "&action=delete";
|
44 |
+
}
|
45 |
+
}
|
php/admin.php
ADDED
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
//require_once( EL_PATH.'php/options.php' );
|
3 |
+
require_once( EL_PATH.'php/db.php' );
|
4 |
+
|
5 |
+
// This class handles all available admin pages
|
6 |
+
class el_admin {
|
7 |
+
|
8 |
+
// show the main admin page as a submenu of "Comments"
|
9 |
+
public static function show_main() {
|
10 |
+
if ( !current_user_can( 'edit_posts' ) ) {
|
11 |
+
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
12 |
+
}
|
13 |
+
|
14 |
+
$out ='
|
15 |
+
<div class="wrap nosubsub" style="padding-bottom:15px">
|
16 |
+
<div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List</h2>
|
17 |
+
</div>';
|
18 |
+
|
19 |
+
// is there POST data to deal with?
|
20 |
+
if ($_POST) {
|
21 |
+
el_db::update_event($_POST);
|
22 |
+
}
|
23 |
+
|
24 |
+
$out .= '<div class="wrap">';
|
25 |
+
|
26 |
+
if( !isset( $_GET['action'] ) ) {
|
27 |
+
$_GET['action'] = '';
|
28 |
+
}
|
29 |
+
switch ( $_GET['action'] ) {
|
30 |
+
case "edit" :
|
31 |
+
$out .= self::show_edit();
|
32 |
+
break;
|
33 |
+
case "delete" :
|
34 |
+
el_db::delete_event( $_GET['id'] );
|
35 |
+
$out .= self::list_events();
|
36 |
+
break;
|
37 |
+
case "copy" :
|
38 |
+
$out .= self::edit_event();
|
39 |
+
break;
|
40 |
+
default :
|
41 |
+
$out .= self::list_events();
|
42 |
+
}
|
43 |
+
$out .= '</div>';
|
44 |
+
echo $out;
|
45 |
+
}
|
46 |
+
|
47 |
+
public static function show_new() {
|
48 |
+
$out = '<div class="wrap">
|
49 |
+
<div class="wrap nosubsub" style="padding-bottom:15px">
|
50 |
+
<div id="icon-edit-pages" class="icon32"><br /></div><h2>New Event</h2>
|
51 |
+
</div>';
|
52 |
+
$out .= self::edit_event();
|
53 |
+
$out .= '</div>';
|
54 |
+
echo $out;
|
55 |
+
}
|
56 |
+
|
57 |
+
private static function show_edit() {
|
58 |
+
$out = '<div class="wrap">
|
59 |
+
<div class="wrap nosubsub" style="padding-bottom:15px">
|
60 |
+
<div id="icon-edit-pages" class="icon32"><br /></div><h2>Edit Event</h2>
|
61 |
+
</div>';
|
62 |
+
$out .= self::edit_event();
|
63 |
+
$out .= '</div>';
|
64 |
+
echo $out;
|
65 |
+
}
|
66 |
+
|
67 |
+
public static function show_settings () {
|
68 |
+
if (!current_user_can('manage_options')) {
|
69 |
+
wp_die( __('You do not have sufficient permissions to access this page.') );
|
70 |
+
}
|
71 |
+
$out = '';
|
72 |
+
if( isset( $_GET['settings-updated'] ) ) {
|
73 |
+
$out .= '<div id="message" class="updated">
|
74 |
+
<p><strong>'.__( 'Settings saved.' ).'</strong></p>
|
75 |
+
</div>';
|
76 |
+
}
|
77 |
+
$out.= '<div class="wrap">
|
78 |
+
<div class="wrap nosubsub" style="padding-bottom:15px">
|
79 |
+
<div id="icon-edit-pages" class="icon32"><br /></div><h2>Event List Settings</h2>
|
80 |
+
</div>
|
81 |
+
<form method="post" action="options.php">
|
82 |
+
Not available yet';
|
83 |
+
// TODO: Add settings to settings page
|
84 |
+
// $out .= settings_fields( 'mfgigcal_settings' );
|
85 |
+
// $out .= do_settings_sections('mfgigcal');
|
86 |
+
// $out .= '<input name="Submit" type="submit" value="'.esc_attr__( 'Save Changes' ).'" />
|
87 |
+
// </form>
|
88 |
+
// </div>';
|
89 |
+
/*
|
90 |
+
<h3>Comment Guestbook Settings</h3>';
|
91 |
+
if( !isset( $_GET['tab'] ) ) {
|
92 |
+
$_GET['tab'] = 'general';
|
93 |
+
}
|
94 |
+
$out .= cgb_admin::create_tabs( $_GET['tab'] );
|
95 |
+
$out .= '<div id="posttype-page" class="posttypediv">';
|
96 |
+
$out .= '
|
97 |
+
<form method="post" action="options.php">
|
98 |
+
';
|
99 |
+
ob_start();
|
100 |
+
settings_fields( 'cgb_'.$_GET['tab'] );
|
101 |
+
$out .= ob_get_contents();
|
102 |
+
ob_end_clean();
|
103 |
+
$out .= '
|
104 |
+
<div style="padding:0 10px">';
|
105 |
+
switch( $_GET['tab'] ) {
|
106 |
+
case 'comment_list' :
|
107 |
+
$out .= '
|
108 |
+
<table class="form-table">';
|
109 |
+
$out .= cgb_admin::show_options( 'comment_list' );
|
110 |
+
$out .= '
|
111 |
+
</table>';
|
112 |
+
break;
|
113 |
+
default : // 'general'
|
114 |
+
$out .= '
|
115 |
+
<table class="form-table">';
|
116 |
+
$out .= cgb_admin::show_options( 'general' );
|
117 |
+
$out .= '
|
118 |
+
</table>';
|
119 |
+
break;
|
120 |
+
}
|
121 |
+
$out .=
|
122 |
+
'</div>';
|
123 |
+
ob_start();
|
124 |
+
submit_button();
|
125 |
+
$out .= ob_get_contents();
|
126 |
+
ob_end_clean();*/
|
127 |
+
$out .='
|
128 |
+
</form>
|
129 |
+
</div>';
|
130 |
+
echo $out;
|
131 |
+
}
|
132 |
+
|
133 |
+
public static function show_about() {
|
134 |
+
$out = '<div class="wrap">
|
135 |
+
<div class="wrap nosubsub" style="padding-bottom:15px">
|
136 |
+
<div id="icon-edit-pages" class="icon32"><br /></div><h2>About Event List</h2>
|
137 |
+
</div>
|
138 |
+
<h3>Instructions</h3>
|
139 |
+
<p>Add your events <a href="admin.php?page=el_admin_main">here</a>.</p>
|
140 |
+
<p>To show the events on your site just place this short code on any Page or Post:</p>
|
141 |
+
<pre>[event-list]</pre>';
|
142 |
+
// <p>The plugin includes a widget to place your events in a sidebar.</p>
|
143 |
+
$out .= '<p>Be sure to also check out the <a href="admin.php?page=el_admin_settings">settings page</a> to get Event List behaving just the way you want.</p>
|
144 |
+
</div>';
|
145 |
+
echo $out;
|
146 |
+
}
|
147 |
+
|
148 |
+
public static function embed_admin_js() {
|
149 |
+
echo '<script type="text/javascript" src="'.EL_URL.'/js/admin.js"></script>';
|
150 |
+
}
|
151 |
+
|
152 |
+
private static function list_events() {
|
153 |
+
if ( isset( $_GET['ytd'] ) ) {
|
154 |
+
$events = el_db::get_events( $_GET['ytd'] );
|
155 |
+
}
|
156 |
+
else {
|
157 |
+
$events = el_db::get_events( 'upcoming' );
|
158 |
+
}
|
159 |
+
$out = el_db::html_calendar_nav();
|
160 |
+
$out .= '<style type="text/css">
|
161 |
+
<!--
|
162 |
+
.widefat .event_date { text-align: right; width: 150px; }
|
163 |
+
.widefat .event_location { text-align: left; width: 27%; min-width: 200px; }
|
164 |
+
.widefat .event_details { min-width: 70px; }
|
165 |
+
.widefat .event_buttons { text-align: right; padding: 8px; }
|
166 |
+
.widefat .event_title { font-weight: bold; }
|
167 |
+
}
|
168 |
+
-->
|
169 |
+
</style>';
|
170 |
+
$out .= '<a href="?page=el_admin_new" class="button-primary" style="float:right;">New Event</a>
|
171 |
+
<table class="widefat" style="margin-top:10px;">
|
172 |
+
<thead>
|
173 |
+
<tr><th class="event_date">Date</th><th class="event_location">Event</th><th class="event_details" colspan="2">Event Details</th></tr>
|
174 |
+
</thead>';
|
175 |
+
|
176 |
+
if ( !empty( $events ) ) {
|
177 |
+
foreach ( $events as $event ) {
|
178 |
+
$out .= '<tr><td class="event_date">';
|
179 |
+
$out .= self::format_date( $event->start_date, $event->end_date).'<br />';
|
180 |
+
$out .= $event->time;
|
181 |
+
$out .= '</td>
|
182 |
+
<td class="event_location"><div class="event_title">'.$event->title.'</div>'.self::truncate( 80, $event->location ).'</td>
|
183 |
+
<td class="event_details">'.self::truncate( 100, $event->details ).'</td>
|
184 |
+
<td class="event_buttons" style="white-space:nowrap;">
|
185 |
+
<a href="?page=el_admin_main&id='.$event->id.'&action=edit" class="button-secondary" title="Edit this event">Edit</a>
|
186 |
+
<a href="?page=el_admin_main&id='.$event->id.'&action=copy" class="button-secondary" title="Create a new event based on this event">Duplicate</a>
|
187 |
+
<a href="#" onClick="eventlist_deleteEvent('.$event->id.');return false;" class="button-secondary" title="Delete this event">Delete</a>
|
188 |
+
</td></tr>';
|
189 |
+
}
|
190 |
+
}
|
191 |
+
else {
|
192 |
+
$out .= '<tr>
|
193 |
+
<td colspan="10" style="text-align:center;">No events found in this range.</td>
|
194 |
+
</tr>';
|
195 |
+
}
|
196 |
+
|
197 |
+
$out .= "</table>";
|
198 |
+
return $out;
|
199 |
+
}
|
200 |
+
|
201 |
+
private static function edit_event() {
|
202 |
+
$copy = false;
|
203 |
+
$new = false;
|
204 |
+
if( isset( $_GET['id'] ) ) {
|
205 |
+
// existing event
|
206 |
+
$event = el_db::get_event( $_GET['id'] );
|
207 |
+
if ( isset( $_GET['action'] ) && $_GET['action'] == 'copy' ) {
|
208 |
+
// copy of existing event
|
209 |
+
$start_date = date('Y-m-d');
|
210 |
+
$end_date = date('Y-m-d');
|
211 |
+
$copy = true;
|
212 |
+
}
|
213 |
+
else {
|
214 |
+
// edit existing event
|
215 |
+
$start_date = $event->start_date;
|
216 |
+
$end_date = $event->end_date;
|
217 |
+
}
|
218 |
+
}
|
219 |
+
else {
|
220 |
+
//new event
|
221 |
+
$start_date = date('Y-m-d');
|
222 |
+
$end_date = date('Y-m-d');
|
223 |
+
$new = true;
|
224 |
+
}
|
225 |
+
|
226 |
+
$out = '<form method="POST" action="?page=el_admin_main">';
|
227 |
+
if ( !$new && !$copy ) {
|
228 |
+
$out .= '<input type="hidden" name="id" value="'.$_GET['id'].'" />';
|
229 |
+
}
|
230 |
+
$out .= '<table class="form-table">
|
231 |
+
<tr>
|
232 |
+
<th><label>Start Date (required)</label></th>
|
233 |
+
<td><input type="text" class="text datepicker form-required" name="start_date" id="start_date" value="'.$start_date.'" /> <label><input type="checkbox" id="multi" /> Multiple Day Event</label></td>
|
234 |
+
</tr>
|
235 |
+
<tr id="end_date_row">
|
236 |
+
<th><label>End Date</label></th>
|
237 |
+
<td><input type="text" class="text datepicker" name="end_date" id="end_date" value="'.$end_date.'" /></td>
|
238 |
+
</tr>
|
239 |
+
<tr>
|
240 |
+
<th><label>Event Title (required)</label></th>
|
241 |
+
<td><input type="text" class="text form-required" style="width:350px;" name="title" id="title" value="'.str_replace( '"', '"', isset( $event->title ) ? $event->title : '' ).'" /></td>
|
242 |
+
</tr>
|
243 |
+
<tr>
|
244 |
+
<th><label>Event Time</label></th>
|
245 |
+
<td><input type="text" class="text" name="time" id="time" value="'.str_replace( '"', '"', isset( $event->time ) ? $event->time : '' ).'" /></td>
|
246 |
+
</tr>
|
247 |
+
<tr>
|
248 |
+
<th><label>Event Location</label></th>
|
249 |
+
<td><input type="text" class="text" name="location" id="location" value="'.str_replace( '"', '"', isset( $event->location ) ? $event->location : '' ).'" /></td>
|
250 |
+
</tr>
|
251 |
+
<tr>
|
252 |
+
<th><label>Event Details</label></th>
|
253 |
+
<td>';
|
254 |
+
$editor_settings = array( 'media_buttons' => true,
|
255 |
+
'wpautop' => false,
|
256 |
+
'tinymce' => array( 'height' => '400',
|
257 |
+
'force_br_newlines' => false,
|
258 |
+
'force_p_newlines' => true,
|
259 |
+
'convert_newlines_to_brs' => false ),
|
260 |
+
'quicktags' => true );
|
261 |
+
ob_start();
|
262 |
+
wp_editor( isset( $event->details ) ? $event->details : '', 'details', $editor_settings);
|
263 |
+
$out .= ob_get_contents();
|
264 |
+
ob_end_clean();
|
265 |
+
$out .= '<p style="margin:2px;"><i>NOTE: In the text editor, use RETURN to start a new paragraph - use SHIFT-RETURN to start a new line.</i></p></td>
|
266 |
+
</tr>
|
267 |
+
</table>';
|
268 |
+
$out .= '<p class="submit"><input type="submit" class="button-primary" name="save" value="Save Event" id="submitbutton"> <a href="?page=el_admin_main" class="button-secondary">Cancel</a></p></form>';
|
269 |
+
return $out;
|
270 |
+
}
|
271 |
+
|
272 |
+
private static function format_date( $start_date, $end_date ) {
|
273 |
+
$start_array = explode("-", $start_date);
|
274 |
+
$start_date = mktime(0,0,0,$start_array[1],$start_array[2],$start_array[0]);
|
275 |
+
$end_array = explode("-", $end_date);
|
276 |
+
$end_date = mktime(0,0,0,$end_array[1],$end_array[2],$end_array[0]);
|
277 |
+
$out = '';
|
278 |
+
|
279 |
+
if ($start_date == $end_date) {
|
280 |
+
if ($start_array[2] == "00") {
|
281 |
+
$start_date = mktime(0,0,0,$start_array[1],15,$start_array[0]);
|
282 |
+
$out .= '<span style="white-space:nowrap;">' . date("F, Y", $start_date) . "</span>";
|
283 |
+
return $out;
|
284 |
+
}
|
285 |
+
$out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "</span>";
|
286 |
+
return $out;
|
287 |
+
}
|
288 |
+
|
289 |
+
if ($start_array[0] == $end_array[0]) {
|
290 |
+
if ($start_array[1] == $end_array[1]) {
|
291 |
+
$out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("j, Y", $end_date) . "</span>";
|
292 |
+
return $out;
|
293 |
+
}
|
294 |
+
$out .= '<span style="white-space:nowrap;">' . date("M j", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
|
295 |
+
return $out;
|
296 |
+
|
297 |
+
}
|
298 |
+
|
299 |
+
$out .= '<span style="white-space:nowrap;">' . date("M j, Y", $start_date) . "-" . date("M j, Y", $end_date) . "</span>";
|
300 |
+
return $out;
|
301 |
+
}
|
302 |
+
|
303 |
+
private static function create_tabs( $current = 'general' ) {
|
304 |
+
$tabs = array( 'general' => 'General settings', 'comment_list' => 'Comment-list settings', 'comment_form' => 'Comment-form settings',
|
305 |
+
'comment_form_html' => 'Comment-form html code', 'comment_html' => 'Comment html code' );
|
306 |
+
$out = '<h3 class="nav-tab-wrapper">';
|
307 |
+
foreach( $tabs as $tab => $name ){
|
308 |
+
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
|
309 |
+
$out .= "<a class='nav-tab$class' href='?page=cgb_admin_main&tab=$tab'>$name</a>";
|
310 |
+
}
|
311 |
+
$out .= '</h3>';
|
312 |
+
return $out;
|
313 |
+
}
|
314 |
+
|
315 |
+
// $desc_pos specifies where the descpription will be displayed.
|
316 |
+
// available options: 'right' ... description will be displayed on the right side of the option (standard value)
|
317 |
+
// 'newline' ... description will be displayed below the option
|
318 |
+
private static function show_options( $section, $desc_pos='right' ) {
|
319 |
+
$out = '';
|
320 |
+
foreach( self::$options as $oname => $o ) {
|
321 |
+
if( $o['section'] == $section ) {
|
322 |
+
$out .= '
|
323 |
+
<tr valign="top">
|
324 |
+
<th scope="row">';
|
325 |
+
if( $o['label'] != '' ) {
|
326 |
+
$out .= '<label for="'.$oname.'">'.$o['label'].':</label>';
|
327 |
+
}
|
328 |
+
$out .= '</th>
|
329 |
+
<td>';
|
330 |
+
switch( $o['type'] ) {
|
331 |
+
case 'checkbox':
|
332 |
+
$out .= cgb_admin::show_checkbox( $oname, self::get( $oname ), $o['caption'] );
|
333 |
+
break;
|
334 |
+
case 'text':
|
335 |
+
$out .= cgb_admin::show_text( $oname, self::get( $oname ) );
|
336 |
+
break;
|
337 |
+
case 'textarea':
|
338 |
+
$out .= cgb_admin::show_textarea( $oname, self::get( $oname ) );
|
339 |
+
break;
|
340 |
+
}
|
341 |
+
$out .= '
|
342 |
+
</td>';
|
343 |
+
if( $desc_pos == 'newline' ) {
|
344 |
+
$out .= '
|
345 |
+
</tr>
|
346 |
+
<tr>
|
347 |
+
<td></td>';
|
348 |
+
}
|
349 |
+
$out .= '
|
350 |
+
<td class="description">'.$o['desc'].'</td>
|
351 |
+
</tr>';
|
352 |
+
if( $desc_pos == 'newline' ) {
|
353 |
+
$out .= '
|
354 |
+
<tr><td></td></tr>';
|
355 |
+
}
|
356 |
+
}
|
357 |
+
}
|
358 |
+
return $out;
|
359 |
+
}
|
360 |
+
|
361 |
+
private static function show_checkbox( $name, $value, $caption ) {
|
362 |
+
$out = '
|
363 |
+
<label for="'.$name.'">
|
364 |
+
<input name="'.$name.'" type="checkbox" id="'.$name.'" value="1"';
|
365 |
+
if( $value == 1 ) {
|
366 |
+
$out .= ' checked="checked"';
|
367 |
+
}
|
368 |
+
$out .= ' />
|
369 |
+
'.$caption.'
|
370 |
+
</label>';
|
371 |
+
return $out;
|
372 |
+
}
|
373 |
+
|
374 |
+
private static function show_text( $name, $value ) {
|
375 |
+
$out = '
|
376 |
+
<input name="'.$name.'" type="text" id="'.$name.'" value="'.$value.'" />';
|
377 |
+
return $out;
|
378 |
+
}
|
379 |
+
|
380 |
+
private static function show_textarea( $name, $value ) {
|
381 |
+
$out = '
|
382 |
+
<textarea name="'.$name.'" id="'.$name.'" rows="20" class="large-text code">'.$value.'</textarea>';
|
383 |
+
return $out;
|
384 |
+
}
|
385 |
+
|
386 |
+
// function to truncate and shorten html text
|
387 |
+
private static function truncate( $maxLength, $html ) {
|
388 |
+
$printedLength = 0;
|
389 |
+
$position = 0;
|
390 |
+
$tags = array();
|
391 |
+
|
392 |
+
$out = '';
|
393 |
+
|
394 |
+
while ($printedLength < $maxLength && preg_match('{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}', $html, $match, PREG_OFFSET_CAPTURE, $position)) {
|
395 |
+
list($tag, $tagPosition) = $match[0];
|
396 |
+
|
397 |
+
// Print text leading up to the tag.
|
398 |
+
$str = substr($html, $position, $tagPosition - $position);
|
399 |
+
if ($printedLength + strlen($str) > $maxLength) {
|
400 |
+
$out .= substr($str, 0, $maxLength - $printedLength);
|
401 |
+
$printedLength = $maxLength;
|
402 |
+
break;
|
403 |
+
}
|
404 |
+
|
405 |
+
$out .= $str;
|
406 |
+
$printedLength += strlen($str);
|
407 |
+
|
408 |
+
if ($tag[0] == '&') {
|
409 |
+
// Handle the entity.
|
410 |
+
$out .= $tag;
|
411 |
+
$printedLength++;
|
412 |
+
}
|
413 |
+
else {
|
414 |
+
// Handle the tag.
|
415 |
+
$tagName = $match[1][0];
|
416 |
+
if ($tag[1] == '/')
|
417 |
+
{
|
418 |
+
// This is a closing tag.
|
419 |
+
$openingTag = array_pop($tags);
|
420 |
+
assert($openingTag == $tagName); // check that tags are properly nested.
|
421 |
+
$out .= $tag;
|
422 |
+
}
|
423 |
+
else if ($tag[strlen($tag) - 2] == '/') {
|
424 |
+
// Self-closing tag.
|
425 |
+
$out .= $tag;
|
426 |
+
}
|
427 |
+
else {
|
428 |
+
// Opening tag.
|
429 |
+
$out .= $tag;
|
430 |
+
$tags[] = $tagName;
|
431 |
+
}
|
432 |
+
}
|
433 |
+
|
434 |
+
// Continue after the tag.
|
435 |
+
$position = $tagPosition + strlen($tag);
|
436 |
+
}
|
437 |
+
|
438 |
+
// Print any remaining text.
|
439 |
+
if ($printedLength < $maxLength && $position < strlen($html)) {
|
440 |
+
$out .= substr($html, $position, $maxLength - $printedLength);
|
441 |
+
}
|
442 |
+
if ($maxLength < strlen($html)) {
|
443 |
+
$out .= "...";
|
444 |
+
}
|
445 |
+
|
446 |
+
// Close any open tags.
|
447 |
+
while (!empty($tags)) {
|
448 |
+
$out .= "</" . array_pop($tags) . ">";
|
449 |
+
}
|
450 |
+
return $out;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
?>
|
php/db.php
ADDED
@@ -0,0 +1,188 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
9 |
+
// UPDATE DB
|
10 |
+
public static function update_check() {
|
11 |
+
// TODO: added version checking
|
12 |
+
// if( el_options::get( 'el_db_version' ) != self::VERSION) {
|
13 |
+
$sql = 'CREATE TABLE '.self::table_name().' (
|
14 |
+
id int(11) NOT NULL AUTO_INCREMENT,
|
15 |
+
pub_user bigint(20) NOT NULL,
|
16 |
+
pub_date datetime NOT NULL DEFAULT "0000-00-00 00:00:00",
|
17 |
+
start_date date NOT NULL DEFAULT "0000-00-00",
|
18 |
+
end_date date DEFAULT NULL,
|
19 |
+
time text,
|
20 |
+
title text NOT NULL,
|
21 |
+
location text,
|
22 |
+
details text,
|
23 |
+
history text,
|
24 |
+
PRIMARY KEY (id) )
|
25 |
+
DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;';
|
26 |
+
|
27 |
+
require_once( ABSPATH.'wp-admin/includes/upgrade.php' );
|
28 |
+
dbDelta( $sql );
|
29 |
+
|
30 |
+
// el_options::set( 'el_db_version', self::VERSION );
|
31 |
+
// }
|
32 |
+
}
|
33 |
+
|
34 |
+
public static function table_name() {
|
35 |
+
global $wpdb;
|
36 |
+
return $wpdb->prefix.self::TABLE_NAME;
|
37 |
+
}
|
38 |
+
|
39 |
+
public static function get_events( $date_range='all' ) {
|
40 |
+
global $wpdb;
|
41 |
+
|
42 |
+
// set date for data base query
|
43 |
+
if( $date_range === 'all' ) {
|
44 |
+
// get all events
|
45 |
+
$range_start = '0000-01-01';
|
46 |
+
$range_end = '9999-12-31';
|
47 |
+
}
|
48 |
+
elseif( $date_range === 'upcoming' ) {
|
49 |
+
// get only events in the future
|
50 |
+
$range_start = date( 'Y-m-d' );
|
51 |
+
$range_end = '9999-12-31';
|
52 |
+
}
|
53 |
+
else {
|
54 |
+
$range_start = $date_range.'-01-01';
|
55 |
+
$range_end = $date_range.'-12-31';
|
56 |
+
}
|
57 |
+
$sql = 'SELECT * FROM '.self::table_name().' WHERE (end_date >= "'.$range_start.'" AND start_date <= "'.$range_end.'") ORDER BY start_date';
|
58 |
+
return $wpdb->get_results( $sql );
|
59 |
+
}
|
60 |
+
|
61 |
+
public static function get_event( $id ) {
|
62 |
+
global $wpdb;
|
63 |
+
$sql = 'SELECT * FROM '.self::table_name().' WHERE id = '.$id.' LIMIT 1';
|
64 |
+
return $wpdb->get_row( $sql );
|
65 |
+
}
|
66 |
+
|
67 |
+
public static function get_event_date( $event ) {
|
68 |
+
global $wpdb;
|
69 |
+
if( $event === 'first' ) {
|
70 |
+
// first year
|
71 |
+
$search_date = 'start_date';
|
72 |
+
$sql = 'SELECT DISTINCT '.$search_date.' FROM '.self::table_name().' WHERE '.$search_date.' != "0000-00-00" ORDER BY '.$search_date.' ASC LIMIT 1';
|
73 |
+
}
|
74 |
+
else {
|
75 |
+
// last year
|
76 |
+
$search_date = 'end_date';
|
77 |
+
$sql = 'SELECT DISTINCT '.$search_date.' FROM '.self::table_name().' WHERE '.$search_date.' != "0000-00-00" ORDER BY '.$search_date.' DESC LIMIT 1';
|
78 |
+
}
|
79 |
+
$date = $wpdb->get_results($sql, ARRAY_A);
|
80 |
+
if( !empty( $date ) ) {
|
81 |
+
$date = self::extract_date( $date[0][$search_date],'Y');
|
82 |
+
}
|
83 |
+
else {
|
84 |
+
$date = date("Y");
|
85 |
+
}
|
86 |
+
return $date;
|
87 |
+
}
|
88 |
+
|
89 |
+
public static function update_event( $event_data ) {
|
90 |
+
global $wpdb;
|
91 |
+
self::remove_wp_magic_quotes();
|
92 |
+
$current_user = wp_get_current_user();
|
93 |
+
|
94 |
+
$sqldata = array( 'pub_user' => $current_user->ID,
|
95 |
+
'pub_date' => date( "Y-m-d H:i:s" ),
|
96 |
+
'start_date' => $event_data['start_date'],
|
97 |
+
'end_date' => $event_data['end_date'],
|
98 |
+
'time' => $event_data['time'],
|
99 |
+
'title' => $event_data['title'],
|
100 |
+
'location' => $event_data['location'],
|
101 |
+
'details' => $event_data['details'] );
|
102 |
+
$sqltypes = array( '%s', '%s', '%s', '%s', '%s', '%s', '%s' );
|
103 |
+
|
104 |
+
if( isset( $event_data['id'] ) ) { // update event
|
105 |
+
$wpdb->update( self::table_name(), $sqldata, array( 'id' => $event_data['id'] ), $sqltypes );
|
106 |
+
}
|
107 |
+
else { // new event
|
108 |
+
$wpdb->insert( self::table_name(), $sqldata, $sqltypes );
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
public static function delete_event( $event_id ) {
|
113 |
+
global $wpdb;
|
114 |
+
$wpdb->query( 'DELETE FROM '.self::table_name().' WHERE id = "'.$event_id.'"' );
|
115 |
+
}
|
116 |
+
|
117 |
+
public static function remove_wp_magic_quotes() {
|
118 |
+
$_GET = stripslashes_deep($_GET);
|
119 |
+
$_POST = stripslashes_deep($_POST);
|
120 |
+
$_COOKIE = stripslashes_deep($_COOKIE);
|
121 |
+
$_REQUEST = stripslashes_deep($_REQUEST);
|
122 |
+
}
|
123 |
+
|
124 |
+
public static function extract_date( $date, $format ) {
|
125 |
+
|
126 |
+
if( $date == "0000-00-00" || !$date ) return false;
|
127 |
+
|
128 |
+
$dateArray = explode( "-", $date );
|
129 |
+
$date = mktime( 0, 0, 0, $dateArray[1] ,$dateArray[2] ,$dateArray[0] );
|
130 |
+
|
131 |
+
// special for day set to "00"
|
132 |
+
if( $dateArray[2] == "00" ) {
|
133 |
+
if( $format == "d" ) {
|
134 |
+
return "00";
|
135 |
+
}
|
136 |
+
else {
|
137 |
+
$date = mktime(0,0,0,$dateArray[1],15,$dateArray[0]);
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return date( $format, $date );
|
142 |
+
}
|
143 |
+
|
144 |
+
public static function html_calendar_nav() {
|
145 |
+
$first_year = self::get_event_date( 'first' );
|
146 |
+
$last_year = self::get_event_date( 'last' );
|
147 |
+
|
148 |
+
if ( is_admin() ) {
|
149 |
+
$url = "?page=el_admin_main&";
|
150 |
+
}
|
151 |
+
else if ( get_option( 'permalink_structure' ) ) {
|
152 |
+
$url = "?";
|
153 |
+
}
|
154 |
+
else {
|
155 |
+
$existing = "?";
|
156 |
+
foreach ( $_GET as $k => $v ) {
|
157 |
+
if ( $k != "ytd" && $k != "event_id" ) $existing .= $k . "=" . $v . "&";
|
158 |
+
}
|
159 |
+
$url = $existing;
|
160 |
+
}
|
161 |
+
|
162 |
+
// Calendar Navigation
|
163 |
+
$out = '<div id="eventlist_nav">';
|
164 |
+
if ( isset( $_GET['ytd'] ) || isset( $_GET['event_id'] ) ) {
|
165 |
+
$out .= '<a href="'.$url.'">Upcoming</a>';
|
166 |
+
}
|
167 |
+
else {
|
168 |
+
$out .= '<strong>Upcoming</strong>';
|
169 |
+
}
|
170 |
+
for( $year=$last_year; $year>=$first_year; $year-- ) {
|
171 |
+
$out .= ' | ';
|
172 |
+
if( isset( $_GET['ytd'] ) && $year == $_GET['ytd'] ) {
|
173 |
+
$out .= '<strong>'.$year.'</strong>';
|
174 |
+
}
|
175 |
+
else {
|
176 |
+
$out .= '<a href="'.$url.'ytd='.$year.'">'.$year.'</a>';
|
177 |
+
}
|
178 |
+
}
|
179 |
+
$out .= '</div><br />';
|
180 |
+
|
181 |
+
// Title (only if event details are viewed)
|
182 |
+
if( isset( $_GET['event_id'] ) ) {
|
183 |
+
$out .= '<h2>Event Information:</h2>';
|
184 |
+
}
|
185 |
+
return $out;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
?>
|
php/sc_event-list.php
ADDED
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
7 |
+
// All available attributes
|
8 |
+
public static $attr = array(
|
9 |
+
|
10 |
+
'initial_date' => array( 'val' => 'upcoming<br />year e.g. "2012"',
|
11 |
+
'std_val' => 'upcoming',
|
12 |
+
'desc' => 'This attribute specifies which events are listed after the site is shown. The standard is to show the upcoming events.<br />
|
13 |
+
Specify a year e.g. "2012" to change this.' )
|
14 |
+
);
|
15 |
+
|
16 |
+
// main function to show the rendered HTML output
|
17 |
+
public static function show_html( $atts ) {
|
18 |
+
// check attributes
|
19 |
+
$std_values = array();
|
20 |
+
foreach( self::$attr as $aname => $attribute ) {
|
21 |
+
$std_values[$aname] = $attribute['std_val'];
|
22 |
+
}
|
23 |
+
$a = shortcode_atts( $std_values, $atts );
|
24 |
+
|
25 |
+
if( isset( $_GET['event_id'] ) ) {
|
26 |
+
$out = self::html_event_details( $_GET['event_id'] );
|
27 |
+
}
|
28 |
+
else {
|
29 |
+
$out = self::html_events( $a );
|
30 |
+
}
|
31 |
+
return $out;
|
32 |
+
}
|
33 |
+
|
34 |
+
private static function html_event_details( $event_id ) {
|
35 |
+
$event = el_db::get_event( $event_id );
|
36 |
+
$out = el_db::html_calendar_nav();
|
37 |
+
$out .= '<ul id="eventlist">';
|
38 |
+
$out .= self::html_event( $event );
|
39 |
+
$out .= '</ul>';
|
40 |
+
return $out;
|
41 |
+
}
|
42 |
+
|
43 |
+
private static function html_events( $a ) {
|
44 |
+
// specify visible events
|
45 |
+
if( isset( $_GET['ytd'] ) ) {
|
46 |
+
$events = el_db::get_events( $_GET['ytd'] );
|
47 |
+
}
|
48 |
+
elseif( $a['initial_date'] !== 'upcoming' ) {
|
49 |
+
$events = el_db::get_events( $a['initial_date'] );
|
50 |
+
}
|
51 |
+
else {
|
52 |
+
$events = el_db::get_events( 'upcoming' );
|
53 |
+
}
|
54 |
+
$out = '';
|
55 |
+
// TODO: add rss feed
|
56 |
+
// if ($mfgigcal_settings['rss']) {
|
57 |
+
// (get_option('permalink_structure')) ? $feed_link = "/feed/events" : $feed_link = "/?feed=events";
|
58 |
+
// $out .= "<a href=\"$feed_link\" class=\"rss-link\">RSS</a>";
|
59 |
+
// }
|
60 |
+
|
61 |
+
// generate output
|
62 |
+
$out .= el_db::html_calendar_nav();
|
63 |
+
// TODO: Setting missing
|
64 |
+
if( empty( $events ) /*&& $mfgigcal_settings['no-events'] == "text"*/ ) {
|
65 |
+
$out .= "<p>" . 'no event' /*$mfgigcal_settings['message'] */. "</p>";
|
66 |
+
return $out;
|
67 |
+
}
|
68 |
+
/* else if (empty($events)) {
|
69 |
+
$this_year = date("Y");
|
70 |
+
// show the current year
|
71 |
+
$sql = "SELECT * FROM $mfgigcal_table WHERE (end_date >= '$this_year-01-01' AND start_date <= '$this_year-12-31') ORDER BY start_date ASC";
|
72 |
+
$events = $wpdb->get_results($sql);
|
73 |
+
if (empty($events)) {
|
74 |
+
$out .= "<p>" . $mfgigcal_settings['message'] . "</p>";
|
75 |
+
return $out;
|
76 |
+
}
|
77 |
+
}
|
78 |
+
*/
|
79 |
+
else {
|
80 |
+
$url = '?';
|
81 |
+
if( !get_option( 'permalink_structure' ) ) {
|
82 |
+
foreach( $_GET as $k => $v ) {
|
83 |
+
if( $k != 'ytd' && $k != 'event_id' ) {
|
84 |
+
$url .= $k . "=" . $v . "&";
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
// set html code
|
90 |
+
$out .= '<ul id="eventlist">';
|
91 |
+
foreach ($events as $event) {
|
92 |
+
$out .= self::html_event( $event, $url );
|
93 |
+
}
|
94 |
+
$out .= '</ul>';
|
95 |
+
return $out;
|
96 |
+
}
|
97 |
+
return $out;
|
98 |
+
}
|
99 |
+
|
100 |
+
private static function html_event( $event, $url=false ) {
|
101 |
+
$out = '<li class="event">';
|
102 |
+
$out .= self::html_fulldate( $event->start_date, $event->end_date );
|
103 |
+
$out .= '<div class="info_block"><h3>';
|
104 |
+
if( $url ) {
|
105 |
+
$out .= '<a href="'.$url.'event_id='.$event->id.'">'.$event->title.'</a>';
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
$out .= $event->title;
|
109 |
+
}
|
110 |
+
$out .= '</h3>';
|
111 |
+
if( $event->time != '' ) {
|
112 |
+
$out .= '<span class="time">'.$event->time.'</span>';
|
113 |
+
}
|
114 |
+
$out .= '<span class="location">'.$event->location.'</span>';
|
115 |
+
$out .= '<span class="details">'.$event->details.'</span>';
|
116 |
+
$out .= '</div></li>';
|
117 |
+
return $out;
|
118 |
+
}
|
119 |
+
|
120 |
+
private static function html_fulldate( $start_date, $end_date ) {
|
121 |
+
$startArray = explode("-", $start_date);
|
122 |
+
$start_date = mktime(0,0,0,$startArray[1],$startArray[2],$startArray[0]);
|
123 |
+
$endArray = explode("-", $end_date);
|
124 |
+
$end_date = mktime(0,0,0,$endArray[1],$endArray[2],$endArray[0]);
|
125 |
+
$out = '';
|
126 |
+
if( $start_date == $end_date ) {
|
127 |
+
// one day event
|
128 |
+
$out .= '<div class="date">';
|
129 |
+
$out .= '<div class="end-date">';
|
130 |
+
$out .= self::html_date( $start_date );
|
131 |
+
$out .= '</div>';
|
132 |
+
}
|
133 |
+
else {
|
134 |
+
// multi day event
|
135 |
+
$out .= '<div class="date multi-date">';
|
136 |
+
$out .= '<div class="start-date">';
|
137 |
+
$out .= self::html_date( $start_date );
|
138 |
+
$out .= '</div>';
|
139 |
+
$out .= '<div class="end-date">';
|
140 |
+
$out .= self::html_date( $end_date );
|
141 |
+
$out .= '</div>';
|
142 |
+
}
|
143 |
+
$out .= '</div>';
|
144 |
+
return $out;
|
145 |
+
}
|
146 |
+
|
147 |
+
private static function html_date( $date ) {
|
148 |
+
$out = '<div class="weekday">'.date( 'D', $date ).'</div>';
|
149 |
+
$out .= '<div class="day">'.date( 'd', $date ).'</div>';
|
150 |
+
$out .= '<div class="month">'.date( 'M', $date ).'</div>';
|
151 |
+
$out .= '<div class="year">'.date( 'Y', $date ).'</div>';
|
152 |
+
return $out;
|
153 |
+
}
|
154 |
+
}
|
155 |
+
?>
|
readme.txt
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Event List ===
|
2 |
+
Contributors: mibuthu
|
3 |
+
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W54LNZMWF9KW2
|
4 |
+
Tags: event, events, list, listview, calendar, schedule, shortcode, page, category, categories, admin, attribute, widget, sidebar
|
5 |
+
Requires at least: 3.3
|
6 |
+
Tested up to: 3.4.2
|
7 |
+
Stable tag: 0.1.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
|
11 |
+
|
12 |
+
Manage your events and show them in a list view on your site.
|
13 |
+
|
14 |
+
|
15 |
+
== Description ==
|
16 |
+
|
17 |
+
The purpose of this plugin is to to show a list of events with date, time, description, place, etc. on your site by using a shortcode.
|
18 |
+
There are also admin sites available to access the plugin-settings and to manage the events.
|
19 |
+
|
20 |
+
= Current Features =
|
21 |
+
* beginning and end dates for multiple-day events
|
22 |
+
* Wordpress's WYSIWYG editor for the event description so you can include styled text, links, images and other media in your event list
|
23 |
+
* a duplicate function for events
|
24 |
+
* an possibility to view past events by year
|
25 |
+
|
26 |
+
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:
|
27 |
+
|
28 |
+
‘[event-list]’
|
29 |
+
|
30 |
+
If you want to follow the development status have a look at the [git-repository on github](https://github.com/mibuthu/wp-event-list "wp-event-list git-repository").
|
31 |
+
|
32 |
+
|
33 |
+
== Installation ==
|
34 |
+
|
35 |
+
The easiest version of installing is to go to the admin page. There you can install new plugins in the menu Plugins -> Add new. Search for "Event List" and press "Install now".
|
36 |
+
|
37 |
+
If you want to install the plugin manually download the zip-file and extract the files into your wp-content/plugins folder.
|
38 |
+
|
39 |
+
|
40 |
+
== Frequently Asked Questions ==
|
41 |
+
|
42 |
+
= How do I get a calendar to show up in a Page or Post on my site? =
|
43 |
+
Insert the shortcode [event-list] in your page.
|
44 |
+
|
45 |
+
= How do I use styled text and images in the event descriptions? =
|
46 |
+
Event List uses the built-in Wordpress WYSIWYG editor. It's exactly the same process you use when creating Posts or Pages.
|
47 |
+
|
48 |
+
|
49 |
+
== Screenshots ==
|
50 |
+
|
51 |
+
not available yet
|
52 |
+
|
53 |
+
|
54 |
+
== Changelog ==
|
55 |
+
|
56 |
+
= 0.1.0 (2012-09-08) =
|
57 |
+
|
58 |
+
* Initial release
|