Dotclear

Changeset 2683


Ignore:
Timestamp:
09/30/10 08:22:11 (12 years ago)
Author:
Tomtom33
Message:

lunarPhase 1.1-RC1:

  • Added new calc method more accurate for moon phases
  • Added few information
Location:
plugins/lunarPhase/trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • plugins/lunarPhase/trunk/_define.php

    r1634 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1616          /* Name */               'lunarPhase', 
    1717          /* Description */        'Display the moon phases', 
    18           /* Author */             'Tomtom (http://plugins.zenstyle.fr)', 
    19           /* Verion */             '1.0.5', 
     18          /* Author */             'Tomtom (http://blog.zenstyle.fr)', 
     19          /* Verion */             '1.1-RC1', 
    2020          /* Premission */         'usage,contentadmin' 
    2121); 
  • plugins/lunarPhase/trunk/_prepend.php

    r1634 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1111# -- END LICENSE BLOCK ------------------------------------ 
    1212 
     13if (!defined('DC_RC_PATH')) { return; } 
     14 
    1315$__autoload['lunarPhase'] = dirname(__FILE__).'/inc/class.lunarphase.php'; 
    1416 
  • plugins/lunarPhase/trunk/_public.php

    r1634 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1818{ 
    1919     /** 
    20       * This function add CSS file in the public header 
    21       */ 
     20     This function add CSS file in the public header 
     21     */ 
    2222     public static function addCss() 
    2323     { 
    2424          global $core; 
    25  
    26           $url = $core->blog->url.'pf='.basename(dirname(__FILE__)).'/style.css'; 
     25           
     26          $url = $core->blog->getQMarkURL().'pf='.basename(dirname(__FILE__)).'/style.css'; 
    2727           
    2828          echo '<link rel="stylesheet" media="screen" type="text/css" href="'.$url.'" />'; 
     
    3333{ 
    3434     /** 
    35       * Displays lunarphase widget 
    36       * 
    37       * @param object    w 
    38       * 
    39       * @return     string 
    40       */ 
     35     Displays lunarphase widget 
     36      
     37     @param    object    w 
     38     @return   string 
     39     */ 
    4140     public static function widget($w) 
    4241     { 
    4342          global $core; 
    44  
    45           $lp = new lunarPhase($core,$w); 
    46  
     43           
     44          $lp = new lunarPhase(); 
     45           
     46          $ul_mask = '<ul class="%2$s">%1$s</ul>'; 
     47          $li_mask = '<li class="%2$s">%1$s</li>'; 
     48           
    4749          if ($w->homeonly && $core->url->type != 'default') { 
    4850               return; 
    4951          } 
    50  
     52           
    5153          $res = strlen($w->title) > 0 ? '<h2>'.$w->title.'</h2>' : ''; 
    52  
    53           $res .= 
    54                '<h3>'.__('In live').'</h3>'. 
    55                '<ul class="lunarphase">'. 
    56                lunarPhasePublic::setLine($lp->getPhase(),$w,'live'). 
    57                '</ul>'. 
    58                '<h3>'.__('Previsions').'</h3>'. 
    59                '<ul class="lunarphase">'; 
    60           foreach ($lp->getPrevisions() as $prevision) { 
    61                $mode = (!strpos($prevision->id,'moon')) ? 'illumination' : 'previsions'; 
    62                $res .= lunarPhasePublic::setLine($prevision,$w,$mode); 
    63           } 
    64           $res .= 
    65                '</ul>'. 
    66                '</div>'; 
    67  
    68           return  
     54           
     55          # Get live content 
     56          $res .= lunarPhasePublic::getLive($w,$lp); 
     57          # Get prevision content 
     58          $res .= lunarPhasePublic::getPrevisions($w,$lp); 
     59                
     60          return 
    6961               '<div id="lunarphase">'. 
    7062               $res. 
    7163               '</div>'; 
    7264     } 
    73  
    74      /** 
    75       * Returns each line of the item list 
    76       * 
    77       * @param object    obj 
    78       * @param object    w 
    79       * @param string    mode 
    80       * 
    81       * @return     string 
    82       */ 
    83      public static function setLine($obj,$w,$mode) 
     65      
     66     public static function getLive($w,$lp) 
    8467     { 
    85           $item = '<li class="%1$s">%2$s</li>'."\n"; 
    86           $str = preg_replace(array('/%days%/','/%date%/'),array('%1$s','%2$s'),$w->{$obj->id}); 
     68          $ul_mask = '<ul class="%2$s">%1$s</ul>'; 
     69          $li_mask = '<li class="%2$s">%1$s</li>'; 
     70          $live = $lp->getLive(); 
     71          $res = ''; 
    8772           
    88           if ($mode == 'previsions') { 
    89                $text = sprintf($str,$obj->days,$obj->date); 
     73          # Phase 
     74          if ($w->phase) { 
     75               $res .= sprintf($li_mask,$live['name'],$live['id']); 
    9076          } 
    91           elseif ($mode == 'illumination') { 
    92                $text = sprintf($w->{$obj->id},$obj->value); 
     77          # Illumination 
     78          if ($w->illumination) { 
     79               $res .= 
     80               sprintf($li_mask,sprintf(__('Illumination: %s%%'), 
     81               lunarPhasePublic::formatValue('percent',$live['illumination'])), 
     82               'illumination'); 
    9383          } 
    94           elseif ($mode == 'live') { 
    95                $text = $obj->name; 
     84          # Moon's age 
     85          if ($w->age) { 
     86               $res .= 
     87               sprintf($li_mask,sprintf(__('Age of moon: %s days'), 
     88               lunarPhasePublic::formatValue('int',$live['age'])), 
     89               'age'); 
    9690          } 
    97           else { 
    98                $text = ''; 
     91          # Distance from earth 
     92          if ($w->dist_to_earth) { 
     93               $res .= 
     94               sprintf($li_mask,sprintf(__('Distance to earth: %s km'), 
     95               lunarPhasePublic::formatValue('int',$live['dist_to_earth'])), 
     96               'dist_to_earth'); 
     97          }          
     98          # Distance from sun 
     99          if ($w->dist_to_sun) { 
     100               $res .= 
     101               sprintf($li_mask,sprintf(__('Distance to sun: %s km'), 
     102               lunarPhasePublic::formatValue('int',$live['dist_to_sun'])), 
     103               'dist_to_sun'); 
    99104          } 
    100  
    101           return !empty($text) ? sprintf($item,$obj->id,$text) : ''; 
     105          # Moon's angle 
     106          if ($w->moon_angle) { 
     107               $res .= 
     108               sprintf($li_mask,sprintf(__('Angle of moon: %s deg'), 
     109               lunarPhasePublic::formatValue('deg',$live['moon_angle'])), 
     110               'moon_angle'); 
     111          } 
     112          # Sun's angle 
     113          if ($w->sun_angle) { 
     114               $res .= 
     115               sprintf($li_mask,sprintf(__('Angle of sun: %s deg'), 
     116               lunarPhasePublic::formatValue('deg',$live['sun_angle'])), 
     117               'sun_angle'); 
     118          } 
     119          # Parallax 
     120          if ($w->parallax) { 
     121               $res .= 
     122               sprintf($li_mask,sprintf(__('Parallax: %s deg'), 
     123               lunarPhasePublic::formatValue('deg',$live['parallax'])), 
     124               'parallax'); 
     125          } 
     126           
     127          if (strlen($res) > 0) { 
     128               return 
     129               '<h3>'.__('In live').'</h3>'. 
     130               sprintf($ul_mask,$res,'lunarphase'); 
     131          } 
     132     } 
     133      
     134     public static function getPrevisions($w,$lp) 
     135     { 
     136          $ul_mask = '<ul class="%2$s">%1$s</ul>'; 
     137          $li_mask = '<li class="%2$s">%1$s</li>'; 
     138          $res = ''; 
     139           
     140          if ($w->previsions) { 
     141               foreach ($lp->getPrevisions() as $k => $v) { 
     142                    $res .= sprintf($li_mask,lunarPhasePublic::formatValue('date',$v),$k); 
     143               } 
     144          } 
     145           
     146          if (strlen($res) > 0) { 
     147               return 
     148               '<h3>'.__('Previsions').'</h3>'. 
     149               sprintf($ul_mask,$res,'lunarphase'); 
     150          } 
     151     } 
     152      
     153     public static function formatValue($type = '',$value) 
     154     { 
     155          $res = ''; 
     156          $format = $GLOBALS['core']->blog->settings->system->date_format.' - '; 
     157          $format .= $GLOBALS['core']->blog->settings->system->time_format; 
     158           
     159          switch ($type) { 
     160               case 'int': 
     161                    $res = number_format($value,0); 
     162                    break; 
     163               case 'float': 
     164                    $res = number_format($value,2); 
     165                    break; 
     166               case 'percent': 
     167                    $res = number_format($value * 100,0); 
     168                    break; 
     169               case 'date': 
     170                    $res = dt::str($format,$value); 
     171                    break; 
     172               case 'deg': 
     173                    $res = number_format(($value * (180.0 / M_PI)),2); 
     174                    break; 
     175               default: 
     176                    $res = $value; 
     177                    break; 
     178          } 
     179           
     180          return $res; 
    102181     } 
    103182} 
  • plugins/lunarPhase/trunk/_widgets.php

    r1716 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1717class lunarPhaseWidgets 
    1818{ 
    19      /** 
    20       * This function create a new lunarPhase widget 
    21       * 
    22       * @param object    w 
    23       */ 
    2419     public static function initWidgets($w) 
    2520     { 
    2621          $w->create('lunarphase',__('Moon phases'),array('lunarPhasePublic','widget')); 
    2722          $w->lunarphase->setting('title',__('Title:'),__('Moon phases')); 
    28           $w->lunarphase->setting('new_moon',__('Text for new moon:'),__('New moon in %days% day(s) - %date%')); 
    29           $w->lunarphase->setting('first_quarter_moon',__('Text for first quarter:'),__('First Quarter in %days% day(s) - %date%')); 
    30           $w->lunarphase->setting('full_moon',__('Text for full moon:'),__('Full moon in %days% day(s) - %date%')); 
    31           $w->lunarphase->setting('last_quarter_moon',__('Text for last quarter:'),__('Last Quarter in %days% day(s) - %date%')); 
    32           $w->lunarphase->setting('illumination',__('Text for illumination:'),__('Illumination : %s %%')); 
    33           $w->lunarphase->setting('format_date',__('format date (leave blank to use Dotclear date format):'),''); 
     23          $w->lunarphase->setting('phase',__('Display actual phase of moon'),1,'check'); 
     24          $w->lunarphase->setting('illumination',__('Display actual illumination of moon'),1,'check'); 
     25          $w->lunarphase->setting('age',__('Display actual age of moon'),1,'check'); 
     26          $w->lunarphase->setting('dist_to_earth',__('Display actual distance between moon and earth'),1,'check'); 
     27          $w->lunarphase->setting('dist_to_sun',__('Display actual distance between moon and sun'),1,'check'); 
     28          $w->lunarphase->setting('moon_angle',__('Display actual angle of moon'),1,'check'); 
     29          $w->lunarphase->setting('sun_angle',__('Display actual angle of sun'),1,'check'); 
     30          $w->lunarphase->setting('parallax',__('Display actual parallax of moon'),1,'check'); 
     31          $w->lunarphase->setting('previsions',__('Display all previsions for the next moon phases'),1,'check'); 
    3432          $w->lunarphase->setting('homeonly',__('Home page only'),1,'check'); 
    3533     } 
  • plugins/lunarPhase/trunk/inc/class.lunarphase.php

    r1716 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1313class lunarPhase 
    1414{ 
    15      protected $phase; 
     15     # Astronomical constants. 
     16     const epoch         = 2444238.5;                                 # 1980 January 0.0 
     17 
     18     # Constants defining the Sun's apparent orbit. 
     19     const elonge        = 278.833540;                                # ecliptic longitude of the Sun at epoch 1980.0 
     20     const elongp        = 282.596403;                                # ecliptic longitude of the Sun at perigee 
     21     const eccent        = 0.016718;                                  # eccentricity of Earth's orbit 
     22     const sunsMax       = 1.495985e8;                                # semi-major axis of Earth's orbit, km 
     23     const sunAngSiz     = 0.533128;                                  # sun's angular size, degrees, at semi-major axis distance 
     24 
     25     # Elements of the Moon's orbit, epoch 1980.0. 
     26     const mmLong        = 64.975464;                                 # moon's mean longitude at the epoch 
     27     const mmLongp       = 349.383063;                                # mean longitude of the perigee at the epoch 
     28     const mlNode        = 151.950429;                                # mean longitude of the node at the epoch 
     29     const mInc          = 5.145396;                                  # inclination of the Moon's orbit 
     30     const mEcc          = 0.054900;                                  # eccentricity of the Moon's orbit 
     31     const mAngSiz       = 0.5181;                                    # moon's angular size at distance a from Earth 
     32     const msMax         = 384401.0;                                  # semi-major axis of Moon's orbit in km 
     33     const mParallax     = 0.9507;                                    # parallax at distance a from Earth 
     34     const synodic       = 29.53058868;                               # synodic month (new Moon to new Moon) 
     35      
     36     protected $live; 
    1637     protected $previsions; 
    17      protected $references; 
    18  
    19      /** 
    20       * Constructor of the class... What else? (Yes, i drink Nespresso ;)) 
    21       */ 
    22      public function __construct($core,$w) 
     38      
     39     public function __construct() 
    2340     { 
    24           $this->core =& $core; 
    25           $this->w    =& $w; 
    26  
    27           $this->setReferences(); 
    28           $this->setPhase(); 
     41          $this->live = new ArrayObject; 
     42          $this->previsions = new ArrayObject; 
     43           
     44          $this->setLive(); 
    2945          $this->setPrevisions(); 
    3046     } 
    31  
    32      public function getPhase() 
     47      
     48     public function getLive() 
    3349     { 
    34           return $this->phase; 
     50          return $this->live; 
    3551     } 
    36  
     52      
    3753     public function getPrevisions() 
    3854     { 
    3955          return $this->previsions; 
    4056     } 
    41  
    42      /** 
    43       * Calculates and defines the current moon phase 
    44       */ 
     57      
     58     private function setLive() 
     59     { 
     60          $day = $this->jTime(time()) - self::epoch; 
     61           
     62          # Calculate sun's position and angle 
     63          $N = $this->fixAngle((360 / 365.2422) * $day); 
     64          $M = $this->fixAngle($N + self::elonge - self::elongp); 
     65          $Ec = $this->kepler($M, self::eccent); 
     66          $Ec = sqrt((1 + self::eccent) / (1 - self::eccent)) * tan($Ec / 2); 
     67          $Ec = 2 * $this->toDeg(atan($Ec)); 
     68          $lambdaSun = $this->fixAngle($Ec + self::elongp); 
     69          $F = ((1 + self::eccent * cos($this->toRad($Ec))) / (1 - self::eccent * self::eccent)); 
     70           
     71          # Calculate moon's age, position and angle 
     72          $ml = $this->fixAngle(13.1763966 * $day + self::mmLong); 
     73          $MM = $this->fixAngle($ml - 0.1114041 * $day - self::mmLongp); 
     74          $MN = $this->fixAngle(self::mlNode - 0.0529539 * $day); 
     75          $Ev = 1.2739 * sin($this->toRad(2 * ($ml - $lambdaSun) - $MM)); 
     76          $Ae = 0.1858 * sin($this->toRad($M)); 
     77          $A3 = 0.37 * sin($this->toRad($M)); 
     78          $MmP = $MM + $Ev - $Ae - $A3; 
     79          $mEc = 6.2886 * sin($this->toRad($MmP)); 
     80          $A4 = 0.214 * sin($this->toRad(2 * $MmP)); 
     81          $lP = $ml + $Ev + $mEc - $Ae + $A4; 
     82          $V = 0.6583 * sin($this->toRad(2 * ($lP - $lambdaSun))); 
     83          $lPP = $lP + $V; 
     84          $NP = $MN - 0.16 * sin($this->toRad($M)); 
     85          $y = sin($this->toRad($lPP - $NP)) * cos($this->toRad(self::mInc)); 
     86          $x = cos($this->toRad($lPP - $NP)); 
     87          $lambdaMoon = $this->toDeg(atan2($y, $x)); 
     88          $lambdaMoon += $NP; 
     89          $mage = $lPP - $lambdaSun; 
     90          $BetaM = $this->toDeg(asin(sin($this->toRad($lPP - $NP)) * sin($this->toRad(self::mInc)))); 
     91           
     92          $this->live['illumination']   = (1 - cos($this->toRad($mage))) / 2; 
     93          $this->live['age']            = self::synodic * ($this->fixAngle($mage) / 360.0);  
     94          $this->live['dist_to_earth']  = (self::msMax * (1 - self::mEcc * self::mEcc)) / (1 + self::mEcc * cos($this->toRad($MmP + $mEc))); 
     95          $this->live['dist_to_sun']    = self::sunsMax / $F; 
     96          $this->live['sun_angle']      = $F * self::sunAngSiz; 
     97          $this->live['moon_angle']     = self::mAngSiz / ($this->live['dist_to_earth'] / self::msMax); 
     98          $this->live['parallax']  = self::mParallax / ($this->live['dist_to_earth'] / self::msMax); 
     99           
     100          $this->setPhase(); 
     101     } 
     102      
    45103     private function setPhase() 
    46104     { 
    47           $ts = time() - $this->references->new_moon; 
    48  
    49           $this->phase = new stdClass(); 
    50           $this->phase->value = abs(($ts % $this->references->day_in_sec) / $this->references->day_in_sec); 
    51  
    52           if ($this->phase->value >= 0.474 && $this->phase->value <= 0.53) { 
    53                $this->phase->id = 'new_moon'; 
    54                $this->phase->name = __('New moon'); 
     105          if ($this->live['age'] >= self::synodic && $this->live['age'] <= self::synodic/8) { 
     106               $this->live['id'] = 'new_moon'; 
     107               $this->live['name'] = __('New moon'); 
    55108          } 
    56           elseif ($this->phase->value >= 0.53 && $this->phase->value <= 0.724) { 
    57                $this->phase->id = 'waxing_crescent_moon'; 
    58                $this->phase->name = __('Waxing crescent moon'); 
     109          elseif ($this->live['age'] >= self::synodic/8 && $this->live['age'] <= self::synodic/4) {  
     110               $this->live['id'] = 'waxing_crescent_moon'; 
     111               $this->live['name'] = __('Waxing crescent moon'); 
    59112          } 
    60           elseif ($this->phase->value >= 0.724 && $this->phase->value <= 0.776) { 
    61                $this->phase->id = 'first_quarter_moon'; 
    62                $this->phase->name = __('First quarter moon'); 
     113          elseif ($this->live['age'] >= self::synodic/4 && $this->live['age'] <= self::synodic*3/8) { 
     114               $this->live['id'] = 'first_quarter_moon'; 
     115               $this->live['name'] = __('First quarter moon'); 
    63116          } 
    64           elseif ($this->phase->value >= 0.776 && $this->phase->value <= 0.974) { 
    65                $this->phase->id = 'waxing_gibbous_moon'; 
    66                $this->phase->name = __('Waxing gibbous moon'); 
     117          elseif ($this->live['age'] >= self::synodic*3/8 && $this->live['age'] <= self::synodic/2) { 
     118               $this->live['id'] = 'waxing_gibbous_moon'; 
     119               $this->live['name'] = __('Waxing gibbous moon'); 
    67120          } 
    68           elseif ($this->phase->value >= 0.974 || $this->phase->value <= 0.026) { 
    69                $this->phase->id = 'full_moon'; 
    70                $this->phase->name = __('Full moon'); 
     121          elseif ($this->live['age'] >= self::synodic/2 && $this->live['age'] <= self::synodic*5/8) { 
     122               $this->live['id'] = 'full_moon'; 
     123               $this->live['name'] = __('Full moon'); 
    71124          } 
    72           elseif ($this->phase->value >= 0.026 && $this->phase->value <= 0.234) { 
    73                $this->phase->id = 'waning_gibbous_moon'; 
    74                $this->phase->name = __('Waning gibbous moon'); 
     125          elseif ($this->live['age'] >= self::synodic*5/8 && $this->live['age'] <= self::synodic*3/4) { 
     126               $this->live['id'] = 'waning_gibbous_moon'; 
     127               $this->live['name'] = __('Waning gibbous moon'); 
    75128          } 
    76           elseif ($this->phase->value >= 0.234 && $this->phase->value <= 0.295) { 
    77                $this->phase->id = 'last_quarter_moon'; 
    78                $this->phase->name = __('Last quarter moon'); 
     129          elseif ($this->live['age'] >= self::synodic*3/4 && $this->live['age'] <= self::synodic*7/8) { 
     130               $this->live['id'] = 'last_quarter_moon'; 
     131               $this->live['name'] = __('Last quarter moon'); 
    79132          } 
    80           elseif ($this->phase->value >= 0.295 && $this->phase->value <= 0.4739) { 
    81                $this->phase->id = 'waning_crescent_moon'; 
    82                $this->phase->name = __('Waning crescent moon'); 
     133          elseif ($this->live['age'] >= self::synodic*7/8 && $this->live['age'] <= self::synodic/8) { 
     134               $this->live['id'] = 'waning_crescent_moon'; 
     135               $this->live['name'] = __('Waning crescent moon'); 
    83136          } 
    84137     } 
    85  
    86      /** 
    87       * Calculates all other previsions 
    88       */ 
     138      
    89139     private function setPrevisions() 
    90140     { 
    91           $this->previsions = new stdClass(); 
    92  
    93           $this->calcNewMoon(); 
    94           $this->calcFirstQuarterMoon(); 
    95           $this->calcFullMoon(); 
    96           $this->calcLastQuarterMoon(); 
    97           $this->calcIllumination(); 
     141          $ts_day = 24*60*60; 
     142          $ts_synodic = self::synodic * $ts_day; 
     143          $start = time() - $this->live['age'] * $ts_day; 
     144           
     145          $this->previsions = new ArrayObject; 
     146          $this->previsions['waxing_crescent_moon'] = $start + $ts_synodic / 8; 
     147          $this->previsions['first_quarter_moon'] = $start + $ts_synodic / 4; 
     148          $this->previsions['waxing_gibbous_moon'] = $start + $ts_synodic * 3 / 8; 
     149          $this->previsions['full_moon'] = $start + $ts_synodic / 2; 
     150          $this->previsions['waning_gibbous_moon'] = $start + $ts_synodic * 5 / 8; 
     151          $this->previsions['last_quarter_moon'] = $start + $ts_synodic * 3 / 4; 
     152          $this->previsions['waning_crescent_moon'] = $start + $ts_synodic * 7 / 8; 
     153          $this->previsions['new_moon'] = $start + $ts_synodic; 
     154           
    98155     } 
    99  
    100      /** 
    101       * Defines references for the plugin 
    102       */ 
    103      private function setReferences() 
     156      
     157     private function fixAngle($x) 
    104158     { 
    105           $this->references = new stdClass(); 
    106  
    107           $this->references->synodic_moon = (1/((1/27.322)-(1/365.25)))*24*60*60; 
    108           $this->references->new_moon = mktime(6,39,0,2,16,1999); 
    109           $this->references->day_in_sec = 60*60*24; 
     159          return ($x - 360.0 * (floor($x / 360.0))); 
    110160     } 
    111  
    112      /** 
    113       * Calculates the next new moon 
    114       */ 
    115      private function calcNewMoon() 
     161      
     162     private function toRad($x) 
    116163     { 
    117           if ($this->phase->value < 0.5) { 
    118                $ts = (0.5 - $this->phase->value) * $this->references->synodic_moon; 
     164          return ($x * (M_PI / 180.0)); 
     165     } 
     166      
     167     private function toDeg($x) 
     168     { 
     169          return ($x * (180.0 / M_PI)); 
     170     } 
     171      
     172     private function jTime($t) 
     173     { 
     174          return ($t / 86400) + 2440587.5; 
     175     } 
     176      
     177     private function kepler($m, $ecc) 
     178     { 
     179          $delta = null; 
     180          $EPSILON = 1e-6; 
     181           
     182          $m = $this->toRad($m); 
     183          $e = $m; 
     184          while (abs($delta) > $EPSILON) 
     185          { 
     186               $delta = $e - $ecc * sin($e) - $m; 
     187               $e -= $delta / (1 - $ecc * cos($e)); 
    119188          } 
    120           elseif ($this->phase->value >= 0.5) { 
    121                $ts = (1.5 - $this->phase->value) * $this->references->synodic_moon; 
    122           } 
    123  
    124           $this->previsions->new_moon = new stdClass(); 
    125           $this->previsions->new_moon->id = 'new_moon'; 
    126           $this->previsions->new_moon->days = $this->tsToDays($ts); 
    127           $this->previsions->new_moon->date = $this->tsToDate($ts); 
    128      } 
    129  
    130      /** 
    131       * Calculates the next first quarter moon 
    132       */ 
    133      private function calcFirstQuarterMoon() 
    134      { 
    135           if ($this->phase->value < 0.75) { 
    136                $ts = (0.75 - $this->phase->value) * $this->references->synodic_moon; 
    137           } 
    138           elseif ($this->phase->value >= 0.75) { 
    139                $ts = (1.75 - $this->phase->value) * $this->references->synodic_moon; 
    140           } 
    141  
    142           $this->previsions->first_quarter_moon = new stdClass(); 
    143           $this->previsions->first_quarter_moon->id = 'first_quarter_moon'; 
    144           $this->previsions->first_quarter_moon->days = $this->tsToDays($ts); 
    145           $this->previsions->first_quarter_moon->date = $this->tsToDate($ts); 
    146      } 
    147  
    148      /** 
    149       * Calculates the next fulle moon 
    150       */ 
    151      private function calcFullMoon() 
    152      { 
    153           $ts = (1 - $this->phase->value) * $this->references->synodic_moon; 
    154       
    155           $this->previsions->full_moon = new stdClass(); 
    156           $this->previsions->full_moon->id = 'full_moon'; 
    157           $this->previsions->full_moon->days = $this->tsToDays($ts); 
    158           $this->previsions->full_moon->date = $this->tsToDate($ts); 
    159      } 
    160  
    161      /** 
    162       * Calculates the next last quarter moon 
    163       */ 
    164      private function calcLastQuarterMoon() 
    165      { 
    166           if ($this->phase->value < 0.25) { 
    167                $ts = (0.25 - $this->phase->value) * $this->references->synodic_moon; 
    168           } 
    169           elseif ($this->phase->value >= 0.25) { 
    170                $ts = (1.25 - $this->phase->value) * $this->references->synodic_moon; 
    171           } 
    172  
    173           $this->previsions->last_quarter_moon = new stdClass(); 
    174           $this->previsions->last_quarter_moon->id = 'last_quarter_moon'; 
    175           $this->previsions->last_quarter_moon->days = $this->tsToDays($ts); 
    176           $this->previsions->last_quarter_moon->date = $this->tsToDate($ts); 
    177      } 
    178  
    179      /** 
    180       * Calculates the current illumination of the moon 
    181       */ 
    182      private function calcIllumination() 
    183      { 
    184           $this->previsions->illumination = new stdClass(); 
    185           $this->previsions->illumination->id = 'illumination'; 
    186           $this->previsions->illumination->value = round(((1.0 + cos(2.0 * M_PI * $this->phase->value)) / 2.0) * 100,1); 
    187      } 
    188  
    189      /** 
    190       * Returns date according to the timestamp in argument 
    191       * 
    192       * @param timestamp ts 
    193       * 
    194       * @return     timestamp 
    195       */ 
    196      private function tsToDate($ts) 
    197      { 
    198           $format = !empty($this->w->format_date) ? $this->w->format_date : $this->core->blog->settings->date_format; 
    199  
    200           return dt::str($format,$ts + time()); 
    201      } 
    202  
    203      /** 
    204       * Return the time passed an argument converting in days 
    205       * 
    206       * @param time ts 
    207       * 
    208       * @return     float 
    209       */ 
    210      private function tsToDays($ts) 
    211      { 
    212           return round($ts / $this->references->day_in_sec,1); 
     189          return ($e); 
    213190     } 
    214191} 
  • plugins/lunarPhase/trunk/locales/fr/main.po

    r1716 r2683  
    1 # Français translation of lunarPhase, a plugin for dotclear 
    2 # This file is generated by LangOmatic, a plugin for Dotclear 
     1# Language: Français 
     2# Module: lunarPhase - 1.1 
     3# Date: 2010-09-30 06:18:51 
     4# Translated with translater 1.5 
     5 
    36msgid "" 
    47msgstr "" 
    58"Content-Type: text/plain; charset=UTF-8\n" 
    6 "Project-Id-Version: \n" 
     9"Project-Id-Version: lunarPhase 1.1\n" 
    710"POT-Creation-Date: \n" 
    8 "PO-Revision-Date: \n" 
    9 "Last-Translator: Kozlika <kozlika@free.fr>\n" 
     11"PO-Revision-Date: 2010-09-30T06:18:51+00:00\n" 
     12"Last-Translator: Thomas Bouron\n" 
    1013"Language-Team: \n" 
    1114"MIME-Version: 1.0\n" 
    1215"Content-Transfer-Encoding: 8bit\n" 
    1316 
    14 #: _widgets.php:28 
    15 #: _widgets.php:29 
     17#: _public.php:80 
     18msgid "Illumination: %s%%" 
     19msgstr "Illumination %s%%" 
     20 
     21#: _public.php:87 
     22msgid "Age of moon: %s days" 
     23msgstr "Age de la lune: %s jours" 
     24 
     25#: _public.php:94 
     26msgid "Distance to earth: %s km" 
     27msgstr "Distance à la terre: %s km" 
     28 
     29#: _public.php:101 
     30msgid "Distance to sun: %s km" 
     31msgstr "Distance au soleil: %s km" 
     32 
     33#: _public.php:108 
     34msgid "Angle of moon: %s deg" 
     35msgstr "Angle de la lune: %s deg" 
     36 
     37#: _public.php:115 
     38msgid "Angle of sun: %s deg" 
     39msgstr "Angle du soleil: %s deg" 
     40 
     41#: _public.php:122 
     42msgid "Parallax: %s deg" 
     43msgstr "Parallaxe: %s deg" 
     44 
     45#: _public.php:129 
     46msgid "In live" 
     47msgstr "En direct" 
     48 
     49#: _public.php:148 
     50msgid "Previsions" 
     51msgstr "Prévisions" 
     52 
     53#: _widgets.php:21 
     54#: _widgets.php:22 
    1655msgid "Moon phases" 
    1756msgstr "Phases lunaires" 
    1857 
    19 #: _widgets.php:30 
    20 msgid "Text for new moon:" 
    21 msgstr "Texte pour la nouvelle lune :" 
     58#: _widgets.php:23 
     59msgid "Display actual phase of moon" 
     60msgstr "Afficher la phase lunaire actuelle" 
     61 
     62#: _widgets.php:24 
     63msgid "Display actual illumination of moon" 
     64msgstr "Afficher le taux d'illumination actuel de la lune" 
     65 
     66#: _widgets.php:25 
     67msgid "Display actual age of moon" 
     68msgstr "Afficher l'age actuel de la lune" 
     69 
     70#: _widgets.php:26 
     71msgid "Display actual distance between moon and earth" 
     72msgstr "Afficher la distance actuelle entre la terre et la lune" 
     73 
     74#: _widgets.php:27 
     75msgid "Display actual distance between moon and sun" 
     76msgstr "Afficher la distance actuelle entre le soleil et la lune" 
     77 
     78#: _widgets.php:28 
     79msgid "Display actual angle of moon" 
     80msgstr "Afficher l'angle actuel de la lune" 
     81 
     82#: _widgets.php:29 
     83msgid "Display actual angle of sun" 
     84msgstr "Afficher l'angle actuel du soleil" 
    2285 
    2386#: _widgets.php:30 
    24 msgid "New moon in %days% day(s) - %date%" 
    25 msgstr "Nouvelle lune dans %days% jour(s) - %date%" 
     87msgid "Display actual parallax of moon" 
     88msgstr "Afficher la parallaxe actuelle de la lune" 
    2689 
    2790#: _widgets.php:31 
    28 msgid "Text for first quarter:" 
    29 msgstr "Texte pour le premier quartier :" 
     91msgid "Display all previsions for the next moon phases" 
     92msgstr "Afficher toutes les prévisions des prochaines lunaisons" 
    3093 
    31 #: _widgets.php:31 
    32 msgid "First Quarter in %days% day(s) - %date%" 
    33 msgstr "Premier quartier dans %days% jour(s) - %date%" 
    34  
    35 #: _widgets.php:32 
    36 msgid "Text for full moon:" 
    37 msgstr "Texte pour la pleine lune :" 
    38  
    39 #: _widgets.php:32 
    40 msgid "Full moon in %days% day(s) - %date%" 
    41 msgstr "Pleine lune dans %days% jour(s) - %date%" 
    42  
    43 #: _widgets.php:33 
    44 msgid "Text for last quarter:" 
    45 msgstr "Texte pour le dernier quartier :" 
    46  
    47 #: _widgets.php:33 
    48 msgid "Last Quarter in %days% day(s) - %date%" 
    49 msgstr "Dernier quartier dans %days% jour(s) - %date%" 
    50  
    51 #: _widgets.php:34 
    52 msgid "Text for illumination:" 
    53 msgstr "Texte pour le pourcentage d'illlumination :" 
    54  
    55 #: _widgets.php:34 
    56 msgid "Illumination : %s %%" 
    57 msgstr "Illumination %s %%" 
    58  
    59 #: _widgets.php:35 
    60 msgid "format date (leave blank to use Dotclear date format):" 
    61 msgstr "Format de la date (laissez vide pour utiliser le format de Dotclear) :" 
    62  
    63 #: inc/class.lunarphase.php:47 
     94#: inc/class.lunarphase.php:107 
    6495msgid "New moon" 
    6596msgstr "Nouvelle lune" 
    6697 
    67 #: inc/class.lunarphase.php:51 
     98#: inc/class.lunarphase.php:111 
    6899msgid "Waxing crescent moon" 
    69100msgstr "Lune croissante" 
    70101 
    71 #: inc/class.lunarphase.php:55 
     102#: inc/class.lunarphase.php:115 
    72103msgid "First quarter moon" 
    73104msgstr "Premier quartier" 
    74105 
    75 #: inc/class.lunarphase.php:59 
     106#: inc/class.lunarphase.php:119 
    76107msgid "Waxing gibbous moon" 
    77108msgstr "Lune gibbeuse croissante" 
    78109 
    79 #: inc/class.lunarphase.php:63 
     110#: inc/class.lunarphase.php:123 
    80111msgid "Full moon" 
    81112msgstr "Pleine lune" 
    82113 
    83 #: inc/class.lunarphase.php:67 
     114#: inc/class.lunarphase.php:127 
    84115msgid "Waning gibbous moon" 
    85116msgstr "Lune gibbeuse décroissante" 
    86117 
    87 #: inc/class.lunarphase.php:71 
     118#: inc/class.lunarphase.php:131 
    88119msgid "Last quarter moon" 
    89120msgstr "Dernier quartier" 
    90121 
    91 #: inc/class.lunarphase.php:75 
     122#: inc/class.lunarphase.php:135 
    92123msgid "Waning crescent moon" 
    93124msgstr "Lune décroissante" 
    94125 
    95 #: inc/lib.lunarphase.ui.php:66 
    96 msgid "In live" 
    97 msgstr "En direct" 
    98  
    99 #: inc/lib.lunarphase.ui.php:70 
    100 msgid "Previsions" 
    101 msgstr "Prévisions" 
    102  
    103 msgid "lunarPhase" 
    104 msgstr "lunarPhase" 
    105  
  • plugins/lunarPhase/trunk/style.css

    r1634 r2683  
    33# This file is part of lunarPhase, a plugin for Dotclear. 
    44#  
    5 # Copyright (c) 2009 Tomtom 
     5# Copyright (c) 2009-2010 Tomtom 
    66# http://blog.zenstyle.fr/ 
    77#  
     
    1111# -- END LICENSE BLOCK ------------------------------------ 
    1212*/ 
    13 #sidebar ul.lunarphase li.new_moon { 
     13#lunarphase ul li.new_moon { 
    1414     background: transparent url(index.php?pf=lunarPhase/img/nm.gif) no-repeat left 0.2em; 
    1515     padding-left: 2em; 
    1616} 
    17 #sidebar ul.lunarphase li.waxing_crescent_moon { 
     17#lunarphase ul li.waxing_crescent_moon { 
    1818     background: transparent url(index.php?pf=lunarPhase/img/wcm1.gif) no-repeat left 0.2em; 
    1919     padding-left: 2em; 
    2020} 
    21 #sidebar ul.lunarphase li.first_quarter_moon { 
     21#lunarphase ul li.first_quarter_moon { 
    2222     background: transparent url(index.php?pf=lunarPhase/img/fqm.gif) no-repeat left 0.2em; 
    2323     padding-left: 2em; 
    2424} 
    25 #sidebar ul.lunarphase li.waxing_gibbous_moon { 
     25#lunarphase ul li.waxing_gibbous_moon { 
    2626     background: transparent url(index.php?pf=lunarPhase/img/wgm1.gif) no-repeat left 0.2em; 
    2727     padding-left: 2em; 
    2828} 
    29 #sidebar ul.lunarphase li.full_moon { 
     29#lunarphase ul li.full_moon { 
    3030     background: transparent url(index.php?pf=lunarPhase/img/fm.gif) no-repeat left 0.2em; 
    3131     padding-left: 2em; 
    3232} 
    33 #sidebar ul.lunarphase li.waning_gibbous_moon { 
     33#lunarphase ul li.waning_gibbous_moon { 
    3434     background: transparent url(index.php?pf=lunarPhase/img/wgm2.gif) no-repeat left 0.2em; 
    3535     padding-left: 2em; 
    3636} 
    37 #sidebar ul.lunarphase li.last_quarter_moon { 
     37#lunarphase ul li.last_quarter_moon { 
    3838     background: transparent url(index.php?pf=lunarPhase/img/tqm.gif) no-repeat left 0.2em; 
    3939     padding-left: 2em; 
    4040} 
    41 #sidebar ul.lunarphase li.waning_crescent_moon { 
     41#lunarphase ul li.waning_crescent_moon { 
    4242     background: transparent url(index.php?pf=lunarPhase/img/wcm2.gif) no-repeat left 0.2em; 
    4343     padding-left: 2em; 
    4444} 
    45 #sidebar ul.lunarphase li.illumination { 
    46      background: transparent url(index.php?pf=lunarPhase/img/light.png) no-repeat left 0.2em; 
    47      padding-left: 2em; 
    48 } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map