extractMetadata(new \APP\plugins\metadata\dc11\schema\Dc11Schema()); $response = "\n"; foreach ($dcDescription->getProperties() as $propertyName => $property) { /** @var MetadataProperty $property */ if ($dcDescription->hasStatement($propertyName)) { if ($property->getTranslated()) { $values = $dcDescription->getStatementTranslations($propertyName); } else { $values = $dcDescription->getStatement($propertyName); } $response .= $this->formatElement($propertyName, $values, $property->getTranslated()); } } $response .= "\n"; return $response; } /** * Format XML for single DC element. * * @param string $propertyName * @param bool $multilingual optional */ public function formatElement($propertyName, $values, $multilingual = false) { if (!is_array($values)) { $values = [$values]; } // Translate the property name to XML syntax. $openingElement = str_replace(['[@', ']'], [' ',''], $propertyName); $closingElement = PKPString::regexp_replace('/\[@.*/', '', $propertyName); // Create the actual XML entry. $response = ''; foreach ($values as $key => $value) { if ($multilingual) { $key = str_replace('_', '-', $key); assert(is_array($value)); foreach ($value as $subValue) { if ($key == MetadataDescription::METADATA_DESCRIPTION_UNKNOWN_LOCALE) { $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($subValue) . "\n"; } else { $response .= "\t<{$openingElement} xml:lang=\"{$key}\">" . OAIUtils::prepOutput($subValue) . "\n"; } } } else { assert(is_scalar($value)); $response .= "\t<{$openingElement}>" . OAIUtils::prepOutput($value) . "\n"; } } return $response; } }