[mythtv] [patch] new "All Recordings" page for mythweb

Dave Alden alden at math.ohio-state.edu
Thu Jan 29 19:06:56 EST 2004


Hi,

  Ever since I switched to mythtv (from ReplayTV), I've always missed one
feature -- the ability to list all of my schedule recordings.  Note that
what I mean is not the current "scheduled recordings" type of screen, but
simply a page that shows all of the entries in the record table.  Since
I'm not a talented c++/qt programmer, I decided to add this feature to
mythweb. :-)

  I've added a new page called "All Recordings" that lists all of the shows
you've set to record.  This way you can go in and remove the ones that are
no longer of use.  For example, I have an entry in the record table for
recording "The Amazing Race 4" -- I'm fairly sure that will never be on
again (and even if it is, it'll be a rerun :-).  With this patch I can
now find that entry and remove it.

  Note that I've only modified the "Default" theme so far.  If others
find this useful, I'll be more than happy to update the other themes.
I've attached a patch (it's against CVS as of 01/29/04 7:00pm EST).

...dave

ps  I debated adding this to the "Scheduled Recordings" page instead of
    creating a new "All Recordings" page -- but in the end I felt this
    was "better".  Let me know if you think this should go in the
    "Scheduled Recordings" page and I'll see about putting it there. :-)
-------------- next part --------------
Index: mythweb/program_detail.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/program_detail.php,v
retrieving revision 1.6
diff -u -r1.6 program_detail.php
--- mythweb/program_detail.php	22 Nov 2003 08:59:16 -0000	1.6
+++ mythweb/program_detail.php	29 Jan 2004 23:52:48 -0000
@@ -14,7 +14,11 @@
 
 
 // Grab the one and only program on this channel that starts at the specified time
-	$this_program = &load_one_program($_GET['starttime'], $_GET['chanid']);
+	if (isset($_GET['recordid']))
+		$this_program = &load_all_recordings($_GET['recordid']);
+	else
+		$this_program = &load_one_program($_GET['starttime'], $_GET['chanid']);
+
 	$this_channel = &$this_program->channel;
 
 // Make sure this is a valid program.  If not, forward the user back to the listings page
@@ -34,6 +38,10 @@
 		$this_program->recorddups = (isset($_GET['recorddups']) && $_GET['recorddups'] == "on") ? 1 : 0;
 		$this_program->autoexpire = (isset($_GET['autoexpire']) && $_GET['autoexpire'] == "on") ? 1 : 0;
 		$this_program->maxnewest  = (isset($_GET['maxnewest']) && $_GET['maxnewest'] == "on")   ? 1 : 0;
