Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example without fig sources #103

Open
ppKrauss opened this issue Jan 8, 2016 · 0 comments
Open

Example without fig sources #103

ppKrauss opened this issue Jan 8, 2016 · 0 comments

Comments

@ppKrauss
Copy link

ppKrauss commented Jan 8, 2016

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant