OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Exporting journal (XML file)

Are you an Editor, Author, or Journal Manager in need of help? Want to talk to us about workflow issues? This is your forum.

Moderators: jmacgreg, michael, vgabler, John

Forum rules
This forum is meant for general questions about the usability of OJS from an everyday user's perspective: journal managers, authors, and editors are welcome to post questions here, as are librarians and other support staff. We welcome general questions about the role of OJS and how the workflow works, as well as specific function- or user-related questions.

What to do if you have general, workflow or usability questions about OJS:

1. Read the documentation. We've written documentation to cover from OJS basics to system administration and code development, and we encourage you to read it.

2. take a look at the tutorials. We will continue to add tutorials covering OJS basics as time goes on.

3. Post a question. Questions are always welcome here, but if it's a technical question you should probably post to the OJS Technical Support subforum; if you have a development question, try the OJS Development subforum.

Exporting journal (XML file)

Postby arnost » Tue Apr 12, 2005 12:21 pm

Hi,
I wrote this script which can export journal and article metadata. It should export in same format which is accepted by xmlimport.php.

This is first testing version, have some bugs. (Did't check for undefined values, so sometimes produces empty tags like <address></address> instead of skipping this tag.)

Is somebody interested? Have any comments?

thanks for your reply

Arnost Valicek

Code: Select all
<?php

//
// Open Journal Systems 1.1
// (c) The Public Knowledge Project 2003
// http://www.pkp.ubc.ca
//
// This file is part of Open Journal Systems.
//
// Open Journal Systems is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Open Journal Systems is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Open Journal Systems; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// admin/editor/xmlexport.php
// journal setup - table of contents and db creation

include("../../include/common.php");

if(!validEditor()) {
   redirect("admin/index.php");
}

function getFilenameForID($articleID) {
   $articlesql = "select * from tblfiles where nFileID='$articleID'";
   $articlesquery = $db->query($articlesql);
   $row = $db->assoc_array($articlesquery);

   return $row['chFileName'];
}

if ($db_connected) {

   header("Content-type: text/xml");
   header("Content-disposition: inline; filename=journal_export.xml");

   echo "<?xml version=\"1.0\" encoding=\""._tr('HTML_CHARSET')."\"?>\n";
   echo "<archive>\n";

   //get file path - contains HTML, PDF... files
   $fpq=$db->query("select  chFilePath from tbljournalconfig");
   $row = $db->assoc_array($fpq);
   $files_path = $row['chFilePath'];


   //list issues (only published!)
        $issues = $db->query("select * from tblissues where bPublished=1");
   $num_i = $db->num_rows($issues);
   for ($i=0; $i<$num_i; $i++) {
      $row = $db->assoc_array($issues, $i);
      extract($row);

      echo "   <issue>\n";
      ?>
      <issue_description>
         <title><?php echo $chIssueTitle ?></title>
         <volume><?php echo $nVolume ?></volume>
         <number><?php echo $nNumber ?></number>
         <year><?php echo $nYear ?></year>
      </issue_description>

      <?php
      // for each published issue, do:
      if ($bPublished == '1') {
         //echo "****** $nIssueID - $chIssueTitle - $nVolume - $nNumber ******<br/>\n";

         $articles = $db->query("select *, DATE_FORMAT(dtDateSubmitted,'%Y/%m/%d') as dateSubmitted, DATE_FORMAT(dtDatePublished,'%Y/%m/%d') as datePublished   from tblarticles where fkIssueID=$nIssueID order by nOrder ");
         $num_a = $db->num_rows($articles);

         for ($j=0; $j<$num_a; $j++) {
            $row_a = $db->assoc_array($articles, $j);
            extract($row_a);
            //echo "$nArticleID  - $chMetaTitle - $chMetaFormat - $chWorldID <br/>\n";
         ?>

         <article>
         <?php
            #find section name
            $sections = $db->query("select *from tblsections where nSectionID=$fkSectionID");
            $sect_row =  $db->assoc_array($sections,0);
         ?>
         <section><?php echo $sect_row['chTitle']?></section>
         <number><?php echo $nOrder ?></number>
         <title><?php echo $chMetaTitle ?></title>
         <abstract><?php echo $chMetaAbstract ?></abstract>

         <date_submitted><?php echo $dateSubmitted ?></date_submitted>
         <date_published><?php echo $datePublished ?></date_published>
         <html><?php
            //echo getFilenameForID($fkFileHTMLID);
            $articlesql = "select * from tblfiles where nFileID='$fkFileHTMLID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];
         ?></html>

         <pdf><?php
            //echo $fkFilePDFID
            $articlesql = "select * from tblfiles where nFileID='$fkFilePDFID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];
         ?></pdf>
         <postscript><?php
            //echo $fkFilePostScriptID
            $articlesql = "select * from tblfiles where nFileID='$fkFilePostScriptID'";
            $articlesquery = $db->query($articlesql);
            $row = $db->assoc_array($articlesquery);
            echo $files_path.$row['chFileName'];

         ?></postscript>
         <language><?php echo $chMetaLanguage ?></language>
         <discipline><?php echo $chMetaDiscipline ?></discipline>
         <subject><?php echo $chMetaSubject ?></subject>
         <subject_class><?php echo $chMetaSubjectClass ?></subject_class>
         <coverage_geo><?php echo $chMetaCoverageGeo ?></coverage_geo>
         <coverage_chron><?php echo $chMetaCoverageChron ?></coverage_chron>
         <coverage_sample><?php echo $chMetaCoverageSample ?></coverage_sample>
         <!--<approach><?php echo $chXXX ?></approach>
         <sponsor><?php echo $chXXX ?></sponsor>-->
         <?php
         //get authors of this article

         $authors = $db->query("select chFirstName,chSurname,chEmail from tblmetaauthors where fkArticleID=$nArticleID");
         $num_au = $db->num_rows($authors);
         for ($k=0; $k<$num_au; $k++) {
            $row_au = $db->assoc_array($authors , $k);
            extract($row_au);

            ?>

               <author><?php
               if ($chFirstName!="") {
                  echo "<first_name>$chFirstName</first_name>";
               }
               if ($chMiddleInitial !="") {
                  echo "<middle_initial>$chMiddleInitial</middle_initial";
               }
               if ($chSurname!="") {
                  echo "<last_name>$chSurname</last_name>";
               }
               if ($chEmail !="") {
                  echo "<email>$chEmail</email>";
               }
               if ($chAffiliation!="") {
                  echo "<affiliation>$chAffiliation</affiliation>";
               }
               if ($chPhone !="") {
                  echo "<phone>$chPhone</phone>";
               }
               if ($chFax !="") {
                  echo "<fax>$chFax</fax>";
               }
               if ($chMailAddr  !="") {
                  echo "<address>$chMailAddr</address>";
               }
               if ($chBiography !="") {
                  echo "<biography>$chBiography</biography>";
               }
               ?>
               </author>
            <?php
            }
            ?>

         </article>
         <?php
         }
      }
      echo "   </issue>\n";
   }

   echo "</archive>";

}
arnost
 
Posts: 5
Joined: Thu Jan 22, 2004 2:27 am

thanks to share !

Postby mbria » Thu Feb 23, 2006 4:16 am

Thanks to share arnost,

I will use your code as a base for a future issue of indexation that I need to fix.

Cheers,

m.
mbria
 
Posts: 292
Joined: Wed Dec 14, 2005 4:15 am

Postby asmecher » Thu Feb 23, 2006 10:54 am

FYI, this code is applicable to OJS 1.x. For OJS 2.x, see the Journal Manager's "Import/Export Data" functions (which make use of the import/export plugins).

Regards,
Alec Smecher
Open Journal Systems Team
asmecher
 
Posts: 8470
Joined: Wed Aug 10, 2005 12:56 pm

Postby mbria » Fri Feb 24, 2006 3:41 am

thanks for the advice.
mbria
 
Posts: 292
Joined: Wed Dec 14, 2005 4:15 am


Return to OJS Editorial Support and Discussion

Who is online

Users browsing this forum: Bing [Bot] and 2 guests