Ticket #3834: weather.2.patch
File weather.2.patch, 46.3 KB (added by , 17 years ago) |
---|
-
mythplugins/mythweb/modules/weather/set_screen.php
1 <?php 2 /** 3 * Weather Screen settings 4 * 5 * @author $Author: vitaminjoe $ 6 * @license GPL 7 * 8 * @package MythWeb 9 * @subpackage Weather 10 /**/ 11 12 require_once 'includes/objects/WeatherScreen.php'; 13 14 // Load all of the known mythtv frontend hosts 15 $Settings_Hosts = array('' => t('MythWeb Session')); 16 $sh = $db->query('SELECT DISTINCT hostname 17 FROM weatherscreens 18 ORDER BY hostname'); 19 while (list($host) = $sh->fetch_row()) { 20 if (empty($host)) 21 continue; 22 $Settings_Hosts[$host] = $host; 23 } 24 $sh->finish(); 25 26 // Initialize Screens 27 rebuild_active_screens(); 28 rebuild_inactive_screens(); 29 30 // Make sure we have a valid host selected 31 if (!isset($Settings_Hosts[$_SESSION['settings']['host']])) 32 $_SESSION['settings']['host'] = reset(array_keys($Settings_Hosts)); 33 34 // Add to Active Screens 35 else if (isset($_POST['add']) && isset($_POST['host'])) { 36 if (isset($_POST['inactive_screen'])) { 37 $screen = new WeatherScreen(null); 38 $screen->initNew($_POST['inactive_screen'], $_POST['host']); 39 40 // Reload active screens 41 rebuild_active_screens(); 42 } 43 $_SESSION['settings']['host'] = $_POST['host']; 44 } 45 // Delete from Active Screens 46 else if (isset($_POST['delete']) && isset($_POST['host'])) { 47 if (isset($_POST['active_screen'])) { 48 $screen = new WeatherScreen($_POST['active_screen']); 49 $screen->deleteScreen(); 50 51 // Reload active screens 52 rebuild_active_screens(); 53 } 54 $_SESSION['settings']['host'] = $_POST['host']; 55 } 56 57 // Move screen 58 else if ((isset($_POST['move_u']) || isset($_POST['move_d'])) && isset($_POST['host'])) { 59 if (isset($_POST['active_screen'])) { 60 $screen = new WeatherScreen($_POST['active_screen']); 61 if (isset($_POST['move_u'])) $screen->move("up"); 62 if (isset($_POST['move_d'])) $screen->move("down"); 63 64 // Rebuild screens 65 rebuild_active_screens(); 66 } 67 } 68 69 // Edit Active Screen 70 else if (isset($_POST['edit']) && isset($_POST['host'])) { 71 // Cancel editting 72 if (isset($_POST['cancel_edit'])) { 73 unset($_SESSION['weather']['edit']); 74 unset($_SESSION['weather']['search']); 75 } 76 // Edit screen 77 if (isset($_POST['active_screen'])) { 78 $_SESSION['weather']['edit'] = $_POST['active_screen']; 79 } 80 // Search locations 81 if (isset($_POST['edit_search']) && (strlen($_POST['weather_search'])>0)) { 82 $_SESSION['weather']['search'] = $_POST['weather_search']; 83 } 84 // Save changes 85 if (isset($_POST['save_edit'])) { 86 $screen = new WeatherScreen($_POST['edit']); 87 // Save location changes 88 if (isset($_POST['weather_location']) && isset($_POST['weather_use_results'])) { 89 $matches = array(); 90 if (preg_match('/\(\((\d*)\)\)(.*)/', $_POST['weather_location'], $matches)) { 91 $screen->updateLocation($matches[1], $matches[2]); 92 } 93 } 94 // Save unit changes 95 if (isset($_POST['weather_units'])) 96 $screen->updateUnits($_POST['weather_units']); 97 98 // Save clears out search and edit functions 99 unset($_SESSION['weather']['edit']); 100 unset($_SESSION['weather']['search']); 101 } 102 103 $_SESSION['settings']['host'] = $_POST['host']; 104 } 105 106 107 /** 108 * refreshes the active screens array 109 /**/ 110 function rebuild_active_screens() { 111 global $db; 112 $_SESSION['weather']['active'] = array(); 113 114 $sh = $db->query('SELECT screen_id, draworder 115 FROM weatherscreens 116 WHERE hostname=? 117 ORDER BY draworder', $_SESSION['settings']['host']); 118 119 // Populate active screens 120 while(list($screen_id, $draworder) = $sh->fetch_row()) 121 $_SESSION['weather']['active'][$draworder] = $screen_id; 122 123 $sh->finish(); 124 } 125 126 /** 127 * refreshes the inactive screens array 128 /**/ 129 function rebuild_inactive_screens() { 130 global $db; 131 132 // Don't rebuild if we don't have to 133 if (!isset($_SESSION['weather']['inactive'])) 134 $_SESSION['weather']['inactive'] = array(); 135 else return; 136 137 $sh = $db->query('SELECT types 138 FROM weathersourcesettings 139 WHERE hostname=?', $_SESSION['settings']['host']); 140 141 // Populate inactive screens 142 // 143 // TODO Hardcoding these variables is probably a no-no. But all of this 144 // stuff is coded into the XML theme (weather-ui.xml). Having the 145 // module parse that seems overkill. 146 while(list($types) = $sh->fetch_row()) { 147 $scratch = explode(',', $types); 148 foreach ($scratch as $item) { 149 if ($item == "cclocation") $type_list[$item] = "Current Conditions"; 150 if ($item == "3dlocation") $type_list[$item] = "Three Day Forecast"; 151 if ($item == "6dlocation") $type_list[$item] = "Six Day Forecast"; 152 if ($item == "smdesc") $type_list[$item] = "Static Map"; 153 if ($item == "amdesc") $type_list[$item] = "Animated Map"; 154 if ($item == "swlocation") $type_list[$item] = "Severe Weather Alerts"; 155 if ($item == "18hrlocation") $type_list[$item] = "18 Hour Forecast"; 156 } 157 } 158 159 foreach ($type_list as $key => $value) 160 array_push($_SESSION['weather']['inactive'], $type_list[$key]); 161 162 $sh->finish(); 163 sort($_SESSION['weather']['inactive']); 164 } 165 166 /** 167 * displays a list of inactive screens as a <select> list 168 /**/ 169 function display_inactive_screens() { 170 if (!isset($_SESSION['weather']['inactive'])) return; 171 172 echo "<select name=\"inactive_screen\">\n"; 173 foreach ($_SESSION['weather']['inactive'] as $screen) { 174 if (! $screen->active) { 175 echo "<option>". $screen ."</option>\n"; 176 } 177 } 178 echo "</select>\n"; 179 } 180 181 /** 182 * displays a list of active screens as a <select> list 183 /**/ 184 function display_active_screens() { 185 if (!isset($_SESSION['weather']['active'])) return; 186 187 echo "<ol>\n"; 188 foreach ($_SESSION['weather']['active'] as $screen_id) { 189 $screen = new WeatherScreen($screen_id); 190 echo "\t<li><input type=\"radio\" name=\"active_screen\" value=\"". $screen->screen_id ."\">"; 191 echo $screen->container ."</li>\n"; 192 } 193 echo "</ol>"; 194 } -
mythplugins/mythweb/modules/weather/handler.php
2 2 /** 3 3 * Handler for the Weather module. 4 4 * 5 * @url $URL$6 * @date $Date$7 * @version $Revision$8 5 * @author $Author$ 9 6 * @license GPL 10 7 * … … 14 11 /**/ 15 12 16 13 // Load the weather classes 17 require_once 'includes/objects/WeatherS ite.php';18 require_once 'includes/objects/Forecast.php';14 require_once 'includes/objects/WeatherScreen.php'; 15 $WeatherScreens = array(); 19 16 20 // Default unit preference is not metric 21 if (empty($_SESSION['weather']['siunits'])) { 22 $_SESSION['weather']['siunits'] = 'NO'; 23 } 17 // Get configured WeatherScreens from the database 18 $sh = $db->query('SELECT screen_id, draworder 19 FROM weatherscreens 20 WHERE hostname=?', 21 $_SESSION['settings']['host']); 24 22 25 /** 26 * @global array $GLOBALS['Weather_Types'] 27 * @name $Weather_Types 28 /**/ 29 global $Weather_Types; 30 $Weather_Types = array(); 31 32 // Load the weather data 33 foreach (file(modules_path.'/'.module.'/weathertypes.dat') as $line) { 34 list($id, $name, $img) = explode(',', $line); 35 $Weather_Types[$id] = array($img, $name); 23 while(list($screen_id, $draworder) = $sh->fetch_row()) { 24 $WeatherScreens[$draworder] = new WeatherScreen($screen_id); 25 $WeatherScreens[$draworder]->getData(); 36 26 } 37 27 38 /** 39 * @global array $GLOBALS['WeatherSites'] 40 * @name $WeatherSites 41 /**/ 42 global $WeatherSites; 43 $WeatherSites = array(); 44 45 // Build a list of the known weather sites, starting with the session prefs 46 if ($_SESSION['weather']['locale']) 47 $WeatherSites[$_SESSION['weather']['locale']] = new WeatherSite($_SESSION['weather']['locale'], 48 t('MythWeb Session'), 49 $_SESSION['weather']['siunits']); 50 // Pull from the database next 51 $sh = $db->query('SELECT data, hostname FROM settings WHERE value="locale"'); 52 while (list($locale, $host) = $sh->fetch_row()) { 53 // New data site 54 if (empty($WeatherSites[$locale])) { 55 $siunits = $db->query_col('SELECT data 56 FROM settings 57 WHERE value="SIUnits" AND hostname=?', 58 $host); 59 $WeatherSites[$locale] = new WeatherSite($locale, $host, $siunits); 60 } 61 // Add the hostname to sites we've already seen 62 else { 63 $WeatherSites[$locale]->hosts[] = $host; 64 } 65 66 } 28 ksort($WeatherScreens); 67 29 $sh->finish(); 68 30 69 31 // Print the weather page template -
mythplugins/mythweb/modules/weather/includes/objects/WeatherScreen.php
1 <?php 2 /** 3 * WeatherScreen class for MythWeb's Weather module 4 * 5 * @author $Author: vitaminjoe $ 6 * @license GPL 7 * 8 * @package MythWeb 9 * subpackage Weather 10 * 11 /**/ 12 13 class WeatherScreen { 14 15 var $screen_id; 16 var $draworder; 17 var $container; 18 var $host; 19 var $units; 20 var $active; 21 22 var $data = array(); 23 var $search = array(); 24 25 function WeatherScreen($screen_id) { 26 global $db; 27 28 $this->screen_id = $screen_id; 29 $this->setActive(); 30 31 if ($this->active) { 32 $sh = $db->query('SELECT draworder, container, hostname, units 33 FROM weatherscreens 34 WHERE screen_id=?', 35 $this->screen_id); 36 37 list($draworder, $container, $hostname, $units) = $sh->fetch_row(); 38 39 $this->draworder = $draworder; 40 $this->container = $container; 41 $this->host = $hostname; 42 $this->units = $units; 43 } 44 } 45 46 function setActive() { 47 if ($this->checkScreenID()) $this->active = 1; 48 else $this->active = 0; 49 } 50 51 function deleteScreen() { 52 global $db; 53 54 if (! $this->checkScreenID()) return; 55 56 $db->query('DELETE 57 FROM weatherscreens 58 WHERE screen_id=? 59 AND hostname=?', 60 $this->screen_id, $this->host); 61 62 $db->query('DELETE 63 FROM weatherdatalayout 64 WHERE weatherscreens_screen_id=?', 65 $this->screen_id); 66 67 $this->active = 0; 68 $this->renumDrawOrder(); 69 70 return; 71 } 72 73 function initNew($container, $hostname) { 74 global $db; 75 76 // Get next draworder 77 $draworder = $db->query_col('SELECT MAX(draworder) 78 FROM weatherscreens 79 WHERE hostname=?', $hostname); 80 81 if ($draworder >= 0) $draworder++; 82 else $draworder = 0; 83 84 // Insert screen 85 $db->query('INSERT INTO weatherscreens 86 SET screen_id=NULL, 87 draworder=?, 88 container=?, 89 hostname=?, 90 units=0', 91 $draworder, $container, $hostname); 92 93 $this->setActive(); 94 $this->renumDrawOrder(); 95 } 96 97 function renumDrawOrder( ) { 98 global $db; 99 $i = 0; 100 101 $sh = $db->query('SELECT screen_id 102 FROM weatherscreens 103 WHERE hostname=? 104 ORDER BY draworder', 105 $this->host); 106 107 while(list($id) = $sh->fetch_row()) { 108 $db->query('UPDATE weatherscreens 109 SET draworder=? 110 WHERE hostname=? 111 AND screen_id=?', 112 $i, $this->host, $id); 113 $i++; 114 } 115 } 116 117 function move( $direction ) { 118 global $db; 119 120 if ($direction == "up") $i = -1; 121 if ($direction == "down") $i = 1; 122 123 $db->query('UPDATE weatherscreens 124 SET draworder=? 125 WHERE draworder=? 126 AND hostname=?', 127 $this->draworder, ($this->draworder+$i), $this->host); 128 129 $db->query('UPDATE weatherscreens 130 SET draworder=? 131 WHERE screen_id=? 132 AND hostname=?', 133 ($this->draworder+$i), $this->screen_id, $this->host); 134 135 $this->renumDrawOrder(); 136 } 137 138 function checkScreenID( ) { 139 global $db; 140 141 // Sanity check on screen_id 142 if ($this->screen_id >= 0) { 143 $count = $db->query_col('SELECT count(screen_id) FROM weatherscreens 144 WHERE screen_id=?', $this->screen_id); 145 if ($count == 0) return false; 146 else return true; 147 } 148 return false; 149 } 150 151 function runSearch( $needle ) { 152 global $db; 153 if (! $this->checkScreenID()) { return; } 154 155 // Build container name to types hash 156 // 157 // TODO This is not the way to do this. All of this data is stored 158 // in the weather-ui.xml file. Parsing it to get type descriptions 159 // seems overkill. 160 161 $type_hash['Animated Map'] = 'amdesc'; 162 $type_hash['Static Map'] = 'smdesc'; 163 $type_hash['Current Conditions'] = 'cclocation'; 164 $type_hash['Six Day Forecast'] = '6dlocation'; 165 $type_hash['Three Day Forecast'] = '3dlocation'; 166 $type_hash['Severe Weather Alerts'] = 'swlocation'; 167 $type_hash['18 Hour Forecast'] = '18hrlocation'; 168 169 // Run scripts that supply $this->container and search for $needle 170 $sh = $db->query('SELECT sourceid, path, types 171 FROM weathersourcesettings 172 WHERE hostname=?', 173 $this->host); 174 175 while (list($source_id, $script, $types) = $sh->fetch_row()) { 176 $types_arr = explode(',', $types); 177 foreach ($types_arr as $type) { 178 if ($type_hash[$this->container] == $type) { 179 $results = $this->runScript($script, "-l \"$needle\""); 180 if (count($results)) 181 $this->search[$source_id] = $results; 182 } 183 } 184 } 185 186 $sh->finish(); 187 } 188 189 function getData( ) { 190 global $db; 191 if (! $this->checkScreenID()) { return; } 192 193 // Find script file for this screen_id 194 $sh = $db->query('SELECT DISTINCT weathersourcesettings.path 195 FROM weathersourcesettings, weatherdatalayout 196 WHERE weatherdatalayout.weatherscreens_screen_id=? 197 AND weathersourcesettings_sourceid=weathersourcesettings.sourceid', $this->screen_id); 198 199 list($script) = $sh->fetch_row(); 200 if (!isset($script)) return; 201 202 // Find location 203 $sh = $db->query('SELECT DISTINCT location from weatherdatalayout 204 WHERE weatherscreens_screen_id='. $this->screen_id); 205 list($location) = $sh->fetch_row(); 206 207 // Generate args and run the script 208 $units = $this->units == 0 ? 'SI' : 'ENG'; 209 $output_array = $this->runScript($script, "-u ". $units ." -d ". getcwd() ."/". cache_dir ." $location"); 210 211 // Query db data items 212 $sh = $db->query('SELECT weatherdatalayout.dataitem 213 FROM weatherdatalayout,weathersourcesettings 214 WHERE weatherscreens_screen_id='. $this->screen_id .' 215 AND weathersourcesettings_sourceid=weathersourcesettings.sourceid'); 216 217 // Populate data array 218 while(list($dataitem) = $sh->fetch_row()) { 219 $this->data[$dataitem] = $output_array[$dataitem]; 220 } 221 } 222 223 function runScript( $script, $args ) { 224 $cwd = getcwd(); 225 $output_array = array(); 226 227 // Separate path and filename of script 228 $scratch = explode("/", $script); 229 $script = array_pop($scratch); 230 $path = implode("/", $scratch); 231 232 if (chdir($path)) { 233 $command = "$script $args"; 234 $output = `./$command`; 235 } else { 236 custom_error("Could not change active directory to $path.\n"); 237 } 238 239 if (! chdir($cwd)) { 240 custom_error("Could not change active directory to $cwd.\n"); 241 } 242 243 // Split script output into an array 244 $scratch = preg_split("/\n/", $output); 245 foreach ($scratch as $line) { 246 list($key, $var) = preg_split("/::/", $line); 247 if (strlen($key)) { $output_array[$key] = trim($var); } 248 } 249 250 return $output_array; 251 } 252 253 function updateLocation ( $source_id, $loc ) { 254 global $db; 255 if (! $this->checkScreenID()) { return; } 256 if (strlen($loc) <= 0) { return; } 257 258 // Does this location have settings? 259 $has_settings = $db->query_col('SELECT COUNT(weathersourcesettings_sourceid) 260 FROM weatherdatalayout 261 WHERE weatherscreens_screen_id=?', 262 $this->screen_id); 263 264 if ($has_settings) { 265 $db->query('UPDATE weatherdatalayout 266 SET location=?, weathersourcesettings_sourceid=? 267 WHERE weatherscreens_screen_id=?', 268 $loc, $source_id, $this->screen_id); 269 } else { 270 $types = $db->query_col('SELECT types 271 FROM weathersourcesettings 272 WHERE sourceid=?', 273 $source_id); 274 275 foreach(explode(',', $types) as $type) { 276 $db->query('INSERT INTO weatherdatalayout 277 ( location, dataitem, weatherscreens_screen_id, weathersourcesettings_sourceid ) 278 VALUES ( ?, ?, ?, ? )', 279 $loc, $type, $this->screen_id, $source_id); 280 } 281 } 282 } 283 284 function updateUnits( $units ) { 285 global $db; 286 if (! $this->checkScreenID()) { return; } 287 if ( ($units < 0) || ($units > 1) ) { return; } 288 289 $db->query('UPDATE weatherscreens 290 SET units=? 291 WHERE screen_id=? 292 AND hostname=?', 293 $units, $this->screen_id, $this->host); 294 295 } 296 } 297 -
mythplugins/mythweb/modules/weather/init.php
2 2 /** 3 3 * Initialization routines for the MythWeb Weather module 4 4 * 5 * @url $URL$ 6 * @date $Date$ 7 * @version $Revision$ 8 * @author $Author$ 5 * @author $Author: vitaminjoe$ 9 6 * @license GPL 10 7 * 11 8 * @package MythWeb … … 15 12 16 13 // Settings options 17 14 $Settings['weather'] = array('name' => t('Weather'), 18 'choices' => array('prefs' => t('Preferences'), 19 ), 20 'default' => 'prefs', 15 'choices' => array('screen' => 'Screen Settings'), 16 'default' => 'screen', 21 17 ); 22 18 23 19 // First, we should check to see that MythWeather is configured. 24 $has_weather = $_SESSION['locale'] 25 ? true 26 : $db->query_col('SELECT COUNT(data) 27 FROM settings 28 WHERE value="locale"'); 20 $has_weather = $db->query_col('SELECT COUNT(screen_id) 21 FROM weatherscreens'); 29 22 30 31 32 23 // If weather is enabled, add it to the list. 33 24 if ($has_weather) { 34 25 $Modules['weather'] = array('path' => 'weather', -
mythplugins/mythweb/modules/weather/tmpl/default/define_screen.php
1 <?php 2 /** 3 * Display/save MythWeather Screen settings 4 * 5 * @author $Author: vitaminjoe $ 6 * @license GPL 7 * 8 * @package MythWeb 9 * @subpackage Weather 10 * 11 /**/ 12 13 ?> 14 15 <form class="form" method="post" action="<?php echo form_action ?>"> 16 <input type="hidden" name="host" value="<?php echo html_entities($_SESSION['settings']['host']) ?>" /> 17 18 <table border="0" cellspacing="0" cellpadding="0"> 19 <tr> 20 <td colspan="2"><?php echo t('Inactive Screens') ?></td> 21 </tr> 22 <tr class="-sep"> 23 <td><?php display_inactive_screens() ?></td> 24 <td><input type="submit" class="submit" name="add" value="<?php echo t('Add To Active Screens') ?>"></td> 25 </tr> 26 </table> 27 28 <table border="0" cellspacing="0" cellpadding="0"> 29 <tr> 30 <td colspan="2"><?php echo t('Active Screens') ?></td> 31 </tr> 32 <tr> 33 <td><?php display_active_screens() ?></th> 34 <td> 35 <table border="0" cellspacing="0" cellpadding="0"> 36 <tr><td><input type="submit" class="submit" name="move_u" value="<?php echo t('Up') ?>"></td></tr> 37 <tr><td><input type="submit" class="submit" name="move_d" value="<?php echo t('Down') ?>"></td></tr> 38 <tr><td><input type="submit" class="submit" name="edit" value="<?php echo t('Edit') ?>"></td></tr> 39 <tr><td><input type="submit" class="submit" name="delete" value="<?php echo t('Delete') ?>"></td></tr> 40 </table> 41 </td> 42 </tr> 43 </table> 44 45 </form> -
mythplugins/mythweb/modules/weather/tmpl/default/set_screen.php
1 <?php 2 /** 3 * Display/save MythWeather Screen settings 4 * 5 * @author $Author: vitaminjoe $ 6 * @license GPL 7 * 8 * @package MythWeb 9 * @subpackage Weather 10 * 11 /**/ 12 ?> 13 14 <?php 15 16 // Edit screen 17 if (isset($_SESSION['weather']['edit'])) { 18 require_once('edit_screen.php'); 19 } else { 20 // Setup screens 21 require_once('define_screen.php'); 22 } 23 24 ?> 25 -
mythplugins/mythweb/modules/weather/tmpl/default/weather.am.php
1 <?php 2 /** 3 * Display template for Animated Maps for the Weather module 4 * 5 * @author $Author: vitaminjoe@gmail.com$ 6 * @license GPL 7 * 8 * @package MythWeb 9 * 10 /**/ 11 ?> 12 <div class="radar"> 13 <h2><?php echo $screen->data["amdesc"] ?></h2> 14 15 <div class="radar_image"><center> 16 <script type='text/javascript'> 17 <!-- 18 19 images = new Array(); 20 imageNum = 0; 21 speed = 3; 22 delay = 300; 23 <?php 24 $matches = array(); 25 $image = array_pop(split('/', $screen->data["animatedimage"])); 26 preg_match("/(.*)-\%1-(\d*)-(\d*)x(\d*)/", $image, $matches); 27 28 echo "imageTotal = ". $matches[2] .";\n"; 29 for ($i=0; $i<$matches[2]; $i++) { 30 echo "images[$i] = new Image();\n"; 31 echo "images[$i].src = \"/". cache_dir ."/". $matches[1] ."-$i\";\n"; 32 } 33 ?> 34 function nextFrame (inc) { 35 // display next frame from images array 36 imageNum += inc; 37 if (imageNum >= imageTotal) { 38 imageNum = 0; 39 } 40 41 imageCurrent = imageNum; 42 document.animation.src = images[imageCurrent].src; 43 } 44 45 function animate() { 46 // start animation loop 47 nextFrame(1); 48 } 49 50 function setDelay(i) { 51 speed = i; 52 delay = speed * 100; 53 if (delay == 0) delay = 50; 54 } 55 56 output = '<form name="animap" id="animap" action="get">' 57 output += '<b>Slower</b> ' 58 <?php 59 for ($i=6;$i>=0;$i-=1) { 60 echo "output += '<input type=\"radio\" name=\"speedRadio\" value=\"". $i. "\" onClick=\"setDelay(". $i .")\""; 61 if ($i == 3) { echo " checked"; } 62 echo ">'\n"; 63 } 64 ?> 65 66 output += ' <b>Faster</b><br>' 67 output += '<img name="animation" src="<?php echo "/". cache_dir ."/". $matches[1] ."-0" ?>" alt="Animation" onload="setTimeout(\'animate()\', delay)" />' 68 output += '</form>' 69 document.write(output); 70 71 // --> 72 </script> 73 </center> 74 </div> 75 </div> 76 -
mythplugins/mythweb/modules/weather/tmpl/default/weather.18h.php
1 <?php 2 /** 3 * Display template for 18 Hour Forecast for the Weather module 4 * 5 * @author $Author: vitaminjoe@gmail.com$ 6 * @license GPL 7 * 8 * @package MythWeb 9 * 10 /**/ 11 ?> 12 <p class="host"><?php 13 echo t('Host') .": ". $screen->host; 14 ?></p> 15 <p class="location"><?php 16 echo $screen->data["18hrlocation"] 17 ?></p> 18 19 <div class="forecast clearfix"> 20 <h2><?php echo $screen->container ?></h2> 21 22 <?php 23 for($i=0;$i<6;$i++) { 24 ?> 25 26 <div class="daily_forecast"> 27 <h3><?php echo $screen->data["time-$i"] ?></h3> 28 <img src="<?php echo skin_url ?>img/weather/<?php echo $screen->data["18icon-$i"] ?>" class="alpha_png" /> 29 30 <div class="temps"> 31 <div class="high"> 32 <p class="temp"> 33 <?php echo $screen->data["temp-$i"] == 'NA' ? '' : $screen->data["temp-$i"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 34 </p> 35 </div> 36 </div> 37 </div> 38 <?php } ?> 39 </div> 40 -
mythplugins/mythweb/modules/weather/tmpl/default/weather.php
21 21 // Print the page header 22 22 require 'modules/_shared/tmpl/'.tmpl.'/header.php'; 23 23 24 // Print Information for each of the known weather sites. 25 foreach ($WeatherSites as $accid => $site) { 24 // Print Information for each of the screensa 26 25 ?> 27 26 <div class="weather_site"> 28 <p class="host"><?php29 echo tn('Host', 'Hosts', count($site->hosts)), ': ',30 implode(', ', $site->hosts);31 ?></p>32 <p class="location"><?php33 echo "$site->acid: $site->city, ",34 ($site->subdiv ? "$site->subdiv, " : ''),35 $site->country;36 ?></p>37 38 <div class="current_conditions clearfix">39 <h2><?php echo t('Current Conditions') ?>:</h2>40 41 <div class="overview">42 <img src="<?php echo skin_url ?>img/weather/<?php echo $site->ConditionImage ?>" class="alpha_png" />43 <h3><?php echo $site->ConditionText ?></h3>44 <p class="temp">45 <?php echo $site->Temperature ?>°<sup><?php echo (strcasecmp($site->use_metric, 'YES') == 0) ? 'C' : 'F' ?></sup>46 </p>47 </div>48 49 <table border="0" cellspacing="0" cellpadding="0">50 <tr>51 <th><?php echo t('Humidity') ?></th>52 <td><?php echo $site->Humidity ?>%</td>53 </tr><tr>54 <th><?php echo t('Pressure') ?></th>55 <td><?php echo $site->BarometricPressure; if($site->use_metric == "YES") echo " cm"; else echo " in" ?> </td>56 </tr><tr>57 <th><?php echo t('Wind') ?></th>58 <td><?php echo $site->WindDirection . t(' at ') . $site->WindSpeed; if($site->use_metric == "YES") echo " kph"; else echo " mph" ?></td>59 </tr><tr>60 <th><?php echo t('Visibility') ?></th>61 <td><?php echo $site->Visibility; if($site->use_metric == "YES") echo " km"; else echo " mi" ?></td>62 </tr><tr>63 <th><?php echo t('Wind Chill') ?></th>64 <td class="temp"><?php echo $site->Real.'°<sup>';65 echo (strcasecmp($site->use_metric, 'YES') == 0) ? 'C' : 'F';66 ?></sup></td>67 </tr><tr>68 <th><?php echo t('UV Index') ?></th>69 <td><?php70 echo $site->UV . " (";71 if ($site->UV < 3) echo t('UV Minimal');72 elseif ($site->UV < 6) echo t('UV Moderate');73 elseif ($site->UV < 8) echo t('UV High');74 else echo t('UV Extreme');75 ?>)</td>76 </tr>77 </table>78 </div>79 80 <div class="forecast clearfix">81 <h2><?php echo t('Forecast') ?>:</h2>82 83 27 <?php 84 for ($i=0; $i<6; $i++) { 85 $forecast = $site->Forecast[$i]; 86 if (!$forecast) 87 break; 28 foreach ($WeatherScreens as $screen) { 29 if ($screen->container == "Current Conditions") 30 require tmpl_dir.'weather.cc.php'; 31 if ($screen->container == "18 Hour Forecast") 32 require tmpl_dir.'weather.18h.php'; 33 if ($screen->container == "Three Day Forecast") 34 require tmpl_dir.'weather.3d.php'; 35 if ($screen->container == "Six Day Forecast") 36 require tmpl_dir.'weather.6d.php'; 37 if ($screen->container == "Animated Map") 38 require_once tmpl_dir.'weather.am.php'; 39 } 88 40 ?> 89 <div class="daily_forecast">90 <h3><?php91 92 $today = date("m/d/Y");93 $tomorrow = date("m/d/Y", mktime(0, 0, 0, date("m") , date("d")+1, date("Y")));94 95 switch($forecast->dayofweek) {96 case 0: $day = t('Sunday'); break;97 case 1: $day = t('Monday'); break;98 case 2: $day = t('Tuesday'); break;99 case 3: $day = t('Wednesday'); break;100 case 4: $day = t('Thursday'); break;101 case 5: $day = t('Friday'); break;102 case 6: $day = t('Saturday'); break;103 default: $day = $forecast->date; break;104 }105 106 if ($forecast->date == $today)107 echo t('Today')." ($day)";108 elseif ($forecast->date == $tomorrow)109 echo t('Tomorrow')." ($day)";110 else111 echo $day;112 113 ?></h3>114 115 <img src="<?php echo skin_url ?>img/weather/<?php echo $forecast->DescImage ?>" class="alpha_png" />116 117 <h3><?php echo $forecast->DescText ?></h3>118 119 <div class="temps">120 <div class="low">121 <p><?php echo t('Low') ?></p>122 <p class="temp">123 <?php echo $forecast->LowTemperature ?>°<sup><?php echo (strcasecmp($site->use_metric, 'YES') == 0) ? 'C' : 'F' ?></sup>124 </p>125 </div>126 <div class="high">127 <p><?php echo t('High') ?></p>128 <p class="temp">129 <?php echo $forecast->HighTemperature ?>°<sup><?php echo (strcasecmp($site->use_metric, 'YES') == 0) ? 'C' : 'F' ?></sup>130 </p>131 </div>132 </div>133 </div>134 <?php } ?>135 136 </div>137 138 <div class="radar">139 140 <h2><?php echo t('Radar') ?>:</h2>141 142 <div class="radar_image">143 <img src="<?php echo $site->RadarImage ?>" />144 </div>145 146 </div>147 148 <p class="last_updated">149 <?php echo t('Last Updated') ?>: <?php echo $site->LastUpdated ?>150 </p>151 41 </div> 42 152 43 <?php 153 }154 44 155 45 // Print the page footer 156 46 require 'modules/_shared/tmpl/'.tmpl.'/footer.php'; -
mythplugins/mythweb/modules/weather/tmpl/default/weather.cc.php
1 <?php 2 /** 3 * Display template for Current Conditions for the Weather module 4 * 5 * @author $Author: vitaminjoe@gmail.com$ 6 * @license GPL 7 * 8 * @package MythWeb 9 * 10 /**/ 11 ?> 12 <p class="host"><?php 13 echo t('Host') .": ". $screen->host; 14 ?></p> 15 <p class="location"><?php 16 echo $screen->data["cclocation"] 17 ?></p> 18 19 <div class="current_conditions clearfix"> 20 <h2><?php echo t($screen->container) ?></h2> 21 22 <div class="overview"> 23 <img src="<?php echo skin_url ?>img/weather/<?php echo $screen->data["weather_icon"] ?>" class="alpha_png" /> 24 <h3><?php echo $screen->data["weather"] ?></h3> 25 <p class="temp"> 26 <?php echo $screen->data["temp"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 27 </p> 28 </div> 29 30 <table border="0" cellspacing="0" cellpadding="0"> 31 <tr> 32 <th><?php echo t('Humidity') ?></th> 33 <td><?php echo $screen->data["relative_humidity"] ?>%</td> 34 </tr><tr> 35 <th><?php echo t('Pressure') ?></th> 36 <td><?php echo $screen->data["pressure"]; echo $screen->units == 0 ? ' mb' : ' in' ?></td> 37 </tr><tr> 38 <th><?php echo t('Wind') ?></th> 39 <td><?php echo $screen->data["wind_dir"] . t(' at ') . $screen->data["wind_spdgst"] ?></td> 40 </tr><tr> 41 <th><?php echo t('Visibility') ?></th> 42 <td><?php echo $screen->data["visibility"]; echo $screen->units == 0 ? ' km' : ' mi' ?></td> 43 </tr><tr> 44 <th><?php echo t('Wind Chill') ?></th> 45 <td><?php echo $screen->data["appt"] . '°<sup>'; echo $screen->units == 0 ? 'C' : 'F' ?></sup></td> 46 </tr><tr> 47 <td colspan="2"><?php echo $screen->data["observation_time"] ?></td> 48 </tr> 49 </table> 50 </div> 51 -
mythplugins/mythweb/modules/weather/tmpl/default/edit_screen.php
1 <?php 2 /** 3 * Display/save MythWeather Screen settings 4 * 5 * @author $Author: vitaminjoe $ 6 * @license GPL 7 * 8 * @package MythWeb 9 * @subpackage Weather 10 * 11 /**/ 12 13 if (isset($_SESSION['weather']['edit'])) 14 $screen = new WeatherScreen($_SESSION['weather']['edit']); 15 $screen->getData(); 16 17 if (isset($_SESSION['weather']['search'])) 18 $screen->runSearch($_SESSION['weather']['search']); 19 ?> 20 21 <form class="form" method="post" action="<?php echo form_action ?>"> 22 <input type="hidden" name="host" value="<?php echo html_entities($_SESSION['settings']['host']) ?>" /> 23 <input type="hidden" name="edit" value="<?php echo $screen->screen_id ?>" /> 24 25 <table border="0" cellspacing="0" cellpadding="0"> 26 <tr> 27 <td colspan="2"><?php echo t('Edit Screen') ?></td> 28 </tr> 29 <tr> 30 <th>Screen Name</th> 31 <td><?php echo $screen->container ?></td> 32 </tr> 33 <tr> 34 <th>Location</th> 35 <td><?php 36 foreach($screen->data as $key => $value) { 37 if (preg_match('/location/', $key)) echo $value; 38 if (preg_match('/desc/', $key)) echo $value; 39 } 40 41 ?></td> 42 </tr> 43 44 <?php if (isset($_SESSION['weather']['search'])) { ?> 45 <tr> 46 <th>Search Results</th> 47 <?php if (count($screen->search)) { ?> 48 <td><select name="weather_location" size="1"><?php 49 foreach($screen->search as $key => $value) { 50 foreach ($value as $location => $description) { 51 echo "<option value=\"(($key))$location\">". htmlentities($description) ."</option>\n"; 52 } 53 } 54 ?></select> 55 </td> 56 </tr> 57 <tr> 58 <th><input type="checkbox" name="weather_use_results"></th> 59 <td>Use selected location</td> 60 </tr> 61 <?php } else { ?> 62 <td>Nothing found for "<i><?php echo $_SESSION['weather']['search'] ?></i>"</td> 63 <?php } } ?> 64 </tr> 65 <tr> 66 <th>Change Location</th> 67 <td><input type="text" name="weather_search" size="15" value="<?php echo $_SESSION['weather']['search'] ?>"> <input type="submit" class="submit" name="edit_search" value="<?php echo t('Search') ?>"></td> 68 </tr> 69 <tr> 70 <th>Units</th> 71 <td><select name="weather_units"> 72 <option value="0" <?php echo $screen->units == 0 ? 'SELECTED' : '' ?>>SI</option> 73 <option value="1" <?php echo $screen->units == 1 ? 'SELECTED' : '' ?>>English</option> 74 </select> 75 </td> 76 </tr> 77 <tr> 78 <th></th> 79 <td> 80 <input type="submit" class="submit" name="save_edit" value="<?php echo t('Save') ?>"> 81 <input type="submit" class="submit" name="cancel_edit" value="<?php echo t('Cancel') ?>"> 82 </td> 83 </tr> 84 </table> 85 86 </form> -
mythplugins/mythweb/modules/weather/tmpl/default/weather.3d.php
1 <?php 2 /** 3 * Display template for Six 6 Forecast for the Weather module 4 * 5 * @author $Author: vitaminjoe@gmail.com$ 6 * @license GPL 7 * 8 * @package MythWeb 9 * 10 /**/ 11 ?> 12 <p class="host"><?php 13 echo t('Host') .": ". $screen->host; 14 ?></p> 15 <p class="location"><?php 16 echo $screen->data["3dlocation"] 17 ?></p> 18 19 <div class="forecast clearfix"> 20 <h2><?php echo $screen->container ?></h2> 21 22 <?php 23 for($i=0;$i<3;$i++) { 24 ?> 25 26 <div class="daily_forecast"> 27 <h3><?php echo $screen->data["date-$i"] ?></h3> 28 <img src="<?php echo skin_url ?>img/weather/<?php echo $screen->data["icon-$i"] ?>" class="alpha_png" /> 29 30 <div class="temps"> 31 <div class="low"> 32 <p><?php echo t('Low') ?></p> 33 <p class="temp"> 34 <?php echo $screen->data["low-$i"] == 'NA' ? '' : $screen->data["low-$i"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 35 </p> 36 </div> 37 38 <div class="high"> 39 <p><?php echo t('High') ?></p> 40 <p class="temp"> 41 <?php echo $screen->data["high-$i"] == 'NA' ? '' : $screen->data["high-$i"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 42 </p> 43 </div> 44 </div> 45 </div> 46 <?php } ?> 47 </div> 48 -
mythplugins/mythweb/modules/weather/tmpl/default/weather.6d.php
1 <?php 2 /** 3 * Display template for Six 6 Forecast for the Weather module 4 * 5 * @author $Author: vitaminjoe@gmail.com$ 6 * @license GPL 7 * 8 * @package MythWeb 9 * 10 /**/ 11 ?> 12 <p class="host"><?php 13 echo t('Host') .": ". $screen->host; 14 ?></p> 15 <p class="location"><?php 16 echo $screen->data["6dlocation"] 17 ?></p> 18 19 <div class="forecast clearfix"> 20 <h2><?php echo $screen->container ?></h2> 21 22 <?php 23 for($i=0;$i<6;$i++) { 24 ?> 25 26 <div class="daily_forecast"> 27 <h3><?php echo $screen->data["date-$i"] ?></h3> 28 <img src="<?php echo skin_url ?>img/weather/<?php echo $screen->data["icon-$i"] ?>" class="alpha_png" /> 29 30 <div class="temps"> 31 <div class="low"> 32 <p><?php echo t('Low') ?></p> 33 <p class="temp"> 34 <?php echo $screen->data["low-$i"] == 'NA' ? '' : $screen->data["low-$i"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 35 </p> 36 </div> 37 38 <div class="high"> 39 <p><?php echo t('High') ?></p> 40 <p class="temp"> 41 <?php echo $screen->data["high-$i"] == 'NA' ? '' : $screen->data["high-$i"] ?>°<sup><?php echo $screen->units == 0 ? 'C' : 'F' ?></sup> 42 </p> 43 </div> 44 </div> 45 </div> 46 <?php } ?> 47 </div> 48 -
mythplugins/mythweb/modules/_shared/lang/English.lang
34 34 "Aborted" 35 35 "Aborting" 36 36 "Action" 37 "Active Screens" 37 38 "Activate" 38 39 "Add" 39 40 "Add Album to Current Playlist" … … 41 42 "Add Song to Current Playlist" 42 43 "add string" 43 44 "Add this Playlist as a Subplaylist" 45 "Add To Active Screens" 44 46 "Additional Tables" 45 47 "Admin Key" 46 48 "Advanced" … … 70 72 Allo Ciné 71 73 "An error occured while adding your playlist." 72 74 "and" 75 "Animated Map" 73 76 "Any" 74 77 "Any Category" 75 78 "Any Channel" … … 153 156 "Create Schedule" 154 157 "Current Conditions" 155 158 "Current recordings" 159 "Current path" 156 160 "Currently Browsing: $1" 157 161 "Currently Recording: Edit" 158 162 "Custom" … … 164 168 "Deactivated" 165 169 "Default" 166 170 "Default MythVideo View" 171 "Default view size" 167 172 "Delete" 168 173 "delete" 169 174 "Delete $1" … … 197 202 "Edit existing group" 198 203 "Edit keybindings on" 199 204 "Edit MythWeb and some MythTV settings." 205 "Edit Screen" 200 206 "Edit settings for" 201 207 "Edit settings for: $1" 202 208 "Editing " … … 242 248 "freqid" 243 249 "Friday" 244 250 "Frontends" 251 "Gallery" 252 "Gallery image path" 245 253 "generic_date" 246 254 %a %b %e, %Y 247 255 "generic_time" … … 269 277 "Hide" 270 278 "High" 271 279 "Home" 280 "Horizontal screen resolution" 272 281 "Host" 273 282 "Hosted by" 274 283 "Hosts" … … 276 285 "Hour Format" 277 286 "hue" 278 287 "Humidity" 288 "Images per page" 279 289 "IMDB" 280 290 "imdb rating" 281 291 "IMDBTYPE" 282 292 Imdb 283 293 "Inactive" 294 "Inactive Screens" 284 295 "info: activate recording" 285 296 Force this specific showing to record. 286 297 "info: default recording" … … 318 329 "length" 319 330 "Length" 320 331 "Length (min)" 332 "List of allowed image formats" 333 "List of available view sizes" 321 334 "Listing "Jump to"" 322 335 "Listing Time Key" 323 336 "Listings" … … 367 380 "mythvideo.sort_ignores_case" 368 381 "MythWeb" 369 382 "MythWeb Defaults" 383 "MythWeb Gallery." 370 384 "MythWeb Global Defaults" 371 385 "MythWeb Session" 372 386 "MythWeb session settings" … … 401 415 "Number of shows" 402 416 "Number of Songs" 403 417 "Number of timeslots" 418 "of" 404 419 "Only display favourite channels" 405 420 "Only match commercial-free channels" 406 421 "Only match HD programs" … … 415 430 "Past Month" 416 431 "Past Week" 417 432 "Past Year" 433 "Path where the thumbnails are" 418 434 "Paused" 419 435 "Pending" 420 436 "People" … … 628 644 things up if you're not careful, and short of restoring the database from 629 645 a backup, there is <b>no</b> way to undo your changes. 630 646 "settings: overview" 647 "Severe Weather Alerts" 631 648 "Shift" 632 649 "Show" 633 650 "Show descriptions on new line" … … 640 657 "Shows" 641 658 "SI Units" 642 659 "SI Units?" 660 "Six Day Forecast" 643 661 "Skip Ahead" 644 662 "Skip Back" 645 663 "Songs" … … 654 672 "Start Early" 655 673 "Start Time" 656 674 "Starting" 675 "Static Map" 657 676 "Statistics" 658 677 "Stats" 659 678 "Status" … … 674 693 "Sunday" 675 694 "Surround Sound" 676 695 "Tab" 696 "Switch view mode" 677 697 "The requested recording schedule has been deleted." 678 698 "There are no items in this Playlist!" 679 699 "There was a problem saving your playlist" 680 700 "This playlist is already loaded!" 681 701 "This will overwrite your current, unsaved playlist. Are you sure you want to continue?" 702 "Three Day Forecast" 682 703 "Thursday" 683 704 "Time" 684 705 "Time Span" … … 690 711 "Title Match" 691 712 "Title search" 692 713 "Title Search" 714 "to" 693 715 "Today" 694 716 "Tomorrow" 695 717 "Too Many" … … 784 806 "Wednesday" 785 807 "welcome: backend_log" 786 808 Show the server logs. 809 "welcome: gallery" 810 Browse your picture collection. 787 811 "welcome: music" 788 812 Browse your music collection. 789 813 "welcome: remote"