Commit 2f7e57f6 authored by Penny Leach's avatar Penny Leach
Browse files

Leap importer: fixed the default fallback import strategy a bit



Since the blog is the default fallback importer, make it be aware of
selections and import them as blogs, rather than blogposts.

It's still necessary to have a strategy for importing these entries as
blogposts as well, in case some of the child entries have a higher
weighted strategy as the fallback, because in that case, they'll be
imported using that strategy and the selection would be lost.
Signed-off-by: default avatarPenny Leach <penny@mjollnir.org>
parent 2631e3b2
......@@ -64,27 +64,42 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer) {
$strategies = array();
if (PluginImportLeap::is_rdf_type($entry, $importer, 'selection')
&& PluginImportLeap::is_correct_category_scheme($entry, $importer, 'selection_type', 'Blog')) {
if (PluginImportLeap::is_rdf_type($entry, $importer, 'selection')) {
if (PluginImportLeap::is_correct_category_scheme($entry, $importer, 'selection_type', 'Blog')) {
$score = 100;
} else {
// the blog plugin can either fall back to importing single entries
// or handle the case where things are a selection that have no other strategies either.
// however, in the case where the otherrequiredentries for the selection have a higher strategy elsewhere,
// we need to still fallback to importing a selection post as a blog post by itself, to avoid dataloss.
$score = 20; // other things *can* be imported as blogs
}
$otherrequiredentries = array();
// Get entries that this blog feels are a part of it
// 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'])) {
$otherrequiredentries[] = (string)$link['href'];
}
}
// TODO: Get entries that feel they should be a part of this blog.
// TODO: Get entries that feel they should be a part of this blog/selection
// We can compare the lists and perhaps warn if they're different
// $otherentries = $importer->xml->xpath('//a:feed/a:entry/a:link[@rel="leap:is_part_of" and @href="' . $entryid . '"]/../a:id');
$otherrequiredentries = array_unique($otherrequiredentries);
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_BLOG,
'score' => 100,
'score' => $score,
'other_required_entries' => $otherrequiredentries,
);
if ($score == 20) {
$strategies[] = array(
'strategy' => self::STRATEGY_IMPORT_AS_ENTRY,
'score' => 10,
'other_required_entries' => array(),
);
}
}
else {
// The blog can import any entry as a literal blog post
......
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