# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1514573962 -3600 # Node ID 6766250a0baadd2345ef1db8ad0098603f87ee62 # Parent 8678ce12d53315f559ee60d76f7535820d6e7035 Support for parameters as directory structure. diff -r 8678ce12d533 -r 6766250a0baa InputParser.inc --- 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"); diff -r 8678ce12d533 -r 6766250a0baa Sitemap.inc --- 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); } } diff -r 8678ce12d533 -r 6766250a0baa index.php --- 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 +?> diff -r 8678ce12d533 -r 6766250a0baa sitemap.php --- 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) {