OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



full paper export to XML

OCS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, michael

Forum rules
The Public Knowledge Project Support Forum is moving to http://forum.pkp.sfu.ca

This forum will be maintained permanently as an archived historical resource, but all new questions should be added to the new forum. Questions will no longer be monitored on this old forum after March 30, 2015.

full paper export to XML

Postby novakmartin » Fri May 03, 2013 11:36 pm

Hi, I am trying to create a function to export a full paper text in XML in the XML export plugin. I have managed to create the function, but I am unable to get the file contents correctly out.

Here is the code

Code: Select all
$root =& XMLCustomWriter::createElement($doc, 'full_paper_file');

import('file.PaperFileManager');
$paperFileManager = new PaperFileManager($paper->getId());
$fileNode =& XMLCustomWriter::createElement($doc, 'file');
XMLCustomWriter::appendChild($root, $fileNode);
      
$embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($paperFileManager->readFile($paper->getFileId())));

XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
XMLCustomWriter::setAttribute($embedNode, 'mime_type', 'application/pdf');



The function crashed at the $embedNode ... line, the $paper->getFileId() does not get the nothing. If I use getPaperId() is get correctly the paper ID. The function should embed the whole paper file in the latest revision in the xml file. Please help. Thanks
novakmartin
 
Posts: 2
Joined: Fri May 03, 2013 11:27 pm

Re: full paper export to XML

Postby asmecher » Tue May 07, 2013 2:42 pm

Hi novakmartin,

Check your error logs; it's likely that you hit a PHP memory limit or something similar when encoding the file contents.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 10015
Joined: Wed Aug 10, 2005 12:56 pm

Re: full paper export to XML

Postby novakmartin » Thu May 09, 2013 11:17 pm

I have found a working solution. One of the problems was that the paper have not been assigned to directors, so the getFileId function did not return anything.
Here goes the working code

Code: Select all
function &generateFullPaperFile(&$doc, &$schedConf, &$paper) {
      $root =& XMLCustomWriter::createElement($doc, 'full_paper_file');

      import('file.PaperFileManager');
      $paperFileManager = new PaperFileManager($paper->getId());
      
      $fileNode =& XMLCustomWriter::createElement($doc, 'file');
      XMLCustomWriter::appendChild($root, $fileNode);

      // this works only is the papers are already assigned to Directors, i.e. in director directory
      $embedNode =& XMLCustomWriter::createChildWithText($doc, $fileNode, 'embed', base64_encode($paperFileManager->readFile($paper->getDirectorFileId())));      
      XMLCustomWriter::setAttribute($embedNode, 'encoding', 'base64');
      XMLCustomWriter::setAttribute($embedNode, 'mime_type', 'application/pdf'); /*application/pdf*/
      
      return $root;


This is then called from function &generatePaperDom in NativeExportDom.inc.php


Code: Select all
/* --- Full Paper Files --- */
         $fullPAP =& NativeExportDom::generateFullPaperFile($doc, $schedConf, $paper);
         if ($fullPAP !== null) XMLCustomWriter::appendChild($root, $fullPAP);
         unset($fullPAP);


Now the generated .xml file contains the full paper text.
novakmartin
 
Posts: 2
Joined: Fri May 03, 2013 11:27 pm


Return to OCS Development

Who is online

Users browsing this forum: No registered users and 0 guests

cron