From 160da172537aced598eb7c52f083cc77be80213b Mon Sep 17 00:00:00 2001 From: nbm Date: Wed, 22 Dec 2004 10:15:09 +0000 Subject: [PATCH] Whitespace cleanup. --- lib/browse/FolderBrowser.inc | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------- presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc | 260 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------- 2 files changed, 218 insertions(+), 206 deletions(-) diff --git a/lib/browse/FolderBrowser.inc b/lib/browse/FolderBrowser.inc index 48dcdf2..b727b7d 100644 --- a/lib/browse/FolderBrowser.inc +++ b/lib/browse/FolderBrowser.inc @@ -15,32 +15,32 @@ require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * - * @version $Revision$ + * @version $Revision$ * @author Michael Joseph , Jam Warehouse (Pty) Ltd, South Africa * @package lib.browse */ class FolderBrowser extends Browser { - /** - * Construct a new FolderBrowser instance with the specified sort criteria - * - * @param string the field to sort the results by - * @param string the direction to sort the results - */ - function FolderBrowser($sSortField = "name", $sSortDirection = "asc", $aNewSortCriteria = array()) { - Browser::Browser($sSortField, $sSortDirection, $aNewSortCriteria); - } - + /** + * Construct a new FolderBrowser instance with the specified sort criteria + * + * @param string the field to sort the results by + * @param string the direction to sort the results + */ + function FolderBrowser($sSortField = "name", $sSortDirection = "asc", $aNewSortCriteria = array()) { + Browser::Browser($sSortField, $sSortDirection, $aNewSortCriteria); + } + /** * Browse the documents by folder * @@ -52,137 +52,137 @@ class FolderBrowser extends Browser { // XXX: Shouldn't be getting this from $_REQUEST $iFolderID = $_REQUEST['fFolderID']; - // we're browsing folders - $this->setBrowseStart($iFolderID); - $iFolderID = $iFolderID; - + // we're browsing folders + $this->setBrowseStart($iFolderID); + $iFolderID = $iFolderID; + // instantiate and initialise $results = array(); $sql = $default->db; - + // no folder specified, so depending on the users groups, resolve to the right folderID if ($iFolderID == "") { // no folder specified, so start at the root folder - - //TO DO: Need to look up all the Units + + //TO DO: Need to look up all the Units // look up this users unit $unitID = User::getUnitID($_SESSION["userID"]); - - $default->log->debug("Users UNIT = " . $unitID ); - + + $default->log->debug("Users UNIT = " . $unitID ); + if ($unitID) { // if the user is in a unit, start at the unit's root folder - + // lookup the unit name - $unitName = lookupField($default->units_table, "name", "id", $unitID); + $unitName = lookupField($default->units_table, "name", "id", $unitID); // the unit root folder has the same name as the unit // FIXME: dodgy i know, but its easy $unitRootFolderName = $unitName; - + // now lookup the folderID $aFolders = Folder::getList("name='$unitRootFolderName' and parent_id=1"); - - $default->log->debug("Users UNIT Name = " . $unitRootFolderName ); - + + $default->log->debug("Users UNIT Name = " . $unitRootFolderName ); + if (!$aFolders) { // no folder exists with this name, so start at the root - $default->log->debug("Users UNIT Name NO FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); + $default->log->debug("Users UNIT Name NO FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); $iFolderID = lookupID($default->folders_table, "parent_id", 0); } else { - $iFolderID = $aFolders[0]->getID(); - $default->log->debug("FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); + $iFolderID = $aFolders[0]->getID(); + $default->log->debug("FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); } - + } else { // else just start at the root // FIXME: start at the root folder for the default organisation $iFolderID = lookupID($default->folders_table, "parent_id", 0); } } else{ - $default->log->debug("Folder specified " . $iFolderID ); + $default->log->debug("Folder specified " . $iFolderID ); } - + $default->log->debug("FolderBrowser::browseByFolder: folderID=" . $iFolderID); - + // get the folder $rootFolder = Folder::get($iFolderID); // FIXME: check permissions for the current folder before getting children $results["folders"][] = & $rootFolder; if ($results["folders"][0]) { - - // now find all the child folders relative to this one + + // now find all the child folders relative to this one // FIXME: in the same unit? - + $aLookupCriteria = $this->aSortCriteria[$this->sSortField]["lookup"]; - + // if we're sorting by name or creator_id then sort folders in the appropriate direction - + $aParams = array(); $sFolderQuery = "SELECT f.id FROM $default->folders_table AS f ";/*ok*/ - if (in_array($this->sSortField, array("name", "creator_id"))) { - if (isset($aLookupCriteria)) { - $sFolderQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON f.$this->sSortField=lt.id WHERE parent_id = ?"; - $sFolderQuery .= " ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; - } else { - $sFolderQuery .= "WHERE parent_id = ? ORDER BY $this->sSortField $this->sSortDirection"; - } - } else { - $sFolderQuery .= "WHERE parent_id = ? ORDER BY f.name asc"; - } + if (in_array($this->sSortField, array("name", "creator_id"))) { + if (isset($aLookupCriteria)) { + $sFolderQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON f.$this->sSortField=lt.id WHERE parent_id = ?"; + $sFolderQuery .= " ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; + } else { + $sFolderQuery .= "WHERE parent_id = ? ORDER BY $this->sSortField $this->sSortDirection"; + } + } else { + $sFolderQuery .= "WHERE parent_id = ? ORDER BY f.name asc"; + } $aParams[] = $iFolderID; - $default->log->debug("Ordering folderQuery = $sFolderQuery"); - + $default->log->debug("Ordering folderQuery = $sFolderQuery"); + if ($sql->query(array($sFolderQuery, $aParams))) { while ($sql->next_record()) { $default->log->debug("In folder iteration while, with folder_id " . $sql->f("id")); // check whether to display folders which are not readable and display/hide these accordingly - $oFolder = Folder::get($sql->f("id")); - if ($default->folderHidingFlag) { - if (Permission::userHasFolderReadPermission($oFolder)) { - $default->log->debug("FOLDER PERMISSIONS: Does have permission for folder " . $oFolder->getID() . ":" . $sql->f("id") ); - $results["folders"][] = $oFolder; - } else { - $default->log->debug("FOLDER PERMISSIONS: Does NOT have permission for folder " . $sql->f("id") ); - } - } else{ + $oFolder = Folder::get($sql->f("id")); + if ($default->folderHidingFlag) { + if (Permission::userHasFolderReadPermission($oFolder)) { + $default->log->debug("FOLDER PERMISSIONS: Does have permission for folder " . $oFolder->getID() . ":" . $sql->f("id") ); + $results["folders"][] = $oFolder; + } else { + $default->log->debug("FOLDER PERMISSIONS: Does NOT have permission for folder " . $sql->f("id") ); + } + } else{ $results["folders"][] = $oFolder; - } + } } } - + $default->log->debug("Going on to document checking"); - + // create query to retrieve documents in this folder $documentQuery = "SELECT d.id as id FROM $default->documents_table AS d ";/*wc*/ if (isset($aLookupCriteria)) { - $documentQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON "; - $documentQuery .= "d.$this->sSortField" . "=lt." . (isset($aLookupCriteria["joinColumn"]) ? $aLookupCriteria["joinColumn"] : "id"); - } - $documentQuery .= " WHERE d.folder_id=$iFolderID " . (isset($aLookupCriteria["whereClause"]) ? "AND lt." . $aLookupCriteria["whereClause"] : "") . " "; - if (isset($aLookupCriteria)) { - $documentQuery .= "ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; + $documentQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON "; + $documentQuery .= "d.$this->sSortField" . "=lt." . (isset($aLookupCriteria["joinColumn"]) ? $aLookupCriteria["joinColumn"] : "id"); + } + $documentQuery .= " WHERE d.folder_id=$iFolderID " . (isset($aLookupCriteria["whereClause"]) ? "AND lt." . $aLookupCriteria["whereClause"] : "") . " "; + if (isset($aLookupCriteria)) { + $documentQuery .= "ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; } else { - $documentQuery .= "ORDER BY $this->sSortField $this->sSortDirection"; + $documentQuery .= "ORDER BY $this->sSortField $this->sSortDirection"; } $default->log->debug("docQuery=$documentQuery"); - + // initialise access flag; $results["accessDenied"] = false; if ($sql->query($documentQuery)) { - - // do the check for whether this documents have folder read permission, if they do, it's all good. - $hasFolderRead = Permission::userHasFolderReadPermission($rootFolder); - + + // do the check for whether this documents have folder read permission, if they do, it's all good. + $hasFolderRead = Permission::userHasFolderReadPermission($rootFolder); + while ($sql->next_record()) { - $oDocument = & Document::get($sql->f("id")); + $oDocument = & Document::get($sql->f("id")); // proceed if the document is live if ($oDocument->isLive()) { // check permissions if ($hasFolderRead || Permission::userHasDocumentReadPermission($oDocument)) { // add documents to array // set file attributes - $results["documents"][] = $oDocument; + $results["documents"][] = $oDocument; } else { // set access denied message $results["accessDenied"] = true; @@ -192,12 +192,12 @@ class FolderBrowser extends Browser { } else { $_SESSION["errorMessage"] = "documents table select failed"; } - + return $results; } } - + function getSectionName() { - return "Manage Documents"; + return "Manage Documents"; } } diff --git a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc index ae1b8bb..5cf2344 100644 --- a/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc +++ b/presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc @@ -19,12 +19,12 @@ require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -43,43 +43,43 @@ require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); function renderBrowseTypeSelect($sBrowseType) { // TODO: write function for onChange that checks if the new value return "\n - \t" . _("View documents by") . ": " . _("Folders") ."\n" . - " " . _("Category") . "\n" . - " " . _("Document Type") . "\n"; + \t" . _("View documents by") . ": " . _("Folders") ."\n" . + " " . _("Category") . "\n" . + " " . _("Document Type") . "\n"; } // /** * Displays the passed category path as a link - * + * * @param string the category name to display */ -function displayCategoryPathLink($aCategories) { +function displayCategoryPathLink($aCategories) { // if the first value in arr["categories"] == Categories then we've got a list of categories if ($aCategories[0] == "Categories") { return displayCategoryLink($aCategories[0]); } else { // else the first entry is the category name, so build a little path return displayCategoryLink("Categories") . ($aCategories[0] ? " > " . displayCategoryLink($aCategories[0]) : ""); - } + } } /** * Displays the passed category as a link - * + * * @param string the category name to display */ function displayCategoryLink($sCategoryName) { if ($sCategoryName != "") { return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=category" . - // if the category title is passed in, link back to the list of categories - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), - $sCategoryName); + "fBrowseType=category" . + // if the category title is passed in, link back to the list of categories + (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), + $sCategoryName); } else { return false; } @@ -90,16 +90,16 @@ function displayCategoryLink($sCategoryName) { * * @param array the category browse results */ -function renderCategoryResults($aResults) { +function renderCategoryResults($aResults) { $sToRender = ""; - + //var_dump($aResults["categories"][0]); - // if the first value in arr["categories"] == Categories then we've got a list of categories + // if the first value in arr["categories"] == Categories then we've got a list of categories if ($aResults["categories"][0] == "Categories") { // loop through categories and display them for ($i=1; $i"; - + // category name $sToRender .= "" . displayCategoryLink($aResults["categories"][$i]) . ""; // blank filename @@ -109,17 +109,17 @@ function renderCategoryResults($aResults) { // modified date $sToRender .= " "; // document type - $sToRender .= " "; + $sToRender .= " "; $sToRender .= "\n"; } } else { - if (count($aResults["categories"]) > 0) { - // else the first entry is the category name, so display the documents in the category - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); - } else { - $sToRender .= "" . _("There is no Category Document Field- contact a System Administrator.") . ""; - } + if (count($aResults["categories"]) > 0) { + // else the first entry is the category name, so display the documents in the category + $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); + } else { + $sToRender .= "" . _("There is no Category Document Field- contact a System Administrator.") . ""; + } } return $sToRender; } @@ -129,8 +129,8 @@ function renderCategoryResults($aResults) { // /** * Displays the passed document type path as a link - * - * @param string the document type to display + * + * @param string the document type to display */ function displayDocumentTypePathLink($aDocumentTypes) { // if the first value in arr["categories"] == Categories then we've got a list of categories @@ -144,15 +144,15 @@ function displayDocumentTypePathLink($aDocumentTypes) { /** * Displays the passed document type as a link - * - * @param string the document type to display + * + * @param string the document type to display */ function displayDocumentTypeLink($aDocumentType) { return generateLink($_SERVER["PHP_SELF"], - "fBrowseType=documentType" . - // if the document type title is passed in, link back to the list of document types - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), - $aDocumentType["name"]); + "fBrowseType=documentType" . + // if the document type title is passed in, link back to the list of document types + (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), + $aDocumentType["name"]); } /** @@ -162,12 +162,12 @@ function displayDocumentTypeLink($aDocumentType) { */ function renderDocumentTypeResults($aResults) { $sToRender = ""; - + // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types if ($aResults["documentTypes"][0]["name"] == "Document Types") { // loop through document types and display them for ($i=1; $i"; + $sToRender .= ""; // document type name $sToRender .= "" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . ""; // blank filename @@ -177,8 +177,8 @@ function renderDocumentTypeResults($aResults) { // modified date $sToRender .= " "; // document type - $sToRender .= " "; - $sToRender .= "\n"; + $sToRender .= " "; + $sToRender .= "\n"; } } else { // else the first entry is the document type name, so display the documents in the document type @@ -204,9 +204,9 @@ function renderFolderResults($aResults, $bTemplateBrowsing = false) { for ($i=1; $igetCreatorID()); - + // the first element of the array contains the current folder name - $sToRender .= ""; + $sToRender .= ""; // folder name $sToRender .= "" . $sFolderLink . ""; // blank filename (folder description?) @@ -216,18 +216,18 @@ function renderFolderResults($aResults, $bTemplateBrowsing = false) { // modified date (TODO: add to db) $sToRender .= " "; // document type (??: display one of the mapped document types? which one?) - $sToRender .= " "; + $sToRender .= " "; $sToRender .= "\n"; } } else { $sToRender .= "" . _("This folder contains no sub folders") . ""; } - - $sToRender .= "" . renderDocumentList($aResults, _("This folder contains no documents"), - _("You don't have access to the documents in this folder"), - false, $bTemplateBrowsing) . - "\n"; - + + $sToRender .= "" . renderDocumentList($aResults, _("This folder contains no documents"), + _("You don't have access to the documents in this folder"), + false, $bTemplateBrowsing) . + "\n"; + return $sToRender; } // @@ -240,36 +240,36 @@ function renderFolderResults($aResults, $bTemplateBrowsing = false) { * @param string the direction currently sorted in */ function renderSortHeadings($sSortBy, $sSortDirection) { - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - - // need list of display criteria and sort name - $aSortCriteria = $oBrowser->getSortCriteria(); - + global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; + + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); + + // need list of display criteria and sort name + $aSortCriteria = $oBrowser->getSortCriteria(); + $sToRender .= ""; - while (list($key, $value) = each ($aSortCriteria)) { - $sCurrentSortDirection = "asc"; - $displayText = $value["display"]; - // if the current heading is being sorted then flip the sort direction - if ($sSortBy == $key) { - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); - $displayText = "" . $displayText; - } - switch ($fBrowseType) { - case "folder" : - $queryString = "fFolderID=$fFolderID"; - break; - case "category" : - $queryString = "fCategoryName=$fCategoryName"; - break; - case "documentType" : - $queryString = "fDocumentTypeID=$fDocumentTypeID"; - break; - } - $sToRender .= "" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . ""; - } + while (list($key, $value) = each ($aSortCriteria)) { + $sCurrentSortDirection = "asc"; + $displayText = $value["display"]; + // if the current heading is being sorted then flip the sort direction + if ($sSortBy == $key) { + $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); + $displayText = "" . $displayText; + } + switch ($fBrowseType) { + case "folder" : + $queryString = "fFolderID=$fFolderID"; + break; + case "category" : + $queryString = "fCategoryName=$fCategoryName"; + break; + case "documentType" : + $queryString = "fDocumentTypeID=$fDocumentTypeID"; + break; + } + $sToRender .= "" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . ""; + } $sToRender .= "\n"; return $sToRender; @@ -284,19 +284,19 @@ function renderSortHeadings($sSortBy, $sSortDirection) { * @param boolean whether to display the complete path to the document or not */ function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false, $bTemplateBrowsing = false) { - global $default; + global $default; - $iFolderCount = count($aResults["folders"]) - 1; + $iFolderCount = count($aResults["folders"]) - 1; // loop through the files and display links if (count($aResults["documents"]) > 0) { for ($i=0; $i" . - "getID() . "\"/>" . - ($bTemplateBrowsing ? displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) : - displayDocumentLink($aResults["documents"][$i], $bDisplayFullPath)) . ""; - + // in order for candy striping to work we need to take the number of folders + // into account when alternating + $sToRender .= "" . + "getID() . "\"/>" . + ($bTemplateBrowsing ? displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) : + displayDocumentLink($aResults["documents"][$i], $bDisplayFullPath)) . ""; + // #3425 the title is now the filename, and the description is the title $sToRender .= "" . $aResults["documents"][$i]->getName() . ""; $oCreator = User::get($aResults["documents"][$i]->getCreatorID()); @@ -305,24 +305,24 @@ function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessa $sToRender .= "" . $aDocumentTransaction[0]->dDateTime . ""; $oDocumentType = DocumentType::get($aResults["documents"][$i]->getDocumentTypeID()); if ($oDocumentType) { - $sToRender .= "" . $oDocumentType->getName() . ""; + $sToRender .= "" . $oDocumentType->getName() . ""; } $sToRender .= "\n"; } - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); - $sToRender .= "" . - " " . _("Select all documents") . ""; + $sToRender .= "" . + " " . _("Select all documents") . ""; - $sToRender .= ""; - $sToRender .= ""; + $sToRender .= ""; + $sToRender .= ""; - $sToRender .= ""; - $sToRender .= ""; - $sToRender .= "\n"; - // Change for group Operations + $sToRender .= ""; + $sToRender .= ""; + $sToRender .= "\n"; + // Change for group Operations } else if ($aResults["accessDenied"]) { @@ -338,11 +338,11 @@ function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessa * Appends folder and document counts to the last folder path */ function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { - // append to the last path component and return - $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . - " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . - ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; - return $aFolderPath; + // append to the last path component and return + $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . + " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . + ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; + return $aFolderPath; } /** @@ -356,12 +356,12 @@ function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection, $bTemplateBrowsing = false) { global $default; - - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); + + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); $sToRender = renderHeading(_("Browse collection")); - + // Script function to select all documents $sToRender = "\n\n\n\n"; - $sToRender .= "
"; + $sToRender .= "
"; switch ($sBrowseType) { - case "folder" : $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), - appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), - count($aResults["folders"])-1, - count($aResults["documents"]))); break; - case "category" : $sToRender .= displayCategoryPathLink($aResults["categories"]); break; - case "documentType" : $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); break; + case "folder": + $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), + appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), + count($aResults["folders"])-1, count($aResults["documents"]))); + break; + case "category": + $sToRender .= displayCategoryPathLink($aResults["categories"]); + break; + case "documentType": + $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); + break; } $sToRender .= "
\n"; - - // browse type select - $sToRender .= "\n"; + + // browse type select + $sToRender .= "
\n"; $sToRender .= "\t"; $sToRender .= "\t
" . renderBrowseTypeSelect($sBrowseType) . "
"; - + // display folders|documents - $sToRender .= "\n"; - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); - $sToRender .= "
\n"; + $sToRender .= "\n"; + $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); + $sToRender .= "\n"; $sToRender .= "\t
\n"; switch ($sBrowseType) { - case "folder" : $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); break; - case "category" : $sToRender .= renderCategoryResults($aResults); break; - case "documentType" : $sToRender .= renderDocumentTypeResults($aResults); break; + case "folder": + $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); + break; + case "category": + $sToRender .= renderCategoryResults($aResults); + break; + case "documentType": + $sToRender .= renderDocumentTypeResults($aResults); + break; } $sToRender .= "
"; - + return $sToRender; } + ?> -- libgit2 0.21.4