see http://phpdocu.sourceforge.net/ // +----------------------------------------------------------------------+ // | Author (TikiWiki): Stephan Borg // | Reworked for Bitweaver (& Undoubtedly Screwed-Up) // | by: StarRider // +----------------------------------------------------------------------+ // $Id$ /** * definitions */ define( 'PLUGIN_GUID_DATACOUNTDOWN', 'datacountdown' ); global $gLibertySystem; $pluginParams = [ 'tag' => 'COUNTDOWN', 'auto_activate' => false, 'requires_pair' => false, 'load_function' => '\data_countdown', 'title' => 'CountDown', 'help_page' => 'DataPluginCountDown', 'description' => KernelTools::tra("Displays a Count-Down until a date:time is reached - then - negative numbers indicate how long it has been since that date. The Count-Down is displayed in the format of (X days, X hours, X minutes and X seconds)."), 'help_function' => '\data_countdown_help', 'syntax' => "{COUNTDOWN enddate= localtime= class= punct= text=}", 'plugin_type' => DATA_PLUGIN, ]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATACOUNTDOWN, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATACOUNTDOWN ); // Help Function function data_countdown_help() { $help = '' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'' .'
' . KernelTools::tra( "Key" ) . '' . KernelTools::tra( "Type" ) . '' . KernelTools::tra( "Comments" ) . '
enddate' . KernelTools::tra( "string") . '
' . KernelTools::tra("(mandatory)") . '
' . KernelTools::tra( "A date used to compare to the present date. Several date formats are accepted, but spelling it out like this: May 10 2004 is probably the simplest. A time can be include with the date like this: 20:02:00 or 8:02pm . There is NO Default.") . '
localtime' . KernelTools::tra( "boolean") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Determins if Local Time is displayed or not. Passing any value in this parameter will make it true. The Default = false so Local Time will not be displayed") . '
class' . KernelTools::tra( "string") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Classname of the SPAN surrounding the countdown. The date/time segments are each wrapped in a VAR-Tag. Default = countdown") . '
punct' . KernelTools::tra( "string") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Any kind of punctuation to divide the date/time segments from each other, a comma, a colon, a pipe ... Default = space. To put a non breaking space, use HTML:  ") . '
text' . KernelTools::tra( "string") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Text to be displayed after the date/time string. It's wrapped in <em>.") . '
' .'

' . KernelTools::tra("Example 1: ") . '

' .'

' . KernelTools::tra("Example 2: ") . '

' ; return $help; } // Load Function function data_countdown($data,$params) { // The next 2 lines allow access to the $pluginParams given above global $gLibertySystem; $pluginParams = $gLibertySystem->mPlugins[PLUGIN_GUID_DATACOUNTDOWN]; extract ($params, EXTR_SKIP); if (!isset($enddate) ) { // The Mandatory Parameter is missing $ret = KernelTools::tra("The required parameter ") . "enddate" . KernelTools::tra(" was missing from the plugin ") . '"' . $pluginParams['tag'] . '"'; $ret.= data_countdown_help(); return $ret; } $then = strtotime ($enddate); if ($then == -1) { // strtotime failed so enddate was not a valid date $ret = KernelTools::tra("__Error__ - The plugin ") . '"' . $pluginParams['tag'] . '"' . KernelTools::tra(" was not given a valid date. The date given was:\n") . "enddate=$enddate"; return $ret; } $tz = isset($localtime) && $localtime == 'on' && isset($_COOKIE['tz_offset']) ? $_COOKIE['tz_offset'] : 0; if (!isset($class)) { $class = 'countdown'; } if (!isset($punct)) { $punct = " "; } if (!isset($text)) { $text = ""; } $now = strtotime ("now") + $tz; $difference = $then - $now; $num = $difference/86400; $days = (int) $num; $num2 = ($num - $days)*24; $hours = (int) $num2; $num3 = ($num2 - $hours)*60; $mins = (int) $num3; $num4 = ($num3 - $mins)*60; $secs = (int) $num4; $ret = " " . "" . $days . " " . KernelTools::tra("days") . "" . $punct . "" . $hours . " " . KernelTools::tra("hours") . "" . $punct . "" . $mins . " " . KernelTools::tra("minutes") . "" . $punct . "" . $secs . " " . KernelTools::tra("seconds") . "" . " " . "" . $text . "" . "" ; return $ret; }