From 4e682ecbe20778ce10160cd20de58ec07ee9bee7 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Mon, 27 Apr 2015 08:27:19 +0200 Subject: [PATCH] add more hooks for showing/editing attributes --- views/bootstrap/class.AddDocument.php | 16 +++++++++++++ views/bootstrap/class.EditDocument.php | 8 +++++++ views/bootstrap/class.EditFolder.php | 9 ++++++++ views/bootstrap/class.UpdateDocument.php | 9 ++++++++ views/bootstrap/class.ViewDocument.php | 29 ++++++++++++++++++++---- views/bootstrap/class.ViewFolder.php | 13 +++++++++-- 6 files changed, 77 insertions(+), 7 deletions(-) diff --git a/views/bootstrap/class.AddDocument.php b/views/bootstrap/class.AddDocument.php index 75154a09c..3cd74b1b7 100644 --- a/views/bootstrap/class.AddDocument.php +++ b/views/bootstrap/class.AddDocument.php @@ -149,12 +149,20 @@ $(document).ready(function() { $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_document, SeedDMS_Core_AttributeDefinition::objtype_all)); if($attrdefs) { foreach($attrdefs as $attrdef) { + $arr = $this->callHook('editDocumentAttribute', null, $attrdef); + if(is_array($arr)) { + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } else { ?> getName()); ?> printAttributeEditField($attrdef, '') ?> getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); if($attrdefs) { foreach($attrdefs as $attrdef) { + $arr = $this->callHook('editDocumentAttribute', null, $attrdef); + if(is_array($arr)) { + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } else { ?> getName()); ?> printAttributeEditField($attrdef, '', 'attributes_version') ?> callHook('editDocumentAttribute', $document, $attrdef); + if(is_array($arr)) { + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } else { ?> getName()); ?>: printAttributeEditField($attrdef, $document->getAttribute($attrdef)) ?> diff --git a/views/bootstrap/class.EditFolder.php b/views/bootstrap/class.EditFolder.php index 8d5d6a865..9a8d61f84 100644 --- a/views/bootstrap/class.EditFolder.php +++ b/views/bootstrap/class.EditFolder.php @@ -98,12 +98,21 @@ function checkForm() { if($attrdefs) { foreach($attrdefs as $attrdef) { + $arr = $this->callHook('folderEditAttribute', $folder, $attrdef); + if(is_array($arr)) { + echo $txt; + echo ""; + echo "".$arr[0].""; + echo "".$arr[1].""; + echo ""; + } else { ?> getName()); ?> printAttributeEditField($attrdef, $folder->getAttribute($attrdef)) ?> diff --git a/views/bootstrap/class.UpdateDocument.php b/views/bootstrap/class.UpdateDocument.php index 7969eb664..5b27a2fb5 100644 --- a/views/bootstrap/class.UpdateDocument.php +++ b/views/bootstrap/class.UpdateDocument.php @@ -202,12 +202,21 @@ function checkForm() $attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_documentcontent, SeedDMS_Core_AttributeDefinition::objtype_all)); if($attrdefs) { foreach($attrdefs as $attrdef) { + $arr = $this->callHook('editDocumentContentAttribute', null, $attrdef); + if(is_array($arr)) { + echo $txt; + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } else { ?> getName()); ?>: printAttributeEditField($attrdef, '') ?> getAttributes(); if($attributes) { foreach($attributes as $attribute) { - $this->printAttribute($attribute); + $arr = $this->callHook('showDocumentAttribute', $document, $attribute); + if(is_array($arr)) { + echo $txt; + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].""; + echo ""; + } else { + $this->printAttribute($attribute); + } } } ?> @@ -393,8 +402,13 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { $attributes = $latestContent->getAttributes(); if($attributes) { foreach($attributes as $attribute) { - $attrdef = $attribute->getAttributeDefinition(); - print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."
  • \n"; + $arr = $this->callHook('showDocumentContentAttribute', $latestcontent, $attribute); + if(is_array($arr)) { + print "
  • ".$arr[0].": ".$arr[1]."
  • \n"; + } else { + $attrdef = $attribute->getAttributeDefinition(); + print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."
  • \n"; + } } } print "\n"; @@ -998,8 +1012,13 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { $attributes = $version->getAttributes(); if($attributes) { foreach($attributes as $attribute) { - $attrdef = $attribute->getAttributeDefinition(); - print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."
  • \n"; + $arr = $this->callHook('showDocumentContentAttribute', $version, $attribute); + if(is_array($arr)) { + print "
  • ".$arr[0].": ".$arr[1]."
  • \n"; + } else { + $attrdef = $attribute->getAttributeDefinition(); + print "
  • ".htmlspecialchars($attrdef->getName()).": ".htmlspecialchars(implode(', ', $attribute->getValueAsArray()))."
  • \n"; + } } } print "\n"; diff --git a/views/bootstrap/class.ViewFolder.php b/views/bootstrap/class.ViewFolder.php index 263ac8c62..feed7f3bd 100644 --- a/views/bootstrap/class.ViewFolder.php +++ b/views/bootstrap/class.ViewFolder.php @@ -199,13 +199,22 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { $attributes = $folder->getAttributes(); if($attributes) { foreach($attributes as $attribute) { - $attrdef = $attribute->getAttributeDefinition(); + $arr = $this->callHook('showFolderAttribute', $folder, $attribute); + if(is_array($arr)) { + echo $txt; + echo ""; + echo "".$arr[0].":"; + echo "".$arr[1].":"; + echo ""; + } else { + $attrdef = $attribute->getAttributeDefinition(); ?> getName()); ?>: getValueAsArray())); ?> - \n";