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