Example #1
0
 function key()
 {
     if ($_GET[Q_DB]->contains($_GET[Q_KEY])) {
         $bibdisplay = new BibEntryDisplay($_GET[Q_DB]->getEntryByKey($_GET[Q_KEY]));
         new $this->wrapper($bibdisplay, $bibdisplay->metadata());
         return 'END_DISPATCH';
     } else {
         new NonExistentBibEntryError();
     }
 }
 function test_google_scholar_metadata()
 {
     $test_data = fopen('php://memory', 'x+');
     fwrite($test_data, "@article{aKey,title={A Book},author={Martin Monperrus},publisher={Springer},year=2009,pages={42--4242},number=1}\n" . "@String{x=2008}\n");
     fseek($test_data, 0);
     $db = new BibDataBase();
     $db->update_internal("inline", $test_data);
     $dis = new BibEntryDisplay($db->getEntryByKey('aKey'));
     $metadata = $dis->metadata_dict();
     //print_r($metadata);
     $this->assertEquals("A Book", $metadata['citation_title']);
     $this->assertEquals("2009", $metadata['citation_date']);
     $this->assertEquals("2009", $metadata['citation_year']);
     $this->assertEquals("42", $metadata['citation_firstpage']);
     $this->assertEquals("4242", $metadata['citation_lastpage']);
     $this->assertEquals("1", $metadata['citation_issue']);
 }
Example #3
0
 function test_metadata_opengraph()
 {
     $test_data = fopen('php://memory', 'x+');
     fwrite($test_data, "@article{aKey,title={A Book},author={Martin Monperrus},url={http://foo.com/},publisher={Springer},year=2009,pages={42--4242},number=1}\n" . "@String{x=2008}\n");
     fseek($test_data, 0);
     $db = new BibDataBase();
     $db->update_internal("inline", $test_data);
     $dis = new BibEntryDisplay($db->getEntryByKey('aKey'));
     $metadata = $dis->metadata_dict();
     //print_r($metadata);
     $this->assertEquals("A Book", $metadata['og:title']);
     $this->assertEquals("article", $metadata['og:type']);
     $this->assertTrue(1 == preg_match("/http:.*author=Martin\\+Monperrus/", $metadata['og:author']));
     $this->assertEquals("2009", $metadata['og:published_time']);
 }