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