0,0 → 1,113 |
<?php |
|
require_once 'Controller.php'; |
|
require_once 'application/views/IndexView.php'; |
|
class IndexController extends Controller |
{ |
/** |
* Creates a new controller for the index view |
* |
* @see Controller::__construct() |
*/ |
public function __construct () |
{ |
parent::__construct('IndexView'); |
} |
|
public function indexAction () |
{ |
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] . '–' . $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) |
{ |
if (is_int($season_key)) |
{ |
$serie['season_ranges'][$season_key + 1] = array($episode_count, $episode_count + $season_length - 1); |
} |
|
$episode_count += $season_length; |
} |
} |
else |
{ |
$serie['total'] = max(array_keys($serie['episodes'])); |
} |
|
$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>']); |
|
$this->assign('serien', $serien); |
$this->assign('min_series', $min_series); |
$this->render(); |
} |
} |