Commit 7b8e9227 authored by Nigel McNie's avatar Nigel McNie
Browse files

Convert attachments to using the RDF standard rel="enclosure".



This is a one-way relationship to signify "attachments".

Read it on import, and while I was there, fixed the broken blog post
attachment importing.
Signed-off-by: default avatarNigel McNie <nigel@catalyst.net.nz>
parent 69f3d801
...@@ -42,7 +42,7 @@ class LeapExportElementBlogpost extends LeapExportElement { ...@@ -42,7 +42,7 @@ class LeapExportElementBlogpost extends LeapExportElement {
} }
foreach ($attachments as $attachment) { foreach ($attachments as $attachment) {
$f = artefact_instance_from_id($attachment); $f = artefact_instance_from_id($attachment);
$this->add_artefact_link($f, 'has_attachment'); $this->add_artefact_link($f, 'enclosure');
} }
} }
......
...@@ -142,16 +142,12 @@ class LeapImportBlog extends LeapImportArtefactPlugin { ...@@ -142,16 +142,12 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
foreach ($otherentries as $entryid) { foreach ($otherentries as $entryid) {
$blogpostentry = $importer->get_entry_by_id($entryid); $blogpostentry = $importer->get_entry_by_id($entryid);
// Get all attachments this blogpost things are attached to it // Get all attachments this blogpost things are attached to it
// TODO: get all entries that think they're attached to the blogpost. if (!isset($blogpostentry->link)) {
// I think we can only look for files, Mahara doesn't understand
// attaching something that isn't a file to a blogpost
if (!isset($blogpost->link)) {
continue; continue;
} }
foreach ($blogpostentry->link as $blogpostlink) { foreach ($blogpostentry->link as $blogpostlink) {
$blogpost = null; $blogpost = null;
if ($importer->curie_equals($blogpostlink['rel'], PluginImportLeap::NS_LEAP, 'has_attachment') && isset($blogpostlink['href'])) { if ($importer->curie_equals($blogpostlink['rel'], '', 'enclosure') && isset($blogpostlink['href'])) {
if (!$blogpost) { if (!$blogpost) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id); $artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id);
$blogpost = new ArtefactTypeBlogPost($artefactids[0]); $blogpost = new ArtefactTypeBlogPost($artefactids[0]);
......
...@@ -36,19 +36,6 @@ class LeapExportElementFile extends LeapExportElement { ...@@ -36,19 +36,6 @@ class LeapExportElementFile extends LeapExportElement {
private $filename; private $filename;
public function add_links() {
parent::add_links();
// Check for artefacts this file may be attached to
if (!$posts = get_records_array('artefact_attachment',
'attachment', $this->artefact->get('id'))) {
return;
}
foreach ($posts as $p) {
$post = artefact_instance_from_id($p->artefact);
$this->add_artefact_link($post, 'is_attachment_of');
}
}
public function get_leap_type() { public function get_leap_type() {
return 'resource'; return 'resource';
} }
......
...@@ -526,7 +526,7 @@ class LeapExportElement { ...@@ -526,7 +526,7 @@ class LeapExportElement {
* @param keyed array $extras any extra bits to go in (eg display_order => 1) * @param keyed array $extras any extra bits to go in (eg display_order => 1)
*/ */
public function add_generic_link($id, $rel, $extras=null) { public function add_generic_link($id, $rel, $extras=null) {
if (!in_array($rel, array('related', 'alternate'))) { if (!in_array($rel, array('related', 'alternate', 'enclosure'))) {
$rel = 'leap:' . $rel; $rel = 'leap:' . $rel;
} }
$link = array( $link = array(
......
Supports Markdown
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