From 473b8308673a8fc01c1059d7ebf9f0b691a220bc Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 16 Dec 2014 23:07:31 +1300 Subject: [PATCH] Resolve test failures --- code/DocumentationManifest.php | 8 +++----- code/controllers/DocumentationViewer.php | 18 +++++++++++------- code/forms/DocumentationSearchForm.php | 11 +++++------ code/tasks/RebuildLuceneDocsIndex.php | 4 ++-- javascript/DocumentationViewer.js | 3 +++ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/code/DocumentationManifest.php b/code/DocumentationManifest.php index a0b8e86..86c7177 100644 --- a/code/DocumentationManifest.php +++ b/code/DocumentationManifest.php @@ -121,11 +121,9 @@ class DocumentationManifest { $path = $this->getRealPath($details['Path']); $key = (isset($details['Key'])) ? $details['Key'] : $details['Title']; - - if($path && !is_dir($path)) { - throw new Exception($path . ' is not a valid documentation directory'); - } else if(!$path) { - return; + + if(!$path || !is_dir($path)) { + throw new Exception($details['Path'] . ' is not a valid documentation directory'); } $version = (isset($details['Version'])) ? $details['Version'] : ''; diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index 3c9fa69..6465987 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -316,15 +316,19 @@ class DocumentationViewer extends Controller { $current = $this->getEntity(); foreach($entities as $entity) { + $checkLang = $entity->getLanguage(); + $checkVers = $entity->getVersion(); - // only show entities with the same language - if($entity->getLanguage() !== $this->getLanguage()) { + // only show entities with the same language or any entity that + // isn't registered under any particular language (auto detected) + if($checkLang && $checkLang !== $this->getLanguage()) { continue; } - - // only show entities with the same version - if($entity->getVersion() !== $current->getVersion()) { - continue; + + if($current && $checkVers) { + if($entity->getVersion() !== $current->getVersion()) { + continue; + } } $mode = 'link'; @@ -459,7 +463,7 @@ class DocumentationViewer extends Controller { * @return ArrayList */ public function getVersions() { - return $this->manifest->getVersions($this->getEntity()); + return $this->getManifest()->getVersions($this->getEntity()); } /** diff --git a/code/forms/DocumentationSearchForm.php b/code/forms/DocumentationSearchForm.php index eb6863c..a08d705 100644 --- a/code/forms/DocumentationSearchForm.php +++ b/code/forms/DocumentationSearchForm.php @@ -3,13 +3,12 @@ class DocumentationSearchForm extends Form { public function __construct($controller) { + $versions = HiddenField::create( + 'Versions', + _t('DocumentationViewer.VERSIONS', 'Versions'), + implode(',', $controller->getManifest()->getAllVersions()) + ); - //pass through the current version - $page = $controller->getPage(); - if($page){ - $versions = HiddenField::create('Versions','Versions',$page->getEntity()->getVersion()); - } - $fields = new FieldList( TextField::create('q', _t('DocumentationViewer.SEARCH', 'Search'), '') ->setAttribute('placeholder', _t('DocumentationViewer.SEARCH', 'Search')), diff --git a/code/tasks/RebuildLuceneDocsIndex.php b/code/tasks/RebuildLuceneDocsIndex.php index 0ba27ad..b417aa6 100755 --- a/code/tasks/RebuildLuceneDocsIndex.php +++ b/code/tasks/RebuildLuceneDocsIndex.php @@ -48,7 +48,7 @@ class RebuildLuceneDocsIndex extends BuildTask { $index->removeReference(); } catch (Zend_Search_Lucene_Exception $e) { - // user_error($e); + user_error($e); } try { @@ -61,7 +61,7 @@ class RebuildLuceneDocsIndex extends BuildTask { // includes registration $manifest = new DocumentationManifest(true); $pages = $manifest->getPages(); - + if($pages) { $count = 0; diff --git a/javascript/DocumentationViewer.js b/javascript/DocumentationViewer.js index 2b94f6d..4031f44 100755 --- a/javascript/DocumentationViewer.js +++ b/javascript/DocumentationViewer.js @@ -135,6 +135,7 @@ $(this).removeClass('hover'); }); + /* $(".search input").live("keyup", function(e) { clearTimeout($.data(this, 'timer')); @@ -185,7 +186,9 @@ return false; }, 100)); }; + }); + */ /** --------------------------------------------- * LANGAUGE SELECTER