Commit 929b0a8de3053877489f73ea7763ade5bf07a0a9
1 parent
bc452961
Use templating directly to build the document data table (turfing
PatternListFromQuery) git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3735 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
1 changed file
with
45 additions
and
24 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc
| @@ -49,36 +49,57 @@ function renderDocumentData($oDocument, $bEditable, $sStatusMessage = "") { | @@ -49,36 +49,57 @@ function renderDocumentData($oDocument, $bEditable, $sStatusMessage = "") { | ||
| 49 | $aDocuments[] = $iVersionID; | 49 | $aDocuments[] = $iVersionID; |
| 50 | } | 50 | } |
| 51 | $sWhere = DBUtil::paramArray($aDocuments); | 51 | $sWhere = DBUtil::paramArray($aDocuments); |
| 52 | - /*ok*/ $sQuery = array("SELECT D.id, D.name, D.modified, D.created, D.size, U.name AS initiator, D.metadata_version, CONCAT(CONCAT(D.major_version, '.'), D.minor_version) AS version, DTL.name AS document_type, D.is_checked_out, COALESCE(U2.name, '') AS c_user " . | 52 | + /*ok*/ $sQuery = "SELECT D.id, D.name, D.modified, D.created, D.size, U.name AS initiator, D.metadata_version, CONCAT(CONCAT(D.major_version, '.'), D.minor_version) AS version, DTL.name AS document_type, D.is_checked_out, COALESCE(U2.name, '') AS c_user " . |
| 53 | "FROM $default->documents_table AS D " . | 53 | "FROM $default->documents_table AS D " . |
| 54 | "LEFT JOIN $default->users_table AS U ON U.id = D.creator_id " . | 54 | "LEFT JOIN $default->users_table AS U ON U.id = D.creator_id " . |
| 55 | "LEFT OUTER JOIN $default->document_types_table AS DTL ON DTL.id = D.document_type_id " . | 55 | "LEFT OUTER JOIN $default->document_types_table AS DTL ON DTL.id = D.document_type_id " . |
| 56 | "LEFT OUTER JOIN $default->users_table AS U2 ON U2.id = D.checked_out_user_id " . | 56 | "LEFT OUTER JOIN $default->users_table AS U2 ON U2.id = D.checked_out_user_id " . |
| 57 | - "WHERE D.id IN ($sWhere) ", $aDocuments); | ||
| 58 | - | ||
| 59 | - $aColumns = array("metadata_version", "name", "modified", "created", "size", "initiator", "document_type", "c_user", "id", "version"); | ||
| 60 | - $aColumnNames = array(_("Metadata Version"), _("Document title"), _("Last updated"), _("Created"), _("File Size"), _("Document initiator"), _("Document Type"), _("Checked out by"), _("ID"), _("Document Version"),); | ||
| 61 | - $aColumnTypes = array(1,1,1,1,1,1,1,1,1,1); | ||
| 62 | - $oPatternListFromQuery = & new PatternListFromQuery($sQuery, $aColumns, $aColumnNames, $aColumnTypes); | ||
| 63 | - $oPatternListFromQuery->setTableHeading(_("Document Data")); | ||
| 64 | - $oPatternListFromQuery->setEmptyTableMessage(_("No Document Data")); | ||
| 65 | - $oPatternListFromQuery->setTableWidth("400"); | ||
| 66 | - | ||
| 67 | - $sToRender .= "\t<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n"; | ||
| 68 | - if ($sStatusMessage) { | ||
| 69 | - $sToRender .= "<tr><td> </td></tr><tr><td><font color=\"red\">$sStatusMessage</font></td></tr>"; | ||
| 70 | - } | ||
| 71 | - $sToRender .= "\t<tr>\n"; | ||
| 72 | - $sToRender .= "\t\t<td>" . $oPatternListFromQuery->render() . "</td>\n"; | ||
| 73 | - $sToRender .= "\t</tr>\n"; | ||
| 74 | - if ($bEditable) { | ||
| 75 | - $sToRender .= "\t<tr>\n"; | ||
| 76 | - $sToRender .= "<td colspan=\"2\"><a href=\"$default->rootUrl/control.php?action=modifyDocument&fDocumentID=" . $oDocument->getID() . "\"><img src=\"" . KTHtml::getEditButton() . "\" border=\"0\"></a></td>\n"; | ||
| 77 | - $sToRender .= "\t</tr>\n"; | 57 | + "WHERE D.id = ?"; |
| 58 | + | ||
| 59 | + // $aColumns = array("metadata_version", "name", "modified", "created", "size", "initiator", "document_type", "c_user", "id", "version"); | ||
| 60 | + $aColumns = array( | ||
| 61 | + "metadata_version" =>_("Metadata Version"), | ||
| 62 | + "name" => _("Document title"), | ||
| 63 | + "modified" => _("Last updated"), | ||
| 64 | + "created" => _("Created"), | ||
| 65 | + "size" => _("File Size"), | ||
| 66 | + "initiator" => _("Document initiator"), | ||
| 67 | + "document_type" => _("Document Type"), | ||
| 68 | + "c_user" => _("Checked out by"), | ||
| 69 | + "id" => _("ID"), | ||
| 70 | + "document_version" => _("Document Version"), | ||
| 71 | + ); | ||
| 72 | + | ||
| 73 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 74 | + $oTemplate = $oTemplating->loadTemplate('ktcore/document_generic_metadata'); | ||
| 75 | + | ||
| 76 | + $iDocumentsLen = count($aDocuments); | ||
| 77 | + $map = array(); | ||
| 78 | + $iDocumentCount = 0; | ||
| 79 | + foreach ($aDocuments as $iDocumentID) { | ||
| 80 | + $map['Metadata Version'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); | ||
| 81 | + $oThisDocument =& Document::get($iDocumentID); | ||
| 82 | + if (PEAR::isError($oThisDocument)) { | ||
| 83 | + continue; | ||
| 84 | + } | ||
| 85 | + if ($oThisDocument === false) { | ||
| 86 | + continue; | ||
| 87 | + } | ||
| 88 | + $map['Metadata Version'][$iDocumentCount] = $oThisDocument->getMetadataVersion(); | ||
| 89 | + $aRow = DBUtil::getOneResult(array($sQuery, array($iDocumentID))); | ||
| 90 | + foreach ($aColumns as $dbname => $prettyname) { | ||
| 91 | + $newarray = KTUtil::arrayGet($map, $prettyname, array_fill(0, $iDocumentsLen, null)); | ||
| 92 | + $newarray[$iDocumentCount] = $aRow[$dbname]; | ||
| 93 | + $map[$prettyname] = $newarray; | ||
| 94 | + } | ||
| 95 | + $iDocumentCount++; | ||
| 78 | } | 96 | } |
| 79 | - $sToRender .= "\t</table>\n"; | ||
| 80 | 97 | ||
| 81 | - return $sToRender; | 98 | + $oTemplate->setData(array( |
| 99 | + 'map' => $map, | ||
| 100 | + )); | ||
| 101 | + | ||
| 102 | + return $oTemplate->render(); | ||
| 82 | } | 103 | } |
| 83 | 104 | ||
| 84 | 105 |