public static function get_comment_instance(SimpleXMLElement $entry, PluginImportLeap $importer) { $artefactids = $importer->get_artefactids_imported_by_entryid((string) $entry->id); return new ArtefactTypeComment($artefactids[0]); }
/** * Checks to see if a blogpost had out-of-line content, and if it did, * attaches the generated file to it * * @param SimpleXMLElement $entry The entry to check * @param PluginImportLeap $importer The importer */ private static function setup_outoflinecontent_relationship(SimpleXMLElement $entry, PluginImportLeap $importer) { $artefactids = $importer->get_artefactids_imported_by_entryid((string) $entry->id); if (count($artefactids) == 2) { // In this case, a file was created as a result of // importing a blog entry with out-of-line content. We // attach the file to this post. $blogpost = new ArtefactTypeBlogPost($artefactids[0]); $blogpost->attach_file($artefactids[1]); $blogpost->commit(); } }
/** * Attach files to their resume composite * TODO: this is experimental and is not actually working correctly. * This may be due to the structure of the export for resume items or * due to this import function being wrong or both. */ public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries) { $newartefactmapping = array(); $class = false; switch ($strategy) { case self::STRATEGY_IMPORT_AS_ENTRY: case self::STRATEGY_IMPORT_AS_ABILITY: if ($strategy == self::STRATEGY_IMPORT_AS_ENTRY) { $types = array('careergoal', 'academicgoal', 'personalgoal', 'interest', 'coverletter'); } else { $types = array('workskill', 'academicskill', 'personalskill'); } // do stuff here break; case self::STRATEGY_IMPORT_AS_ACHIEVEMENT: $class = 'ArtefactTypeCertification'; break; case self::STRATEGY_IMPORT_AS_EMPLOYMENT: $class = 'ArtefactTypeEmploymenthistory'; break; case self::STRATEGY_IMPORT_AS_BOOK: $class = 'ArtefactTypeBook'; break; case self::STRATEGY_IMPORT_AS_EDUCATION: $class = 'ArtefactTypeEducationhistory'; break; case self::STRATEGY_IMPORT_AS_MEMBERSHIP: $class = 'ArtefactTypeMembership'; break; case self::STRATEGY_IMPORT_AS_SELECTION: // This space intentionally left blank break; default: throw new ImportException($importer, 'TODO: get_string: unknown strategy chosen for importing entry'); } foreach ($otherentries as $entryid) { $compositeentry = $importer->get_entry_by_id($entryid); $composite = null; foreach ($compositeentry->link as $compositelink) { if (class_exists($class)) { if (!$composite) { $artefactids = $importer->get_artefactids_imported_by_entryid((string) $compositeentry->id); $composite = new $class($artefactids[0], array('owner' => $importer->get('usr'))); } if ($id = $importer->create_attachment($entry, $compositelink, $composite)) { $newartefactmapping[$link['href']][] = $id; } if ($composite) { $composite->commit(); } } } } return $newartefactmapping; }
/** * Fix annotations to point to the right view. */ public static function setup_view_relationships_from_requests(PluginImportLeap $importer) { // Get all the annotations imported. if ($entry_requests = get_records_select_array('import_entry_requests', 'importid = ? AND entrytype = ?', array($importer->get('importertransport')->get('importid'), 'annotation'))) { foreach ($entry_requests as $entry_request) { $annotationids = $importer->get_artefactids_imported_by_entryid($entry_request->entryid); $annotation = new ArtefactTypeAnnotation($annotationids[0]); if (!$annotation->get('id')) { continue; } $annotation_entry = $importer->get_entry_by_id($entry_request->entryid); $view_entry_request = self::get_referent_entryid($annotation_entry, $importer); // Now see which view had this entryid. if ($viewid = $importer->get_viewid_imported_by_entryid($view_entry_request)) { // Set the view on the annotation. $annotation->set('view', $viewid); $annotation->commit(); } else { // Nothing to link this annotation to, so leave it in the temporary view. self::$savetempview = true; } } } }