Commit 4c6c3d9b7e54c93210fad5460b529bb1f5161c55
1 parent
4dca22aa
moved browseBL to appropriate directory
initial revision of supporting UI functions git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@484 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
268 additions
and
0 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseBL.php
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +// main library routines and defaults | |
| 4 | +require_once("../../config/dmsDefaults.php"); | |
| 5 | +require_once("$default->owl_ui_directory/documentmanagement/browseUI.inc"); | |
| 6 | +require_once("$default->owl_fs_root/lib/documentmanagement/DocumentBrowser.inc"); | |
| 7 | + | |
| 8 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternMainPage.inc"); | |
| 9 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternImage.inc"); | |
| 10 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternTableLinks.inc"); | |
| 11 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternTableSqlQuery.inc"); | |
| 12 | +require_once("$default->owl_fs_root/lib/visualpatterns/PatternCustom.inc"); | |
| 13 | +require_once("$default->owl_fs_root/lib/visualpatterns/NavBar.inc"); | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * $Id$ | |
| 17 | + * | |
| 18 | + * This page controls browsing for documents- this can be done either by | |
| 19 | + * folder, category or document type. | |
| 20 | + * The relevant permission checking is performed, calls to the business logic | |
| 21 | + * layer to retrieve the details of the documents to view are made and the user | |
| 22 | + * interface is contructed. | |
| 23 | + * | |
| 24 | + * Licensed under the GNU GPL. For full terms see the file COPYING. | |
| 25 | + * | |
| 26 | + * @version $Revision$ | |
| 27 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 28 | + * @package presentation | |
| 29 | + */ | |
| 30 | + | |
| 31 | +/* | |
| 32 | + * Querystring variables | |
| 33 | + * --------------------- | |
| 34 | + * fBrowseType - determines whether to browse by (folder, category, documentType) [mandatory] | |
| 35 | + * fFolderID - the folder to browse [optional depending on fBrowseType] | |
| 36 | + * fCategoryName - the category to browse [optional depending on fBrowseType] | |
| 37 | + * fDocumentTypeID - the document type id to browse [optional depending on fBrowseType] | |
| 38 | + * fSortBy - the document/folder criteria to sort the browse results by | |
| 39 | + * fSortDirection - the direction that the sort should happen in (asc|desc) | |
| 40 | + */ | |
| 41 | + | |
| 42 | +// ------------------------------- | |
| 43 | +// page start | |
| 44 | +// ------------------------------- | |
| 45 | + | |
| 46 | +// only if we have a valid session | |
| 47 | +if (checkSession()) { | |
| 48 | + require_once("../webpageTemplate.inc"); | |
| 49 | + $oContent = new PatternCustom(); | |
| 50 | + | |
| 51 | + // retrieve variables | |
| 52 | + if (!$fBrowseType) { | |
| 53 | + // required param not set- internal error or user querystring hacking | |
| 54 | + // set it to default= folder | |
| 55 | + $fBrowseType = "folder"; | |
| 56 | + } | |
| 57 | + | |
| 58 | + // fire up the document browser | |
| 59 | + $oDocBrowser = new DocumentBrowser(); | |
| 60 | + | |
| 61 | + $oContent = new PatternCustom(); | |
| 62 | + | |
| 63 | + $oContent->addHtml( | |
| 64 | + startTable("0", "100%") . | |
| 65 | + // pending documents | |
| 66 | + startTableRowCell() . | |
| 67 | + startTable("0", "100%") . | |
| 68 | + tableRow("left", "", tableData(browseTypeSelect($fBrowseType)))); | |
| 69 | + | |
| 70 | + // instantiate data arrays | |
| 71 | + $folders = NULL; | |
| 72 | + $categories = NULL; | |
| 73 | + $documentTypes = NULL; | |
| 74 | + | |
| 75 | + switch ($fBrowseType) { | |
| 76 | + case "folder" : // retrieve folderID if present | |
| 77 | + if (!$fFolderID) { | |
| 78 | + $results = $oDocBrowser->browseByFolder(); | |
| 79 | + } else { | |
| 80 | + $results = $oDocBrowser->browseByFolder($fFolderID); | |
| 81 | + } | |
| 82 | + if ($results) { | |
| 83 | + $default->log->debug("browseBL.php: retrieved results from folder browse=" . arrayToString($results)); | |
| 84 | + $folderID = $results["folders"][0]->getID(); | |
| 85 | + | |
| 86 | + // the first folder in the list is the folder we're in so display the path to this folder | |
| 87 | + // as the heading | |
| 88 | + $oContent->addHtml(tableRow("", "", tableData(displayFolderPathLink(Folder::getFolderPathAsArray($results["folders"][0]->getID()))))); | |
| 89 | + | |
| 90 | + // empty row for spacing | |
| 91 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 92 | + | |
| 93 | + // now loop through the rest of the folders and display links | |
| 94 | + for ($i=1; $i<count($results["folders"]); $i++) { | |
| 95 | + $sRow = displayFolderLink($results["folders"][$i]); | |
| 96 | + $oContent->addHtml(tableRow("", "", tableData($sRow))); | |
| 97 | + } | |
| 98 | + | |
| 99 | + // loop through the files and display links | |
| 100 | + for ($i=0; $i<count($results["documents"]); $i++) { | |
| 101 | + $sDocumentLink = displayDocumentLink($results["documents"][$i]); | |
| 102 | + $oContent->addHtml(tableRow("", "", tableData($sDocumentLink))); | |
| 103 | + } | |
| 104 | + } else { | |
| 105 | + // empty row for spacing | |
| 106 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 107 | + $oContent->addHtml(tablerow("", "", tableData($_SESSION["errorMessage"]))); | |
| 108 | + } | |
| 109 | + | |
| 110 | + break; | |
| 111 | + | |
| 112 | + case "category" : | |
| 113 | + if (!$fCategoryName) { | |
| 114 | + $results = $oDocBrowser->browseByCategory(); | |
| 115 | + | |
| 116 | + // we have a list of categories | |
| 117 | + // so loop through them and display | |
| 118 | + $oContent->addHtml(tableRow("", "", tableData("Categories"))); | |
| 119 | + | |
| 120 | + // empty row for spacing | |
| 121 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 122 | + | |
| 123 | + for ($i=0; $i<count($results["categories"]); $i++) { | |
| 124 | + $oContent->addHtml(tableRow("", "", tableData(displayCategoryLink($results["categories"][$i])))); | |
| 125 | + } | |
| 126 | + | |
| 127 | + } else { | |
| 128 | + $results = $oDocBrowser->browseByCategory($fCategoryName); | |
| 129 | + // display category heading | |
| 130 | + $oContent->addHtml(tableRow("", "", tableData(displayCategoryPathLink($results["categories"][0])))); | |
| 131 | + | |
| 132 | + // empty row for spacing | |
| 133 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 134 | + | |
| 135 | + // now loop through the documents in the category (TODO: if any) | |
| 136 | + // and display them (TODO: with hyperlinked paths) | |
| 137 | + for ($i=0; $i<count($results["documents"]); $i++) { | |
| 138 | + $sDocumentLink = displayDocumentLink($results["documents"][$i]); | |
| 139 | + $oContent->addHtml(tableRow("", "", tableData($sDocumentLink))); | |
| 140 | + } | |
| 141 | + } | |
| 142 | + | |
| 143 | + break; | |
| 144 | + | |
| 145 | + case "documentType" : | |
| 146 | + if (!$fDocumentTypeID) { | |
| 147 | + $results = $oDocBrowser->browseByDocumentType(); | |
| 148 | + | |
| 149 | + // we have a list of document types | |
| 150 | + // so loop through them and display | |
| 151 | + $oContent->addHtml(tableRow("", "", tableData("Document Types"))); | |
| 152 | + | |
| 153 | + // empty row for spacing | |
| 154 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 155 | + | |
| 156 | + for ($i=0; $i<count($results["documentTypes"]); $i++) { | |
| 157 | + $oContent->addHtml(tableRow("", "", tableData(displayDocumentTypeLink($results["documentTypes"][$i])))); | |
| 158 | + } | |
| 159 | + | |
| 160 | + } else { | |
| 161 | + $results = $oDocBrowser->browseByDocumentType($fDocumentTypeID); | |
| 162 | + // display document type heading | |
| 163 | + $oContent->addHtml(tableRow("", "", tableData(displayDocumentTypePathLink($results["documentTypes"][0])))); | |
| 164 | + | |
| 165 | + // empty row for spacing | |
| 166 | + $oContent->addHtml(tableRow("", "", tableData(" "))); | |
| 167 | + | |
| 168 | + // now loop through the documents in the category (TODO: if any) | |
| 169 | + // and display them (TODO: with hyperlinked paths) | |
| 170 | + for ($i=0; $i<count($results["documents"]); $i++) { | |
| 171 | + $sDocumentLink = displayDocumentLink($results["documents"][$i]); | |
| 172 | + $oContent->addHtml(tableRow("", "", tableData($sDocumentLink))); | |
| 173 | + } | |
| 174 | + } | |
| 175 | + break; | |
| 176 | + } | |
| 177 | + | |
| 178 | + $oContent->addHtml( | |
| 179 | + stopTable() . | |
| 180 | + endTableRowCell() . | |
| 181 | + stopTable()); | |
| 182 | + | |
| 183 | + $main->setCentralPayload($oContent); | |
| 184 | + | |
| 185 | + $main->render(); | |
| 186 | + | |
| 187 | +} else { | |
| 188 | + // redirect to no permission page | |
| 189 | + redirect("$default->owl_ui_url/noAccess.php"); | |
| 190 | +} | |
| 191 | +?> | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/browseUI.inc
0 → 100644
| 1 | +<?php | |
| 2 | + | |
| 3 | +require_once("$default->owl_fs_root/presentation/Html.inc"); | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * $Id$ | |
| 7 | + * | |
| 8 | + * Document browsing page html UI building functions. | |
| 9 | + * | |
| 10 | + * Licensed under the GNU GPL. For full terms see the file COPYING. | |
| 11 | + * | |
| 12 | + * @version $Revision$ | |
| 13 | + * @author Michael Joseph <michael@jamwarehouse.com>, Jam Warehouse (Pty) Ltd, South Africa | |
| 14 | + * @package presentation.documentmanagement | |
| 15 | + */ | |
| 16 | + | |
| 17 | +function browseTypeSelect($sBrowseType) { | |
| 18 | + return "View documents by: <input type=\"radio\" name=\"fBrowseType\" value=\"folder\"" . | |
| 19 | + ((($sBrowseType=="folder") || (strlen($sBrowseType)==0)) ? "checked" : "") . "> Folders" . | |
| 20 | + "<input type=\"radio\" name=\"fBrowseType\" value=\"category\"" . | |
| 21 | + (($sBrowseType=="category") ? "checked" : "") . "> Category" . | |
| 22 | + "<input type=\"radio\" name=\"fBrowseType\" value=\"documentType\"" . | |
| 23 | + (($sBrowseType=="documentType") ? "checked" : "") . "> Document Type"; | |
| 24 | +} | |
| 25 | + | |
| 26 | +function displayFolderPathLink($aPathArray) { | |
| 27 | + // display a separate link to each folder in the path | |
| 28 | + for ($i=0; $i<count($aPathArray); $i++) { | |
| 29 | + // retrieve the folder id for this folder name | |
| 30 | + $iFolderID = Folder::getFolderID($aPathArray[$i]); | |
| 31 | + // generate a link back to this page setting fFolderID | |
| 32 | + $sLink = generateLink("/presentation/documentmanagement/browseBL.php", | |
| 33 | + "fBrowseType=folder&fFolderID=$iFolderID", | |
| 34 | + $aPathArray[$i]); | |
| 35 | + $sPathLinks = (strlen($sPathLinks) > 0) ? $sPathLinks . " > " . $sLink : $sLink; | |
| 36 | + } | |
| 37 | + return $sPathLinks; | |
| 38 | +} | |
| 39 | + | |
| 40 | +function displayFolderLink($oFolder) { | |
| 41 | + return generateLink("/presentation/documentmanagement/browseBL.php", | |
| 42 | + "fBrowseType=folder&fFolderID=" . $oFolder->getID(), | |
| 43 | + // TODO: display folder icon | |
| 44 | + $oFolder->getName()); | |
| 45 | +} | |
| 46 | + | |
| 47 | +function displayCategoryPathLink($sCategoryName) { | |
| 48 | + return "Categories > " . displayCategoryLink($sCategoryName); | |
| 49 | +} | |
| 50 | + | |
| 51 | +function displayCategoryLink($sCategoryName) { | |
| 52 | + return generateLink("/presentation/documentmanagement/browseBL.php", | |
| 53 | + "fBrowseType=category&fCategoryName=$sCategoryName", | |
| 54 | + $sCategoryName); | |
| 55 | +} | |
| 56 | + | |
| 57 | +function displayDocumentTypeLink($aDocumentType) { | |
| 58 | + return generateLink("/presentation/documentmanagement/browseBL.php", | |
| 59 | + "fBrowseType=documentType&fDocumentTypeID=" . $aDocumentType["id"], | |
| 60 | + $aDocumentType["name"]); | |
| 61 | +} | |
| 62 | + | |
| 63 | +function displayDocumentTypePathLink($aDocumentType) { | |
| 64 | + return "Document Types > " . displayDocumentTypeLink($aDocumentType); | |
| 65 | +} | |
| 66 | + | |
| 67 | +function displayDocumentLink($oDocument) {//, $bDisplayFullPath) { | |
| 68 | + global $default; | |
| 69 | + $sIconPath = generateImage($oDocument->getMimeTypeIconUrl()); | |
| 70 | + return generateLink("/presentation/documentmanagement/documentViewBL.php", | |
| 71 | + "fDocumentID=" . $oDocument->getID(), | |
| 72 | + // TODO: display file type icon | |
| 73 | + ($sIconPath ? $sIconPath : "") . | |
| 74 | + //($bDisplayFullPath ? Document::getDocumentPathAsArray($oDocument->getID()) : $oDocument->getName()); | |
| 75 | + $oDocument->getName()); | |
| 76 | +} | |
| 77 | +?> | ... | ... |