Trim leading slash from $_SERVER["SCRIPT_NAME"] so that server side rendered links are relative instead of absolute.
This commit is contained in:
		
							parent
							
								
									b0be1e55f6
								
							
						
					
					
						commit
						4845dfa425
					
				
					 1 changed files with 5 additions and 1 deletions
				
			
		
							
								
								
									
										6
									
								
								base.php
									
										
									
									
									
								
							
							
						
						
									
										6
									
								
								base.php
									
										
									
									
									
								
							|  | @ -375,13 +375,16 @@ class Link | ||||||
| class LinkNavigation extends Link | class LinkNavigation extends Link | ||||||
| { | { | ||||||
|     public function __construct($phref, $prel = NULL, $ptitle = NULL) { |     public function __construct($phref, $prel = NULL, $ptitle = NULL) { | ||||||
|  |         error_log("BENTEST: " . $_SERVER["SCRIPT_NAME"]); | ||||||
|         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); |         parent::__construct ($phref, Link::OPDS_NAVIGATION_TYPE, $prel, $ptitle); | ||||||
|         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); | ||||||
|         if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; |         if (!preg_match ("#^\?(.*)#", $this->href) && !empty ($this->href)) $this->href = "?" . $this->href; | ||||||
|         if (preg_match ("/(bookdetail|getJSON).php/", $_SERVER["SCRIPT_NAME"])) { |         if (preg_match ("/(bookdetail|getJSON).php/", $_SERVER["SCRIPT_NAME"])) { | ||||||
|             $this->href = "index.php" . $this->href; |             $this->href = "index.php" . $this->href; | ||||||
|  |             error_log("BENTEST2: " . $this->href); | ||||||
|         } else { |         } else { | ||||||
|             $this->href = $_SERVER["SCRIPT_NAME"] . $this->href; |             $this->href = trim($_SERVER["SCRIPT_NAME"],'/') . $this->href; | ||||||
|  |             error_log("BENTEST3: " . $this->href); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | @ -389,6 +392,7 @@ class LinkNavigation extends Link | ||||||
| class LinkFacet extends Link | class LinkFacet extends Link | ||||||
| { | { | ||||||
|     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { |     public function __construct($phref, $ptitle = NULL, $pfacetGroup = NULL, $pactiveFacet = FALSE) { | ||||||
|  |         error_log("BENTEST: " . $_SERVER["SCRIPT_NAME"]); | ||||||
|         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); |         parent::__construct ($phref, Link::OPDS_PAGING_TYPE, "http://opds-spec.org/facet", $ptitle, $pfacetGroup, $pactiveFacet); | ||||||
|         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); |         if (!is_null (GetUrlParam (DB))) $this->href = addURLParameter ($this->href, DB, GetUrlParam (DB)); | ||||||
|         $this->href = $_SERVER["SCRIPT_NAME"] . $this->href; |         $this->href = $_SERVER["SCRIPT_NAME"] . $this->href; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue