liberty
[ class tree: liberty ] [ index: liberty ] [ all elements ]

Source for file data.countdown.php

Documentation is available at data.countdown.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2004, bitweaver.org
  9. // +----------------------------------------------------------------------+
  10. // | All Rights Reserved. See below for details and a complete list of authors.
  11. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  12. // |
  13. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  14. // | -> see http://phpdocu.sourceforge.net/
  15. // +----------------------------------------------------------------------+
  16. // | Author (TikiWiki): Stephan Borg <wolff_borg@users.sourceforge.net>
  17. // | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
  18. // | by: StarRider <starrrider@users.sourceforge.net>
  19. // +----------------------------------------------------------------------+
  20. // $Id$
  21.  
  22. /**
  23.  * definitions
  24.  */
  25. define'PLUGIN_GUID_DATACOUNTDOWN''datacountdown' );
  26. global $gLibertySystem;
  27. $pluginParams array (
  28.     'tag' => 'COUNTDOWN',
  29.     'auto_activate' => FALSE,
  30.     'requires_pair' => FALSE,
  31.     'load_function' => 'data_countdown',
  32.     'title' => 'CountDown',
  33.     'help_page' => 'DataPluginCountDown',
  34.     'description' => 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)."),
  35.     'help_function' => 'data_countdown_help',
  36.     'syntax' => "{COUNTDOWN enddate= localtime= class= punct= text=}",
  37.     'plugin_type' => DATA_PLUGIN
  38. );
  39. $gLibertySystem->registerPluginPLUGIN_GUID_DATACOUNTDOWN$pluginParams );
  40. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATACOUNTDOWN );
  41.  
  42. // Help Function
  43. function data_countdown_help({
  44.     $help =
  45.         '<table class="data help">'
  46.             .'<tr>'
  47.                 .'<th>' tra"Key" '</th>'
  48.                 .'<th>' tra"Type" '</th>'
  49.                 .'<th>' tra"Comments" '</th>'
  50.             .'</tr>'
  51.             .'<tr class="odd">'
  52.                 .'<td>enddate</td>'
  53.                 .'<td>' tra"string"'<br />' tra("(mandatory)"'</td>'
  54.                 .'<td>' tra"A date used to compare to the present date. Several date formats are accepted, but spelling it out like this: <strong>May 10 2004</strong> is probably the simplest. A time can be include with the date like this: <strong>20:02:00 or 8:02pm</strong> . There is <strong>NO</strong> Default."'</td>'
  55.             .'</tr>'
  56.             .'<tr class="even">'
  57.                 .'<td>localtime</td>'
  58.                 .'<td>' tra"boolean"'<br />' tra("(optional)"'</td>'
  59.                 .'<td>' tra"Determins if Local Time is displayed or not. Passing any value in this parameter will make it <strong>TRUE</strong>. The Default = <strong>FALSE</strong> so Local Time will not be displayed"'</td>'
  60.             .'</tr>'
  61.             .'<tr class="odd">'
  62.                 .'<td>class</td>'
  63.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  64.                 .'<td>' tra"Classname of the SPAN surrounding the countdown. The date/time segments are each wrapped in a VAR-Tag. Default = countdown"'</td>'
  65.             .'</tr>'            
  66.             .'<tr class="even">'
  67.                 .'<td>punct</td>'
  68.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  69.                 .'<td>' 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: &amp;nbsp;"'</td>'
  70.             .'</tr>'            
  71.             .'<tr class="odd">'
  72.                 .'<td>text</td>'
  73.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  74.                 .'<td>' tra"Text to be displayed after the date/time string. It's wrapped in &lt;em&gt;."'</td>'
  75.             .'</tr>'            
  76.         .'</table>'
  77.         .'<p>' tra("Example 1: "'<input value="{COUNTDOWN enddate=\'8:02pm May 10 2004\' localtime=\'on\' text=\'' tra(" - Time Passes So Slowly"'\'}" type="text" size="40" /></p>'
  78.         .'<p>' tra("Example 2: "'<input value="{COUNTDOWN enddate=\'2012-12-22 00:01\' class=\'alert red\' punct=\', \' text=\'Purple Haze\'}" type="text" size="40" /></p>'
  79.     ;
  80.     return $help;
  81. }
  82.  
  83. // Load Function
  84. function data_countdown($data,$params{
  85.     // The next 2 lines allow access to the $pluginParams given above
  86.     global $gLibertySystem;
  87.     $pluginParams $gLibertySystem->mPlugins[PLUGIN_GUID_DATACOUNTDOWN];
  88.     extract ($paramsEXTR_SKIP);
  89.     
  90.     if (!isset($enddate) ) {  // The Mandatory Parameter is missing
  91.         $ret tra("The required parameter ""<strong>enddate</strong>" tra(" was missing from the plugin "'<strong>"' $pluginParams['tag''"</strong>';
  92.         $ret.= data_countdown_help();
  93.         return $ret;
  94.     }
  95.     
  96.     $then strtotime ($enddate);
  97.     
  98.     if ($then == -1// strtotime failed so enddate was not a valid date
  99.         $ret tra("__Error__ - The plugin "'<strong>"' $pluginParams['tag''"</strong>' tra(" was not given a valid date. The date given was:\n""enddate=$enddate";
  100.         return $ret;
  101.     }
  102.     
  103.     if (isset($localtime&& $localtime == 'on' && isset($_COOKIE['tz_offset'])) {
  104.         $tz $_COOKIE['tz_offset'];
  105.     else {
  106.         $tz 0;
  107.     }
  108.     
  109.     if (!isset($class)) {
  110.         $class 'countdown';
  111.     }
  112.     
  113.     if (!isset($punct)) {
  114.         $punct " ";
  115.     }
  116.  
  117.     if (!isset($text)) {
  118.         $text "";
  119.     }
  120.  
  121.     
  122.     $now strtotime ("now"$tz;
  123.     $difference $then $now;
  124.     $num $difference/86400;
  125.     $days intval($num);
  126.     $num2 ($num $days)*24;
  127.     $hours intval($num2);
  128.     $num3 ($num2 $hours)*60;
  129.     $mins intval($num3);
  130.     $num4 ($num3 $mins)*60;
  131.     $secs intval($num4);
  132.     $ret "
  133.         <span class='".$class."'>"
  134.         . "<var>" $days  " " tra("days")    "</var>" $punct
  135.         . "<var>" $hours " " tra("hours")   "</var>" $punct
  136.         . "<var>" $mins  " " tra("minutes""</var>" $punct
  137.         . "<var>" $secs  " " tra("seconds""</var>" " "
  138.         . "<em>"  $text  "</em>"
  139.         . "</span>"
  140.     ;
  141.     return $ret;
  142. }
  143. ?>

Documentation generated on Wed, 29 Jul 2015 13:56:18 +0000 by phpDocumentor 1.5.0-lsces