ajnyga / embedGalley

OJS3 plugin for visualizing JATS XML galleys
GNU General Public License v3.0
8 stars 3 forks source link

Including Images #2

Closed GrazingScientist closed 6 years ago

GrazingScientist commented 6 years ago

Hi there!

I just uploaded this xml file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "TextureArticle 0.1.0" "http://substance.io/TextureArticle-1.0.0.dtd">
<article id="article" xmlns:xlink="http://www.w3.org/1999/xlink">
  <front id="front-1">
    <article-meta id="article-meta-1">
      <title-group id="title-group-1">
        <article-title id="article-title-1">This is a Nice Test Article</article-title>
      </title-group>
      <history id="history-1" />
      <abstract id="abstract-1">
        <p id="p-1">A nice article not in need of any abstract.</p>
      </abstract>
    </article-meta>
  </front>
  <body id="body-1">
    <p id="p-2">Well, I have to write something.</p>
    <fig id="fig-7ca66d845ea9ec67723b37adf209b6fc">
      <object-id id="object-id-3cae7257ceed7091fb226510f4bc922f">fig-7ca66d845ea9ec67723b37adf209b6fc</object-id>
      <label>Figure 1</label>
      <caption id="caption-940ee25b59a2f2982561703336202d60">
        <title id="title-5e83b2c705efd3ff3664c4a847316410">A title</title>
        <p id="p-95ed9f3dcf7c1330940737588b114b05">A caption</p>
      </caption>
      <graphic id="graphic-bfd8aceaa6d085a3e5edc2e070942909" mime-subtype="jpeg" mimetype="image" xlink:href="e862c6fa801d48141fd64505eb397f94.jpg" />
    </fig>
  </body>
  <back id="back-1">
    <ref-list id="ref-list-1" />
  </back>
</article>

When uploading only this (not the image file), my article page loses its sidebar... How can I included images without giving a link to the file but uploading it directly in the backend?

Edit: When the sidebar gets lost, the log tells me: "Uncaught Error: Call to undefined method stdClass::saveHTML()". Perhaps this helps....

ajnyga commented 6 years ago

what ojs version do you use?

GrazingScientist commented 6 years ago

Sorry! It's OJS 3.1.1.2

ajnyga commented 6 years ago

ok, I guess something has changed in OJS.

I am planning to upgrade our own OJS installation to latest version during July and will check this plugin then as well while we have one journal using it. I will let you know when it is ready.

GrazingScientist commented 6 years ago

Thanks! You are awesome! 🥇

ajnyga commented 6 years ago

You could make sure that you have both DOM and libxml extensions installed in your server.

You should see "DOM/XML enabled" and "libxml active" in Administration => System Information => Extended PHP Information (bottom of page).

GrazingScientist commented 6 years ago

"DOM/XML" is "enabled". "libXML support" is "active". Does the version matter? "DOM/XML API Version" is version 20031129. libXML is version 2.9.1 .

ajnyga commented 6 years ago

ok thanks, I will get back to you once I do the upgrade (probably during next week)

GrazingScientist commented 6 years ago

I was digging further in this regard and now found that the solution to the given problem seems to be caused earlier in the code. However, since I have no idea of PHP, I hope for your help. My error log is this:

