Subversion Repositories LCARS

Rev

Rev 172 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

1
<?php

require_once 'data.inc';

$min_percentage = 100;
$min_series = null;

$data = array(
    'urns' => array(
        'wiki' => 'http://de.wikipedia.org/wiki/'
    ),
    'list' => &$serien
);

foreach ($serien as $key => &$serie)
{
  $count = 0;
  $serie['coverage'] = array();

  if (isset($serie['seen']))
  {
    $count = count($serie['seen']);
 
    foreach ($serie['seen'] as $episode)
    {
      if (is_array($episode))
      {
        $count += $episode[1] - $episode[0];
        $serie['coverage'][] = $episode[0] . '&ndash;' . $episode[1];
      }
      else
      {
        $serie['coverage'][] = $episode;
      }
    }
  }
 
  $serie['count'] = $count;
 
  $serie['total'] = 0;
  if (isset($serie['seasons']) && is_array($serie['seasons']))
  {
    $serie['total'] = array_sum($serie['seasons']);
   
    $episode_count = 1;
    $serie['season_ranges'] = array();
    foreach ($serie['seasons'] as $season_key => $season_length)
    {
      $serie['season_ranges'][$season_key + 1] = array($episode_count, $episode_count + $season_length - 1);
      $episode_count += $season_length;
    }
  }
 
  $serie['percentage'] = 0;
  if ($serie['total'] > 0)
  {
    $serie['percentage'] = $count / $serie['total'] * 100;
   
    if ((!isset($serie['ignore']) || !$serie['ignore'])
         && $serie['percentage'] < $min_percentage)
    {
      $min_percentage = $serie['percentage'];
      $min_series = $key;
    }
  }

  if (isset($serie['episode_list']))
  {
    $episode_list =& $serie['episode_list'];
    foreach ($data['urns'] as $prefix => $urn)
    {
      if (preg_match("/^{$prefix}:/", $episode_list))
      {
        $episode_list = preg_replace("/^{$prefix}:/", $urn,
          str_replace(' ', '_', $episode_list));
      }
    }
  }
}

// var_dump($serien['<span class="alf">ALF</span>']);

require_once 'series.tpl';