Commit cf6eab67 authored by Penny Leach's avatar Penny Leach
Browse files

Merge remote branch 'public/leap2aupdates'

Conflicts:
	htdocs/artefact/file/blocktype/filedownload/theme/raw/filedownload.tpl

This merge had a conflict with some theme changes by evonne disagreeing
with what I had changed, removing WWWROOT from the file download
template.  All leap2 related stuff merged clean
parents 98bef197 1547164e
......@@ -78,7 +78,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
// Get entries that this blog/selection feels are a part of it
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'has_part') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'has_part') && isset($link['href'])) {
$otherrequiredentries[] = (string)$link['href'];
}
}
......@@ -181,23 +181,14 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
if (!isset($blogpostentry->link)) {
continue;
}
$blogpost = null;
foreach ($blogpostentry->link as $blogpostlink) {
$blogpost = null;
if ($importer->curie_equals($blogpostlink['rel'], '', 'enclosure') && isset($blogpostlink['href'])) {
if (!$blogpost) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id);
$blogpost = new ArtefactTypeBlogPost($artefactids[0]);
}
$importer->trace("Attaching file $blogpostlink[href] to blog post $blogpostentry->id", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostlink['href']);
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else { // it may be just an attached file, with no Leap2A element in its own right ....
if ($id = self::attach_linked_file($blogpostentry, $blogpostlink, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$blogpostlink['href']][] = $id;
}
}
if (!$blogpost) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id);
$blogpost = new ArtefactTypeBlogPost($artefactids[0]);
}
if ($id = $importer->create_attachment($entry, $blogpostlink, $blogpost)) {
$newartefactmapping[$link['href']][] = $id;
}
if ($blogpost) {
$blogpost->commit();
......@@ -215,15 +206,8 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
$blogpost = new ArtefactTypeBlogPost($blogpostids[0]);
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else {
if ($id = self::attach_linked_file($entry, $link, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$link['href']][] = $id;
}
}
if ($id = $importer->create_attachment($entry, $link, $blogpost)) {
$newartefactmapping[$link['href']][] = $id;
}
}
$blogpost->commit();
......@@ -320,7 +304,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
$blogpost->set('title', (string)$entry->title);
// If the entry has out of line content, we import that separately as a
// file and set the content to refer to it
if (isset($entry->content['src']) && isset($entry->content['type'])) {
if (LeapImportFile::is_file($entry, $importer)) {
$file = LeapImportFile::create_file($entry, $importer);
$createdartefacts[] = $file->get('id');
......
......@@ -90,7 +90,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
// Check that the entry 'reflects_on' something
$otherentries = array();
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'reflects_on') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'reflects_on') && isset($link['href'])) {
$otherentries[] = (string)$link['href'];
}
}
......@@ -172,7 +172,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
*/
public static function get_referent_entryid(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'reflects_on') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'reflects_on') && isset($link['href'])) {
return (string)$link['href'];
}
}
......@@ -194,7 +194,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
*/
public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer) {
$comment = null;
$newartefacts = array(); // save any newly created extra ones (eg enclosures)
$referentid = self::get_referent_entryid($entry, $importer);
// Link artefact comments; view comments are done later
......@@ -206,21 +206,18 @@ class LeapImportComment extends LeapImportArtefactPlugin {
// Attachments
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (!$comment) {
$comment = self::get_comment_instance($entry, $importer);
}
$importer->trace("Attaching file $link[href] to comment $entry->id", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$link['href']);
if (isset($artefactids[0])) {
$comment->attach($artefactids[0]);
}
if (!$comment) {
$comment = self::get_comment_instance($entry, $importer);
}
if ($id = $importer->create_attachment($entry, $link, $comment)) {
$newartefacts[] = $id;
}
}
if ($comment) {
$comment->commit();
}
return $newartefacts;
}
/**
......
{foreach $files file}
<div title="{$file.title}">
<div class="fl"><a href="{$WWWROOT}{$file.downloadurl}" target="_blank"><img src="{$file.iconsrc}" alt=""></a></div>
<div class="fl"><a href="{$file.downloadurl}" target="_blank"><img src="{$file.iconsrc}" alt=""></a></div>
<div style="margin-left: 40px;">
<h4><a href="{$file.downloadurl}" target="_blank">{$file.title|str_shorten_text:20}</a></h4>
{if $file.description}<p>{$file.description}</p>{/if}
......
......@@ -53,11 +53,11 @@ class LeapExportElementFile extends LeapExportElement {
public function assign_smarty_vars() {
parent::assign_smarty_vars();
$this->smarty->assign('summary', $this->artefact->get('description'));
$this->smarty->assign('contentsrc', $this->exporter->get('filedir') . $this->filename);
}
public function add_attachments() {
$this->filename = $this->exporter->add_attachment($this->artefact->get_path(), $this->artefact->get('title'));
$this->add_enclosure_link($this->filename);
}
public function get_content_type() {
......
......@@ -102,13 +102,30 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* if it's of rdf:type rdf:resource. This may be more strict than necessary
* - possibly just having the content ouf of line should be enough.
*
* In the 2010-07 version of Leap2A, an entry is *also* a file, if it's in an enclosure link.
* However, since we have to support BC, those might actually be entries too, so we have to check
* to see if what's in there is actually something that exists as a key in the array of entry ids.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a file
*/
private static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
return PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src']);
public static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
if (PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src'])) {
return true;
}
else {
// go through all the links and look for enclsures
$filesfound = 0;
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href']) && !$importer->entry_exists((string)$link['href'])) {
$filesfound++;
}
}
return ($filesfound == 1);
}
return false;
}
/**
......@@ -141,7 +158,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*/
private static function has_parent_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_part_of') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'is_part_of') && isset($link['href'])) {
$potentialfolder = $importer->get_entry_by_id((string)$link['href']);
if ($potentialfolder && self::is_folder($potentialfolder, $importer)) {
return true;
......@@ -169,7 +186,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// Get entries that this folder feels are a part of it
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'has_part') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'has_part') && isset($link['href'])) {
$child = $importer->get_entry_by_id((string)$link['href']);
if ($child) {
if (self::is_file($child, $importer) || self::is_folder($child, $importer)) {
......@@ -216,7 +233,20 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// This means that it could have UTF8 characters in it, and the PHP
// documentation doesn't sound hopeful that urldecode will work with
// UTF8 characters
$pathname = urldecode((string)$entry->content['src']);
$pathname = false;
if (isset($entry->content['src'])) {
$pathname = urldecode((string)$entry->content['src']);
} else {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href']) && !$importer->entry_exists((string)$link['href'])) {
$pathname = urldecode((string)$link['href']);
}
}
}
if (!$pathname) {
$importer->trace("WARNING: couldn't find a file for $entry->id ");
return;
}
// TODO: might want to make it easier to get at the directory where the import files are
$dir = dirname($importer->get('filename'));
......@@ -245,7 +275,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// This API sucks, but that's not my problem
if (!$id = ArtefactTypeFile::save_file($pathname, $data, $importer->get('usrobj'), true)) {
$importer->trace("WARNING: the file for entry $entry->id does not exist in the import (path={$entry->content['src']})");
$importer->trace("WARNING: the file for entry $entry->id does not exist in the import (path={$pathname})");
return;
}
......
......@@ -1612,10 +1612,10 @@ class ArtefactTypeProfileIcon extends ArtefactTypeImage {
class ArtefactTypeArchive extends ArtefactTypeFile {
private $archivetype;
private $handle;
private $info;
private $data = array();
protected $archivetype;
protected $handle;
protected $info;
protected $data = array();
public function __construct($id = 0, $data = null) {
parent::__construct($id, $data);
......
......@@ -50,9 +50,11 @@ class LeapExportElementInternal extends LeapExportElement {
public function assign_smarty_vars() {
$user = $this->get('exporter')->get('user');
$userid = $user->get('id');
$updated = get_record_sql('select '.db_format_tsfield('max(mtime)', 'mtime').' from {artefact} a join {artefact_installed_type} t on a.artefacttype = t.name where t.plugin = \'internal\'');
$this->smarty->assign('artefacttype', 'internal');
$this->smarty->assign('artefactplugin', 'internal');
$this->smarty->assign('title', display_name($user, $user));
$this->smarty->assign('updated', PluginExportLeap::format_rfc3339_date($updated->mtime));
// If this ID is changed, you'll have to change it in author.tpl too
$this->smarty->assign('id', 'portfolio:artefactinternal');
$this->smarty->assign('leaptype', $this->get_leap_type());
......
{include file="export:leap:entry.tpl" skipfooter=true}
{foreach from=$persondata item=entry}
<leap:persondata
<leap2:persondata
mahara:artefactplugin="{$entry->artefactplugin}"
mahara:artefacttype="{$entry->artefacttype}"
{if $entry->mahara}
leap:field="other" mahara:field="{$entry->field}"
leap2:field="other" mahara:field="{$entry->field}"
{else}
leap:field="{$entry->field}"
leap2:field="{$entry->field}"
{/if}
leap:label="{$entry->label}"
leap2:label="{$entry->label}"
{if $entry->service}
leap:service="{$entry->service}"
leap2:service="{$entry->service}"
{/if}
>{$entry->value}</leap:persondata>
>{$entry->value}</leap2:persondata>
{/foreach}
{if $spacialdata}
<leap:spatial>
<leap2:spatial>
{foreach from=$spacialdata item=entry}
<leap:{$entry->type} mahara:artefacttype="{$entry->artefacttype}"{if $entry->countrycode} leap:countrycode="{$entry->countrycode}"{/if}>{$entry->value}</leap:{$entry->type}>
<leap2:{$entry->type} mahara:artefacttype="{$entry->artefacttype}"{if $entry->countrycode} leap2:countrycode="{$entry->countrycode}"{/if}>{$entry->value}</leap2:{$entry->type}>
{/foreach}
</leap:spatial>
</leap2:spatial>
{/if}
{include file="export:leap:entryfooter.tpl"}
......@@ -227,6 +227,8 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
* to the author, if there is one
*/
public static function import_author_data(PluginImportLeap $importer, $persondataid) {
$namespaces = $importer->get_namespaces();
$ns = $namespaces[$importer->get_leap2a_namespace()];
if ($persondataid) {
// Grab all the leap:persondata elements and import them
$person = $importer->get_entry_by_id($persondataid);
......@@ -239,9 +241,9 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
}
// Most of the rest of the profile data comes from leap:persondata elements
$persondata = $person->xpath('leap:persondata');
$persondata = $person->xpath($ns.':persondata');
foreach ($persondata as $item) {
$leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
$leapattributes = PluginImportLeap::get_attributes($item, $importer->get_leap2a_namespace());
if (isset($leapattributes['field'])) {
self::import_persondata($importer, $item, $leapattributes);
......@@ -259,8 +261,8 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
self::import_namedata($importer, $persondata);
// People can have address info associated with them
$addressdata = $person->xpath('leap:spatial');
if (count($addressdata) == 1) {
$addressdata = $person->xpath($ns.':spatial');
if (is_array($addressdata) && count($addressdata) == 1) {
self::import_addressdata($importer, $addressdata[0]);
}
......@@ -456,7 +458,9 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
private static function import_addressdata(PluginImportLeap $importer, SimpleXMLElement $addressdata) {
// TODO: this xpath doesn't respect the namespace prefix - we should
// look it up from $importer->namespaces[NS_LEAP]
$addresslines = $addressdata->xpath('leap:addressline');
$namespaces = $importer->get_namespaces();
$ns = $namespaces[$importer->get_leap2a_namespace()];
$addresslines = $addressdata->xpath($ns.':addressline');
// We look for 'town' and 'city' deliberately, Mahara has
// separate fields for those. The rest get thrown in the
......@@ -483,11 +487,11 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
}
// Now deal with country
$country = $addressdata->xpath('leap:country');
$country = $addressdata->xpath($ns.':country');
if (count($country) == 1) {
$country = $country[0];
$leapattributes = PluginImportLeap::get_attributes($country, PluginImportLeap::NS_LEAP);
$leapattributes = PluginImportLeap::get_attributes($country, $importer->get_leap2a_namespace());
// Try using countrycode attribute first, but fall back to name if it's not present or
// doesn't represent a country
......@@ -520,7 +524,7 @@ class LeapImportInternal extends LeapImportArtefactPlugin {
);
foreach ($persondata as $item) {
$leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
$leapattributes = PluginImportLeap::get_attributes($item, $importer->get_leap2a_namespace());
if (isset($leapattributes['field'])) {
if (in_array($leapattributes['field'], array_keys($namefields))) {
// legal_given_name is allowed to occur any number of times
......
......@@ -135,7 +135,9 @@ class LeapExportElementResumeComposite extends LeapExportElement {
}
public function set_composites() {
$this->composites = get_records_array($this->artefact->get_other_table_name(), 'artefact', $this->artefact->get('id'));
$this->composites = get_records_sql_array('SELECT '.db_format_tsfield('a.mtime', 'mtime').', b.* FROM {artefact} a JOIN {'.$this->artefact->get_other_table_name().'} b
ON a.id = b.artefact
WHERE b.artefact = ?', array($this->artefact->get('id')));
}
public function get_leap_type() {
......@@ -270,6 +272,7 @@ class LeapExportElementResumeCompositeChildCertification extends LeapExportEleme
'end' => $record->date,
'title' => $record->title,
'content' => $record->description,
'updated' => PluginExportLeap::format_rfc3339_date($record->mtime),
);
}
......@@ -285,11 +288,12 @@ class LeapExportElementResumeCompositeChildMembership extends LeapExportElementR
'end' => $record->enddate,
'title' => $record->title,
'content' => $record->description,
'updated' => PluginExportLeap::format_rfc3339_date($record->mtime),
);
}
public function get_leap_type() {
return 'activity';
return 'affiliation';
}
}
......@@ -317,10 +321,12 @@ class LeapExportElementResumeCompositeChildEducationhistory extends LeapExportEl
$this->siblings = array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->institution,
'updated' => PluginExportLeap::format_rfc3339_date($this->originalrecord->mtime),
), 'organization', 'supports'),
'supports' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->qualtype,
'content' => $this->originalrecord->qualname,
'updated' => PluginExportLeap::format_rfc3339_date($this->originalrecord->mtime),
), 'achievement', 'is_supported_by')
);
}
......@@ -331,6 +337,7 @@ class LeapExportElementResumeCompositeChildEducationhistory extends LeapExportEl
'end' => $record->enddate,
'title' => $record->qualname,
'content' => $record->qualdescription,
'updated' => PluginExportLeap::format_rfc3339_date($record->mtime),
);
}
......@@ -354,6 +361,7 @@ class LeapExportElementResumeCompositeChildEmploymenthistory extends LeapExportE
$this->siblings = array(
'is_supported_by' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->employer,
'updated' => PluginExportLeap::format_rfc3339_date($this->originalrecord->mtime),
), 'organization', 'supports')
);
}
......@@ -364,6 +372,7 @@ class LeapExportElementResumeCompositeChildEmploymenthistory extends LeapExportE
'end' => $record->enddate,
'title' => $record->jobtitle,
'content' => $record->positiondescription,
'updated' => PluginExportLeap::format_rfc3339_date($record->mtime),
);
}
......@@ -380,26 +389,20 @@ class LeapExportElementResumeCompositeChildEmploymenthistory extends LeapExportE
));
}
}
class LeapExportElementResumeCompositeChildBook extends LeapExportElementResumeCompositeChildWithSiblings {
public function ensure_siblings() {
$this->siblings = array(
'related' => new LeapExportElementResumeCompositeSibling($this->parentartefact, $this->exporter, $this, array(
'title' => $this->originalrecord->contribution,
'content' => $this->originalrecord->description,
), 'achievement', 'related')
);
}
class LeapExportElementResumeCompositeChildBook extends LeapExportElementResumeCompositeChild {
public function record_to_entrydata($record) {
return array(
'end' => $record->date,
'title' => $record->title,
'myrole' => $record->contribution,
'content' => $record->description,
'updated' => PluginExportLeap::format_rfc3339_date($record->mtime),
);
}
public function get_leap_type() {
return 'resource';
return 'publication';
}
public function get_categories() {
......
{include file="export:leap:entry.tpl" skipfooter=true}
{if $start} <leap:date leap:point="start" leap:label="{$start}"></leap:date>
{if $myrole} <leap2:myrole>{$myrole}</leap2:myrole>
{/if}
{if $end} <leap:date leap:point="end" leap:label="{$end}"></leap:date>
{if $start} <leap2:date leap2:point="start" leap2:label="{$start}"></leap2:date>
{/if}
{if $end} <leap2:date leap2:point="end" leap2:label="{$end}"></leap2:date>
{/if}
{include file="export:leap:entryfooter.tpl"}
......@@ -100,7 +100,9 @@ class LeapImportResume extends LeapImportArtefactPlugin {
$isability = PluginImportLeap::is_rdf_type($entry, $importer, 'ability');
$isachievement = PluginImportLeap::is_rdf_type($entry, $importer, 'achievement');
$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) {
......@@ -161,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) {
......@@ -190,7 +192,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
// the qualification the user gained in relation to this entry
foreach ($entry->link as $link) {
if (!isset($other_required_entries['achievement'])
&& $importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'supports') && isset($link['href'])) {
&& $importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'supports') && isset($link['href'])) {
if ($potentialqualification = $importer->get_entry_by_id((string)$link['href'])) {
if (PluginImportLeap::is_rdf_type($potentialqualification, $importer, 'achievement')) {
// We have a related achievement!
......@@ -214,7 +216,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
// Professional Membership
$correctmaharatype = count($entry->xpath('mahara:artefactplugin[@mahara:plugin="resume" and @mahara:type="pseudo:membership"]')) == 1;
if ($isactivity && $correctmaharatype) {
if (($isactivity && $correctmaharatype) || $isaffiliation) {
return array(array(
'strategy' => self::STRATEGY_IMPORT_AS_MEMBERSHIP,
'score' => 100,
......@@ -280,7 +282,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
}
break;
case self::STRATEGY_IMPORT_AS_ACHIEVEMENT:
$dates = PluginImportLeap::get_leap_dates($entry);
$dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
$values = array(
......@@ -292,7 +294,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
ArtefactTypeResumeComposite::ensure_composite_value($values, 'certification', $importer->get('usr'));
break;
case self::STRATEGY_IMPORT_AS_EMPLOYMENT:
$dates = PluginImportLeap::get_leap_dates($entry);
$dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
$startdate = (isset($dates['start'])) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
......@@ -313,7 +315,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
ArtefactTypeResumeComposite::ensure_composite_value($values, 'employmenthistory', $importer->get('usr'));
break;
case self::STRATEGY_IMPORT_AS_BOOK:
$dates = PluginImportLeap::get_leap_dates($entry);
$dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
$contribution = $description = '';
......@@ -322,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,
......@@ -333,7 +343,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
ArtefactTypeResumeComposite::ensure_composite_value($values, 'book', $importer->get('usr'));
break;
case self::STRATEGY_IMPORT_AS_EDUCATION:
$dates = PluginImportLeap::get_leap_dates($entry);
$dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
$startdate = (isset($dates['start'])) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
......@@ -366,7 +376,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
ArtefactTypeResumeComposite::ensure_composite_value($values, 'educationhistory', $importer->get('usr'));
break;
case self::STRATEGY_IMPORT_AS_MEMBERSHIP:
$dates = PluginImportLeap::get_leap_dates($entry);
$dates = PluginImportLeap::get_leap_dates($entry, $importer->get_namespaces(), $importer->get_leap2a_namespace());
$startdate = (isset($dates['start'])) ? self::convert_leap_date_to_resume_date($dates['start']) : '';
$enddate = (isset($dates['end'])) ? self::convert_leap_date_to_resume_date($dates['end']) : '';
......@@ -397,14 +407,16 @@ class LeapImportResume extends LeapImportArtefactPlugin {
$composites = array();
$person = $importer->get_entry_by_id($persondataid);
$persondata = $person->xpath('leap:persondata');
$namespaces = $importer->get_namespaces();
$ns = $importer->get_leap2a_namespace();
$persondata = $person->xpath($namespaces[$ns].':persondata');
foreach ($persondata as $item) {
$leapattributes = PluginImportLeap::get_attributes($item, PluginImportLeap::NS_LEAP);
$leapattributes = PluginImportLeap::get_attributes($item, $ns);
if (!isset($leapattributes['field'])) {
// 'Field' is required
// http://wiki.cetis.ac.uk/2009-03/Leap2A_personal_data#field
$importer->trace('WARNING: persondata element did not have leap:field attribute');
$importer->trace('WARNING: persondata element did not have leap2:field attribute');
continue;
}
......@@ -491,7 +503,7 @@ class LeapImportResume extends LeapImportArtefactPlugin {
* @return string The ID of the organization if there is one, else an empty string