This repository has been archived by the owner on Aug 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathec_widget.class.php
143 lines (132 loc) · 3.74 KB
/
ec_widget.class.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* This file contains WP Events Calendar plugin.
*
* This is the main WPEC file.
* @internal Complete the description.
*
* @package WP-Events-Calendar
* @since 1.0
*
* @autbor Luke Howell <[email protected]>, Ugoku <[email protected]>
*
* @copyright Copyright (c) 2007-2009 Luke Howell, 2013 Ugoku
*
* @license GPLv3 {@link http://www.gnu.org/licenses/gpl}
* @filesource
*/
/*
--------------------------------------------------------------------------
WP Events Calendar is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
if (!class_exists('EC_Widget'))
{
require_once (EVENTSCALENDARCLASSPATH . '/ec_calendar.class.php');
require_once (EVENTSCALENDARCLASSPATH . '/ec_js.class.php');
/**
* Displays the sidebar widget.
*
* This can either be the small calendar or the event list,
* depending on the widget control option.
*
* @package WP-Events-Calendar
* @since 6.0
*/
class EC_Widget
{
/**
* Month to display.
*
* @since 6.0
* @access private
* @var int
*/
var $month;
/**
* Year to display.
*
* @since 6.0
* @access private
* @var int
*/
var $year;
/**
* Holds the EC_Calendar object.
*
* @since 6.0
* @access private
* @var object
*/
var $calendar;
/**
* Constructor.
*
* Instantiates the EC_Calendar and setups the year-month to display.
* This is either going to be the current month or one asked by the user
* when clicking on the navigation links in the calendar.
*
* @since 6.5.2.2
*/
function __construct()
{
$this->calendar = new EC_Calendar();
$this->month = date('m');
$this->year = date('Y');
if (isset($_GET['EC_action']))
{
$this->month = $_GET['EC_action'] == 'switchMonth' ? (int)$_GET['EC_month'] : date('m');
$this->year = $_GET['EC_action'] == 'switchMonth' ? (int)$_GET['EC_year'] : date('Y');
}
}
/**
* Displays the widget.
*
* This is called from event-calendar.php and eventscalendar.class.php
* Depending on the wiget option "type", it will either display the
* small calendar or the event list.
*
*
* @since 6.0
*
* @param array $args an array containing the following parameters
* @internal param string $name the sidebar name
* @internal param int $id the sidebar id
* @internal param string $before_widget
* @internal param string $after_widget
* @internal param string $before_title
* @internal param string $after_title
* @internal param int $widget_id the widget ID
* @internal param string $widget_name the wwidget name
*/
function display($args)
{
$js = new EC_JS();
extract($args);
echo $before_widget;
$options = get_option('widgetEventsCalendar');
if (isset($options['title']) && !empty($options['title']))
echo $before_title . $options['title'] . $after_title;
if ($options['type'] == 'calendar')
{
$this->calendar->displayWidget($this->year, $this->month);
} else {
if (!isset($options['listCount']))
$this->calendar->displayEventList(5);
else
$this->calendar->displayEventList($options['listCount']);
}
echo $after_widget;
}
}
}
?>