Subversion Repositories LCARS

Rev

Rev 26 | Rev 186 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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