'%first_author%. %iso%.
%pmid_url% %pmcid_url% %doi_url%', "long" => '%authors%. %title%. %iso%.
%pmid_url% %pmcid_url% %doi_url%', "long_tt" => '%authors%. %title_tt%. %iso%.
%pmid_url% %pmcid_url% %doi_url%', "long_pdf" => '%authors%. %title%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %localpdf% %tweet%', "long_tt_pdf" => '%authors%. %title_tt%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %localpdf% %tweet%', "long_abstract" => '%authors%. %title%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %abstract% %abstractFr% %tweet%', "long_tt_abstract" => '%authors%. %title_tt%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %abstract% %abstractFr% %tweet%', "long_abstract_pdf" => '%authors%. %title%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %abstract% %abstractFr% %localpdf%', "long_tt_abstract_pdf" => '%authors%. %title_tt%. %iso%.
%pmid_url% %pmcid_url% %doi_url% %abstract% %abstractFr% %localpdf%', "vancouver" => '%vancouver%', "vancouver_links" => '%vancouver%
%pmid_url% %pmcid_url%', "npg" => '%authorsLimit3% %title_tt%. %npg_iso%.', "npg_full" => '%npg_full%', "npg_full_links" => '%npg_full% %pmid_url% %pmcid_url%', "gpnv_full" => '%gpnv_full%', // Add item one by one "authors" => '%authors%', "title" => '%title%', "year" => '%year%', "date" => '%month% %year%', "journal" => '%journal_title%', "journaliso" => '%journal_iso%', "doi_link" => '%doi% %journal_url%', "abstract_wiki" => '%abstract_wiki%', "abstract_html" => '%abstract_html%', "listgroup" => '%listgroup%' ); var $commands = Array( 'addtt', 'addhash_fr', 'convertid', 'test', 'raw_medline', 'clear_raw_medline', 'remove_dir', 'search', 'recreate_cross_refs', 'full_pdf_list', ); // Constructor public function __construct(){ if (!class_exists('pubmed2020_cache')) @require_once(DOKU_PLUGIN.'pubmed2020/classes/cache.php'); if (!class_exists('PubMed2020')) @require_once(DOKU_PLUGIN.'pubmed2020/classes/pubmed2020.php'); $this->pubmed2020 = new PubMed2020(); $this->pubmedCache = new pubmed2020_cache("pubmed","pubmed","nbib"); $this->documentFormat = $this->getConf('default_command'); $this->useDocumentFormat = false; } function getType() { return 'substition'; } function getSort() { return 306; } /** * Plugin tag format: {{pmid>command:arg}} */ function connectTo($mode) { $this->Lexer->addSpecialPattern('\{\{(?:pmid|pmcid)>[^}]*\}\}', $mode,'plugin_pubmed2020'); } /** * Handle the match. */ function handle($match, $state, $pos, Doku_Handler $handler){ $match = str_replace("{{", "", $match); $match = str_replace("}}", "", $match); return array($state, explode('>', $match, 2)); } function _span($refs, $class, $id) { // No data if (empty($refs[$id])) return ""; // Data = array if (is_array($refs[$id])) return "".hsc(implode(", ",$refs[$id])).""; // Default return "".hsc($refs[$id]).""; } function _a($refs, $class, $href, $id, $text) { // No data if (empty($refs[$id])) return ""; // Default return "[$text]"; } /** * Replace tokens in the string \e $outputString using the array $refs. * \returns Replaced string content. */ function replaceTokens($outputString, $refs) { // Empty array -> exit if (count($refs) < 2) { // PMID is always included return sprintf($this->getLang('pubmed_not_found'), $refs["pmid"]); } // $r = replacement key/value: key=tag to replace in string, value=replacement string $r = array( // IDs "pmid" => "", "pmcid" => "", "doi" => "", // AUTHORS "authors" => $this->_span($refs, "authors", "authors"), "authorsLimit3" => $this->_span($refs, "authors", "authorsLimit3"), "first_author" => $this->_span($refs, "authors", "first_author"), "authorsVancouver" => $this->_span($refs, "vancouver authors", "authorsVancouver"), "collectif" => $this->_span($refs, "authors", "collectif"), "corporate_author"=> $this->_span($refs, "authors", "corporate_author"), // CITATION "vancouver" => "", "npg_iso" => $this->_span($refs, "iso", "npg_iso"), "npg_full" => $this->_span($refs, "npg", "npg_full"), "gpnv_full" => $this->_span($refs, "gpnv_authors", "gpnv_full_authors"). $this->_span($refs, "gpnv_title", "gpnv_full_title"). $this->_span($refs, "gpnv_journal", "gpnv_full_journal"). $this->_span($refs, "gpnv_iso", "gpnv_full_iso") , // URLS "pmid_url" => $this->_a($refs, "pmid", $refs["url"], "url", "PMID: ".$refs["pmid"]), "pmcid_url" => $this->_a($refs, "pmcid", $refs["pmcurl"], "pmcid", "PMCID: ".$refs["pmcid"]), "pmc_url" => $this->_a($refs, "pmcid", $refs["pmcurl"], "pmcid", "PMCID: ".$refs["pmcid"]), "doi_url" => $this->_a($refs, "pmcid", $this->doiUrl.$refs["doi"], "doi", "DOI: ".$refs["doi"]), "journal_url" => $this->_a($refs, "pmid", $this->doiUrl.$refs["doi"], "pmid", $refs["iso"]), "tweet_current" => "Twitter cet article ". "(lien vers ce site)", "tweet_pmid" => "". "Twitter cet article (lien vers l'article)", // TITLE "title" => "", "booktitle" => $this->_span($refs, "title", "booktitle"), "title_low" => "", "translated_title" => $this->_span($refs, "title", "translated_title"), "translated_title_low" => $this->_span($refs, "title", "translated_title_low"), "title_tt" => $this->_span($refs, "title", "translated_title"), // JOURNAL "journal_iso" => "", "journal_title" => "", "journal_iso" => "", // OTHERS "lang" => "", "iso" => "", "vol" => "", "issue" => "", "year" => "", "month" => "", "pages" => "", "abstract" => '
'.$refs["abstract_html"].'', "abstract_wiki" => $refs["abstract_wiki"], "abstract_html" => $refs["abstract_html"], "type" => "", "country" => "", "copyright" => "", "collection_title" => "", "publisher" => "", ); $r["tweet"] = "
". $r["tweet_pmid"]."
". $r["tweet_current"]. "
"; // Check if we have the local PDF of the paper $localPdf = $this->pubmedCache->GetLocalPdfPath($refs["pmid"], $refs["doi"]); if (empty($localPdf)) { $r["localpdf"] = $this->_span($refs, "nopdf", "No PDF"); } else { $r["localpdf"] = $this->_a($refs, "localPdf", $localPdf, "pmid", "PDF"); } foreach($r as $key => $value) { $v = $value; if (empty($v)) $v = $this->_span($refs, $key, $key); $outputString = str_replace("%".$key."%", $v, $outputString); } // note tt -> if empty = title // note doi & journal_url -> if empty add nothing //echo print_r($r); $refs["abstractFr"] = $this->pubmedCache->GetTranslatedAbstract($refs["pmid"]); if (empty($refs["abstractFr"])) { $outputString = str_replace("%abstractFr%", '
Traduction automatique en Français sur Google Translate
', $outputString); } else { // TODO: Create a form to send french abstrat to this class // TODO: Allow to store it in a separate file abstractfr_{pmid}.txt $outputString = str_replace("%abstractFr%", ''.$refs["abstractFr"].'', $outputString); } // Bootstrap listgroup if (strpos($outputString, "%listgroup%") !== false) { if (empty($refs["translated_title"])) { $lg = "
"; $lg .= "