NavBar.inc
10.2 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc");
global $default;
/**
* Contains all the functions to create the navbar...
*
* @author Mukhtar Dharsey
* @date 22 January 2003
*/
class NavBar {
//variable used to pass highlighting
var $home;
var $mdocs;
var $subscriptions;
var $asearch;
var $admin;
var $prefs;
var $help;
var $logout;
var $nwColourbar;
var $sSection;
/** variables used for searching */
var $sBrowseType;
var $iFolderID;
var $iDocumentID;
var $sCategoryName;
var $iDocTypeID;
function NavBar($sTmpBrowseType, $iTmpFolderID, $iTmpDocumentID, $sTmpCategoryName, $iTmpDocTypeID) {
global $default;
$this->sBrowseType = $iTmpBrowseType;
$this->iFolderID = $iTmpFolderID;
$this->iDocumentID = $iTmpDocumentID;
$this->sCategoryName = $sTmpCategoryName;
$this->iDocTypeID = $iTmpDocTypeID;
$this->mdocs = "$default->graphicsUrl/mdocs/norm.gif";
$this->home = "$default->graphicsUrl/home/norm.gif";
$this->subscriptions = "$default->graphicsUrl/subscriptions/norm.gif";
$this->asearch = "$default->graphicsUrl/asearch/norm.gif";
$this->admin = "$default->graphicsUrl/admin/norm.gif";
$this->prefs = "$default->graphicsUrl/prefs/norm.gif";
$this->help = "$default->graphicsUrl/help/norm.gif";
$this->logout = "$default->graphicsUrl/logout/norm.gif";
}
/**
* gets the url for the colour bar
*
* @param The section that needs to be highlighted
*/
function getNWColourbar() {
return $this->nwColourBar;
}
/**
* sets a highlighted section varaibles
*
* @param The section that needs to be highlighted
*/
function setHighlightedSection($section) {
global $default;
$this->sSection = $section;
// check for highlighting..and highlight as required
if($section == "General") {
$this->home = "$default->graphicsUrl/home/over.gif";
$this->nwColourBar = "$default->graphicsUrl/home/def.gif";
}
if(($section == "Manage Documents") || ($section == "Manage Categories") || ($section == "Manage Document Types")) {
$this->mdocs = "$default->graphicsUrl/mdocs/over.gif";
$this->nwColourBar = "$default->graphicsUrl/mdocs/def.gif";
}
if($section == "Discussion Threads" ) {
$this->mdocs = "$default->graphicsUrl/mdocs/over.gif";
$this->nwColourBar = "$default->graphicsUrl/mdocs/def.gif";
}
if($section == "Subscriptions") {
$this->subscriptions = "$default->graphicsUrl/subscriptions/over.gif";
$this->nwColourBar = "$default->graphicsUrl/subscriptions/def.gif";
}
if(($section == "Standard Search") || ($section == "Advanced Search")) {
$this->asearch = "$default->graphicsUrl/asearch/over.gif";
$this->nwColourBar = "$default->graphicsUrl/asearch/def.gif";
}
if(substr($section, -14) == "Administration") {
$this->admin = "$default->graphicsUrl/admin/over.gif";
$this->nwColourBar = "$default->graphicsUrl/admin/def.gif";
}
if($section == "Preferences") {
$this->prefs = "$default->graphicsUrl/prefs/over.gif";
$this->nwColourBar = "$default->graphicsUrl/prefs/def.gif";
}
if($section == "Help") {
$this->help = "$default->graphicsUrl/help/over.gif";
$this->nwColourBar = "$default->graphicsUrl/help/def.gif";
}
if($section == "Logout") {
$this->logout = "$default->graphicsUrl/logout/over.gif";
$this->nwColourBar = "$default->graphicsUrl/logout/def.gif";
}
}
/**
* this function creates the navbar for a specific page...
*/
function render() {
global $default;
//set up headings for row 1 and 2
$heading = "$default->graphicsUrl/heading.gif";
$hStretched = "$default->graphicsUrl/hrepeat.gif";
// set colour pics for row 4 of navbar
$colourHome = "$default->graphicsUrl/home/colour.gif";
$colourmdocs = "$default->graphicsUrl/mdocs/colour.gif";
$coloursubscriptions = "$default->graphicsUrl/subscriptions/colour.gif";
$colourasearch = "$default->graphicsUrl/asearch/colour.gif";
$colouradmin = "$default->graphicsUrl/admin/colour.gif";
$colourprefs = "$default->graphicsUrl/prefs/colour.gif";
$colourhelp = "$default->graphicsUrl/help/colour.gif";
$colourlogout = "$default->graphicsUrl/logout/colour.gif";
// get list of sections
$aTopMenuLinks = array(generateControllerUrl("dashboard"),
generateControllerUrl($default->siteMap->getDefaultAction("Manage Documents")),
generateControllerUrl($default->siteMap->getDefaultAction("Subscriptions")),
generateControllerUrl($default->siteMap->getDefaultAction("Advanced Search")),
generateControllerUrl($default->siteMap->getDefaultAction("Administration")),
generateControllerUrl($default->siteMap->getDefaultAction("Preferences")),
"help",
generateControllerUrl($default->siteMap->getDefaultAction("Logout")));
// create array of images for navbar sections
$aTopMenuImages = array($this->home,
$this->mdocs,
$this->subscriptions,
$this->asearch,
$this->admin,
$this->prefs,
$this->help,
$this->logout);
// create array of menu colour images
$aColourMenuImages = array($colourHome,$colourmdocs,$coloursubscriptions,$colourasearch,$colouradmin,$colourprefs,$colourhelp,$colourlogout);
//set up the links
for ($i = 0; $i < count($aTopMenuLinks); $i++) {
if (strcmp($aTopMenuLinks[$i], "help") == 0) {
$sTopMenu .= "<td width=\"10\"><a href=\"#\" onClick=\"javascript:helpWindow();\"><image src=\"" . $aTopMenuImages[$i] . "\" border=\"0\" /></a></td>\n";
$sColourMenu .= "<td width=\"10\"><a href=\"#\" onClick=\"javascript:helpWindow();\"><image src=\"" . $aColourMenuImages[$i] . "\" border=\"0\" /></a></td>\n";
} else {
$sTopMenu .= "<td width=\"10\">" . (strlen($aTopMenuLinks[$i]) > 0 ? "<a href=\"" . $aTopMenuLinks[$i] . "\">" : "") . "<img src=\"" . $aTopMenuImages[$i] . "\" border=\"0\" /></a></td>\n";
$sColourMenu .= "<td width=\"10\">" . (strlen($aTopMenuLinks[$i]) > 0 ? "<a href=\"" . $aTopMenuLinks[$i] . "\">" : "") . "<img src=\"" . $aColourMenuImages[$i] . "\" border=\"0\"/></a></td>\n";
}
}
$toRender = new PatternCustom;
// build the nav bar
$bar = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n";
$bar .= "\t<tr height=\"30\">\n";
$bar .= "\t\t<td align=\"right\" valign=\"top\" width=\"100%\"><img src=\"$heading\"/><img src=\"$default->graphicsUrl/logo.jpg\"/></td>\n";
$bar .= "\t</tr>\n";
$bar .= "\t<tr height=\"30\">\n";
$bar .= "\t\t<td colspan=\"2\" bgcolor=\"#1A4383\" width=\"100%\" nowrap>";
$bar .= "<img align=\"absmiddle\" src=\"$default->graphicsUrl/arrow.gif\" ></img>\n";
$bar .= "<INPUT type=\"hidden\" name=\"fForStandardSearch\" value=\"no\" />\n ";
//disable the search bar if we are browsing search results
if ((strcmp($this->sSection,"Standard Search") == 0) || (strcmp($this->sSection,"Advanced Search") == 0)) {
$bar .= "<INPUT type=\"hidden\" name=\"fSearchText\"/>\n ";
} else {
$bar .= "<INPUT type=\"text\" name=\"fStandardSearchString\" width=\"30\" height = \"10\" align = \"absmiddle\" />\n";
(isset($this->iFolderID) ? $bar .= "<INPUT type=\"hidden\" name=\"fFolderID\" value=\"" . $this->iFolderID . "\" />\n " : $bar .= "");
(isset($this->iDocumentID) ? $bar .= "<INPUT type=\"hidden\" name=\"fDocumentID\" value=\"" . $this->iDocumentID . "\" />\n " : $bar .= "");
(isset($this->sCategoryName) ? $bar .= "<INPUT type=\"hidden\" name=\"fCategoryName\" value=\"" . $this->sCategoryName . "\" />\n " : $bar .= "");
(isset($this->iDocTypeID) ? $bar .= "<INPUT type=\"hidden\" name=\"fDocTypeID\" value=\"" . $this->iDocTypeID . "\" />\n " : $bar .= "");
//this next line works in IE, and Netscape 4.79 up, but NOT Netscape 4.79
//$bar .= "<INPUT type=\"image\" onClick=\"return validateStandardSearch('" . $default->rootUrl . "/control.php')\" src=\"$default->graphicsUrl/search.gif\" align = \"absmiddle\" border=\"0\" />\n";
//replaced with this line
$bar .= "<a href=\"#\" onClick=\"return validateStandardSearch('" . $default->rootUrl . "/control.php')\"><image src=\"$default->graphicsUrl/search.gif\" border=\"0\" /></a>";
}
$bar .= "\t\t</td>\n";
$bar .= "\t</tr>\n";
$bar .= "<tr height=30><td ><table cellspacing=0 cellpadding=0 border=0><tr>$sTopMenu</tr>\n";
$bar .= "<tr>$sColourMenu</tr></table></td></tr>\n";
$bar .= "</table>\n";
//set the bar as html to object
$toRender->setHtml($bar);
//render the object
return $toRender->render() . $this->getSearchValidationJavaScript();
}
function getSearchValidationJavaScript() {
$sToRender = "\n\n<SCRIPT LANGUAGE=\"javascript\">\n ";
$sToRender .= "<!--\n";
$sToRender .= "function validateStandardSearch(newAction) {\n";
$sToRender .= "\tif (!(validRequired(document.MainForm.fStandardSearchString, 'Search text'))) {\n";
$sToRender .= "\t\treturn false;\n\t}\n";
$sToRender .= "\telse {\n";
$sToRender .= "\t\tsetActionAndSubmitSearch(newAction);\n";
$sToRender .= "\t}\n";
$sToRender .= "}\n";
$sToRender .= "//-->\n";
$sToRender .= "</SCRIPT>\n\n";
return $sToRender;
}
}
?>