1<?php
2/**
3 * DokuWiki Plugin fetchmedia (Admin Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Michael Große <dokuwiki@cosmocode.de>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class admin_plugin_fetchmedia extends DokuWiki_Admin_Plugin {
13    /**
14     * Should carry out any processing required by the plugin.
15     */
16    public function handle() {
17    }
18
19    /**
20     * Render HTML output, e.g. helpful text and a form
21     */
22    public function html() {
23        $doc = '<h1>'.$this->getLang('menu').'</h1>';
24
25        $doc .= $this->locale_xhtml('intro');
26
27        $form = new \dokuwiki\Form\Form(['id' => 'fetchmedia_form']);
28        $form->addFieldsetOpen();
29        $form->addTextInput('namespace', $this->getLang('label: namespace input'))->attrs([
30            'inputmode' => 'verbatim',
31            'pattern' => '[-a-z0-9_:/;\.]+',
32            'placeholder' => 'name:space',
33            'title' => $this->getLang('title: namespace input hint'),
34            'required' => 'required',
35            'autofocus' => 'autofocus,'
36        ]);
37        $form->addHTML('<br />');
38        $radioCommon = $form->addRadioButton('mediatypes', $this->getLang('label: common media only'))->val('common')->attr('required', 'required');
39        $radioWin = $form->addRadioButton('mediatypes', $this->getLang('label: windows shares'))->val('windows-shares')->attr('required', 'required');
40        $radioAll = $form->addRadioButton('mediatypes', $this->getLang('label: all media'))->val('all')->attr('required', 'required');
41
42        if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
43            $radioAll->attr('disabled', 'disabled');
44            $radioWin->attr('disabled', 'disabled');
45            $radioCommon->attr('checked', 'checked');
46        } else {
47            $radioWin->attr('checked', 'checked');
48        }
49
50        $form->addButton('submit', $this->getLang('label: button search'));
51        $form->addFieldsetClose();
52
53        $doc .= '<div id="plugin_fetchmedia_page">';
54        $doc .= $form->toHTML();
55        $doc .= '<div id="fetchmedia_results"></div>';
56        $doc .= '</div>';
57        echo $doc;
58    }
59}
60
61// vim:ts=4:sw=4:et:
62