-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostprocess.php
More file actions
40 lines (37 loc) · 1.36 KB
/
postprocess.php
File metadata and controls
40 lines (37 loc) · 1.36 KB
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
<?php
// call this with the projectname and a list of extensions separated by commas, eg:
// php postprocess.php urs pdf,mp4
// Note: will need to screen out dublin_core.xml if the users include xml files in their uploads.
// 2023 tried to make this to work with new chc workflow, in which the content files are added manually. This can be reverted once the chc input stage is not interrupted by manual file editing.
$APPDIR = getcwd();
$PROJPATH = "{$APPDIR}/{$argv[1]}";
$WORKDIR = "{$PROJPATH}/work";
function write_list($dirpath, $types){
$fp = fopen($dirpath . "/contents", 'w');
$string = "";
$iterator = new DirectoryIterator($dirpath);
foreach($iterator as $fileinfo ){
$filename = $fileinfo->getFilename();
$ext = pathinfo($filename, PATHINFO_EXTENSION);
if (in_array($ext, $types))
$string .= $filename ."\tbundle:ORIGINAL\n";
}
$string .= "license.txt" . "\t" . "bundle:LICENSE\n";
fwrite($fp, $string);
fclose($fp);
}
// processing starts here. Modified to enable no content file
if(sizeof($argv) > 2)
$types = explode(",", $argv[2]);
else
$types = [];
$iterator = new DirectoryIterator($WORKDIR);
foreach($iterator as $dir){
if($dir->isDot()) continue;
if($dir->isDir()){
$fullpath = $dir->getPath() . "/" . $dir->getFilename();
write_list($fullpath, $types);
copy("{$APPDIR}/license.txt", "{$fullpath}/license.txt");
}
}
?>