show attributes according to context in [document|folder]ListRow()

This commit is contained in:
Uwe Steinmann 2016-08-03 13:23:10 +02:00
parent 50fa5a991c
commit 119f6430e6

View File

@ -1306,7 +1306,8 @@ $('#acceptkeywords').click(function(ev) {
*
* @param object $attribute attribute
*/
protected function printAttributeValue($attribute) { /* {{{ */
protected function printAttributeValue($attribute, $noecho=false) { /* {{{ */
$content = '';
$attrdef = $attribute->getAttributeDefinition();
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_url:
@ -1315,7 +1316,7 @@ $('#acceptkeywords').click(function(ev) {
foreach($attrs as $attr) {
$tmp[] = '<a href="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
echo implode('<br />', $tmp);
$content .= implode('<br />', $tmp);
break;
case SeedDMS_Core_AttributeDefinition::type_email:
$attrs = $attribute->getValueAsArray();
@ -1323,11 +1324,15 @@ $('#acceptkeywords').click(function(ev) {
foreach($attrs as $attr) {
$tmp[] = '<a mailto="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
echo implode('<br />', $tmp);
$content .= implode('<br />', $tmp);
break;
default:
echo htmlspecialchars(implode(', ', $attribute->getValueAsArray()));
$content .= htmlspecialchars(implode(', ', $attribute->getValueAsArray()));
}
if($noecho)
return $content;
else
echo $content;
} /* }}} */
/**
@ -2092,8 +2097,15 @@ $(document).ready( function() {
* @param object $document
* @param object $previewer
* @param boolean $skipcont set to true if embrasing tr shall be skipped
* @param integer $version set to a value != 0 for a specific version, otherwise
* the latest version will be used
* @param integer $context specifies the type of list. Can be any value
* of SeedDMS_Core_AttributeDefinitionGroup::show_xxx, though only
* show_list and show_ѕearchlist are useful. If the parameter is
* not set or 0, attributes will not be output at all.
* @return string html
*/
function documentListRow($document, $previewer, $skipcont=false, $version=0) { /* {{{ */
function documentListRow($document, $previewer, $skipcont=false, $version=0, $context=0) { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$showtree = $this->params['showtree'];
@ -2157,6 +2169,32 @@ $(document).ready( function() {
if($comment) {
$content .= "<br /><span style=\"font-size: 85%;\">".htmlspecialchars($comment)."</span>";
}
if($context) {
$attrdefgrps = $document->getParent()->getAttributeDefintionGroupList(true);
if($attrdefgrps) {
foreach($attrdefgrps as $attrdefgrp) {
$attrdefs = $attrdefgrp['group']->getAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_all, SeedDMS_Core_AttributeDefinition::objtype_document), $context);
if($attrdefs) {
$content .= "<br /><b>".htmlspecialchars($attrdefgrp['group']->getName())."</b><br />";
foreach($attrdefs as $attrdefarr) {
$attrdef = $attrdefarr['attrdef'];
$attribute = $document->getAttribute($attrdef);
if($attribute) {
$arr = $this->callHook('showDocumentAttribute', $document, $attribute, $context);
if(is_array($arr)) {
$content .= "".$arr[0].": ";
$content .= "".$arr[1]."<br />";
} else {
$content .= "".htmlspecialchars($attrdef->getName()).": ";
$content .= $this->printAttributeValue($attribute, true);
}
}
}
}
}
}
}
$content .= "</td>\n";
$content .= "<td nowrap>";
@ -2203,7 +2241,17 @@ $(document).ready( function() {
return $content;
} /* }}} */
function folderListRow($subFolder) { /* {{{ */
/**
* Return the HTML for a row in a list of folders
*
* @param object $subFolder folder to be listed
* @param integer $context specifies the type of list. Can be any value
* of SeedDMS_Core_AttributeDefinitionGroup::show_xxx, though only
* show_list and show_ѕearchlist are useful. If the parameter is
* not set or 0, attributes will not be output at all.
* @return string html
*/
function folderListRow($subFolder, $context=0) { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
// $folder = $this->params['folder'];
@ -2225,6 +2273,32 @@ $(document).ready( function() {
if($comment) {
$content .= "<br /><span style=\"font-size: 85%;\">".htmlspecialchars($comment)."</span>";
}
if($context) {
$attrdefgrps = $subFolder->getAttributeDefintionGroupList(true);
if($attrdefgrps) {
foreach($attrdefgrps as $attrdefgrp) {
$attrdefs = $attrdefgrp['group']->getAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_all, SeedDMS_Core_AttributeDefinition::objtype_folder), $context);
if($attrdefs) {
$content .= "<br /><b>".htmlspecialchars($attrdefgrp['group']->getName())."</b><br />";
foreach($attrdefs as $attrdefarr) {
$attrdef = $attrdefarr['attrdef'];
$attribute = $subFolder->getAttribute($attrdef);
if($attribute) {
$arr = $this->callHook('showFolderAttribute', $subFolder, $attribute, $context);
if(is_array($arr)) {
$content .= "".$arr[0].": ";
$content .= "".$arr[1]."<br />";
} else {
$content .= "".htmlspecialchars($attrdef->getName()).": ";
$content .= $this->printAttributeValue($attribute, true);
}
}
}
}
}
}
}
$content .= "</td>\n";
// $content .= "<td>".htmlspecialchars($owner->getFullName())."</td>";
$content .= "<td colspan=\"1\" nowrap><small>";