addDocumentUI.inc
7.33 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
<?php
/**
* Presentation data used to add a document. Used by addDocumentBL.php
*
* @author Rob Cherry, Jam Warehouse (Pty) Ltd, South Africa
* @date 28 January 2003
* @package presentation.lookAndFeel.knowledgeTree.documentmanagement
*
*/
function getDocumentType($iFolderID, $iDocumentTypeID) {
global $default;
$sWhereClause = "FDL.folder_id = $iFolderID";
$oPatternListBox = & new PatternListBox("$default->owl_document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause);
$oPatternListBox->setIncludeDefaultValue(true);
$oPatternListBox->setFromClause("INNER JOIN $default->owl_folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id");
$oPatternListBox->setPostBackOnChange(true);
$oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fFolderID=$iFolderID')");
if ($iDocumentTypeID) {
$oPatternListBox->setSelectedValue($iDocumentTypeID);
$sHeading = "Document Type";
} else {
$sHeading = "Please select the document type:";
}
return "<table><tr><td><b>$sHeading<b></td></tr><tr><td>" . $oPatternListBox->render() . "</td></tr></table>";
}
/**
* Displays the file browse widget
*/
function getUploadDocument() {
global $default;
$sToRender .= "<table border=\"0\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "<td colspan=\"2\"><b>Document to add:<b></td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "<tr><td>File</td><td><input type=\"file\" name=\"fFile\" onChange=\"document.MainForm.fName=document.MainForm.fFile\"></td></tr>\n";
$sToRender .= "<tr><td>Title</td><td><input type=\"text\" name=\"fName\" size=\"20\"></td></tr>\n";
$sToRender .= "</table>\n";
return $sToRender;
}
/**
* Displays the generic meta data fields form
*/
function getGenericMetaDataForm() {
global $default;
$sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " .
"FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " .
"WHERE DF.is_generic = 1 ";
$aStoreColumnNames = array("document_id", "document_field_id", "value");
$aDisplayColumnNames = array("document_id", "field_name", "value");
$aMetaDataColumnNames = array(2=>"field_name");
$aColumnsEditable = array(0,0,1);
$aColumnsVisible = array(0,1,1);
$aColumnDisplayTypes = array(1,1,4);
$aColumnDatabaseTypes = array(4,0,1);
$oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes);
$oPatternTableSqlQuery->setTableCaption("Generic Meta Data");
$oPatternTableSqlQuery->setUniqueName("gmd");
$oPatternTableSqlQuery->setRequiredColumnNames(array("value"));
$oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames);
$oPatternTableSqlQuery->setEmptyTableMessage("No Generic Meta Data");
$oPatternTableSqlQuery->setRenderJavascriptValidation(false);
return $oPatternTableSqlQuery;
}
/**
* Displays the type specific meta data fields form
*/
function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) {
global $default;
$sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, DTFL.is_mandatory AS is_mandatory, -1 AS id " .
"FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " .
"LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " .
"WHERE DF.is_generic = 0 " .
"AND DTFL.document_type_id = $iDocumentTypeID";
$aStoreColumnNames = array("document_id", "document_field_id", "value");
$aDisplayColumnNames = array("document_id", "field_name", "value");
$aColumnsEditable = array(0,0,1);
$aColumnsVisible = array(0,1,1);
$aColumnDisplayTypes = array(1,1,4);
$aColumnDatabaseTypes = array(4,0,1);
$aMetaDataColumnNames = array(2=>"field_name");
$oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes);
$oPatternTableSqlQuery->setTableCaption("Type specific meta data");
$oPatternTableSqlQuery->setEmptyTableMessage("No Type Specific Meta Data");
$oPatternTableSqlQuery->setUniqueName("tsmd");
$oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames);
$oPatternTableSqlQuery->setRenderJavascriptValidation(false);
return $oPatternTableSqlQuery;
}
function getMetaDataForm($iFolderID, $iDocumentTypeID) {
$oGenericPattern = getGenericMetaDataForm();
$oTypeSpecificPattern = getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr><td><b>Document Meta Data<b></td></tr>\n";
$sToRender .= "<tr><td valign=\"top\">" . $oGenericPattern->render() . "</td><td valign=\"top\">" . $oTypeSpecificPattern->render() . "</td></tr>";
$sToRender .= "</table>";
// validation starts
$sToRender .= "\n\n<script language=\"javascript\">\n<!--\n";
$sToRender .= "function validateForm(theForm) {\n";
// document title
$sToRender .= "\tif (!(validRequired(theForm.fName, 'Document Title'))) {\n";
$sToRender .= "\t\treturn false;\n\t}\n";
// filename
$sToRender .= "\tif (!(validRequired(theForm.fFile, 'Document Filename'))) {\n";
$sToRender .= "\t\treturn false;\n\t}\n";
// metadata
$sToRender .= $oGenericPattern->getValidationJavascript();
$sToRender .= $oTypeSpecificPattern->getValidationJavascript();
$sToRender .= "return true;\n}\n";
$sToRender .= "//-->\n</script>\n\n";
return $sToRender;
}
function getPage($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null) {
global $default;
$sToRender .= renderHeading("Add Document");
$sToRender .= renderFolderPath($iFolderID, "", false);
if ($iDocumentTypeID) {
$sToRender .= "<table><tr><td><b>Document Type<b></td></tr><tr><td>" . lookupName($default->owl_document_types_table, $iDocumentTypeID) . "</td></tr></table>";
$sToRender .= getUploadDocument();
$sToRender .= getMetaDataForm($iFolderID, $iDocumentTypeID);
$sActionButtons = "<input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/>";
$sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">";
$sActionButtons .= generateControllerLink("addDocument", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"/>") .
generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>");
} else {
$sToRender .= getDocumentType($iFolderID, $iDocumentTypeID);
$sActionButtons .= generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>");
}
$sToRender .= "<table border=\"0\" width=\"100%\" >\n";
$sToRender .= "<tr><td>$sActionButtons</td></tr>";
$sToRender .= "</table>";
return $sToRender;
}
function getStatusPage($iFolderID, $sMessage) {
$sToRender .= renderHeading("Add Document");
$sToRender .= renderFolderPath($iFolderID, "", false);
$sToRender .= "<table border=\"0\" width=\"100%\">\n";
$sToRender .= "<tr>\n";
$sToRender .= "\t<td><font color=\"red\">$sMessage</font></td>\n";
$sToRender .= "</tr>\n";
$sToRender .= "</table>\n";
return $sToRender;
}
?>