diff --git a/lib/documentmanagement/DocumentBrowser.inc b/lib/documentmanagement/DocumentBrowser.inc index 2783107..9faacd7 100644 --- a/lib/documentmanagement/DocumentBrowser.inc +++ b/lib/documentmanagement/DocumentBrowser.inc @@ -92,8 +92,18 @@ class DocumentBrowser { // FIXME: in the same unit? // if we're sorting by name then sort folders in the appropriate direction - $folderQuery = "SELECT id FROM $default->owl_folders_table WHERE parent_id=" . $folderID . " ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); - $default->log->debug("DocumentBrowser::browseByFolder child folder query=$folderQuery"); + $folderQuery = "SELECT f.id FROM $default->owl_folders_table f "; + + if ( $sSortField == "creator_id" ) { + $folderQuery .= "INNER JOIN " . $this->aSortCriteria["creator_id"]["lookup"]["lookupTable"] . " lt ON f.$sSortField=lt.id "; + } + $folderQuery .= "WHERE f.parent_id=$folderID "; + if ( $sSortField == "creator_id" ) { + $folderQuery .= "ORDER BY lt." . $this->aSortCriteria["creator_id"]["lookup"]["lookupField"] . " $sSortDirection"; + } else { + $folderQuery .= "ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); + } + if ($sql->query($folderQuery)) { while ($sql->next_record()) { // add the child folders to the array @@ -161,8 +171,10 @@ class DocumentBrowser { $results["categories"][] = "Categories"; // get a list of category values - $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table WHERE document_field_id=$categoryFieldID ORDER BY value ASC"; - $default->log->debug("DocumentBrowser::browseByCategory category listing query=$query"); + $query = "SELECT DISTINCT value FROM $default->owl_document_fields_table " . + "WHERE document_field_id=$categoryFieldID " . + "ORDER BY value " . ($sSortField == "name" ? $sSortDirection : "ASC"); + $sql->query($query); // loop through resultset, build array and return while ($sql->next_record()) { @@ -210,7 +222,7 @@ class DocumentBrowser { */ function browseByDocumentType($documentTypeID = -1, $sSortField = "name", $sSortDirection = "asc") { global $default; - + $results = array(); $sql = $default->db; @@ -220,7 +232,8 @@ class DocumentBrowser { $results["documentTypes"][] = array("name" => "Document Types"); // return a list of document types - $query = "SELECT * FROM $default->owl_document_types_table"; + $query = "SELECT * FROM $default->owl_document_types_table ORDER BY name " . ($sSortField == "name" ? $sSortDirection : "ASC"); + $sql->query($query); while ($sql->next_record()) { $results["documentTypes"][] = array ("id" => $sql->f("id"), "name" => $sql->f("name")); diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php index e856136..1dcb30c 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php @@ -61,7 +61,7 @@ if (checkSession()) { $oDocBrowser = new DocumentBrowser(); // instantiate my content pattern $oContent = new PatternCustom(); - + switch ($fBrowseType) { case "folder" : // retrieve folderID if present if (!$fFolderID) { @@ -75,7 +75,7 @@ if (checkSession()) { case "category" : $sectionName = "Manage Categories"; if (!$fCategoryName) { - $aResults = $oDocBrowser->browseByCategory(); + $aResults = $oDocBrowser->browseByCategory("", $fSortBy, $fSortDirection); } else { $aResults = $oDocBrowser->browseByCategory($fCategoryName, $fSortBy, $fSortDirection); } @@ -84,7 +84,7 @@ if (checkSession()) { case "documentType" : $sectionName = "Manage Document Types"; if (!$fDocumentTypeID) { - $aResults = $oDocBrowser->browseByDocumentType(); + $aResults = $oDocBrowser->browseByDocumentType(-1, $fSortBy, $fSortDirection); } else { $aResults = $oDocBrowser->browseByDocumentType($fDocumentTypeID, $fSortBy, $fSortDirection); } diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc index 3086631..e4aafa5 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc @@ -21,7 +21,7 @@ function renderHeading($sHeading) { global $default; $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); $sColor = $default->siteMap->getSectionColour($sSectionName, "th"); - $sToRender = "\n"; + $sToRender = "
\n"; $sToRender .= "\n"; $sToRender .= "\n"; $sToRender .= "\n"; @@ -46,7 +46,7 @@ function renderBrowseTypeSelect($sBrowseType) { (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> Document Type\n"; } -// +// /** * Displays the passed category path as a link @@ -92,7 +92,20 @@ function renderCategoryResults($aResults) { if ($aResults["categories"][0] == "Categories") { // loop through categories and display them for ($i=1; $i" . displayCategoryLink($aResults["categories"][$i]) . "\n"; + $sToRender .= ""; + + // category name + $sToRender .= ""; + // blank filename + $sToRender .= ""; + // creator name + $sToRender .= ""; + // modified date + $sToRender .= ""; + // document type + $sToRender .= ""; + + $sToRender .= "\n"; } } else { // else the first entry is the category name, so display the documents in the category @@ -102,7 +115,7 @@ function renderCategoryResults($aResults) { return $sToRender; } -// +// // /** @@ -145,7 +158,18 @@ function renderDocumentTypeResults($aResults) { if ($aResults["documentTypes"][0]["name"] == "Document Types") { // loop through document types and display them for ($i=1; $i" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . ""; + $sToRender .= ""; + // document type name + $sToRender .= ""; + // blank filename + $sToRender .= ""; + // creator name + $sToRender .= ""; + // modified date + $sToRender .= ""; + // document type + $sToRender .= ""; + $sToRender .= "\n"; } } else { // else the first entry is the document type name, so display the documents in the document type @@ -154,9 +178,48 @@ function renderDocumentTypeResults($aResults) { } return $sToRender; } -// +// +// +/** + * Displays the folders in the browse results + * + * @param array the browse result objects + */ +function renderFolderResults($aResults) { + global $default; + $sToRender = ""; + + // now loop through the rest of the folders and display links + if (count($aResults["folders"]) > 1) { + for ($i=1; $igetCreatorID()); + + $sToRender .= ""; + // folder name + $sToRender .= ""; + // blank filename (??: folder description?) + $sToRender .= ""; + // creator name + $sToRender .= ""; + // modified date (TODO: add to db) + $sToRender .= ""; + // document type (??: display one of the mapped document types?) + $sToRender .= ""; + $sToRender .= "\n"; + } + } else { + $sToRender .= ""; + } + + $sToRender .= "\n"; + + return $sToRender; +} +// + /** * Displays the headings for the displayed document details and enables * resorting the contents @@ -201,31 +264,6 @@ function renderSortHeadings($sSortBy, $sSortDirection) { } /** - * Displays the folders in the browse results - * - * @param array the browse result objects - */ -function renderFolderResults($aResults) { - global $default; - $sToRender = ""; - - // now loop through the rest of the folders and display links - if (count($aResults["folders"]) > 1) { - for ($i=1; $igetCreatorID()); - $sToRender .= "\n"; - } - } else { - $sToRender .= ""; - } - - $sToRender .= "\n"; - - return $sToRender; -} - -/** * Displays the documents in the browse results * * @param array the browse result objects
$sHeading
" . displayCategoryLink($aResults["categories"][$i]) . "
" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "
" . $sFolderLink . "" . $oCreator->getName() . "
This folder contains no sub folders
" . renderDocumentList($aResults, "This folder contains no documents", "You don't have access to the documents in this folder") . "
" . $sFolderLink . "" . $oCreator->getName() . "
This folder contains no sub folders
" . renderDocumentList($aResults, "This folder contains no documents", "You don't have access to the documents in this folder") . "