Commit e51a0c082e289f62b24b659085cf241425ef55f6
1 parent
d57240c4
Added check for no search results
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1156 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
26 additions
and
9 deletions
presentation/lookAndFeel/knowledgeTree/search/advancedSearchBL.php
| @@ -30,13 +30,23 @@ if (checkSession()) { | @@ -30,13 +30,23 @@ if (checkSession()) { | ||
| 30 | if (strlen($sMetaTagIDs) > 0) { | 30 | if (strlen($sMetaTagIDs) > 0) { |
| 31 | $sSQLSearchString = getSQLSearchString($fSearchString); | 31 | $sSQLSearchString = getSQLSearchString($fSearchString); |
| 32 | $sDocument = getApprovedDocumentString($sMetaTagIDs, $sSQLSearchString); | 32 | $sDocument = getApprovedDocumentString($sMetaTagIDs, $sSQLSearchString); |
| 33 | - $oPatternCustom = & new PatternCustom(); | ||
| 34 | - if (!isset($fStartIndex)) { | ||
| 35 | - $fStartIndex = 0; | 33 | + if (strlen($sDocument) > 0) { |
| 34 | + //if there are documents to view | ||
| 35 | + $oPatternCustom = & new PatternCustom(); | ||
| 36 | + if (!isset($fStartIndex)) { | ||
| 37 | + $fStartIndex = 0; | ||
| 38 | + } | ||
| 39 | + $oPatternCustom->setHtml(getSearchResults($sDocument,$fStartIndex, $fSearchString, $sMetaTagIDs)); | ||
| 40 | + $main->setCentralPayload($oPatternCustom); | ||
| 41 | + $main->render(); | ||
| 42 | + } else { | ||
| 43 | + $oPatternCustom = & new PatternCustom(); | ||
| 44 | + $oPatternCustom->setHtml(getSearchPage($fSearchString, explode(",",$sMetaTagIDs))); | ||
| 45 | + $main->setCentralPayload($oPatternCustom); | ||
| 46 | + $main->setErrorMessage("No documents matched your search criteria"); | ||
| 47 | + $main->setFormAction("advancedSearchBL.php?fForSearch=1"); | ||
| 48 | + $main->render(); | ||
| 36 | } | 49 | } |
| 37 | - $oPatternCustom->setHtml(getSearchResults($sDocument,$fStartIndex, $fSearchString, $sMetaTagIDs)); | ||
| 38 | - $main->setCentralPayload($oPatternCustom); | ||
| 39 | - $main->render(); | ||
| 40 | 50 | ||
| 41 | } else { | 51 | } else { |
| 42 | $oPatternCustom = & new PatternCustom(); | 52 | $oPatternCustom = & new PatternCustom(); |
| @@ -86,7 +96,10 @@ function getChosenMetaDataTags() { | @@ -86,7 +96,10 @@ function getChosenMetaDataTags() { | ||
| 86 | 96 | ||
| 87 | } | 97 | } |
| 88 | } | 98 | } |
| 89 | - return implode(",",$aTagIDs); | 99 | + if (count($aTagIDs) > 1) { |
| 100 | + return implode(",",$aTagIDs); | ||
| 101 | + } | ||
| 102 | + return $aTagIDs[0]; | ||
| 90 | } | 103 | } |
| 91 | 104 | ||
| 92 | /** | 105 | /** |
| @@ -109,7 +122,11 @@ function getApprovedDocumentString($sMetaTagIDs, $sSQLSearchString) { | @@ -109,7 +122,11 @@ function getApprovedDocumentString($sMetaTagIDs, $sSQLSearchString) { | ||
| 109 | $aApprovedDocuments[count($aApprovedDocuments)] = $sql->f("id"); | 122 | $aApprovedDocuments[count($aApprovedDocuments)] = $sql->f("id"); |
| 110 | } | 123 | } |
| 111 | } | 124 | } |
| 112 | - return implode(",",$aApprovedDocuments); | 125 | + if (count($aApprovedDocuments) > 1) { |
| 126 | + return implode(",",$aApprovedDocuments); | ||
| 127 | + } | ||
| 128 | + return $aApprovedDocuments[0]; | ||
| 129 | + | ||
| 113 | } | 130 | } |
| 114 | 131 | ||
| 115 | /* | 132 | /* |
presentation/lookAndFeel/knowledgeTree/search/advancedSearchUI.inc
| @@ -10,7 +10,7 @@ | @@ -10,7 +10,7 @@ | ||
| 10 | */ | 10 | */ |
| 11 | 11 | ||
| 12 | function getMetaData($aMetaTagIDs) { | 12 | function getMetaData($aMetaTagIDs) { |
| 13 | - global $default; | 13 | + global $default; |
| 14 | $sQuery = "SELECT name, id FROM $default->owl_fields_table ORDER BY name ASC"; | 14 | $sQuery = "SELECT name, id FROM $default->owl_fields_table ORDER BY name ASC"; |
| 15 | 15 | ||
| 16 | $sql = $default->db; | 16 | $sql = $default->db; |