xref: /plugin/siteexport/inc/settings.php (revision f8fd18e7a336bed77152ec99d1784601de467cee)
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 = false;
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    function settings_plugin_siteexport_settings($functions) {
35        global $ID;
36
37        if ( empty($_REQUEST['pattern']) )
38        {
39            $params = $_REQUEST;
40            $this->pattern = $functions->requestParametersToCacheHash($params);
41        } else {
42            // Set the pattern
43            $this->pattern = $_REQUEST['pattern'];
44        }
45
46        $this->isCLI = (!$_SERVER['REMOTE_ADDR'] && 'cli' == php_sapi_name());
47
48        $this->cachetime = $this->getConf('cachetime');
49        if ( !empty( $_REQUEST['disableCache'] ) ) {
50	        $this->cachetime = intval($_REQUEST['disableCache']) == 1 ? 0 : $this->cachetime;
51        }
52
53        // Load Variables
54        $this->origZipFile = $this->getConf('zipfilename');
55
56        $this->ignoreNon200 = $this->getConf('ignoreNon200');
57
58        // ID
59        $this->downloadZipFile = $functions->getSpecialExportFileName($this->origZipFile, $this->pattern);
60        //        $this->eclipseZipFile = $functions->getSpecialExportFileName(getNS($this->origZipFile) . ':' . $this->origEclipseZipFile, $this->pattern);
61
62        $this->zipFile = mediaFN($this->downloadZipFile);
63
64        $this->tmpDir = mediaFN(getNS($this->origZipFile));
65        $this->exportLinkedPages = intval($_REQUEST['exportLinkedPages']) == 1 ? true : false;
66
67        $this->namespace = $functions->getNamespaceFromID($_REQUEST['ns'], $PAGE);
68        $this->addParams = !empty($_REQUEST['addParams']);
69
70        $this->useTOCFile = !empty($_REQUEST['useTocFile']);
71
72        // set export Namespace - which is a virtual Root
73        $pg = noNS($ID);
74        if ( empty( $this->namespace ) ) { $this->namespace = $functions->getNamespaceFromID(getNS($ID), $pg); }
75        $this->exportNamespace = !empty($_REQUEST['ens']) && preg_match("%^" . $functions->getNamespaceFromID($_REQUEST['ens'], $pg) . "%", $this->namespace) ? $functions->getNamespaceFromID($_REQUEST['ens'], $pg) : $this->namespace;
76
77        $this->TOCMapWithoutTranslation = intval($_REQUEST['TOCMapWithoutTranslation']) == 1 ? true : false;
78
79        // Strip params that should be forwarded
80        $this->additionalParameters = $_REQUEST;
81        $functions->removeWikiVariables($this->additionalParameters, true);
82
83        $tmpID = $ID;
84        $ID = $this->origZipFile;
85
86        $INFO = pageinfo();
87        if ( !$this->isCLI )
88        {
89            // Workaround for the cron which cannot authenticate but has access to everything.
90            if ( $INFO['perm'] < AUTH_DELETE ) {
91                list ( $USER, $PASS) = $functions->basic_authentication();
92                auth_login($USER, $PASS);
93            }
94        }
95
96        $ID = $tmpID;
97    }
98}
99
100?>