PluginProbe
wp-forecast / 1.8
wp-forecast v1.8
10.0 trunk 1.4 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3..5 3..8 3.0 3.1 3.2 3.3 3.4 3.6 All 86 releases
wp-forecast / setup.php

setup.php in wp-forecast 1.8, at setup.php

206 lines 6.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /* This file is part of the wp-forecast plugin for wordpress */
3
4 /* Copyright 2006,2007 Hans Matzen (email : webmaster at tuxlog.de)
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21 //
22 // setting up the default options in table wp-options during
23 // plugin activation from the plugins page
24 //
25 function wp_forecast_activate()
26 {
27 global $wpf_debug;
28
29 if ($wpf_debug > 0)
30 pdebug("Start of wp_forecast_activate ()");
31
32 // add number of widgets, default: 1
33 $count=get_option("wp-forecast-count");
34
35 if ($count == "") {
36 $count="1";
37 add_option("wp-forecast-count",$count,
38 "Contains the number of wp-widgets","yes");
39 };
40
41 // add timeout for accuweather connections, default: 30
42 $timeout=get_option("wp-forecast-timeout");
43
44 if ($timeout == "") {
45 $timeout="30";
46 add_option("wp-forecast-timeout",$timeout,
47 "Timeout in seconds for accuweather connections","yes");
48 };
49 for ($i=0;$i<$count;$i++) {
50 $wpfcid = get_widget_id( $i );
51
52 // get options just in case
53 $location=get_option("wp-forecast-location".$wpfcid);
54 $locname=get_option("wp-forecast-locname".$wpfcid);
55 $refresh=get_option("wp-forecast-refresh".$wpfcid);
56 $metric=get_option("wp-forecast-metric".$wpfcid);
57 $wpf_language=get_option("wp-forecast-language".$wpfcid);
58 $daytime=get_option("wp-forecast-daytime".$wpfcid);
59 $nighttime=get_option("wp-forecast-nighttime".$wpfcid);
60 $dispconfig=get_option("wp-forecast-dispconfig".$wpfcid);
61 $windunit = get_option("wp-forecast-windunit".$wpfcid);
62 $weather = get_option("wp-forecast-cache".$wpfcid);
63 $expire = get_option("wp-forecast-expire".$wpfcid);
64 $currtime = get_option("wp-forecast-currtime".$wpfcid);
65 $title = get_option("wp-forecast-title".$wpfcid);
66
67 // if the options dont exists, add the defaults
68 if ($location == "") {
69 $location="EUR|DE|GM007|FRANKFURT AM MAIN";
70 add_option("wp-forecast-location".$wpfcid,$location,
71 "Contains the location code from accuweather","yes");
72 };
73
74 if ($locname == "") {
75 $locname="Frankfurt am Main";
76 add_option("wp-forecast-location".$wpfcid,$locname,
77 "Contains the location name to show","yes");
78 };
79
80 if ($refresh == "") {
81 $refresh="600";
82 add_option("wp-forecast-refresh".$wpfcid,$refresh,
83 "Contains the intervall the local weather data is renewed",
84 "yes");
85 };
86
87 if ($metric == "") {
88 $metric="1";
89 add_option("wp-forecast-metric".$wpfcid,$metric,
90 "1 if you want to use metric scheme, else 0","yes");
91 };
92
93 if ($wpf_language == "") {
94 $wpf_language="en_US";
95 add_option("wp-forecast-language".$wpfcid,$wpf_language,
96 "The lanugage code","yes");
97 };
98
99
100 if ($weather == "") {
101 $weather="";
102 add_option("wp-forecast-cache".$wpfcid,$weather,
103 "The weather cache","yes");
104 };
105
106 if ($expire == "") {
107 $expire="0";
108 add_option("wp-forecast-expire".$wpfcid,$expire,
109 "when weather cache expires","yes");
110 };
111 if ($daytime == "") {
112 $daytime="000000000";
113 add_option("wp-forecast-daytime".$wpfcid,$daytime,
114 "Switches for Daytime forecast","yes");
115 };
116
117 if ($nighttime == "") {
118 $nighttime="000000000";
119 add_option("wp-forecast-nighttime".$wpfcid,$nighttime,
120 "Switches for Nighttime forecast","yes");
121 };
122
123 if ($currtime == "") {
124 $currtime="1";
125 add_option("wp-forecast-currtime".$wpfcid,$currtime,
126 "1 if you want to use current time, else 0","yes");
127 };
128
129 if ($title == "") {
130 $title=__("The Weather","wp-forecast_".$wpf_language);
131 add_option("wp-forecast-title".$wpfcid,$title,
132 "Contains the widget title","yes");
133 };
134
135 // Displayconfigurationmatrix
136 // CC FC Day FC Night
137 // Icon 0 10 14
138 // Datum 18 - -
139 // Zeit 1 - -
140 // Shorttext 2 11 15
141 // Temperatur 3 12 16
142 // gef. Temp 4 - -
143 // Luftdruck 5 - -
144 // Luftfeuchte 6 - -
145 // Wind 7 13 17
146 // Windboen 22 23 24
147 // Sonnenaufgang 8 - -
148 // Sonnenuntergang 9 - -
149 // Copyright 21 - -
150 // accuweather link 25 - -
151 //
152
153 if ($dispconfig == "") {
154 $dispconfig="11111111111111111111111111";
155 add_option("wp-forecast-dispconfig".$wpfcid,$dispconfig,
156 "Switches for shown Information","yes");
157 }
158
159 if ($windunit == "") {
160 $windunit="ms";
161 add_option("wp-forecast-windunit".$wpfcid,$windunit,
162 "Choose between ms, kmh, mph or kts","yes");
163 }
164 } // end of for
165
166 if ($wpf_debug > 0)
167 pdebug("End of wp_forecast_activate ()");
168 }
169
170 //
171 // is called when plugin is deactivated and removes all
172 // the wp-forecast options from the database
173 //
174 function wp_forecast_deactivate($wpfcid)
175 {
176 global $wpf_debug;
177
178 if ($wpf_debug > 0)
179 pdebug("Start of wp_forecast_deactivate ()");
180
181 $count=get_option('wp-forecast-count');
182
183 for ($i=0;$i<$count;$i++) {
184 $wpfcid = get_widget_id( $i );
185
186 delete_option("wp-forecast-location".$wpfcid);
187 delete_option("wp-forecast-locname".$wpfcid);
188 delete_option("wp-forecast-refresh".$wpfcid);
189 delete_option("wp-forecast-metric".$wpfcid);
190 delete_option("wp-forecast-language".$wpfcid);
191 delete_option("wp-forecast-daytime".$wpfcid);
192 delete_option("wp-forecast-nighttime".$wpfcid);
193 delete_option("wp-forecast-dispconfig".$wpfcid);
194 delete_option("wp-forecast-windunit".$wpfcid);
195 delete_option("wp-forecast-cache".$wpfcid);
196 delete_option("wp-forecast-expire".$wpfcid);
197 delete_option("wp-forecast-currtime".$wpfcid);
198 delete_option("wp-forecast-title".$wpfcid);
199 }
200 delete_option('wp-forecast-timeout');
201 delete_option('wp-forecast-count');
202
203 if ($wpf_debug > 0)
204 pdebug("End of wp_forecast_deactivate ()");
205 }
206 ?>