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    public $excludePattern = "";
43
44    /**
45     * @param siteexport_functions $functions
46     */
47    public function __construct($functions) {
48        global $ID, $conf, $INPUT;
49
50        $functions->debug->setDebugFile($this->getConf('debugFile'));
51        $debugLevel = $INPUT->int('debug', -1, true);
52        if ( $debugLevel >= 0 && $debugLevel <= 5) {
53            $functions->debug->setDebugLevel($debugLevel);
54        } else
55        {
56            $functions->debug->setDebugLevel($this->getConf('debugLevel'));
57        }
58
59        $functions->debug->isAJAX = $this->getConf('ignoreAJAXError') ? false : $functions->debug->isAJAX;
60
61        // Set the pattern
62        $this->pattern = $INPUT->str('pattern');
63        if ( empty( $this->pattern ) )
64        {
65            $params = $_REQUEST;
66            $this->pattern = $functions->requestParametersToCacheHash($params);
67        }
68
69        $this->isCLI = (!$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name());
70
71        $this->cachetime = $this->getConf('cachetime');
72        if ( $INPUT->has( 'disableCache' ) ) {
73            $this->cachetime = 0;
74        }
75
76        // Load variables
77        $this->origZipFile = $this->getConf('zipfilename');
78
79        $this->ignoreNon200 = $this->getConf('ignoreNon200');
80
81        // ID
82        $this->downloadZipFile = $functions->getSpecialExportFileName($this->origZipFile, $this->pattern);
83        //        $this->eclipseZipFile = $functions->getSpecialExportFileName(getNS($this->origZipFile) . ':' . $this->origEclipseZipFile, $this->pattern);
84
85        $this->zipFile = mediaFN($this->downloadZipFile);
86
87        $this->tmpDir = mediaFN(getNS($this->origZipFile));
88        $this->exportLinkedPages = $INPUT->bool( 'exportLinkedPages', true );
89
90        $this->namespace = $functions->getNamespaceFromID( $INPUT->str('ns'), $PAGE );
91        $this->addParams = $INPUT->bool( 'addParams' );
92
93        $this->useTOCFile = $INPUT->bool( 'useTocFile' );
94
95        // set export Namespace - which is a virtual Root
96        $pg = noNS($ID);
97        if (empty($this->namespace)) { $this->namespace = $functions->getNamespaceFromID(getNS($ID), $pg); }
98        $ens = $INPUT->str( 'ens' );
99        $this->exportNamespace = !empty($ens) && preg_match("%^" . preg_quote($functions->getNamespaceFromID($ens, $pg), '%') . "%", $this->namespace) ? $functions->getNamespaceFromID($ens, $pg) : $this->namespace;
100
101        $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation'] ?? 0) == 1 ? true : false;
102
103        $this->defaultLang = $INPUT->str( 'defaultLang', $conf['lang'], true );
104
105        // Strip params that should be forwarded
106        $this->additionalParameters = $_REQUEST;
107        $functions->removeWikiVariables($this->additionalParameters, true);
108
109        if ( $INPUT->has( 'disableCache' ) ) {
110            $this->additionalParameters['nocache']=1;
111        }
112
113        $this->excludePattern = $INPUT->str( 'exclude', $this->getConf('exclude'), true );
114    }
115}
116