/** * The content of this block is now stored as an html artefact, but older versions stored * the content directly in the 'text' property of the block config. If this config has * 'text' but not 'artefactid', create an artefact. * * @param array $biconfig The block instance config * @param array $viewconfig The view config * @return BlockInstance The newly made block instance */ public static function import_create_blockinstance_leap(array $biconfig, array $viewconfig) { $configdata = $biconfig['config']; if (isset($configdata['text']) && !isset($configdata['artefactid'])) { $data = array('title' => $biconfig['title'], 'description' => $configdata['text'], 'license' => !empty($configdata['license']) ? $configdata['license'] : '', 'licensor' => !empty($configdata['licensor']) ? $configdata['licensor'] : '', 'licensorurl' => !empty($configdata['licensorurl']) ? $configdata['licensorurl'] : '', 'tags' => !empty($configdata['tags']) ? $configdata['tags'] : '', 'owner' => $viewconfig['owner']); $artefact = new ArtefactTypeHtml(0, $data); $artefact->commit(); $configdata['artefactid'] = $artefact->get('id'); unset($configdata['text']); } $bi = new BlockInstance(0, array('blocktype' => $biconfig['type'], 'configdata' => $configdata)); return $bi; }
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) { $artefactmapping = array(); $entrydata = self::get_entry_data_using_strategy($entry, $importer, $strategy, $otherentries); if (!empty($entrydata)) { switch ($entrydata['type']) { case 'introduction': $introduction = new ArtefactTypeIntroduction(0, array('owner' => $importer->get('usr'))); $introduction->set('title', $entrydata['content']['title']); $introduction->commit(); $artefactmapping[(string) $entry->id] = array($introduction->get('id')); break; case 'html': $note = new ArtefactTypeHtml(); $note->set('title', $entrydata['content']['title']); $note->set('description', $entrydata['content']['description']); $note->set('ctime', strtotime($entrydata['content']['ctime'])); $note->set('mtime', strtotime($entrydata['content']['mtime'])); $note->set('owner', $entrydata['owner']); $note->commit(); $artefactmapping[(string) $entry->id] = array($note->get('id')); // Check for note's attachments if (isset($entry->link)) { foreach ($entry->link as $link) { if ($id = $importer->create_attachment($entry, $link, $note)) { $artefactmapping[$link['href']][] = $id; } } $note->commit(); } break; default: $artefactmapping[(string) $entry->id] = array(self::create_artefact($importer, $entrydata['type'], $entrydata['content']['title'])); break; } } return $artefactmapping; }