plugin:timeline2
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plugin:timeline2 [2011-04-26 23:10] – [Development] 77.7.174.171 | plugin:timeline2 [2016-04-29 11:43] (current) – [Discussion] 87.223.101.51 | ||
---|---|---|---|
Line 2: | Line 2: | ||
---- plugin ---- | ---- plugin ---- | ||
- | description: | + | description: |
- | author | + | author |
- | email : ristigl@ratsgymnasium-pe.de | + | email : ristigl@ratsgymnasium-pe.de |
- | type : | + | type : |
lastupdate : 2011-04-26 | lastupdate : 2011-04-26 | ||
- | compatible : | + | compatible : Angua |
depends | depends | ||
conflicts | conflicts | ||
similar | similar | ||
- | tags : timeline | + | tags : timeline, time |
- | downloadurl: | + | downloadurl: |
- | bugtracker : # eg. http:// | + | bugtracker : # eg. https:// |
- | sourcerepo : # eg. http:// | + | sourcerepo : # eg. https:// |
donationurl: | donationurl: | ||
---- | ---- | ||
- | |||
===== Installation ===== | ===== Installation ===== | ||
Line 24: | Line 23: | ||
Refer to [[: | Refer to [[: | ||
- | Create a folder in the plugin-directory named timeline2, then copy the following syntax.php | + | Create a folder in the plugin-directory named timeline2, then copy the following syntax.php |
====syntax.php==== | ====syntax.php==== | ||
- | <code> | + | |
+ | <file php syntax.php> | ||
<?php | <?php | ||
/** | /** | ||
Line 319: | Line 319: | ||
//Setup VIM: ex: et ts=4 enc=utf-8 : | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
?> | ?> | ||
- | </code> | + | </file> |
====style.css==== | ====style.css==== | ||
- | <code> | + | |
+ | <file css style.css> | ||
div.TimeLine a, div.TimeLine a.wikilink1, | div.TimeLine a, div.TimeLine a.wikilink1, | ||
text-decoration: | text-decoration: | ||
Line 365: | Line 366: | ||
padding-bottom: | padding-bottom: | ||
display: | display: | ||
- | | + | |
- | top:-2.8em; | + | |
left:-1px; | left:-1px; | ||
border:1px solid black; | border:1px solid black; | ||
Line 409: | Line 409: | ||
margin-right: | margin-right: | ||
} | } | ||
- | </code> | + | </file> |
===== Examples/ | ===== Examples/ | ||
Line 431: | Line 431: | ||
hmm | hmm | ||
</ | </ | ||
+ | |||
+ | ==== HTML output ==== | ||
{{http:// | {{http:// | ||
+ | |||
+ | ==== LaTeX output ==== | ||
{{http:// | {{http:// | ||
+ | There is a hover effekt for the events that isn't shown on the screenshot. | ||
===== Syntax ===== | ===== Syntax ===== | ||
Line 464: | Line 469: | ||
===== FAQ ===== | ===== FAQ ===== | ||
- | |||
// | // | ||
+ | |||
+ | - How do I get this working with Latex? | ||
+ | |||
+ | Hi, I get the following error everytime I save a page that contains a timeline:\\ | ||
+ | Warning: Cannot modify header information - headers already sent by (output started at / | ||
+ | |||
+ | After reloading | ||
+ | I run " | ||
+ | Any ideas on that? | ||
+ | |||
+ | Cheers, Thomas | ||
===== Discussion ===== | ===== Discussion ===== | ||
Line 472: | Line 487: | ||
+ | Much better then my own! 8-) , Wbr, Oleg Karachevtsev | ||
+ | |||
+ | :?: Question: is the plugin running well right now? I tried to install it but have problems which means that the charts are not displayed but rows of numbers (weeks)? | ||
+ | |||
+ | ==== Issue: Declarations handle/ | ||
+ | |||
+ | This plugins works here, but i get this warning messages, top of the webpage. | ||
+ | |||
+ | <code php> | ||
+ | Warning: Declaration of syntax_plugin_timeline2:: | ||
+ | |||
+ | Warning: Declaration of syntax_plugin_timeline2:: | ||
+ | </ | ||
+ | ===== Proposal ===== | ||
+ | I modified the code to allow for alternate date formats (see new constants) so that we in countries that insist on continuing to do things the nonsensical way can use this awesome plugin with m/d/Y. | ||
+ | |||
+ | <code php syntax.php> | ||
+ | <?php | ||
+ | |||
+ | /** | ||
+ | * Add TimeLine capability to dokuwiki | ||
+ | * | ||
+ | * < | ||
+ | * highlite=dd/ | ||
+ | * ... | ||
+ | * </ | ||
+ | * | ||
+ | * @license | ||
+ | * @author | ||
+ | */ | ||
+ | if (!defined(' | ||
+ | define(' | ||
+ | if (!defined(' | ||
+ | define(' | ||
+ | require_once(DOKU_PLUGIN . ' | ||
+ | |||
+ | class syntax_plugin_timeline2 extends DokuWiki_Syntax_Plugin | ||
+ | { | ||
+ | |||
+ | var $scale = 0; | ||
+ | var $bgcolor_interval = ' | ||
+ | var $bgcolor_highlight = ' | ||
+ | |||
+ | //Indexes for the order the date elements appear | ||
+ | const DAYINDEX = 1; //for US, would be 2 | ||
+ | const MONTHINDEX = 2; //for US, would be 1 | ||
+ | const YEARINDEX = 3; | ||
+ | //The desired date format, indexes above should match the order they appear | ||
+ | const DATEFORMAT = ' | ||
+ | |||
+ | |||
+ | function getInfo() | ||
+ | { | ||
+ | return array( | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ); | ||
+ | } | ||
+ | |||
+ | function getType() | ||
+ | { | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | function getPType() | ||
+ | { | ||
+ | return ' | ||
+ | } | ||
+ | |||
+ | function getAllowedTypes() | ||
+ | { | ||
+ | return array(' | ||
+ | } | ||
+ | |||
+ | function getSort() | ||
+ | { | ||
+ | return 195; | ||
+ | } | ||
+ | |||
+ | function accepts($mode) | ||
+ | { | ||
+ | if ($mode == substr(get_class($this), | ||
+ | return true; | ||
+ | return parent:: | ||
+ | } | ||
+ | |||
+ | function connectTo($mode) | ||
+ | { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function postConnect() | ||
+ | { | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function reinitvars() | ||
+ | { | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | $this-> | ||
+ | } | ||
+ | |||
+ | function handle($match, | ||
+ | { | ||
+ | |||
+ | switch ($state) { | ||
+ | |||
+ | case DOKU_LEXER_ENTER : | ||
+ | $interval = trim(substr($match, | ||
+ | if (strlen($interval)) { | ||
+ | return array($state, | ||
+ | } | ||
+ | return array($state, | ||
+ | |||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | return array($state, | ||
+ | |||
+ | default: | ||
+ | return array($state); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function render($mode, | ||
+ | { | ||
+ | |||
+ | if ($mode == ' | ||
+ | list($state, | ||
+ | |||
+ | switch ($state) { | ||
+ | case DOKU_LEXER_ENTER : | ||
+ | $this-> | ||
+ | preg_match(" | ||
+ | preg_match(" | ||
+ | preg_match(" | ||
+ | preg_match(" | ||
+ | if (isset($scale)) { | ||
+ | $this-> | ||
+ | if (isset($legend[1])) | ||
+ | $this-> | ||
+ | } | ||
+ | if (isset($color[1])) { | ||
+ | $this-> | ||
+ | } | ||
+ | # Get interval to by shown | ||
+ | if (preg_match('/ | ||
+ | $matches[1] = $match[self:: | ||
+ | } | ||
+ | if (preg_match('/ | ||
+ | |||
+ | $matches[2] = $match[self:: | ||
+ | } | ||
+ | $dt = array($matches[1], | ||
+ | $this-> | ||
+ | $i = 0; | ||
+ | # Check all days for labels and get number of days in interval | ||
+ | while (strtotime($dt[1]) >= strtotime(" | ||
+ | $daytime = strtotime(" | ||
+ | if (isset($this-> | ||
+ | if ($this-> | ||
+ | $this-> | ||
+ | } elseif ($this-> | ||
+ | $this-> | ||
+ | } elseif ($this-> | ||
+ | $this-> | ||
+ | } | ||
+ | } | ||
+ | $i++; | ||
+ | } | ||
+ | $this-> | ||
+ | break; | ||
+ | case DOKU_LEXER_UNMATCHED : | ||
+ | preg_match_all(" | ||
+ | for ($m = 0;; $m++) { | ||
+ | if (!isset($matchesall[0][$m])) { | ||
+ | break; | ||
+ | } | ||
+ | unset($matches); | ||
+ | $matches[1] = $matchesall[1][$m]; | ||
+ | $matches[2] = $matchesall[2][$m]; | ||
+ | if (isset($matchesall[3][$m]) && strlen($matchesall[3][$m])) | ||
+ | $matches[3] = $matchesall[3][$m]; | ||
+ | if (isset($matchesall[4][$m]) && strlen($matchesall[4][$m])) | ||
+ | $matches[4] = $matchesall[4][$m]; | ||
+ | if (isset($matchesall[5][$m]) && strlen($matchesall[5][$m])) | ||
+ | $matches[5] = $matchesall[5][$m]; | ||
+ | if (isset($matchesall[6][$m]) && strlen($matchesall[6][$m])) | ||
+ | $matches[6] = $matchesall[6][$m]; | ||
+ | if (preg_match('/ | ||
+ | $matches[1] = $match[self:: | ||
+ | } | ||
+ | if (preg_match('/ | ||
+ | $matches[2] = $match[self:: | ||
+ | } | ||
+ | $dt = Array($matches[1], | ||
+ | |||
+ | # Get start and end of event in days in interval | ||
+ | $i = 0; | ||
+ | $lasse_event = array(); | ||
+ | while (strtotime($this-> | ||
+ | $daytime_a = strtotime(" | ||
+ | $daytime_b = strtotime(" | ||
+ | if ($daytime_a == strtotime($dt[0])) { | ||
+ | $lasse_event[0] = $i; | ||
+ | } | ||
+ | if ($daytime_b == strtotime($dt[1])) { | ||
+ | $lasse_event[1] = $i; | ||
+ | } | ||
+ | $i++; | ||
+ | } | ||
+ | # start , | ||
+ | $this-> | ||
+ | } | ||
+ | break; | ||
+ | case DOKU_LEXER_EXIT : | ||
+ | // --------------------------------------------------------------------- | ||
+ | // xhtml | ||
+ | // --------------------------------------------------------------------- | ||
+ | if ($mode == " | ||
+ | // --------------- Render bars --------------------- | ||
+ | $renderer-> | ||
+ | if ($this-> | ||
+ | foreach ($this-> | ||
+ | $renderer-> | ||
+ | } | ||
+ | foreach ($this-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | if ($value[3]) { | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | // -------------- Render Legend -------------------- | ||
+ | if ($this-> | ||
+ | $renderer-> | ||
+ | foreach ($this-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | if ($value[3]) { | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | |||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | |||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | break; | ||
+ | } | ||
+ | // --------------------------------------------------------------------- | ||
+ | // Latex | ||
+ | // --------------------------------------------------------------------- | ||
+ | if ($mode == " | ||
+ | // ------------------- Render bars ----------------- | ||
+ | $w = 16; | ||
+ | $h = count($this-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | # date at top | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | # Ticks | ||
+ | if ($this-> | ||
+ | foreach ($this-> | ||
+ | $xp = ($value[1] * $w / $this-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | } | ||
+ | # Events | ||
+ | $i = 0; | ||
+ | foreach ($this-> | ||
+ | $i++; | ||
+ | $xps = ($value[0] * $w / $this-> | ||
+ | $xpe = ($value[1] * $w / $this-> | ||
+ | $yp = $h - ($i - 0.5) * $this-> | ||
+ | $renderer-> | ||
+ | if ($value[3] or $value[4]) { | ||
+ | if ($xpe - $xps > 3) { | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | if ($xps > $w / 3) { | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | } | ||
+ | if ($value[4]) { | ||
+ | $a = $value[4]; | ||
+ | } else { | ||
+ | $a = $value[3]; | ||
+ | } | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | } | ||
+ | // ----------------- Render Legend ----------------- | ||
+ | $renderer-> | ||
+ | if ($this-> | ||
+ | $renderer-> | ||
+ | foreach ($this-> | ||
+ | $renderer-> | ||
+ | if ($value[4]) { | ||
+ | $renderer-> | ||
+ | } else { | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | $renderer-> | ||
+ | } | ||
+ | $renderer-> | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | } | ||
+ | return true; | ||
+ | } | ||
+ | return false; | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | //Setup VIM: ex: et ts=4 enc=utf-8 : | ||
+ | ?> | ||
+ | </ | ||
plugin/timeline2.1303852252.txt.gz · Last modified: 2011-04-26 23:10 by 77.7.174.171