-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathconfig.php
48 lines (42 loc) · 1.21 KB
/
config.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
43
44
45
46
47
48
<?php
if (!defined('IncludingScript')) {
die('Direct access not permitted');
}
// We don't want ANSI coloring.
putenv('TERM=dumb');
$config = [
'ocr-validate' => dirname(__FILE__) . '/../bin/ocr-validate.sh',
'ocr-transform' => dirname(__FILE__) . '/../bin/ocr-transform.sh',
'formats' => [
'transform' => [],
'validate' => [],
],
];
$local_settings = dirname(__FILE__) . '/config.local.php';
if (file_exists($local_settings) === TRUE) {
include $local_settings;
}
/**
* List of installed transform from-to-tuples.
* List of installed schemas.
*/
function buildFormatList()
{
global $config;
$lines = [];
exec($config['ocr-transform'] . ' -L', $lines);
foreach ($lines as $line) {
$fromto = preg_split("/\s+/", $line);
$from = $fromto[0];
$to = $fromto[1];
// echo $from, "\t", $to, "\n";
if (! array_key_exists($from, $config['formats']['transform'])) {
$config['formats']['transform'][$from] = [$to];
} else {
array_push($config['formats']['transform'][$from], $to);
}
}
exec($config['ocr-validate'] . ' -L', $config['formats']['validate']);
}
buildFormatList();
return $config;