+		if (isset($_GET['recordid'])) {
+			$this_program->recordid = $_GET['recordid'];
+			$this_program->record_update();
+		} else
 	// Update
 		switch ($_GET['record']) {
 			case 'always':
Index: mythweb/includes/init.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/includes/init.php,v
retrieving revision 1.10
diff -u -r1.10 init.php
--- mythweb/includes/init.php	28 Jan 2004 02:16:42 -0000	1.10
+++ mythweb/includes/init.php	29 Jan 2004 23:52:48 -0000
@@ -59,9 +59,10 @@
 // Connect to the backend and load some more handy utilities
 	require_once "includes/mythbackend.php";
 
-// Load in the channel and program classes
+// Load in the channel, program and recording classes
 	require_once "includes/channels.php";
 	require_once "includes/programs.php";
+	require_once "includes/recordings.php";
 
 // Detect WAP browsers
 	$wap_agents = array('Noki', // Nokia phones and emulators
Index: mythweb/includes/recordings.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/includes/recordings.php,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 recordings.php
--- mythweb/includes/recordings.php	25 Jul 2003 01:29:36 -0000	1.1.1.1
+++ mythweb/includes/recordings.php	29 Jan 2004 23:52:49 -0000
@@ -1,14 +1,320 @@
 <?
 /***                                                                        ***\
-	recordings.php                           Last Updated: 2003.00.00 (xris)
+	recordings.php                           Last Updated: 2004.01.29 (alden)
 
 	The Recording object, and a couple of related subroutines.
 \***                                                                        ***/
 
+// Make sure the "Channels" class gets loaded   (yes, I know this is recursive, but require_once will handle things nicely)
+	require_once 'includes/channels.php';
 
+//
+	$RecTypes = array(
+				1 => 'once',
+				2 => 'daily',
+				3 => 'channel',
+				4 => 'always',
+				5 => 'weekly'
+				);
 
+/*
+	load_all_recordings:
+	loads all recording data for the specified time range into the $Channels array.
+	Set $single_recording to true if you only want information about recordings that
+	start exactly at $start_time (used by recording_detail.php)
+*/
+	function &load_all_recordings($recordid = 0) {
+		global $Channels;
+	// An array (that later gets converted to a string) containing the id's of channels we want to load
+		$these_channels = array();
+	// No channel data?  Load it
+		if (!is_array($Channels) || !count($Channels))
+			load_all_channels();
+
+	// Build the sql query, and execute it
+		$query = 'SELECT *, UNIX_TIMESTAMP(startdate)+TIME_TO_SEC(starttime) AS starttime_unix,'
+				.' UNIX_TIMESTAMP(enddate)+TIME_TO_SEC(endtime) AS endtime_unix '
+				.'FROM record ';
+		if ($recordid > 0) 
+			$query .= " WHERE recordid = $recordid ";
+		$query .= 'ORDER BY title, subtitle, description, startdate, starttime';
+
+		$result = mysql_query($query)
+			or trigger_error('SQL Error: '.mysql_error(), FATAL);
+	// Load in all of the recordings (if any?)
+		$these_recordings = array();
+		while ($recording_data = mysql_fetch_assoc($result)) {
+			$recording =& new Recording($recording_data);
+			if ($recordid > 0) {
+				mysql_free_result($result);
+echo "returning with =" . $recording->will_record . "=" . $recording->type . "=<br>\n";
+				return $recording;
+			}
+			$these_recordings[] = &$recording;
+		}
+
+	// Cleanup
+		mysql_free_result($result);
+	// Just in case, return an array of all recordings found
+
+		return $these_recordings;
+	}
+
+//
+//	Recordings class
+//
 class Recording {
+	var $recordid;
+	var $type;
+	var $chanid;
+	var $starttime;
+	var $endtime;
+	var $title;
+	var $subtitle;
+	var $description;
+	var $category;
+	var $profile;
+	var $recpriority;
+	var $autoexpire;
+	var $maxepisodes;
+	var $maxnewest;
+	var $recorddups;
+	var $preroll;
+	var $postroll;
+
+	var $texttype;
+	var $channel;
+
+	var $will_record    = false;
+	var $record_daily   = false;
+	var $record_weekly  = false;
+	var $record_once    = false;
+	var $record_channel = false;
+	var $record_always  = false;
+
+	var $class;			// css class, based on category and/or category_type
+
+	function Recording($recording_data) {
+
+		if (isset($recording_data['recordid'])) {
+	// SQL data
+			$this->recordid    = $recording_data['recordid'];
+			$this->type        = $recording_data['type'];
+			$this->chanid      = $recording_data['chanid'];
+			$this->starttime   = $recording_data['starttime_unix'];
+			$this->endtime     = $recording_data['endtime_unix'];
+			$this->title       = $recording_data['title'];
+			$this->subtitle    = $recording_data['subtitle'];
+			$this->description = $recording_data['description'];
+			$this->category    = $recording_data['category'] ? $recording_data['category'] : 'Unknown';
+			$this->profile     = $recording_data['profile'];
+			$this->recpriority = $recording_data['recpriority'];
+			$this->autoexpire  = $recording_data['autoexpire'];
+			$this->maxepisodes = $recording_data['maxepisodes'];
+			$this->maxnewest   = $recording_data['maxnewest'];
+			$this->recorddups  = $recording_data['recorddups'];
+			$this->preroll     = $recording_data['preroll'];
+			$this->postroll    = $recording_data['postroll'];
+		} else {
+			$this->recordid    = $recording_data->recordid;
+			$this->type        = $recording_data->type;
+			$this->chanid      = $recording_data->chanid;
+			$this->starttime   = $recording_data->starttime;
+			$this->startdate   = $recording_data->startdate;
+			$this->endtime     = $recording_data->endtime;
+			$this->enddate     = $recording_data->enddate;
+			$this->title       = $recording_data->title;
+			$this->subtitle    = $recording_data->subtitle;
+			$this->description = $recording_data->description;
+			$this->category    = $recording_data->category ? $recording_data->category : 'Unknown';
+			$this->profile     = $recording_data->profile;
+			$this->recpriority = $recording_data->recpriority;
+			$this->autoexpire  = $recording_data->autoexpire;
+			$this->maxepisodes = $recording_data->maxepisodes;
+			$this->maxnewest   = $recording_data->maxnewest;
+			$this->recorddups  = $recording_data->recorddups;
+			$this->preroll     = $recording_data->preroll;
+			$this->postroll    = $recording_data->postroll;
+		}
+
+		// We get various recording-related information, too
+		if ($this->type == 1)
+			$this->record_once = true;
+		elseif ($this->type == 2)
+			$this->record_daily = true;
+		elseif ($this->type == 3)
+			$this->record_channel = true;
+		elseif ($this->type == 4)
+			$this->record_always = true;
+		elseif ($this->type == 5)
+			$this->record_weekly = true;
+
+		// Add a generic "will record" variable, too
+		$this->will_record     = ($this->record_daily
+						  || $this->record_weekly
+						  || $this->record_once
+						  || $this->record_channel
+						  || $this->record_always ) ? true : false;
+	// Turn type int a word
+		$this->texttype = $GLOBALS['RecTypes'][$this->type];
+	// Do we have a chanid?  Load some info about it
+		if ($this->chanid && !isset($this->channel)) {
+		// No channel data?  Load it
+			global $Channels;
+			if (!is_array($Channels) || !count($Channels))
+				load_all_channels($this->chanid);
+		// Now we really should scan the $Channel array and add a link to this recording's channel
+			foreach (array_keys($Channels) as $key) {
+				if ($Channels[$key]->chanid == $this->chanid) {
+					$this->channel = &$Channels[$key];
+					break;
+				}
+			}
+		}
+
+	// Find out which css category this recording falls into
+		if ($this->chanid != "")
+			$this->category_class();
+	}
+
+	function record_update() {
+
+		$this->will_record    = false;
+		$this->record_always  = false;
+		$this->record_channel = false;
+		$this->record_once    = false;
+		$this->record_daily   = false;
+		$this->record_weekly  = false;
+
+		switch ($_GET['record']) {
+			case 'once':
+				$this->type = 1;
+				$this->record_once = true;
+				break;
+			case 'daily':
+				$this->type = 2;
+				$this->record_daily = true;
+				break;
+			case 'channel':
+				$this->type = 3;
+				$this->record_channel = true;
+				break;
+			case 'always':
+				$this->type = 4;
+				$this->record_always = true;
+				break;
+			case 'weekly':
+				$this->type = 5;
+				$this->record_weekly = true;
+				break;
+			default:
+				$this->type = 0;
+		}
+
+		if ($this->type == 0) {
+	// Remove the record
+			$result = mysql_query('DELETE FROM record WHERE recordid='.escape($this->recordid))
+				or trigger_error('SQL Error: '.mysql_error(), FATAL);
+		} else {
+	// Insert this recording choice into the database
+			$result = mysql_query('UPDATE record SET type='
+						.escape($this->type).', profile='
+						.escape($this->profile).', recpriority='
+						.escape($this->recpriority).', autoexpire='
+						.escape($this->autoexpire).', maxnewest='
+						.escape($this->maxnewest).', recorddups='
+						.escape($this->recorddups).' where recordid='
+						.escape($this->recordid))
+				or trigger_error('SQL Error: '.mysql_error(), FATAL);
+
+		// Add a generic "will record" variable, too
+		$this->will_record     = ($this->record_daily
+						  || $this->record_weekly
+						  || $this->record_once
+						  || $this->record_channel
+						  || $this->record_always ) ? true : false;
+		}
+		
+	// Notify the backend of the changes
+		backend_notify_changes();
+	}
 
+	function category_class() {
+		$this->class = '';
+	// Category type?
+		if ($this->category_type && !preg_match('/unknown/i', $this->category_type))
+			$this->class .= 'type_'.preg_replace("/[^a-zA-Z0-9\-_]+/", '_', $this->category_type).' ';
+	// Category cache
+		$category = strtolower($this->category);	// user lowercase to avoid a little overhead later
+		static $cache = array();
+		if ($cache[$category])
+			$this->class .= $cache[$category];
+	// Now comes the hard part
+		elseif (preg_match('/\\b(?:action|adven)/', $category))
+			$this->class .= $cache[$category] = 'cat_Action';
+		elseif (preg_match('/\\b(?:adult|erot)/', $category))
+			$this->class .= $cache[$category] = 'cat_Adult';
+		elseif (preg_match('/\\b(?:animal|tiere)/', $category))
+			$this->class .= $cache[$category] = 'cat_Animals';
+		elseif (preg_match('/\\b(?:art|dance|musi[ck]|kunst|[ck]ultur)/', $category))
+			$this->class .= $cache[$category] = 'cat_Art_Music';
+		elseif (preg_match('/\\b(?:biz|busine)/', $category))
+			$this->class .= $cache[$category] = 'cat_Business';
+		elseif (preg_match('/\\b(?:child|kin?d|infan|animation)/', $category))
+			$this->class .= $cache[$category] = 'cat_Children';
+		elseif (preg_match('/\\b(?:comed|entertain|sitcom)/', $category))
+			$this->class .= $cache[$category] = 'cat_Comedy';
+		elseif (preg_match('/\\b(?:[ck]rim|myster)/', $category))
+			$this->class .= $cache[$category] = 'cat_Crime_Mystery';
+		elseif (preg_match('/\\b(?:do[ck])/', $category))
+			$this->class .= $cache[$category] = 'cat_Documentary';
+		elseif (preg_match('/\\b(?:drama)/', $category))
+			$this->class .= $cache[$category] = 'cat_Drama';
+		elseif (preg_match('/\\b(?:edu|bildung|interests)/', $category))
+			$this->class .= $cache[$category] = 'cat_Educational';
+		elseif (preg_match('/\\b(?:food|cook|essen|[dt]rink)/', $category))
+			$this->class .= $cache[$category] = 'cat_Food';
+		elseif (preg_match('/\\b(?:game|spiele)/', $category))
+			$this->class .= $cache[$category] = 'cat_Game';
+		elseif (preg_match('/\\b(?:health|medic|gesundheit)/', $category))
+			$this->class .= $cache[$category] = 'cat_Health_Medical';
+		elseif (preg_match('/\\b(?:hist|geschichte)/', $category))
+			$this->class .= $cache[$category] = 'cat_History';
+		elseif (preg_match('/\\b(?:how|home|house|garden)/', $category))
+			$this->class .= $cache[$category] = 'cat_HowTo';
+		elseif (preg_match('/\\b(?:horror)/', $category))
+			$this->class .= $cache[$category] = 'cat_Horror';
+		elseif (preg_match('/\\b(?:special|variety|info|collect)/', $category))
+			$this->class .= $cache[$category] = 'cat_Misc';
+		elseif (preg_match('/\\b(?:news|nachrichten|current)/', $category))
+			$this->class .= $cache[$category] = 'cat_News';
+		elseif (preg_match('/\\b(?:reality)/', $category))
+			$this->class .= $cache[$category] = 'cat_Reality';
+		elseif (preg_match('/\\b(?:romance|lieb)/', $category))
+			$this->class .= $cache[$category] = 'cat_Romance';
+		elseif (preg_match('/\\b(?:fantasy|sci\\w*\\W*fi)/', $category))
+			$this->class .= $cache[$category] = 'cat_SciFi_Fantasy';
+		elseif (preg_match('/\\b(?:science|nature|environment|wissenschaft)/', $category))
+			$this->class .= $cache[$category] = 'cat_Science_Nature';
+		elseif (preg_match('/\\b(?:shop)/', $category))
+			$this->class .= $cache[$category] = 'cat_Shopping';
+		elseif (preg_match('/\\b(?:soaps)/', $category))
+			$this->class .= $cache[$category] = 'cat_Soaps';
+		elseif (preg_match('/\\b(?:spirit|relig)/', $category))
+			$this->class .= $cache[$category] = 'cat_Spiritual';
+		elseif (preg_match('/\\b(?:sport|deportes|futbol)/', $category))
+			$this->class .= $cache[$category] = 'cat_Sports';
+		elseif (preg_match('/\\b(?:talk)/', $category))
+			$this->class .= $cache[$category] = 'cat_Talk';
+		elseif (preg_match('/\\b(?:travel|reisen)/', $category))
+			$this->class .= $cache[$category] = 'cat_Travel';
+		elseif (preg_match('/\\b(?:war|krieg)/', $category))
+			$this->class .= $cache[$category] = 'cat_War';
+		elseif (preg_match('/\\b(?:west)/', $category))
+			$this->class .= $cache[$category] = 'cat_Western';
+		else
+			$this->class .= $cache[$category] = 'cat_Unknown';
+	}
 }
 
-?>
\ No newline at end of file
+?>
Index: mythweb/includes/sorting.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/includes/sorting.php,v
retrieving revision 1.9
diff -u -r1.9 sorting.php
--- mythweb/includes/sorting.php	20 Aug 2003 05:13:33 -0000	1.9
+++ mythweb/includes/sorting.php	29 Jan 2004 23:52:49 -0000
@@ -74,6 +74,10 @@
 		return strcasecmp($a->title, $b->title);
 	}
 
+	function by_type(&$a, &$b) {
+		return strcasecmp($a->texttype, $b->texttype);
+	}
+
 	function by_subtitle(&$a, &$b) {
 		return strcasecmp($a->subtitle, $b->subtitle);
 	}
Index: mythweb/themes/Default/program_detail.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/themes/Default/program_detail.php,v
retrieving revision 1.13
diff -u -r1.13 program_detail.php
--- mythweb/themes/Default/program_detail.php	28 Jan 2004 02:16:42 -0000	1.13
+++ mythweb/themes/Default/program_detail.php	29 Jan 2004 23:52:49 -0000
@@ -62,11 +62,11 @@
 				?></span></td>
 		</tr><tr>
 			<td colspan="3">&nbsp;</td>
-		</tr><? if (strlen($this_program->subtitle)) { ?><tr>
+		</tr><? if (!isset($_GET[recordid]) && strlen($this_program->subtitle)) { ?><tr>
 			<td colspan="2" align="right">Episode:&nbsp;</td>
 			<td><?=$this_program->subtitle?></td>
 		</tr><? }
-				if (strlen($this_program->description)) {?><tr>
+				if (!isset($_GET[recordid]) && strlen($this_program->description)) {?><tr>
 			<td colspan="2" align="right" valign="top">Description:&nbsp;</td>
 			<td><?=wordwrap($this_program->description, 45, "<BR>\n")?></td>
 		</tr><? } ?><tr>
@@ -88,8 +88,12 @@
 	<td valign="top" align="right" rowspan="2">
 
 		<form action="program_detail.php" method="get" name="record_settings">
+		<? if (isset($_GET[recordid])) {?>
+		<input type="hidden" name="recordid" value="<?=$_GET['recordid']?>">
+		<? } else {?>
 		<input type="hidden" name="chanid" value="<?=$_GET['chanid']?>">
 		<input type="hidden" name="starttime" value="<?=$_GET['starttime']?>">
+		<? } ?>
 
 		<table class="command command_border_l command_border_t command_border_b command_border_r" align="center" border="0" cellspacing="0" cellpadding="5">
 		<tr>
@@ -168,8 +172,11 @@
 </tr>
 <tr>
 	<td height="100%" align="center" valign="bottom">
-		<a href="program_listing.php?time=<?php echo $this_program->starttime?>">What else is on at this time?</a>&nbsp;&nbsp;&nbsp;
-        <a href="program_listing.php?time=<?php echo $_SESSION['list_time']?>">Back to the program listing!</a></td>
+		<? if (isset($_GET[recordid])) { ?>
+	<a href="all_recordings.php">Back to All recordings!</a></td>
+		<? } else { ?>
+	<a href="program_listing.php?time=<?php echo $this_program->starttime?>">What else is on at this time?</a>&nbsp;&nbsp;&nbsp;
+        <a href="program_listing.php?time=<?php echo $_SESSION['list_time']?>">Back to the program listing!</a></td> <? } ?>
 	</td>
 </tr>
 </table>
Index: mythweb/themes/Default/theme.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/themes/Default/theme.php,v
retrieving revision 1.12
diff -u -r1.12 theme.php
--- mythweb/themes/Default/theme.php	28 Jan 2004 02:26:58 -0000	1.12
+++ mythweb/themes/Default/theme.php	29 Jan 2004 23:52:49 -0000
@@ -122,6 +122,8 @@
 				&nbsp; | &nbsp;
 				<a href="scheduled_recordings.php">Scheduled Recordings</a>
 				&nbsp; | &nbsp;
+				<a href="all_recordings.php">All Recordings</a>
+				&nbsp; | &nbsp;
 				<a href="recorded_programs.php">Recorded Programs</a>
 				&nbsp; | &nbsp;
 				<a href="status.php">Backend Status</a><?php
--- /dev/null	2003-09-15 09:40:47.000000000 -0400
+++ mythweb/all_recordings.php	2004-01-29 14:04:15.000000000 -0500
@@ -0,0 +1,89 @@
+<?
+/***                                                                        ***\
+	all_recordings.php                      Last Updated: 2004.01.29 (alden)
+
+	view and fix scheduling conflicts.
+\***                                                                        ***/
+
+
+// Initialize the script, database, etc.
+	require_once "includes/init.php";
+	require_once "includes/sorting.php";
+
+// Make sure we get the form data
+	isset($_GET['chanid'])    or $_GET['chanid']    = $_POST['chanid'];
+	isset($_GET['starttime']) or $_GET['starttime'] = $_POST['starttime'];
+
+// Doing something to a recording?  Load its detailed info
+	if ($_GET['chanid'] && $_GET['starttime']) {
+		$recording = load_one_recording($_GET['starttime'], $_GET['chanid']);
+
+	// Fake an old recording so that this show won't record again
+		if ($_GET['never_record'] || $_POST['never_record']) {
+			$result = mysql_query('REPLACE INTO oldrecorded (chanid, starttime, endtime, title, subtitle, description, category) VALUES ('
+									.escape($recording->chanid)                    .','
+									.escape($recording->starttime)                 .'),'
+									.escape($recording->endtime)                   .'),'
+									.escape($recording->title)                     .','
+									.escape($recording->subtitle)                  .','
+									.escape($recording->description)               .','
+									.escape($recording->category)                  .')')
+				or trigger_error('SQL Error: '.mysql_error(), FATAL);
+		// Make sure the aren't any manual overrides set for this show, either
+			$result = mysql_query('DELETE FROM recordoverride WHERE chanid='.escape($_GET['chanid']).' AND title='.escape($recording->title).' AND subtitle='.escape($recording->subtitle).' AND description='.escape($recording->desription))
+				or trigger_error('SQL Error: '.mysql_error().' [#'.mysql_errno().']', FATAL);
+		}
+	// Suppress something that shouldn't be recorded
+		elseif ($_GET['suppress'] || $_POST['suppress']) {
+			$result = mysql_query('DELETE FROM recordoverride WHERE chanid='.escape($recording->chanid).' AND starttime=FROM_UNIXTIME('.escape($recording->starttime).') AND endtime=FROM_UNIXTIME('.escape($recording->endtime).')')
+				or trigger_error('SQL Error: '.mysql_error().' [#'.mysql_errno().']', FATAL);
+			$result = mysql_query('REPLACE INTO recordoverride (recordid,type,chanid,starttime,endtime,title,subtitle,description) VALUES ('
+									.escape($recording->recordid).','
+									.'2,'	// record override type:   1 == record, 2 == don't record
+									.escape($recording->chanid)                    .','
+									.'FROM_UNIXTIME('.escape($recording->starttime).'),'
+									.'FROM_UNIXTIME('.escape($recording->endtime)  .'),'
+									.escape($recording->title)                     .','
+									.escape($recording->subtitle)                  .','
+									.escape($recording->description)               .')')
+				or trigger_error('SQL Error: '.mysql_error().' [#'.mysql_errno().']', FATAL);
+		}
+
+	// Notify the backend of the changes
+		backend_notify_changes();
+	}
+
+// Load the recordings
+	$records = load_all_recordings();
+
+// Parse the recording list
+	$All_Shows = array();
+	$Recordings  = array();
+	$Channels  = array();
+
+	foreach ($records as $record) {
+		$show = new Recording($record);
+	// Assign a reference to this show to the various arrays
+		$All_Shows[]                 = &$show;
+		$Recordings[$show['title']][]  = &$show;
+		$Channels[$show['chanid']][] = &$show;
+		unset($show);
+	}
+
+// Sort the recordings
+	if (count($All_Shows))
+		sort_programs($All_Shows, 'scheduled_sortby');
+
+// Load the class for this page
+	require_once theme_dir."all_recordings.php";
+
+// Create an instance of this page from its theme object
+	$Page = new Theme_all_recordings();
+
+// Display the page
+	$Page->print_page();
+
+// Exit
+	exit;
+
+?>
--- /dev/null	2003-09-15 09:40:47.000000000 -0400
+++ mythweb/themes/Default/all_recordings.php	2004-01-29 18:22:54.000000000 -0500
@@ -0,0 +1,189 @@
+<?php
+/***                                                                        ***\
+	all_recordings.php                    Last Updated: 2004.01.29 (alden)
+
+	This file defines a theme class for the all recordings section.
+	It must define one method.   documentation will be added someday.
+
+\***                                                                        ***/
+
+#class theme_program_detail extends Theme {
+class Theme_all_recordings extends Theme {
+
+	function print_page() {
+	// Print the main page header
+		parent::print_header('MythWeb - All Recordings');
+	// Print the page contents
+		global $All_Shows;
+?>
+
+<script language="JavaScript" type="text/javascript">
+<!--
+	function changevisible() {
+		var prev_visible_class = "no_padding";
+
+		for (var i=1; i < document.getElementById("listings").rows.length; i++) {
+			if (document.getElementById("listings").rows[i].className == "list_separator") {
+				if (prev_visible_class == "list_separator")
+					document.getElementById("listings").rows[i].style.display = "none";
+				else
+					document.getElementById("listings").rows[i].style.display = "";
+				prev_visible_class = "list_separator";
+			}
+			else {
+	 			if (document.getElementById(document.getElementById("listings").rows[i].className).checked) {
+					document.getElementById("listings").rows[i].style.display = "";
+					prev_visible_class = document.getElementById("listings").rows[i].className;
+	 			}
+				else
+					document.getElementById("listings").rows[i].style.display = "none";
+			}
+      	}
+	}
+// -->
+</script>
+
+<?php
+$group_field = $_GET['sortby'];
+if ($group_field == "") {
+    $group_field = "title";
+} elseif ( ! (($group_field == "title") || ($group_field == "channum") || ($group_field == "type")) ) {
+	$group_field = "";
+}
+
+?>
+
+<table id="listings" width="100%" border="0" cellpadding="4" cellspacing="2" class="list small">
+<tr class="menu">
+	<?php if ($group_field != '') echo "<td class=\"list\">&nbsp;</td>\n"; ?>
+	<td><a href="all_recordings.php?sortby=title">show</a></td>
+	<td><a href="all_recordings.php?sortby=channum">station</a></td>
+	<td><a href="all_recordings.php?sortby=type">type</a></td>
+</tr><?php
+	$row = 0;
+
+	$prev_group="";
+	$cur_group="";
+
+	foreach ($All_Shows as $show) {
+	// Reset the command variable to a default URL
+		$commands = array();
+		$urlstr = 'recordid='.$show->recordid;
+
+		$class   = 'scheduled';
+
+	// Build a popup table for the mouseover of the cell, with extra program information?
+		if (show_popup_info) {
+		// A program id counter
+			static $program_id_counter = 0;
+			$program_id_counter++;
+		// Add a footnote
+			global $Footnotes;
+			$Footnotes[] = "<div id=\"program_$program_id_counter\" class=\"hidden\">
+<table class=\"menu small\" border=\"1\" cellpadding=\"5\" cellspacing=\"0\">
+<tr>
+	<td><table class=\"menu small\" cellpadding=\"2\" cellspacing=\"0\">
+		<tr>
+			<td align=\"right\">Airtime:</td>
+			<td>".date($_SESSION['date_scheduled_popup'].', '.$_SESSION['time_format'], $show->starttime).' to '.date($_SESSION['time_format'], $show->endtime)."</td>
+		</tr><tr>
+			<td align=\"right\">Program:</td>
+			<td>$show->title</td>
+		</tr>"
+		.(preg_match('/\\S/', $show->subtitle) ? "<tr>
+			<td align=\"right\">Episode:</td>
+			<td>$show->subtitle</td>
+		</tr>" : '')
+		.(preg_match('/\\S/', $show->description) ? "<tr>
+			<td align=\"right\" valign=\"top\">Description:</td>
+			<td>".nl2br(wordwrap($show->description, 70))."</td>
+		</tr>" : '')
+		.(preg_match('/\\S/', $show->rating) ? "<tr>
+			<td align=\"right\" valign=\"top\">Rating:</td>
+			<td>$show->rating</td>
+		</tr>" : '') . "<tr>
+			<td align=\"right\">Type:</td>
+			<td>$show->texttype</td>
+		</tr>"
+//		.($show->airdate > 0 ? "<tr>
+//			<td align=\"right\">Orig.&nbsp;Airdate:</td>
+//			<td>$show->airdate</td>
+//		</tr>" : '')
+		.(preg_match('/\\S/', $show->category) ? "<tr>
+			<td align=\"right\">Category:</td>
+			<td>$show->category</td>
+		</tr>" : '')
+		.($show->previouslyshown ? "<tr>
+			<td align=\"right\">Rerun:</td>
+			<td>Yes</td>
+		</tr>" : '')
+		.($show->will_record ? "<tr>
+			<td align=\"right\">Schedule:</td>
+			<td>".($show->record_daily       ? "Always record on this channel at this time"
+					: ($show->record_weekly  ? "Always record on this channel at this time on this day of the week"
+					: ($show->record_once    ? "Will be recorded once"
+					: ($show->record_channel ? "Always record on this channel"
+					: "Always record"))))."</td>
+		</tr>" : '')
+		.(preg_match('/\\S/', $show->profile) ? "<tr>
+			<td align=\"right\">Profile:</td>
+			<td>$show->profile</td>
+		</tr>" : '')
+		.($show->recstatus ? "<tr>
+			<td align=\"right\">Notes:</td>
+			<td>".$GLOBALS['RecStatus_Reasons'][$show->recstatus]."</td>
+		</tr>" : '')
+		."</table></td>
+</tr>
+</table>
+</div>";
+		}
+
+	// Print a dividing row if grouping changes
+	if ($group_field == "type")
+		$cur_group = $show->texttype;
+	elseif ($group_field == "channum")
+		$cur_group = $show->channel->name;
+	elseif ($group_field == "title")
+		$cur_group = $show->title;
+
+	if ( $cur_group != $prev_group && $group_field != '' ) {
+?><tr class="list_separator">
+	<td colspan="5" class="list_separator"><?php echo $cur_group?></td>
+</tr><?php
+	}
+
+	// Print the content
+	?><tr class="<?php echo $class?>">
+	<?php if ($group_field != '') echo "<td class=\"list\">&nbsp;</td>\n"; ?>
+	<td class="<?php echo $show->class?>"><?php
+		// Print a link to record this show
+		echo '<a id="program_'.$program_id_counter.'_anchor" href="program_detail.php?recordid='.$show->recordid.'"'
+			 .(show_popup_info ? ' onmouseover="window.status=\'Details for: '.str_replace('\'', '\\\]', $show->title).'\';show(\'program_'.$program_id_counter.'\');return true"'
+			 					.' onmouseout="window.status=\'\';hide(\'program_'.$program_id_counter.'\');return true"'
+							   : '')
+			 .'>'.$show->title
+			 .(preg_match('/\\w/', $show->subtitle) ? ":  $show->subtitle" : '')
+			 .'</a>';
+		?></td>
+	<td><?php echo $show->channel->name?></td>
+	<td nowrap><?php echo $show->texttype?></td>
+<?php	foreach ($commands as $command) { ?>
+	<td nowrap width="5%" class="command command_border_l command_border_t command_border_b command_border_r" align="center"><?php echo $command?></td>
+<?php	} ?>
+</tr><?php
+		$prev_group = $cur_group;
+		$row++;
+	}
+?>
+
+</table>
+<?php
+
+	// Print the main page footer
+		parent::print_footer();
+	}
+
+}
+
+?>


More information about the mythtv-dev mailing list