Subversion Repositories LCARS

Rev

Rev 172 | Go to most recent revision | Details | 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] . '&ndash;' . $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
    {
49
      $serie['season_ranges'][$season_key + 1] = array($episode_count, $episode_count + $season_length - 1);
50
      $episode_count += $season_length;
51
    }
52
  }
53
 
54
  $serie['percentage'] = 0;
55
  if ($serie['total'] > 0)
56
  {
57
    $serie['percentage'] = $count / $serie['total'] * 100;
58
 
59
    if ((!isset($serie['ignore']) || !$serie['ignore'])
60
         && $serie['percentage'] < $min_percentage)
61
    {
62
      $min_percentage = $serie['percentage'];
63
      $min_series = $key;
64
    }
65
  }
66
 
67
  if (isset($serie['episode_list']))
68
  {
69
    $episode_list =& $serie['episode_list'];
70
    foreach ($data['urns'] as $prefix => $urn)
71
    {
72
      if (preg_match("/^{$prefix}:/", $episode_list))
73
      {
74
        $episode_list = preg_replace("/^{$prefix}:/", $urn,
75
          str_replace(' ', '_', $episode_list));
76
      }
77
    }
78
  }
79
}
80
 
81
// var_dump($serien['<span class="alf">ALF</span>']);
82
 
83
require_once 'series.tpl';