-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprint_cpds.php
executable file
·42 lines (32 loc) · 1.03 KB
/
print_cpds.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/*
requires as argument the name of the metadata sheet.
metadata sheet should be exported to tab-delimited .txt file and
formatted like this: dmrec TAB filename TAB title TAB [and whatever out here]
*/
$lines = file($argv[1]);
$f;
$string = "";
foreach($lines as $line){
$parts = explode("\t", $line);
if (strpos($parts[1], "cpd") !== FALSE){
if ($f != null && get_resource_type($f) === 'stream'){
fwrite($f, "</cpd>");
fclose($f);
}
$f = fopen($parts[1], 'w');
fwrite($f, "<?xml version='1.0'?><cpd><type>Folder</type>\n");
$string = "";
}//if directory
else {
$string = make_page($parts[2], $parts[1], $parts[0]);
fwrite($f, $string);
}
}//for
function make_page($title,$file, $dmrec){
$string .= "<page><pagetitle>" . $title . "</pagetitle>\n";
$string .= "<pagefile>" . $file . "</pagefile>\n";
$string .= "<pageptr>" . $dmrec . "</pageptr></page>\n";
return $string;
}
?>