Changeset 2683
- Timestamp:
- 09/30/10 08:22:11 (12 years ago)
- Location:
- plugins/lunarPhase/trunk
- Files:
-
- 1 deleted
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/lunarPhase/trunk/_define.php
r1634 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 16 16 /* Name */ 'lunarPhase', 17 17 /* 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', 20 20 /* Premission */ 'usage,contentadmin' 21 21 ); -
plugins/lunarPhase/trunk/_prepend.php
r1634 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 13 if (!defined('DC_RC_PATH')) { return; } 14 13 15 $__autoload['lunarPhase'] = dirname(__FILE__).'/inc/class.lunarphase.php'; 14 16 -
plugins/lunarPhase/trunk/_public.php
r1634 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 18 18 { 19 19 /** 20 *This function add CSS file in the public header21 20 This function add CSS file in the public header 21 */ 22 22 public static function addCss() 23 23 { 24 24 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'; 27 27 28 28 echo '<link rel="stylesheet" media="screen" type="text/css" href="'.$url.'" />'; … … 33 33 { 34 34 /** 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 */ 41 40 public static function widget($w) 42 41 { 43 42 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 47 49 if ($w->homeonly && $core->url->type != 'default') { 48 50 return; 49 51 } 50 52 51 53 $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 69 61 '<div id="lunarphase">'. 70 62 $res. 71 63 '</div>'; 72 64 } 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) 84 67 { 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 = ''; 87 72 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']); 90 76 } 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'); 93 83 } 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'); 96 90 } 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'); 99 104 } 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; 102 181 } 103 182 } -
plugins/lunarPhase/trunk/_widgets.php
r1716 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 17 17 class lunarPhaseWidgets 18 18 { 19 /**20 * This function create a new lunarPhase widget21 *22 * @param object w23 */24 19 public static function initWidgets($w) 25 20 { 26 21 $w->create('lunarphase',__('Moon phases'),array('lunarPhasePublic','widget')); 27 22 $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'); 34 32 $w->lunarphase->setting('homeonly',__('Home page only'),1,'check'); 35 33 } -
plugins/lunarPhase/trunk/inc/class.lunarphase.php
r1716 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 13 13 class lunarPhase 14 14 { 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; 16 37 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() 23 40 { 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(); 29 45 $this->setPrevisions(); 30 46 } 31 32 public function get Phase()47 48 public function getLive() 33 49 { 34 return $this-> phase;50 return $this->live; 35 51 } 36 52 37 53 public function getPrevisions() 38 54 { 39 55 return $this->previsions; 40 56 } 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 45 103 private function setPhase() 46 104 { 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'); 55 108 } 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'); 59 112 } 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'); 63 116 } 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'); 67 120 } 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'); 71 124 } 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'); 75 128 } 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'); 79 132 } 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'); 83 136 } 84 137 } 85 86 /** 87 * Calculates all other previsions 88 */ 138 89 139 private function setPrevisions() 90 140 { 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 98 155 } 99 100 /** 101 * Defines references for the plugin 102 */ 103 private function setReferences() 156 157 private function fixAngle($x) 104 158 { 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))); 110 160 } 111 112 /** 113 * Calculates the next new moon 114 */ 115 private function calcNewMoon() 161 162 private function toRad($x) 116 163 { 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)); 119 188 } 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); 213 190 } 214 191 } -
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 3 6 msgid "" 4 7 msgstr "" 5 8 "Content-Type: text/plain; charset=UTF-8\n" 6 "Project-Id-Version: \n"9 "Project-Id-Version: lunarPhase 1.1\n" 7 10 "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" 10 13 "Language-Team: \n" 11 14 "MIME-Version: 1.0\n" 12 15 "Content-Transfer-Encoding: 8bit\n" 13 16 14 #: _widgets.php:28 15 #: _widgets.php:29 17 #: _public.php:80 18 msgid "Illumination: %s%%" 19 msgstr "Illumination %s%%" 20 21 #: _public.php:87 22 msgid "Age of moon: %s days" 23 msgstr "Age de la lune: %s jours" 24 25 #: _public.php:94 26 msgid "Distance to earth: %s km" 27 msgstr "Distance à la terre: %s km" 28 29 #: _public.php:101 30 msgid "Distance to sun: %s km" 31 msgstr "Distance au soleil: %s km" 32 33 #: _public.php:108 34 msgid "Angle of moon: %s deg" 35 msgstr "Angle de la lune: %s deg" 36 37 #: _public.php:115 38 msgid "Angle of sun: %s deg" 39 msgstr "Angle du soleil: %s deg" 40 41 #: _public.php:122 42 msgid "Parallax: %s deg" 43 msgstr "Parallaxe: %s deg" 44 45 #: _public.php:129 46 msgid "In live" 47 msgstr "En direct" 48 49 #: _public.php:148 50 msgid "Previsions" 51 msgstr "Prévisions" 52 53 #: _widgets.php:21 54 #: _widgets.php:22 16 55 msgid "Moon phases" 17 56 msgstr "Phases lunaires" 18 57 19 #: _widgets.php:30 20 msgid "Text for new moon:" 21 msgstr "Texte pour la nouvelle lune :" 58 #: _widgets.php:23 59 msgid "Display actual phase of moon" 60 msgstr "Afficher la phase lunaire actuelle" 61 62 #: _widgets.php:24 63 msgid "Display actual illumination of moon" 64 msgstr "Afficher le taux d'illumination actuel de la lune" 65 66 #: _widgets.php:25 67 msgid "Display actual age of moon" 68 msgstr "Afficher l'age actuel de la lune" 69 70 #: _widgets.php:26 71 msgid "Display actual distance between moon and earth" 72 msgstr "Afficher la distance actuelle entre la terre et la lune" 73 74 #: _widgets.php:27 75 msgid "Display actual distance between moon and sun" 76 msgstr "Afficher la distance actuelle entre le soleil et la lune" 77 78 #: _widgets.php:28 79 msgid "Display actual angle of moon" 80 msgstr "Afficher l'angle actuel de la lune" 81 82 #: _widgets.php:29 83 msgid "Display actual angle of sun" 84 msgstr "Afficher l'angle actuel du soleil" 22 85 23 86 #: _widgets.php:30 24 msgid " New moon in %days% day(s) - %date%"25 msgstr " Nouvelle lune dans %days% jour(s) - %date%"87 msgid "Display actual parallax of moon" 88 msgstr "Afficher la parallaxe actuelle de la lune" 26 89 27 90 #: _widgets.php:31 28 msgid " Text for first quarter:"29 msgstr " Texte pour le premier quartier :"91 msgid "Display all previsions for the next moon phases" 92 msgstr "Afficher toutes les prévisions des prochaines lunaisons" 30 93 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 64 95 msgid "New moon" 65 96 msgstr "Nouvelle lune" 66 97 67 #: inc/class.lunarphase.php: 5198 #: inc/class.lunarphase.php:111 68 99 msgid "Waxing crescent moon" 69 100 msgstr "Lune croissante" 70 101 71 #: inc/class.lunarphase.php: 55102 #: inc/class.lunarphase.php:115 72 103 msgid "First quarter moon" 73 104 msgstr "Premier quartier" 74 105 75 #: inc/class.lunarphase.php: 59106 #: inc/class.lunarphase.php:119 76 107 msgid "Waxing gibbous moon" 77 108 msgstr "Lune gibbeuse croissante" 78 109 79 #: inc/class.lunarphase.php: 63110 #: inc/class.lunarphase.php:123 80 111 msgid "Full moon" 81 112 msgstr "Pleine lune" 82 113 83 #: inc/class.lunarphase.php: 67114 #: inc/class.lunarphase.php:127 84 115 msgid "Waning gibbous moon" 85 116 msgstr "Lune gibbeuse décroissante" 86 117 87 #: inc/class.lunarphase.php: 71118 #: inc/class.lunarphase.php:131 88 119 msgid "Last quarter moon" 89 120 msgstr "Dernier quartier" 90 121 91 #: inc/class.lunarphase.php: 75122 #: inc/class.lunarphase.php:135 92 123 msgid "Waning crescent moon" 93 124 msgstr "Lune décroissante" 94 125 95 #: inc/lib.lunarphase.ui.php:6696 msgid "In live"97 msgstr "En direct"98 99 #: inc/lib.lunarphase.ui.php:70100 msgid "Previsions"101 msgstr "Prévisions"102 103 msgid "lunarPhase"104 msgstr "lunarPhase"105 -
plugins/lunarPhase/trunk/style.css
r1634 r2683 3 3 # This file is part of lunarPhase, a plugin for Dotclear. 4 4 # 5 # Copyright (c) 2009 Tomtom5 # Copyright (c) 2009-2010 Tomtom 6 6 # http://blog.zenstyle.fr/ 7 7 # … … 11 11 # -- END LICENSE BLOCK ------------------------------------ 12 12 */ 13 # sidebar ul.lunarphaseli.new_moon {13 #lunarphase ul li.new_moon { 14 14 background: transparent url(index.php?pf=lunarPhase/img/nm.gif) no-repeat left 0.2em; 15 15 padding-left: 2em; 16 16 } 17 # sidebar ul.lunarphaseli.waxing_crescent_moon {17 #lunarphase ul li.waxing_crescent_moon { 18 18 background: transparent url(index.php?pf=lunarPhase/img/wcm1.gif) no-repeat left 0.2em; 19 19 padding-left: 2em; 20 20 } 21 # sidebar ul.lunarphaseli.first_quarter_moon {21 #lunarphase ul li.first_quarter_moon { 22 22 background: transparent url(index.php?pf=lunarPhase/img/fqm.gif) no-repeat left 0.2em; 23 23 padding-left: 2em; 24 24 } 25 # sidebar ul.lunarphaseli.waxing_gibbous_moon {25 #lunarphase ul li.waxing_gibbous_moon { 26 26 background: transparent url(index.php?pf=lunarPhase/img/wgm1.gif) no-repeat left 0.2em; 27 27 padding-left: 2em; 28 28 } 29 # sidebar ul.lunarphaseli.full_moon {29 #lunarphase ul li.full_moon { 30 30 background: transparent url(index.php?pf=lunarPhase/img/fm.gif) no-repeat left 0.2em; 31 31 padding-left: 2em; 32 32 } 33 # sidebar ul.lunarphaseli.waning_gibbous_moon {33 #lunarphase ul li.waning_gibbous_moon { 34 34 background: transparent url(index.php?pf=lunarPhase/img/wgm2.gif) no-repeat left 0.2em; 35 35 padding-left: 2em; 36 36 } 37 # sidebar ul.lunarphaseli.last_quarter_moon {37 #lunarphase ul li.last_quarter_moon { 38 38 background: transparent url(index.php?pf=lunarPhase/img/tqm.gif) no-repeat left 0.2em; 39 39 padding-left: 2em; 40 40 } 41 # sidebar ul.lunarphaseli.waning_crescent_moon {41 #lunarphase ul li.waning_crescent_moon { 42 42 background: transparent url(index.php?pf=lunarPhase/img/wcm2.gif) no-repeat left 0.2em; 43 43 padding-left: 2em; 44 44 } 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.