xref: /plugin/siteexport/inc/settings.php (revision 9801ffe085e62db6d25c8d936dc16913bcee6035)
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    /**
37     * @param siteexport_functions $functions
38     */
39    function __construct($functions) {
40        global $ID, $conf, $INPUT;
41
42        $functions->debug->setDebugFile($this->getConf('debugFile'));
43        $debugLevel = $INPUT->int('debug', -1, true);
44        if ( $debugLevel >= 0 && $debugLevel <= 5) {
45            $functions->debug->setDebugLevel($debugLevel);
46        } else
47        {
48            $functions->debug->setDebugLevel($this->getConf('debugLevel'));
49        }
50
51        $functions->debug->isAJAX = $this->getConf('ignoreAJAXError') ? false : $functions->debug->isAJAX;
52
53        // Set the pattern
54        $this->pattern = $INPUT->str('pattern');
55        if ( empty( $this->pattern ) )
56        {
57            $params = $_REQUEST;
58            $this->pattern = $functions->requestParametersToCacheHash($params);
59        }
60
61        $this->isCLI = (!$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name());
62
63        $this->cachetime = $this->getConf('cachetime');
64        if ( $INPUT->has( 'disableCache' ) ) {
65            $this->cachetime = 0;
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 = $INPUT->bool( 'exportLinkedPages', false, true );
81
82        $this->namespace = $functions->getNamespaceFromID( $INPUT->str('ns'), $PAGE );
83        $this->addParams = $INPUT->bool( 'addParams' );
84
85        $this->useTOCFile = $INPUT->bool( '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        $ens = $INPUT->str( 'ens' );
91        $this->exportNamespace = !empty($ens) && preg_match("%^" . preg_quote($functions->getNamespaceFromID($ens, $pg), '%') . "%", $this->namespace) ? $functions->getNamespaceFromID($ens, $pg) : $this->namespace;
92
93        $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation']) == 1 ? true : false;
94
95        $this->defaultLang = $INPUT->str( 'defaultLang', $conf['lang'], true );
96
97        // Strip params that should be forwarded
98        $this->additionalParameters = $_REQUEST;
99        $functions->removeWikiVariables($this->additionalParameters, true);
100    }
101}
102