Example without fig sources
ppKrauss opened this issue · 0 comments
ppKrauss commented
At tests/example.xml there are no image... So run example at test/index.php also without.
Alternative to send figs by git, and generalize the local build of an HTML, using fig's DOI... But need an PeerJ API to get image file from DOI-fig.
$xpath = new DOMXPath($document);
foreach($xpath->query('//fig|//table') as $e) {
$id = $e->getAttribute('id');
$out = "\n -- {$e->tagName} $id";
foreach($xpath->query('.//graphic',$e) as $g) {
$gfile = $g->getAttribute('xlink:href');
print "$out\n\t file: $gfile";
$out = '';
if (file_exists(__DIR__.$gfile))
print " OK!";
else {
$oid = $xpath->query('object-id[@pub-id-type="doi"]',$e)->item(0);
if ($oid) {
$doi = $oid->nodeValue;
print " without file here, get it from DOI $doi...";
$bin = file_get_contents("http://dx.doi.org/$doi");
if ($bin) {
// OPS, WHERE THE API for get full-image!?
// Example, DOI:10.7717/peerj.182/fig-1 must be transtated to
// https://dfzljdn9uc3pi.cloudfront.net/2013/182/1/fig-1-2x.jpg
file_put_contents($gfile,$bin);
print " OK!";
} else
print " ops, NO ONLINE FILE";
} else
print "... no DOI";
}
} // graphic
} // graphic-container