forked from septor/forecasty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
forecasty_shortcodes.php
executable file
·125 lines (90 loc) · 2.94 KB
/
forecasty_shortcodes.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
<?php
/*
* Forecasty - A weather plugin for e107
*
* Copyright (C) 2015 Patrick Weaver (http://trickmod.com/)
* For additional information refer to the README.md file.
*
*/
class forecasty_shortcodes extends e_shortcode
{
public $types = array('current', 'nexthour', 'nextday', 'nextweek');
function sc_temperature($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
$output = ($pref['accuracy'] == 'round' ? round($this->var[$type]['temperature']) : $this->var[$type]['temperature']);
return $output;
}
function sc_feelslike($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
$output = ($pref['accuracy'] == 'round' ? round($this->var[$type]['feelsLike']) : $this->var[$type]['feelsLike']);
return $output;
}
function sc_icon($parm)
{
$pref = e107::pref('forecasty');
$type = (empty($parm['type']) ? 'current' : $parm['type']);
$height = (empty($parm['height']) ? '82px' : $parm['height']);
$width = (empty($parm['width']) ? '82px' : $parm['width']);
$iconSet = (isset($pref['iconSet']) ? $pref['iconSet'] : 'Climacons');
$isp = e_PLUGIN.'forecasty/icons/'.$iconSet.'/';
require_once($isp.'icon_set.php');
if(!in_array($type, $this->types))
$type = 'current';
return '<img src="'.$isp.$this->var[$type]['icon'].'.'.$format.'" style="height:'.$height.'; width:'.$width.';" />';
}
function sc_condition($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['condition'];
}
function sc_oneliner($parm='')
{
$sql = e107::getDb();
$icon = $this->var['current']['icon'];
$oneliners = $sql->retrieve('forecasty_oneliners', '*', "`condition`='".$icon."' AND `vulgarity`='".e107::pref('forecasty', 'vulgarity')."'", true);
return $oneliners[array_rand($oneliners)]['line'];
}
function sc_humidity($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['humidity'];
}
function sc_windspeed($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['windSpeed'];
}
function sc_visibility($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['visibility'];
}
function sc_pressure($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['pressure'];
}
function sc_dewpoint($parm)
{
$type = (empty($parm['type']) ? 'current' : $parm['type']);
if(!in_array($type, $this->types))
$type = 'current';
return $this->var[$type]['dewPoint'];
}
}