1<?php
2require __DIR__ . '/../vendor/autoload.php';
3
4$WIZ = new dokuwiki\plugin\dev\www\PluginWizard();
5try {
6    $archive = $WIZ->handle();
7    if ($archive) {
8        header('Content-Type: application/zip');
9        header('Content-Disposition: attachment; filename="plugin.zip"');
10        echo $archive;
11        exit;
12    }
13} catch (Exception $ignored) {
14    // errors should only happen when the frontend validation is ignored
15}
16
17header('Content-Type: text/html; charset=utf-8');
18?>
19<html lang="en">
20<head>
21    <title>DokuWiki Plugin Wizard</title>
22    <script type="text/javascript">
23        const ACTION_EVENTS = <?php echo json_encode($WIZ->getEvents(), JSON_THROW_ON_ERROR); ?>;
24    </script>
25
26    <link rel="stylesheet" href="style.css"/>
27    <link rel="stylesheet" href="awesomplete.css"
28    /
29</head>
30<body>
31<main>
32    <h1>DokuWiki Plugin Wizard</h1>
33
34
35    <div class="intro">
36        <p>
37            This wizard generates a <a href="https://www.dokuwiki.org/devel:plugins">DokuWiki plugin</a>
38            skeleton to help you get started with coding your plugin.
39            Before using it, you should familiarize your self with how plugins in DokuWiki work
40            and determine what components your plugin will need.
41        </p>
42
43        <p>
44            To use it, fill in the general plugin info and add plugin components. Once you're
45            done, click "create" and download your plugin skeleton.
46        </p>
47
48        <p>
49            Alternatively you can also use the <a href="https://www.dokuwiki.org/plugin:dev">dev plugin</a>.
50            This plugin will also come in handy when editing and extending your plugin later.
51        </p>
52    </div>
53
54    <noscript>
55        <div class="nojs">
56            Sorry, this wizard needs JavaScript to do its magic. It will not work with your
57            current setup.
58        </div>
59    </noscript>
60
61
62    <form action="index.php" method="post" id="ajax__plugin_wiz">
63
64        <section>
65            <div id="plugin_info">
66                <h2>Plugin Information</h2>
67
68                <label>
69                    <span>Plugin base name:</span>
70                    <input type="text" name="base" required="required" pattern="^[a-z0-9]+$"
71                           placeholder="yourplugin">
72                    <small>(lowercase, no special chars)</small>
73                </label>
74
75                <label>
76                    <span>A short description of what the plugin does:</span>
77                    <input type="text" name="desc" required="required"
78                           placeholder="A plugin to flurb the blarg">
79                </label>
80
81                <label>
82                    <span>Your name:</span>
83                    <input type="text" name="author" required="required" placeholder="Jane Doe">
84                </label>
85
86                <label>
87                    <span>Your E-Mail address:</span>
88                    <input type="text" name="mail" required="required" placeholder="jane@example.com">
89                </label>
90
91                <label>
92                    <span>URL for the plugin:</span>
93                    <input type="text" name="url" placeholder="https://www.dokuwiki.org/plugin:yourplugin">
94                    <small>(leave empty for default dokuwiki.org location)</small>
95                </label>
96
97                <label>
98                    <input type="checkbox" name="use_lang" value="1"/>
99                    <span>Use localization</span>
100                </label>
101
102                <label>
103                    <input type="checkbox" name="use_conf" value="1"/>
104                    <span>Use configuration</span>
105                </label>
106
107                <label>
108                    <input type="checkbox" name="use_tests" value="1" checked="checked" disabled="disabled"/>
109                    <span>Use unit tests</span>
110                    <small>(now always enabled)</small>
111                </label>
112            </div>
113
114            <div id="plugin_components">
115                <h2>Add Plugin Components</h2>
116
117                <label>
118                    <span>Type:</span>
119                    <select>
120                        <?php foreach ($WIZ->getPluginTypes() as $type) : ?>
121                            <option value="<?php echo $type ?>"><?php echo ucfirst($type) ?></option>
122                        <?php endforeach; ?>
123                    </select>
124                </label>
125
126                <label>
127                    <span>Add as a Sub-Component:</span>
128                    <input type="text" value="" pattern="^[a-z0-9]+$" placeholder="subcomponent"/>
129                    <small>(leave empty to add top level)</small>
130                </label>
131
132                <button type="button">Add Component</button>
133
134                <ul id="output"></ul>
135
136            </div>
137        </section>
138
139        <button type="submit" name="plugin_wiz_create">Create and Download<br>Plugin Skeleton</button>
140
141    </form>
142
143</main>
144<script src="awesomplete.min.js"></script>
145<script src="script.js"></script>
146</body>
147</html>
148