PHP Warning: XSLTProcessor::transformToDoc(): runtime error: file /testling/plugins/ge neric/embedGalley/xsl/jats-to-html.xsl line 999 element copy-of in /testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.273648 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: XSLTProcessor::transformToDoc(): Cannot add an attribute node to a non-element node. in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.274111 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: XSLTProcessor::transformToDoc(): runtime error: file testling/plugins/ge neric/embedGalley/xsl/jats-to-html.xsl line 999 element copy-of in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.274140 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: XSLTProcessor::transformToDoc(): Attribute nodes must be added before any child nodes to an element. in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.274365 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: XSLTProcessor::transformToDoc(): runtime error: file testling/plugins/generic/embedGalley/xsl/jats-to-html.xsl line 999 element copy-of in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.274385 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: XSLTProcessor::transformToDoc(): Attribute nodes must be added before any child nodes to an element. in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 207 [Tue Sep 25 11:34:08.276973 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Warning: Creating default object from empty value in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 208 [Tue Sep 25 11:34:08.278488 2018] [:error] [pid 3502] [client 141.2.31.132:49468] PHP Fatal error: Uncaught Error: Call to undefined method stdClass::saveHTML() in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php:210\nStack trace:\n#0 testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php(168): EmbedGalleyPlugin->_parseXml(Object(SubmissionFile))\n#1 testling/lib/pkp/classes/plugins/HookRegistry.inc.php(107): EmbedGalleyPlugin->embedHtml('Templates::Arti...', Array)\n#2 testling/lib/pkp/classes/template/PKPTemplateManager.inc.php(1145): HookRegistry::call('Templates::Arti...', Array)\n#3 testling/cache/t_compile/42362804174f266c598cdb32c3208fc745b92101^%%2D^2D7^2D7EC92F%%article.tpl.php(32): PKPTemplateManager->smartyCallHook(Array, Object(TemplateManager))\n#4 testling/lib/pkp/lib/vendor/smarty/smarty/libs/Smarty.class.php(1257): include('...')\n#5 testling/lib/pkp/classes/template/PKPTemplateManager.inc in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 210

I excluded the parental directory in this log. I also tried a file given my asmecher, which causes this error: https://github.com/asmecher/texture/blob/master/texture/data/kitchen-sink/manuscript.xml

Can you help?

ajnyga commented 6 years ago

So it seems that at some point I did changes to the plugin which I did not upgrade here. I added the current version as a new release here: https://github.com/ajnyga/embedGalley/releases

We are using that exact same version in one of our journals and using OJS 3.1.1.2

GrazingScientist commented 6 years ago

Thanks! This removed the problem, but resulted in another one:

PHP Warning: DOMDocument::load(https://ojs.ub.uni-frankfurt.de/testling/plugins/generic/embedGalley/xsl/APA.xsl): failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized\r\n in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 250, referer: https://ojs.ub.uni-frankfurt.de/testling/index.php/ltz/index [Tue Sep 25 13:28:44.770173 2018] [:error] [pid 22121] [client 141.2.31.132:52768] PHP Warning: DOMDocument::load(): Attempt to load network entity http://substance.io/TextureArticle-1.0.0.dtdValidation failed: no DTD found !I/O warning : failed to load external entity "https://ojs.ub.uni-frankfurt.de/testling/plugins/generic/embedGalley/xsl/APA.xsl&quot; in testling/plugins/generic/embedGalley/EmbedGalleyPlugin.inc.php on line 250, referer: https://ojs.ub.uni-frankfurt.de/testling/index.php/ltz/index

I checked the rights and all are read and writeable by the Apache...

GrazingScientist commented 6 years ago

I assume this is because my Apache server wants a login. I would say, a more generic solution would be to use the path of the directory of the plugin. Not?!

ajnyga commented 6 years ago

true!

ajnyga commented 6 years ago

Does it work with: $path = Core::getBaseDir() . DIRECTORY_SEPARATOR . $this->getPluginPath() . DIRECTORY_SEPARATOR . 'xsl' . DIRECTORY_SEPARATOR . $citation_style . ".xsl";

here: https://github.com/ajnyga/embedGalley/blob/master/EmbedGalleyPlugin.inc.php#L247

GrazingScientist commented 6 years ago

Your code snippet removed the mentioned error. Yes! 👍

GrazingScientist commented 6 years ago

Shall I close this issue, because the mentioned error is resolved or may I post additional errors here?

ajnyga commented 6 years ago

Great, thanks for the feedback!

I will make that change to the code and do a new release.

I remember seeing the same error when I have done test upgrades of our production server, but never looked into this because the code of course worked on the production server without htaccess protection. Glad to have this sorted out, thanks :)

Go ahead and close this and start a new issue if needed. Just a heads up that during the winter I will see whether to start using this plugin or to use something based on the JatsParser plugin that is built for example into the OldGregg theme.

What I would like to see is a embed plugin that would show the article in the abstract page, but would still result into hits in the download counters. I have an idea how to accomplish this, but sure yet if it is actually possible.

GrazingScientist commented 6 years ago

I am looking forward to any new release! :)