Rev 26 | Rev 186 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
26 | PointedEar | 1 | <?php |
2 | |||
3 | require_once 'data.inc'; |
||
4 | |||
5 | $min_percentage = 100; |
||
6 | $min_series = null; |
||
7 | |||
8 | $data = array( |
||
9 | 'urns' => array( |
||
10 | 'wiki' => 'http://de.wikipedia.org/wiki/' |
||
11 | ), |
||
12 | 'list' => &$serien |
||
13 | ); |
||
14 | |||
15 | foreach ($serien as $key => &$serie) |
||
16 | { |
||
17 | $count = 0; |
||
18 | $serie['coverage'] = array(); |
||
19 | |||
20 | if (isset($serie['seen'])) |
||
21 | { |
||
22 | $count = count($serie['seen']); |
||
23 | |||
24 | foreach ($serie['seen'] as $episode) |
||
25 | { |
||
26 | if (is_array($episode)) |
||
27 | { |
||
28 | $count += $episode[1] - $episode[0]; |
||
29 | $serie['coverage'][] = $episode[0] . '–' . $episode[1]; |
||
30 | } |
||
31 | else |
||
32 | { |
||
33 | $serie['coverage'][] = $episode; |
||
34 | } |
||
35 | } |
||
36 | } |
||
37 | |||
38 | $serie['count'] = $count; |
||
39 | |||
40 | $serie['total'] = 0; |
||
41 | if (isset($serie['seasons']) && is_array($serie['seasons'])) |
||
42 | { |
||
43 | $serie['total'] = array_sum($serie['seasons']); |
||
44 | |||
45 | $episode_count = 1; |
||
46 | $serie['season_ranges'] = array(); |
||
47 | foreach ($serie['seasons'] as $season_key => $season_length) |
||
48 | { |
||
28 | PointedEar | 49 | if (is_int($season_key)) |
50 | { |
||
51 | $serie['season_ranges'][$season_key + 1] = array($episode_count, $episode_count + $season_length - 1); |
||
52 | } |
||
53 | |||
26 | PointedEar | 54 | $episode_count += $season_length; |
55 | } |
||
56 | } |
||
28 | PointedEar | 57 | else |
58 | { |
||
59 | $serie['total'] = max(array_keys($serie['episodes'])); |
||
60 | } |
||
26 | PointedEar | 61 | |
62 | $serie['percentage'] = 0; |
||
63 | if ($serie['total'] > 0) |
||
64 | { |
||
65 | $serie['percentage'] = $count / $serie['total'] * 100; |
||
66 | |||
67 | if ((!isset($serie['ignore']) || !$serie['ignore']) |
||
68 | && $serie['percentage'] < $min_percentage) |
||
69 | { |
||
70 | $min_percentage = $serie['percentage']; |
||
71 | $min_series = $key; |
||
72 | } |
||
73 | } |
||
74 | |||
75 | if (isset($serie['episode_list'])) |
||
76 | { |
||
77 | $episode_list =& $serie['episode_list']; |
||
78 | foreach ($data['urns'] as $prefix => $urn) |
||
79 | { |
||
80 | if (preg_match("/^{$prefix}:/", $episode_list)) |
||
81 | { |
||
82 | $episode_list = preg_replace("/^{$prefix}:/", $urn, |
||
83 | str_replace(' ', '_', $episode_list)); |
||
84 | } |
||
85 | } |
||
86 | } |
||
87 | } |
||
88 | |||
89 | // var_dump($serien['<span class="alf">ALF</span>']); |
||
90 | |||
91 | require_once 'series.tpl'; |