Beispiel #1
0
 /**
  * Take a structured meta-data statement and transform it into a
  * plain text value that can be displayed to the end-user.
  *
  * @param $property MetadataProperty
  * @param $value mixed
  * @return string
  */
 function _getStringValueFromMetadataStatement(&$property, &$value)
 {
     if ($property->getCardinality() == METADATA_PROPERTY_CARDINALITY_MANY && !empty($value)) {
         $allowedTypes = $property->getAllowedTypes();
         if (isset($allowedTypes[METADATA_PROPERTY_TYPE_COMPOSITE])) {
             // We currently only can transform composite
             // name arrays to strings.
             $allowedAssocTypes = $allowedTypes[METADATA_PROPERTY_TYPE_COMPOSITE];
             assert(in_array(ASSOC_TYPE_AUTHOR, $allowedAssocTypes) || in_array(ASSOC_TYPE_EDITOR, $allowedAssocTypes));
             import('lib.pkp.plugins.metadata.nlm30.filter.Nlm30NameSchemaPersonStringFilter');
             $personStringFilter = new Nlm30NameSchemaPersonStringFilter(PERSON_STRING_FILTER_MULTIPLE);
             assert($personStringFilter->supportsAsInput($value));
             $stringValue = $personStringFilter->execute($value);
         } else {
             // We currently can't transform properties of
             // cardinality "many" to strings.
             assert(is_array($value) && count($value) <= 1);
             $stringValue = $value[0];
         }
     } else {
         $stringValue = (string) $value;
     }
     return $stringValue;
 }