| 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 |
// location array and counter init |
| 23 |
$loc=array(); |
| 24 |
$i=0; |
| 25 |
|
| 26 |
// generic functions |
| 27 |
require_once("funclib.php"); |
| 28 |
|
| 29 |
// |
| 30 |
// delete cache if parameters are changed, to make sure |
| 31 |
// current data will be available with next call |
| 32 |
// |
| 33 |
function wp_forecast_admin_init() |
| 34 |
{ |
| 35 |
global $wpf_debug; |
| 36 |
|
| 37 |
if ($wpf_debug > 0) |
| 38 |
pdebug("Start of wp_forecast_admin_init ()"); |
| 39 |
|
| 40 |
$count = get_option('wp-forecast-count'); |
| 41 |
|
| 42 |
if ( ($_SERVER['QUERY_STRING']=="page=wp-forecast-admin.php") && |
| 43 |
(isset($_POST['info_update']) )) |
| 44 |
{ |
| 45 |
for ($i=0;$i<$count;$i++) { |
| 46 |
$wpfcid = get_widget_id( $i ); |
| 47 |
|
| 48 |
// delete cache for old location |
| 49 |
update_option("wp-forecast-expire".$wpfcid,"0"); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
if ($wpf_debug > 0) |
| 54 |
pdebug("End of wp_forecast_admin_init ()"); |
| 55 |
} |
| 56 |
|
| 57 |
// |
| 58 |
// add menuitem for options menu |
| 59 |
// |
| 60 |
function wp_forecast_admin() |
| 61 |
{ |
| 62 |
global $wpf_debug; |
| 63 |
|
| 64 |
if ($wpf_debug > 0) |
| 65 |
pdebug("Start of wp_forecast_admin ()"); |
| 66 |
|
| 67 |
|
| 68 |
if (function_exists('add_options_page')) { |
| 69 |
add_options_page('WP-Forecast', 'WP-Forecast', 6, |
| 70 |
basename(__FILE__), 'wpf_admin_form'); |
| 71 |
} |
| 72 |
|
| 73 |
if ($wpf_debug > 0) |
| 74 |
pdebug("End of wp_forecast_admin ()"); |
| 75 |
} |
| 76 |
|
| 77 |
// |
| 78 |
// print out hint for the widget control |
| 79 |
// |
| 80 |
function wpf_admin_hint($args = null) |
| 81 |
{ |
| 82 |
global $wpf_debug; |
| 83 |
|
| 84 |
if ($wpf_debug > 0) |
| 85 |
pdebug("Start of wp_admin_hint ()"); |
| 86 |
|
| 87 |
$wpfcid = $args; |
| 88 |
|
| 89 |
// get translation |
| 90 |
$locale = get_locale(); |
| 91 |
if ( empty($locale) ) |
| 92 |
$locale = 'en_US'; |
| 93 |
if(function_exists('load_textdomain')) |
| 94 |
load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo"); |
| 95 |
|
| 96 |
// code for widget title form |
| 97 |
$title = $newtitle = get_option("wp-forecast-title".$wpfcid); |
| 98 |
|
| 99 |
if ( $_POST["wpf-submit-title".$wpfcid] ) |
| 100 |
$newtitle = strip_tags(stripslashes($_POST["wpf-title-".$wpfcid])); |
| 101 |
|
| 102 |
if ( $title != $newtitle ) { |
| 103 |
$title = $newtitle; |
| 104 |
update_option('wp-forecast-title'.$wpfcid, $title); |
| 105 |
} |
| 106 |
|
| 107 |
echo __("Title:","wp-forecast_".$locale); |
| 108 |
echo " <input style='width: 250px;' id='wpf-title-". $wpfcid ."' name='wpf-title-" . $wpfcid . "' type='text' value='". $title . "' />"; |
| 109 |
echo "<input type='hidden' id='wpf-submit-title" . $wpfcid . "' name='wpf-submit-title".$wpfcid."' value='1' />"; |
| 110 |
echo "<p>".__('widget_hint',"wp-forecast_".$locale)."</p>"; |
| 111 |
|
| 112 |
if ($wpf_debug > 0) |
| 113 |
pdebug("End of wp_admin_hint ()"); |
| 114 |
} |
| 115 |
|
| 116 |
// |
| 117 |
// get the locationlist and return it in one long string |
| 118 |
// |
| 119 |
function get_loclist($uri,$loc) |
| 120 |
{ |
| 121 |
global $wpf_debug; |
| 122 |
|
| 123 |
if ($wpf_debug > 0) |
| 124 |
pdebug("Start of get_loclist ()"); |
| 125 |
|
| 126 |
$url=$uri . urlencode($loc); |
| 127 |
$xml = fetchURL($url); |
| 128 |
|
| 129 |
if ($wpf_debug > 0) |
| 130 |
pdebug("End of get_loclist ()"); |
| 131 |
|
| 132 |
return $xml; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
// |
| 137 |
// parse xml and extract locations as an array |
| 138 |
// for later us in the admin form |
| 139 |
// |
| 140 |
function get_locations($xml) |
| 141 |
{ |
| 142 |
global $wpf_debug; |
| 143 |
|
| 144 |
if ($wpf_debug > 0) |
| 145 |
pdebug("Start of get_locations ()"); |
| 146 |
|
| 147 |
// start_element() - wird vom XML-Parser bei öffnenden Tags aufgerufen |
| 148 |
function s_element( $parser, $name, $attribute ) |
| 149 |
{ |
| 150 |
global $loc,$i; |
| 151 |
if ($name == "LOCATION") { |
| 152 |
$loc[$i]=array(); |
| 153 |
$loc[$i]['city'] = $attribute['CITY']; |
| 154 |
$loc[$i]['state'] = $attribute['STATE']; |
| 155 |
$loc[$i]['location'] = $attribute['LOCATION']; |
| 156 |
$i++; |
| 157 |
} |
| 158 |
} |
| 159 |
|
| 160 |
// end_element() - dummy function |
| 161 |
function e_element( $parser, $name ){} |
| 162 |
|
| 163 |
// Instanz des XML-Parsers erzeugen |
| 164 |
$parser = xml_parser_create(); |
| 165 |
|
| 166 |
// Parameter des XML-Parsers setzen |
| 167 |
xml_parser_set_option( $parser, XML_OPTION_CASE_FOLDING, true ); |
| 168 |
|
| 169 |
// Handler für Elemente ( öffnende / schließende Tags ) setzen |
| 170 |
xml_set_element_handler( $parser, "s_element", "e_element" ); |
| 171 |
|
| 172 |
// try to parse the xml |
| 173 |
if( !xml_parse( $parser, $xml,true ) ) |
| 174 |
{ |
| 175 |
// Fehler -> Ausführung abbrechen |
| 176 |
die( "XML Fehler: " . |
| 177 |
xml_error_string( xml_get_error_code( $parser ) ) . |
| 178 |
" in Zeile " . |
| 179 |
xml_get_current_line_number( $parser ) |
| 180 |
); |
| 181 |
} |
| 182 |
|
| 183 |
// Vom XML-Parser belegten Speicher freigeben |
| 184 |
xml_parser_free( $parser ); |
| 185 |
|
| 186 |
if ($wpf_debug > 0) |
| 187 |
pdebug("End of get_locations ()"); |
| 188 |
|
| 189 |
// return locations |
| 190 |
return $loc; |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
// |
| 195 |
// form handler for the widgets |
| 196 |
// |
| 197 |
function wpf_admin_form($wpfcid='A',$widgetcall=0) |
| 198 |
{ |
| 199 |
global $wpf_debug,$wpf_maxwidgets; |
| 200 |
|
| 201 |
if ($wpf_debug > 0) |
| 202 |
pdebug("Start of wpf_admin_form ()"); |
| 203 |
|
| 204 |
$count = get_option('wp-forecast-count'); |
| 205 |
$wpf_timeout = get_option("wp-forecast-timeout"); |
| 206 |
|
| 207 |
// get locale |
| 208 |
$locale = get_locale(); |
| 209 |
if ( empty($locale) ) |
| 210 |
$locale = 'en_US'; |
| 211 |
|
| 212 |
// called via the options menu not from widgets |
| 213 |
if ($widgetcall==0) { |
| 214 |
// load translation |
| 215 |
if(function_exists('load_textdomain')) { |
| 216 |
load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo"); |
| 217 |
} |
| 218 |
|
| 219 |
// if this is a post call, number of widgets |
| 220 |
if ( isset($_POST['wpf-count-submit']) ) { |
| 221 |
$number = (int) $_POST['wpf-number']; |
| 222 |
if ( $number > $wpf_maxwidgets ) $number = $wpf_maxwidgets; |
| 223 |
if ( $number < 1 ) $number = 1; |
| 224 |
$newcount = $number; |
| 225 |
|
| 226 |
if ( $count != $newcount ) { |
| 227 |
$count = $newcount; |
| 228 |
update_option('wp-forecast-count', $count); |
| 229 |
// add missing option to database |
| 230 |
wp_forecast_activate(); |
| 231 |
// init the new number of widgets |
| 232 |
widget_wp_forecast_init($count); |
| 233 |
} |
| 234 |
} |
| 235 |
|
| 236 |
// if this is a post call, timeout |
| 237 |
if ( isset($_POST['wpf-timeout-submit']) ) { |
| 238 |
$timeout = (int) $_POST['wpf-timeout']; |
| 239 |
if ( $timeout < 0 ) $timeout = 1; |
| 240 |
|
| 241 |
if ( $wpf_timeout != $timeout ) { |
| 242 |
$wpf_timeout = $timeout; |
| 243 |
update_option('wp-forecast-timeout', $wpf_timeout); |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
// print out number of widgets selection |
| 248 |
$out = "<div class='wrap'>"; |
| 249 |
$out .= "<h2>WP-Forecast Widgets</h2>"; |
| 250 |
$out .= "<form name='options' id='options' method='post' action=''>"; |
| 251 |
$out .= "<table class='form-table'><tr><td>".__('How many wp-forecast widgets would you like?',"wp-forecast_".$locale)."</td>"; |
| 252 |
$out .= "<td><select id='wpf-number' name='wpf-number'>"; |
| 253 |
|
| 254 |
for ( $i = 1; $i <= $wpf_maxwidgets; ++$i ) { |
| 255 |
$out .= "<option value='$i' "; |
| 256 |
if ($count==$i) |
| 257 |
$out .= "selected='selected' "; |
| 258 |
$out .= ">$i</option>"; |
| 259 |
} |
| 260 |
$out .= "</select></td><td><span class='submit'><input type='submit' name='wpf-count-submit' id='wpf-count-submit' value='".attribute_escape(__('Save'),"wp-forecast_".$locale)."' /></span></td></tr>"; |
| 261 |
|
| 262 |
// print out widget selection form |
| 263 |
$out .="<tr><td>".__('Available widgets',"wp-forecast_".$locale).": </td>"; |
| 264 |
$out .="<td><select name='widgetid' size='1' >"; |
| 265 |
for ($i=0;$i<$count;$i++) { |
| 266 |
$id = get_widget_id( $i ); |
| 267 |
$out .="<option value='".$id."' "; |
| 268 |
if ( ($id==$_POST['widgetid'] and isset($_POST['set_widget'])) or |
| 269 |
(isset($_POST['info_update']) and $id==$_POST['wid']) or |
| 270 |
(isset($_POST['search_loc']) and $id==$_POST['wid']) or |
| 271 |
(isset($_POST['set_loc']) and $id==$_POST['wid'])) |
| 272 |
$out .="selected"; |
| 273 |
$out .=">".$id."</option>"; |
| 274 |
} |
| 275 |
$out .= "</select></td>"; |
| 276 |
|
| 277 |
$out .="<td><span class=\"submit\"><input type=\"submit\" name=\"set_widget\" value=\"" ; |
| 278 |
$out .=__('Select widget',"wp-forecast_".$locale)." »\" /></span></td></tr>\n"; |
| 279 |
|
| 280 |
|
| 281 |
// print out timeout input field for fsockopen |
| 282 |
// (timeout for accuweather connection) |
| 283 |
$out .= "<tr><td>".__('Timeout for accuweather connections (secs.)?',"wp-forecast_".$locale)."</td>"; |
| 284 |
$out .= "<td><input id='wpf-timeout' name='wpf-timeout' type='text' size='3' maxlength='3' value='".$wpf_timeout. "' />"; |
| 285 |
$out .= "</td><td><span class='submit'><input type='submit' name='wpf-timeout-submit' id='wpf-timeout-submit' value='".attribute_escape(__('Save'),"wp-forecast_".$locale)."' /></span></td></tr></table></form></div>\n"; |
| 286 |
|
| 287 |
echo $out; |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
// if this is a post call, select widget |
| 292 |
if (isset($_POST['set_widget']) and $widgetcall==0) |
| 293 |
$wpfcid = $_POST['widgetid']; |
| 294 |
|
| 295 |
// if this is any other post call |
| 296 |
if ( (isset($_POST['info_update']) and $widgetcall==0) or |
| 297 |
(isset($_POST['set_loc']) and $widgetcall==0) or |
| 298 |
(isset($_POST['search_loc']) and $widgetcall==0) ) |
| 299 |
$wpfcid = $_POST['wid']; |
| 300 |
|
| 301 |
// default is the first widget |
| 302 |
if ($wpfcid=="") |
| 303 |
$wpfcid="A"; |
| 304 |
|
| 305 |
// call sub form |
| 306 |
wpf_sub_admin_form($wpfcid,$widgetcall); |
| 307 |
|
| 308 |
if ($wpf_debug > 0) |
| 309 |
pdebug("End of wpf_admin_form ()"); |
| 310 |
} |
| 311 |
|
| 312 |
// |
| 313 |
// form to modify wp-forecast setup |
| 314 |
// options in wp_option: wp-forecast-location, wp-forecast-refresh |
| 315 |
// wp-forecast-metric, wp-forecast-language |
| 316 |
// wp-forecast-daytime wp-forecast-nighttime |
| 317 |
// wp-forecast-dispconfig wp-forecast-locname |
| 318 |
// |
| 319 |
// the form also has a search function to search the wright location |
| 320 |
// |
| 321 |
function wpf_sub_admin_form($wpfcid,$widgetcall) { |
| 322 |
global $loc,$wpf_debug; |
| 323 |
|
| 324 |
if ($wpf_debug > 0) |
| 325 |
pdebug("Start of wpf_sub_admin_form ()"); |
| 326 |
|
| 327 |
// uri for location search |
| 328 |
$LOC_URI="http://forecastfox.accuweather.com/adcbin/forecastfox/locate_city.asp?location="; |
| 329 |
|
| 330 |
// wp-forecast optionen aus datenbank lesen |
| 331 |
$location=get_option("wp-forecast-location".$wpfcid); |
| 332 |
$locname=get_option("wp-forecast-locname".$wpfcid); |
| 333 |
$refresh=get_option("wp-forecast-refresh".$wpfcid); |
| 334 |
$metric=get_option("wp-forecast-metric".$wpfcid); |
| 335 |
$wpf_language=get_option("wp-forecast-language".$wpfcid); |
| 336 |
$daytime=get_option("wp-forecast-daytime".$wpfcid); |
| 337 |
$nighttime=get_option("wp-forecast-nighttime".$wpfcid); |
| 338 |
$dispconfig=get_option("wp-forecast-dispconfig".$wpfcid); |
| 339 |
$windunit = get_option("wp-forecast-windunit".$wpfcid); |
| 340 |
$currtime = get_option("wp-forecast-currtime".$wpfcid); |
| 341 |
|
| 342 |
// get translation |
| 343 |
$locale = get_locale(); |
| 344 |
if ( empty($locale) ) |
| 345 |
$locale = 'en_US'; |
| 346 |
if(function_exists('load_textdomain')) |
| 347 |
load_textdomain("wp-forecast_".$locale,ABSPATH . "wp-content/plugins/wp-forecast/lang/".$locale.".mo"); |
| 348 |
|
| 349 |
|
| 350 |
// if this is a POST call, save new values |
| 351 |
if (isset($_POST['info_update'])) { |
| 352 |
$upflag=false; |
| 353 |
|
| 354 |
if ($location != $_POST["location"]) { |
| 355 |
$location = $_POST["location"]; |
| 356 |
update_option("wp-forecast-location".$wpfcid, $location); |
| 357 |
$upflag=true; |
| 358 |
} |
| 359 |
|
| 360 |
if ($locname != $_POST["locname"]) { |
| 361 |
$locname = $_POST["locname"]; |
| 362 |
update_option("wp-forecast-locname".$wpfcid, $locname); |
| 363 |
$upflag=true; |
| 364 |
} |
| 365 |
|
| 366 |
if ($refresh != $_POST["refresh"]) { |
| 367 |
$refresh = $_POST["refresh"]; |
| 368 |
update_option("wp-forecast-refresh".$wpfcid, $refresh); |
| 369 |
$upflag=true; |
| 370 |
} |
| 371 |
|
| 372 |
if ($metric != $_POST["metric"]) { |
| 373 |
$metric = $_POST["metric"]; |
| 374 |
if ($metric=="") $metric="0"; |
| 375 |
update_option("wp-forecast-metric".$wpfcid, $metric); |
| 376 |
$upflag=true; |
| 377 |
} |
| 378 |
|
| 379 |
if ($windunit != $_POST["windunit"]) { |
| 380 |
$windunit = $_POST["windunit"]; |
| 381 |
update_option("wp-forecast-windunit".$wpfcid, $windunit); |
| 382 |
$upflag=true; |
| 383 |
} |
| 384 |
|
| 385 |
if ($wpf_language != $_POST["language"]) { |
| 386 |
$wpf_language = $_POST["language"]; |
| 387 |
update_option("wp-forecast-language".$wpfcid, $wpf_language); |
| 388 |
$upflag=true; |
| 389 |
} |
| 390 |
|
| 391 |
if ($currtime != $_POST["currtime"]) { |
| 392 |
$currtime = $_POST["currtime"]; |
| 393 |
if ($currtime=="") $currtime="0"; |
| 394 |
update_option("wp-forecast-currtime".$wpfcid, $currtime); |
| 395 |
$upflag=true; |
| 396 |
} |
| 397 |
|
| 398 |
// set checkbox value to zero if not set |
| 399 |
// for forecast options |
| 400 |
$nd = array('day1','day2','day3','day4','day5','day6','day7','day8','day9','night1','night2','night3','night4','night5','night6','night7','night8','night9'); |
| 401 |
foreach ($nd as $i) { |
| 402 |
if ($_POST[$i]=="") |
| 403 |
$_POST["$i"]="0"; |
| 404 |
} |
| 405 |
|
| 406 |
// set empty checkboxes to 0 |
| 407 |
$do = array('d_c_icon','d_c_time','d_c_short','d_c_temp','d_c_real','d_c_press','d_c_humid','d_c_wind','d_c_sunrise','d_c_sunset','d_d_icon','d_d_short','d_d_temp','d_d_wind','d_n_icon','d_n_short','d_n_temp','d_n_wind','d_c_date','d_d_date','d_n_date','d_c_copyright','d_c_wgusts','d_d_wgusts','d_n_wgusts','d_c_accuweather'); |
| 408 |
foreach ($do as $i) { |
| 409 |
if ($_POST[$i]=="") |
| 410 |
$_POST["$i"]="0"; |
| 411 |
} |
| 412 |
|
| 413 |
// build config string for dispconfig and update if necessary |
| 414 |
$newdispconfig=""; |
| 415 |
foreach ($do as $i) |
| 416 |
$newdispconfig.=$_POST[$i]; |
| 417 |
|
| 418 |
if (strcmp($dispconfig,$newdispconfig) != 0) { |
| 419 |
$dispconfig = $newdispconfig; |
| 420 |
update_option("wp-forecast-dispconfig".$wpfcid, $newdispconfig); |
| 421 |
$upflag=true; |
| 422 |
} |
| 423 |
|
| 424 |
|
| 425 |
// build config string for forecast and update if necessary |
| 426 |
$newdaytime=$_POST["day1"].$_POST["day2"].$_POST["day3"].$_POST["day4"].$_POST["day5"].$_POST["day6"].$_POST["day7"].$_POST["day8"].$_POST["day9"]; |
| 427 |
|
| 428 |
if ($daytime != $newdaytime) { |
| 429 |
$daytime = $newdaytime; |
| 430 |
update_option("wp-forecast-daytime".$wpfcid, $newdaytime); |
| 431 |
$upflag=true; |
| 432 |
} |
| 433 |
// build config string for forecast and update if necessary |
| 434 |
$newnighttime=$_POST["night1"].$_POST["night2"].$_POST["night3"].$_POST["night4"].$_POST["night5"].$_POST["night6"].$_POST["night7"].$_POST["night8"].$_POST["night9"]; |
| 435 |
|
| 436 |
if ($nighttime != $newnighttime) { |
| 437 |
$nighttime = $newnighttime; |
| 438 |
update_option("wp-forecast-nighttime".$wpfcid, $newnighttime); |
| 439 |
$upflag=true; |
| 440 |
} |
| 441 |
// put message after update |
| 442 |
echo"<div class='updated'><p><strong>"; |
| 443 |
if ($upflag) |
| 444 |
echo __('Settings successfully updated',"wp-forecast_".$locale); |
| 445 |
else |
| 446 |
echo __('You have to change a field to update settings.',"wp-forecast_".$locale); |
| 447 |
|
| 448 |
echo "</strong></p></div>"; |
| 449 |
} |
| 450 |
|
| 451 |
// if this is a POST call, search locations |
| 452 |
if (isset($_POST['search_loc'])) { |
| 453 |
$xml=get_loclist($LOC_URI,$_POST["searchloc"]); |
| 454 |
$xml=utf8_encode($xml); |
| 455 |
get_locations($xml); |
| 456 |
} |
| 457 |
|
| 458 |
// if this is a POST call, set location |
| 459 |
if (isset($_POST['set_loc'])) { |
| 460 |
$location=$_POST["newloc"]; |
| 461 |
} |
| 462 |
?> |
| 463 |
|
| 464 |
<?php if ($widgetcall == 0): ?><div class="wrap"> |
| 465 |
<form method="post" action=''><?php endif; ?> |
| 466 |
<input name='wid' type='hidden' value='<?php echo $wpfcid; ?>'/> |
| 467 |
<h2><?php echo __('WP-Forecast Setup',"wp-forecast_".$locale)." (Widget ".$wpfcid.") ";?></h2> |
| 468 |
<?php if ($widgetcall == 0): ?><fieldset id="set1"><?php endif; ?> |
| 469 |
<div style="float: left; width: 49%"> |
| 470 |
<b><?php echo __('Location',"wp-forecast_".$locale)?>:</b> |
| 471 |
<input name="location" type="text" size="30" maxlength="80" value="<?php echo $location ?>"<?php if ($widgetcall==1) echo "readonly" ?> /> |
| 472 |
<?php if (isset($_POST['set_loc'])) { ?> |
| 473 |
<p><b><?php echo __('Press Update options to save new location.',"wp-forecast_".$locale)?></b></p> |
| 474 |
<?php } ?> |
| 475 |
|
| 476 |
<p><b><?php echo __('Locationname',"wp-forecast_".$locale)?>:</b> |
| 477 |
<input name="locname" type="text" size="30" maxlength="80" value="<?php echo $locname ?>" /></p> |
| 478 |
<p><b><?php echo __('Refresh cache after',"wp-forecast_".$locale)?></b> |
| 479 |
<input name="refresh" type="text" size="10" maxlength="6" value="<?php echo $refresh ?>"/> |
| 480 |
<b><?php echo __('secs.',"wp-forecast_".$locale)?></b><br /></p> |
| 481 |
<p><input type="checkbox" name="metric" value="1" <?php if ($metric=="1") echo "checked=\"checked\""?> /> <b><?php echo __('Use metric units',"wp-forecast_".$locale)?></b> |
| 482 |
</p> |
| 483 |
|
| 484 |
<p><input type="checkbox" name="currtime" value="1" <?php if ($currtime=="1") echo "checked=\"checked\""?> /> <b><?php echo __('Use current time',"wp-forecast_".$locale)?></b> |
| 485 |
</p> |
| 486 |
|
| 487 |
<p><b><?php echo __('Windspeed-Unit',"wp-forecast_".$locale)?>: </b><select name="windunit" size="1"> |
| 488 |
<option value="ms" <?php if ($windunit=="ms") echo "selected=\"selected\""?>><?php echo __('Meter/Second (m/s)',"wp-forecast_".$locale)?></option> |
| 489 |
<option value="kmh" <?php if ($windunit=="kmh") echo "selected=\"selected\""?>><?php echo __('Kilometer/Hour (km/h)',"wp-forecast_".$locale)?></option> |
| 490 |
<option value="mph" <?php if ($windunit=="mph") echo "selected=\"selected\""?>><?php echo __('Miles/Hour (mph)',"wp-forecast_".$locale)?></option> |
| 491 |
<option value="kts" <?php if ($windunit=="kts") echo "selected=\"selected\""?>><?php echo __('Knots (kts)',"wp-forecast_".$locale)?></option> |
| 492 |
</select></p> |
| 493 |
|
| 494 |
|
| 495 |
<p> |
| 496 |
<b><?php echo __('Language',"wp-forecast_".$locale)?>: </b><select name="language" size="1"> |
| 497 |
<option value="en_US" <?php if ($wpf_language=="en_US") echo "selected=\"selected\""?>>english</option> |
| 498 |
<option value="de_DE" <?php if ($wpf_language=="de_DE") echo "selected=\"selected\""?>>deutsch</option> |
| 499 |
<option value="da_DK" <?php if ($wpf_language=="da_DK") echo "selected=\"selected\""?>>dansk</option> |
| 500 |
<option value="nl_NL" <?php if ($wpf_language=="nl_NL") echo "selected=\"selected\""?>>dutch</option> |
| 501 |
<option value="fr_FR" <?php if ($wpf_language=="fr_FR") echo "selected=\"selected\""?>>french</option> |
| 502 |
<option value="it_IT" <?php if ($wpf_language=="it_IT") echo "selected=\"selected\""?>>italian</option> |
| 503 |
<option value="pt_PT" <?php if ($wpf_language=="pt_PT") echo "selected=\"selected\""?>>português</option> |
| 504 |
<option value="nb_NO" <?php if ($wpf_language=="nb_NO") echo "selected=\"selected\""?>>norwegian</option> |
| 505 |
<option value="sv_SE" <?php if ($wpf_language=="sv_SE") echo "selected=\"selected\""?>>swedish</option> |
| 506 |
|
| 507 |
</select></p> |
| 508 |
|
| 509 |
<b><?php echo __('Forecast',"wp-forecast_".$locale)?></b> |
| 510 |
<table border="1"> |
| 511 |
<tr> |
| 512 |
<td> </td> |
| 513 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 1</td> |
| 514 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 2</td> |
| 515 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 3</td> |
| 516 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 4</td> |
| 517 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 5</td> |
| 518 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 6</td> |
| 519 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 7</td> |
| 520 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 8</td> |
| 521 |
<td><?php echo __('Day',"wp-forecast_".$locale)?> 9</td> |
| 522 |
</tr> |
| 523 |
<tr><td><?php echo __('Daytime',"wp-forecast_".$locale)?></td> |
| 524 |
<td><input type="checkbox" name="day1" value="1" |
| 525 |
<?php if (substr($daytime,0,1)=="1") echo "checked=\"checked\""?> /></td> |
| 526 |
<td><input type="checkbox" name="day2" value="1" |
| 527 |
<?php if (substr($daytime,1,1)=="1") echo "checked=\"checked\""?> /></td> |
| 528 |
<td><input type="checkbox" name="day3" value="1" |
| 529 |
<?php if (substr($daytime,2,1)=="1") echo "checked=\"checked\""?> /></td> |
| 530 |
<td><input type="checkbox" name="day4" value="1" |
| 531 |
<?php if (substr($daytime,3,1)=="1") echo "checked=\"checked\""?> /></td> |
| 532 |
<td><input type="checkbox" name="day5" value="1" |
| 533 |
<?php if (substr($daytime,4,1)=="1") echo "checked=\"checked\""?> /></td> |
| 534 |
<td><input type="checkbox" name="day6" value="1" |
| 535 |
<?php if (substr($daytime,5,1)=="1") echo "checked=\"checked\""?> /></td> |
| 536 |
<td><input type="checkbox" name="day7" value="1" |
| 537 |
<?php if (substr($daytime,6,1)=="1") echo "checked=\"checked\""?> /></td> |
| 538 |
<td><input type="checkbox" name="day8" value="1" |
| 539 |
<?php if (substr($daytime,7,1)=="1") echo "checked=\"checked\""?> /></td> |
| 540 |
<td><input type="checkbox" name="day9" value="1" |
| 541 |
<?php if (substr($daytime,8,1)=="1") echo "checked=\"checked\""?> /></td> |
| 542 |
</tr> |
| 543 |
<tr><td><?php echo __('Nighttime',"wp-forecast_".$locale)?></td> |
| 544 |
<td><input type="checkbox" name="night1" value="1" |
| 545 |
<?php if (substr($nighttime,0,1)=="1") echo "checked=\"checked\""?> /></td> |
| 546 |
<td><input type="checkbox" name="night2" value="1" |
| 547 |
<?php if (substr($nighttime,1,1)=="1") echo "checked=\"checked\""?> /></td> |
| 548 |
<td><input type="checkbox" name="night3" value="1" |
| 549 |
<?php if (substr($nighttime,2,1)=="1") echo "checked=\"checked\""?> /></td> |
| 550 |
<td><input type="checkbox" name="night4" value="1" |
| 551 |
<?php if (substr($nighttime,3,1)=="1") echo "checked=\"checked\""?> /></td> |
| 552 |
<td><input type="checkbox" name="night5" value="1" |
| 553 |
<?php if (substr($nighttime,4,1)=="1") echo "checked=\"checked\""?> /></td> |
| 554 |
<td><input type="checkbox" name="night6" value="1" |
| 555 |
<?php if (substr($nighttime,5,1)=="1") echo "checked=\"checked\""?> /></td> |
| 556 |
<td><input type="checkbox" name="night7" value="1" |
| 557 |
<?php if (substr($nighttime,6,1)=="1") echo "checked=\"checked\""?> /></td> |
| 558 |
<td><input type="checkbox" name="night8" value="1" |
| 559 |
<?php if (substr($nighttime,7,1)=="1") echo "checked=\"checked\""?> /></td> |
| 560 |
<td><input type="checkbox" name="night9" value="1" |
| 561 |
<?php if (substr($nighttime,8,1)=="1") echo "checked=\"checked\""?> /></td> |
| 562 |
</tr> |
| 563 |
</table> |
| 564 |
<br /> |
| 565 |
</div> |
| 566 |
<div style="padding-left: 2%; float: left; width: 49%;"> |
| 567 |
<b><?php echo __('Display Configuration',"wp-forecast_".$locale)?></b> |
| 568 |
<table border="1"> |
| 569 |
<tr> |
| 570 |
<td> </td> |
| 571 |
<td><?php echo __('Current Conditions',"wp-forecast_".$locale)?></td> |
| 572 |
<td><?php echo __('Forecast Day',"wp-forecast_".$locale)?></td> |
| 573 |
<td><?php echo __('Forecast Night',"wp-forecast_".$locale)?></td> |
| 574 |
</tr> |
| 575 |
<tr> |
| 576 |
<td><?php echo __('Icon',"wp-forecast_".$locale)?></td> |
| 577 |
<td align='center'><input type="checkbox" name="d_c_icon" value="1" |
| 578 |
<?php if (substr($dispconfig,0,1)=="1") echo "checked=\"checked\""?> /></td> |
| 579 |
<td align='center'><input type="checkbox" name="d_d_icon" value="1" |
| 580 |
<?php if (substr($dispconfig,10,1)=="1") echo "checked=\"checked\""?> /></td> |
| 581 |
<td align='center'><input type="checkbox" name="d_n_icon" value="1" |
| 582 |
<?php if (substr($dispconfig,14,1)=="1") echo "checked=\"checked\""?> /></td> |
| 583 |
</tr> |
| 584 |
<tr> |
| 585 |
<td><?php echo __('Date',"wp-forecast_".$locale)?></td> |
| 586 |
<td align='center'><input type="checkbox" name="d_c_date" value="1" |
| 587 |
<?php if (substr($dispconfig,18,1)=="1") echo "checked=\"checked\""?> /></td> |
| 588 |
<td align='center'>n/a</td> |
| 589 |
<td align='center'>n/a</td> |
| 590 |
</tr> |
| 591 |
<tr> |
| 592 |
<td><?php echo __('Time',"wp-forecast_".$locale)?></td> |
| 593 |
<td align='center'><input type="checkbox" name="d_c_time" value="1" |
| 594 |
<?php if (substr($dispconfig,1,1)=="1") echo "checked=\"checked\""?> /></td> |
| 595 |
<td align='center'>n/a</td> |
| 596 |
<td align='center'>n/a</td> |
| 597 |
</tr> |
| 598 |
<tr> |
| 599 |
<td><?php echo __('Short Description',"wp-forecast_".$locale)?></td> |
| 600 |
<td align='center'><input type="checkbox" name="d_c_short" value="1" |
| 601 |
<?php if (substr($dispconfig,2,1)=="1") echo "checked=\"checked\""?> /></td> |
| 602 |
<td align='center'><input type="checkbox" name="d_d_short" value="1" |
| 603 |
<?php if (substr($dispconfig,11,1)=="1") echo "checked=\"checked\""?> /></td> |
| 604 |
<td align='center'><input type="checkbox" name="d_n_short" value="1" |
| 605 |
<?php if (substr($dispconfig,15,1)=="1") echo "checked=\"checked\""?> /></td> |
| 606 |
</tr> |
| 607 |
<tr> |
| 608 |
<td><?php echo __('Temperature',"wp-forecast_".$locale)?></td> |
| 609 |
<td align='center'><input type="checkbox" name="d_c_temp" value="1" |
| 610 |
<?php if (substr($dispconfig,3,1)=="1") echo "checked=\"checked\""?> /></td> |
| 611 |
<td align='center'><input type="checkbox" name="d_d_temp" value="1" |
| 612 |
<?php if (substr($dispconfig,12,1)=="1") echo "checked=\"checked\""?> /></td> |
| 613 |
<td align='center'><input type="checkbox" name="d_n_temp" value="1" |
| 614 |
<?php if (substr($dispconfig,16,1)=="1") echo "checked=\"checked\""?> /></td> |
| 615 |
</tr> |
| 616 |
<tr> |
| 617 |
<td><?php echo __('Realfeel',"wp-forecast_".$locale)?></td> |
| 618 |
<td align='center'><input type="checkbox" name="d_c_real" value="1" |
| 619 |
<?php if (substr($dispconfig,4,1)=="1") echo "checked=\"checked\""?> /></td> |
| 620 |
<td align='center'>n/a</td> |
| 621 |
<td align='center'>n/a</td> |
| 622 |
</tr> |
| 623 |
<tr> |
| 624 |
<td><?php echo __('Pressure',"wp-forecast_".$locale)?></td> |
| 625 |
<td align='center'><input type="checkbox" name="d_c_press" value="1" |
| 626 |
<?php if (substr($dispconfig,5,1)=="1") echo "checked=\"checked\""?> /></td> |
| 627 |
<td align='center'>n/a</td> |
| 628 |
<td align='center'>n/a</td> |
| 629 |
</tr> |
| 630 |
<tr> |
| 631 |
<td><?php echo __('Humidity',"wp-forecast_".$locale)?></td> |
| 632 |
<td align='center'><input type="checkbox" name="d_c_humid" value="1" |
| 633 |
<?php if (substr($dispconfig,6,1)=="1") echo "checked=\"checked\""?> /></td> |
| 634 |
<td align='center'>n/a</td> |
| 635 |
<td align='center'>n/a</td> |
| 636 |
</tr> |
| 637 |
<tr> |
| 638 |
<td><?php echo __('Wind',"wp-forecast_".$locale)?></td> |
| 639 |
<td align='center'><input type="checkbox" name="d_c_wind" value="1" |
| 640 |
<?php if (substr($dispconfig,7,1)=="1") echo "checked=\"checked\""?> /></td> |
| 641 |
<td align='center'><input type="checkbox" name="d_d_wind" value="1" |
| 642 |
<?php if (substr($dispconfig,13,1)=="1") echo "checked=\"checked\""?> /></td> |
| 643 |
<td align='center'><input type="checkbox" name="d_n_wind" value="1" |
| 644 |
<?php if (substr($dispconfig,17,1)=="1") echo "checked=\"checked\""?> /></td> |
| 645 |
</tr> |
| 646 |
<tr> |
| 647 |
<td><?php echo __('Windgusts',"wp-forecast_".$locale)?></td> |
| 648 |
<td align='center'><input type="checkbox" name="d_c_wgusts" value="1" |
| 649 |
<?php if (substr($dispconfig,22,1)=="1") echo "checked=\"checked\""?> /></td> |
| 650 |
<td align='center'><input type="checkbox" name="d_d_wgusts" value="1" |
| 651 |
<?php if (substr($dispconfig,23,1)=="1") echo "checked=\"checked\""?> /></td> |
| 652 |
<td align='center'><input type="checkbox" name="d_n_wgusts" value="1" |
| 653 |
<?php if (substr($dispconfig,24,1)=="1") echo "checked=\"checked\""?> /></td> |
| 654 |
</tr> |
| 655 |
<tr> |
| 656 |
<td><?php echo __('Sunrise',"wp-forecast_".$locale)?></td> |
| 657 |
<td align='center'><input type="checkbox" name="d_c_sunrise" value="1" |
| 658 |
<?php if (substr($dispconfig,8,1)=="1") echo "checked=\"checked\""?> /></td> |
| 659 |
<td align='center'>n/a</td> |
| 660 |
<td align='center'>n/a</td> |
| 661 |
</tr> |
| 662 |
<tr> |
| 663 |
<td><?php echo __('Sunset',"wp-forecast_".$locale)?></td> |
| 664 |
<td align='center'><input type="checkbox" name="d_c_sunset" value="1" |
| 665 |
<?php if (substr($dispconfig,9,1)=="1") echo "checked=\"checked\""?> /></td> |
| 666 |
<td align='center'>n/a</td> |
| 667 |
<td align='center'>n/a</td> |
| 668 |
</tr> |
| 669 |
<tr> |
| 670 |
<td><?php echo __('Copyright',"wp-forecast_".$locale)?></td> |
| 671 |
<td align='center'><input type="checkbox" name="d_c_copyright" value="1" |
| 672 |
<?php if (substr($dispconfig,21,1)=="1") echo "checked=\"checked\""?> /></td> |
| 673 |
<td align='center'>n/a</td> |
| 674 |
<td align='center'>n/a</td> |
| 675 |
</tr> |
| 676 |
<tr> |
| 677 |
<td><?php echo __('Link to Accuweather',"wp-forecast_".$locale)?></td> |
| 678 |
<td align='center'><input type="checkbox" name="d_c_accuweather" value="1" |
| 679 |
<?php if (substr($dispconfig,25,1)=="1") echo "checked=\"checked\""?> /></td> |
| 680 |
<td align='center'>n/a</td> |
| 681 |
<td align='center'>n/a</td> |
| 682 |
</tr> |
| 683 |
</table> |
| 684 |
<br /> |
| 685 |
</div> |
| 686 |
<?php if ($widgetcall==0): ?></fieldset><?php endif; ?> |
| 687 |
<?php |
| 688 |
if ($widgetcall ==0) |
| 689 |
echo "<div class='submit'><input type='submit' name='info_update' value='".__('Update options',"wp-forecast_".$locale)." »' /></div>"; |
| 690 |
else |
| 691 |
echo "<input type='hidden' name='info_update' value='1' />"; |
| 692 |
|
| 693 |
|
| 694 |
if ($widgetcall==0) { |
| 695 |
echo "<hr /><fieldset id=\"set2\"><legend>".__('Search location',"wp-forecast_".$locale)."</legend><br />"; |
| 696 |
|
| 697 |
if (count($loc)<=0) { |
| 698 |
echo "<p><b>".__('Searchterm',"wp-forecast_".$locale).":</b>\n"; |
| 699 |
echo "<input name=\"searchloc\" type=\"text\" size=\"30\" maxlength=\"30\" /><br /></p>\n"; |
| 700 |
if (isset($_POST['search_loc'])) { |
| 701 |
echo "<p>".__('No locations found.',"wp-forecast_".$locale)."</p>"; |
| 702 |
} else { |
| 703 |
echo "<p>".__('Please replace german Umlaute ä,ö,ü with a, o, u in your searchterm.',"wp-forecast_".$locale)."</p>"; |
| 704 |
} |
| 705 |
|
| 706 |
echo "</fieldset>\n"; |
| 707 |
echo "<div class=\"submit\">\n"; |
| 708 |
echo "<input type=\"submit\" name=\"search_loc\" value=\"" ; |
| 709 |
echo __('Search location',"wp-forecast_".$locale); |
| 710 |
echo " »\" />\n"; |
| 711 |
} else { |
| 712 |
echo "<b>".__('Search result',"wp-forecast_".$locale).": </b><select name=\"newloc\" size=\"1\">\n"; |
| 713 |
foreach ($loc as $l) { |
| 714 |
echo "<option value=\"".$l['location']."\">"; |
| 715 |
echo $l['city']."/".$l['state']; |
| 716 |
echo "</option>\n"; |
| 717 |
} |
| 718 |
echo "</select><br /><p>".__('Please select your city and press set location.',"wp-forecast_".$locale)."</p>\n"; |
| 719 |
echo "</fieldset>\n"; |
| 720 |
echo "<div class=\"submit\">\n"; |
| 721 |
echo "<input type=\"submit\" name=\"set_loc\" value=\"" ; |
| 722 |
echo __('Set location',"wp-forecast_".$locale); |
| 723 |
echo " »\" />\n"; |
| 724 |
} |
| 725 |
echo "</div></form></div>"; |
| 726 |
} |
| 727 |
|
| 728 |
if ($wpf_debug > 0) |
| 729 |
pdebug("End of wpf_sub_admin_form ()"); |
| 730 |
} |
| 731 |
?> |
| 732 |
|