Commit 0f8e5bac9e7608cf534a174df7fca30777510907
1 parent
f8bee8f2
added category name and document type list sorting
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@1746 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
3 changed files
with
91 additions
and
40 deletions
lib/documentmanagement/DocumentBrowser.inc
| ... | ... | @@ -92,8 +92,18 @@ class DocumentBrowser { |
| 92 | 92 | // FIXME: in the same unit? |
| 93 | 93 | |
| 94 | 94 | // if we're sorting by name then sort folders in the appropriate direction |
| 95 | - $folderQuery = "SELECT id FROM $default->owl_folders_table WHERE parent_id=" . $folderID . " ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); | |
| 96 | - $default->log->debug("DocumentBrowser::browseByFolder child folder query=$folderQuery"); | |
| 95 | + $folderQuery = "SELECT f.id FROM $default->owl_folders_table f "; | |
| 96 | + | |
| 97 | + if ( $sSortField == "creator_id" ) { | |
| 98 | + $folderQuery .= "INNER JOIN " . $this->aSortCriteria["creator_id"]["lookup"]["lookupTable"] . " lt ON f.$sSortField=lt.id "; | |
| 99 | + } | |
| 100 | + $folderQuery .= "WHERE f.parent_id=$folderID "; | |
| 101 | + if ( $sSortField == "creator_id" ) { | |
| 102 | + $folderQuery .= "ORDER BY lt." . $this->aSortCriteria["creator_id"]["lookup"]["lookupField"] . " $sSortDirection"; | |
| 103 | + } else { | |
| 104 | + $folderQuery .= "ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); | |
| 105 | + } | |
| 106 | + | |
| 97 | 107 | if ($sql->query($folderQuery)) { |
| 98 | 108 | while ($sql->next_record()) { |
| 99 | 109 | // add the child folders to the array |
| ... | ... | @@ -161,8 +171,10 @@ class DocumentBrowser { |
| 161 | 171 | $results["categories"][] = "Categories"; |
| 162 | 172 | |
| 163 | 173 | // get a list of category values |
| 164 | - $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value ASC"; | |
| 165 | - $default->log->debug("DocumentBrowser::browseByCategory category listing query=$query"); | |
| 174 | + $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table " . | |
| 175 | + "WHERE document_field_id=$categoryFieldID " . | |
| 176 | + "ORDER BY value " . ($sSortField == "name" ? $sSortDirection : "ASC"); | |
| 177 | + | |
| 166 | 178 | $sql->query($query); |
| 167 | 179 | // loop through resultset, build array and return |
| 168 | 180 | while ($sql->next_record()) { |
| ... | ... | @@ -210,7 +222,7 @@ class DocumentBrowser { |
| 210 | 222 | */ |
| 211 | 223 | function browseByDocumentType($documentTypeID = -1, $sSortField = "name", $sSortDirection = "asc") { |
| 212 | 224 | global $default; |
| 213 | - | |
| 225 | + | |
| 214 | 226 | $results = array(); |
| 215 | 227 | $sql = $default->db; |
| 216 | 228 | |
| ... | ... | @@ -220,7 +232,8 @@ class DocumentBrowser { |
| 220 | 232 | $results["documentTypes"][] = array("name" => "Document Types"); |
| 221 | 233 | |
| 222 | 234 | // return a list of document types |
| 223 | - $query = "SELECT * FROM $default->owl_document_types_table"; | |
| 235 | + $query = "SELECT * FROM $default->owl_document_types_table ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); | |
| 236 | + | |
| 224 | 237 | $sql->query($query); |
| 225 | 238 | while ($sql->next_record()) { |
| 226 | 239 | $results["documentTypes"][] = array ("id" => $sql->f("id"), "name" => $sql->f("name")); | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php
| ... | ... | @@ -61,7 +61,7 @@ if (checkSession()) { |
| 61 | 61 | $oDocBrowser = new DocumentBrowser(); |
| 62 | 62 | // instantiate my content pattern |
| 63 | 63 | $oContent = new PatternCustom(); |
| 64 | - | |
| 64 | + | |
| 65 | 65 | switch ($fBrowseType) { |
| 66 | 66 | case "folder" : // retrieve folderID if present |
| 67 | 67 | if (!$fFolderID) { |
| ... | ... | @@ -75,7 +75,7 @@ if (checkSession()) { |
| 75 | 75 | case "category" : |
| 76 | 76 | $sectionName = "Manage Categories"; |
| 77 | 77 | if (!$fCategoryName) { |
| 78 | - $aResults = $oDocBrowser->browseByCategory(); | |
| 78 | + $aResults = $oDocBrowser->browseByCategory("", $fSortBy, $fSortDirection); | |
| 79 | 79 | } else { |
| 80 | 80 | $aResults = $oDocBrowser->browseByCategory($fCategoryName, $fSortBy, $fSortDirection); |
| 81 | 81 | } |
| ... | ... | @@ -84,7 +84,7 @@ if (checkSession()) { |
| 84 | 84 | case "documentType" : |
| 85 | 85 | $sectionName = "Manage Document Types"; |
| 86 | 86 | if (!$fDocumentTypeID) { |
| 87 | - $aResults = $oDocBrowser->browseByDocumentType(); | |
| 87 | + $aResults = $oDocBrowser->browseByDocumentType(-1, $fSortBy, $fSortDirection); | |
| 88 | 88 | } else { |
| 89 | 89 | $aResults = $oDocBrowser->browseByDocumentType($fDocumentTypeID, $fSortBy, $fSortDirection); |
| 90 | 90 | } | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc
| ... | ... | @@ -21,7 +21,7 @@ function renderHeading($sHeading) { |
| 21 | 21 | global $default; |
| 22 | 22 | $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); |
| 23 | 23 | $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); |
| 24 | - $sToRender = "<table border=\"0\" width=\"100%\">\n"; | |
| 24 | + $sToRender = "<table border=\"0\" width=\"600\">\n"; | |
| 25 | 25 | $sToRender .= "<tr align=\"left\"><th class=\"sectionHeading\" bgcolor=\"$sColor\"><font color=\"ffffff\">$sHeading</font></th></tr>\n"; |
| 26 | 26 | $sToRender .= "<tr/>\n"; |
| 27 | 27 | $sToRender .= "<tr/>\n"; |
| ... | ... | @@ -46,7 +46,7 @@ function renderBrowseTypeSelect($sBrowseType) { |
| 46 | 46 | (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> Document Type\n</span>"; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | -// <category display helper methods> | |
| 49 | +// <category browse helper methods> | |
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * Displays the passed category path as a link |
| ... | ... | @@ -92,7 +92,20 @@ function renderCategoryResults($aResults) { |
| 92 | 92 | if ($aResults["categories"][0] == "Categories") { |
| 93 | 93 | // loop through categories and display them |
| 94 | 94 | for ($i=1; $i<count($aResults["categories"]); $i++) { |
| 95 | - $sToRender .= "<tr><td bgcolor=\"" . getColour($i) . "\">" . displayCategoryLink($aResults["categories"][$i]) . "</td></tr>\n"; | |
| 95 | + $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | |
| 96 | + | |
| 97 | + // category name | |
| 98 | + $sToRender .= "<td>" . displayCategoryLink($aResults["categories"][$i]) . "</td>"; | |
| 99 | + // blank filename | |
| 100 | + $sToRender .= "<td></td>"; | |
| 101 | + // creator name | |
| 102 | + $sToRender .= "<td></td>"; | |
| 103 | + // modified date | |
| 104 | + $sToRender .= "<td></td>"; | |
| 105 | + // document type | |
| 106 | + $sToRender .= "<td></td>"; | |
| 107 | + | |
| 108 | + $sToRender .= "</tr>\n"; | |
| 96 | 109 | } |
| 97 | 110 | } else { |
| 98 | 111 | // else the first entry is the category name, so display the documents in the category |
| ... | ... | @@ -102,7 +115,7 @@ function renderCategoryResults($aResults) { |
| 102 | 115 | return $sToRender; |
| 103 | 116 | } |
| 104 | 117 | |
| 105 | -// </category display helper methods> | |
| 118 | +// </category browse helper methods> | |
| 106 | 119 | |
| 107 | 120 | // <document type display helper methods> |
| 108 | 121 | /** |
| ... | ... | @@ -145,7 +158,18 @@ function renderDocumentTypeResults($aResults) { |
| 145 | 158 | if ($aResults["documentTypes"][0]["name"] == "Document Types") { |
| 146 | 159 | // loop through document types and display them |
| 147 | 160 | for ($i=1; $i<count($aResults["documentTypes"]); $i++) { |
| 148 | - $sToRender .= "<tr><td bgcolor=\"" . getColour($i) . "\">" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "</td></tr>"; | |
| 161 | + $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | |
| 162 | + // document type name | |
| 163 | + $sToRender .= "<td>" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "</td>"; | |
| 164 | + // blank filename | |
| 165 | + $sToRender .= "<td></td>"; | |
| 166 | + // creator name | |
| 167 | + $sToRender .= "<td></td>"; | |
| 168 | + // modified date | |
| 169 | + $sToRender .= "<td></td>"; | |
| 170 | + // document type | |
| 171 | + $sToRender .= "<td></td>"; | |
| 172 | + $sToRender .= "</tr>\n"; | |
| 149 | 173 | } |
| 150 | 174 | } else { |
| 151 | 175 | // else the first entry is the document type name, so display the documents in the document type |
| ... | ... | @@ -154,9 +178,48 @@ function renderDocumentTypeResults($aResults) { |
| 154 | 178 | } |
| 155 | 179 | return $sToRender; |
| 156 | 180 | } |
| 157 | -// </document type display helper methods> | |
| 181 | +// </document type browse helper methods> | |
| 158 | 182 | |
| 159 | 183 | |
| 184 | +// <folder browse helper methods> | |
| 185 | +/** | |
| 186 | + * Displays the folders in the browse results | |
| 187 | + * | |
| 188 | + * @param array the browse result objects | |
| 189 | + */ | |
| 190 | +function renderFolderResults($aResults) { | |
| 191 | + global $default; | |
| 192 | + $sToRender = ""; | |
| 193 | + | |
| 194 | + // now loop through the rest of the folders and display links | |
| 195 | + if (count($aResults["folders"]) > 1) { | |
| 196 | + for ($i=1; $i<count($aResults["folders"]); $i++) { | |
| 197 | + $sFolderLink = displayFolderLink($aResults["folders"][$i]); | |
| 198 | + $oCreator = User::get($aResults["folders"][$i]->getCreatorID()); | |
| 199 | + | |
| 200 | + $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\">"; | |
| 201 | + // folder name | |
| 202 | + $sToRender .= "<td>" . $sFolderLink . "</td>"; | |
| 203 | + // blank filename (??: folder description?) | |
| 204 | + $sToRender .= "<td></td>"; | |
| 205 | + // creator name | |
| 206 | + $sToRender .= "<td>" . $oCreator->getName() . "</td>"; | |
| 207 | + // modified date (TODO: add to db) | |
| 208 | + $sToRender .= "<td></td>"; | |
| 209 | + // document type (??: display one of the mapped document types?) | |
| 210 | + $sToRender .= "<td></td>"; | |
| 211 | + $sToRender .= "</tr>\n"; | |
| 212 | + } | |
| 213 | + } else { | |
| 214 | + $sToRender .= "<tr><td colspan=\"5\">This folder contains no sub folders</td></tr>"; | |
| 215 | + } | |
| 216 | + | |
| 217 | + $sToRender .= "<tr><td>" . renderDocumentList($aResults, "This folder contains no documents", "You don't have access to the documents in this folder") . "</td></tr>\n"; | |
| 218 | + | |
| 219 | + return $sToRender; | |
| 220 | +} | |
| 221 | +// </folder browse helper methods> | |
| 222 | + | |
| 160 | 223 | /** |
| 161 | 224 | * Displays the headings for the displayed document details and enables |
| 162 | 225 | * resorting the contents |
| ... | ... | @@ -201,31 +264,6 @@ function renderSortHeadings($sSortBy, $sSortDirection) { |
| 201 | 264 | } |
| 202 | 265 | |
| 203 | 266 | /** |
| 204 | - * Displays the folders in the browse results | |
| 205 | - * | |
| 206 | - * @param array the browse result objects | |
| 207 | - */ | |
| 208 | -function renderFolderResults($aResults) { | |
| 209 | - global $default; | |
| 210 | - $sToRender = ""; | |
| 211 | - | |
| 212 | - // now loop through the rest of the folders and display links | |
| 213 | - if (count($aResults["folders"]) > 1) { | |
| 214 | - for ($i=1; $i<count($aResults["folders"]); $i++) { | |
| 215 | - $sFolderLink = displayFolderLink($aResults["folders"][$i]); | |
| 216 | - $oCreator = User::get($aResults["folders"][$i]->getCreatorID()); | |
| 217 | - $sToRender .= "<tr bgcolor=\"" . getColour($i) . "\"><td colspan=\"2\" nowrap width=\"100%\">" . $sFolderLink . "</td><td>" . $oCreator->getName() . "</td><td colspan=\"2\"></td></tr>\n"; | |
| 218 | - } | |
| 219 | - } else { | |
| 220 | - $sToRender .= "<tr><td>This folder contains no sub folders</td></tr>"; | |
| 221 | - } | |
| 222 | - | |
| 223 | - $sToRender .= "<tr><td>" . renderDocumentList($aResults, "This folder contains no documents", "You don't have access to the documents in this folder") . "</td></tr>\n"; | |
| 224 | - | |
| 225 | - return $sToRender; | |
| 226 | -} | |
| 227 | - | |
| 228 | -/** | |
| 229 | 267 | * Displays the documents in the browse results |
| 230 | 268 | * |
| 231 | 269 | * @param array the browse result objects | ... | ... |