75 function __construct($sac_rootin, $sac_dirin, $sac_rootout, $sac_fileout) {
77 $this->sac_root_in = $sac_rootin;
78 $this->sac_dir_in = $sac_dirin;
79 $this->sac_root_out = $sac_rootout;
80 $this->sac_file_out = $sac_fileout;
81 $this->sac_creators = array();
82 $this->sac_subjects = array();
83 $this->sac_files = array();
84 $this->sac_mimetypes = array();
85 $this->sac_provenances = array();
86 $this->sac_rights = array();
87 $this->sac_filecount = 0;
91 $this->sac_type = $sac_thetype;
95 $this->sac_title = $this->
clean($sac_thetitle);
99 $this->sac_abstract = $this->
clean($sac_thetitle);
103 array_push($this->sac_creators, $this->
clean($sac_creator));
107 array_push($this->sac_subjects, $this->
clean($sac_subject));
111 array_push($this->sac_provenances, $this->
clean($sac_provenance));
115 array_push($this->sac_rights, $this->
clean($sac_right));
119 $this->sac_identifier = $sac_theidentifier;
123 $this->sac_statusstatement = $sac_thestatus;
127 $this->sac_copyrightholder = $this->
clean($sac_thecopyrightholder);
131 $this->sac_custodian = $this->
clean($sac_thecustodian);
135 $this->sac_citation = $this->
clean($sac_thecitation);
139 $this->sac_language = $this->
clean($sac_thelanguage);
143 $this->sac_dateavailable = $sac_thedta;
147 $this->sac_publisher = $sac_thepublisher;
150 function addFile($sac_thefile, $sac_themimetype) {
151 array_push($this->sac_files, $sac_thefile);
152 array_push($this->sac_mimetypes, $sac_themimetype);
153 $this->sac_filecount++;
157 switch ($sac_theelement) {
164 case "bibliographicCitation":
184 $fh = @fopen($this->sac_root_in .
'/' . $this->sac_dir_in .
'/' . $this->sac_metadata_filename,
'w');
186 throw new Exception(
"Error writing metadata file (" .
187 $this->sac_root_in .
'/' . $this->sac_dir_in .
'/' . $this->sac_metadata_filename .
")");
189 $this->writeHeader($fh);
197 $zip =
new ZipArchive();
198 $zip->open($this->sac_root_out .
'/' . $this->sac_file_out, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
199 $zip->addFile($this->sac_root_in .
'/' . $this->sac_dir_in .
'/mets.xml',
204 $zip->addFile($this->sac_root_in .
'/' . $this->sac_dir_in .
'/' . $this->sac_files[$i],
205 $this->sac_files[$i]);
211 fwrite($fh,
"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"no\" ?" .
">\n");
212 fwrite($fh,
"<mets ID=\"sort-mets_mets\" OBJID=\"sword-mets\" LABEL=\"DSpace SWORD Item\" PROFILE=\"DSpace METS SIP Profile 1.0\" xmlns=\"http://www.loc.gov/METS/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/mets.xsd\">\n");
213 fwrite($fh,
"\t<metsHdr CREATEDATE=\"2008-09-04T00:00:00\">\n");
214 fwrite($fh,
"\t\t<agent ROLE=\"CUSTODIAN\" TYPE=\"ORGANIZATION\">\n");
215 if (isset($this->sac_custodian)) { fwrite($fh,
"\t\t\t<name>$this->sac_custodian</name>\n"); }
216 else { fwrite($fh,
"\t\t\t<name>Unknown</name>\n"); }
217 fwrite($fh,
"\t\t</agent>\n");
218 fwrite($fh,
"\t</metsHdr>\n");
222 fwrite($fh,
"<dmdSec ID=\"sword-mets-dmd-1\" GROUPID=\"sword-mets-dmd-1_group-1\">\n");
223 fwrite($fh,
"<mdWrap LABEL=\"SWAP Metadata\" MDTYPE=\"OTHER\" OTHERMDTYPE=\"EPDCX\" MIMETYPE=\"text/xml\">\n");
224 fwrite($fh,
"<xmlData>\n");
225 fwrite($fh,
"<epdcx:descriptionSet xmlns:epdcx=\"http://purl.org/eprint/epdcx/2006-11-16/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://purl.org/eprint/epdcx/2006-11-16/ http://purl.org/eprint/epdcx/xsd/2006-11-16/epdcx.xsd\">\n");
226 fwrite($fh,
"<epdcx:description epdcx:resourceId=\"sword-mets-epdcx-1\">\n");
228 if (isset($this->sac_type)) {
230 "http://purl.org/dc/elements/1.1/type",
231 "http://purl.org/eprint/terms/Type",
235 if (isset($this->sac_title)) {
237 "http://purl.org/dc/elements/1.1/title",
241 if (isset($this->sac_abstract)) {
243 "http://purl.org/dc/terms/abstract",
247 foreach ($this->sac_creators as $sac_creator) {
249 "http://purl.org/dc/elements/1.1/creator",
253 foreach ($this->sac_subjects as $sac_subject) {
255 "http://purl.org/dc/elements/1.1/subject",
259 foreach ($this->sac_provenances as $sac_provenance) {
261 "http://purl.org/dc/terms/provenance",
265 foreach ($this->sac_rights as $sac_right) {
267 "http://purl.org/dc/terms/rights",
271 if (isset($this->sac_identifier)) {
273 "http://purl.org/dc/elements/1.1/identifier",
277 if (isset($this->sac_publisher)) {
279 "http://purl.org/dc/elements/1.1/publisher",
283 fwrite($fh,
"<epdcx:statement epdcx:propertyURI=\"http://purl.org/eprint/terms/isExpressedAs\" " .
284 "epdcx:valueRef=\"sword-mets-expr-1\" />\n");
286 fwrite($fh,
"</epdcx:description>\n");
288 fwrite($fh,
"<epdcx:description epdcx:resourceId=\"sword-mets-expr-1\">\n");
291 "http://purl.org/dc/elements/1.1/type",
292 "http://purl.org/eprint/entityType/Expression");
294 if (isset($this->sac_language)) {
296 "http://purl.org/dc/elements/1.1/language",
297 "http://purl.org/dc/terms/RFC3066",
302 "http://purl.org/dc/elements/1.1/type",
303 "http://purl.org/eprint/terms/Type",
304 "http://purl.org/eprint/entityType/Expression");
306 if (isset($this->sac_dateavailable)) {
308 "http://purl.org/dc/terms/available",
310 $this->sac_dateavailable));
313 if (isset($this->sac_statusstatement)) {
315 "http://purl.org/eprint/terms/Status",
316 "http://purl.org/eprint/terms/Status",
317 $this->sac_statusstatement);
320 if (isset($this->sac_copyrightholder)) {
322 "http://purl.org/eprint/terms/copyrightHolder",
326 if (isset($this->sac_citation)) {
328 "http://purl.org/eprint/terms/bibliographicCitation",
332 fwrite($fh,
"</epdcx:description>\n");
334 fwrite($fh,
"</epdcx:descriptionSet>\n");
335 fwrite($fh,
"</xmlData>\n");
336 fwrite($fh,
"</mdWrap>\n");
337 fwrite($fh,
"</dmdSec>\n");
341 fwrite($fh,
"\t<fileSec>\n");
342 fwrite($fh,
"\t\t<fileGrp ID=\"sword-mets-fgrp-1\" USE=\"CONTENT\">\n");
344 fwrite($fh,
"\t\t\t<file GROUPID=\"sword-mets-fgid-0\" ID=\"sword-mets-file-" . $i .
"\" " .
345 "MIMETYPE=\"" . $this->sac_mimetypes[$i] .
"\">\n");
346 fwrite($fh,
"\t\t\t\t<FLocat LOCTYPE=\"URL\" xlink:href=\"" . $this->
clean($this->sac_files[$i]) .
"\" />\n");
347 fwrite($fh,
"\t\t\t</file>\n");
349 fwrite($fh,
"\t\t</fileGrp>\n");
350 fwrite($fh,
"\t</fileSec>\n");
354 fwrite($fh,
"\t<structMap ID=\"sword-mets-struct-1\" LABEL=\"structure\" TYPE=\"LOGICAL\">\n");
355 fwrite($fh,
"\t\t<div ID=\"sword-mets-div-1\" DMDID=\"sword-mets-dmd-1\" TYPE=\"SWORD Object\">\n");
356 fwrite($fh,
"\t\t\t<div ID=\"sword-mets-div-2\" TYPE=\"File\">\n");
358 fwrite($fh,
"\t\t\t\t<fptr FILEID=\"sword-mets-file-" . $i .
"\" />\n");
360 fwrite($fh,
"\t\t\t</div>\n");
361 fwrite($fh,
"\t\t</div>\n");
362 fwrite($fh,
"\t</structMap>\n");
366 fwrite($fh,
"</mets>\n");
370 return "<epdcx:valueString>" .
372 "</epdcx:valueString>\n";
376 return "<epdcx:valueString epdcx:sesURI=\"" . $sesURI .
"\">" .
378 "</epdcx:valueString>\n";
382 fwrite($fh,
"<epdcx:statement epdcx:propertyURI=\"" . $propertyURI .
"\">\n" .
384 "</epdcx:statement>\n");
388 fwrite($fh,
"<epdcx:statement epdcx:propertyURI=\"" . $propertyURI .
"\" " .
389 "epdcx:valueURI=\"" . $value .
"\" />\n");
393 fwrite($fh,
"<epdcx:statement epdcx:propertyURI=\"" . $propertyURI .
"\" " .
394 "epdcx:vesURI=\"" . $vesURI .
"\">\n" .
396 "</epdcx:statement>\n");
400 fwrite($fh,
"<epdcx:statement epdcx:propertyURI=\"" . $propertyURI .
"\" " .
401 "epdcx:vesURI=\"" . $vesURI .
"\" " .
402 "epdcx:valueURI=\"" . $value .
"\" />\n");
406 return str_replace(
''',
''', htmlspecialchars($data, ENT_QUOTES));