コード例 #1
0
 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;
 }