/** * @brief Parse OpenURL parameters and return referent * * @param params Array of OpenURL parameters * @param referent Referent object to populate * */ function parse_openurl($params, &$referent) { global $debug; $referent->authors = array(); foreach ($params as $key => $value) { switch ($key) { case 'rft_val_fmt': switch ($value) { case 'info:ofi/fmt:kev:mtx:journal': $referent->genre = 'article'; break; case 'info:ofi/fmt:kev:mtx:book': $referent->genre = 'book'; break; default: if (!isset($referent->genre)) { $referent->genre = 'unknown'; } break; } break; // Article title // Article title case 'rft.atitle': case 'atitle': $title = $value[0]; $title = preg_replace('/\\.$/', '', $title); $title = strip_tags($title); $title = html_entity_decode($title, ENT_NOQUOTES, 'UTF-8'); $referent->title = $title; $referent->genre = 'article'; break; // Book title // Book title case 'rft.btitle': case 'btitle': $referent->title = $value[0]; $referent->genre = 'book'; break; // Journal title // Journal title case 'rft.jtitle': case 'rft.title': case 'title': $secondary_title = trim($value[0]); $secondary_title = preg_replace('/^\\[\\[/', '', $secondary_title); $secondary_title = preg_replace('/\\]\\]$/', '', $secondary_title); $referent->secondary_title = $secondary_title; $referent->genre = 'article'; break; case 'rft.issn': case 'issn': $ISSN_proto = $value[0]; $clean = ISN_clean($ISSN_proto); $class = ISSN_classifier($clean); if ($class == "checksumOK") { $referent->issn = canonical_ISSN($ISSN_proto); $referent->genre = 'article'; } break; // Identifiers // Identifiers case 'rft_id': case 'id': foreach ($value as $v) { // DOI if (preg_match('/^(info:doi\\/|doi:)(?<doi>.*)/', $v, $match)) { $referent->doi = $match['doi']; } // URL if (preg_match('/^http:\\/\\//', $v, $match)) { $referent->url = $v; } // LSID if (preg_match('/^urn:lsid:/', $v, $match)) { $referent->lsid = $v; } } break; // Authors // Authors case 'rft.au': case 'au': foreach ($value as $v) { $parts = parse_name($v); $author = new stdClass(); if (isset($parts['last'])) { $author->lastname = $parts['last']; } if (isset($parts['suffix'])) { $author->suffix = $parts['suffix']; } if (isset($parts['first'])) { $author->forename = $parts['first']; if (array_key_exists('middle', $parts)) { $author->forename .= ' ' . $parts['middle']; } } $referent->authors[] = $author; } break; default: $k = str_replace("rft.", '', $key); $referent->{$k} = $value[0]; break; } } // Clean // Dates if (isset($referent->date)) { if (preg_match('/^[0-9]{4}$/', $referent->date)) { $referent->year = $referent->date; $referent->date = $referent->date . '-00-00'; } if (preg_match('/^(?<year>[0-9]{4})-(?<month>[0-9]{2})-(?<day>[0-9]{2})$/', $referent->date, $match)) { $referent->year = $match['year']; $referent->date = $match['year'] . '-' . $match['month'] . '-' . $match['day']; } } // Zotero if (isset($referent->pages)) { // Note "u" option in regular expression, so that we match UTF-8 characters such as – if (preg_match('/(?<spage>[0-9]+)[\\-|–](?<epage>[0-9]+)/u', $referent->pages, $match)) { $referent->spage = $match['spage']; $referent->epage = $match['epage']; unset($referent->pages); } } // Endnote epage may have leading "-" as it splits spage-epage to generate OpenURL if (isset($referent->epage)) { $referent->epage = preg_replace('/^\\-/', '', $referent->epage); } // Single page if (isset($referent->pages)) { if (is_numeric($referent->pages)) { $referent->spage = $referent->pages; $referent->epage = $referent->pages; unset($referent->pages); } } // Journal titles with series numbers are split into title,series fields if (preg_match('/(?<title>.*),?\\s+series\\s+(?<series>[0-9]+)$/i', $referent->secondary_title, $match)) { $referent->secondary_title = $match['title']; $referent->series = $match['series']; } // Volume might have series information if (preg_match('/^series\\s+(?<series>[0-9]+),\\s*(?<volume>[0-9]+)$/i', $referent->volume, $match)) { $referent->volume = $match['volume']; $referent->series = $match['series']; } // Roman to Arabic volume if (!is_numeric($referent->volume)) { if (preg_match('/^[ivxicl]+$/', $referent->volume)) { $referent->volume = arabic($referent->volume); } } // Author array might not be populated, in which case add author from aulast and aufirst fields if (count($referent->authors) == 0 && (isset($referent->aulast) && isset($referent->aufirst))) { $author = new stdClass(); $author->lastname = $referent->aulast; $author->forename = $referent->aufirst; $referent->authors[] = $author; } // Use aulast and aufirst to ensure first author name properly parsed if (isset($referent->aulast) && isset($referent->aufirst)) { $author = new stdClass(); $author->lastname = $referent->aulast; $author->forename = $referent->aufirst; $referent->authors[0] = $author; } // EndNote encodes accented characters, which break journal names if (isset($referent->secondary_title)) { $referent->secondary_title = preg_replace('/%9F/', 'ü', $referent->secondary_title); } }
function process_citation($citation) { $debug = false; $matched = false; $matches = array(); $series = ''; // Clean if (preg_match('/\\(Ser\\. (?<series>\\d+)\\)/', $citation, $matches)) { $series = $matches['series']; $citation = preg_replace('/\\(Ser\\. \\d+\\)/', '', $citation); } if (preg_match('/\\Series (?<series>\\d+),/', $citation, $matches)) { $series = $matches['series']; $citation = preg_replace('/Series \\d+,/', '', $citation); } $citation = preg_replace('/^ZOOTAXA/', "", $citation); // Fix pagination character from ZootaxaPDF $citation = preg_replace('/(\\d+)([|-|—|–])(\\d+)\\.$/u', "\$1-\$3", $citation); if (!$matched) { if (preg_match('/ (?<authorstring>.*) \\s+ \\((?<year>[0-9]{4})[a-z]?(\\s+"[0-9]{4}")?\\)[\\.|:]? \\s+ (?<title>(([^\\.]+|(?R))(\\.))+) (?<secondary_title>.*), \\s+ (?<volume>(\\d+|([L|X|I|V]+))) (\\s*\\((?<issue>\\d+([-|\\/]\\d+)?)\\))? , \\s+ (?<spage>[e]?\\d+) ( [-||-|—|–| ] (?<epage>\\d+) )? /xu', $citation, $matches)) { if ($debug) { echo __LINE__ . "\n"; print_r($matches); } $matches['genre'] = 'article'; $matched = true; } } /* // Rec Aust Mus if (!$matched) { if (preg_match('/ (?<authorstring>.*) \s+ (?<year>[0-9]{4})[a-z]? \. \s+ (?<title>(([^\.]+|(?R))(\.))+) (?<secondary_title>.*) \s+ (?<volume>(\d+|([L|X|I|V]+))) (\s*\((?<issue>\d+([-|\/]\d+)?)\))? : \s+ (?<spage>[e]?\d+) ( [-||-|—|–| ] (?<epage>\d+) )? /xu', $citation, $matches)) { if ($debug) { echo __LINE__ . "\n"; print_r($matches); } $matches['genre'] = 'article'; $matched = true; } } */ if (!$matched) { // Peters, J.A. 1964. Dictionary of Herpetology: A Brief and Meaningful Definition of Words and Terms Used in Herpetology. Hafner Publishing Company, New York. 393 pp. if (preg_match('/ (?<authorstring>.*) \\s+ [\\(]?(?<year>[0-9]{4})[a-z]?(\\s+"[0-9]{4}")?[\\)]? \\.? \\s+ (?<title>(([^\\.]+|(?R))(\\.))+) \\s+ (?<publisher>.*), (?<publoc>.*) [\\.|,] \\s+ (?<pages>\\d+) \\s+ pp. /xu', $citation, $matches)) { if ($debug) { echo __LINE__ . "\n"; print_r($matches); } $matches['genre'] = 'book'; $matched = true; } } // Post process $ref = new stdclass(); $ref->citation = $citation; if (!$matched) { echo "FAILED TO PARSE\n----------------------------------\n"; } else { if ($series != '') { $ref->series = $series; } foreach ($matches as $k => $v) { switch ($k) { case 'genre': case 'secondary_title': case 'issue': case 'spage': case 'epage': case 'year': case 'publisher': case 'publoc': case 'pages': if ($v != '') { $ref->{$k} = trim($v); } break; case 'title': $v = preg_replace('/\\.$/', '', trim($v)); $ref->{$k} = $v; break; case 'volume': // Clean up volume (if Roman convert to Arabic) if (!is_numeric($v)) { if (preg_match('/^[MDCLXVI]+$/', $v)) { $v = arabic($v); } } $ref->{$k} = $v; break; case 'authorstring': $v = preg_replace('/&/', '|', $v); $v = preg_replace('/(Jr\\.[,]?\\s+)/', "", $v); $v = preg_replace('/([A-Z]\\.),/', "\$1|", $v); $v = preg_replace('/\\|\\s*\\|/', "\$1|", $v); $v = preg_replace('/\\|$/', "", $v); $authors = explode("|", $v); //echo "authors=$v\n"; foreach ($authors as $a) { reference_add_author_from_string($ref, $a); } break; default: //echo "$k\n"; break; } } unset($ref->{0}); //print_r($ref); } return $ref; }
function parse_bhl_date($str, &$info) { $debug = false; $matched = false; // Clean up // $str = preg_replace('/^new ser./', '', $str); // $str = preg_replace('/text$/', '', $str); $str = preg_replace('/:plates$/', '', $str); $str = trim($str); if ($debug) { echo $str . '<br/>'; } // n.s. t. 4 (1857) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^n.s. t.\\s+(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // n.s. t. 6 (1859-1860) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^n.s. t.\\s+(?<volume>\\d+)\\s+\\((?<year_from>[0-9]{4})\\s*-\\s*(?<year_to>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->start = $m['year_from']; $info->end = $m['yearend']; $matched = true; } } // año 8 (1904) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^año\\s+(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Bd. 4; Hft. 4/5 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd.\\s+(?<volume>\\d+);\\s+Hft.\\s+(?<issue>.*)\$/Uu", $str, $m)) { $info->volume = $m['volume'] . 'A'; $matched = true; } } // v.123:suppl. (2003) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v.(?<volume>\\d+):suppl.\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume'] . 'A'; $info->start = $m['year']; $matched = true; } } // n.s. v. 25 Jan-June (1907) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^n.s.\\s+v.\\s+(?<volume>\\d+)\\s+\\w+-\\w+\\s+\\(?(?<year>[0-9]{4})\\)?\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 1857 - 1858 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<year_from>[0-9]{4})\\s*-\\s*(?<year_to>[0-9]{4})\$/Uu", $str, $m)) { $info->start = $m['year_from']; $info->end = $m['yearend']; $matched = true; } } // an.1900:52nd if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^an\\.\\s*(?<year>[0-9]{4}):(?<volume>\\d+)[rd|nd]\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // an. 1917 69: T.80 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^an\\.\\s*(?<year>[0-9]{4})\\s*(?<volume>\\d+):/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Tome 11 (3rd ser. Tome 1) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Tome\\s*(?<volume>\\d+)\\s+\\((.*)\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // T. 86 (1922) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^T.\\s*(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // heft 26-27 1986-1987 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^heft\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+(?<year_from>[0-9]{4})-(?<year_to>[0-9]{4})\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = $m['yearend']; $matched = true; } } // no. 330-346 1990 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)((\\s+\\w+\\.?)?\\s+(?<year_from>[0-9]{4}))?\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $matched = true; } } // no. 187-190( 1975) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s*\\(\\s*(?<year_from>[0-9]{4}))\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $matched = true; } } // no. 531/542 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no.\\s*(?<volume_from>\\d+)\\/(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $matched = true; } } // no. 494 Dec. 2001 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no.\\s*(?<volume_from>\\d+)(\\s+\\w+\\.?)?\\s+(?<year_from>[0-9]{4})\$/Uu", $str, $m)) { $info->volume = $m['volume_from']; $info->start = $m['year_from']; $matched = true; } } // if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/((Ser.\\s+(?<series>\\d+),|Suppl.)\\s+)?d.\\s*(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Biology: v.3 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Biology: v.(?<volume>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // t. 47; (ser. 5, t. 7) (1911) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^t\\.\\s*(?<v>\\d+);\\s+\\(ser\\.\\s+(?<series>\\d+),\\s+t\\.\\s+(?<volume>\\d+)\\)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->series = $m['series']; $info->start = $m['year']; $matched = true; } } // Bd 3..Lfg..2 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\s*(?<volume>\\d+)((\\s*(..)?)Lfg[\\.]+(?<issue>.*))?\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // t. 116 :fasc. 2 (2009) // t. 94 fasc. 3-4 1987 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^t\\.\\s*(?<volume>\\d+)\\s+[:]?fasc\\.\\s*(?<issue>.*)\\s*\\(?(?<year>[0-9]{4})\\)?\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 72, no. 1 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)[,]?\\s+no[\\.]?\\s+(?<issue>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // 47 (1904-1905) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\s+\\((?<year_from>[0-9]{4})-(?<year_to>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year_from']; $info->end = $m['year_to']; $matched = true; } } // Vol 59-60 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $matched = true; } } // n. s. v. 15-16 (1920-21) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^n. s. v.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<year_from>[0-9]{4})-(?<year_to>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // Bnd.01 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bnd\\.\\s*0(?<volume>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Vol 65(1) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol\\s*(?<volume>\\d+)\\s*\\((?<issue>\\d+)\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Vol 63, No. 2 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol\\.?\\s*(?<volume>\\d+)[,]?\\s+No[\\.]?\\s*(?<issue>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Vol.23 (1854) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol\\.\\s*(?<volume>\\d+)(\\((?<issue>\\d+)\\))?\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // new ser:v.15 (1919) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^new ser:v.\\s*(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // new ser:v.11 (1915-1916) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^new ser:v.\\s*(?<volume>\\d+)\\s+\\((?<year_from>[0-9]{4})-(?<year_to>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year_from']; $info->end = $m['year_to']; $matched = true; } } // Vol. 57-58 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol.\\s+(?<volume_from>\\d+)-(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $matched = true; } } // v108-109 2001-2003 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+(?<year_from>[0-9]{4})-(?<year_to>[0-9]{4})\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = $m['year_to']; $matched = true; } } // No. 12-13 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^No\\.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year']; $matched = true; } } // no. 272-280 (1999) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no\\.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year']; $matched = true; } } // bd. 1 1911-12 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd\\.\\s*(?<volume>\\d+)\\s+(?<year_from>[0-9]{4})-(?<year_to>[0-9]{2})\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year_from']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // bd. 3-4 1914-16 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd\\.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+(?<year_from>[0-9]{4})-(?<year_to>[0-9]{2})\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // Vol.82 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^[V|v]ol\\.\\s*(?<volume>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Vols 87-88 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vols\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $matched = true; } } // new. ser.:v.43 (1900):text if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^new.? ser.:v.(?<volume>[0-9]+)\\s+\\((?<year_from>[0-9]{4})(-(?<year_to>[0-9]{4}))?\\)(:text)?\$/i", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year_from']; if ($m['year_to'] != '') { $info->end = $m['year_to']; } $matched = true; } } // n.s., v.55, 1910 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^n.s.,. v.(?<volume>[0-9]+)\\s+(?<year_from>[0-9]{4})(-(?<year_to>[0-9]{4}))?\$/i", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year_from']; if ($m['year_to'] != '') { $info->end = $m['year_to']; } $matched = true; } } // new ser.:v.27 (1886-1887):text // Vols 65, no 1 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vols\\s+(?<volume>[0-9]+),\\s+no\\s+(?<issue>\\d+)\$/i", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $info->issue = $m['issue']; $matched = true; } } // pt. 11, 1883 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^pt\\.\\s*(?<volume>[0-9]+),\\s+(?<year>[0-9]{4})\$/i", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // 38 - part 2 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<volume>[0-9]+)\\s+-\\s+part\\s+\\d+\$/i", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year_from']; $matched = true; } } // jahrg 45 - 46 (1913-14) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahrg\\s+(?<volume_from>\\d+)\\s*-\\s*(?<volume_to>\\d+)\\s+\\((?<year_from>[0-9]{4})-(?<year_to>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // Nr.1-50 (1957-1960) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Nr.(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<year_from>[0-9]{4})-(?<year_to>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year_from']; $info->end = $m['year_to']; $matched = true; } } // Bd. 1-2 (1918-19) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\.?\\s+(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // t. 70 fasc. 4 Dec 1963 if (!$matched) { if (preg_match('/^t\\.\\s+(?<volume>\\d+)\\s+fasc\\.\\s+\\d+\\s+\\w+\\s+(?<year>[0-9]{4})$/Uu', $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // t. 67 1960 suppl. if (!$matched) { if (preg_match('/^t\\.\\s+(?<volume>\\d+)\\s+(?<year>[0-9]{4})\\s+suppl\\.$/Uu', $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // t. 26, suppl. (1918) if (!$matched) { if (preg_match('/^t\\.\\s+(?<volume>\\d+),\\s+suppl\\.\\s+\\((?<year>[0-9]{4})\\)$/Uu', $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // v. XLIII (1899) if (!$matched) { if (preg_match('/^[V|v]\\.\\s+(?<volume>[XLVICM]+)\\s+\\((?<year>[0-9]{4})\\)$/Uu', $str, $m)) { $info->volume = arabic($m['volume']); $info->start = $m['year']; $matched = true; } } // ser.1, v. 16 (1880-81) if (!$matched) { if (preg_match('/^ser\\.\\s*(?<series>\\d+),\\s*v\\.\\s*(?<volume>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)$/Uu', $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // ser.3:v.28 (1884) if (!$matched) { if (preg_match('/^ser\\.(?<series>\\d+):v\\.(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)$/Uu', $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Jan-Mai 1882 if (!$matched) { if (preg_match('/^[A-Z][a-z]+\\-[A-Z][a-z]+\\s+(?<year>[0-9]{4})$/Uu', $str, $m)) { $info->volume = $m['year']; $info->start = $m['year']; $matched = true; } } // Jahrg. 44 (1891) if (!$matched) { if (preg_match('/^Jahrg.\\s+(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)$/Uu', $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // d. 1 1901-05 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^d\\.\\s+(?<volume>\\d+)\\s+(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 79th 1958-59 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^\\d+(st|th|rd|nd)\\s+(?<volume>[0-9|-]+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // v. 2-3 (1916-1917) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.?\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // v 12-13 (1916-19) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.?\\s+(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // t.49-50 (1900) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^t\\.(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['year']; $matched = true; } } // ser.3:t.4 (1905) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.(?<series>\\d+):t\\.(Vol\\s+)?(?<volume>[0-9]+)\\s+\\((?<yearstart>[0-9]{4})(-(?<yearend>[0-9]{4}))?\\)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->series = $m['series']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // Vol 22 (3rd Series) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(Vol\\s+)?(?<volume>[0-9]+)\\s+\\((?<series>\\d+)(nd|st|rd|th) Series\\)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->series = $m['series']; $matched = true; } } // 53 part 2 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<volume>[0-9]+)\\s+part\\s+\\d+\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // 55 number 1 part 2 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<volume>[0-9]+)\\s+number\\s+(?<issue>\\d+)\\s+part\\s+(\\d+)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->issue = $m['issue']; $matched = true; } } // t.6, 1881 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^t\\.\\s*(?<volume>[0-9]+)\\,\\s+(?<year>[0-9]{4})\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 13.Bd. (1883-1884) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+)\\.Bd\\.\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // f.56 (Simenchelys parasiticus) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^f\\.(?<volume>\\d+)\\s+\\((.*)\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Dec.1-5 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Dec\\.(?<volume_from>\\d+)-(?<volume_to>\\d+)\$/Uu", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $matched = true; } } // ser. 2, v. 1 (1881-1883) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.\\s+(?<series>\\d+),\\s*v.\\s*(?<volume>[0-9]+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // an. 1920, 72: T. 83 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^an.\\s*(?<year>[0-9]{4})[:|,](.*)[T|t].\\s*(?<volume>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.(?<volume>\\d+)\\s+(?<year>[0-9]{4})\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Jahrig. 38, bd. 1 (1872) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Jahrig.\\s+(?<volume>\\d+),\\s+bd.\\s+(\\d+(-\\d+)?)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 22 Part 9 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\s+Part\\s+(?<issue>\\d+)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->issue = $m['issue']; $matched = true; } } // vol.72(1908) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^vol\\.(?<volume>\\d+)\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // jahrg. 20 (1902) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahrg.\\s+(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } //jahrg. 30, beiheft 5, 6, 8, 9 , 11 (1912) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahrg.\\s+(?<volume>\\d+),\\s+beiheft (.*)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 1902, v. 2 (May-Dec.) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<year>[0-9]{4}),\\s+v\\.\\s+(?<volume>\\d+)\\s+\\(\\w+\\.?-\\w+\\.?\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // // Jahrg.1892 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Jahrg.(?<year>[0-9]{4})\$/Uu", $str, $m)) { $info->start = $m['year']; $matched = true; } } // v. 40-45 1991-96 (Inc.) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s+(?<volume_from>\\d+)\\s*-\\s*(?<volume_to>\\d+)\\s+(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\s+/Uu", $str, $m)) { $info->series = $m['series']; $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\.\\s*(?<volume>\\d+)\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Bd.47, 1916 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\.(?<volume>\\d+),\\s+(?<year>[0-9]{4})\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // v.34:pt.1 (1951) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s*(?<volume>\\d+):(pt|no)\\.(?<issue>\\d+(-\\d+)?)\\s+\\((?<year>[0-9]{4})\\)\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->issue = $m['issue']; $info->start = $m['year']; $matched = true; } } // v.51:no.12-25 (1978-1980) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s*(?<volume>\\d+)(:(pt|no)\\.(\\d+-\\d+))?\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year_from']; $info->end = $m['year_to']; $matched = true; } } // no.36 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no\\.\\s*(?<volume>\\d+)\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // Stuttgarter Beiträge zur Naturkunde // nr. 588 1999 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^nr\\.\\s*(?<volume>\\d+)\\s*(?<year>[0-9]{4})\$/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // nr. 506-517 1994 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^nr\\.?\\s+(?<volume_from>\\d+)-(?<volume_to>\\d+)\\s+(?<yearstart>[0-9]{4})(\\-(?<yearend>[0-9]{2}))?\$/Uu", $str, $m)) { $info->series = $m['series']; $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; if ($m['yearend'] == '') { $info->end = $info->start; } else { $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; } $matched = true; } } // n.s. no.77(1994) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/n.s. no.\\s*(?<volume>\\d+)\\s*\\((?<year>[0-9]{4})\\)/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // an.1902:54th if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^an.\\s*(?<year>[0-9]{4}):(?<volume>\\d+)th/Uiu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // bd. 26 heft 1 Mar 2003 // Bd. 27 :heft 2 (2004: July) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd.\\s+(?<volume>\\d+)\\s+[:]?heft\\.?\\s+(?<issue>\\d+)\\s+(\\w+\\s+|\\()(?<year>[0-9]{4})(: \\w+\\.?\\))?\$/Uiu", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 6e sér.:t.3e (1883) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<series>\\d+)e\\s+sér.:t.(?<volume>\\d+)e\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 4 (1970) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // t. 12, Index t. 1-12 (1904) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^t. (?<volume>\\d+), Index t. 1-12 \\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // ser. 7, t.11-12 (1886-88) // ser 10, t. 5-8 (1913-16) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.?\\s+(?<series>\\d+),\\s+t\\.\\s*(?<volume_from>\\d+)\\s*-\\s*(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->series = $m['series']; $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // ser. 9, t. 5 (1902-03) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.?\\s+(?<series>\\d+),\\s+t\\.\\s*(?<volume>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/Uu", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.?\\s+(?<series>\\d+),\\s+t\\.\\s*(?<volume>\\d+)\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 36.Jahrg. (1891) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\.\\s*Jahrg\\.\\s+\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // jahrg. 29 1912 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahrg.\\s*(?<volume>\\d+) (?<year>[0-9]{4})\$/Uui", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // jahrg. 32-34 1915-17 if (!$matched) { if (preg_match("/^jahrg.\\s*(?<volume_from>\\d+)-(?<volume_to>\\d+) (?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})/Uui", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // bd. 35 pt. 1-4 1921 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd. (?<volume>\\d+) pt. (?<issue>\\d+-\\d+) (?<year>[0-9]{4})\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->issue = $m['issue']; $info->start = $m['year']; $matched = true; } } // 4th ser. v. 12, p. 695-1320 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<series>\\d+)th ser. v. (?<volume>\\d+),? p[t]?/Uu", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $matched = true; } } // no. 202 v. 2 1960 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/no.\\s+(?<volume>\\d+) v. \\d+ (?<year>[0-9]{4})\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Jaarg.1 (1863) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/Jaarg\\.(?<volume>\\d+)\\b(.*)\\((?<year>[0-9]{4})\\)\$/Uu", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 4e sér.:t.10e (1870) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<series>\\d+)e sér.:t.(?<volume>\\d+)e \\((?<year>[0-9]{4})\\)\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // v. 1F (1958) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v. (?<volume>\\d+[A-Z]) \\((?<year>[0-9]{4})\\)\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // v. 1D (1956-57) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v. (?<volume>\\d+[A-Z]) \\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // no. 86 (June 1999) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no. (?<volume>\\d+) \\(\\w+ (?<year>[0-9]{4})\\)\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // arg. 59 (1902) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^arg. (?<volume>\\d+) \\((?<year>[0-9]{4})\\)\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // n.s., v. 4 1856-58 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/n.s., v. (?<volume>\\d+) (?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 3rd ser., v. 3 1864-69 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/(?<series>\\d+)rd ser., v. (?<volume>\\d+) (?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})/", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // ser. 2 v. 6 (1894-1897) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/ser. (?<series>\\d+) v. (?<volume>\\d+) \\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)/", $str, $m)) { $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // 35-36, 1918-1920 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume_from>\\d+)\\-(?<volume_to>\\d+),\\s+(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\$/", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // 34, 1917-1918 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+),\\s+(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\$/", $str, $m)) { $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // v. 99- 100 1956-57 if (!$matched) { if ($str == 'v. 99- 100 1956-57') { $info->volume_from = 99; $info->volume_to = 100; $info->start = 1956; $info->end = 1957; $matched = true; } } // bd. 17-18 (1899-1900) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd\\.\\s+(?<volume_from>\\d+)\\-(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // bd. 19-20 (1901-02) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd\\.\\s+(?<volume_from>\\d+)\\-(?<volume_to>\\d+)\\s+\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)\$/", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // v. 88/89 1977/78 if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s+(?<volume_from>\\d+)\\/(?<volume_to>\\d+)\\s+(?<yearstart>[0-9]{4})\\/(?<yearend>[0-9]{2})/", $str, $m)) { $info->volume_from = $m['volume_from']; $info->volume_to = $m['volume_to']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 1901, v. 1 (Jan.-Apr.) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]{4}),\\s+v.\\s+\\d+\\s+\\(\$/", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // 1867 (incomplete) if (!$matched) { if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]{4})\\s+\\(incomplete\\)\$/", $str, $m)) { $info->volume = $m['volume']; $matched = true; } } // 1921 v. 1-2 if (!$matched) { if ($str == '1921 v. 1-2') { $info->volume = 1921; $matched = true; } } // Part 19 - Part 20 (1851-52) if (!$matched) { if ($str == 'Part 19 - Part 20 (1851-52)') { $info->volume_from = 1851; $info->volume_to = 1852; $matched = true; } } // [1908-1944] if (!$matched) { if ($str == '[1908-1944]') { $info->start = 1908; $info->end = 1944; $matched = true; } } // Vol 10 - Vol 10 if (!$matched) { if ($str == 'Vol 10 - Vol 10') { $info->volume = 10; $matched = true; } } if (!$matched) { if ($str == 'Vol 20 - Vol 20') { $info->volume = 10; $matched = true; } } // v 11 (1914-15) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v (?<volume>\\d+) \\((?<yearstart>[0-9]{4})-(?<yearend>[0-9]{2})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 1923, pt. 3-4 (pp. 483-1097) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]{4}),\\s*p[p|t]\\./", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // Vol 10 (3) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Vol (?<volume>[0-9]+) \\((?<issue>[0-9]+)\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volume']; $info->issue = $m['issue']; $info->issue = $info->issue; $matched = true; } } // // Band I - Band II if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Band (?<volumefrom>[XVI]+) - Band (?<volumeto>[XVI]+)/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = arabic($m['volumefrom']); $info->volume_to = arabic($m['volumeto']); $matched = true; } } // Band V if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Band (?<volume>[XVI]+)/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = arabic($m['volume']); $matched = true; } } // Bd.2.E.b if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\.(?<volume>[0-9]+)\\./", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // Jahrg. 74:bd. 2:heft 2 (1908) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Jahrg\\.\\s+(?<volume>[0-9]+):(.*)\\((?<year>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // Jahrg. 73:bd. 2:heft 2: Lief. 3 - Jahrg. 73:bd. 2: if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Jahrg\\.\\s+(?<volume>[0-9]+):/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // 88.d. (1945) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\.d\\.\\s+\\((?<year>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 65./66. d. 1922/23 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volumefrom>\\d+)\\.\\/(?<volumeto>\\d+)\\.\\s*d\\.\\s*(?<yearstart>[0-9]{4})\\/(?<yearend>[0-9]{2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // bd. 2 (1901-04) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd.\\s*(?<volume>\\d+)\\s*\\((?<yearstart>[0-9]{4})-(?<yearend>[0-9]{2})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // nuova ser.:v.1 (1901-1905) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^nuova ser.:v.(?<volume>[0-9]+)\\s*\\((?<yearstart>[0-9]{4})-(?<yearend>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // 8 (Series 2) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>\\d+)\\s+\\(Series\\s+(?<series>\\d+)\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->series = $m['series']; $matched = true; } } // 1912 v. 59 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<year>1[8|9][0-9]{2}) v.\\s*(?<volume>[0-9]{1,2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 1916-18 v. 63-65 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<yearstart>1[8|9][0-9]{2})-(?<yearend>[0-9]{2}) v. \n\t\t(?<volumefrom>[0-9]{1,2})-(?<volumeto>[0-9]{1,2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 3. d. 1859 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+).\\s*(d\\.|jaarg\\.)\\s*(?<year>[0-9]{4})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // 29. d. 1885/86 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+).\\s*(d\\.|jaarg\\.)\\s*(?<yearstart>[0-9]{4})\\/(?<yearend>[0-9]{2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // 46./47. d. 1903/04 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s*(?<volumefrom>[0-9]+).\\s*(d\\.|jaarg\\.)\\s*(?<yearstart>[0-9]{4})\\/(?<yearend>[0-9]{2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // Volume XI if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Volume\\s+(?<volume>[XVI]+)\$/", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = arabic($m['volume']); $matched = true; } } // 14, 1891 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+),\\s*(?<year>[0-9]{4})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // jahrg.5 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahr[g]?\\.(?<volume>[0-9]+)\$/u", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // jahr.21-25 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^jahr[g]?\\.(?<volumefrom>[0-9]+)([-|—](?<volumeto>[0-9]+))?\$/u", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $matched = true; } } //v.58-59 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s*(?<volumefrom>[0-9]+)-(?<volumeto>[0-9]+)\$/u", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $matched = true; } } // 31 n.01 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volumefrom>[0-9]+)\\s+n\\.(?<issue>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->issue = $m['issue']; $info->issue = preg_replace('/^0/', '', $info->issue); $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<year>[0-9]{4})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->start = $m['year']; $matched = true; } } // Volume 46 // vol 4 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(Volume|vol) (?<volume>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // no. 224 pt. 1 1962 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no\\.\\s*(?<volume>[0-9]+)\\s*pt\\.\\s*(?<issue>[0-9]+)\\s*\\(?(?<year>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->issue = $m['issue']; $info->start = $m['year']; $matched = true; } } // Bd.4 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Bd\\.(?<volume>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // Jahrg. 6, Bd. 1 (1840) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Jahrg\\.\\s*(?<volume>[0-9]+),\\s*[B|b]d\\.\\s*(?<issue>[0-9]+)\\s*\\(?(?<year>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->issue = $m['issue']; $info->start = $m['year']; $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // Fieldiana Zoology v.24, no.16 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<title>.*)\\s+v.(?<volume>[0-9]+), no.(?<issue>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->title = $m['title']; $info->volume = $m['volume']; $info->issue = $m['issue']; $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(no|v|t)\\.\\s*(?<volume>[0-9]+)(.*)\\((?<yearstart>[0-9]{4})(?<yearend>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(bd|v|t|ser|Haft)\\.\\s*(?<volume>[0-9]+)(.*)\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(v|t|bd|Bd|anno|Haft)\\.?\\s*(?<volume>[0-9]+)\\s*\\(?(?<year>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // no.180 (1996) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^no\\.\\s*(?<volume>[0-9]+)\\s*\\(?(?<year>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // bd.52, 1921 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^bd\\.\\s*(?<volume>[0-9]+),\\s*(?<year>[0-9]{4})?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // e.g. Ann. mag. nat. hist., Proc Calif Acad Sci // 3rd ser. v. 8 (1861) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<series>[0-9]+)(rd|th|nd)\\.?\\s+ser.\\s*v.\\s*(?<volume>[0-9]+)\\s*\\(?((?<yearstart>[0-9]{4})(\\-(?<yearend>[0-9]{4}))?)?\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; if (isset($m['yearstart'])) { $info->start = $m['yearstart']; } if (isset($m['yearend'])) { $info->end = $m['yearend']; } $info->series = $m['series']; $matched = true; } } // *** WARNING *** Line:369 Not matched "4th ser. v. 41 1977-79"< if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<series>[0-9]+)(rd|th|nd)\\.?\\s+ser.\\s*v.\\s*(?<volume>[0-9]+)\\s*\\(?((?<yearstart>[0-9]{4})(\\-(?<yearend>[0-9]{2})))\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $info->series = $m['series']; $matched = true; } } // this one is v dangerous as has (*.) in middle, use only as last resort...!!!!!! /* if (!$matched) { $m = array(); if ($debug) echo "Trying " . __LINE__ . "\n"; if (preg_match("/^(?<volume>[0-9]+)(.*)\(?(?<year>[0-9]{4})\)?$/", $str, $m)) { if ($debug) { echo "$str "; print_r($m); } $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } */ if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(no|v|t)\\.\\s*((?<volumefrom>[0-9]+)\\-(?<volumeto>[0-9]+))(.*)\\((?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // no. 85-93 1991-92 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(no|v|t)\\.\\s*((?<volumefrom>[0-9]+)\\-(?<volumeto>[0-9]+))(.*)\\(?(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // no. 85-93 1991-92 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(Bd|no|v|t)\\.\\s*(?<volume>[0-9]+)(.*)\\(?(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{2})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->start = $m['yearstart']; $info->end = substr($m['yearstart'], 0, 2) . $m['yearend']; $matched = true; } } // v. 1-2 (1814-1826) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(no|v|t)\\.\\s*((?<volumefrom>[0-9]+)\\-(?<volumeto>[0-9]+))(.*)\\(?(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // ser.2 t.1-2 1895-1897 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(ser)\\.\\s*(?<series>[0-9]+)\\s*t\\.((?<volumefrom>[0-9]+)\\-(?<volumeto>[0-9]+))\\s*\\(?(?<yearstart>[0-9]{4})\\-(?<yearend>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->series = $m['series']; $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $info->start = $m['yearstart']; $info->end = $m['yearend']; $matched = true; } } // ser.3, v. 6, 1914 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^ser\\.\\s*(?<series>[0-9]+),?\\s*[v|t]\\.\\s*(?<volume>[0-9]+),?\\s*(.*)\\(?(?<year>[0-9]{4})\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->series = $m['series']; $info->volume = $m['volume']; $info->start = $m['year']; $matched = true; } } // new ser.:v.44 (1900-1901):plates if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(new )ser\\.\\s*[,|:]?\\s*[v|t]\\.\\s*(?<volume>[0-9]+)\\s*\\(?((?<yearstart>[0-9]{4})(\\-(?<yearend>[0-9]{4}))?)?\\)?\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->series = 'new series'; $info->volume = $m['volume']; if (isset($m['yearstart'])) { $info->start = $m['yearstart']; } if (isset($m['yearend'])) { $info->end = $m['yearend']; } $matched = true; } } // No date, just volume (e.g. Bull brit Mus Nat Hist) if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^((Vol|tome\\.?)\\s*)?(?<volume>[0-9]+[A-Z]?)\$/", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // Tome 20 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^Tome\\s+(?<volume>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // 18 and index to v.1-17 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+) and index/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // 22-24 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volumefrom>[0-9]+)\\-(?<volumeto>[0-9]+)\$/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume_from = $m['volumefrom']; $info->volume_to = $m['volumeto']; $matched = true; } } // 20:pt.1 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^(?<volume>[0-9]+):/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $matched = true; } } // v.33, no.1 if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/^v\\.\\s*(?<volume>[0-9]+)(, (no|pt).\\s*(?<issue>[0-9]+))?/", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; if (isset($m['issue'])) { $info->issue = $m['issue']; } $matched = true; } } if (!$matched) { $m = array(); if ($debug) { echo "Trying " . __LINE__ . "\n"; } if (preg_match("/new series,? no.\\s*(?<volume>[0-9]+)?/i", $str, $m)) { if ($debug) { echo "{$str}\n"; print_r($m); } $info->volume = $m['volume']; $info->series = 'new series'; $matched = true; } } return $matched; }
/** * @brief Handle OpenURL request * * We may have more than one parameter with same name, so need to access QUERY_STRING, not _GET * http://stackoverflow.com/questions/353379/how-to-get-multiple-parameters-with-same-name-from-a-url-in-php * */ function main() { global $config; global $couch; $debug_openurl = false; $webhook = ''; $callback = ''; // If no query parameters if (count($_GET) == 0) { //display_form(); exit(0); } if (isset($_GET['webhook'])) { $webhook = $_GET['webhook']; } if (isset($_GET['debug'])) { $debug_openurl = true; } if (isset($_GET['callback'])) { $callback = $_GET['callback']; } // Handle query and display results. $query = explode('&', html_entity_decode($_SERVER['QUERY_STRING'])); $params = array(); foreach ($query as $param) { list($key, $value) = explode('=', $param); $key = preg_replace('/^\\?/', '', urldecode($key)); $params[$key][] = trim(urldecode($value)); } // This is what we got from user $context_object = new stdclass(); parse_openurl($params, $context_object); //print_r($context_object); // OK, can we find this? // result object $openurl_result = new stdclass(); $openurl_result->status = 404; $openurl_result->context_object = $context_object; $openurl_result->results = array(); if ($debug_openurl) { $openurl_result->debug = new stdclass(); } // via DOI or other identifier if (count($openurl_result->results) == 0) { // identifier search if (isset($context_object->referent->identifier)) { //print_r($context_object->referent->identifier); $found = false; foreach ($context_object->referent->identifier as $identifier) { if ($debug_openurl) { $openurl_result->debug->identifiers[] = $identifier; } if (!$found) { switch ($identifier->type) { case 'doi': $url = $config['couchdb_options']['database'] . "/_design/identifier/_view/doi?key=" . urlencode('"' . $identifier->id . '"'); //echo $url . '<br />'; if ($config['stale']) { $url .= '&stale=ok'; } $resp = $couch->send("GET", "/" . $url . '&limit=1'); $result = json_decode($resp); if (count($result->rows) == 1) { $openurl_result->debug->found_from_identifiers = true; $found = true; $match = new stdclass(); $match->match = true; $match->id = $result->rows[0]->id; $match->{$identifier->type} = $identifier->id; $openurl_result->results[] = $match; $openurl_result->status = 200; } break; case 'pmid': $url = $config['couchdb_options']['database'] . "/_design/identifier/_view/pmid?key=" . $identifier->id; //echo $url . '<br />'; if ($config['stale']) { $url .= '&stale=ok'; } $resp = $couch->send("GET", "/" . $url . '&limit=1'); $result = json_decode($resp); if (count($result->rows) == 1) { $openurl_result->debug->found_from_identifiers = true; $found = true; $match = new stdclass(); $match->match = true; $match->id = $result->rows[0]->id; $match->{$identifier->type} = $identifier->id; $openurl_result->results[] = $match; $openurl_result->status = 200; } break; default: break; } } } } } // classical OpenURL lookup using [ISSN,volume,spage] triple if (count($openurl_result->results) == 0) { $triple = false; if (isset($context_object->referent->journal->name)) { $journal = $context_object->referent->journal->name; // Convert accented characters $journal = strtr(utf8_decode($journal), utf8_decode("ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž"), "aaaaaaaaaaaaaaaaaaccccccccccddddddeeeeeeeeeeeeeeeeeegggggggghhhhiiiiiiiiiiiiiiiiiijjkkkllllllllllnnnnnnnnnnnoooooooooooooooooorrrrrrsssssssssttttttuuuuuuuuuuuuuuuuuuuuwwyyyyyyzzzzzz"); $journal = utf8_encode($journal); $journal = strtolower($journal); $journal = preg_replace('/\\bfor\\b/', '', $journal); $journal = preg_replace('/\\band\\b/', '', $journal); $journal = preg_replace('/\\bof\\b/', '', $journal); $journal = preg_replace('/\\bthe\\b/', '', $journal); $journal = preg_replace('/\\bde\\b/', '', $journal); $journal = preg_replace('/\\bla\\b/', '', $journal); $journal = preg_replace('/\\bet\\b/', '', $journal); // whitespace $journal = preg_replace('/\\s+/', '', $journal); // punctuation $journal = preg_replace('/[\\.|,|\'|\\(|\\)]+/', '', $journal); if (isset($context_object->referent->journal->volume)) { $volume = $context_object->referent->journal->volume; if (isset($context_object->referent->journal->pages)) { if (is_numeric($context_object->referent->journal->pages)) { $spage = $context_object->referent->journal->pages; $triple = true; } else { if (preg_match('/^(?<spage>\\d+)--(?<epage>\\d+)$/', $context_object->referent->journal->pages, $m)) { $spage = $m['spage']; $triple = true; } } } } if ($triple) { if ($debug_openurl) { $openurl_result->debug->triple = $triple; $openurl_result->debug->journal = $journal; } $openurl_result->status = 200; // i. get ISSN $url = $config['couchdb_options']['database'] . "/_design/openurl/_view/journal_to_issn?key=" . urlencode('"' . $journal . '"'); //echo $url; if ($config['stale']) { $url .= '&stale=ok'; } //echo $url; $resp = $couch->send("GET", "/" . $url . '&limit=1'); $result = json_decode($resp); //print_r($resp); if (count($result->rows) == 1) { // we have an ISSN for this journal $issn = $result->rows[0]->value; if ($debug_openurl) { $openurl_result->debug->issn = $issn; } // build triple [ISSN, volume, spage] $keys = array($issn, $volume, $spage); if ($debug_openurl) { $openurl_result->debug->keys = $keys; } $url = $config['couchdb_options']['database'] . "/_design/openurl/_view/issn_triple?key=" . urlencode(json_encode($keys)); //echo $url . '<br />'; if ($config['stale']) { $url .= '&stale=ok'; } $resp = $couch->send("GET", "/" . $url); $r = json_decode($resp); //print_r($r); if (count($r->rows) > 0) { foreach ($r->rows as $row) { $match = new stdclass(); $match->match = true; $match->triple = $keys; $match->id = $row->id; $openurl_result->results[] = $match; } } else { // No hit, try converting volume to/from Roman if (is_numeric($volume)) { $volume = strtolower(roman($volume)); } else { $volume = arabic($volume); } $keys = array($issn, $volume, $spage); if ($debug_openurl) { $openurl_result->debug->keys = $keys; } $url = $config['couchdb_options']['database'] . "/_design/openurl/_view/triple?key=" . urlencode(json_encode($keys)); //echo $url . '<br />'; if ($config['stale']) { $url .= '&stale=ok'; } $resp = $couch->send("GET", "/" . $url); $r = json_decode($resp); //print_r($r); if (count($r->rows) > 0) { foreach ($r->rows as $row) { $match = new stdclass(); $match->match = true; $match->triple = $keys; $match->id = $row->id; $openurl_result->results[] = $match; } } } } } } } /* // full text search if (count($openurl_result->results) == 0) { // Has user supplied an unparsed string? if (isset($context_object->referent->dat)) { find_citation($context_object->referent->dat, $openurl_result, 0.7); } else { find_citation(reference_to_citation_string($context_object->referent), $openurl_result, 0.7); } } */ // ok, if we have one or more results we return these and let user/agent decide what to do $num_results = count($openurl_result->results); if ($context_object->redirect) { $id = 0; if ($num_results == 1) { if ($openurl_result->results[0]->match) { // I'm feeling lucky $id = $openurl_result->results[0]->id; } } // Redirect to reference display, if not found then id is 0 and so we get default error message header('Location: reference/' . $id . "\n\n"); } else { // API call return, populated with details for ($i = 0; $i < $num_results; $i++) { $resp = $couch->send("GET", "/" . $config['couchdb_options']['database'] . "/" . urlencode($openurl_result->results[$i]->id)); $reference = json_decode($resp); if (!isset($reference->error)) { $openurl_result->results[$i]->reference = $reference; } } api_output($openurl_result, $callback); } }
$will_take = $current["width"] + $current["left"] + $spacing; $break = $x + $will_take > $settings["width"] ? true : false; $x = $break ? $will_take : $x + $will_take; $i = $break ? $i + 1 : $i; $y = $begin["height"] * $i + $top + ($i != 0 ? $interline : 0); imagettftext($content, $settings["size"], 0, $settings["width"] - $x, $y, $white, $settings["font"], $word); $first_word = false; } /** Calculate text height */ $textheight = $y + $begin["height"] - $top / 2; /** Draw background rectangle based on textheight */ $image = rectangle($image, 15, (250 - $textheight) / 2 - 5, $settings["width"] + 25, (250 - $textheight) / 2 + 5 + $textheight, 5, $rectangle); imagecopy($image, $content, 20, (250 - $textheight) / 2, 0, 0, $settings["width"], $textheight); // Copy text image to background image $font = "tweet/fonts/GD/cocon.ttf"; $name = arabic("" . $data["name"]); $current = textbox($name, $font, $settings["size"] + 4); $y = (250 - $textheight) / 2 - $current["height"] - $current["top"] + 20; $x = $current["left"] + $current["width"] + 30; $x = $settings["width"] - $x + 10; imagettftext($image, $settings["size"] + 4, 0, $x + 1, $y + 1, $clear, $font, $name); // write Quote name shadow imagettftext($image, $settings["size"] + 4, 0, $x, $y, $color, $font, $name); // write Quote name $current = textbox("ˮ", "tweet/fonts/GD/arial.ttf", 70); // write Quote icon imagettftext($image, 70, 0, $settings["width"] + 20 - $current["width"] + 1, $y + $current["top"] - 15, $color + 1, "tweet/fonts/GD/arial.ttf", "ˮ"); /** Set headers and print the image */ header("Content-type: image/png"); // set PNG header imagepng($image);