Example #1
0
?>

<!-- Tracé des icones -->	
<?php 
$arrow = $moonpercent >= 0 && $moonpercent < 50 ? '&#10138;' : '&#10136;';
$txt = tr('Phase lunaire');
echo "<table id= 'icones' style='margin-left:auto; margin-right:auto;  margin-top:-2px; margin-bottom:0px; padding:0px '>\n\t\t<tr>\n";
echo "<td>\n";
echo "<table class='icone'>\n";
echo "<tr><td colspan='2' class='th'>{$txt}</td>\n";
echo "</tr><tr><td ><img src={$moonimg} ALT='moon' style='height:100px;vertical-align:bottom;'/></td>\n";
echo "<td style='font-size:13px;'>phase:{$moonpercent}% &nbsp; <span style='font-size:18px;'> {$arrow} </span><br>lumen:{$lumen}%</td>\n";
echo "</tr>\n";
/* Moon info */
$tinfo = tr("Autres informations");
$moonphase = new MoonPhase();
$txt0 = tr('Nouvelle lune');
$txt1 = tr('Premier quartier');
$txt2 = tr('Pleine lune');
$txt3 = tr('Dernier quartier');
$txt0 = tr('Nouvelle lune');
$date0 = date("d/m/Y H:i", $moonphase->new_moon());
$date1 = date("d/m/Y H:i", $moonphase->first_quarter());
$date2 = date("d/m/Y H:i", $moonphase->full_moon());
$date3 = date("d/m/Y H:i", $moonphase->last_quarter());
$date4 = date("d/m/Y H:i", $moonphase->next_new_moon());
echo "\n\t<tr><td class='hl'> </td>\n\t    <td class='tooltip' >\n\t\t<a href='#' class='tooltip'>\n  \t\t{$tinfo}:\t\t\n        <div >\n        <table class='info'>\n        <tr><td style='width:90px;'>{$txt0}</td><td style='text-align:center;'>{$date0}</td></tr>\n        <tr><td style='width:90px;'>{$txt1}</td><td style='text-align:center;'>{$date1}</td></tr>\n        <tr><td style='width:90px;'>{$txt2}</td><td style='text-align:center;'>{$date2}</td></tr>\n        <tr><td style='width:90px;'>{$txt3}</td><td style='text-align:center;'>{$date3}</td></tr>\n        <tr><td style='width:90px;'>{$txt0}</td><td style='text-align:center;'>{$date4}</td></tr>\n        </table>\n        </div></a>\n</td></tr></table>\n";
echo "</td>\n";
// Tracé des icones
for ($i = 0; $i < $numStations; $i++) {
    echo "<td>";
 /**
  * Compute ephemeris.
  *
  * @since    2.0.0
  */
 public function compute()
 {
     $result = array();
     $stations = $this->get_located_stations_list();
     foreach ($stations as $id => $station) {
         $lat = $station['loc_latitude'];
         $lon = $station['loc_longitude'];
         $tz = $station['loc_timezone'];
         $nm = array();
         $nm['device_id'] = $id;
         $nm['device_name'] = $station['device_name'];
         $nm['_id'] = self::get_ephemeris_virtual_id($id);
         $nm['type'] = 'NAEphemer';
         $nm['module_name'] = __('[Ephemeris]', 'live-weather-station');
         $nm['battery_vp'] = 6000;
         $nm['rf_status'] = 0;
         $nm['firmware'] = LWS_VERSION;
         $dashboard = array();
         $dashboard['time_utc'] = time();
         $dashboard['sunrise'] = date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
         $dashboard['sunset'] = date_sunset(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon);
         try {
             $datetime = new DateTime(date('Y-m-d H:i:s', time()), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $month = $datetime->format('m');
             $day = $datetime->format('d');
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise = $moon->moonrise;
             $moonset = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', time() - 86400), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise_yesterday = $moon->moonrise;
             $moonset_yesterday = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', time() + 86400), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             $moon = Moon::calculateMoonTimes($datetime->format('m'), $datetime->format('d'), $datetime->format('Y'), $lat, $lon);
             $moonrise_tomorrow = $moon->moonrise;
             $moonset_tomorrow = $moon->moonset;
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonrise_yesterday), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonrise = $moonrise_yesterday;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonset_yesterday), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonset = $moonset_yesterday;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonrise_tomorrow), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonrise = $moonrise_tomorrow;
             }
             $datetime = new DateTime(date('Y-m-d H:i:s', $moonset_tomorrow), new DateTimeZone('UTC'));
             $datetime->setTimezone(new DateTimeZone($tz));
             if ($month == $datetime->format('m') && $day == $datetime->format('d')) {
                 $moonset = $moonset_tomorrow;
             }
             $dashboard['moonrise'] = $moonrise;
             $dashboard['moonset'] = $moonset;
         } catch (Exception $ex) {
             $dashboard['moonrise'] = -9999;
             $dashboard['moonset'] = -9999;
         }
         try {
             $moon_phase = new MoonPhase();
             $dashboard['moon_age'] = round($moon_phase->age(), 3);
             $dashboard['moon_phase'] = round($moon_phase->phase(), 4);
             $dashboard['moon_illumination'] = round($moon_phase->illumination() * 100);
             $dashboard['moon_distance'] = round($moon_phase->distance());
             $dashboard['moon_diameter'] = round($moon_phase->diameter(), 9);
             $dashboard['sun_distance'] = round($moon_phase->sundistance());
             $dashboard['sun_diameter'] = round($moon_phase->sundiameter(), 9);
         } catch (Exception $ex) {
             $dashboard['moon_age'] = -9999;
             $dashboard['moon_phase'] = -9999;
             $dashboard['moon_illumination'] = -9999;
             $dashboard['moon_distance'] = -9999;
             $dashboard['moon_diameter'] = -9999;
             $dashboard['sun_distance'] = -9999;
             $dashboard['sun_diameter'] = -9999;
         }
         $nm['dashboard_data'] = $dashboard;
         $nm['data_type'] = array('sunrise', 'sunset', 'moonrise', 'moonset', 'moon_age', 'moon_phase', 'moon_illumination', 'moon_distance', 'moon_diameter', 'sun_distance', 'sun_diameter');
         if (count($nm['dashboard_data']) > 0) {
             $result[] = $nm;
         }
     }
     foreach ($result as $data) {
         $this->get_dashboard($data['device_id'], $data['device_name'], $data['_id'], $data['module_name'], $data['type'], $data['data_type'], $data['dashboard_data']);
     }
     return $result;
 }