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