move printAttribute() into parent class

This commit is contained in:
Uwe Steinmann 2020-03-19 09:47:35 +01:00
parent 2c53286943
commit 9c3b34b41e
2 changed files with 49 additions and 38 deletions

View File

@ -1556,6 +1556,55 @@ $(document).ready(function() {
<?php
} /* }}} */
/**
* Output a single attribute in the document info section
*
* @param object $attribute attribute
*/
protected function printAttributeValue($attribute, $noecho=false) { /* {{{ */
$content = '';
$attrdef = $attribute->getAttributeDefinition();
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_url:
$attrs = $attribute->getValueAsArray();
$tmp = array();
foreach($attrs as $attr) {
$tmp[] = '<a href="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
$content .= implode('<br />', $tmp);
break;
case SeedDMS_Core_AttributeDefinition::type_email:
$attrs = $attribute->getValueAsArray();
$tmp = array();
foreach($attrs as $attr) {
$tmp[] = '<a mailto="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
$content .= implode('<br />', $tmp);
break;
default:
$content .= htmlspecialchars(implode(', ', $attribute->getValueAsArray()));
}
if($noecho)
return $content;
else
echo $content;
} /* }}} */
/**
* Output a single attribute in the document info section
*
* @param object $attribute attribute
*/
protected function printAttribute($attribute) { /* {{{ */
$attrdef = $attribute->getAttributeDefinition();
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td><?php $this->printAttributeValue($attribute); ?></td>
</tr>
<?php
} /* }}} */
function printAttributeEditField($attrdef, $attribute, $fieldname='attributes', $norequire=false) { /* {{{ */
echo self::getAttributeEditField($attrdef, $attribute, $fieldname, $norequire);
} /* }}} */

View File

@ -83,44 +83,6 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
}
} /* }}} */
/**
* Output a single attribute in the document info section
*
* @param object $attribute attribute
*/
protected function printAttribute($attribute) { /* {{{ */
$attrdef = $attribute->getAttributeDefinition();
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?>:</td>
<td>
<?php
switch($attrdef->getType()) {
case SeedDMS_Core_AttributeDefinition::type_url:
$attrs = $attribute->getValueAsArray();
$tmp = array();
foreach($attrs as $attr) {
$tmp[] = '<a href="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
echo implode('<br />', $tmp);
break;
case SeedDMS_Core_AttributeDefinition::type_email:
$attrs = $attribute->getValueAsArray();
$tmp = array();
foreach($attrs as $attr) {
$tmp[] = '<a mailto="'.htmlspecialchars($attr).'">'.htmlspecialchars($attr).'</a>';
}
echo implode('<br />', $tmp);
break;
default:
echo htmlspecialchars(implode(', ', $attribute->getValueAsArray()));
}
?>
</td>
</tr>
<?php
} /* }}} */
function documentListItem() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];