-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuildverses.php
More file actions
53 lines (39 loc) · 1.5 KB
/
buildverses.php
File metadata and controls
53 lines (39 loc) · 1.5 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
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
// A command line script to generate the file verses.inc.php
if (php_sapi_name()!='cli') {
echo "<h1>Dette script kan kun eksekveres fra kommandolinjen</h1>";
die();
}
require_once('oversigt.inc.php');
function look_through(string $book, int $chapt)
{
global $outfile, $filetype;
switch (is_array($filetype[$book]) ? $filetype[$book][$chapter] : $filetype[$book]) {
case 'sfm':
echo "$book er i SFM-format, som ikke understøttes af buildverses.php\n";
break;
case 'txt':
$txt = file_get_contents(sprintf('tekst/%s%03d.txt',$book,$chapt));
$verses = [];
for ($verse = 1; $verse < 177; ++$verse)
if (strstr($txt, sprintf("v%d ",$verse))!==false)
$verses[] = $verse;
fwrite($outfile, "\$verses['$book'][$chapt] = [" . implode(',',$verses) . "];\n");
break;
}
}
$outfile = fopen("verses.inc.php","w");
fwrite($outfile, "<?php\n\n// DO NOT EDIT. This file is generated by buildverses.php\n\n");
foreach ($style as $book => $val) {
if (is_array($val)) {
foreach ($val as $chapt => $mature) {
if (in_array($chapt,$chap[$book]) && $mature == $modenhed['ufuldstændigt'])
look_through($book,$chapt);
}
}
elseif ($val == $modenhed['ufuldstændigt']) {
// Hele bogen gennemsøges
foreach ($chap[$book] as $chapt)
look_through($book,$chapt);
}
}