Subversion Repositories LCARS

Compare Revisions

Last modification

Ignore whitespace Rev 172 → Rev 173

/trunk/media/video/series/application/controllers/IndexController.php
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] . '&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)
{
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();
}
}
/trunk/media/video/series/application/views/IndexView.php
0,0 → 1,14
<?php
 
class IndexView extends View
{
/**
* Creates a new index view
*
* @see View::__construct()
*/
public function __construct ($template)
{
parent::__construct('application/layouts/index/index.phtml');
}
}
/trunk/media/video/series/includes/glee.php
0,0 → 1,57
<?php
 
$glee = array(
// 'ignore' => true,
'channel' => 'online',
// 'showtimes' => 'Di 16:35',
'seen' => array(array(1, 9)),
// 'last_seen' => mktime(16, 55, 0, 8, 25, 2011),
'seasons' => array(22, 22, 22, 16),
'episode_list' => 'wiki:en:List_of_Glee_episodes',
'episodes' => array(
1 => "Pilot",
2 => "Showmance",
3 => "Acafellas",
4 => "Preggers",
5 => "The Rhodes Not Taken",
6 => "Vitamin D",
7 => "Throwdown",
8 => "Mash-Up",
9 => "Wheels",
10 => "Ballad",
11 => "Hairography",
12 => "Mattress",
13 => "Sectionals",
14 => "Hell-o",
15 => "The Power of Madonna",
16 => "Home",
17 => "Bad Reputation",
18 => "Laryngitis",
19 => "Dream On",
20 => "Theatricality",
21 => "Funk",
22 => "Journey to Regionals",
23 => "Audition",
24 => "Britney/Brittany",
25 => "Grilled Cheesus",
26 => "Duets",
27 => "The Rocky Horror Glee Show",
28 => "Never Been Kissed",
29 => "The Substitute",
30 => "Furt",
31 => "Special Education",
32 => "A Very Glee Christmas",
33 => "The Sue Sylvester Shuffle",
34 => "Silly Love Songs",
35 => "Comeback",
36 => "Blame It on the Alcohol",
37 => "Sexy",
38 => "Original Song",
39 => "A Night of Neglect",
40 => "Born This Way",
41 => "Rumours",
42 => "Prom Queen",
43 => "Funeral",
44 => "New York",
)
);