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,6 +15,8 @@ require_once("../../../../config/dmsDefaults.php"); | ||
| 15 | 15 | ||
| 16 | if (checkSession()) { | 16 | if (checkSession()) { |
| 17 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternTableSqlQuery.inc"); | 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 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); | 20 | require_once("$default->fileSystemRoot/lib/visualpatterns/PatternCustom.inc"); |
| 19 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); | 21 | require_once("$default->fileSystemRoot/lib/foldermanagement/Folder.inc"); |
| 20 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); | 22 | require_once("$default->fileSystemRoot/lib/documentmanagement/Document.inc"); |
| @@ -27,20 +29,22 @@ if (checkSession()) { | @@ -27,20 +29,22 @@ if (checkSession()) { | ||
| 27 | require_once("$default->fileSystemRoot/presentation/Html.inc"); | 29 | require_once("$default->fileSystemRoot/presentation/Html.inc"); |
| 28 | require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); | 30 | require_once("$default->fileSystemRoot/lib/subscriptions/SubscriptionEngine.inc"); |
| 29 | require_once("addDocumentUI.inc"); | 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 | if (isset($fFolderID)) { | 35 | if (isset($fFolderID)) { |
| 32 | if (Permission::userHasFolderWritePermission($fFolderID)) { | 36 | if (Permission::userHasFolderWritePermission($fFolderID)) { |
| 33 | //user has permission to add document to this folder | 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 | //make sure the user actually selected a file first | 41 | //make sure the user actually selected a file first |
| 40 | if (strlen($_FILES['fFile']['name']) > 0) { | 42 | if (strlen($_FILES['fFile']['name']) > 0) { |
| 41 | //if the user selected a file to upload | 43 | //if the user selected a file to upload |
| 42 | //create the document in the database | 44 | //create the document in the database |
| 43 | $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); | 45 | $oDocument = & PhysicalDocumentManager::createDocumentFromUploadedFile($_FILES['fFile'], $fFolderID); |
| 46 | + // set the document title | ||
| 47 | + $oDocument->setName($fName); | ||
| 44 | if (!(Document::documentExists($oDocument->getFileName(), $oDocument->getFolderID()))) { | 48 | if (!(Document::documentExists($oDocument->getFileName(), $oDocument->getFolderID()))) { |
| 45 | if ($oDocument->create()) { | 49 | if ($oDocument->create()) { |
| 46 | //if the document was successfully created in the db, then store it on the file system | 50 | //if the document was successfully created in the db, then store it on the file system |
| @@ -82,6 +86,14 @@ if (checkSession()) { | @@ -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 | // fire subscription alerts for the new document | 97 | // fire subscription alerts for the new document |
| 86 | $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), | 98 | $count = SubscriptionEngine::fireSubscription($fFolderID, SubscriptionConstants::subscriptionAlertType("AddDocument"), |
| 87 | SubscriptionConstants::subscriptionType("FolderSubscription"), | 99 | SubscriptionConstants::subscriptionType("FolderSubscription"), |
| @@ -89,76 +101,64 @@ if (checkSession()) { | @@ -89,76 +101,64 @@ if (checkSession()) { | ||
| 89 | "folderName" => Folder::getFolderName($fFolderID))); | 101 | "folderName" => Folder::getFolderName($fFolderID))); |
| 90 | $default->log->info("addDocumentBL.php fired $count subscription alerts for new document " . $oDocument->getName()); | 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 | } else { | 106 | } else { |
| 96 | // couldn't store document in db | 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 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 109 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 110 | + // delete the document from the database | ||
| 98 | $oDocument->delete(); | 111 | $oDocument->delete(); |
| 99 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 115 | $main->render(); |
| 107 | } | 116 | } |
| 108 | } else { | 117 | } else { |
| 109 | // couldn't store document on fs | 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 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 120 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 111 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 124 | $main->render(); |
| 119 | } | 125 | } |
| 120 | } else { | 126 | } else { |
| 121 | // document already exists in folder | 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 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 129 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 123 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 133 | $main->render(); |
| 131 | } | 134 | } |
| 132 | } else { | 135 | } else { |
| 136 | + // no uploaded file | ||
| 133 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 137 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 134 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 141 | $main->render(); |
| 141 | } | 142 | } |
| 142 | } else { | 143 | } else { |
| 143 | - // the folder doesn't have a default document type | 144 | + // no document type was selected |
| 144 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 145 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 145 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 149 | $main->render(); |
| 152 | } | 150 | } |
| 153 | - | ||
| 154 | } else { | 151 | } else { |
| 155 | //we're still just browsing | 152 | //we're still just browsing |
| 156 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 153 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 157 | $oPatternCustom = & new PatternCustom(); | 154 | $oPatternCustom = & new PatternCustom(); |
| 158 | - $oPatternCustom->setHtml(getBrowseAddPage($fFolderID, $fDependantDocumentID)); | 155 | + $oPatternCustom->setHtml(getPage($fFolderID, $fDocumentTypeID, $fDependantDocumentID)); |
| 159 | $main->setCentralPayload($oPatternCustom); | 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 | $main->setFormEncType("multipart/form-data"); | 160 | $main->setFormEncType("multipart/form-data"); |
| 161 | + $main->setHasRequiredFields(true); | ||
| 162 | $main->render(); | 162 | $main->render(); |
| 163 | } | 163 | } |
| 164 | } else { | 164 | } else { |
| @@ -166,9 +166,8 @@ if (checkSession()) { | @@ -166,9 +166,8 @@ if (checkSession()) { | ||
| 166 | //so don't display add button | 166 | //so don't display add button |
| 167 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 167 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 168 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 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 | $main->render(); | 171 | $main->render(); |
| 173 | } | 172 | } |
| 174 | } else { | 173 | } else { |
| @@ -176,11 +175,9 @@ if (checkSession()) { | @@ -176,11 +175,9 @@ if (checkSession()) { | ||
| 176 | //so display an error message | 175 | //so display an error message |
| 177 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); | 176 | require_once("$default->fileSystemRoot/presentation/webpageTemplate.inc"); |
| 178 | $oPatternCustom = & new PatternCustom(); | 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 | $main->setCentralPayload($oPatternCustom); | 179 | $main->setCentralPayload($oPatternCustom); |
| 181 | $main->render(); | 180 | $main->render(); |
| 182 | } | 181 | } |
| 183 | } | 182 | } |
| 184 | - | ||
| 185 | - | ||
| 186 | -?> | 183 | +?> |
| 187 | \ No newline at end of file | 184 | \ No newline at end of file |
presentation/lookAndFeel/knowledgeTree/documentmanagement/addDocumentUI.inc
| @@ -8,75 +8,156 @@ | @@ -8,75 +8,156 @@ | ||
| 8 | * | 8 | * |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | -function getDocumentListForFolder($fFolderID) { | 11 | +function getDocumentType($iFolderID, $iDocumentTypeID) { |
| 12 | global $default; | 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 | $sToRender .= "<table border=\"0\">\n"; | 36 | $sToRender .= "<table border=\"0\">\n"; |
| 41 | $sToRender .= "<tr>\n"; | 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 | return $sToRender; | 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 | global $default; | 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 | $sToRender .= "<tr>\n"; | 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 | $sToRender .= "</tr>\n"; | 159 | $sToRender .= "</tr>\n"; |
| 61 | $sToRender .= "</table>\n"; | 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 | return $sToRender; | 161 | return $sToRender; |
| 81 | } | 162 | } |
| 82 | -?> | 163 | -?> |
| 164 | +?> | ||
| 83 | \ No newline at end of file | 165 | \ No newline at end of file |