Commit cad1c37e authored by Adrian Schlegel's avatar Adrian Schlegel
Browse files

added capability to import publications as defined in leap2a version 2010-07


Signed-off-by: default avatarAdrian Schlegel <adrian@liip.ch>
parent b585c6c1
......@@ -102,6 +102,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
$isactivity = PluginImportLeap::is_rdf_type($entry, $importer, 'activity');
$isaffiliation = PluginImportLeap::is_rdf_type($entry, $importer, 'affiliation');
$isresource = PluginImportLeap::is_rdf_type($entry, $importer, 'resource');
$ispublication = PluginImportLeap::is_rdf_type($entry, $importer, 'publication');
// Goals, cover letter & interests
if ($isentry && $correctplugintype) {
......@@ -162,7 +163,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
// Books
$other_required_entries = array();
if (($isresource || $isentry) && PluginImportLeap::is_correct_category_scheme($entry, $importer, 'resource_type', 'Printed')) {
if (($ispublication || $isresource || $isentry) && PluginImportLeap::is_correct_category_scheme($entry, $importer, 'resource_type', 'Printed')) {
// If it exists, the related achievement will be the user's role in
// relation to the book
foreach ($entry->link as $link) {
......@@ -323,6 +324,14 @@ class LeapImportResume extends LeapImportArtefactPlugin {
$contribution = $role->title;
$description = PluginImportLeap::get_entry_content($role, $importer);
}
// check if the import is of the version leap2a 2010-07. If it is then override the contribution and description
if($importer->get_leap2a_namespace() == PluginImportLeap::NS_LEAP) {
$myrole = PluginImportLeap::get_leap_myrole($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
if($myrole) {
$contribution = $myrole;
}
$description = PluginImportLeap::get_entry_content($entry, $importer);
}
$values = array(
'date' => $enddate,
......
......@@ -1143,6 +1143,28 @@ class PluginImportLeap extends PluginImport {
return $dates;
}
/**
* Look for a leap2:myrole element that is part of an entry (if any) and
* return the value
*
*
* @param SimpleXMLElement $entry The element containing the date
* @param array $namespaces array of namespaces @see PluginImportLeap::namespaces
* @param string $ns namespace URL which is used as a key in the $namespaces array
*
* @return string
*
* Spec reference: http://wiki.leapspecs.org/2A/literals#myrole
*/
public static function get_leap_myrole(SimpleXMLElement $entry, $namespaces, $ns) {
$myrole = $entry->xpath($namespaces[$ns].':myrole');
// we only expect one role
if($myrole[0]) {
return $myrole[0];
}
return '';
}
/**
* Waffer thin helper to grab all attributes in a namespace.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment