1<?php
2/**
3 * Bootstrap Wrapper: Popup helper
4 *
5 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author     Giuseppe Di Terlizzi <giuseppe.diterlizzi@gmail.com>
7 * @copyright  (C) 2015-2020, Giuseppe Di Terlizzi
8 */
9
10$doku_inc_dirs = array(
11    '/opt/bitnami/dokuwiki',                       # Bitnami (Docker)
12    '/usr/share/webapps/dokuwiki',                 # Arch Linux
13    '/usr/share/dokuwiki',                         # Debian/Ubuntu
14    '/app/dokuwiki',                               # LinuxServer.io (Docker),
15    realpath(dirname(__FILE__) . '/../../../../'), # Default DokuWiki path
16);
17
18# Load doku_inc.php file
19#
20if (file_exists(dirname(__FILE__) . '/../doku_inc.php')) {
21    require_once dirname(__FILE__) . '/../doku_inc.php';
22}
23
24if (!defined('DOKU_INC')) {
25    foreach ($doku_inc_dirs as $dir) {
26        if (!defined('DOKU_INC') && @file_exists("$dir/inc/init.php")) {
27            define('DOKU_INC', "$dir/");
28        }
29    }
30}
31
32if (!file_exists(DOKU_INC)) {
33    print 'Problem with DOKU_INC directory. Please check your DokuWiki installation directory!';
34    die;
35}
36
37
38define('DOKU_MEDIAMANAGER', 1); // needed to get proper CSS/JS
39
40require_once DOKU_INC . 'inc/init.php';
41require_once DOKU_INC . 'inc/template.php';
42require_once DOKU_INC . 'inc/lang/en/lang.php';
43require_once DOKU_INC . 'inc/lang/' . $conf['lang'] . '/lang.php';
44
45global $lang;
46global $conf;
47global $JSINFO;
48global $INPUT;
49
50$JSINFO['id']        = '';
51$JSINFO['namespace'] = '';
52
53$NS = cleanID($INPUT->str('ns'));
54
55$tmp = array();
56trigger_event('MEDIAMANAGER_STARTED', $tmp);
57session_write_close(); //close session
58
59$syntax = array();
60
61foreach (scandir(dirname(__FILE__) . '/../syntax/') as $file) {
62
63    if ($file == '.' || $file == '..') {
64        continue;
65    }
66
67    $file              = str_replace('.php', '', $file);
68    $syntax_class_name = "syntax_plugin_bootswrapper_$file";
69    $syntax_class      = new $syntax_class_name;
70
71    if ($file == 'macros') {
72        continue;
73    }
74
75    if ($tag_name = $syntax_class->tag_name) {
76        $tag_attributes = $syntax_class->tag_attributes;
77        if ($tag_name == 'pills' || $tag_name == 'tabs') {
78            unset($tag_attributes['type']);
79        }
80        $syntax[$tag_name] = $tag_attributes;
81    }
82
83}
84
85ksort($syntax);
86
87header('Content-Type: text/html; charset=utf-8');
88header('X-UA-Compatible: IE=edge,chrome=1');
89
90?><!DOCTYPE html>
91<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $conf['lang'] ?>" lang="<?php echo $conf['lang'] ?>" dir="<?php echo $lang['direction'] ?>" class="no-js">
92<head>
93  <meta charset="UTF-8" />
94  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
95  <title>Bootstrap Wrapper Plugin</title>
96  <script>(function(H){H.className=H.className.replace(/\bno-js\b/,'js')})(document.documentElement)</script>
97  <meta name="viewport" content="width=device-width,initial-scale=1" />
98  <?php
99        if (tpl_getConf('themeByNamespace')) {
100            echo '<link href="' . tpl_basedir() . 'css.php?id='. cleanID("$NS:start") .'" rel="stylesheet" />';
101        }
102  ?>
103  <?php echo tpl_favicon(array('favicon', 'mobile')) ?>
104  <?php tpl_metaheaders()?>
105  <!--[if lt IE 9]>
106  <script type="text/javascript" src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
107  <script type="text/javascript" src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
108  <![endif]-->
109  <script type="text/javascript" src="popup.js" <?php echo ((isset($conf['defer_js']) && $conf['defer_js']) ? 'defer="defer"' : '') ?>></script>
110  <style>
111    body { padding-top: 10px; }
112    footer { padding-top: 100px; }
113    aside .nav li { margin: 0; }
114    aside .nav li a { padding: 1px 5px !important; }
115    pre#preview { white-space: pre-wrap; }
116  </style>
117</head>
118<body class="container-fluid dokuwiki">
119
120  <div class="row">
121    <aside class="small col-xs-2">
122      <ul class="nav nav-pills nav-stacked" role="tablist">
123
124        <?php foreach (array_keys($syntax) as $tag): ?>
125        <li>
126          <a data-toggle="tab" href="#tab-<?php echo $tag ?>" data-component="<?php echo $tag ?>"><?php echo ucfirst($tag) ?></a>
127        </li>
128        <?php endforeach?>
129
130      </ul>
131    </aside>
132
133    <main class="col-xs-10 tab-content">
134
135      <?php foreach ($syntax as $tag => $item): ?>
136      <div id="tab-<?php echo $tag ?>" class="tab-pane fade">
137
138        <?php if (file_exists(dirname(__FILE__) . '/help/' . $tag . '.txt')): ?>
139        <div class="text-right">
140          <button title="Help <?php echo $tag ?>" type="button" data-help="help.php?syntax=<?php echo $tag ?>" data-toggle="modal" data-target="#help-modal" class="btn btn-xs btn-primary help-btn">
141            <i class="fa fa-question-circle"></i>
142        </button>
143        </div>
144        <?php endif;?>
145
146        <h3><?php echo ucfirst($tag) ?></h3>
147        <p>&nbsp;</p>
148
149        <form class="form-horizontal">
150          <?php foreach ($item as $type => $data): ?>
151            <div class="form-group">
152              <label class="col-sm-2 control-label"><?php echo $type ?></label>
153              <div class="col-sm-10 attribute" data-attribute-type="<?php echo $data['type'] ?>" data-attribute-name="<?php echo $type ?>">
154                <?php
155                    switch ($data['type']) {
156
157                        case 'string':
158                            if (is_array($data['values'])) {
159                                echo '<select class="form-control">';
160                                echo '<option></option>';
161                                foreach ($data['values'] as $value) {
162                                    echo '<option ' . (($data['default'] == $value) ? 'selected="selected"' : '') . ' value="' . $value . '" class="text-' . $value . '">' . $value . '</option>';
163                                }
164                                echo '</select>';
165                            } else {
166                                echo '<input type="text" class="form-control" />';
167                            }
168                            break;
169
170                        case 'boolean':
171                            echo '<input type="checkbox" class="checkbox-inline" />';
172                            break;
173
174                        case 'integer':
175                            echo '<input type="number" min="' . @$data['min'] . '" max="' . @$data['max'] . '" value="' . $data['default'] . '" class="form-control" />';
176                            break;
177                    }
178                ?>
179              </div>
180            </div>
181          <?php endforeach;?>
182        </form>
183
184      </div>
185      <?php endforeach;?>
186
187      <div class="preview-box hide">
188
189        <h5>Preview</h5>
190
191        <pre id="preview"></pre>
192
193        <input type="hidden" id="output" />
194        <input type="hidden" id="component" />
195
196      </div>
197
198    </main>
199
200  </div>
201
202  <footer>
203    <nav class="navbar navbar-default navbar-fixed-bottom">
204      <div class="container-fluid">
205        <div class="navbar-text">
206          <button type="button" id="btn-preview" class="hidden btn btn-default">Preview code</button>
207          <button type="button" id="btn-insert" class="btn btn-success">Insert</button>
208          <button type="button" id="btn-reset" class="btn btn-default">Reset</button>
209        </div>
210      </div>
211    </nav>
212  </footer>
213
214  <div class="modal fade" tabindex="-1" role="dialog" id="help-modal">
215    <div class="modal-dialog modal-lg" role="document">
216      <div class="modal-content">
217        <div class="modal-header">
218          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
219          <h4 class="modal-title"><i class="fa fa-question-circle"></i> Help</h4>
220        </div>
221        <div class="modal-body px-5"></div>
222        <div class="modal-footer">
223          <button type="button" class="btn btn-default btn-primary" data-dismiss="modal">
224            <i class="fa fa-times"></i> Close
225          </button>
226        </div>
227      </div>
228    </div>
229  </div>
230
231</body>
232</html>
233