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