function annowf_clone_get_family($post_id) { $ancestors = annowf_clone_get_ancestors($post_id); $children = annowf_clone_get_children($post_id); return array_unique(array_merge($ancestors, $children)); }
/** * Generate the Front portion of an article XML * * @param postObject $article Article to generate the XML for. * @return string XML generated */ private function xml_front($article) { // Journal Title $journal_title = cfct_get_option('journal_name'); if (!empty($journal_title)) { $journal_title_xml = '<journal-title-group> <journal-title>' . esc_html($journal_title) . '</journal-title> </journal-title-group>'; } else { $journal_title_xml = ''; } // Journal ID $journal_id = cfct_get_option('journal_id'); if (!empty($journal_id)) { $journal_id_type = cfct_get_option('journal_id_type'); if (!empty($journal_id_type)) { $journal_id_type_xml = ' journal-id-type="' . esc_attr($journal_id_type) . '"'; } else { $journal_id_type_xml = ''; } $journal_id_xml = '<journal-id' . $journal_id_type_xml . '>' . esc_html($journal_id) . '</journal-id>'; } else { $journal_id_xml = ''; } // Publisher ISSN $pub_issn = cfct_get_option('publisher_issn'); if (!empty($pub_issn)) { $pub_issn_xml = '<issn pub-type="epub">' . esc_html($pub_issn) . '</issn>'; } else { $pub_issn_xml = ''; } // Abstract $abstract = $article->post_excerpt; if (!empty($abstract)) { $abstract_xml = ' <abstract>' . $abstract . '</abstract>'; } else { $abstract_xml = ''; } // Funding Statement $funding = get_post_meta($article->ID, '_anno_funding', true); if (!empty($funding)) { $funding_xml = '<funding-group> <funding-statement>' . esc_html($funding) . '</funding-statement> </funding-group>'; } else { $funding_xml = ''; } // DOI $doi = get_post_meta($article->ID, '_anno_doi', true); if (!empty($doi)) { $doi_xml = '<article-id pub-id-type="doi">' . esc_html($doi) . '</article-id>'; } else { $doi_xml = ''; } // Article category. Theoretically, there can only be one! $cats = wp_get_object_terms($article->ID, 'article_category'); if (!empty($cats) && is_array($cats)) { $category = get_category($cats[0]); if (!empty($category)) { $category_xml = '<article-categories> <subj-group> <subject>' . esc_html($category->name) . '</subject> </subj-group> </article-categories>'; } else { $category_xml = ''; } } else { $category_xml = ''; } // Article Tags $tags = wp_get_object_terms($article->ID, 'article_tag'); if (!empty($tags) && is_array($tags)) { $tag_xml = '<kwd-group kwd-group-type="simple">'; foreach ($tags as $tag) { $tag = get_term($tag, 'article_tag'); $tag_xml .= '<kwd>' . esc_html($tag->name) . '</kwd>'; } $tag_xml .= ' </kwd-group>'; } else { $tag_xml = ''; } // Article title/subtitle $subtitle = get_post_meta($article->ID, '_anno_subtitle', true); $title_xml = '<title-group>'; if (!empty($article->post_title) || !empty($subtitle)) { $title_xml = '<title-group>'; if (!empty($article->post_title)) { $title_xml .= ' <article-title>' . esc_html($article->post_title) . '</article-title>'; } else { $title_xml .= ' <article-title />'; } if (!empty($subtitle)) { $title_xml .= ' <subtitle>' . esc_html($subtitle) . '</subtitle>'; } } $title_xml .= ' </title-group>'; // Publisher info $pub_name = cfct_get_option('publisher_name'); $pub_loc = cfct_get_option('publisher_location'); if (!empty($pub_name) || !empty($pub_loc)) { $publisher_xml = '<publisher>'; if (!empty($pub_name)) { $publisher_xml .= ' <publisher-name>' . esc_html($pub_name) . '</publisher-name>'; } if (!empty($pub_loc)) { $publisher_xml .= ' <publisher-loc>' . esc_html($pub_loc) . '</publisher-loc>'; } $publisher_xml .= ' </publisher>'; } else { $publisher_xml = ''; } $pub_date_xml = $this->xml_pubdate($article->post_date); // Authors $authors = get_post_meta($article->ID, '_anno_author_snapshot', true); if (!empty($authors) && is_array($authors)) { $author_xml = '<contrib-group>'; foreach ($authors as $author) { $author_xml .= ' <contrib>'; if (isset($author['surname']) && !empty($author['surname']) || isset($author['given_names']) && !empty($author['given_names']) || isset($author['prefix']) && !empty($author['prefix']) || isset($author['suffix']) && !empty($author['suffix'])) { $author_xml .= ' <name>'; if (isset($author['surname']) && !empty($author['surname'])) { $author_xml .= ' <surname>' . esc_html($author['surname']) . '</surname>'; } if (isset($author['given_names']) && !empty($author['given_names'])) { $author_xml .= ' <given-names>' . esc_html($author['given_names']) . '</given-names>'; } if (isset($author['prefix']) && !empty($author['prefix'])) { $author_xml .= ' <prefix>' . esc_html($author['prefix']) . '</prefix>'; } if (isset($author['suffix']) && !empty($author['suffix'])) { $author_xml .= ' <suffix>' . esc_html($author['suffix']) . '</suffix>'; } $author_xml .= ' </name>'; } // Affiliation legacy support if (!empty($author['affiliation']) || !empty($author['institution'])) { $author_xml .= ' <aff>'; if (!empty($author['affiliation'])) { $author_xml .= esc_html($author['affiliation']); } if (!empty($author['institution'])) { $author_xml .= '<institution>' . esc_html($author['institution']) . '</institution>'; } $author_xml .= '</aff>'; } if (isset($author['bio']) && !empty($author['bio'])) { $author_xml .= ' <bio><p>' . esc_html($author['bio']) . '</p></bio>'; } if (isset($author['link']) && !empty($author['link'])) { $author_xml .= ' <ext-link ext-link-type="uri" xlink:href="' . esc_url($author['link']) . '">' . esc_html($author['link']) . '</ext-link>'; } $author_xml .= ' </contrib>'; } $author_xml .= ' </contrib-group>'; } // Related Articles $related_xml = ''; if (anno_workflow_enabled()) { $related_articles = annowf_clone_get_ancestors($article->ID); } if (!empty($related_articles) && is_array($related_articles)) { foreach ($related_articles as $related_article_id) { $related_article = get_post($related_article_id); if (!empty($related_article) && $related_article->post_status == 'publish') { $related_xml .= '<related-article id="' . esc_attr('a' . $related_article->ID) . '" related-article-type="companion" ext-link-type="uri" xlink:href="' . esc_attr(get_permalink($related_article_id)) . '" '; $related_doi = get_post_meta($related_article_id, '_anno_doi', true); if (!empty($related_doi)) { $related_xml .= 'elocation-id="' . esc_attr($related_doi) . '" '; } // Queried for above if (!empty($journal_id)) { $related_xml .= 'journal_id="' . esc_attr($journal_id) . '" '; } // Queried for above if (!empty($journal_id_type)) { $related_xml .= 'journal_id_type="' . esc_attr($journal_id_type) . '" '; } $related_xml .= ' />'; } } } return '<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "journalpublishing3.dtd"> <article article-type="research-article" xml:lang="en" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <?origin annotum?> <front> <journal-meta> ' . $journal_id_xml . ' ' . $journal_title_xml . ' ' . $pub_issn_xml . ' ' . $publisher_xml . ' </journal-meta> <article-meta> ' . $doi_xml . ' ' . $category_xml . ' ' . $title_xml . ' ' . $author_xml . ' ' . $pub_date_xml . ' ' . $abstract_xml . ' ' . $tag_xml . ' ' . $funding_xml . ' ' . $related_xml . ' </article-meta> </front>'; }