PluginProbe
wp-forecast / 1.4
wp-forecast v1.4
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.4, at setup.php

196 lines 6.3 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 for ($i=0;$i<$count;$i++) {
42 $wpfcid = get_widget_id( $i );
43
44 // get options just in case
45 $location=get_option("wp-forecast-location".$wpfcid);
46 $locname=get_option("wp-forecast-locname".$wpfcid);
47 $refresh=get_option("wp-forecast-refresh".$wpfcid);
48 $metric=get_option("wp-forecast-metric".$wpfcid);
49 $wpf_language=get_option("wp-forecast-language".$wpfcid);
50 $daytime=get_option("wp-forecast-daytime".$wpfcid);
51 $nighttime=get_option("wp-forecast-nighttime".$wpfcid);
52 $dispconfig=get_option("wp-forecast-dispconfig".$wpfcid);
53 $windunit = get_option("wp-forecast-windunit".$wpfcid);
54 $weather = get_option("wp-forecast-cache".$wpfcid);
55 $expire = get_option("wp-forecast-expire".$wpfcid);
56 $currtime = get_option("wp-forecast-currtime".$wpfcid);
57 $title = get_option("wp-forecast-title".$wpfcid);
58
59 // if the options dont exists, add the defaults
60 if ($location == "") {
61 $location="EUR|DE|GM007|FRANKFURT AM MAIN";
62 add_option("wp-forecast-location".$wpfcid,$location,
63 "Contains the location code from accuweather","yes");
64 };
65
66 if ($locname == "") {
67 $locname="Frankfurt am Main";
68 add_option("wp-forecast-location".$wpfcid,$locname,
69 "Contains the location name to show","yes");
70 };
71
72 if ($refresh == "") {
73 $refresh="600";
74 add_option("wp-forecast-refresh".$wpfcid,$refresh,
75 "Contains the intervall the local weather data is renewed",
76 "yes");
77 };
78
79 if ($metric == "") {
80 $metric="1";
81 add_option("wp-forecast-metric".$wpfcid,$metric,
82 "1 if you want to use metric scheme, else 0","yes");
83 };
84
85 if ($wpf_language == "") {
86 $wpf_language="en_US";
87 add_option("wp-forecast-language".$wpfcid,$wpf_language,
88 "The lanugage code","yes");
89 };
90
91
92 if ($weather == "") {
93 $weather="";
94 add_option("wp-forecast-cache".$wpfcid,$weather,
95 "The weather cache","yes");
96 };
97
98 if ($expire == "") {
99 $expire="0";
100 add_option("wp-forecast-expire".$wpfcid,$expire,
101 "when weather cache expires","yes");
102 };
103 if ($daytime == "") {
104 $daytime="000000000";
105 add_option("wp-forecast-daytime".$wpfcid,$daytime,
106 "Switches for Daytime forecast","yes");
107 };
108
109 if ($nighttime == "") {
110 $nighttime="000000000";
111 add_option("wp-forecast-nighttime".$wpfcid,$nighttime,
112 "Switches for Nighttime forecast","yes");
113 };
114
115 if ($currtime == "") {
116 $currtime="1";
117 add_option("wp-forecast-currtime".$wpfcid,$currtime,
118 "1 if you want to use current time, else 0","yes");
119 };
120
121 if ($title == "") {
122 $title=__("The Weather","wp-forecast_".$wpf_language);
123 add_option("wp-forecast-title".$wpfcid,$title,
124 "Contains the widget title","yes");
125 };
126
127 // Displayconfigurationmatrix
128 // CC FC Day FC Night
129 // Icon 0 10 14
130 // Datum 18 - -
131 // Zeit 1 - -
132 // Shorttext 2 11 15
133 // Temperatur 3 12 16
134 // gef. Temp 4 - -
135 // Luftdruck 5 - -
136 // Luftfeuchte 6 - -
137 // Wind 7 13 17
138 // Windboen 22 23 24
139 // Sonnenaufgang 8 - -
140 // Sonnenuntergang 9 - -
141 // Copyright 21 - -
142 //
143
144 if ($dispconfig == "") {
145 $dispconfig="1111111111111111111111111";
146 add_option("wp-forecast-dispconfig".$wpfcid,$dispconfig,
147 "Switches for shown Information","yes");
148 }
149
150 if ($windunit == "") {
151 $windunit="ms";
152 add_option("wp-forecast-windunit".$wpfcid,$windunit,
153 "Choose between ms, kmh, mph or kts","yes");
154 }
155 } // end of for
156
157 if ($wpf_debug > 0)
158 pdebug("End of wp_forecast_activate ()");
159 }
160
161 //
162 // is called when plugin is deactivated and removes all
163 // the wp-forecast options from the database
164 //
165 function wp_forecast_deactivate($wpfcid)
166 {
167 global $wpf_debug;
168
169 if ($wpf_debug > 0)
170 pdebug("Start of wp_forecast_deactivate ()");
171
172 $count=get_option('wp-forecast-count');
173
174 for ($i=0;$i<$count;$i++) {
175 $wpfcid = get_widget_id( $i );
176
177 delete_option("wp-forecast-location".$wpfcid);
178 delete_option("wp-forecast-locname".$wpfcid);
179 delete_option("wp-forecast-refresh".$wpfcid);
180 delete_option("wp-forecast-metric".$wpfcid);
181 delete_option("wp-forecast-language".$wpfcid);
182 delete_option("wp-forecast-daytime".$wpfcid);
183 delete_option("wp-forecast-nighttime".$wpfcid);
184 delete_option("wp-forecast-dispconfig".$wpfcid);
185 delete_option("wp-forecast-windunit".$wpfcid);
186 delete_option("wp-forecast-cache".$wpfcid);
187 delete_option("wp-forecast-expire".$wpfcid);
188 delete_option("wp-forecast-currtime".$wpfcid);
189 delete_option("wp-forecast-title".$wpfcid);
190 }
191 delete_option('wp-forecast-count');
192
193 if ($wpf_debug > 0)
194 pdebug("End of wp_forecast_deactivate ()");
195 }
196 ?>