Skip to content

Commit

Permalink
Add in a way to view recommended shows based on previous recommendati…
Browse files Browse the repository at this point in the history
…ons. Add in header link.
  • Loading branch information
kormoc committed Apr 13, 2013
1 parent b735c0a commit 15080f2
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/_shared/tmpl/default/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@
  |  
<a href="tv/recorded"><?php echo t('Recorded Programs') ?></a>
&nbsp; | &nbsp;
<?php if(setting('recommend_enabled', null)) { ?>
<a href="tv/recommended"><?php echo t('Recommended Programs') ?></a>
&nbsp; | &nbsp;
<?php } ?>
<?php } ?>
<a href="status"><?php echo t('Backend Status') ?></a>
<?php if (Modules::getModule('backend_log')) { ?>
Expand Down
44 changes: 44 additions & 0 deletions modules/tv/recommended.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Request any recommended shows from the engine and display them
*
* @license GPL
*
* @package MythWeb
* @subpackage TV
*
/**/

$recommend_enabled = setting('recommend_enabled', null);
$recommend_server = setting('recommend_server', null);
$recommend_key = setting('recommend_key', null);


$url = "{$recommend_server}/shows/recommended.json?auth_token={$recommend_key}";

$ch=curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$r=curl_exec($ch);
curl_close($ch);

$results = json_decode($r, true);
$shows = array();
$query = '';


foreach($results as $result) {
if (!strlen($result['tms_id']))
continue;
if (strlen($query))
$query .= ' OR ';
$query .= " program.seriesid = '{$result['tms_id']}'";

}

$shows =& load_all_program_data(time(), strtotime('+1 month'), NULL, false, "({$query})", true);

// Load the class for this page
require_once tmpl_dir.'recommended.php';

// Exit
exit;
85 changes: 85 additions & 0 deletions modules/tv/tmpl/default/recommended.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* Show recommended results
*
* @license GPL
*
* @package MythWeb
* @subpackage TV
*
/**/

// Set the desired page title
$page_title = 'MythWeb - '.t('Recommended');

// Custom headers
$headers[] = '<link rel="stylesheet" type="text/css" href="'.skin_url.'/tv_search.css">';

// Print the page header
require 'modules/_shared/tmpl/'.tmpl.'/header.php';

?>

<table id="search_results" class="list small" width="100%" border="0" cellpadding="4" cellspacing="2">
<tr class="menu">
<th class="x-title"><?php echo t('Title'); ?></th>
<th class="x-category"><?php echo t('Category'); ?></th>
<th class="x-description"><?php echo t('Description'); ?></th>
<th class="x-channum"><?php echo t('Channel'); ?></th>
<th class="x-airdate"><?php echo t('Airdate'); ?></th>
<th class="x-length"><?php echo t('Length'); ?></th>
</tr>
<?php
if (count($shows) == 0) {
?>
<tr><td colspan=6"><?php echo t('No matches found'); ?></td></tr>
<tr><td colspan=6"><?php echo t('Please rate more shows to get more results'); ?></td></tr>
<?php
}
foreach ($shows as $show) { ?>
<tr class="<?php echo $show->css_class ?>" valign="top">
<td class="x-title <?php echo $show->css_class ?>"><?php
if ($show->hdtv)
echo '<span class="hdtv_icon">HD</span>';
echo '<a href="', root_url, 'tv/detail/', $show->chanid, '/', $show->starttime, '">',
$show->title, '</a>';
if ($show->subtitle)
echo ': ', $show->subtitle;
// Print some additional information for movies
if ($show->category_type == 'movie') {
$info = array();
if ($show->airdate > 0)
$info[] = sprintf('%4d', $show->airdate);
if (strlen($show->rating) > 0)
$info[] = "<i>$show->rating</i>";
if (strlen($show->starstring) > 0)
$info[] = $show->starstring;
if (count($info) > 0)
echo '<br>(', implode(', ', $info), ')';
}

?></td>
<td class="x-category"><?php echo $show->category ?></td>
<td class="x-description"><?php echo $show->description ?></td>
<td class="x-channum"><?php echo $show->channel->channum.' - '.$show->channel->name ?></td>
<td class="x-airdate"><?php
echo '<a href="'.root_url.'tv/detail/'.$show->chanid.'/'.$show->starttime.'">'.
strftime($_SESSION['date_search'], $show->starttime) . '</a>';
if ($show->extra_showings)
foreach ($show->extra_showings as $pair) {
list($chanid, $showtime) = $pair;
echo '<br><a href="', root_url, 'tv/detail/', $chanid, '/', $showtime, '" class="italic">',
strftime($_SESSION['date_search'] ,$showtime);
if ($chanid != $show->chanid)
echo ' (', Channel::find($chanid)->callsign, ')';
echo '</a>';
}
?></td>
<td class="x-length"><?php echo nice_length($show->length) ?></td>
</tr>
<?php } ?>
</table>

<?php
// Print the page footer
require 'modules/_shared/tmpl/'.tmpl.'/footer.php';

0 comments on commit 15080f2

Please sign in to comment.