Commit 30d2d758bc32f843d3d3815b3ac0b8f77c80ca21
1 parent
6ece9666
Group document-specific metadata display by fieldset.
git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3925 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
62 additions
and
36 deletions
presentation/lookAndFeel/knowledgeTree/documentmanagement/viewUI.inc
| ... | ... | @@ -169,34 +169,58 @@ function renderTypeSpecificMetaData($oDocument, $bEditable) { |
| 169 | 169 | $aDocuments[] = $iVersionID; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - /*ok*/ $sQuery = "SELECT DF.name AS name, DFL.value AS value " . | |
| 172 | + $sParam = DBUtil::paramArray($aDocuments); | |
| 173 | + $sQuery = "SELECT D.id AS document_id, DF.id AS field_id, DFL.value AS value, F.id AS fieldset_id " . | |
| 173 | 174 | "FROM $default->documents_table AS D INNER JOIN document_fields_link AS DFL ON D.id = DFL.document_id " . |
| 174 | 175 | "INNER JOIN $default->document_fields_table AS DF ON DF.ID = DFL.document_field_id " . |
| 175 | - "WHERE D.id = ? " . | |
| 176 | + "INNER JOIN $default->fieldsets_table AS F ON F.id = DF.parent_fieldset " . | |
| 177 | + "WHERE D.id IN ($sParam) " . | |
| 176 | 178 | "AND DF.name NOT LIKE 'Category' " . |
| 177 | 179 | "AND DF.is_generic = 0"; |
| 178 | - | |
| 179 | - $iDocumentsLen = count($aDocuments); | |
| 180 | - $map = array(); | |
| 181 | - $iDocumentCount = 0; | |
| 182 | - foreach ($aDocuments as $iDocumentID) { | |
| 183 | - $map['Metadata Version'] = KTUtil::arrayGet($map, 'Metadata Version', array_fill(0, $iDocumentsLen, null)); | |
| 184 | - $oThisDocument =& Document::get($iDocumentID); | |
| 185 | - if (PEAR::isError($oThisDocument)) { | |
| 186 | - continue; | |
| 180 | + $aParam = $aDocuments; | |
| 181 | + | |
| 182 | + $aResults = DBUtil::getResultArray(array($sQuery, $aParam)); | |
| 183 | + | |
| 184 | + $aMap = array(); | |
| 185 | + foreach ($aResults as $aResult) { | |
| 186 | + $fieldset_id = $aResult['fieldset_id']; | |
| 187 | + $field_id = $aResult['field_id']; | |
| 188 | + $document_id = $aResult['document_id']; | |
| 189 | + $aMyFieldset = KTUtil::arrayGet($aMap, $fieldset_id); | |
| 190 | + if (empty($aMyFieldset)) { | |
| 191 | + $aMap[$fieldset_id]["fieldset"] = KTFieldset::get($fieldset_id); | |
| 192 | + $aMap[$fieldset_id]["fields"] = array(); | |
| 187 | 193 | } |
| 188 | - if ($oThisDocument === false) { | |
| 189 | - continue; | |
| 194 | + $aMyField = KTUtil::arrayGet($aMap[$fieldset_id]['fields'], $field_id); | |
| 195 | + if (empty($aMyField)) { | |
| 196 | + $aMap[$fieldset_id]['fields'][$field_id] = array(); | |
| 197 | + $aMap[$fieldset_id]['fields'][$field_id]['field'] = DocumentField::get($field_id); | |
| 198 | + $aMap[$fieldset_id]['fields'][$field_id]['values'] = array(); | |
| 190 | 199 | } |
| 191 | - $map['Metadata Version'][$iDocumentCount] = $oThisDocument->getMetadataVersion(); | |
| 192 | - $aTDRows = DBUtil::getResultArray(array($sQuery, array($iDocumentID))); | |
| 193 | - foreach ($aTDRows as $aRow) { | |
| 194 | - $newarray = KTUtil::arrayGet($map, $aRow['name'], array_fill(0, $iDocumentsLen, null)); | |
| 195 | - $newarray[$iDocumentCount] = $aRow['value']; | |
| 196 | - $map[$aRow['name']] = $newarray; | |
| 200 | + $aMap[$fieldset_id]['fields'][$field_id]['values'][$document_id] = $aResult['value']; | |
| 201 | + } | |
| 202 | + $oTemplating =& KTTemplating::getSingleton(); | |
| 203 | + $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata'); | |
| 204 | + $sToRender = $oTemplate->render(array( | |
| 205 | + 'aDocumentIds' => $aDocuments, | |
| 206 | + 'map' => $aMap, | |
| 207 | + )); | |
| 208 | + return $sToRender; | |
| 209 | + | |
| 210 | + print "<pre>"; | |
| 211 | + foreach ($aMap as $k => $v) { | |
| 212 | + print $v['fieldset']->getName() . "\n"; | |
| 213 | + foreach ($v['fields'] as $k => $aField) { | |
| 214 | + print $aField['field']->getName() . ": "; | |
| 215 | + foreach ($aField['values'] as $document_id => $sValue) { | |
| 216 | + print "$document_id => $sValue"; | |
| 217 | + } | |
| 218 | + print "\n"; | |
| 197 | 219 | } |
| 198 | - $iDocumentCount++; | |
| 220 | + print "\n\n"; | |
| 199 | 221 | } |
| 222 | + exit(0); | |
| 223 | + | |
| 200 | 224 | |
| 201 | 225 | $oTemplating =& KTTemplating::getSingleton(); |
| 202 | 226 | $oTemplate = $oTemplating->loadTemplate('ktcore/document_specific_metadata'); | ... | ... |
templates/ktcore/document_specific_metadata.smarty
| 1 | -<table class="prettysw" cellpadding="0" cellspacing="0"> | |
| 2 | -<caption colspan="{$map|count}"><b>Type Specific Meta Data</b></caption> | |
| 3 | -{ foreach key=k item=values from=$map } | |
| 4 | -<tr> | |
| 5 | - <th>{$k}</th> | |
| 6 | - { foreach item=v from=$values } | |
| 7 | - { cycle values="odd,compare" name=$k assign="class" } | |
| 8 | - <td class="{$class}" style="width: 10em">{$v|default:" "}</td> | |
| 9 | - { /foreach } | |
| 10 | -</tr> | |
| 11 | -{ /foreach } | |
| 12 | -</table> | |
| 13 | - | |
| 14 | -{ if $editable } | |
| 15 | -{$editable} | |
| 16 | -{ /if } | |
| 1 | +{foreach key=fieldset_id item=fieldset_info from=$map} | |
| 2 | + {assign var=fieldset value=$fieldset_info.fieldset} | |
| 3 | + <fieldset> | |
| 4 | + <legend>{$fieldset->getName()}</legend> | |
| 17 | 5 | |
| 6 | + <table class="prettysw" cellpadding="0" cellspacing="0"> | |
| 7 | + {foreach key=field_id item=field_info from=$fieldset_info.fields} | |
| 8 | + <tr> | |
| 9 | + {assign var=field value=$field_info.field} | |
| 10 | + <th>{$field->getName()}</th> | |
| 11 | + {assign var=values value=$field_info.values} | |
| 12 | + {foreach item=iDocumentId from=$aDocumentIds} | |
| 13 | + <td>{$values.$iDocumentId}</td> | |
| 14 | + {/foreach} | |
| 15 | + </tr> | |
| 16 | + {/foreach} | |
| 17 | + </table> | |
| 18 | + </fieldset> | |
| 19 | +{/foreach} | ... | ... |