/
admin_config.php
executable file
·288 lines (263 loc) · 7.3 KB
/
admin_config.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<?php
/*
* Forecasty - A weather plugin for e107
*
* Copyright (C) 2015 Patrick Weaver (http://trickmod.com/)
* For additional information refer to the README.md file.
*
*/
require_once('../../class2.php');
if (!getperms('P'))
{
header('location:'.e_BASE.'index.php');
exit;
}
class forecasty_adminArea extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'forecasty_ui',
'path' => null,
'ui' => 'forecasty_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
'main/list' => array('caption' => 'Manage One Liners', 'perm' => 'P'),
'main/create' => array('caption' => 'Create One Liner', 'perm' => 'P'),
'main/prefs' => array('caption' => LAN_PREFS, 'perm' => 'P'),
'main/custom' => array('caption' => 'Get Location', 'perm' => 'P'),
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = 'forecasty';
}
class forecasty_ui extends e_admin_ui
{
protected $pluginTitle = 'Forecasty';
protected $pluginName = 'forecasty';
protected $table = 'forecasty_oneliners';
protected $pid = 'id';
protected $perPage = 10;
protected $batchDelete = true;
protected $listOrder = 'id DESC';
protected $fields = array(
'checkboxes' => array(
'title' => '',
'type' => null,
'data' => null,
'width' => '5%',
'thclass' => 'center',
'forced' => '1',
'class' => 'center',
'toggle' => 'e-multiselect',
),
'id' => array(
'title' => LAN_ID,
'data' => 'int',
'width' => '5%',
'help' => '',
'readParms' => '',
'writeParms' => '',
'class' => 'left',
'thclass' => 'left',
),
'line' => array(
'title' => 'One Liner',
'type' => 'text',
'data' => 'str',
'width' => 'auto',
'inline' => true,
'help' => 'A line used to describe the current weather condition.',
'readParms' => '',
'writeParms' => '',
'class' => 'left',
'thclass' => 'left',
),
'condition' => array(
'title' => 'Weather Condition',
'type' => 'dropdown',
'data' => 'str',
'width' => 'auto',
'inline' => true,
'help' => '',
'readParms' => '',
'writeParms' => array('optArray' => array(
'clear-day' => 'Clear (day)',
'clear-night' => 'Clear (night)',
'rain' => 'Raining',
'snow' => 'Snowing',
'sleet' => 'Sleeting',
'wind' => 'Windy',
'fog' => 'Foggy',
'cloudy' => 'Cloudy',
'partly-cloudy-day' => 'Partly Cloudy (day)',
'partly-cloudy-night' => 'Partly Cloudy (night)',
)),
'class' => 'left',
'thclass' => 'left',
),
'vulgarity' => array(
'title' => 'Vulgarity Level',
'type' => 'dropdown',
'data' => 'str',
'width' => 'auto',
'inline' => true,
'help' => '',
'readParms' => '',
'writeParms' => array('optArray' => array(
'low' => 'Low',
'medium' => 'Medium',
'high' => 'High',
)),
'class' => 'left',
'thclass' => 'left',
),
);
protected $fieldpref = array();
protected $prefs = array(
'apiKey' => array(
'title' => 'API Key',
'type' => 'text',
'data' => 'str',
'help' => 'Your Dark Sky Forecast API Key.'
),
'fallbackLocation' => array(
'title' => 'Fallback Location',
'type' => 'text',
'data' => 'str',
'help' => 'The location you want displayed if your visitors do not show up.'
),
'tempType' => array(
'title' => 'Temperature Type',
'type' => 'dropdown',
'data' => 'str',
'help' => 'The unit used to measure the temperature, Fahrenheit (F) or Celsius (C).',
'writeParms' => array('optArray' => array(
'F' => 'Fahrenheit',
'C' => 'Celsius',
)),
),
'accuracy' => array(
'title' => 'Temperature Accuracy',
'type' => 'dropdown',
'data' => 'str',
'help' => 'Do you want an exact temperature display or rounded?',
'writeParms' => array('optArray' => array(
'exact' => 'Exact Temperature',
'round' => 'Rounded Temperature',
)),
),
'tempThreshold' => array(
'title' => 'Temperature Threshold',
'type' => 'number',
'data' => 'str',
'help' => 'The temperature in which the plugin converts from hot to cold (or cold to hot).'
),
'hotColor' => array(
'title' => 'Hot Hex Color',
'type' => 'text',
'data' => 'str',
'help' => 'The color you want various elements displayed when the temperature is above the threshold.',
'writeParms' => array('class' => 'colorpicker'),
),
'coldColor' => array(
'title' => 'Cold Hex Color',
'type' => 'text',
'data' => 'str',
'help' => 'The color you want various elements displayed when the temperature is below the threshold.',
'writeParms' => array('class' => 'colorpicker'),
),
'vulgarity' => array(
'title' => 'Vulgarity',
'type' => 'dropdown',
'data' => 'str',
'help' => 'Based on your audiance, you may want a lower vulgarity displayed.',
'writeParms' => array('optArray' => array(
'low' => 'Low',
'medium' => 'Medium',
'high' => 'High',
)),
),
'iconSet' => array(
'title' => 'Weather Icon Set',
'type' => 'dropdown',
'data' => 'str',
'help' => 'Select an icon set you want displayed',
),
);
public function init()
{
$this->iconSet[e107::pref('forecasty', 'iconSet')] = e107::pref('forecasty', 'iconSet');
foreach(glob(e_PLUGIN.'forecasty/icons/*', GLOB_ONLYDIR) as $dir)
{
$dir = str_replace(e_PLUGIN.'forecasty/icons/', '', $dir);
if($dir != e107::pref('forecasty', 'iconSet'))
$this->iconSet[$dir] = $dir;
}
$this->prefs['iconSet']['writeParms'] = $this->iconSet;
}
public function beforeCreate($new_data)
{
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
}
public function onCreateError($new_data, $old_data)
{
}
public function beforeUpdate($new_data, $old_data, $id)
{
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
}
public function onUpdateError($new_data, $old_data, $id)
{
}
public function customPage()
{
// TODO: Utilize the URL instead of the local file.
// First, I have to figure out why it won't load!
e107::js('forecasty', 'assets/googlemaps.js', 'jquery');
// e107::js('url', 'http://maps.googleapis.com/maps/api/js?sensor=false');
e107::js('forecasty', 'assets/jquery-gmaps-latlon-picker.js', 'jquery');
e107::css('forecasty', 'assets/jquery-gmaps-latlon-picker.css');
$text = '
The below accepts many different formats of locations:
<ul>
<li>Zip Codes</li>
<li>City, State</li>
<li>City, Country</li>
<li>State</li>
<li>.. etc.</li>
</ul>
You can also fine tune your location by dragging and double clicking the map.
<br /><br />
<fieldset class="gllpLatlonPicker">
<input type="text" class="gllpSearchField">
<input type="button" class="gllpSearchButton" value="Search">
<div class="gllpMap">Google Maps</div>
Latitude: <input type="text" class="gllpLatitude" value="-76.61483160837915">
<br />
Longitude: <input type="text" class="gllpLongitude" value="19.218757152557373">
<input type="hidden" class="gllpZoom" value="3">
</fieldset>
<br /><br />
For your Fallback Location you need Latitude,Longitude in that exact format.<br /><br />
This page will be updated to work, flow, and look better in the future.
';
return $text;
}
}
class forecasty_form_ui extends e_admin_form_ui
{
}
new forecasty_adminArea();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;