Mercurial > SimpleWebPresenter
changeset 124:6766250a0baa
Support for parameters as directory structure.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Fri, 29 Dec 2017 19:59:22 +0100 |
| parents | 8678ce12d533 |
| children | ee939079b8b6 |
| files | InputParser.inc Sitemap.inc index.php sitemap.php |
| diffstat | 4 files changed, 31 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/InputParser.inc Thu Dec 28 19:43:24 2017 +0100 +++ b/InputParser.inc Fri Dec 29 19:59:22 2017 +0100 @@ -30,7 +30,9 @@ $this->options = new Options($this->master); $this->options->setCache($cache); - $this->options->setBasePath(basePath()); + $base=basePath(); + $base=$_SERVER['CONTEXT_DOCUMENT_ROOT']; + $this->options->setBasePath($base); $this->options->setCacheable(true); $this->options->setUrlParams(array('name', 'lang')); @@ -47,6 +49,18 @@ if(array_key_exists('name', $_GET) && $_GET['name']) { $this->options->setName($_GET['name']); } + else { + $pathToAnalyze=$_SERVER['PATH_TRANSLATED']; + $prefix=$_SERVER['SCRIPT_FILENAME']; + if (substr($pathToAnalyze, 0, strlen($prefix)) == $prefix) { + $pathToAnalyze = substr($pathToAnalyze, strlen($prefix)); + } + preg_match('/\/([^\/]*)$/', $pathToAnalyze, $groups); + if ($groups[1]) { + $this->options->setName($groups[1]); + } + } + $params = $this->master->getElementsByTagName("param");
--- a/Sitemap.inc Thu Dec 28 19:43:24 2017 +0100 +++ b/Sitemap.inc Fri Dec 29 19:59:22 2017 +0100 @@ -72,11 +72,15 @@ private function processDir($dir, $lang, $acceptedLanguages, $base) { $urls = array(); - if ($handle = opendir(basePath() . "/${dir}")) { + $base=basePath(); + $base=$_SERVER['DOCUMENT_ROOT']; + $baseurl = $_SERVER["REQUEST_SCHEME"] ."://". $_SERVER["SERVER_NAME"]; + + + if ($handle = opendir($base . "/${dir}")) { while (false !== ($entry = readdir($handle))) { if (endsWith($entry, '.xml')) { - $fentry = basepath() . "/${dir}/${entry}"; - + $fentry = $base . "/${dir}/${entry}"; $doc = new DOMDocument(); if (file_exists($fentry)) { @@ -97,9 +101,7 @@ } $optstring = genUrl($opts, array(), array('lang', 'name')); - - $location = "${base}${optstring}/"; - + $location = "${baseurl}${optstring}/"; array_push($urls, $location); } }
--- a/index.php Thu Dec 28 19:43:24 2017 +0100 +++ b/index.php Fri Dec 29 19:59:22 2017 +0100 @@ -23,7 +23,10 @@ } try { - $input = new InputParser(basePath() . "/master.xml", $cache); + $base=basePath(); + $base=$_SERVER['CONTEXT_DOCUMENT_ROOT']; + $target=$base . "/master.xml"; + $input = new InputParser($target, $cache); $input->display(); } catch (Exception $e) { @@ -31,4 +34,4 @@ } /// @endcond -?> \ No newline at end of file +?>
--- a/sitemap.php Thu Dec 28 19:43:24 2017 +0100 +++ b/sitemap.php Fri Dec 29 19:59:22 2017 +0100 @@ -13,7 +13,9 @@ $cache->includeOnce('Sitemap.inc', dirname(__FILE__)); try { - $sitemap = new Sitemap(basePath() . "/master.xml"); + $base=basePath(); + $base=$_SERVER['DOCUMENT_ROOT']; + $sitemap = new Sitemap($base . "/master.xml"); $sitemap->display(); } catch (Exception $e) {
