commit | author | age
|
8bd4d9
|
1 |
<?php |
JK |
2 |
class xmltv_parse { |
|
3 |
static $file; |
|
4 |
static $aliases; |
|
5 |
|
|
6 |
static function schedule($id, $datetime=NULL) { |
|
7 |
if($datetime === NULL) $datetime = time(); |
|
8 |
|
|
9 |
$dane = simplexml_load_file(self::$file); |
|
10 |
$abc = $dane->xpath('programme[@channel=\''.$id.'\' and number(substring(@stop, 1, 12))>\''.date('YmdHi', $datetime).'\' and number(substring(@start, 1, 12))<\''.date('YmdHi', $datetime+(3600*24)).'\']'); |
|
11 |
|
|
12 |
$last = 0; |
|
13 |
$concat = ''; |
|
14 |
foreach($abc as $value) { |
|
15 |
$now = date('d.m.Y', strtotime(substr($value['start'], 0, -6))); |
|
16 |
if($now != $last) { |
|
17 |
if(!empty($concat)) GGapi::putRichText($concat); |
|
18 |
GGapi::putRichText("\n".$now."\n", TRUE); |
|
19 |
$last = $now; |
|
20 |
$concat = ''; |
|
21 |
} |
|
22 |
$concat .= date('H:i', strtotime(substr($value['start'], 0, -6))).' '.$value->title."\n"; |
|
23 |
} |
|
24 |
|
|
25 |
if(!empty($concat)) GGapi::putRichText($concat); |
|
26 |
} |
|
27 |
|
|
28 |
static function aliases($tv = NULL) { |
|
29 |
$tv = funcs::utfToAscii($tv); |
|
30 |
$dane = file(self::$aliases); |
|
31 |
|
|
32 |
$return = array(); |
|
33 |
foreach($dane as $line) { |
|
34 |
$line = trim($line); |
|
35 |
if(empty($line) OR substr($line, 0, 1)=='#') |
|
36 |
continue; |
|
37 |
|
|
38 |
$line = explode("\t", $line); |
|
39 |
for($i=0; $i<count($line); $i++) { |
587c93
|
40 |
if($tv !== NULL AND funcs::utfToAscii($line[$i]) == $tv) { |
8bd4d9
|
41 |
return $line[0]; |
JK |
42 |
} |
|
43 |
else |
|
44 |
{ |
|
45 |
$return[$line[$i]] = $line[0]; |
|
46 |
} |
|
47 |
} |
|
48 |
} |
|
49 |
|
587c93
|
50 |
if($tv !== NULL) { |
8bd4d9
|
51 |
return FALSE; |
JK |
52 |
} |
|
53 |
else |
|
54 |
{ |
|
55 |
return $return; |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
static function channels() { |
|
60 |
$dane = file(self::$aliases); |
|
61 |
|
|
62 |
$return = array(); |
|
63 |
foreach($dane as $nazwa) { |
|
64 |
$nazwa = trim($nazwa); |
|
65 |
if(empty($nazwa) OR substr($nazwa, 0, 1)=='#') |
|
66 |
continue; |
|
67 |
|
|
68 |
$return[] = strtok($nazwa, "\t\n"); |
|
69 |
} |
|
70 |
|
|
71 |
return $return; |
|
72 |
} |
|
73 |
} |
|
74 |
?> |