Commit 160da172537aced598eb7c52f083cc77be80213b
1 parent
fd63735a
Whitespace cleanup.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3071 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
218 additions
and
206 deletions
lib/browse/FolderBrowser.inc
| ... | ... | @@ -15,32 +15,32 @@ require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); |
| 15 | 15 | * it under the terms of the GNU General Public License as published by |
| 16 | 16 | * the Free Software Foundation; either version 2 of the License, or |
| 17 | 17 | * (at your option) any later version. |
| 18 | - * | |
| 18 | + * | |
| 19 | 19 | * This program is distributed in the hope that it will be useful, |
| 20 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | 22 | * GNU General Public License for more details. |
| 23 | - * | |
| 23 | + * | |
| 24 | 24 | * You should have received a copy of the GNU General Public License |
| 25 | 25 | * along with this program; if not, write to the Free Software |
| 26 | 26 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 27 | 27 | * |
| 28 | - * @version $Revision$ | |
| 28 | + * @version $Revision$ | |
| 29 | 29 | * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa |
| 30 | 30 | * @package lib.browse |
| 31 | 31 | */ |
| 32 | 32 | class FolderBrowser extends Browser { |
| 33 | 33 | |
| 34 | - /** | |
| 35 | - * Construct a new FolderBrowser instance with the specified sort criteria | |
| 36 | - * | |
| 37 | - * @param string the field to sort the results by | |
| 38 | - * @param string the direction to sort the results | |
| 39 | - */ | |
| 40 | - function FolderBrowser($sSortField = "name", $sSortDirection = "asc", $aNewSortCriteria = array()) { | |
| 41 | - Browser::Browser($sSortField, $sSortDirection, $aNewSortCriteria); | |
| 42 | - } | |
| 43 | - | |
| 34 | + /** | |
| 35 | + * Construct a new FolderBrowser instance with the specified sort criteria | |
| 36 | + * | |
| 37 | + * @param string the field to sort the results by | |
| 38 | + * @param string the direction to sort the results | |
| 39 | + */ | |
| 40 | + function FolderBrowser($sSortField = "name", $sSortDirection = "asc", $aNewSortCriteria = array()) { | |
| 41 | + Browser::Browser($sSortField, $sSortDirection, $aNewSortCriteria); | |
| 42 | + } | |
| 43 | + | |
| 44 | 44 | /** |
| 45 | 45 | * Browse the documents by folder |
| 46 | 46 | * |
| ... | ... | @@ -52,137 +52,137 @@ class FolderBrowser extends Browser { |
| 52 | 52 | // XXX: Shouldn't be getting this from $_REQUEST |
| 53 | 53 | $iFolderID = $_REQUEST['fFolderID']; |
| 54 | 54 | |
| 55 | - // we're browsing folders | |
| 56 | - $this->setBrowseStart($iFolderID); | |
| 57 | - $iFolderID = $iFolderID; | |
| 58 | - | |
| 55 | + // we're browsing folders | |
| 56 | + $this->setBrowseStart($iFolderID); | |
| 57 | + $iFolderID = $iFolderID; | |
| 58 | + | |
| 59 | 59 | // instantiate and initialise |
| 60 | 60 | $results = array(); |
| 61 | 61 | $sql = $default->db; |
| 62 | - | |
| 62 | + | |
| 63 | 63 | // no folder specified, so depending on the users groups, resolve to the right folderID |
| 64 | 64 | if ($iFolderID == "") { |
| 65 | 65 | // no folder specified, so start at the root folder |
| 66 | - | |
| 67 | - //TO DO: Need to look up all the Units | |
| 66 | + | |
| 67 | + //TO DO: Need to look up all the Units | |
| 68 | 68 | // look up this users unit |
| 69 | 69 | $unitID = User::getUnitID($_SESSION["userID"]); |
| 70 | - | |
| 71 | - $default->log->debug("Users UNIT = " . $unitID ); | |
| 72 | - | |
| 70 | + | |
| 71 | + $default->log->debug("Users UNIT = " . $unitID ); | |
| 72 | + | |
| 73 | 73 | if ($unitID) { |
| 74 | 74 | // if the user is in a unit, start at the unit's root folder |
| 75 | - | |
| 75 | + | |
| 76 | 76 | // lookup the unit name |
| 77 | - $unitName = lookupField($default->units_table, "name", "id", $unitID); | |
| 77 | + $unitName = lookupField($default->units_table, "name", "id", $unitID); | |
| 78 | 78 | |
| 79 | 79 | // the unit root folder has the same name as the unit |
| 80 | 80 | // FIXME: dodgy i know, but its easy |
| 81 | 81 | $unitRootFolderName = $unitName; |
| 82 | - | |
| 82 | + | |
| 83 | 83 | // now lookup the folderID |
| 84 | 84 | $aFolders = Folder::getList("name='$unitRootFolderName' and parent_id=1"); |
| 85 | - | |
| 86 | - $default->log->debug("Users UNIT Name = " . $unitRootFolderName ); | |
| 87 | - | |
| 85 | + | |
| 86 | + $default->log->debug("Users UNIT Name = " . $unitRootFolderName ); | |
| 87 | + | |
| 88 | 88 | if (!$aFolders) { |
| 89 | 89 | // no folder exists with this name, so start at the root |
| 90 | - $default->log->debug("Users UNIT Name NO FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); | |
| 90 | + $default->log->debug("Users UNIT Name NO FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); | |
| 91 | 91 | $iFolderID = lookupID($default->folders_table, "parent_id", 0); |
| 92 | 92 | } else { |
| 93 | - $iFolderID = $aFolders[0]->getID(); | |
| 94 | - $default->log->debug("FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); | |
| 93 | + $iFolderID = $aFolders[0]->getID(); | |
| 94 | + $default->log->debug("FOLDER EXISTS WITH THIS NAME" . $unitRootFolderName ); | |
| 95 | 95 | } |
| 96 | - | |
| 96 | + | |
| 97 | 97 | } else { |
| 98 | 98 | // else just start at the root |
| 99 | 99 | // FIXME: start at the root folder for the default organisation |
| 100 | 100 | $iFolderID = lookupID($default->folders_table, "parent_id", 0); |
| 101 | 101 | } |
| 102 | 102 | } else{ |
| 103 | - $default->log->debug("Folder specified " . $iFolderID ); | |
| 103 | + $default->log->debug("Folder specified " . $iFolderID ); | |
| 104 | 104 | } |
| 105 | - | |
| 105 | + | |
| 106 | 106 | $default->log->debug("FolderBrowser::browseByFolder: folderID=" . $iFolderID); |
| 107 | - | |
| 107 | + | |
| 108 | 108 | // get the folder |
| 109 | 109 | $rootFolder = Folder::get($iFolderID); |
| 110 | 110 | // FIXME: check permissions for the current folder before getting children |
| 111 | 111 | $results["folders"][] = & $rootFolder; |
| 112 | 112 | if ($results["folders"][0]) { |
| 113 | - | |
| 114 | - // now find all the child folders relative to this one | |
| 113 | + | |
| 114 | + // now find all the child folders relative to this one | |
| 115 | 115 | // FIXME: in the same unit? |
| 116 | - | |
| 116 | + | |
| 117 | 117 | $aLookupCriteria = $this->aSortCriteria[$this->sSortField]["lookup"]; |
| 118 | - | |
| 118 | + | |
| 119 | 119 | // if we're sorting by name or creator_id then sort folders in the appropriate direction |
| 120 | - | |
| 120 | + | |
| 121 | 121 | $aParams = array(); |
| 122 | 122 | $sFolderQuery = "SELECT f.id FROM $default->folders_table AS f ";/*ok*/ |
| 123 | - if (in_array($this->sSortField, array("name", "creator_id"))) { | |
| 124 | - if (isset($aLookupCriteria)) { | |
| 125 | - $sFolderQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON f.$this->sSortField=lt.id WHERE parent_id = ?"; | |
| 126 | - $sFolderQuery .= " ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; | |
| 127 | - } else { | |
| 128 | - $sFolderQuery .= "WHERE parent_id = ? ORDER BY $this->sSortField $this->sSortDirection"; | |
| 129 | - } | |
| 130 | - } else { | |
| 131 | - $sFolderQuery .= "WHERE parent_id = ? ORDER BY f.name asc"; | |
| 132 | - } | |
| 123 | + if (in_array($this->sSortField, array("name", "creator_id"))) { | |
| 124 | + if (isset($aLookupCriteria)) { | |
| 125 | + $sFolderQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON f.$this->sSortField=lt.id WHERE parent_id = ?"; | |
| 126 | + $sFolderQuery .= " ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; | |
| 127 | + } else { | |
| 128 | + $sFolderQuery .= "WHERE parent_id = ? ORDER BY $this->sSortField $this->sSortDirection"; | |
| 129 | + } | |
| 130 | + } else { | |
| 131 | + $sFolderQuery .= "WHERE parent_id = ? ORDER BY f.name asc"; | |
| 132 | + } | |
| 133 | 133 | $aParams[] = $iFolderID; |
| 134 | - $default->log->debug("Ordering folderQuery = $sFolderQuery"); | |
| 135 | - | |
| 134 | + $default->log->debug("Ordering folderQuery = $sFolderQuery"); | |
| 135 | + | |
| 136 | 136 | if ($sql->query(array($sFolderQuery, $aParams))) { |
| 137 | 137 | while ($sql->next_record()) { |
| 138 | 138 | $default->log->debug("In folder iteration while, with folder_id " . $sql->f("id")); |
| 139 | 139 | // check whether to display folders which are not readable and display/hide these accordingly |
| 140 | - $oFolder = Folder::get($sql->f("id")); | |
| 141 | - if ($default->folderHidingFlag) { | |
| 142 | - if (Permission::userHasFolderReadPermission($oFolder)) { | |
| 143 | - $default->log->debug("FOLDER PERMISSIONS: Does have permission for folder " . $oFolder->getID() . ":" . $sql->f("id") ); | |
| 144 | - $results["folders"][] = $oFolder; | |
| 145 | - } else { | |
| 146 | - $default->log->debug("FOLDER PERMISSIONS: Does NOT have permission for folder " . $sql->f("id") ); | |
| 147 | - } | |
| 148 | - } else{ | |
| 140 | + $oFolder = Folder::get($sql->f("id")); | |
| 141 | + if ($default->folderHidingFlag) { | |
| 142 | + if (Permission::userHasFolderReadPermission($oFolder)) { | |
| 143 | + $default->log->debug("FOLDER PERMISSIONS: Does have permission for folder " . $oFolder->getID() . ":" . $sql->f("id") ); | |
| 144 | + $results["folders"][] = $oFolder; | |
| 145 | + } else { | |
| 146 | + $default->log->debug("FOLDER PERMISSIONS: Does NOT have permission for folder " . $sql->f("id") ); | |
| 147 | + } | |
| 148 | + } else{ | |
| 149 | 149 | $results["folders"][] = $oFolder; |
| 150 | - } | |
| 150 | + } | |
| 151 | 151 | } |
| 152 | 152 | } |
| 153 | - | |
| 153 | + | |
| 154 | 154 | $default->log->debug("Going on to document checking"); |
| 155 | - | |
| 155 | + | |
| 156 | 156 | // create query to retrieve documents in this folder |
| 157 | 157 | $documentQuery = "SELECT d.id as id FROM $default->documents_table AS d ";/*wc*/ |
| 158 | 158 | if (isset($aLookupCriteria)) { |
| 159 | - $documentQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON "; | |
| 160 | - $documentQuery .= "d.$this->sSortField" . "=lt." . (isset($aLookupCriteria["joinColumn"]) ? $aLookupCriteria["joinColumn"] : "id"); | |
| 161 | - } | |
| 162 | - $documentQuery .= " WHERE d.folder_id=$iFolderID " . (isset($aLookupCriteria["whereClause"]) ? "AND lt." . $aLookupCriteria["whereClause"] : "") . " "; | |
| 163 | - if (isset($aLookupCriteria)) { | |
| 164 | - $documentQuery .= "ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; | |
| 159 | + $documentQuery .= "INNER JOIN " . $aLookupCriteria["table"] . " lt ON "; | |
| 160 | + $documentQuery .= "d.$this->sSortField" . "=lt." . (isset($aLookupCriteria["joinColumn"]) ? $aLookupCriteria["joinColumn"] : "id"); | |
| 161 | + } | |
| 162 | + $documentQuery .= " WHERE d.folder_id=$iFolderID " . (isset($aLookupCriteria["whereClause"]) ? "AND lt." . $aLookupCriteria["whereClause"] : "") . " "; | |
| 163 | + if (isset($aLookupCriteria)) { | |
| 164 | + $documentQuery .= "ORDER BY lt." . $aLookupCriteria["field"] . " $this->sSortDirection"; | |
| 165 | 165 | } else { |
| 166 | - $documentQuery .= "ORDER BY $this->sSortField $this->sSortDirection"; | |
| 166 | + $documentQuery .= "ORDER BY $this->sSortField $this->sSortDirection"; | |
| 167 | 167 | } |
| 168 | 168 | $default->log->debug("docQuery=$documentQuery"); |
| 169 | - | |
| 169 | + | |
| 170 | 170 | // initialise access flag; |
| 171 | 171 | $results["accessDenied"] = false; |
| 172 | 172 | if ($sql->query($documentQuery)) { |
| 173 | - | |
| 174 | - // do the check for whether this documents have folder read permission, if they do, it's all good. | |
| 175 | - $hasFolderRead = Permission::userHasFolderReadPermission($rootFolder); | |
| 176 | - | |
| 173 | + | |
| 174 | + // do the check for whether this documents have folder read permission, if they do, it's all good. | |
| 175 | + $hasFolderRead = Permission::userHasFolderReadPermission($rootFolder); | |
| 176 | + | |
| 177 | 177 | while ($sql->next_record()) { |
| 178 | - $oDocument = & Document::get($sql->f("id")); | |
| 178 | + $oDocument = & Document::get($sql->f("id")); | |
| 179 | 179 | // proceed if the document is live |
| 180 | 180 | if ($oDocument->isLive()) { |
| 181 | 181 | // check permissions |
| 182 | 182 | if ($hasFolderRead || Permission::userHasDocumentReadPermission($oDocument)) { |
| 183 | 183 | // add documents to array |
| 184 | 184 | // set file attributes |
| 185 | - $results["documents"][] = $oDocument; | |
| 185 | + $results["documents"][] = $oDocument; | |
| 186 | 186 | } else { |
| 187 | 187 | // set access denied message |
| 188 | 188 | $results["accessDenied"] = true; |
| ... | ... | @@ -192,12 +192,12 @@ class FolderBrowser extends Browser { |
| 192 | 192 | } else { |
| 193 | 193 | $_SESSION["errorMessage"] = "documents table select failed"; |
| 194 | 194 | } |
| 195 | - | |
| 195 | + | |
| 196 | 196 | return $results; |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | - | |
| 199 | + | |
| 200 | 200 | function getSectionName() { |
| 201 | - return "Manage Documents"; | |
| 201 | + return "Manage Documents"; | |
| 202 | 202 | } |
| 203 | 203 | } | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc
| ... | ... | @@ -19,12 +19,12 @@ require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); |
| 19 | 19 | * it under the terms of the GNU General Public License as published by |
| 20 | 20 | * the Free Software Foundation; either version 2 of the License, or |
| 21 | 21 | * (at your option) any later version. |
| 22 | - * | |
| 22 | + * | |
| 23 | 23 | * This program is distributed in the hope that it will be useful, |
| 24 | 24 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 25 | 25 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 26 | 26 | * GNU General Public License for more details. |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * You should have received a copy of the GNU General Public License |
| 29 | 29 | * along with this program; if not, write to the Free Software |
| 30 | 30 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| ... | ... | @@ -43,43 +43,43 @@ require_once("$default->uiDirectory/foldermanagement/addFolderUI.inc"); |
| 43 | 43 | function renderBrowseTypeSelect($sBrowseType) { |
| 44 | 44 | // TODO: write function for onChange that checks if the new value |
| 45 | 45 | return "<span class=\"browseTypeSelect\">\n |
| 46 | - \t" . _("View documents by") . ": <input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"folder\"" . | |
| 47 | - ((($sBrowseType=="folder") || (strlen($sBrowseType)==0)) ? " checked=\"checked\"" : "") . "/> " . _("Folders") ."\n" . | |
| 48 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"category\"" . | |
| 49 | - (($sBrowseType=="category") ? " checked=\"checked\"" : "") . "/> " . _("Category") . "\n" . | |
| 50 | - "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"documentType\"" . | |
| 51 | - (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> " . _("Document Type") . "\n</span>"; | |
| 46 | + \t" . _("View documents by") . ": <input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"folder\"" . | |
| 47 | + ((($sBrowseType=="folder") || (strlen($sBrowseType)==0)) ? " checked=\"checked\"" : "") . "/> " . _("Folders") ."\n" . | |
| 48 | + "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"category\"" . | |
| 49 | + (($sBrowseType=="category") ? " checked=\"checked\"" : "") . "/> " . _("Category") . "\n" . | |
| 50 | + "<input type=\"radio\" name=\"fBrowseType\" onclick=\"document.MainForm.submit()\" value=\"documentType\"" . | |
| 51 | + (($sBrowseType=="documentType") ? " checked=\"checked\"" : "") . "/> " . _("Document Type") . "\n</span>"; | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // <category browse helper methods> |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Displays the passed category path as a link |
| 58 | - * | |
| 58 | + * | |
| 59 | 59 | * @param string the category name to display |
| 60 | 60 | */ |
| 61 | -function displayCategoryPathLink($aCategories) { | |
| 61 | +function displayCategoryPathLink($aCategories) { | |
| 62 | 62 | // if the first value in arr["categories"] == Categories then we've got a list of categories |
| 63 | 63 | if ($aCategories[0] == "Categories") { |
| 64 | 64 | return displayCategoryLink($aCategories[0]); |
| 65 | 65 | } else { |
| 66 | 66 | // else the first entry is the category name, so build a little path |
| 67 | 67 | return displayCategoryLink("Categories") . ($aCategories[0] ? " > " . displayCategoryLink($aCategories[0]) : ""); |
| 68 | - } | |
| 68 | + } | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * Displays the passed category as a link |
| 73 | - * | |
| 73 | + * | |
| 74 | 74 | * @param string the category name to display |
| 75 | 75 | */ |
| 76 | 76 | function displayCategoryLink($sCategoryName) { |
| 77 | 77 | if ($sCategoryName != "") { |
| 78 | 78 | return generateLink($_SERVER["PHP_SELF"], |
| 79 | - "fBrowseType=category" . | |
| 80 | - // if the category title is passed in, link back to the list of categories | |
| 81 | - (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), | |
| 82 | - $sCategoryName); | |
| 79 | + "fBrowseType=category" . | |
| 80 | + // if the category title is passed in, link back to the list of categories | |
| 81 | + (($sCategoryName == "Categories") ? "" : "&fCategoryName=" . urlencode($sCategoryName)), | |
| 82 | + $sCategoryName); | |
| 83 | 83 | } else { |
| 84 | 84 | return false; |
| 85 | 85 | } |
| ... | ... | @@ -90,16 +90,16 @@ function displayCategoryLink($sCategoryName) { |
| 90 | 90 | * |
| 91 | 91 | * @param array the category browse results |
| 92 | 92 | */ |
| 93 | -function renderCategoryResults($aResults) { | |
| 93 | +function renderCategoryResults($aResults) { | |
| 94 | 94 | $sToRender = ""; |
| 95 | - | |
| 95 | + | |
| 96 | 96 | //var_dump($aResults["categories"][0]); |
| 97 | - // if the first value in arr["categories"] == Categories then we've got a list of categories | |
| 97 | + // if the first value in arr["categories"] == Categories then we've got a list of categories | |
| 98 | 98 | if ($aResults["categories"][0] == "Categories") { |
| 99 | 99 | // loop through categories and display them |
| 100 | 100 | for ($i=1; $i<count($aResults["categories"]); $i++) { |
| 101 | 101 | $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; |
| 102 | - | |
| 102 | + | |
| 103 | 103 | // category name |
| 104 | 104 | $sToRender .= "<td>" . displayCategoryLink($aResults["categories"][$i]) . "</td>"; |
| 105 | 105 | // blank filename |
| ... | ... | @@ -109,17 +109,17 @@ function renderCategoryResults($aResults) { |
| 109 | 109 | // modified date |
| 110 | 110 | $sToRender .= "<td> </td>"; |
| 111 | 111 | // document type |
| 112 | - $sToRender .= "<td> </td>"; | |
| 112 | + $sToRender .= "<td> </td>"; | |
| 113 | 113 | |
| 114 | 114 | $sToRender .= "</tr>\n"; |
| 115 | 115 | } |
| 116 | 116 | } else { |
| 117 | - if (count($aResults["categories"]) > 0) { | |
| 118 | - // else the first entry is the category name, so display the documents in the category | |
| 119 | - $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); | |
| 120 | - } else { | |
| 121 | - $sToRender .= "<tr><td colspan=\"5\"><font color=\"red\">" . _("There is no Category Document Field- contact a System Administrator.") . "</font></td></tr>"; | |
| 122 | - } | |
| 117 | + if (count($aResults["categories"]) > 0) { | |
| 118 | + // else the first entry is the category name, so display the documents in the category | |
| 119 | + $sToRender .= renderDocumentList($aResults, _("This category contains no documents"), _("You don't have access to the documents in this category")); | |
| 120 | + } else { | |
| 121 | + $sToRender .= "<tr><td colspan=\"5\"><font color=\"red\">" . _("There is no Category Document Field- contact a System Administrator.") . "</font></td></tr>"; | |
| 122 | + } | |
| 123 | 123 | } |
| 124 | 124 | return $sToRender; |
| 125 | 125 | } |
| ... | ... | @@ -129,8 +129,8 @@ function renderCategoryResults($aResults) { |
| 129 | 129 | // <document type display helper methods> |
| 130 | 130 | /** |
| 131 | 131 | * Displays the passed document type path as a link |
| 132 | - * | |
| 133 | - * @param string the document type to display | |
| 132 | + * | |
| 133 | + * @param string the document type to display | |
| 134 | 134 | */ |
| 135 | 135 | function displayDocumentTypePathLink($aDocumentTypes) { |
| 136 | 136 | // if the first value in arr["categories"] == Categories then we've got a list of categories |
| ... | ... | @@ -144,15 +144,15 @@ function displayDocumentTypePathLink($aDocumentTypes) { |
| 144 | 144 | |
| 145 | 145 | /** |
| 146 | 146 | * Displays the passed document type as a link |
| 147 | - * | |
| 148 | - * @param string the document type to display | |
| 147 | + * | |
| 148 | + * @param string the document type to display | |
| 149 | 149 | */ |
| 150 | 150 | function displayDocumentTypeLink($aDocumentType) { |
| 151 | 151 | return generateLink($_SERVER["PHP_SELF"], |
| 152 | - "fBrowseType=documentType" . | |
| 153 | - // if the document type title is passed in, link back to the list of document types | |
| 154 | - (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), | |
| 155 | - $aDocumentType["name"]); | |
| 152 | + "fBrowseType=documentType" . | |
| 153 | + // if the document type title is passed in, link back to the list of document types | |
| 154 | + (($aDocumentType["name"] == "Document Types") ? "" : "&fDocumentTypeID=" . $aDocumentType["id"]), | |
| 155 | + $aDocumentType["name"]); | |
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
| ... | ... | @@ -162,12 +162,12 @@ function displayDocumentTypeLink($aDocumentType) { |
| 162 | 162 | */ |
| 163 | 163 | function renderDocumentTypeResults($aResults) { |
| 164 | 164 | $sToRender = ""; |
| 165 | - | |
| 165 | + | |
| 166 | 166 | // if the first value in arr["documentTypes"] == Document Types then we've got a list of document types |
| 167 | 167 | if ($aResults["documentTypes"][0]["name"] == "Document Types") { |
| 168 | 168 | // loop through document types and display them |
| 169 | 169 | for ($i=1; $i<count($aResults["documentTypes"]); $i++) { |
| 170 | - $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; | |
| 170 | + $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; | |
| 171 | 171 | // document type name |
| 172 | 172 | $sToRender .= "<td>" . displayDocumentTypeLink($aResults["documentTypes"][$i]) . "</td>"; |
| 173 | 173 | // blank filename |
| ... | ... | @@ -177,8 +177,8 @@ function renderDocumentTypeResults($aResults) { |
| 177 | 177 | // modified date |
| 178 | 178 | $sToRender .= "<td> </td>"; |
| 179 | 179 | // document type |
| 180 | - $sToRender .= "<td> </td>"; | |
| 181 | - $sToRender .= "</tr>\n"; | |
| 180 | + $sToRender .= "<td> </td>"; | |
| 181 | + $sToRender .= "</tr>\n"; | |
| 182 | 182 | } |
| 183 | 183 | } else { |
| 184 | 184 | // 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) { |
| 204 | 204 | for ($i=1; $i<count($aResults["folders"]); $i++) { |
| 205 | 205 | $sFolderLink = displayFolderLink($aResults["folders"][$i]); |
| 206 | 206 | $oCreator = User::get($aResults["folders"][$i]->getCreatorID()); |
| 207 | - | |
| 207 | + | |
| 208 | 208 | // the first element of the array contains the current folder name |
| 209 | - $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; | |
| 209 | + $sToRender .= "<tr bgcolor=\"" . getColour($i-1) . "\">"; | |
| 210 | 210 | // folder name |
| 211 | 211 | $sToRender .= "<td valign=\"bottom\">" . $sFolderLink . "</td>"; |
| 212 | 212 | // blank filename (folder description?) |
| ... | ... | @@ -216,18 +216,18 @@ function renderFolderResults($aResults, $bTemplateBrowsing = false) { |
| 216 | 216 | // modified date (TODO: add to db) |
| 217 | 217 | $sToRender .= "<td valign=\"bottom\"> </td>"; |
| 218 | 218 | // document type (??: display one of the mapped document types? which one?) |
| 219 | - $sToRender .= "<td valign=\"bottom\"> </td>"; | |
| 219 | + $sToRender .= "<td valign=\"bottom\"> </td>"; | |
| 220 | 220 | $sToRender .= "</tr>\n"; |
| 221 | 221 | } |
| 222 | 222 | } else { |
| 223 | 223 | $sToRender .= "<tr><td colspan=\"5\">" . _("This folder contains no sub folders") . "</td></tr>"; |
| 224 | 224 | } |
| 225 | - | |
| 226 | - $sToRender .= "<tr><td>" . renderDocumentList($aResults, _("This folder contains no documents"), | |
| 227 | - _("You don't have access to the documents in this folder"), | |
| 228 | - false, $bTemplateBrowsing) . | |
| 229 | - "</td></tr>\n"; | |
| 230 | - | |
| 225 | + | |
| 226 | + $sToRender .= "<tr><td>" . renderDocumentList($aResults, _("This folder contains no documents"), | |
| 227 | + _("You don't have access to the documents in this folder"), | |
| 228 | + false, $bTemplateBrowsing) . | |
| 229 | + "</td></tr>\n"; | |
| 230 | + | |
| 231 | 231 | return $sToRender; |
| 232 | 232 | } |
| 233 | 233 | // </folder browse helper methods> |
| ... | ... | @@ -240,36 +240,36 @@ function renderFolderResults($aResults, $bTemplateBrowsing = false) { |
| 240 | 240 | * @param string the direction currently sorted in |
| 241 | 241 | */ |
| 242 | 242 | function renderSortHeadings($sSortBy, $sSortDirection) { |
| 243 | - global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; | |
| 244 | - | |
| 245 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 246 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 247 | - | |
| 248 | - // need list of display criteria and sort name | |
| 249 | - $aSortCriteria = $oBrowser->getSortCriteria(); | |
| 250 | - | |
| 243 | + global $default, $oBrowser, $fBrowseType, $fFolderID, $fCategoryName, $fDocumentTypeID; | |
| 244 | + | |
| 245 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 246 | + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 247 | + | |
| 248 | + // need list of display criteria and sort name | |
| 249 | + $aSortCriteria = $oBrowser->getSortCriteria(); | |
| 250 | + | |
| 251 | 251 | $sToRender .= "<tr bgcolor=\"$sTDBGColour\">"; |
| 252 | - while (list($key, $value) = each ($aSortCriteria)) { | |
| 253 | - $sCurrentSortDirection = "asc"; | |
| 254 | - $displayText = $value["display"]; | |
| 255 | - // if the current heading is being sorted then flip the sort direction | |
| 256 | - if ($sSortBy == $key) { | |
| 257 | - $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); | |
| 258 | - $displayText = "<img border=\"0\" src=\"" . imgSrc($sCurrentSortDirection . ".gif") . "\">" . $displayText; | |
| 259 | - } | |
| 260 | - switch ($fBrowseType) { | |
| 261 | - case "folder" : | |
| 262 | - $queryString = "fFolderID=$fFolderID"; | |
| 263 | - break; | |
| 264 | - case "category" : | |
| 265 | - $queryString = "fCategoryName=$fCategoryName"; | |
| 266 | - break; | |
| 267 | - case "documentType" : | |
| 268 | - $queryString = "fDocumentTypeID=$fDocumentTypeID"; | |
| 269 | - break; | |
| 270 | - } | |
| 271 | - $sToRender .= "<td>" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . "</td>"; | |
| 272 | - } | |
| 252 | + while (list($key, $value) = each ($aSortCriteria)) { | |
| 253 | + $sCurrentSortDirection = "asc"; | |
| 254 | + $displayText = $value["display"]; | |
| 255 | + // if the current heading is being sorted then flip the sort direction | |
| 256 | + if ($sSortBy == $key) { | |
| 257 | + $sCurrentSortDirection = ($sSortDirection == "asc" ? "desc" : "asc"); | |
| 258 | + $displayText = "<img border=\"0\" src=\"" . imgSrc($sCurrentSortDirection . ".gif") . "\">" . $displayText; | |
| 259 | + } | |
| 260 | + switch ($fBrowseType) { | |
| 261 | + case "folder" : | |
| 262 | + $queryString = "fFolderID=$fFolderID"; | |
| 263 | + break; | |
| 264 | + case "category" : | |
| 265 | + $queryString = "fCategoryName=$fCategoryName"; | |
| 266 | + break; | |
| 267 | + case "documentType" : | |
| 268 | + $queryString = "fDocumentTypeID=$fDocumentTypeID"; | |
| 269 | + break; | |
| 270 | + } | |
| 271 | + $sToRender .= "<td>" . generateLink($_SERVER["PHP_SELF"], "fBrowseType=$fBrowseType&$queryString&fSortBy=$key&fSortDirection=$sCurrentSortDirection", $displayText) . "</td>"; | |
| 272 | + } | |
| 273 | 273 | |
| 274 | 274 | $sToRender .= "</tr>\n"; |
| 275 | 275 | return $sToRender; |
| ... | ... | @@ -284,19 +284,19 @@ function renderSortHeadings($sSortBy, $sSortDirection) { |
| 284 | 284 | * @param boolean whether to display the complete path to the document or not |
| 285 | 285 | */ |
| 286 | 286 | function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessage, $bDisplayFullPath = false, $bTemplateBrowsing = false) { |
| 287 | - global $default; | |
| 287 | + global $default; | |
| 288 | 288 | |
| 289 | - $iFolderCount = count($aResults["folders"]) - 1; | |
| 289 | + $iFolderCount = count($aResults["folders"]) - 1; | |
| 290 | 290 | // loop through the files and display links |
| 291 | 291 | if (count($aResults["documents"]) > 0) { |
| 292 | 292 | for ($i=0; $i<count($aResults["documents"]); $i++) { |
| 293 | - // in order for candy striping to work we need to take the number of folders | |
| 294 | - // into account when alternating | |
| 295 | - $sToRender .= "<tr bgcolor=\"" . getColour($i+$iFolderCount) . "\" width=\"100%\"><td valign=\"bottom\">" . | |
| 296 | - "<input type=\"checkbox\" name=\"fDocumentIDs[]\" value=\"" . $aResults["documents"][$i]->getID() . "\"/>" . | |
| 297 | - ($bTemplateBrowsing ? displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) : | |
| 298 | - displayDocumentLink($aResults["documents"][$i], $bDisplayFullPath)) . "</td>"; | |
| 299 | - | |
| 293 | + // in order for candy striping to work we need to take the number of folders | |
| 294 | + // into account when alternating | |
| 295 | + $sToRender .= "<tr bgcolor=\"" . getColour($i+$iFolderCount) . "\" width=\"100%\"><td valign=\"bottom\">" . | |
| 296 | + "<input type=\"checkbox\" name=\"fDocumentIDs[]\" value=\"" . $aResults["documents"][$i]->getID() . "\"/>" . | |
| 297 | + ($bTemplateBrowsing ? displayDocumentLinkForTemplateBrowsing($aResults["documents"][$i], $bDisplayFullPath) : | |
| 298 | + displayDocumentLink($aResults["documents"][$i], $bDisplayFullPath)) . "</td>"; | |
| 299 | + | |
| 300 | 300 | // #3425 the title is now the filename, and the description is the title |
| 301 | 301 | $sToRender .= "<td valign=\"bottom\">" . $aResults["documents"][$i]->getName() . "</td>"; |
| 302 | 302 | $oCreator = User::get($aResults["documents"][$i]->getCreatorID()); |
| ... | ... | @@ -305,24 +305,24 @@ function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessa |
| 305 | 305 | $sToRender .= "<td valign=\"bottom\">" . $aDocumentTransaction[0]->dDateTime . "</td>"; |
| 306 | 306 | $oDocumentType = DocumentType::get($aResults["documents"][$i]->getDocumentTypeID()); |
| 307 | 307 | if ($oDocumentType) { |
| 308 | - $sToRender .= "<td valign=\"bottom\">" . $oDocumentType->getName() . "</td>"; | |
| 308 | + $sToRender .= "<td valign=\"bottom\">" . $oDocumentType->getName() . "</td>"; | |
| 309 | 309 | } |
| 310 | 310 | $sToRender .= "</tr>\n"; |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 314 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 313 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 314 | + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 315 | 315 | |
| 316 | - $sToRender .= "<tr bgcolor=\"". $sTDBGColour . "\"><td colspan=\"5\" valign=\"bottom\">" . | |
| 317 | - "<input type=\"checkbox\" name=\"selectall\" onClick=\"selectAll()\"/> " . _("Select all documents") . "</td></tr>"; | |
| 316 | + $sToRender .= "<tr bgcolor=\"". $sTDBGColour . "\"><td colspan=\"5\" valign=\"bottom\">" . | |
| 317 | + "<input type=\"checkbox\" name=\"selectall\" onClick=\"selectAll()\"/> " . _("Select all documents") . "</td></tr>"; | |
| 318 | 318 | |
| 319 | - $sToRender .= "<tr><td colspan=\"5\" >"; | |
| 320 | - $sToRender .= "<input type=\"hidden\" name=\"fActions\">"; | |
| 319 | + $sToRender .= "<tr><td colspan=\"5\" >"; | |
| 320 | + $sToRender .= "<input type=\"hidden\" name=\"fActions\">"; | |
| 321 | 321 | |
| 322 | - $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='move'; document.MainForm.submit()\" src=\"" . KTHtml::getMoveButton() . "\" border=\"0\"/>"; | |
| 323 | - $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='delete'; document.MainForm.submit()\" src=\"" . KTHtml::getDeleteButton() . "\" border=\"0\"/>"; | |
| 324 | - $sToRender .= "</td></tr>\n"; | |
| 325 | - // Change for group Operations | |
| 322 | + $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='move'; document.MainForm.submit()\" src=\"" . KTHtml::getMoveButton() . "\" border=\"0\"/>"; | |
| 323 | + $sToRender .= "<input type=\"image\" onclick=\"document.MainForm.fActions.value='delete'; document.MainForm.submit()\" src=\"" . KTHtml::getDeleteButton() . "\" border=\"0\"/>"; | |
| 324 | + $sToRender .= "</td></tr>\n"; | |
| 325 | + // Change for group Operations | |
| 326 | 326 | |
| 327 | 327 | |
| 328 | 328 | } else if ($aResults["accessDenied"]) { |
| ... | ... | @@ -338,11 +338,11 @@ function renderDocumentList($aResults, $sNoDocumentsMessage, $sNoPermissionMessa |
| 338 | 338 | * Appends folder and document counts to the last folder path |
| 339 | 339 | */ |
| 340 | 340 | function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { |
| 341 | - // append to the last path component and return | |
| 342 | - $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . | |
| 343 | - " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . | |
| 344 | - ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; | |
| 345 | - return $aFolderPath; | |
| 341 | + // append to the last path component and return | |
| 342 | + $aFolderPath[count($aFolderPath)-1] = $aFolderPath[count($aFolderPath)-1] . | |
| 343 | + " ($iFolderCount folder" . (($iFolderCount > 1) || ($iFolderCount == 0) ? "s" : "") . | |
| 344 | + ", $iDocumentCount document" . (($iDocumentCount > 1) || ($iDocumentCount == 0) ? "s" : "") . ")"; | |
| 345 | + return $aFolderPath; | |
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
| ... | ... | @@ -356,12 +356,12 @@ function appendCounts($aFolderPath, $iFolderCount, $iDocumentCount) { |
| 356 | 356 | |
| 357 | 357 | function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection, $bTemplateBrowsing = false) { |
| 358 | 358 | global $default; |
| 359 | - | |
| 360 | - $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 361 | - $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 359 | + | |
| 360 | + $sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"]))); | |
| 361 | + $sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td"); | |
| 362 | 362 | |
| 363 | 363 | $sToRender = renderHeading(_("Browse collection")); |
| 364 | - | |
| 364 | + | |
| 365 | 365 | // Script function to select all documents |
| 366 | 366 | $sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n "; |
| 367 | 367 | $sToRender .= "<!--\n"; |
| ... | ... | @@ -377,34 +377,46 @@ function renderPage($aResults, $sBrowseType, $sSortBy, $sSortDirection, $bTempla |
| 377 | 377 | $sToRender .= "//-->\n"; |
| 378 | 378 | $sToRender .= "</SCRIPT>\n\n"; |
| 379 | 379 | |
| 380 | - $sToRender .= "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td bgcolor=\"$sTDBGColour\">"; | |
| 380 | + $sToRender .= "<table border=\"0\" cellpadding=\"5\" width=\"100%\"><tr><td bgcolor=\"$sTDBGColour\">"; | |
| 381 | 381 | switch ($sBrowseType) { |
| 382 | - case "folder" : $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), | |
| 383 | - appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), | |
| 384 | - count($aResults["folders"])-1, | |
| 385 | - count($aResults["documents"]))); break; | |
| 386 | - case "category" : $sToRender .= displayCategoryPathLink($aResults["categories"]); break; | |
| 387 | - case "documentType" : $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); break; | |
| 382 | + case "folder": | |
| 383 | + $sToRender .= displayFolderPathLink(Folder::getFolderPathAsArray($aResults["folders"][0]->getID()), | |
| 384 | + appendCounts(Folder::getFolderPathNamesAsArray($aResults["folders"][0]->getID()), | |
| 385 | + count($aResults["folders"])-1, count($aResults["documents"]))); | |
| 386 | + break; | |
| 387 | + case "category": | |
| 388 | + $sToRender .= displayCategoryPathLink($aResults["categories"]); | |
| 389 | + break; | |
| 390 | + case "documentType": | |
| 391 | + $sToRender .= displayDocumentTypePathLink($aResults["documentTypes"]); | |
| 392 | + break; | |
| 388 | 393 | } |
| 389 | 394 | $sToRender .= "</td></tr></table>\n"; |
| 390 | - | |
| 391 | - // browse type select | |
| 392 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 395 | + | |
| 396 | + // browse type select | |
| 397 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 393 | 398 | $sToRender .= "\t<tr><td bgcolor=\"$sTDBGColour\">" . renderBrowseTypeSelect($sBrowseType) . "</td></tr>"; |
| 394 | 399 | $sToRender .= "\t</table>"; |
| 395 | - | |
| 400 | + | |
| 396 | 401 | // display folders|documents |
| 397 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 398 | - $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); | |
| 399 | - $sToRender .= "<tr><td>\n"; | |
| 402 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 403 | + $sToRender .= renderSortHeadings($sSortBy, $sSortDirection); | |
| 404 | + $sToRender .= "<tr><td>\n"; | |
| 400 | 405 | switch ($sBrowseType) { |
| 401 | - case "folder" : $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); break; | |
| 402 | - case "category" : $sToRender .= renderCategoryResults($aResults); break; | |
| 403 | - case "documentType" : $sToRender .= renderDocumentTypeResults($aResults); break; | |
| 406 | + case "folder": | |
| 407 | + $sToRender .= renderFolderResults($aResults, $bTemplateBrowsing); | |
| 408 | + break; | |
| 409 | + case "category": | |
| 410 | + $sToRender .= renderCategoryResults($aResults); | |
| 411 | + break; | |
| 412 | + case "documentType": | |
| 413 | + $sToRender .= renderDocumentTypeResults($aResults); | |
| 414 | + break; | |
| 404 | 415 | } |
| 405 | 416 | $sToRender .= "</tr></td>\n"; |
| 406 | 417 | $sToRender .= "\t</table>"; |
| 407 | - | |
| 418 | + | |
| 408 | 419 | return $sToRender; |
| 409 | 420 | } |
| 421 | + | |
| 410 | 422 | ?> | ... | ... |