final version 1.0
Dieser Commit ist enthalten in:
		
							Ursprung
							
								
									5e9bd9c7d0
								
							
						
					
					
						Commit
						4e9e9308c8
					
				
					 1 geänderte Dateien mit 105 neuen und 8 gelöschten Zeilen
				
			
		|  | @ -13,9 +13,8 @@ | ||||||
|  * $Id$ |  * $Id$ | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| $cfgMod = array( | $cfgMod = array( | ||||||
|     'debug' => false |     'debug' => true | ||||||
| ); | ); | ||||||
| 
 | 
 | ||||||
| // init db-object
 | // init db-object
 | ||||||
|  | @ -30,15 +29,113 @@ if (!is_object($oTpl)) { | ||||||
| $oTpl->reset(); | $oTpl->reset(); | ||||||
| 
 | 
 | ||||||
| // init debugger
 | // init debugger
 | ||||||
|  | if ($cfgMod['debug']) { | ||||||
|     cInclude('classes', 'Debug/DebuggerFactory.class.php'); |     cInclude('classes', 'Debug/DebuggerFactory.class.php'); | ||||||
|     /* @var $oDebug Debug_VisibleAdv */ |     /* @var $oDebug Debug_VisibleAdv */ | ||||||
|     $oDebug = DebuggerFactory::getDebugger('visible_adv'); |     $oDebug = DebuggerFactory::getDebugger('visible_adv'); | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
|  | $oToday = new DateTime(); | ||||||
|  | if ($cfgMod['debug']) { | ||||||
|  |     if(isset($_GET['dateoffset'])) { | ||||||
|  |         $oToday->modify($_GET['dateoffset']." days"); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | $oXmasDate = new DateTime(date("Y")."-12-24 23:59:59"); | ||||||
|  | $oXmasMondayDate = clone $oXmasDate; | ||||||
|  | $oXmasMondayDate->modify("+2 days"); | ||||||
|  | 
 | ||||||
|  | $oFirstAdventDate = new DateTime(date("Y")."-11-26"); | ||||||
|  | $oFirstAdventDate->modify("next sunday"); | ||||||
|  | 
 | ||||||
|  | $oSecondAdvent = clone $oFirstAdventDate; | ||||||
|  | $oSecondAdvent->modify("+7 days"); | ||||||
|  | 
 | ||||||
|  | $oThirdAdvent = clone $oSecondAdvent; | ||||||
|  | $oThirdAdvent->modify("+7 days"); | ||||||
|  | 
 | ||||||
|  | $oFourthAdvent = clone $oThirdAdvent; | ||||||
|  | $oFourthAdvent->modify("+7 days"); | ||||||
|  | 
 | ||||||
|  | if($oToday <= $oXmasMondayDate && $oToday >= $oFirstAdventDate) { | ||||||
|  |     $sImgPath = $cfgClient[$client]['images']."adventskranz/Extra/"; | ||||||
|  |      | ||||||
|  |     if($oToday >= $oFirstAdventDate && $oToday < $oSecondAdvent) { | ||||||
|  |         $sImgPath .= "advent1.gif"; | ||||||
|  |     } else if($oToday >= $oSecondAdvent && $oToday < $oThirdAdvent) { | ||||||
|  |         $sImgPath .= "advent2.gif"; | ||||||
|  |     } else if ($oToday >= $oThirdAdvent && $oToday < $oFourthAdvent) { | ||||||
|  |         $sImgPath .= "advent3.gif"; | ||||||
|  |     } else { | ||||||
|  |         $sImgPath .= "advent4.gif"; | ||||||
|  |     }     | ||||||
|  |      | ||||||
|  |     echo '<div id="adventskranz" style="width: 200px; margin: auto; text-align: center;">';  | ||||||
|  |     echo '<img src="'.$sImgPath.'" alt="'.mi18n("Der ewige Adventskranz").'" />'; | ||||||
|  |     echo '<p class="eak_countdown">'; | ||||||
|  |     // countdown till xmas
 | ||||||
|  |     $iDaysTillmas = (int) daysdiff( $oXmasDate->format("Y-m-d"), $oToday->format("Y-m-d")); | ||||||
|  |     if($iDaysTillmas > 1) { | ||||||
|  |         printf(mi18n("Noch %s Tage bis Weihnachten"), $iDaysTillmas); | ||||||
|  |     } else if($iDaysTillmas == 1) { | ||||||
|  |         printf(mi18n("Noch %s Tag bis Weihnachten"), $iDaysTillmas); | ||||||
|  |     } else if($iDaysTillmas === 0) { | ||||||
|  |         echo mi18n("Frohe Weihnacht!<br/>(Heiliger Abend)"); | ||||||
|  |     } else { | ||||||
|  |         echo mi18n("Frohe Weihnacht!"); | ||||||
|  |     } | ||||||
|  |     echo "</p></div>"; | ||||||
|  | } | ||||||
| 
 | 
 | ||||||
| // your code here
 |  | ||||||
| // show debug & cleanup
 | // show debug & cleanup
 | ||||||
| if ($cfgMod['debug']) | if ($cfgMod['debug']) { | ||||||
|  |     $oDebug->add($cfgClient, "cfgClient array"); | ||||||
|  |     $oDebug->add($oToday, "Heute DateTime object"); | ||||||
|  |     $oDebug->add($oXmasDate, "Xmas DateTime object"); | ||||||
|  |     $oDebug->add($oFirstAdventDate, "1. Advent DateTime object");  | ||||||
|  |     $oDebug->add($oSecondAdvent, "2. Advent DateTime object"); | ||||||
|  |     $oDebug->add($oThirdAdvent, "3. Advent DateTime object"); | ||||||
|  |     $oDebug->add($oFourthAdvent, "4. Advent DateTime object"); | ||||||
|     $oDebug->showAll(); |     $oDebug->showAll(); | ||||||
| unset($cfgMod); |  | ||||||
|     unset($oDebug); |     unset($oDebug); | ||||||
|  | } | ||||||
|  | unset($cfgMod); | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * compare two datetime objects | ||||||
|  |  * workaround of a php-bug in PHP for windows | ||||||
|  |  *  | ||||||
|  |  * @author fbastage at yahoo dot com | ||||||
|  |  * @link https://bugs.php.net/bug.php?id=51184 | ||||||
|  |  * @param DateTime $dt1 | ||||||
|  |  * @param DateTime $dt2 | ||||||
|  |  * @param type $timeZone | ||||||
|  |  * @return type  | ||||||
|  |  */ | ||||||
|  | function daysdiff($dt1, $dt2, $timeZone = 'UTC') { | ||||||
|  |   $tZone = new DateTimeZone($timeZone); | ||||||
|  |    | ||||||
|  |   $dt1 = new DateTime($dt1, $tZone); | ||||||
|  |   $dt2 = new DateTime($dt2, $tZone);   | ||||||
|  |    | ||||||
|  |   // use the DateTime datediff function IF we have a non-buggy version
 | ||||||
|  |   // there is a bug in many Windows implementations that diff() always returns
 | ||||||
|  |   // 6015  
 | ||||||
|  |   if( $dt1->diff($dt1)->format("%a") != 6015 ) { | ||||||
|  |     return $dt1->diff($dt2)->format("%a"); | ||||||
|  |   } | ||||||
|  |    | ||||||
|  |   // else let's use our own method
 | ||||||
|  | 
 | ||||||
|  |   $y1 = $dt1->format('Y');   | ||||||
|  |   $y2 = $dt2->format('Y'); | ||||||
|  |   $z1 = $dt1->format('z'); | ||||||
|  |   $z2 = $dt2->format('z'); | ||||||
|  |    | ||||||
|  |   $diff = intval($y1 * 365.2425 + $z1) - intval($y2 * 365.2425 + $z2); | ||||||
|  | 
 | ||||||
|  |   return $diff; | ||||||
|  | 
 | ||||||
|  | } | ||||||
| ?>
 | ?>
 | ||||||
		Laden …
	
	Tabelle hinzufügen
		
		In neuem Issue referenzieren