Subversion Repositories LCARS

Rev

Rev 28 | Rev 186 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 172
Line 1... Line 1...
1
<?php
1
<?php
2
2
3
require_once 'data.inc';
3
require_once 'Application.php';
4
4
5
$min_percentage = 100;
5
require_once 'application/models/databases/seriometer/SeriOMeterDb.php';
6
$min_series = null;
-
 
7
6
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']);
7
$application = Application::getInstance();
23
 
-
 
24
    foreach ($serie['seen'] as $episode)
8
$application->setDefaultDatabase(
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']))
9
  $application->registerDatabase('seriometer', new SeriOMeterDb()));
42
  {
-
 
43
    $serie['total'] = array_sum($serie['seasons']);
-
 
44
   
-
 
45
    $episode_count = 1;
10
$application->run();
46
    $serie['season_ranges'] = array();
-
 
47
    foreach ($serie['seasons'] as $season_key => $season_length)
-
 
48
    {
-
 
49
      if (is_int($season_key))
-
 
50
      {
-
 
51
        $serie['season_ranges'][$season_key + 1] = array($episode_count, $episode_count + $season_length - 1);
-
 
52
      }
-
 
53
     
-
 
54
      $episode_count += $season_length;
-
 
55
    }
-
 
56
  }
-
 
57
  else
-
 
58
  {
-
 
59
    $serie['total'] = max(array_keys($serie['episodes']));
-
 
60
  }
-
 
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';
-
 
92
 
11