plugins/importexport/mets/MetsExportDom.inc.php

00001 <?php
00002 
00015 //$Id$
00016 
00017 import('xml.XMLCustomWriter');
00018 
00019 class MetsExportDom {
00020 
00024    function generateConfstructMapWithSchedConfs(&$doc, &$root, &$conference, &$schedConfs) {
00025       $structMap =& XMLCustomWriter::createElement($doc, 'METS:structMap');
00026       XMLCustomWriter::setAttribute($structMap, 'TYPE', 'logical');
00027       $cDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00028       XMLCustomWriter::setAttribute($cDiv, 'TYPE', 'series');
00029       XMLCustomWriter::setAttribute($cDiv, 'DMDID', 'CS-'.$conference->getId());
00030       XMLCustomWriter::setAttribute($cDiv, 'ADMID', 'A-'.$conference->getId());
00031       foreach ($schedConfs as $schedConf) {
00032          MetsExportDom::generateSchedConfDiv($doc, $cDiv, $schedConf);
00033       }
00034       XMLCustomWriter::appendChild($structMap, $cDiv);
00035       XMLCustomWriter::appendChild($root, $structMap);
00036    }
00037 
00041    function generateConfstructMapWithSchedConfsIdArray(&$doc, &$root, &$conference, &$schedConfIdArray) {
00042       $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00043       $structMap =& XMLCustomWriter::createElement($doc, 'METS:structMap');
00044       XMLCustomWriter::setAttribute($structMap, 'TYPE', 'logical');
00045       $cDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00046       XMLCustomWriter::setAttribute($cDiv, 'TYPE', 'series');
00047       XMLCustomWriter::setAttribute($cDiv, 'DMDID', 'CS-'.$conference->getId());
00048       XMLCustomWriter::setAttribute($cDiv, 'ADMID', 'A-'.$conference->getId());
00049       $i = 0;
00050       while ($i < sizeof($schedConfIdArray)) {
00051          $schedConf =& $schedConfDAO->getSchedConf($schedConfIdArray[$i]);
00052          MetsExportDom::generateSchedConfDiv($doc, $cDiv, $schedConf);
00053          $i++;
00054       }
00055       XMLCustomWriter::appendChild($structMap, $cDiv);
00056       XMLCustomWriter::appendChild($root, $structMap);
00057    }
00058 
00062    function generateConfstructMapWithSchedConf(&$doc, &$root, &$conference, &$schedConf) {
00063       $structMap =& XMLCustomWriter::createElement($doc, 'METS:structMap');
00064       XMLCustomWriter::setAttribute($structMap, 'TYPE', 'logical');
00065       $cDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00066       XMLCustomWriter::setAttribute($cDiv, 'TYPE', 'series');
00067       XMLCustomWriter::setAttribute($cDiv, 'DMDID', 'CS-'.$conference->getId());
00068       XMLCustomWriter::setAttribute($cDiv, 'ADMID', 'A-'.$conference->getId());
00069       MetsExportDom::generateSchedConfDiv($doc, $cDiv, $schedConf);
00070       XMLCustomWriter::appendChild($structMap, $cDiv);
00071       XMLCustomWriter::appendChild($root, $structMap);
00072    }
00073 
00077    function generateSchedConfDiv(&$doc, &$root, &$schedConf) {
00078       $sDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00079       XMLCustomWriter::setAttribute($sDiv, 'TYPE', 'conference');
00080       XMLCustomWriter::setAttribute($sDiv, 'DMDID', 'SCHC-'.$schedConf->getId());
00081       MetsExportDom::generateOverViewDiv($doc, $sDiv, $schedConf);
00082       $publishedPaperDAO =& DAORegistry::getDAO('PublishedPaperDAO');
00083       $publishedPapersIterator =& $publishedPaperDAO->getPublishedPapers($schedConf->getId());
00084       $publishedPaperArray =& $publishedPapersIterator->toArray();
00085 
00086       $i = 0;
00087       while ($i < sizeof($publishedPaperArray)) {
00088         MetsExportDom::generatePublishedPaperDiv($doc, $sDiv, $publishedPaperArray[$i], $schedConf);
00089         $i++;
00090       }
00091       XMLCustomWriter::appendChild($root, $sDiv);
00092    }
00093 
00097    function generateOverViewDiv(&$doc, &$root, &$schedConf) {
00098       $schedConfSettingsDAO =& DAORegistry::getDAO('SchedConfSettingsDAO');
00099       $schedConfOverview = $schedConfSettingsDAO->getSetting($schedConf->getId(), 'schedConfOverview');
00100       $schedConfIntroduction = $schedConfSettingsDAO->getSetting($schedConf->getId(), 'schedConfIntroduction');
00101       if($schedConfOverview != '' || $schedConfIntroduction != ''){
00102          $sDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00103          XMLCustomWriter::setAttribute($sDiv, 'TYPE', 'overview');
00104          XMLCustomWriter::setAttribute($sDiv, 'DMDID', 'OV-'.$schedConf->getId());
00105          XMLCustomWriter::appendChild($root, $sDiv);
00106       }
00107    }
00108 
00112    function generatePublishedPaperDiv(&$doc, &$root, &$paper, &$schedConf) {
00113       $pDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00114       XMLCustomWriter::setAttribute($pDiv, 'TYPE', 'submission');
00115       XMLCustomWriter::setAttribute($pDiv, 'DMDID', 'P'.$paper->getId());
00116       $paperGalleyDAO =& DAORegistry::getDAO('PaperGalleyDAO');
00117       $i = 0;
00118       $galleysArray =& $paperGalleyDAO->getGalleysByPaper($paper->getId());
00119       while ($i < sizeof($galleysArray)) {
00120          MetsExportDom::generatePaperFileDiv($doc, $pDiv,  $galleysArray[$i]);
00121          $i++;
00122       }
00123       $exportSuppFiles =& Request::getUserVar('exportSuppFiles');
00124       $rtDao =& DAORegistry::getDAO('RTDAO');
00125       $conferenceRt =& $rtDao->getConferenceRTByConference($schedConf->getConference());
00126       if($exportSuppFiles == 'on' || $conferenceRt->getEnabled()) {
00127          $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
00128          $paperFilesArray =& $suppFileDAO->getSuppFilesByPaper($paper->getId());
00129          $i = 0;
00130          while ($i < sizeof($paperFilesArray)) {
00131             MetsExportDom::generatePaperSuppFilesDiv($doc, $pDiv, $paperFilesArray[$i]);
00132             $i++;
00133          }
00134       }
00135       XMLCustomWriter::appendChild($root, $pDiv);
00136    }
00137 
00141    function generatePaperFileDiv(&$doc, &$root, $paperFile) {
00142       $fDiv =& XMLCustomWriter::createElement($doc, 'METS:fptr');
00143       XMLCustomWriter::setAttribute($fDiv, 'FILEID', 'F'.$paperFile->getFileId().'-P'.$paperFile->getPaperId());
00144       XMLCustomWriter::appendChild($root, $fDiv);
00145    }
00146 
00150    function generateConfDmdSecDom(&$doc, $root, &$conference) {
00151       $dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
00152       XMLCustomWriter::setAttribute($dmdSec, 'ID', 'CS-'.$conference->getId());
00153       $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00154       $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00155       XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
00156       $mods =& XMLCustomWriter::createElement($doc, 'mods:mods');
00157       XMLCustomWriter::setAttribute($mods, 'xmlns:mods', 'http://www.loc.gov/mods/v3');
00158       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd');
00159       $titleInfo =& XMLCustomWriter::createElement($doc, 'mods:titleInfo');
00160       XMLCustomWriter::createChildWithText($doc, $titleInfo, 'mods:title', $conference->getConferenceTitle());
00161       XMLCustomWriter::appendChild($mods, $titleInfo);
00162       XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', 'series');
00163       XMLCustomWriter::appendChild($xmlData, $mods);
00164       XMLCustomWriter::appendChild($dmdSec, $mdWrap);
00165       XMLCustomWriter::appendChild($mdWrap,$xmlData);
00166       XMLCustomWriter::appendChild($root, $dmdSec);
00167    }
00168 
00172    function generateSchedConfDmdSecDom(&$doc, &$root, &$conference, &$schedConf) {
00173       $dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
00174       XMLCustomWriter::setAttribute($dmdSec, 'ID', 'SCHC-'.$schedConf->getId());
00175       $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00176       $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00177       XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
00178       $mods =& XMLCustomWriter::createElement($doc, 'mods:mods');
00179       XMLCustomWriter::setAttribute($mods, 'xmlns:mods', 'http://www.loc.gov/mods/v3');
00180       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd');
00181       $titleInfo =& XMLCustomWriter::createElement($doc, 'mods:titleInfo');
00182       XMLCustomWriter::createChildWithText($doc, $titleInfo, 'mods:title', $schedConf->getSchedConfTitle());
00183       XMLCustomWriter::appendChild($mods, $titleInfo);
00184       XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', 'conference');
00185       if($schedConf->getStartDate() != '' || $schedConf->getEndDate() != ''){
00186          $originInfo =& XMLCustomWriter::createElement($doc, 'mods:originInfo');
00187          if($schedConf->getStartDate() != ''){
00188             $sDate = XMLCustomWriter::createChildWithText($doc, $originInfo, 'mods:dateOther', $schedConf->getStartDate());
00189             XMLCustomWriter::setAttribute($sDate, 'point', 'start');
00190          }
00191          if($schedConf->getEndDate() != ''){
00192             $sDate = XMLCustomWriter::createChildWithText($doc, $originInfo, 'mods:dateOther', $schedConf->getEndDate());
00193             XMLCustomWriter::setAttribute($sDate, 'point', 'end');
00194          }
00195          XMLCustomWriter::appendChild($mods, $originInfo);
00196       }
00197       XMLCustomWriter::appendChild($xmlData, $mods);
00198       XMLCustomWriter::appendChild($dmdSec, $mdWrap);
00199       XMLCustomWriter::appendChild($mdWrap,$xmlData);
00200       XMLCustomWriter::appendChild($root, $dmdSec);
00201       MetsExportDom::generateOverViewDmdSecDom($doc, $root, $schedConf);
00202       $publishedPaperDAO =& DAORegistry::getDAO('PublishedPaperDAO');
00203       $publishedPapersIterator =& $publishedPaperDAO->getPublishedPapers($schedConf->getId());
00204       $publishedPaperArray =& $publishedPapersIterator->toArray();
00205 
00206       $i = 0;
00207       while ($i < sizeof($publishedPaperArray)) {
00208          MetsExportDom::generatePublishedPaperDmdSecDom($doc, $root, $publishedPaperArray[$i], $conference, $schedConf);
00209          $i++;
00210       }
00211    }
00212 
00216    function generateOverViewDmdSecDom(&$doc, $root, &$schedConf) {
00217       $schedConfSettingsDAO =& DAORegistry::getDAO('SchedConfSettingsDAO');
00218       $schedConfOverview = $schedConfSettingsDAO->getSetting($schedConf->getId(), 'schedConfOverview');
00219       $schedConfIntroduction = $schedConfSettingsDAO->getSetting($schedConf->getId(), 'schedConfIntroduction');
00220       if($schedConfOverview != '' || $schedConfIntroduction != ''){
00221          $dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
00222          XMLCustomWriter::setAttribute($dmdSec, 'ID', 'OV-'.$schedConf->getId());
00223          $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00224          $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00225          XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
00226          $mods =& XMLCustomWriter::createElement($doc, 'mods:mods');
00227          XMLCustomWriter::setAttribute($mods, 'xmlns:mods', 'http://www.loc.gov/mods/v3');
00228          XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd');
00229          if($schedConfOverview != ''){
00230             $overviewNode = XMLCustomWriter::createChildWithText($doc, $mods, 'mods:abstract', $schedConfOverview);
00231             XMLCustomWriter::setAttribute($overviewNode, 'type', 'overview');
00232          }
00233          if($schedConfIntroduction != ''){
00234             $introNode = XMLCustomWriter::createChildWithText($doc, $mods, 'mods:abstract', $schedConfIntroduction);
00235             XMLCustomWriter::setAttribute($introNode, 'type', 'introduction');
00236          }
00237          XMLCustomWriter::appendChild($xmlData, $mods);
00238          XMLCustomWriter::appendChild($dmdSec, $mdWrap);
00239          XMLCustomWriter::appendChild($mdWrap,$xmlData);
00240          XMLCustomWriter::appendChild($root, $dmdSec);
00241       }
00242    }
00243 
00247    function generatePublishedPaperDmdSecDom(&$doc, &$root, &$paper, &$conference, &$schedConf) {
00248       if($paper->getStatus() == STATUS_PUBLISHED){
00249          $dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
00250          XMLCustomWriter::setAttribute($dmdSec, 'ID', 'P'.$paper->getId());
00251          $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00252          $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00253          XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
00254          $mods =& XMLCustomWriter::createElement($doc, 'mods:mods');
00255          XMLCustomWriter::setAttribute($mods, 'xmlns:mods', 'http://www.loc.gov/mods/v3');
00256          XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd');
00257 
00258          $primaryLocale = $conference->getPrimaryLocale();
00259          foreach ($paper->getTitle(null) as $locale => $title) {
00260             $titleInfo =& XMLCustomWriter::createElement($doc, 'mods:titleInfo');
00261             XMLCustomWriter::createChildWithText($doc, $titleInfo, 'mods:title', $title);
00262             if ($locale != $primaryLocale) XMLCustomWriter::setAttribute($titleInfo, 'type', 'alternative');
00263             XMLCustomWriter::appendChild($mods, $titleInfo);
00264             unset($titleInfo);
00265          }
00266 
00267          foreach ($paper->getAbstract(null) as $locale => $abstract) {
00268             XMLCustomWriter::createChildWithText($doc, $mods, 'mods:abstract', $abstract);
00269          }
00270 
00271          MetsExportDom::generateAuthorsDom($doc, $mods, $paper->getId());
00272          XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', 'submission');
00273          if($paper->getDatePublished() != ''){
00274             $originInfo =& XMLCustomWriter::createElement($doc, 'mods:originInfo');
00275             $sDate = XMLCustomWriter::createChildWithText($doc, $originInfo, 'mods:dateIssued', $paper->getDatePublished());
00276             XMLCustomWriter::appendChild($mods, $originInfo);
00277          }
00278          XMLCustomWriter::appendChild($xmlData, $mods);
00279          XMLCustomWriter::appendChild($dmdSec, $mdWrap);
00280          XMLCustomWriter::appendChild($mdWrap,$xmlData);
00281          XMLCustomWriter::appendChild($root, $dmdSec);
00282          $exportSuppFiles =& Request::getUserVar('exportSuppFiles');
00283          $rtDao =& DAORegistry::getDAO('RTDAO');
00284          $conferenceRt =& $rtDao->getConferenceRTByConference($schedConf->getConference());
00285          if($exportSuppFiles == 'on' || $conferenceRt->getEnabled()) {
00286             $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
00287             $paperFilesArray =& $suppFileDAO->getSuppFilesByPaper($paper->getId());
00288             $i = 0;
00289             while ($i < sizeof($paperFilesArray)) {
00290                MetsExportDom::generatePaperSuppFilesDmdSecDom($doc, $root, $paperFilesArray[$i], $conference, $schedConf);
00291                $i++;
00292             }
00293          }
00294       }
00295    }
00296 
00300    function generatePaperSuppFilesDmdSecDom(&$doc, &$root, &$paperFile, &$conference, &$schedConf) {
00301       $dmdSec =& XMLCustomWriter::createElement($doc, 'METS:dmdSec');
00302       XMLCustomWriter::setAttribute($dmdSec, 'ID', 'DMD-SF'.$paperFile->getFileId().'-P'.$paperFile->getPaperId());
00303       $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00304       $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00305       XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'MODS');
00306       $mods =& XMLCustomWriter::createElement($doc, 'mods:mods');
00307       XMLCustomWriter::setAttribute($mods, 'xmlns:mods', 'http://www.loc.gov/mods/v3');
00308       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-0.xsd');
00309 
00310       $primaryLocale = $conference->getPrimaryLocale();
00311       foreach ($paperFile->getTitle(null) as $locale => $title) {
00312          $titleInfo =& XMLCustomWriter::createElement($doc, 'mods:titleInfo');
00313          XMLCustomWriter::createChildWithText($doc, $titleInfo, 'mods:title', $title);
00314          if ($locale != $primaryLocale) XMLCustomWriter::setAttribute($titleInfo, 'type', 'alternative');
00315          XMLCustomWriter::appendChild($mods, $titleInfo);
00316          unset($titleInfo);
00317       }
00318 
00319       foreach ($paperFile->getCreator(null) as $locale => $creator) {
00320          $creatorNode =& XMLCustomWriter::createElement($doc, 'mods:name');
00321          XMLCustomWriter::setAttribute($creatorNode, 'type', 'personal');
00322          $nameNode =& XMLCustomWriter::createChildWithText($doc, $creatorNode, 'mods:namePart', $creator);
00323          $role =& XMLCustomWriter::createElement($doc, 'mods:role');
00324          $roleTerm =& XMLCustomWriter::createChildWithText($doc, $role, 'mods:roleTerm', 'creator');
00325          XMLCustomWriter::setAttribute($roleTerm, 'type', 'text');
00326          XMLCustomWriter::appendChild($creatorNode, $role);
00327          XMLCustomWriter::appendChild($mods, $creatorNode);
00328          unset($creatorNode, $nameNode, $role, $roleTerm);
00329       }
00330       foreach ($paperFile->getDescription(null) as $locale => $description) {
00331          XMLCustomWriter::createChildWithText($doc, $mods, 'mods:abstract', $description);
00332       }
00333       if($paperFile->getDateCreated() != ''){
00334          $originInfo =& XMLCustomWriter::createElement($doc, 'mods:originInfo');
00335          $sDate = XMLCustomWriter::createChildWithText($doc, $originInfo, 'mods:dateCreated', $paperFile->getDateCreated());
00336          XMLCustomWriter::appendChild($mods, $originInfo);
00337          unset($originInfo);
00338       }
00339       XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', 'additional material');
00340       if($paperFile->getType() != '')
00341          XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', $paperFile->getType());
00342       foreach ($paperFile->getTypeOther(null) as $locale => $typeOther) {
00343          XMLCustomWriter::createChildWithText($doc, $mods, 'mods:genre', $typeOther);
00344       }
00345       foreach ($paperFile->getSubject(null) as $locale => $subject) {
00346          $subjNode =& XMLCustomWriter::createElement($doc, 'mods:subject');
00347          XMLCustomWriter::createChildWithText($doc, $subjNode, 'mods:topic', $subject);
00348          XMLCustomWriter::appendChild($mods, $subjNode);
00349          unset($subjNode);
00350       }
00351       if($paperFile->getLanguage() != '')
00352          XMLCustomWriter::createChildWithText($doc, $mods, 'mods:language', $paperFile->getLanguage());
00353       XMLCustomWriter::appendChild($xmlData, $mods);
00354       XMLCustomWriter::appendChild($dmdSec, $mdWrap);
00355       XMLCustomWriter::appendChild($mdWrap,$xmlData);
00356       XMLCustomWriter::appendChild($root, $dmdSec);
00357    }
00358 
00362    function generatePaperSuppFilesDiv(&$doc, &$root, $suppFile) {
00363       $sDiv =& XMLCustomWriter::createElement($doc, 'METS:div');
00364       XMLCustomWriter::setAttribute($sDiv, 'TYPE', 'additional_material');
00365       XMLCustomWriter::setAttribute($sDiv, 'DMDID', 'DMD-SF'.$suppFile->getFileId().'-P'.$suppFile->getPaperId());
00366       $fDiv =& XMLCustomWriter::createElement($doc, 'METS:fptr');
00367       XMLCustomWriter::setAttribute($fDiv, 'FILEID', 'SF'.$suppFile->getFileId().'-P'.$suppFile->getPaperId());
00368       XMLCustomWriter::appendChild($sDiv, $fDiv);
00369       XMLCustomWriter::appendChild($root, $sDiv);
00370    }
00371 
00376    function generateSchedConfFileSecDom(&$doc, &$root, &$conference, &$schedConf) {
00377       $publishedPaperDAO =& DAORegistry::getDAO('PublishedPaperDAO');
00378       $publishedPapersIterator =& $publishedPaperDAO->getPublishedPapers($schedConf->getId());
00379       $publishedPaperArray =& $publishedPapersIterator->toArray();
00380 
00381       $i = 0;
00382       while ($i < sizeof($publishedPaperArray)) {
00383          MetsExportDom::generatePaperFilesDom($doc, $root, $publishedPaperArray[$i], $conference, $schedConf);
00384          $i++;
00385       }
00386    }
00387 
00391    function generatePaperFilesDom(&$doc, &$root, &$paper, &$conference, &$schedConf) {
00392       $paperGalleyDAO =& DAORegistry::getDAO('PaperGalleyDAO');
00393       $i = 0;
00394       $galleysArray =& $paperGalleyDAO->getGalleysByPaper($paper->getId());
00395       while ($i < sizeof($galleysArray)) {
00396          MetsExportDom::generatePaperFileDom($doc, $root, $paper, $galleysArray[$i], $conference, $schedConf);
00397          $i++;
00398       }
00399       $exportSuppFiles =& Request::getUserVar('exportSuppFiles');
00400       $rtDao =& DAORegistry::getDAO('RTDAO');
00401       $conferenceRt =& $rtDao->getConferenceRTByConference($schedConf->getConference());
00402       if($exportSuppFiles == 'on' || $conferenceRt->getEnabled()) {
00403          $suppFileDAO =& DAORegistry::getDAO('SuppFileDAO');
00404          $paperFilesArray =& $suppFileDAO->getSuppFilesByPaper($paper->getId());
00405          $i = 0;
00406          while ($i < sizeof($paperFilesArray)) {
00407             MetsExportDom::generatePaperSuppFileDom($doc, $root, $paper, $paperFilesArray[$i], $conference, $schedConf);
00408             $i++;
00409          }
00410       }
00411    }
00412 
00416    function generatePaperFileDom(&$doc, &$root, &$paper, &$paperFile, &$conference, &$schedConf) {
00417       import('classes.file.PublicFileManager');
00418       import('classes.file.FileManager');
00419       $contentWrapper =& Request::getUserVar('contentWrapper');
00420       $mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
00421       $filePath  = MetsExportDom::getPublicFilePath($paperFile , '/public/');
00422       $chkmd5return = md5_file($filePath);
00423       XMLCustomWriter::setAttribute($mfile, 'ID', 'F'.$paperFile->getFileId().'-P'.$paperFile->getPaperId());
00424       XMLCustomWriter::setAttribute($mfile, 'SIZE', $paperFile->getFileSize());
00425       XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $paperFile->getFileType());
00426       XMLCustomWriter::setAttribute($mfile, 'OWNERID', $paperFile->getFileName());
00427       XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
00428       XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
00429       if($contentWrapper == 'FContent'){
00430          $fileContent =& FileManager::readFile($filePath);
00431          $fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
00432          $fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData',base64_encode($fileContent));
00433          XMLCustomWriter::appendChild($mfile, $fContent);
00434       } else {
00435          $fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
00436          XMLCustomWriter::setAttribute($fLocat, 'xlink:href', Request::url(
00437             $conference->getPath(), $schedConf->getPath(),
00438             'paper', 'download',
00439             array($paperFile->getPaperId(), $paperFile->getGalleyId())
00440          ));
00441          XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
00442          XMLCustomWriter::appendChild($mfile, $fLocat);
00443       }
00444       XMLCustomWriter::appendChild($root, $mfile);
00445    }
00446 
00450    function generatePaperSuppFileDom(&$doc, &$root, &$paper, &$paperFile, &$conference, &$schedConf) {
00451       import('classes.file.PublicFileManager');
00452       import('classes.file.FileManager');
00453       $contentWrapper =& Request::getUserVar('contentWrapper');
00454       $mfile =& XMLCustomWriter::createElement($doc, 'METS:file');
00455       $filePath  = MetsExportDom::getPublicFilePath($paperFile , '/supp/');;
00456       $chkmd5return = md5_file($filePath);
00457       XMLCustomWriter::setAttribute($mfile, 'ID', 'SF'.$paperFile->getFileId().'-P'.$paperFile->getPaperId());
00458       XMLCustomWriter::setAttribute($mfile, 'SIZE', $paperFile->getFileSize());
00459       XMLCustomWriter::setAttribute($mfile, 'MIMETYPE', $paperFile->getFileType());
00460       XMLCustomWriter::setAttribute($mfile, 'OWNERID', $paperFile->getFileName());
00461       XMLCustomWriter::setAttribute($mfile, 'CHECKSUM', $chkmd5return);
00462       XMLCustomWriter::setAttribute($mfile, 'CHECKSUMTYPE', 'MD5');
00463       if($contentWrapper == 'FContent'){
00464          $fileContent =& FileManager::readFile($filePath);
00465          $fContent =& XMLCustomWriter::createElement($doc, 'METS:FContent');
00466          $fNameNode =& XMLCustomWriter::createChildWithText($doc, $fContent, 'METS:binData',base64_encode($fileContent));
00467          XMLCustomWriter::appendChild($mfile, $fContent);
00468       } else {
00469          $fLocat =& XMLCustomWriter::createElement($doc, 'METS:FLocat');
00470          XMLCustomWriter::setAttribute($fLocat, 'xlink:href', Request::url(
00471             $conference->getPath(), $schedConf->getPath(),
00472             'paper', 'downloadSuppFile',
00473             array($paperFile->getPaperId(), $paperFile->getSuppFileId())
00474          ));
00475          XMLCustomWriter::setAttribute($fLocat, 'LOCTYPE', 'URL');
00476          XMLCustomWriter::appendChild($mfile, $fLocat);
00477       }
00478       XMLCustomWriter::appendChild($root, $mfile);
00479    }
00480 
00484    function generateAuthorsDom(&$doc, &$root, $paperID) {
00485       $authorDAO =& DAORegistry::getDAO('AuthorDAO');
00486       $i = 0;
00487       $authorsArray =& $authorDAO->getAuthorsByPaper($paperID);
00488       while ($i < sizeof($authorsArray)) {
00489          $authorNode =  &MetsExportDom::generateAuthorDom($doc, $authorsArray[$i]);
00490          XMLCustomWriter::appendChild($root, $authorNode);
00491          $i++;
00492       }
00493    }
00494 
00498    function &generateAuthorDom(&$doc, $author) {
00499       $authorNode =& XMLCustomWriter::createElement($doc, 'mods:name');
00500       XMLCustomWriter::setAttribute($authorNode, 'type', 'personal');
00501       $fNameNode =& XMLCustomWriter::createChildWithText($doc, $authorNode, 'mods:namePart', $author->getFirstName().' '.$author->getMiddleName());
00502       XMLCustomWriter::setAttribute($fNameNode, 'type', 'given');
00503       $lNameNode =& XMLCustomWriter::createChildWithText($doc, $authorNode, 'mods:namePart', $author->getLastName());
00504       XMLCustomWriter::setAttribute($lNameNode, 'type', 'family');
00505       $role =& XMLCustomWriter::createElement($doc, 'mods:role');
00506       $roleTerm =& XMLCustomWriter::createChildWithText($doc, $role, 'mods:roleTerm', 'author');
00507       XMLCustomWriter::setAttribute($roleTerm, 'type', 'text');
00508       XMLCustomWriter::appendChild($authorNode, $role);
00509       return $authorNode;
00510    }
00511 
00515    function createmetsamdSec($doc, &$root, &$conference) {
00516       $amdSec =& XMLCustomWriter::createElement($doc, 'METS:amdSec');
00517       $techMD =& XMLCustomWriter::createElement($doc, 'METS:techMD');
00518       XMLCustomWriter::setAttribute($techMD, 'ID', 'A-'.$conference->getId());
00519       $mdWrap =& XMLCustomWriter::createElement($doc, 'METS:mdWrap');
00520       XMLCustomWriter::setAttribute($mdWrap, 'MDTYPE', 'PREMIS');
00521       $xmlData =& XMLCustomWriter::createElement($doc, 'METS:xmlData');
00522       $pObject =& XMLCustomWriter::createElement($doc, 'premis:object');
00523       XMLCustomWriter::setAttribute($pObject, 'xmlns:premis', 'http://www.loc.gov/standards/premis/v1');
00524       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', str_replace(' http://www.loc.gov/standards/premis/v1 http://www.loc.gov/standards/premis/v1/PREMIS-v1-1.xsd', '', $root->getAttribute('xsi:schemaLocation')) . ' http://www.loc.gov/standards/premis/v1 http://www.loc.gov/standards/premis/v1/PREMIS-v1-1.xsd');
00525       $objectIdentifier =& XMLCustomWriter::createElement($doc, 'premis:objectIdentifier');
00526       XMLCustomWriter::createChildWithText($doc, $objectIdentifier, 'premis:objectIdentifierType', 'internal');
00527       XMLCustomWriter::createChildWithText($doc, $objectIdentifier, 'premis:objectIdentifierValue', 'C-'.$conference->getId());
00528       XMLCustomWriter::appendChild($pObject, $objectIdentifier);
00529       $preservationLevel =& Request::getUserVar('preservationLevel');
00530       if($preservationLevel == ''){
00531          $preservationLevel = '1';
00532       }
00533       XMLCustomWriter::createChildWithText($doc, $pObject, 'premis:preservationLevel', 'level '.$preservationLevel);
00534       XMLCustomWriter::createChildWithText($doc, $pObject, 'premis:objectCategory', 'Representation');
00535 
00536       XMLCustomWriter::appendChild($xmlData, $pObject);
00537       XMLCustomWriter::appendChild($mdWrap, $xmlData);
00538       XMLCustomWriter::appendChild($techMD ,$mdWrap);
00539       XMLCustomWriter::appendChild($amdSec, $techMD);
00540       return $amdSec;
00541    }
00542 
00546    function createmetsHdr($doc) {
00547       $root =& XMLCustomWriter::createElement($doc, 'METS:metsHdr');
00548       XMLCustomWriter::setAttribute($root, 'CREATEDATE', date('c'));
00549       XMLCustomWriter::setAttribute($root, 'LASTMODDATE', date('c'));
00550       $agentNode =& XMLCustomWriter::createElement($doc, 'METS:agent');
00551       XMLCustomWriter::setAttribute($agentNode, 'ROLE', 'DISSEMINATOR');
00552       XMLCustomWriter::setAttribute($agentNode, 'TYPE', 'ORGANIZATION');
00553       $organization =& Request::getUserVar('organization');
00554       if($organization == ''){
00555         $siteDao =& DAORegistry::getDAO('SiteDAO');
00556         $site = $siteDao->getSite();
00557         $organization = $site->getLocalizedTitle();
00558       }
00559       XMLCustomWriter::createChildWithText($doc, $agentNode, 'METS:name', $organization, false);
00560       XMLCustomWriter::appendChild($root, $agentNode);
00561       $agentNode2 =& XMLCustomWriter::createElement($doc, 'METS:agent');
00562       XMLCustomWriter::setAttribute($agentNode2, 'ROLE', 'CREATOR');
00563       XMLCustomWriter::setAttribute($agentNode2, 'TYPE', 'OTHER');
00564       XMLCustomWriter::createChildWithText($doc, $agentNode2, 'METS:name', MetsExportDom::getCreatorString(), false);
00565       XMLCustomWriter::appendChild($root, $agentNode2);
00566       return $root;
00567    }
00568 
00572    function getCreatorString() {
00573       $versionDAO =& DAORegistry::getDAO('VersionDAO');
00574       $cVersion = $versionDAO->getCurrentVersion();
00575       return sprintf('Open Conference Systems v%d.%d.%d build %d', $cVersion->getMajor(), $cVersion->getMinor(), $cVersion->getRevision(), $cVersion->getBuild());
00576    }
00577 
00581    function getPublicFilePath(&$paperFile, $pathComponent) {
00582       $paperDao =& DAORegistry::getDAO('PaperDAO');
00583       $paper =& $paperDao->getPaper($paperFile->getPaperId());
00584       $paperId = $paper->getSchedConfId();
00585       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00586       $schedConf =& $schedConfDao->getSchedConf($paperId);
00587       return Config::getVar('files', 'files_dir') . '/conferences/' . $schedConf->getConferenceId() . '/schedConfs/' . $paperId .
00588       '/papers/' . $paperFile->getPaperId() . $pathComponent . $paperFile->getFileName();
00589    }
00590 }
00591 
00592 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7