1 | <?php |
||
11 | class Weather extends ContentType |
||
12 | { |
||
13 | const BASE_CACHE_TIME = 600; |
||
14 | const URL = 'https://api.darksky.net/forecast/%apikey%/%data%?lang=%lang%&units=%units%&exclude=hourly,daily,alerts'; |
||
15 | |||
16 | public $html = '<div class="weather">%data%</div>'; |
||
17 | public $css = '%field% { text-align: center; } %field% .wi { font-size: 0.8em; }'; |
||
18 | public $js = ''; |
||
19 | public $input = 'latlong'; |
||
20 | public $output = 'text'; |
||
21 | public $usable = true; |
||
22 | public $exemple = '@web/images/weather.preview.jpg'; |
||
23 | public $canPreview = true; |
||
24 | |||
25 | private $opts; |
||
26 | |||
27 | const ICONS = [ |
||
28 | 'clear-day' => 'wi-day-sunny', |
||
29 | 'clear-night' => 'wi-night-clear', |
||
30 | 'rain' => 'wi-rain', |
||
31 | 'snow' => 'wi-snow', |
||
32 | 'sleet' => 'wi-sleet', |
||
33 | 'wind' => 'wi-strong-wind', |
||
34 | 'fog' => 'wi-fog', |
||
35 | 'cloudy' => 'wi-cloudy', |
||
36 | 'partly-cloudy-day' => 'wi-day-cloudy', |
||
37 | 'partly-cloudy-night' => 'wi-night-cloudy', |
||
38 | 'hail' => 'wi-hail', |
||
39 | 'thunderstorm' => 'wi-lightning', |
||
40 | 'tornado' => 'wi-tornado', |
||
41 | ]; |
||
42 | |||
43 | /** |
||
44 | * Power by DarkSky : https://darksky.net/poweredby/. |
||
45 | */ |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | */ |
||
50 | public function __construct($config = []) |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function contentRules() |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function processData($data) |
||
95 | |||
96 | protected function format($w) |
||
116 | } |
||
117 |