xref: /plugin/siteexport/admin.php (revision f8fd18e7a336bed77152ec99d1784601de467cee)
1<?php
2if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
3if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
4require_once(DOKU_PLUGIN.'admin.php');
5require_once(DOKU_PLUGIN.'siteexport/preload.php');
6
7/**
8 * All DokuWiki plugins to extend the admin function
9 * need to inherit from this class
10 */
11class admin_plugin_siteexport extends DokuWiki_Admin_Plugin {
12
13    var $templateSwitching = false;
14    var $pdfExport = false;
15    var $usenumberedheading = false;
16    var $cronEnabled = false;
17    var $translationAvailable = false;
18
19    /**
20     * Constructor
21     */
22    function __construct() {
23        $this->setupLocale();
24    }
25
26    /**
27     * for backward compatability
28     * @see inc/DokuWiki_Plugin#getInfo()
29     */
30    function getInfo(){
31        if ( method_exists(parent, 'getInfo')) {
32            $info = parent::getInfo();
33        }
34        return is_array($info) ? $info : confToHash(dirname(__FILE__).'/plugin.info.txt');
35    }
36
37    /**
38     * return sort order for position in admin menu
39     */
40    function getMenuSort() {
41        return 100;
42    }
43
44    function forAdminOnly(){
45        return false;
46    }
47
48    /**
49     * handle user request
50     */
51    function handle() {
52
53        if ( $functions=& plugin_load('preload', 'siteexport') && $functions->__create_preload_function() ) {
54            $this->templateSwitching = true;
55        }
56
57        if ( $functions =& plugin_load('action', 'dw2pdf' ) ) {
58            $this->pdfExport = true;
59        }
60
61        // if ( $functions =& plugin_load('renderer', 'nodetailsxhtml' ) ) {
62            $this->usenumberedheading = true;
63        // }
64
65        if ( $functions =& plugin_load('cron', 'siteexport' ) ) {
66            $this->cronEnabled = $functions->canWriteSettings();
67        }
68
69        if ( $functions =& plugin_load('helper', 'translation' ) ) {
70            $this->translationAvailable = true;
71        }
72    }
73
74    /**
75     * output appropriate html
76     */
77    function html() {
78        global $ID, $conf;
79
80        if ( ! $functions=& plugin_load('helper', 'siteexport') ) {
81            msg("Can't initialize");
82            return false;
83        }
84
85        $regenerateScript = '';
86        print $this->locale_xhtml('intro');
87
88        $form = new Doku_Form('siteexport', null, 'post');
89        $form->startFieldset( $this->getLang('startingNamespace') );
90
91        $form->addElement(form_makeTextField('ns', $ID, $this->getLang('ns') . ':', 'ns'));
92        $form->addElement(form_makeTag('br'));
93        $form->addElement(form_makeTextField('ens', $ID, $this->getLang('ens') . ':', 'ens'));
94
95        $form->addElement(form_makeTag('br'));
96        $form->addElement(form_makeListboxField('depthType', array( "0.0" => $this->getLang('depth.pageOnly'), "1.0" => $this->getLang('depth.allSubNameSpaces'), "2.0" => $this->getLang('depth.specifiedDepth') ), (empty($_REQUEST['depthType']) ? $this->getLang('depth.allSubNameSpaces') : $_REQUEST['depthType']), $this->getLang('depthType') . ':', 'depthType', null, array_merge(array('class' => 'edit'))));
97
98        $form->addElement(form_makeTag('br'));
99        $form->addElement(form_makeOpenTag("div", array('style' => 'display:' . ($_REQUEST['depthType'] == "2" ? "block" : "none") . ';', 'id' => 'depthContainer')));
100        $form->addElement(form_makeTextField('depth', $this->getConf('depth'), $this->getLang('depth') . ':', 'depth'));
101        $form->addElement(form_makeCloseTag("div"));
102
103        $form->addElement(form_makeTag('br'));
104        $form->addElement(form_makeOpenTag("div", array('style' => 'display:none;', 'id' => 'depthContainer')));
105        $form->addElement(form_makeCheckboxField('exportLinkedPages', 1, $this->getLang('exportLinkedPages') . ':', 'exportLinkedPages'));
106        $form->addElement(form_makeCloseTag("div"));
107
108        $form->endFieldset();
109        $form->addElement(form_makeTag('br'));
110
111        $form->startFieldset( $this->getLang('selectYourOptions') );
112        $form->addElement(form_makeCheckboxField('absolutePath', 1, $this->getLang('absolutePath') . ':', 'absolutePath'));
113        $form->addElement(form_makeTag('br'));
114        $form->addElement(form_makeCheckboxField('exportBody', 1, $this->getLang('exportBody') . ':', 'exportBody'));
115        $form->addElement(form_makeTag('br'));
116        $form->addElement(form_makeCheckboxField('disableCache', 1, $this->getLang('disableCache') . ':', 'disableCache'));
117        $form->addElement(form_makeTag('br'));
118        $form->addElement(form_makeCheckboxField('addParams', 1, $this->getLang('addParams') . ':', 'addParams', null, array_merge(array('checked' => ($conf['userewrite'] != 1 ? 'checked' : '' ) ))));
119        $form->addElement(form_makeTag('br'));
120        $form->addElement(form_makeTag('br'));
121        $form->addElement(form_makeListboxField('renderer', array_merge(array('','xhtml'), plugin_list('renderer')), '', $this->getLang('renderer') . ':', 'renderer', null, array_merge(array('class' => 'edit'))));
122
123        $form->addElement(form_makeTag('br'));
124        if ( $this->templateSwitching ) {
125            $form->addElement(form_makeListboxField('template', $functions->__getTemplates(), $conf['template'], $this->getLang('template') . ':', 'template', null, array_merge(array('class' => 'edit'))));
126            $form->addElement(form_makeTag('br'));
127        } else
128        {
129            $form->addElement(form_makeTag('br'));
130            $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' )));
131            $form->addElement('Can\'t create preload file in \'inc\' directory. Template switching is not available. Plugin disabling is not available.');
132            $form->addElement(form_makeCloseTag('p'));
133        }
134
135        $form->addElement(form_makeTag('br'));
136        $form->addElement(form_makeCheckboxField('pdfExport', 1, $this->getLang('pdfExport') . ':', 'pdfExport', null, $this->pdfExport ? array() : array_merge(array('disabled' => 'disabled')) ));
137        if ( !$this->pdfExport ) {
138            $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' )));
139            $form->addElement('In order to use the PDF export, please ');
140            $form->addElement(form_makeOpenTag('a', array('href' => 'http://www.dokuwiki.org/plugin:dw2pdf', 'alt' => 'install plugin', 'target' => '_blank')));
141            $form->addElement('install the dw2pdf plugin.');
142            $form->addElement(form_makeCloseTag('a'));
143            $form->addElement(form_makeCloseTag('p'));
144        }
145
146        $form->addElement(form_makeTag('br'));
147        $form->addElement(form_makeCheckboxField('usenumberedheading', 1, $this->getLang('usenumberedheading') . ':', 'usenumberedheading', null, $this->usenumberedheading && $this->pdfExport ? array() : array_merge(array('disabled' => 'disabled')) ));
148        $form->addElement(form_makeTag('br'));
149
150        if ( !$this->usenumberedheading ) {
151            $form->addElement(form_makeOpenTag('p', array('style' => 'color: #a00;' )));
152            $form->addElement('In order to use numbered headings, please ');
153            $form->addElement(form_makeOpenTag('a', array('href' => 'http://www.dokuwiki.org/plugin:nodetailsxhtml', 'alt' => 'install plugin', 'target' => '_blank')));
154            $form->addElement('install the nodetailsxhtml plugin.');
155            $form->addElement(form_makeCloseTag('a'));
156            $form->addElement(form_makeCloseTag('p'));
157        }
158
159        $form->endFieldset();
160        $form->addElement(form_makeTag('br'));
161
162        $form->startFieldset( $this->getLang('helpCreationOptions') );
163        $form->addElement(form_makeCheckboxField('eclipseDocZip', 1, $this->getLang('eclipseDocZip') . ':', 'eclipseDocZip'));
164        $form->addElement(form_makeTag('br'));
165        $form->addElement(form_makeCheckboxField('JavaHelpDocZip', 1, $this->getLang('JavaHelpDocZip') . ':', 'JavaHelpDocZip'));
166        $form->addElement(form_makeTag('br'));
167        $form->addElement(form_makeCheckboxField('useTocFile', 1, $this->getLang('useTocFile') . ':', 'useTocFile'));
168        $form->addElement(form_makeTag('br'));
169        $form->addElement(form_makeCheckboxField('emptyTocElem', 1, $this->getLang('emptyTocElem') . ':', 'emptyTocElem'));
170        $form->addElement(form_makeTag('br'));
171        if ( !$this->translationAvailable ) {
172            $form->addElement(form_makeCheckboxField('TOCMapWithoutTranslation', 1, $this->getLang('TOCMapWithoutTranslation') . ':', 'TOCMapWithoutTranslation'));
173            $form->addElement(form_makeTag('br'));
174        }
175        $form->endFieldset();
176        $form->addElement(form_makeTag('br'));
177
178        if ( $this->templateSwitching )
179        {
180            $form->startFieldset( $this->getLang('disablePluginsOption') );
181
182            $form->addElement(form_makeCheckboxField("disableall", 1, 'Disable All:', "disableall", 'forceVisible'));
183            $form->addElement(form_makeTag('br'));
184            $form->addElement(form_makeTag('br'));
185
186            list($allPlugins, $enabledPlugins) = $functions->__getPluginList();
187            foreach ( $allPlugins as $plugin ) {
188                $form->addElement(form_makeCheckboxField("disableplugin[]", $plugin, $plugin . ':', "disableplugin_$plugin", null, (!in_array($plugin, $enabledPlugins) ? array('checked' => 'checked', 'disabled' => 'disabled') : array() )));
189                $form->addElement(form_makeTag('br'));
190            }
191
192            $form->endFieldset();
193            $form->addElement(form_makeTag('br'));
194        }
195
196        $form->startFieldset( $this->getLang('customOptions') );
197        $form->addElement(form_makeOpenTag('p'));
198        $form->addElement( $this->getLang('customOptionsDescription') );
199        $form->addElement(form_makeCloseTag('p'));
200
201        $form->addElement(form_makeOpenTag('ul', array('id' => 'siteexport__customActions')));
202        $form->addElement(form_makeCloseTag('ul'));
203        $form->addElement(form_makeTag('br', array('class'=>'clear')));
204        $form->addElement(form_makeButton('submit', 'addoption', $this->getLang('addCustomOption') , array('style' => 'float:right;') ));
205
206        $form->endFieldset();
207        $form->addElement(form_makeTag('br'));
208
209        $form->startFieldset( $this->getLang('startProcess') );
210
211        $form->addElement(form_makeTextField('copyurl', "", $this->getLang('directDownloadLink') . ':', 'copyurl', null, array('readonly' => 'readonly') ));
212        $form->addElement(form_makeTag('br'));
213        $form->addElement(form_makeTextField('wgeturl', "", $this->getLang('wgetURLLink') . ':', 'wgeturl', null, array('readonly' => 'readonly') ));
214        $form->addElement(form_makeTag('br'));
215        $form->addElement(form_makeTextField('curlurl', "", $this->getLang('curlURLLink') . ':', 'curlurl', null, array('readonly' => 'readonly') ));
216        $form->addElement(form_makeTag('br', array('class'=>'clear')));
217        $form->addElement(form_makeButton('submit', 'siteexport', $this->getLang('start') , array('style' => 'float:right;')));
218        $form->endFieldset();
219        $form->addElement(form_makeTag('br'));
220
221        $form->startFieldset( $this->getLang('status') );
222        $form->addElement(form_makeOpenTag('span', array('id' => 'siteexport__out')));
223
224        $form->addElement(form_makeCloseTag('span'));
225        $form->addElement(form_makeOpenTag('span', array('class' => 'siteexport__throbber')));
226        $form->addElement(form_makeTag('img', array('src' => DOKU_BASE.'lib/images/loading.gif', 'id' => 'siteexport__throbber')));
227        $form->addElement(form_makeCloseTag('span'));
228        $form->endFieldset();
229        $form->addElement(form_makeTag('br'));
230
231        if ( $this->cronEnabled )
232        {
233            $form->startFieldset( $this->getLang('cronSaveProcess') );
234            $form->addElement(form_makeOpenTag('p'));
235            $form->addElement( $this->getLang('cronDescription') );
236            $form->addElement(form_makeCloseTag('p'));
237
238            $form->addElement(form_makeCheckboxField("cronOverwriteExisting", 1, $this->getLang('canOverwriteExisting'), "cronOverwriteExisting"));
239            $form->addElement(form_makeTag('br', array('class'=>'clear')));
240            $form->addElement(form_makeButton('submit', 'cronDeleteAction', $this->getLang('cronDeleteAction') , array('id' => 'cronDeleteAction', 'style' => 'float:left;display:none') ));
241            $form->addElement(form_makeButton('submit', 'cronSaveAction', $this->getLang('cronSaveAction') , array('id' => 'cronSaveAction', 'style' => 'float:right;') ));
242            $form->addElement(form_makeTag('br', array('class'=>'clear')));
243
244            $form->addElement(form_makeOpenTag('a', array('href' => '#cronactions', 'alt' => 'show cron jobs', 'id' => 'showcronjobs', 'target' => '_blank', 'style' => 'float:right;')));
245            $form->addElement('show all cron jobs');
246            $form->addElement(form_makeCloseTag('a'));
247
248            $form->endFieldset();
249        }
250
251        $form->printForm();
252    }
253}
254//Setup VIM: ex: et ts=4 enc=utf-8 :
255