$publication->title = $title; if (!$publication->save()) { // unable to save continue; } } if (!$publication instanceof Publication) { // something went wrong continue; } $publication->bibtext_reference = $ref; $publication->pubtype = $type; // set forwarding $count++; if ($forward_to_edit) { $forward_url = "publications/edit/{$publication->getGUID()}"; } else { $forward_url = $publication->getURL(); } // start handling some custom fields // start/end page $pages = $entry->getPages(); if (is_array($pages)) { $publication->page_from = elgg_extract('0', $pages); $publication->page_to = elgg_extract('1', $pages); } else { $publication->page_from = $pages; } // authors $authors = $entry->getRawAuthors(); if (!empty($authors)) {
/** * Save book editors with a publication * * @param string $event the name of the event * @param string $type the type of the event * @param \Publication $entity supplied entity * * @return void */ public static function saveBookEditors($event, $type, $entity) { if (!$entity instanceof \Publication) { return; } // cleanup book editors $entity->deleteRelationships('book_editor'); unset($entity->book_editors); $supported_types = ['book', 'inbook', 'incollection', 'proceedings', 'inproceedings']; $type = get_input('type'); if (!in_array($type, $supported_types)) { return; } $book_editors_guids = get_input('book_editors'); $book_editors_order = get_input('book_editors_order'); // save book editors if (!empty($book_editors_guids)) { foreach ($book_editors_guids as $book_editor) { add_entity_relationship($entity->getGUID(), 'book_editor', $book_editor); } } $pbook_editors = implode(',', $book_editors_order); $entity->book_editors = $pbook_editors; $entity->save(); }