1<?php
2/**
3 * Timeline Action Plugin -  Get Wiki page with data.
4 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
5 *
6 * Gets page content and returns it as text
7 *
8 * @author   Jerome Jangle <http://maestric.com/>
9 * @author   Tom Cafferty <tcafferty@glocalfocal.com>
10 * @param    string $dokuPageId pagename containing timeline data
11 * @returns  string $html       page content as text
12 *
13 */
14
15function pullInXmlData ($dokuPageId, $wikihtml) {
16
17    // don't refresh caches
18    unset($_REQUEST['purge']);
19    require_once DOKU_INC . '/inc/cache.php';
20
21    // from id parameter, build text file path
22    $pagePath = DOKU_INC . '/data/pages/'. str_replace(":", "/", $dokuPageId) . '.txt';
23
24    // get cached instructions for that file
25    $cache = new cache_instructions($dokuPageId, $pagePath);
26    if ($cache->useCache()){
27        $instructions = $cache->retrieveCache();
28    } else {
29        $instructions = p_get_instructions(io_readfile($pagePath));
30        $cache->storeCache($instructions);
31    }
32
33    // create plain text renderer
34    require_once 'plain.php';
35    $renderer = new Doku_Renderer_plain();
36
37    foreach ( $instructions as $instruction ) {
38        call_user_func_array(array(&$renderer, $instruction[0]),$instruction[1]);
39    }
40
41    // get rendered html
42    $html = $renderer->doc;
43
44	if ($wikihtml==1)
45      $ret_html = xmlentities(htmlentities($html, ENT_COMPAT));
46    else
47      $ret_html = $html;
48    return $ret_html;
49}
50
51function xmlentities ($in_string) {
52    $in_stuff    = array("[data]", "[/data]", "[event ", "[/event]", "]", "&quot;", "/^", "^/");
53    $out_stuff   = array("<data>", "</data>", "<event ", "</event>", ">", "'", "<sup>", "</sup>");
54    return str_replace($in_stuff, $out_stuff, $in_string);
55}