Commit 85f65d1c authored by Penny Leach's avatar Penny Leach
Browse files

leap2a #528423 changed the structured content replacement to deal with attachments



This is the second part of the fix for this bug.
Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent 211086a0
......@@ -188,7 +188,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
} 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)$entry->id][] = $id;
$newartefactmapping[(string)$blogpostlink['href']][] = $id;
}
}
}
......
......@@ -817,7 +817,8 @@ class PluginImportLeap extends PluginImport {
* @return boolean Whether it's worth checking in more detail
*/
private function artefact_reference_quickcheck($field) {
return (false !== strpos($field, 'rel="has_part"'))
return (false !== strpos($field, 'rel="leap:has_part"')
|| false !== strpos($field, 'rel="enclosure"'))
&& (
(false !== strpos($field, '<img'))
|| (false !== strpos($field, '<a'))
......@@ -831,7 +832,7 @@ class PluginImportLeap extends PluginImport {
* @return string The fixed field
*/
private function fix_artefact_reference($field) {
$match = '#<((img)|a)([^>]+)rel="has_part" href="portfolio:artefact([\d]+)"([^>]*)>#';
$match = '#<((img)|a)([^>]+)rel="(?:leap:has_part|enclosure)" (?:src|href)="([^"]+)"([^>]*)>#';
$field = preg_replace_callback($match,
array($this, '_fixref'),
$field);
......@@ -844,11 +845,11 @@ class PluginImportLeap extends PluginImport {
$basepath = get_mahara_install_subdirectory();
}
$artefacts = $this->get_artefactids_imported_by_entryid('portfolio:artefact' . $matches[4]);
$artefacts = $this->get_artefactids_imported_by_entryid($matches[4]);
if (is_null($artefacts) || count($artefacts) != 1) {
// This can happen if a leap2a xml file is uploaded that refers to
// files that (naturally) weren't uploaded with it.
log_debug("Warning: fixref was expecting one artefact to have been imported by entry portfolio:artefact{$matches[4]} but seems to have gotten " . count($artefacts));
log_debug("Warning: fixref was expecting one artefact to have been imported by entry {$matches[4]} but seems to have gotten " . count($artefacts));
return $matches[0];
}
return '<' . $matches[1] . $matches[3] . ($matches[1] == 'img' ? 'src' : 'href') . '="'
......
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