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 revision Previous revision
Next revision
Previous revision
plugin:countdown [2011-05-31 23:10]
79.254.105.114
plugin:countdown [2019-10-02 00:35] (current)
florious [Download and Installation]
Line 2: Line 2:
  
 ---- plugin ---- ---- plugin ----
-description:​ Countdown to a specific date.+description:​ Countdown to a specific date
 author ​    : Luis Machuca Bezzaza (previous authors) author ​    : Luis Machuca Bezzaza (previous authors)
 email      : luis.machuca [at] gulix.cl email      : luis.machuca [at] gulix.cl
 type       : syntax type       : syntax
-lastupdate : 2011-03-11 +lastupdate : 2019-01-13 
-compatible : 2010-11-07+compatible : Lemming, Anteater, Weatherwax, Binky, Frusterick Manners, Greebo
 depends ​   : depends ​   :
 conflicts ​ : conflicts ​ :
Line 13: Line 13:
 tags       : counter, date tags       : counter, date
  
-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-clacks 
 +bugtracker : https://​chiselapp.com/​user/​lmachucab/​repository/​dokuwiki-plugin-countdown/​reportlist 
 +donationurl: ​
  
 ---- ----
Line 19: Line 22:
 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).\\ 
-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\\
-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+
  
 **Important:​** version 2.x is not compatible with version 1.0 (syntax change of date) **Important:​** version 2.x is not compatible with version 1.0 (syntax change of date)
  
 ===== Download and Installation ===== ===== Download and Installation =====
 +Search and install the plugin using the [[plugin:​extension|Extension Manager]]. Refer to [[:​Plugins]] on how to install plugins manually.
  
-Download and install the plugin via the [[plugin:​plugin|Plugin Manager]] using the above link which always points to the **latest version**, or check the [[#​Demo|demo page]] for earlier versoins. ​As of the date of March 2011, the latest version is the version ''​2.5rc2''​, with a 2.5 //final// planned for May 2011.+As of the date of January 2019, the latest version is the version ''​2.6''​.
  
-Refer to [[:Plugins]] on how to install plugins manually.+:!: 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 correctionsAs the last version still needs to be recompiled, follow the solution bellow:
  
-:!: If you are using a previous version of the plugin, it is recommended that you **uninstall** the previous version before installing the RC.+Warningtime() expects exactly 0 parameters1 given in ...lib\plugins\countdown\syntax.php on line 140 
 +  * Just remove "​void"​ in line 140 to fix it ;) the result will be: 
 +    ​''​$t= time();''​ 
 +\\
  
 ==== Previous Versions ==== ==== Previous Versions ====
  
 **Download links for previous version**: **Download links for previous version**:
 +  * [[https://​chiselapp.com/​user/​lmachucab/​repository/​dokuwiki-plugin-countdown/​]] - source control.
   * [[http://​ryan.gulix.cl/​dw/​desarrollo/​dokuwiki/​inicio]] (archive of released 2.x versions)   * [[http://​ryan.gulix.cl/​dw/​desarrollo/​dokuwiki/​inicio]] (archive of released 2.x versions)
   * [[http://​www.ekkart.de/​wp-content/​plugins/​download-monitor/​download.php?​id=6]].   * [[http://​www.ekkart.de/​wp-content/​plugins/​download-monitor/​download.php?​id=6]].
Line 72: Line 77:
   <​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:
 +
 +  ~~NOCACHE~~
  
  
Line 147: Line 156:
 ===== Versions ===== ===== Versions =====
  
 +  * :!: 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.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.
Line 214: Line 224:
 </​code>​ </​code>​
 >This was apparently a bug caused y leftover code, and seems to be fixed in the newest release. >This was apparently a bug caused y leftover code, and seems to be fixed in the newest release.
 +
 +==== 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 : ==== ==== Bug line 127 syntax.php : ====
Line 249: Line 263:
 Regards, Mark W. 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//​
 +
 +==== 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//​
plugin/countdown.1306876231.txt.gz · Last modified: 2011-05-31 23:10 by 79.254.105.114