Commit da9d84cca4dbb12931e49bd6a144140ff53ba714
1 parent
e67d0596
(#2674) Changed Add Document page to incorporate meta data into one page.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@2417 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
173 additions
and
95 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentBL.php
| ... | ... | @@ -15,6 +15,8 @@ require_once("../../../../config/dmsDefaults.php"); |
| 15 | 15 | |
| 16 | 16 | if (checkSession()) { |
| 17 | 17 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); |
| 18 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternMetaData.inc"); | |
| 19 | + require_once("$default->fileSystemRoot/lib/visualpatterns/PatternEditableTableSqlQuery.inc"); | |
| 18 | 20 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 19 | 21 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); |
| 20 | 22 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| ... | ... | @@ -27,20 +29,22 @@ if (checkSession()) { |
| 27 | 29 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 28 | 30 | require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); |
| 29 | 31 | require_once("addDocumentUI.inc"); |
| 32 | + require_once("$default->fileSystemRoot/presentation/lookAndFeel/knowledgeTree/store.inc"); | |
| 30 | 33 | |
| 34 | + $default->log->info("before:" . arrayToString($_REQUEST)); | |
| 31 | 35 | if (isset($fFolderID)) { |
| 32 | 36 | if (Permission::userHasFolderWritePermission($fFolderID)) { |
| 33 | 37 | //user has permission to add document to this folder |
| 34 | - if (isset($fForStore)) { | |
| 35 | - //user wants to store a document | |
| 36 | - | |
| 37 | - // check that the folder has a default document type | |
| 38 | - if (Folder::getDefaultFolderDocumentType($fFolderID)) { | |
| 38 | + if (isset($fStore)) { | |
| 39 | + // check that a document type has been selected | |
| 40 | + if ($fDocumentTypeID) { | |
| 39 | 41 | //make sure the user actually selected a file first |
| 40 | 42 | if (strlen($_FILES['fFile']['name']) > 0) { |
| 41 | 43 | //if the user selected a file to upload |
| 42 | 44 | //create the document in the database |
| 43 | 45 | $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); |
| 46 | + // set the document title | |
| 47 | + $oDocument->setName($fName); | |
| 44 | 48 | if (!(Document::documentExists($oDocument->getFileName(), $oDocument->getFolderID()))) { |
| 45 | 49 | if ($oDocument->create()) { |
| 46 | 50 | //if the document was successfully created in the db, then store it on the file system |
| ... | ... | @@ -82,6 +86,14 @@ if (checkSession()) { |
| 82 | 86 | } |
| 83 | 87 | } |
| 84 | 88 | |
| 89 | + // now handle meta data, pass new document id to queries | |
| 90 | + $aQueries = constructQuery(array_keys($_POST), array("document_id" =>$oDocument->getID())); | |
| 91 | + for ($i=0; $i<count($aQueries); $i++) { | |
| 92 | + $default->log->info("addDocumentBL.php metaDataQuery=" . $aQueries[$i]); | |
| 93 | + $sql = $default->db; | |
| 94 | + $sql->query($aQueries[$i]); | |
| 95 | + } | |
| 96 | + | |
| 85 | 97 | // fire subscription alerts for the new document |
| 86 | 98 | $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), |
| 87 | 99 | SubscriptionConstants::subscriptionType("FolderSubscription"), |
| ... | ... | @@ -89,76 +101,64 @@ if (checkSession()) { |
| 89 | 101 | "folderName" => Folder::getFolderName($fFolderID))); |
| 90 | 102 | $default->log->info("addDocumentBL.php fired $count subscription alerts for new document " . $oDocument->getName()); |
| 91 | 103 | |
| 92 | - // TODO: further meta-data processing | |
| 93 | - //redirect to the document view page | |
| 94 | - redirect("$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID(). "&fFirstEdit=1"); | |
| 104 | + //redirect to the document details page | |
| 105 | + controllerRedirect("viewDocument", "fDocumentID=" . $oDocument->getID()); | |
| 95 | 106 | } else { |
| 96 | 107 | // couldn't store document in db |
| 108 | + $default->log->error("addDocumentBL.php Filesystem error attempting to store document " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . "; id=$fFolderID"); | |
| 97 | 109 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 110 | + // delete the document from the database | |
| 98 | 111 | $oDocument->delete(); |
| 99 | 112 | $oPatternCustom = & new PatternCustom(); |
| 100 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | |
| 113 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "An error occured while storing the document on the file system, please try again.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 101 | 114 | $main->setCentralPayload($oPatternCustom); |
| 102 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "")); | |
| 103 | - $main->setFormEncType("multipart/form-data"); | |
| 104 | - $main->setErrorMessage("An error occured while storing the document on the file system"); | |
| 105 | - $default->log->error("addDocumentBL.php Filesystem error attempting to store document " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . "; id=$fFolderID"); | |
| 106 | 115 | $main->render(); |
| 107 | 116 | } |
| 108 | 117 | } else { |
| 109 | 118 | // couldn't store document on fs |
| 119 | + $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | |
| 110 | 120 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 111 | 121 | $oPatternCustom = & new PatternCustom(); |
| 112 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | |
| 122 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "An error occured while storing the document in the database, please try again.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 113 | 123 | $main->setCentralPayload($oPatternCustom); |
| 114 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "")); | |
| 115 | - $main->setFormEncType("multipart/form-data"); | |
| 116 | - $main->setErrorMessage("An error occured while storing the document in the database"); | |
| 117 | - $default->log->error("addDocumentBL.php DB error storing document in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | |
| 118 | 124 | $main->render(); |
| 119 | 125 | } |
| 120 | 126 | } else { |
| 121 | 127 | // document already exists in folder |
| 128 | + $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | |
| 122 | 129 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 123 | 130 | $oPatternCustom = & new PatternCustom(); |
| 124 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | |
| 131 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "A document with this file name already exists in this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 125 | 132 | $main->setCentralPayload($oPatternCustom); |
| 126 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "")); | |
| 127 | - $main->setFormEncType("multipart/form-data"); | |
| 128 | - $main->setErrorMessage("A document with this file name already exists in this folder"); | |
| 129 | - $default->log->error("addDocumentBL.php Document exists with name " . $oDocument->getFileName() . " in folder " . Folder::getFolderPath($fFolderID) . " id=$fFolderID"); | |
| 130 | 133 | $main->render(); |
| 131 | 134 | } |
| 132 | 135 | } else { |
| 136 | + // no uploaded file | |
| 133 | 137 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 134 | 138 | $oPatternCustom = & new PatternCustom(); |
| 135 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | |
| 139 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "You did not select a valid document to upload</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 136 | 140 | $main->setCentralPayload($oPatternCustom); |
| 137 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "")); | |
| 138 | - $main->setFormEncType("multipart/form-data"); | |
| 139 | - $main->setErrorMessage("Please select a document by first clicking on 'Browse'. Then click 'Add'"); | |
| 140 | 141 | $main->render(); |
| 141 | 142 | } |
| 142 | 143 | } else { |
| 143 | - // the folder doesn't have a default document type | |
| 144 | + // no document type was selected | |
| 144 | 145 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 145 | 146 | $oPatternCustom = & new PatternCustom(); |
| 146 | - $oPatternCustom->setHtml(getBrowsePage($fFolderID, $fDependantDocumentID)); | |
| 147 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "A valid document type was not selected.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 147 | 148 | $main->setCentralPayload($oPatternCustom); |
| 148 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1"); | |
| 149 | - $main->setFormEncType("multipart/form-data"); | |
| 150 | - $main->setErrorMessage("The folder you're attempting to add the document to doesn't have a default document type.<br>Please correct this and try again.</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>"); | |
| 151 | 149 | $main->render(); |
| 152 | 150 | } |
| 153 | - | |
| 154 | 151 | } else { |
| 155 | 152 | //we're still just browsing |
| 156 | 153 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 157 | 154 | $oPatternCustom = & new PatternCustom(); |
| 158 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | |
| 155 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentTypeID, $fDependantDocumentID)); | |
| 159 | 156 | $main->setCentralPayload($oPatternCustom); |
| 160 | - $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID&fForStore=1" . (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "")); | |
| 157 | + $main->setFormAction($_SERVER["PHP_SELF"] . "?fFolderID=$fFolderID" . | |
| 158 | + (isset($fDependantDocumentID) ? "&fDependantDocumentID=$fDependantDocumentID" : "") . | |
| 159 | + (isset($fDocumentTypeID) ? "&fDocumentTypeID=$fDocumentTypeID" : "")); | |
| 161 | 160 | $main->setFormEncType("multipart/form-data"); |
| 161 | + $main->setHasRequiredFields(true); | |
| 162 | 162 | $main->render(); |
| 163 | 163 | } |
| 164 | 164 | } else { |
| ... | ... | @@ -166,9 +166,8 @@ if (checkSession()) { |
| 166 | 166 | //so don't display add button |
| 167 | 167 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 168 | 168 | $oPatternCustom = & new PatternCustom(); |
| 169 | - $oPatternCustom->setHtml(getBrowsePage($fFolderID, $fDependantDocumentID)); | |
| 169 | + $oPatternCustom->setHtml(getStatusPage($fFolderID, "You do not have permission to add a document to this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>")); | |
| 170 | 170 | $main->setCentralPayload($oPatternCustom); |
| 171 | - $main->setErrorMessage("You do not have permission to add a document to this folder</td><td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a>"); | |
| 172 | 171 | $main->render(); |
| 173 | 172 | } |
| 174 | 173 | } else { |
| ... | ... | @@ -176,11 +175,9 @@ if (checkSession()) { |
| 176 | 175 | //so display an error message |
| 177 | 176 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 178 | 177 | $oPatternCustom = & new PatternCustom(); |
| 179 | - $oPatternCustom->setHtml("<p class=\"errorText\">No folder to which a document can be added is currently selected</p>\n"); | |
| 178 | + $oPatternCustom->setHtml("<p class=\"errorText\">You haven't selected a folder to add a document to.</p>\n"); | |
| 180 | 179 | $main->setCentralPayload($oPatternCustom); |
| 181 | 180 | $main->render(); |
| 182 | 181 | } |
| 183 | 182 | } |
| 184 | - | |
| 185 | - | |
| 186 | -?> | |
| 183 | +?> | |
| 187 | 184 | \ No newline at end of file | ... | ... |
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
| ... | ... | @@ -8,75 +8,156 @@ |
| 8 | 8 | * |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -function getDocumentListForFolder($fFolderID) { | |
| 11 | +function getDocumentType($iFolderID, $iDocumentTypeID) { | |
| 12 | 12 | global $default; |
| 13 | - $sQuery = "SELECT D.id AS id, D.folder_id AS folder_id, CONCAT(' ', D.name) AS name, COALESCE(CONCAT('$default->graphicsUrl/', MT.icon_path), '$default->graphicsUrl/unknown.gif') AS image_url " . | |
| 14 | - "FROM $default->owl_documents_table AS D " . | |
| 15 | - "INNER JOIN $default->owl_status_table AS SL on D.status_id=SL.id " . | |
| 16 | - "LEFT OUTER JOIN $default->owl_mime_table AS MT ON D.mime_id = MT.id " . | |
| 17 | - "WHERE folder_id = $fFolderID " . | |
| 18 | - "AND SL.name = 'Live' " . | |
| 19 | - "ORDER BY name ASC"; | |
| 20 | 13 | |
| 21 | - $aColumns = array("name"); | |
| 22 | - $aColumnTypes = array(1); | |
| 23 | - $aColumnHeaderNames = ("Name"); | |
| 24 | - $aDBColumns = array("id"); | |
| 25 | - $aQueryStringVariableNames = array("fDocumentID"); | |
| 26 | - $oPatternTableSqlQuery = & new PatternTableSqlQuery($sQuery, $aColumns, $aColumnTypes, $aColumnHeaderNames, "100%", "$default->rootUrl/control.php?action=viewDocument", $aDBColumns, $aQueryStringVariableNames); | |
| 27 | - $oPatternTableSqlQuery->setEmptyTableMessage("This folder contains no documents"); | |
| 28 | - $oPatternTableSqlQuery->setUseImageURLFromQuery(true); | |
| 29 | - return $oPatternTableSqlQuery->render(); | |
| 14 | + $sWhereClause = "FDL.folder_id = $iFolderID"; | |
| 15 | + $oPatternListBox = & new PatternListBox("$default->owl_document_types_table", "name", "id", "fDocumentTypeID",$sWhereClause); | |
| 16 | + $oPatternListBox->setIncludeDefaultValue(true); | |
| 17 | + $oPatternListBox->setFromClause("INNER JOIN $default->owl_folder_doctypes_table AS FDL ON ST.id = FDL.document_type_id"); | |
| 18 | + $oPatternListBox->setPostBackOnChange(true); | |
| 19 | + $oPatternListBox->setOnChangeAction("setActionAndSubmit('" . $_SERVER["PHP_SELF"] . "?fFolderID=$iFolderID')"); | |
| 30 | 20 | |
| 21 | + if ($iDocumentTypeID) { | |
| 22 | + $oPatternListBox->setSelectedValue($iDocumentTypeID); | |
| 23 | + $sHeading = "Document Type"; | |
| 24 | + } else { | |
| 25 | + $sHeading = "Please select the document type:"; | |
| 26 | + } | |
| 27 | + | |
| 28 | + return "<table><tr><td><b>$sHeading<b></td></tr><tr><td>" . $oPatternListBox->render() . "</td></tr></table>"; | |
| 31 | 29 | } |
| 32 | 30 | |
| 33 | - | |
| 34 | -function getBrowsePage($fFolderID, $iDependantDocumentID) { | |
| 35 | - $sToRender = "<table border=\"0\">\n"; | |
| 36 | - $sToRender .= "<tr>\n"; | |
| 37 | - $sToRender .= "\t<td>" . renderFolderPath($fFolderID, "/control.php?action=addDocument") . "</td>\n"; | |
| 38 | - $sToRender .= "</tr>\n"; | |
| 39 | - $sToRender .= "</table>\n"; | |
| 31 | +/** | |
| 32 | + * Displays the file browse widget | |
| 33 | + */ | |
| 34 | +function getUploadDocument() { | |
| 35 | + global $default; | |
| 40 | 36 | $sToRender .= "<table border=\"0\">\n"; |
| 41 | 37 | $sToRender .= "<tr>\n"; |
| 42 | - $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument" .(isset($fDependantDocumentID) ? "&fDependantDocumentID=$iDependantDocumentID" : "")) . "<td>\n"; | |
| 43 | - $sToRender .= "</tr>\n"; | |
| 44 | - $sToRender .= "<tr>\n"; | |
| 45 | - if (Permission::userHasFolderReadPermission($fFolderID)) { | |
| 46 | - $sToRender .= "<td>" . getDocumentListForFolder($fFolderID) . "</td>\n"; | |
| 47 | - } | |
| 48 | - $sToRender .= "</tr>"; | |
| 49 | - $sToRender .= "</table><br>\n"; | |
| 38 | + $sToRender .= "<td colspan=\"2\"><b>Document to add:<b></td>\n"; | |
| 39 | + $sToRender .= "</tr>\n"; | |
| 40 | + $sToRender .= "<tr><td>File</td><td><input type=\"file\" name=\"fFile\" onChange=\"document.MainForm.fName=document.MainForm.fFile\"></td></tr>\n"; | |
| 41 | + $sToRender .= "<tr><td>Title</td><td><input type=\"text\" name=\"fName\" size=\"20\"></td></tr>\n"; | |
| 42 | + $sToRender .= "</table>\n"; | |
| 50 | 43 | return $sToRender; |
| 44 | +} | |
| 45 | + | |
| 46 | +/** | |
| 47 | + * Displays the generic meta data fields form | |
| 48 | + */ | |
| 49 | +function getGenericMetaDataForm() { | |
| 50 | + global $default; | |
| 51 | + $sQuery = "SELECT DISTINCT -1 AS document_id, DF.id AS document_field_id, DF.name AS field_name, -1 AS id " . | |
| 52 | + "FROM document_fields AS DF LEFT OUTER JOIN document_fields_link AS DFL ON DF.id = DFL.document_field_id " . | |
| 53 | + "WHERE DF.is_generic = 1 "; | |
| 54 | + | |
| 55 | + $aStoreColumnNames = array("document_id", "document_field_id", "value"); | |
| 56 | + $aDisplayColumnNames = array("document_id", "field_name", "value"); | |
| 57 | + $aMetaDataColumnNames = array(2=>"field_name"); | |
| 58 | + $aColumnsEditable = array(0,0,1); | |
| 59 | + $aColumnsVisible = array(0,1,1); | |
| 60 | + $aColumnDisplayTypes = array(1,1,4); | |
| 61 | + $aColumnDatabaseTypes = array(4,0,1); | |
| 62 | + | |
| 63 | + $oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes); | |
| 64 | + $oPatternTableSqlQuery->setTableCaption("Generic Meta Data"); | |
| 65 | + $oPatternTableSqlQuery->setUniqueName("gmd"); | |
| 66 | + $oPatternTableSqlQuery->setRequiredColumnNames(array("value")); | |
| 67 | + $oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames); | |
| 68 | + $oPatternTableSqlQuery->setEmptyTableMessage("No Generic Meta Data"); | |
| 69 | + $oPatternTableSqlQuery->setRenderJavascriptValidation(false); | |
| 70 | + return $oPatternTableSqlQuery; | |
| 71 | +} | |
| 72 | + | |
| 73 | +/** | |
| 74 | + * Displays the type specific meta data fields form | |
| 75 | + */ | |
| 76 | +function getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID) { | |
| 77 | + global $default; | |
| 78 | + $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 " . | |
| 79 | + "FROM document_type_fields_link AS DTFL INNER JOIN document_fields AS DF ON DTFL.field_id = DF.id " . | |
| 80 | + "LEFT OUTER JOIN document_fields_link AS DFL ON DFL.document_field_id = DTFL.field_id " . | |
| 81 | + "WHERE DF.is_generic = 0 " . | |
| 82 | + "AND DTFL.document_type_id = $iDocumentTypeID"; | |
| 83 | + | |
| 84 | + $aStoreColumnNames = array("document_id", "document_field_id", "value"); | |
| 85 | + $aDisplayColumnNames = array("document_id", "field_name", "value"); | |
| 86 | + $aColumnsEditable = array(0,0,1); | |
| 87 | + $aColumnsVisible = array(0,1,1); | |
| 88 | + $aColumnDisplayTypes = array(1,1,4); | |
| 89 | + $aColumnDatabaseTypes = array(4,0,1); | |
| 90 | + $aMetaDataColumnNames = array(2=>"field_name"); | |
| 91 | + | |
| 92 | + $oPatternTableSqlQuery = & new PatternEditableTableSqlQuery($sQuery, "document_fields_link", $aStoreColumnNames, $aDisplayColumnNames, $aColumnsEditable, $aColumnsVisible, $aColumnDisplayTypes, $aColumnDatabaseTypes); | |
| 93 | + $oPatternTableSqlQuery->setTableCaption("Type specific meta data"); | |
| 94 | + $oPatternTableSqlQuery->setEmptyTableMessage("No Type Specific Meta Data"); | |
| 95 | + $oPatternTableSqlQuery->setUniqueName("tsmd"); | |
| 96 | + $oPatternTableSqlQuery->setMetaDataFields($aMetaDataColumnNames); | |
| 97 | + $oPatternTableSqlQuery->setRenderJavascriptValidation(false); | |
| 98 | + return $oPatternTableSqlQuery; | |
| 51 | 99 | } |
| 52 | 100 | |
| 101 | +function getMetaDataForm($iFolderID, $iDocumentTypeID) { | |
| 102 | + $oGenericPattern = getGenericMetaDataForm(); | |
| 103 | + $oTypeSpecificPattern = getTypeSpecificMetaDataForm($iFolderID, $iDocumentTypeID); | |
| 104 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 105 | + $sToRender .= "<tr><td><b>Document Meta Data<b></td></tr>\n"; | |
| 106 | + $sToRender .= "<tr><td valign=\"top\">" . $oGenericPattern->render() . "</td><td valign=\"top\">" . $oTypeSpecificPattern->render() . "</td></tr>"; | |
| 107 | + $sToRender .= "</table>"; | |
| 108 | + | |
| 109 | + // validation starts | |
| 110 | + $sToRender .= "\n\n<script language=\"javascript\">\n<!--\n"; | |
| 111 | + $sToRender .= "function validateForm(theForm) {\n"; | |
| 112 | + // document title | |
| 113 | + $sToRender .= "\tif (!(validRequired(theForm.fName, 'Document Title'))) {\n"; | |
| 114 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 115 | + // filename | |
| 116 | + $sToRender .= "\tif (!(validRequired(theForm.fFile, 'Document Filename'))) {\n"; | |
| 117 | + $sToRender .= "\t\treturn false;\n\t}\n"; | |
| 118 | + // metadata | |
| 119 | + $sToRender .= $oGenericPattern->getValidationJavascript(); | |
| 120 | + $sToRender .= $oTypeSpecificPattern->getValidationJavascript(); | |
| 121 | + $sToRender .= "return true;\n}\n"; | |
| 122 | + $sToRender .= "//-->\n</script>\n\n"; | |
| 53 | 123 | |
| 54 | -function getBrowseAddPage($fFolderID, $iDependantDocumentID = null) { | |
| 124 | + return $sToRender; | |
| 125 | +} | |
| 126 | +function getPage($iFolderID, $iDocumentTypeID, $iDependantDocumentID = null) { | |
| 55 | 127 | global $default; |
| 56 | 128 | |
| 57 | - $sToRender = "<table border=\"0\" width=\"600\">\n"; | |
| 129 | + $sToRender .= renderHeading("Add Document"); | |
| 130 | + $sToRender .= renderFolderPath($iFolderID, "", false); | |
| 131 | + | |
| 132 | + if ($iDocumentTypeID) { | |
| 133 | + $sToRender .= "<table><tr><td><b>Document Type<b></td></tr><tr><td>" . lookupName($default->owl_document_types_table, $iDocumentTypeID) . "</td></tr></table>"; | |
| 134 | + $sToRender .= getUploadDocument(); | |
| 135 | + $sToRender .= getMetaDataForm($iFolderID, $iDocumentTypeID); | |
| 136 | + $sActionButtons = "<input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\"/>"; | |
| 137 | + $sToRender .= "<input type=\"hidden\" name=\"fStore\" value=\"1\">"; | |
| 138 | + $sActionButtons .= generateControllerLink("addDocument", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/back.gif\" border=\"0\"/>") . | |
| 139 | + generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>"); | |
| 140 | + } else { | |
| 141 | + $sToRender .= getDocumentType($iFolderID, $iDocumentTypeID); | |
| 142 | + $sActionButtons .= generateControllerLink("browse", "fFolderID=$iFolderID", "<img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"/>"); | |
| 143 | + } | |
| 144 | + | |
| 145 | + $sToRender .= "<table border=\"0\" width=\"100%\" >\n"; | |
| 146 | + $sToRender .= "<tr><td>$sActionButtons</td></tr>"; | |
| 147 | + $sToRender .= "</table>"; | |
| 148 | + | |
| 149 | + return $sToRender; | |
| 150 | +} | |
| 151 | + | |
| 152 | +function getStatusPage($iFolderID, $sMessage) { | |
| 153 | + $sToRender .= renderHeading("Add Document"); | |
| 154 | + $sToRender .= renderFolderPath($iFolderID, "", false); | |
| 155 | + | |
| 156 | + $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 58 | 157 | $sToRender .= "<tr>\n"; |
| 59 | - $sToRender .= "\t<td>" . renderFolderPath($fFolderID, "/control.php?action=addDocument") . "</td>\n"; | |
| 158 | + $sToRender .= "\t<td><font color=\"red\">$sMessage</font></td>\n"; | |
| 60 | 159 | $sToRender .= "</tr>\n"; |
| 61 | 160 | $sToRender .= "</table>\n"; |
| 62 | - $sToRender .= "<table border=\"0\">\n"; | |
| 63 | - $sToRender .= "<tr>\n"; | |
| 64 | - $sToRender .= "<td colspan=\"2\"><b>Document to add:<b></td>\n"; | |
| 65 | - $sToRender .= "</tr>\n"; | |
| 66 | - $sToRender .= "<td><input type=\"file\" name=\"fFile\"></td>\n"; | |
| 67 | - $sToRender .= "<td><input type=\"image\" src=\"$default->graphicsUrl/widgets/add.gif\" border=\"0\" value=\"Add\"></td>\n"; | |
| 68 | - $sToRender .= "<td><a href=\"$default->rootUrl/control.php?action=browse&fFolderID=$fFolderID\"><img src=\"$default->graphicsUrl/widgets/cancel.gif\" border=\"0\"></a></td>\n"; | |
| 69 | - $sToRender .= "</tr>\n"; | |
| 70 | - $sToRender .= "</table>\n"; | |
| 71 | - $sToRender .= "<table border=\"0\" width=\"100%\">\n"; | |
| 72 | - $sToRender .= "<tr>\n"; | |
| 73 | - $sToRender .= "\t<td>" . renderFolderList($fFolderID, "/control.php?action=addDocument" . (isset($iDependantDocumentID) ? "&fDependantDocumentID=$iDependantDocumentID" : "")) . "<td>\n"; | |
| 74 | - $sToRender .= "</tr>\n"; | |
| 75 | - $sToRender .= "<tr>\n"; | |
| 76 | - $sToRender .= "<td>" . getDocumentListForFolder($fFolderID) . "</td>\n"; | |
| 77 | - $sToRender .= "</tr>"; | |
| 78 | - $sToRender .= "</table><br>\n"; | |
| 79 | - | |
| 80 | 161 | return $sToRender; |
| 81 | 162 | } |
| 82 | 163 | -?> |
| 164 | +?> | |
| 83 | 165 | \ No newline at end of file | ... | ... |