Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
FreeciteRawCitationNlm30CitationSchemaFilter.inc.php
1 <?php
21 import('lib.pkp.plugins.metadata.nlm30.filter.Nlm30CitationSchemaFilter');
22 
23 define('FREECITE_WEBSERVICE', 'http://freecite.library.brown.edu/citations/create');
24 
31  $this->setDisplayName('FreeCite');
32 
33  parent::Nlm30CitationSchemaFilter($filterGroup);
34  }
35 
36  //
37  // Implement template methods from PersistableFilter
38  //
42  function getClassName() {
43  return 'lib.pkp.plugins.citationParser.freecite.filter.FreeciteRawCitationNlm30CitationSchemaFilter';
44  }
45 
46 
47  //
48  // Implement template methods from Filter
49  //
55  function &process(&$input) {
56  $citationString =& $input;
57  $nullVar = null;
58 
59  // Freecite requires a post request
60  $postData = array('citation' => $citationString);
61  if (is_null($resultDOM = $this->callWebService(FREECITE_WEBSERVICE, $postData, XSL_TRANSFORMER_DOCTYPE_DOM, 'POST'))) return $nullVar;
62 
63  // Transform the result into an array of meta-data
64  if (is_null($metadata =& $this->transformWebServiceResults($resultDOM, dirname(__FILE__).DIRECTORY_SEPARATOR.'freecite.xsl'))) return $nullVar;
65 
66  // Extract a publisher from the place string if possible
67  $metadata =& $this->fixPublisherNameAndLocation($metadata);
68 
69  // Convert the genre
70  if (isset($metadata['genre'])) {
71  $genre = $metadata['genre'];
72  import('lib.pkp.plugins.metadata.nlm30.filter.Openurl10Nlm30CitationSchemaCrosswalkFilter');
74  $metadata['[@publication-type]'] = (isset($genreMap[$genre]) ? $genreMap[$genre] : $genre);
75  unset($metadata['genre']);
76  }
77 
78  // Convert article title to source for dissertations
79  if (isset($metadata['[@publication-type]']) && $metadata['[@publication-type]'] == NLM30_PUBLICATION_TYPE_THESIS && isset($metadata['article-title'])) {
80  $metadata['source'] = $metadata['article-title'];
81  unset($metadata['article-title']);
82  }
83 
84  unset($metadata['raw_string']);
85 
86  return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
87  }
88 }
89 ?>
Parsing filter implementation that uses the Freecite web service.
setDisplayName($displayName)
Definition: Filter.inc.php:140
& transformWebServiceResults(&$xmlResult, $xslFileName)
Abstract base class for all filters that transform NLM citation metadata descriptions.
& getNlm30CitationDescriptionFromMetadataArray(&$metadataArray)
& callWebService($url, &$params, $returnType=XSL_TRANSFORMER_DOCTYPE_DOM, $method= 'GET')