Page MenuHomeDevCentral

No OneTemporary

diff --git a/book.php b/book.php
index c10c477..7ea77bb 100644
--- a/book.php
+++ b/book.php
@@ -1,62 +1,64 @@
<?php
+use EasyRdf\Graph;
+
class Book {
/**
* OCLC number
*/
public $OCLC;
public function queryWorldCatFromOCLC () {
$oclc = (string)(int)$this->OCLC;
$url = 'http://www.worldcat.org/oclc/' . $oclc;
- $rdf = new EasyRdf_Graph($url . '.rdf');
+ $rdf = new Graph($url . '.rdf');
$rdf->load();
$resources = $rdf->resources();
$book = $resources[$url];
//Core info
$this->Title = (string)$book->getLiteral('schema:name');
$publisherData = $book->get('schema:publisher');
if ($publisherData) {
$this->Publisher = (string)$publisherData->get('schema:name');
}
//Publishing date
$date = (string)$book->getLiteral('schema:datePublished');
if (strlen($date) == 4) {
$this->YYYY = $date;
} else {
echo '<div class="alert-box">Publishing date: ', $date, " / check the template, the code doesn't know how to parse this format and only made a guess. ",
'<a href="" class="close">&times;</a></div>';
$date = date_parse($date);
$this->YYYY = $date['year'];
$this->MM = $date['month'];
$this->DD = $date['day'];
}
//Authors
$this->Authors = [];
//TODO: look type mapping
$contributors = $book->allResources('schema:contributor');
foreach ($contributors as $contributor) {
$this->Authors[] = [
(string)$contributor->get('schema:givenName'),
(string)$contributor->get('schema:familyName')
];
}
//Kludge for library:placeOfPublication
//We have generally two links, one for the city, one for the country.
//Only the city has a schema:name, the country is only a reference.
$rdf_content = file_get_contents($url . '.rdf');
if (preg_match_all('@<library:placeOfPublication rdf:resource="(.*)"/>@', $rdf_content, $matches)) {
foreach ($matches[1] as $place) {
if ($cityCandidate = (string)$resources[$place]->get('schema:name')) {
$this->Place = $cityCandidate;
break;
}
}
}
}
}
diff --git a/composer.json b/composer.json
index 8534a32..2949e98 100644
--- a/composer.json
+++ b/composer.json
@@ -1,30 +1,30 @@
{
"name": "dereckson/source-templates-generator",
"description": "Generates sources and references templates for Wikipedia",
"type": "package",
"keywords": [
"wikipedia",
"cite",
"sources",
"templates",
"generator"
],
"homepage": "http://tools.nasqueron.org/wikimedia/write/sourcetemplatesgenerator/",
"license": "GPL-3.0-only",
"authors": [
{
"name": "Sébastien Santoro aka Dereckson",
"email": "dereckson@espace-win.org",
"homepage": "http://www.dereckson.be/"
}
],
"require": {
"php": ">=5.4",
- "easyrdf/easyrdf": "*"
+ "easyrdf/easyrdf": "~1.1.1"
},
"support": {
"issues": "http://devcentral.nasqueron.org/tag/nasqueron_tools/",
"irc": "irc://irc.freenode.net/wikipedia-fr",
"source": "https://github.com/dereckson/source-templates-generator/"
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Jul 8, 15:08 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3903902
Default Alt Text
(3 KB)

Event Timeline