DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:countdown

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
plugin:countdown [2010-10-31 13:04] – [Discussion] 82.243.184.242plugin:countdown [2022-05-31 17:08] (current) – [Fix for "DateInterval::format() expects exactly 1 parameter, 0 given”] kkue
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description: Countdown to a specific date. +description: Countdown to a specific date 
-author     : Luis Machuca B.+author     : Luis Machuca Bezzaza (previous authors)
 email      : luis.machuca [at] gulix.cl email      : luis.machuca [at] gulix.cl
 type       : syntax type       : syntax
-lastupdate : 2009-12-19 +lastupdate : 2020-11-01 
-compatible :+compatible : Lemming, Anteater, Weatherwax, Binky, Frusterick Manners, Greebo
 depends    : depends    :
 conflicts  : conflicts  :
 similar    : similar    :
 tags       : counter, date tags       : counter, date
 +version    : 3.0
  
-downloadurl: http://ryan.gulix.cl/dw/_media/desarrollo/dokuwiki/dw-plugin-countdown-latest.zip+downloadurl: https://chiselapp.com/user/lmachucab/repository/dokuwiki-plugin-countdown/zip/countdown.zip 
 +sourceurl  : https://chiselapp.com/user/lmachucab/repository/dokuwiki-plugin-countdown 
 +bugtracker : https://chiselapp.com/user/lmachucab/repository/dokuwiki-plugin-countdown/reportlist 
 +donationurl: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T44AQDXJQJTJQ&source=url
  
 ---- ----
Line 19: Line 23:
 The **Countdown Plugin** shows a countdown to a specific (target) date. The **Countdown Plugin** shows a countdown to a specific (target) date.
  
-**Under new management since June 11, 2009**.+**Under new management since June 11, 2009**.\\ 
 +-Previously maintained by [[ekkart@ekkart.de|Ekkart Kleinod]] (since version 2.x).\\ 
 +-Based on even earlier work by [[rbpeters@peterro.com|Ron Peters]] (version 1.0).\\ 
 +-Which was itself a modified version of the [[http://wakka.xiffy.nl/countdown|nucleuswiki]] plugin by Trent Adams and Edmond Hui\\
  
-Previously maintained by [[ekkart@ekkart.de|Ekkart Kleinod]] (since version 2.x).+**Important:** users of versions 2.x should upgrade if they have PHP 7.3 or 7.4.
  
-Based on even earlier work by [[rbpeters@peterro.com|Ron Peters]] (version 1.0).+**Important:** version 2.x is not compatible with version 1.0 (syntax change of date)
  
-Which was itself a modified version of the [[http://wakka.xiffy.nl/countdown|nucleuswiki]] plugin by Trent Adams and Edmond Hui+===== Download and Installation ===== 
 +Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
  
-**Important:** version 2.x is not compatible with version 1.0 (syntax change of date)+:!: It is recommended you upgrade the plugin if you are using PHP>=7.0 to avoid some warnings in the code, thanks to Stefan Huehner for the corrections.
  
-===== Attention: new maintainer needed -> found =====+==== Previous Versions ====
  
-Due to changes in my homepage backend I no longer develop this pluginI will host the plugin until a new maintainer is foundPlease contact me if a new maintainer takes over the development+**Download links for previous version**: 
 +  * [[https://chiselapp.com/user/lmachucab/repository/dokuwiki-plugin-countdown/]] - source control. 
 +  * [[http://www.ekkart.de/wp-content/plugins/download-monitor/download.php?id=6]].
  
-Regards, Ekkart. 
- 
->Hi, Ekkart. I've already mailed you asking to take over the development. But of course you might want to wait JIC someone else applies too. Kind regards.  --- //[[luis.machuca@gulix.cl|Luis Machuca B.]] 2009/05/26 06:09// 
->>Hi Luis, sorry for not answering, I'm afraid, your mail was put into the spam folder. It's okay for me if you develop the plugin further. All files are in the zip archive. Regards, Ekkart. 
->>>Thanks, Ekkart. As of **June 11, 2009, I'm taking over the development of this plugin**. As a first task I've implemented a demo and download page, and I'll start implementing the feature requests soon, starting with the language files. Anyone interested in contributing their language can send me patches as per [[#Internationalisation]]. Thanks. --  --- //[[luis.machuca@gulix.cl|Luis Machuca B.]] 2009/06/12 06:30// 
  
-===== Description =====+===== Usage =====
  
-With this [[:Plugins|plugin]] you can insert a countdown into your page where it will display the number of days, and optionally hours and minutes, until or since the text that you include.+With this [[:Plugins|plugin]] you can insert a countdown into your page where it will display the number of days, and optionally hours and minutes, until or since a specified timestamp, adding a description of the event as well.
  
 The format is: The format is:
Line 47: Line 52:
   <COUNTDOWN:date|description>   <COUNTDOWN:date|description>
  
-This will be replaced with either+This will be replaced with either:
  
   XX days [HH:MM] until description   XX days [HH:MM] until description
   XX days [HH:MM] since description   XX days [HH:MM] since description
  
-(where the ''[HH:MM]'' part is optional)+(where the ''[HH:MM]'' part is controlled via plugin config)
  
-Possible formats of //date// are all [[http://www.gnu.org/software/tar/manual/html_node/tar_115.html#SEC115|GNU date formats]] that are allowed by [[http://www.php.net/strtotime|strtotime]].+Possible formats of //date// are all [[http://www.gnu.org/software/tar/manual/html_node/tar_115.html#SEC115|GNU date formats]] that are allowed by [[phpfn>strtotime]].
 Examples: Examples:
  
   <COUNTDOWN:mm/dd/yyyy|day to remember>   <COUNTDOWN:mm/dd/yyyy|day to remember>
   <COUNTDOWN:dd.mm.yyyy|Ereignis>   <COUNTDOWN:dd.mm.yyyy|Ereignis>
 +  
 +Disable Page Caching so the plugin text can remain dynamic, insert this into any page using this plugin:
  
-===== Download/Installation/Examples ===== +  ~~NOCACHE~~
- +
-Download and install the plugin using the [[plugin:plugin|Plugin Manager]] using the above link which always points to the **latest version**. As of the date of September 2010, that is the version ''2.5rc'', with a 2.5 //final// planned for ends 2010. +
- +
-:!: If you are using a previous version of the plugin, it is recommended that you **uninstall** the previous version before installing the RC. +
- +
-**Download links for previous version**: +
-  * [[http://www.ekkart.de/wp-content/plugins/download-monitor/download.php?id=6]]. +
-  * [[http://200.11.76.165/~lmachuca/dokuwiki-lucho/_media/desarrollo/informatica/dokuwiki/dw-plugin-countdown-213.zip|dw-plugin-countdown-213.zip at new maintainer's demo page]] +
- +
-Refer to [[:Plugins]] on how to install plugins manually. +
- +
-:!: [[http://ryan.gulix.cl/dw/desarrollo/dokuwiki/plugin-countdown|(Neo) Demo Site]]. The site is in Spanish, but usage should be pretty obvious and language is neutral enough that even Google Translator shall do fine. An English demo page will be made available for the next release of the plugin. +
- +
-Examples of use and more information can be found on [[http://www.ekkart.de/?page_id=76|ekkart.de]]. +
- +
-^  {{http://ryan.gulix.cl/archivos/dokuwiki/scr-plugin-countdown-01.png?nolink}} +
-  The output of the ''countdown'' plugin, showing our remaining time to the\\ Mayan "//End of Days//" (''2012-12-22''). |+
  
  
Line 84: Line 74:
 The plugin is configurable in some ways since version 2.0. The plugin is configurable in some ways since version 2.0.
  
-There are three parameters that are configurable, via either ''local.php'' or the Configuration Manager:+There are seven parameters that are configurable, via either ''local.php'' or the Configuration Manager:
  
-**Visibility of Countdown Date**: +Visibility of Target Date  || 
- +^ Parameter ''include_date'' (boolean| If set, the target date is shown in the plugin output.   |
-The parameter ''include_date'' is a Boolean that determines whether to show (''true'') or not (''false'') the target date in the output.+
  
 Example: Example:
-  $conf['include_date'] = false; +  (with option disabled)
-results in+
   XX days until description   XX days until description
- +  (with option enabled)
-  $conf['include_date'] = true; +
-results in+
   XX days until description (mm/dd/yyyy)   XX days until description (mm/dd/yyyy)
  
-**Short for for Today**: +Short form for today  || 
- +| Parameter ''use_today'' (boolean)  | If set, events that are due today are simply shown as "Today" (or a national equivalent for supported languages).   |
-The parameter ''use_today'' is a Boolean that determines whether to switch the output of the countdown to the short, simple form "Today" if the countdown date is today (''true'').+
  
 Example: Example:
-  $conf['use_today'] = true; +  (with option enabled) 
-results in+
   Today is description   Today is description
  
-**Display hours and minutes**:+Display Remaining Hours || 
 +| Parameter ''with_hours'' (boolean)  | If set, the output includes the remaining hours and minutes of the day (''HH:MM'').  \\ It is disabled by default to preserve compatibility with older plugin versions.  |
  
-The parameter ''with_hours'' is a Boolean that determines whether to show hours and minutes as well as days in the output (''true''). It defaults to **''false''** to maintain output compatibility with previous versions of the plugin. +Examples
- +  (with option enabled)
-Example+
-  $conf['with_hours'] = true; +
-results in+
   XX days HH:MM until description (mm/dd/yyyy)   XX days HH:MM until description (mm/dd/yyyy)
 +
 +^ Display All Days ||
 +^ Parameter ''with_alldays'' (boolean)  | If set, the output shows the output as the total amount of days (as if using strftime flag "''%a''"), instead of splitting into years, months and days.  |
 +
 +Examples:
 +  (with option diabled)
 +  BB months DD days HH:MM until description (mm/dd/yyyy)
 +  (with option enabled)
 +  NNNNN days HH:MM until description (mm/dd/yyyy)
 +
 +^ Display Business Days (estimate)  ||
 +^ Parameter ''business_days'' (boolean)  | If set, the countdown is shown as an estimate of business days (that is, week days not counting Sat and Sun).  |
 +
 +Examples:
 +  (with option enabled)
 +  XX (BB) days until description
 +
 +^ Announce Server Time  ||
 +^ Parameter ''time_message'' (boolean)  | If set, this plugin will add a notice to DokuWiki's notification bar indicating the current time as read by the **server**. \\ This option might be useful for remote servers whose timezone might change periodically.   |
 +
 +Examples:
 +  (with option enabled)
 +  (the following sample message will show on DokuWiki's notification bar)
 +  Server time for Countdown plugin is: 2011-03-08 12:45
 +
  
 ===== Internationalisation ===== ===== Internationalisation =====
Line 126: Line 133:
  
 The following languages are included: The following languages are included:
 +
   * German (de), English (en) by Ekkart Kleinod   * German (de), English (en) by Ekkart Kleinod
   * Estonian (et) by Mikk Leini   * Estonian (et) by Mikk Leini
Line 137: Line 145:
 ===== Versions ===== ===== Versions =====
  
 +  * :!: version 3.0 (2020-11-01): fixes a number of recorded bugs, fixes a 1-day miscount in some events, and allows using a wider range of dates as supported by PHP's ''DateTime'' classes (instead of being limited to POSIX timestamps).
 +  * version 2.6 (2019-01-13): corrections for PHP >= 7.0. The source code is moved to an online repository as well.
 +  * version 2.5rc2 (2011-03-11) maintained by Luis Machuca Bezzaza: correction of a one-day-time bug and addition of the option to display business days and server time; minor overall improvements; plugin.info.txt compatibility.
   * version 2.5rc (2009-12-19) maintained by Luis Machuca Bezzaza: Czech, Spanish and Br-Portuguese language files, ability to display hours, general code rewrite to use getLang(), [[xref>getConf]] capabilities, added README, CHANGELOG and VERSION.   * version 2.5rc (2009-12-19) maintained by Luis Machuca Bezzaza: Czech, Spanish and Br-Portuguese language files, ability to display hours, general code rewrite to use getLang(), [[xref>getConf]] capabilities, added README, CHANGELOG and VERSION.
   * version 2.1.3 (2009-01-24) maintained by Ekkart Kleinod: French language file   * version 2.1.3 (2009-01-24) maintained by Ekkart Kleinod: French language file
Line 145: Line 156:
   * version 2.0 (2008-02-18) maintained by Ekkart Kleinod: language and configuration options, code rewrite   * version 2.0 (2008-02-18) maintained by Ekkart Kleinod: language and configuration options, code rewrite
   * version 1.0 maintained by Ron Peters: basic functionality   * version 1.0 maintained by Ron Peters: basic functionality
 +
 ===== Discussion ===== ===== Discussion =====
 +''with_alldays'' does not work for me. Regardless of whether I set ''with_alldays'' to 0 or 1 in the local.php, something like "288 days until" is still showing in the wiki. All other options appear to work. I also do not see this option exposed in the Configuration Manager page. Using NOCACHE, cleared browser cache, stop/start Doku site. Using latest Doku (Hogfather), PHP 7.4.1, Windows 10, \\ Also, feature request - would LOVE to have a progress bar included in this, like the one in [[https://www.dokuwiki.org/plugin:progrecss|progrecss]]. So user can see a visual of the countdown as well.
  
 Does this plugin work properly with leap years? Does this plugin work properly with leap years?
Line 173: Line 186:
  
 The ability to display "business days" would be very helpful for those who use this at work. Dumping in a little JavaScript or something to make it count down by the second would be neat to... The ability to display "business days" would be very helpful for those who use this at work. Dumping in a little JavaScript or something to make it count down by the second would be neat to...
 +>This feature has been added, albeit in a simple way, in version 2.5.rc2.  --- [[user>ryan.chappelle|Luis Machuca Bezzaza]] //2011/03/12 20:41//
  
 ---- ----
Line 200: Line 214:
 </php> </php>
 </code> </code>
 +>This was apparently a bug caused y leftover code, and seems to be fixed in the newest release.
  
-==== Bug line 127 : ====+==== de-informal ==== 
 +We set the global wiki language "lang" to de-informal. Because there is no such dir in lang, language defaults to english. This was a bit tricky to find out. I set a symlink with "de-informal" to "de", and now it works just fine. 
 + 
 + 
 +==== Bug line 127 syntax.php : ====
    
  
Line 209: Line 228:
           } else {           } else {
                      
-you have to change it to :+you have to change it to : (getLand --> getlang)
                      
                     // check parsed date                     // check parsed date
Line 215: Line 234:
             $renderer->doc .= $this->getLang('wrongformat'). $data[0] . ": " . $data[1];             $renderer->doc .= $this->getLang('wrongformat'). $data[0] . ": " . $data[1];
           } else {           } else {
 +
 +>Will get to fix it. Thanks for letting me know!  --- [[user>ryan.chappelle]] //2010/11/03 16:50//
 +
 +==== Attention: new maintainer needed -> found ====
 +
 +Due to changes in my homepage backend I no longer develop this plugin. I will host the plugin until a new maintainer is found. Please contact me if a new maintainer takes over the development. 
 +
 +Regards, Ekkart.
 +
 +>Hi, Ekkart. I've already mailed you asking to take over the development. But of course you might want to wait JIC someone else applies too. Kind regards.  --- //[[luis.machuca@gulix.cl|Luis Machuca B.]] 2009/05/26 06:09//
 +>>Hi Luis, sorry for not answering, I'm afraid, your mail was put into the spam folder. It's okay for me if you develop the plugin further. All files are in the zip archive. Regards, Ekkart.
 +>>>Thanks, Ekkart. As of **June 11, 2009, I'm taking over the development of this plugin**. As a first task I've implemented a demo and download page, and I'll start implementing the feature requests soon, starting with the language files. Anyone interested in contributing their language can send me patches as per [[#Internationalisation]]. Thanks. --  --- //[[luis.machuca@gulix.cl|Luis Machuca B.]] 2009/06/12 06:30//
 +
 +==== do not show the Description ====
 +
 +I installed the plugin an try it, but the description will not displayed.
 +have a look to: http://pichat-wiki.de/countdown
 +
 +Regards, Mark W.
 +
 +>Fixed in the latest update. Can't believe I just missed one or two lines of code. --  --- [[user>ryan.chappelle|Luis Machuca Bezzaza]] //2011/06/06 00:14//
 +>> updated and it works, thx  --- [[user>oh-mark|oh-mark]] //2011/06/11 02:52//
 +
 +
 +==== ADDON select language ====
 +
 +created by  --- [[user>oh-mark|oh-mark]] //2011/06/11 06:18//
 +
 +if your language for the countdown plugin is different from the prefered language 
 +you need to modify the .../lib/plugins/countdown/syntax.php
 +
 +to select the language during the admin configuration
 +replace the original .../lib/plugins/countdown/conf/metadata.php
 +
 +so we have now two ways to change the language
 +  - per default in the config manager
 +  - with the extented syntax: <COUNTDOWN:date|description|language>
 +
 +i have an example on http://pichat-wiki.de/countdown#countdown
 +
 +=== new .../lib/plugins/countdown/conf/metadata.php ===
 + 
 +
 +<code php>
 +<?php
 +/**
 + * Metadata configuration for countdown plugin.
 + *
 + * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
 + * @author  Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>
 + */
 +
 +$meta['include_date'] = array('onoff');
 +$meta['use_today'   = array('onoff');
 +$meta['with_hours'  = array('onoff');
 +
 +/// The two following configurations are in a beta state
 +$meta['business_days'] = array('onoff');
 +$meta['time_message'] = array('onoff');
 +
 +//---------------------------------------------------------------
 +/**
 + * Addon for Metadata configuration for countdown plugin.
 + *
 + * @author Mark Wolfgruber
 + *  
 + */
 +
 +if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
 +
 +// Source: http://www.easy-coding.de/wiki/php/ordner-auslesen-mit-php.html
 +// if not exist PHP 5 a function named scandir
 +if (!function_exists('scandir')) {
 + function scandir($directory, $sorting_order=0) {
 + if(!is_dir($directory)) {
 + return false; 
 + }
 + $files = array();
 + $handle = opendir($directory);
 + while (false !== ($filename = readdir($handle))) {
 + $files[] = $filename; 
 + }
 + closedir($handle);
 + 
 + if($sorting_order == 1) {
 + rsort($files); 
 + } else {
 + sort($files); 
 + }
 + return $files;
 + }
 +}
 +
 +// define countdown language directory
 +$countdown_lang_folder = DOKU_INC.'lib/plugins/countdown/lang';
 +
 +// read countdown language directory
 +foreach(scandir($countdown_lang_folder) as $file) {
 + if($file[0] != '.') { // do display hidden files
 + if(is_dir($countdown_lang_folder.'/'.$file)) { // read directories
 + $countdown_lang_folderArray[] = $file;
 + } else { // read files (not needed at the moment)
 + $countdown_lang_fileArray[] = $file;
 + }
 + }
 +}
 +$meta['language'      = array('multichoice','_choices' => $countdown_lang_folderArray);
 +</code>
 +
 +=== modification 1 of the .../lib/plugins/countdown/syntax.php ===
 +
 +
 +<code php>
 +   /**
 +    *   Plugin-Addon Language for Countdown-Plugin   
 +    *   this function is a copy of .../lib/plugins/syntax.php and
 +    *   replace the function setupLocale() for this class    
 +    *   only two lines are added
 +    *   insert function setupLocale() directly behind: class syntax_plugin_countdown extends DokuWiki_Syntax_Plugin {    
 +    */ 
 +    function setupLocale() {
 +        if ($this->localised) return;
 +
 +      global $conf;            // definitely don't invoke "global $lang"
 +      $path = DOKU_PLUGIN.$this->getPluginName().'/lang/';
 +
 +      // don't include once, in case several plugin components require the same language file
 +      @include($path.'en/lang.php');
 +    
 +      if ($conf['lang'] != 'en') @include($path.$conf['lang'].'/lang.php');
 +      // add following 2 lines 
 +      if ($this->getConf('countdown_language')) @include($path.$this->getConf('countdown_language').'/lang.php');
 +      if ($this->countdown_language) @include($path.$this->countdown_language.'/lang.php');
 +
 +      $this->lang = $lang;
 +      $this->localised = true;
 +    }
 +</code>
 +
 +
 +
 +=== modification 2 of the .../lib/plugins/countdown/syntax.php ===
 +
 +
 +add in function render($mode, &$renderer, $data) behind\\
 +''$description= $data[1] ? $data[1] : $this->getLang('nodesc');''
 +
 +<code php>
 +        // check for new language data
 +        if ($data[2]) {
 +          if ($this->countdown_language != $data[2]) $this->localised = false;
 +          $this->countdown_language=$data[2];
 +        } else {
 +          if ($this->countdown_language != $this->getConf('countdown_language')) $this->localised = false;
 +          $this->countdown_language=$this->getConf('countdown_language');
 +        }
 +</code>
 +
 +==== Feature: Annual Timer ====
 +Is it possible to have it so the countdown automatically rolls over once it has reached its target so it has a new target of next year. 
 +
 +The idea I have in mind is to have a countdown to someones birthday, and once it has reached the end of the birthday day, it increments the target year by 1 and starts the countdown all over again.
 +
 +Cheers 
 +
 + --- [[user>Jaella|Jaella]] //2012/11/23 15:44//
 +
 +
 +==== 1250 days? ====
 +>Is it a way to show up how many **Years, Month, Days, Hours** - till to the target in 2045? There are too many days to be able to figure out when will take actually place the event...
 +
 + --- [[user>florinko-gmail|Florin]] //2015/03/24//
 +
 +> This one is in the plans, but is unfortunately not yet tested, as the strategy used for internationalization inherited from legacy versions of the plugin, makes it //incredibly annoying// to support (requiring extra string for each and every component of a date, in singular and plural).  --- [[user>ryan-chappelle|ryan-chappelle]] //2020-11-02 05:11//
 +
 +==== 1 day miscount ====
 +In the latest version there is still a problem with day count.
 +To fix that problem next code:
 +<code php>
 +$difference = $diffseconds / 86400;
 +</code>
 +has to be replaced by the following:
 +<code php>
 +$difference = ceil($diffseconds / 86400);
 +</code>
 +in plugin's **syntax.php** file.
 +
 + --- [[user>florinko-gmail|Anders]] //2015/11/13//
 +
 +> The plugin now uses PHP's ''DateTime'' faciities, so this should in theory no longer be an issue.   --- [[user>ryan-chappelle|ryan-chappelle]] //2020-11-02 05:11//
 +
 +==== Fix for "DateInterval::format() expects exactly 1 parameter, 0 given”  ====
 +Add quotes in format-brackets, Line 89:
 +<code php>
 +$Text1= $dt_diff->format("");
 +</code>
 + --- [[user>kkue|kkue]] //2022-05-31 17:04//
  
plugin/countdown.1288526665.txt.gz · Last modified: 2010-10-31 13:04 by 82.243.184.242

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki