/** * @see MetadataDataObjectAdapter::injectMetadataIntoDataObject() * @param $metadataDescription MetadataDescription * @param $dataObject Citation * @param $replace boolean whether existing meta-data should be replaced * @return DataObject */ function &injectMetadataIntoDataObject(&$metadataDescription, &$dataObject, $replace) { // Did we get an existing citation object or should we create a new one? if (is_null($dataObject)) { import('citation.Citation'); $dataObject = new Citation(); } // Add new meta-data statements to the citation. Add the schema // name space to each property name so that it becomes unique // across schemas. $metadataSchemaNamespace = $this->getMetadataNamespace(); $nullVar = null; foreach ($metadataDescription->getPropertyNames() as $propertyName) { $dataObjectKey = $metadataSchemaNamespace . ':' . $propertyName; if ($metadataDescription->hasStatement($propertyName)) { // Directly retrieve the internal data so that we don't // have to care about cardinality and translation. $value =& $metadataDescription->getData($propertyName); if (in_array($propertyName, array('person-group[@person-group-type="author"]', 'person-group[@person-group-type="editor"]'))) { // Convert MetadataDescription objects to simple key/value arrays. assert(is_array($value)); foreach ($value as $key => $nameComposite) { assert(is_a($nameComposite, 'MetadataDescription')); $value[$key] =& $nameComposite->getAllData(); } } $dataObject->setData($dataObjectKey, $value); unset($value); } elseif ($replace && $dataObject->hasData($dataObjectKey)) { // Delete existing property data $dataObject->setData($dataObjectKey, $nullVar); } } return $dataObject; }
/** * @see MetadataDataObjectAdapter::injectMetadataIntoDataObject() * @param $metadataDescription MetadataDescription * @param $dataObject Citation * @param $replace boolean whether existing meta-data should be replaced * @return DataObject */ function &injectMetadataIntoDataObject(&$metadataDescription, &$dataObject, $replace) { // Did we get an existing citation object or should we create a new one? if (is_null($dataObject)) { import('lib.pkp.classes.citation.Citation'); $dataObject = new Citation(); } // Add new meta-data statements to the citation. Add the schema // name space to each property name so that it becomes unique // across schemas. $metadataSchemaNamespace = $this->getMetadataNamespace(); $nullVar = null; foreach ($metadataDescription->getPropertyNames() as $propertyName) { $dataObjectKey = $metadataSchemaNamespace . ':' . $propertyName; if ($metadataDescription->hasStatement($propertyName)) { // Directly retrieve the internal data so that we don't // have to care about cardinality and translation. $value =& $metadataDescription->getData($propertyName); if (in_array($propertyName, array('person-group[@person-group-type="author"]', 'person-group[@person-group-type="editor"]'))) { assert(is_array($value)); // Dereference the value to make sure that we don't destroy // the original MetadataDescription. $tmpValue = $value; unset($value); $value =& $tmpValue; // Convert MetadataDescription objects to simple key/value arrays. foreach ($value as $key => $name) { if (is_a($name, 'MetadataDescription')) { // A name can either be a full name description... $value[$key] =& $name->getAllData(); } else { // ...or an 'et-al' string. assert($name == PERSON_STRING_FILTER_ETAL); // No need to change the value encoding. } } } $dataObject->setData($dataObjectKey, $value); unset($value); } elseif ($replace && $dataObject->hasData($dataObjectKey)) { // Delete existing property data $dataObject->setData($dataObjectKey, $nullVar); } } return $dataObject; }