plugins/importexport/mets/MetsExportPlugin.inc.php

00001 <?php
00002 
00015 //$Id$
00016 
00017 import('classes.plugins.ImportExportPlugin');
00018 
00019 class METSExportPlugin extends ImportExportPlugin {
00026    function register($category, $path) {
00027       $success = parent::register($category, $path);
00028       $this->addLocaleData();
00029       return $success;
00030    }
00031 
00037    function getName() {
00038       return 'METSExportPlugin';
00039    }
00040 
00041    function getDisplayName() {
00042       return __('plugins.importexport.METSExport.displayName');
00043    }
00044 
00045    function getDescription() {
00046       return __('plugins.importexport.METSExport.description');
00047    }
00048 
00049    function display(&$args) {
00050       $templateMgr =& TemplateManager::getManager();
00051       parent::display($args);
00052       $conference =& Request::getConference();
00053       switch (array_shift($args)) {
00054          case 'exportschedConf':
00055             $conferenceDAO =& DAORegistry::getDAO('ConferenceDAO');
00056             $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00057             $schedConfId = array_shift($args);
00058             if ($schedConfId) {
00059                $schedConf =& $schedConfDAO->getSchedConf($schedConfId);
00060                $this->exportSchedConf($conference, $schedConf);
00061                return true;
00062             } else {
00063                $schedConfIds = Request::getUserVar('SchedConfId');
00064                $this->exportSchedConfs($conference, $schedConfIds);
00065                return true;
00066             }
00067             break;
00068          case 'schedConfs':
00069             // Display a list of Scheduled Conferences for export
00070             $this->setBreadcrumbs(array(), true);
00071             $templateMgr =& TemplateManager::getManager();
00072 
00073             $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00074             $currentSchedConfs =& $schedConfDao->getCurrentSchedConfs($conference->getId());
00075 
00076             $siteDao =& DAORegistry::getDAO('SiteDAO');
00077             $site = $siteDao->getSite();
00078             $organization = $site->getLocalizedTitle();
00079 
00080             $templateMgr->assign_by_ref('organization', $organization);
00081             $templateMgr->assign_by_ref('schedConfs', $currentSchedConfs);
00082             $templateMgr->display($this->getTemplatePath().'schedConfs.tpl');
00083             break;
00084          default:
00085             $this->setBreadcrumbs();
00086             $templateMgr->display($this->getTemplatePath() . 'index.tpl');
00087       }
00088    }
00089 
00090    function exportSchedConf(&$conference, &$schedConf) {
00091       $this->import('MetsExportDom');
00092       $doc =& XMLCustomWriter::createDocument();
00093       $root =& XMLCustomWriter::createElement($doc, 'METS:mets');
00094       XMLCustomWriter::setAttribute($root, 'xmlns:METS', 'http://www.loc.gov/METS/');
00095       XMLCustomWriter::setAttribute($root, 'xmlns:xlink', 'http://www.w3.org/TR/xlink');
00096       XMLCustomWriter::setAttribute($root, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
00097       XMLCustomWriter::setAttribute($root, 'PROFILE', 'Australian METS Profile 1.0');
00098       XMLCustomWriter::setAttribute($root, 'TYPE', 'conference');
00099       XMLCustomWriter::setAttribute($root, 'OBJID', 'C-'.$conference->getId());
00100       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', 'http://www.loc.gov/METS/ http://www.loc.gov/mets/mets.xsd');
00101       $headerNode =& MetsExportDom::createmetsHdr($doc);
00102       XMLCustomWriter::appendChild($root, $headerNode);
00103       MetsExportDom::generateConfDmdSecDom($doc, $root, $conference);
00104       MetsExportDom::generateSchedConfDmdSecDom($doc, $root, $conference, $schedConf);
00105       $amdSec =& MetsExportDom::createmetsamdSec($doc, $root, $conference);
00106       XMLCustomWriter::appendChild($root, $amdSec);
00107       $fileSec =& XMLCustomWriter::createElement($doc, 'METS:fileSec');
00108       $fileGrp =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
00109       XMLCustomWriter::setAttribute($fileGrp, 'USE', 'original');
00110       MetsExportDom::generateSchedConfFileSecDom($doc, $fileGrp, $conference, $schedConf);
00111       XMLCustomWriter::appendChild($fileSec, $fileGrp);
00112       XMLCustomWriter::appendChild($root, $fileSec);
00113       MetsExportDom::generateConfstructMapWithSchedConf($doc, $root, $conference, $schedConf);
00114       XMLCustomWriter::appendChild($doc, $root);
00115       header("Content-Type: application/xml");
00116       header("Cache-Control: private");
00117       header("Content-Disposition: attachment; filename=\"".$conference->getPath()."_".$schedConf->getPath()."-mets.xml\"");
00118       XMLCustomWriter::printXML($doc);
00119       return true;
00120    }
00121 
00122    function exportSchedConfs(&$conference, &$schedConfIdArray) {
00123       $this->import('MetsExportDom');
00124       $schedConfDAO =& DAORegistry::getDAO('SchedConfDAO');
00125       $doc =& XMLCustomWriter::createDocument();
00126       $root =& XMLCustomWriter::createElement($doc, 'METS:mets');
00127       XMLCustomWriter::setAttribute($root, 'xmlns:METS', 'http://www.loc.gov/METS/');
00128       XMLCustomWriter::setAttribute($root, 'xmlns:xlink', 'http://www.w3.org/TR/xlink');
00129       XMLCustomWriter::setAttribute($root, 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
00130       XMLCustomWriter::setAttribute($root, 'PROFILE', 'Australian METS Profile 1.0');
00131       XMLCustomWriter::setAttribute($root, 'TYPE', 'conference');
00132       XMLCustomWriter::setAttribute($root, 'OBJID', 'C-'.$conference->getId());
00133       XMLCustomWriter::setAttribute($root, 'xsi:schemaLocation', 'http://www.loc.gov/METS/ http://www.loc.gov/mets/mets.xsd');
00134       $headerNode =& MetsExportDom::createmetsHdr($doc);
00135       XMLCustomWriter::appendChild($root, $headerNode);
00136       MetsExportDom::generateConfDmdSecDom($doc, $root, $conference);
00137       $fileSec =& XMLCustomWriter::createElement($doc, 'METS:fileSec');
00138       $fileGrp =& XMLCustomWriter::createElement($doc, 'METS:fileGrp');
00139       XMLCustomWriter::setAttribute($fileGrp, 'USE', 'original');
00140       $i = 0;
00141       while ($i < sizeof($schedConfIdArray)) {
00142          $schedConf =& $schedConfDAO->getSchedConf($schedConfIdArray[$i]);
00143          MetsExportDom::generateSchedConfDmdSecDom($doc, $root, $conference, $schedConf);
00144          MetsExportDom::generateSchedConfFileSecDom($doc, $fileGrp, $conference, $schedConf);
00145          $i++;
00146       }
00147       $amdSec =& MetsExportDom::createmetsamdSec($doc, $root, $conference);
00148       XMLCustomWriter::appendChild($root, $amdSec);
00149       XMLCustomWriter::appendChild($fileSec, $fileGrp);
00150       XMLCustomWriter::appendChild($root, $fileSec);
00151       MetsExportDom::generateConfstructMapWithSchedConfsIdArray($doc, $root, $conference, $schedConfIdArray);
00152       XMLCustomWriter::appendChild($doc, $root);
00153       header("Content-Type: application/xml");
00154       header("Cache-Control: private");
00155       header("Content-Disposition: attachment; filename=\"".$conference->getPath()."-mets.xml\"");
00156       XMLCustomWriter::printXML($doc);
00157       return true;
00158    }
00159 }
00160 
00161 ?>

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