From bd186a0a7378394ddf4d3d5db8a7de0adced185a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 29 May 2013 18:09:42 +0200 Subject: [PATCH] BUG Index relative URLs Avoids clashes between CLI and web modes (e.g. wrongly configured $_FILE_TO_URL_MAPPING lookups). --- code/models/DocumentationPage.php | 14 ++++++++++---- code/tasks/RebuildLuceneDocsIndex.php | 2 +- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/code/models/DocumentationPage.php b/code/models/DocumentationPage.php index 792f8ff..b5a20d2 100755 --- a/code/models/DocumentationPage.php +++ b/code/models/DocumentationPage.php @@ -148,12 +148,12 @@ class DocumentationPage extends ViewableData { /** * Returns the public accessible link for this page. * + * @param Boolean Absolute URL (incl. domain), or relative to webroot * @return string */ - function getLink() { + function getLink($absolute=true) { if($entity = $this->getEntity()) { - $link = Controller::join_links($entity->Link($this->getVersion(), $this->lang), $this->getRelativeLink()); - + $link = $this->getRelativeLink(); $link = rtrim(DocumentationService::trim_extension_off($link), '/'); // folders should have a / on them. Looks nicer @@ -166,7 +166,13 @@ class DocumentationPage extends ViewableData { $link = $this->getPath(true); } - return $link; + if($absolute) { + $fullLink = Controller::join_links($entity->Link($this->getVersion(), $this->lang), $link); + } else { + $fullLink = Controller::join_links($entity->getRelativeLink($this->getVersion(), $this->lang), $link); + } + + return $fullLink; } /** diff --git a/code/tasks/RebuildLuceneDocsIndex.php b/code/tasks/RebuildLuceneDocsIndex.php index bcf5698..6a84f57 100755 --- a/code/tasks/RebuildLuceneDocsIndex.php +++ b/code/tasks/RebuildLuceneDocsIndex.php @@ -86,7 +86,7 @@ class RebuildLuceneDocsIndex extends BuildTask { $doc->addField(Zend_Search_Lucene_Field::Keyword('Version', $page->getVersion())); $doc->addField(Zend_Search_Lucene_Field::Keyword('Language', $page->getLang())); $doc->addField(Zend_Search_Lucene_Field::Keyword('Entity', $entity)); - $doc->addField(Zend_Search_Lucene_Field::Keyword('Link', $page->Link)); + $doc->addField(Zend_Search_Lucene_Field::Keyword('Link', $page->getLink(false))); // custom boosts $titleField->boost = 3;