xref: /plugin/siteexport/inc/settings.php (revision 0571ece201b9e3bc14846f6c88d943a4f1512014)
1<?php
2
3if (!defined('DOKU_PLUGIN')) die('meh');
4class settings_plugin_siteexport_settings extends DokuWiki_Plugin
5{
6    var $fileType = 'html';
7    var $exportNamespace = '';
8    var $pattern = null;
9
10    var $isCLI = false;
11
12    var $depth = '';
13
14    var $zipFile = '';
15//    var $origEclipseZipFile = 'doc.zip';
16//    var $eclipseZipFile = '';
17    var $addParams = false;
18    var $origZipFile = '';
19    var $downloadZipFile = '';
20    var $exportLinkedPages = true;
21    var $additionalParameters = array();
22    var $isAuthed = false;
23
24    var $TOCMapWithoutTranslation = false;
25
26    var $cachetime = 0;
27    var $hasValidCacheFile = false;
28
29    var $useTOCFile = false;
30    var $cookie = null;
31
32    var $ignoreNon200 = true;
33
34    var $defaultLang = 'en';
35
36    /**
37     * @param siteexport_functions $functions
38     */
39    function settings_plugin_siteexport_settings($functions) {
40        global $ID, $conf;
41
42        $functions->debug->setDebugFile($this->getConf('debugFile'));
43        if (!empty($_REQUEST['debug']) && intval($_REQUEST['debug']) >= 0 && intval($_REQUEST['debug']) <= 5) {
44            $functions->debug->setDebugLevel(intval($_REQUEST['debug']));
45        } else
46        {
47            $functions->debug->setDebugLevel($this->getConf('debugLevel'));
48        }
49
50        $functions->debug->isAJAX = $this->getConf('ignoreAJAXError') ? false : $functions->debug->isAJAX;
51
52        if (empty($_REQUEST['pattern']))
53        {
54            $params = $_REQUEST;
55            $this->pattern = $functions->requestParametersToCacheHash($params);
56        } else {
57            // Set the pattern
58            $this->pattern = $_REQUEST['pattern'];
59        }
60
61        $this->isCLI = (!$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name());
62
63        $this->cachetime = $this->getConf('cachetime');
64        if ( !empty( $_REQUEST['disableCache'] ) ) {
65            $this->cachetime = intval($_REQUEST['disableCache']) == 1 ? 0 : $this->cachetime;
66        }
67
68        // Load Variables
69        $this->origZipFile = $this->getConf('zipfilename');
70
71        $this->ignoreNon200 = $this->getConf('ignoreNon200');
72
73        // ID
74        $this->downloadZipFile = $functions->getSpecialExportFileName($this->origZipFile, $this->pattern);
75        //        $this->eclipseZipFile = $functions->getSpecialExportFileName(getNS($this->origZipFile) . ':' . $this->origEclipseZipFile, $this->pattern);
76
77        $this->zipFile = mediaFN($this->downloadZipFile);
78
79        $this->tmpDir = mediaFN(getNS($this->origZipFile));
80        $this->exportLinkedPages = !isset($_REQUEST['exportLinkedPages']) || intval($_REQUEST['exportLinkedPages']) == 1 ? true : false;
81
82        $this->namespace = $functions->getNamespaceFromID($_REQUEST['ns'], $PAGE);
83        $this->addParams = !empty($_REQUEST['addParams']);
84
85        $this->useTOCFile = !empty($_REQUEST['useTocFile']);
86
87        // set export Namespace - which is a virtual Root
88        $pg = noNS($ID);
89        if (empty($this->namespace)) { $this->namespace = $functions->getNamespaceFromID(getNS($ID), $pg); }
90        $this->exportNamespace = !empty($_REQUEST['ens']) && preg_match("%^" . preg_quote($functions->getNamespaceFromID($_REQUEST['ens'], $pg), '%') . "%", $this->namespace) ? $functions->getNamespaceFromID($_REQUEST['ens'], $pg) : $this->namespace;
91
92        $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation']) == 1 ? true : false;
93
94        $this->defaultLang = empty($_REQUEST['defaultLang']) ? $conf['lang'] : $_REQUEST['defaultLang'];
95
96        // Strip params that should be forwarded
97        $this->additionalParameters = $_REQUEST;
98        $functions->removeWikiVariables($this->additionalParameters, true);
99    }
100}
101
102?>