-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.php
executable file
·56 lines (47 loc) · 1.02 KB
/
generate.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
49
50
51
52
53
54
55
56
#!/usr/bin/php
<?php
class Topic {
public $speaker;
public $title;
public $language;
public $description;
public function __construct($speaker, $title, $language, $description)
{
$this->speaker = $speaker;
$this->title = $title;
$this->language = $language;
$this->description = $description;
}
}
/**
* Load topics from CSV file.
*
* File format:
* speaker,phone,title,stage,language,description
*
* @param string $file CSV file
*
* @return array<Topic>
*/
function load_topics($file)
{
$topics = [];
$file = fopen($file, "r");
while (!feof($file)) {
$row = fgetcsv($file);
$topics[] = new Topic($row[0], $row[2], $row[4], $row[5]);
}
fclose($file);
return $topics;
}
function generate(array $topics)
{
include __DIR__ . '/template.phtml';
}
if (count($argv) < 2) {
echo "Usage: {$argv[0]} <file>" . PHP_EOL;
exit(1);
}
$topics = load_topics(__DIR__ . "/${argv[1]}");
generate($topics);
# vim: tabstop=4 shiftwidth=4