editUI.inc
7.27 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
<?php
/**
* $Id$
*
* Presentation information used for folder editing. Used by editBL.php.
*
* Copyright (c) 2003 Jam Warehouse http://www.jamwarehouse.com
*
* This program is free software; you can redistribute it and/or modify
* 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$
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @package foldermanagement
*/
require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc");
require_once(KT_LIB_DIR . '/documentmanagement/DocumentType.inc');
function getFolderPath($iFolderID) {
global $default;
global $default;
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
return "<table border=\"0\" cellpadding=\"5\" width=\"610\"><tr><td bgcolor=\"$sTDBGColour\">" . displayFolderPathLink(Folder::getFolderPathAsArray($iFolderID), Folder::getFolderPathNamesAsArray($iFolderID), "$default->rootUrl/control.php?action=browse") . "</td></tr></table>\n";
}
function getFolderData($iFolderID, $sDivName, $sStatusMessage = "") {
global $default;
$sSectionName = $default->siteMap->getSectionName(substr($_SERVER["PHP_SELF"], strlen($default->rootUrl), strlen($_SERVER["PHP_SELF"])));
$sTDBGColour = $default->siteMap->getSectionColour($sSectionName, "td");
/*ok*/ $sQuery = array("SELECT F.id, F.name, F.description, F.is_public " .
"FROM $default->folders_table AS F " .
"WHERE F.id = ?", $iFolderID);
$aColumns = array("name", "description", "is_public");
$aColumnHeaders = array(_("Name"), _("Description"), _("Public"));
$aColumnTypes = array(1,1,2);
$oPatternListFromQuery = & new PatternListFromQuery($sQuery, $aColumns, $aColumnHeaders, $aColumnTypes);
$oPatternListFromQuery->setTableHeading(_("Folder Data"));
$oPatternListFromQuery->setTableWidth("610");
$sToRender .= "<table>";
if (strlen($sStatusMessage) > 0) {
$sToRender .= "<tr><td><font color=\"red\">$sStatusMessage</font></td></tr>";
}
$sToRender .= "<tr><td>" . $oPatternListFromQuery->render() . "</td></tr>";
$sToRender .= "<tr><td><a href=\"$default->rootUrl/control.php?action=modifyFolderData&fFolderID=$iFolderID\"><img src=\"" . KTHtml::getEditButton() . "\" border=\"0\" /></a></td></tr>";
$sToRender .= "</table>";;
if ($sStatusMessage) {
return $sToRender;
} else {
return renderSectionDiv($sDivName, $sToRender);
}
}
function getFolderDocTypes($iFolderID, $sDivName) {
$sTable = KTUtil::getTableName('folder_doctypes');
$aQuery = array(
"SELECT document_type_id FROM $sTable WHERE folder_id = ?",
array($iFolderID),
);
$aSelectedIds = DBUtil::getResultArrayKey($aQuery, 'document_type_id');
$sToRender = '<h2>Document Types</h2>';
$oFolder =& Folder::get($iFolderID);
if ($oFolder->getRestrictDocumentTypes()) {
$sToRender .= '<h3>Document types are restricted to the following:</h3>';
$sToRender .= '<ul>';
foreach ($aSelectedIds as $iId) {
$oDocumentType =& DocumentType::get($iId);
$sToRender .= '<li>' . $oDocumentType->getName() . '</li>';
}
$sToRender .= '</ul>';
} else {
$sToRender .= '<h3>Document types are not restricted on this folder</h3>';
}
$sToRender .= sprintf(
'<a href="%s/control.php?action=editFolderDocType&fFolderId=%d"><img src="%s" border="0" /></a>',
$default->rootUrl, $iFolderID, KTHtml::getEditButton());
return renderSectionDiv($sDivName, $sToRender);
}
function renderSectionDiv($sDivName, $sHtml) {
global $default;
if ($default->bNN4) {
return "<div id=\"$sDivName\" style=\"position:absolute;visibility:hidden;top:250px;left:130px;\">" . $sHtml . " </div>";
} else {
return "<div id=\"$sDivName\" style=\"position:absolute;visibility:hidden;left:5px;\">$sHtml</div>";
}
}
function renderFolderSection($sSectionName, $sHeadingText, $bDisplayLink, $iFolderID) {
if ($bDisplayLink) {
$sLink = generateControllerLink("editFolder", "fFolderID=$iFolderID&fShowSection=$sSectionName", $sHeadingText);
} else {
$sLink = "<a href=\"#\" onClick=\"switchDiv('$sSectionName', 'folder');\">$sHeadingText</a>";
}
return "<tr bgcolor=\"" . getColour($iColour) . "\"><td width=\"100%\">$sLink</td></tr>\n";
}
function getPage($iFolderID, $sStatusMessage) {
global $default;
$sToRender = "<div id=\"headings\" style=\"position:relative;visibility:visible;top:2px;left:2px;\">";
$sToRender .= renderHeading(_("Modify Folder Properties"));
$sToRender .= getFolderPath($iFolderID);
$sToRender .= "<table border=0 cellspacing=\"0\" cellpadding=\"0\" width=\"610\">";
$sToRender .= "<tr><td valign=\"top\">";
$sToRender .= "<table border=\"0\" width=\"100%\">";
// if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable
// ie. effectively removes statusMessage on next click
$bDisplayLink = ($sStatusMessage) ? true : false;
$sToRender .= renderFolderSection("folderData", _("Folder Data"), $bDisplayLink, $iFolderID);
$sToRender .= renderFolderSection("documentTypes", _("Document Types"), $bDisplayLink, $iFolderID);
$sToRender .= "</table>";
$sToRender .= "</td><td><table border=1>";
$sToRender .= "</table></td></tr></table>";
$sToRender .= "</div>";
// ugly netscape hacks
if (!$default->bNN4) {
$sToRender .= "<div id=\"contentDiv\" style=\"position:relative;visibility:hidden;width:500px;\">";
}
$sToRender .= getFolderData($iFolderID, "folderData");
$sToRender .= getFolderDocTypes($iFolderID, "documentTypes");
if (!$default->bNN4) {
$sToRender .= "</div>";
}
return $sToRender;
}
function getStatusPage($iFolderID, $sStatusMessage) {
global $default;
$sToRender = "<div id=\"headings\" style=\"position:relative;visibility:visible;top:2px;left:2px;\">";
$sToRender .= renderHeading(_("Modify Folder Properties"));
$sToRender .= getFolderPath($iFolderID);
$sToRender .= "<table border=\"0\" width=\"610\">";
// if we have a status message, then make the section links refresh to viewDocument with the fShowSection variable
// ie. effectively removes statusMessage on next click
$bDisplayLink = ($sStatusMessage) ? true : false;
$sToRender .= renderFolderSection("folderData", _("Folder Data"), $bDisplayLink, $iFolderID);
$sToRender .= renderFolderSection("documentTypes", _("Document Types"), $bDisplayLink, $iFolderID);
$sToRender .= renderFolderSection("folderPermissions", _("Folder Permissions"), $bDisplayLink, $iFolderID);
$sToRender .= "</table>";
$sToRender .= "</div>";
$sToRender .= getFolderData($iFolderID, "folderData", $sStatusMessage);
return $sToRender;
}
?>