/
forecasty_menu.php
executable file
·74 lines (69 loc) · 2.23 KB
/
forecasty_menu.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
<?php
/*
* Forecasty - A weather plugin for e107
*
* Copyright (C) 2015 Patrick Weaver (http://trickmod.com/)
* For additional information refer to the README.md file.
*
*/
if (!defined('e107_INIT')) { exit; }
require_once(e_PLUGIN.'forecasty/_class.php');
$pref = e107::pref('forecasty');
$tp = e107::getParser();
$sc = e107::getScBatch('forecasty', true);
$template = e107::getTemplate('forecasty');
// TODO: Gather the visitors location if they are a memeber, if not, utilize the fallbackLocation.
$location = $pref['fallbackLocation'];
$wf = new Forecasty($pref['apiKey'], $location);
$current = $wf->getData('current');
$hour = $wf->getData('nexthour');
$day = $wf->getData('nextday');
$week = $wf->getData('nextweek');
$sc->setVars(array(
'current' => array(
'temperature' => $current['temperature'],
'feelsLike' => $current['feelsLike'],
'icon' => $current['icon'],
'condition' => $current['condition'],
'humidity' => $current['humidity'],
'windSpeed' => $current['windSpeed'],
'visibility' => $current['visibility'],
'pressure' => $current['pressure'],
'dewPoint' => $current['dewPoint'],
),
'nexthour' => array(
'temperature' => $hour['temperature'],
'feelsLike' => $hour['feelsLike'],
'icon' => $hour['icon'],
'condition' => $hour['condition'],
'humidity' => $hour['humidity'],
'windSpeed' => $hour['windSpeed'],
'visibility' => $hour['visibility'],
'pressure' => $hour['pressure'],
'dewPoint' => $hour['dewPoint'],
),
'nextday' => array(
'temperature' => $day['temperature'],
'feelsLike' => $day['feelsLike'],
'icon' => $day['icon'],
'condition' => $day['condition'],
'humidity' => $day['humidity'],
'windSpeed' => $day['windSpeed'],
'visibility' => $day['visibility'],
'pressure' => $day['pressure'],
'dewPoint' => $day['dewPoint'],
),
'nextweek' => array(
'temperature' => $week['temperature'],
'feelsLike' => $week['feelsLike'],
'icon' => $week['icon'],
'condition' => $week['condition'],
'humidity' => $week['humidity'],
'windSpeed' => $week['windSpeed'],
'visibility' => $week['visibility'],
'pressure' => $week['pressure'],
'dewPoint' => $week['dewPoint'],
),
));
$text = $tp->parseTemplate($template['menu'], false, $sc);
e107::getRender()->tablerender('Weather', $text);