xref: /plugin/mikioplugin/carousel.php (revision c5ddbc362b94c7c487d36277ab86a4675f27d029)
1<?php
2if (!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../../');
3require_once(DOKU_INC . 'inc/init.php');
4
5class CarouselRenderer extends Doku_Renderer
6{
7    public function getFormat()
8    {
9        return 'xhtml';
10    }
11};
12
13$core = new syntax_plugin_mikioplugin_core();
14$renderer = new CarouselRenderer();
15
16if (isset($_GET['id'])) {
17    $content = rawWiki($_GET['id']);
18    preg_match('/<carousel[^-item].*?>.*?<\/carousel>/s', $content, $matches);
19    if (count($matches) > 0) {
20        preg_match('/<[^\/].*?>/s', $matches[0], $tags);
21        foreach ($tags as $tag) {
22            preg_match_all('/([^\r\n\t\f\v<>= \'"]+)(?:=(["\'])?((?:.(?!\2?\s+(?:\S+)=|\2))+[^>])\2?)?/', $tag, $attributes);
23
24            if (count($attributes) > 0) {
25                $tagName = $attributes[1][0];
26                $tagAttribs = array();
27
28                for ($i = 1; $i < count($attributes[1]); $i++) {
29                    $value = $attributes[3][$i];
30                    if (strlen($value) == 0) {
31                        $value = true;
32                    }
33
34                    $tagAttribs[$attributes[1][$i]] = $value;
35                }
36
37                $core->syntaxRender($renderer, $tagName, '', $tagAttribs);
38            }
39        }
40
41        echo '<html lang=en><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><link type="text/css" rel="stylesheet" href="assets/external.css"/><link type="text/css" rel="stylesheet" href="css.php?css=/assets/variables.less,/assets/styles.less"/><script src="../../scripts/jquery/jquery.min.js"></script><script src="script.js"></script></head><body id="dokuwiki__content">';
42        echo $renderer->doc;
43        echo '</body></html>';
44    } else {
45        die('No carousels where found on the page');
46    }
47} else {
48    die('No page id was set in the url');
49}
50
51
52/*
53<carousel slide start dynamic-prefix="IMAGINED THING" dynamic=engagement:grumpus:grumpuslandonline:rrldev:thewell>
54
55Array
56(
57    [0] => Array
58        (
59            [0] => carousel
60            [1] => slide
61            [2] => start
62            [3] => dynamic-prefix="IMAGINED THING"
63            [4] => dynamic=engagement:grumpus:grumpuslandonline:rrldev:thewell
64        )
65
66    [1] => Array
67        (
68            [0] => carousel
69            [1] => slide
70            [2] => start
71            [3] => dynamic-prefix
72            [4] => dynamic
73        )
74
75    [2] => Array
76        (
77            [0] =>
78            [1] =>
79            [2] =>
80            [3] => "
81            [4] =>
82        )
83
84    [3] => Array
85        (
86            [0] =>
87            [1] =>
88            [2] =>
89            [3] => IMAGINED THING
90            [4] => engagement:grumpus:grumpuslandonline:rrldev:thewell
91        )
92
93)
94
95*/