[mythtv] [PATCH] Mythweb -- canned queries, HD search, dup elimination

Brad Templeton brad+mydev at templetons.com
Mon Feb 28 22:27:31 UTC 2005


On Mon, Feb 28, 2005 at 12:06:35PM -0800, Chris Petersen wrote:
> >what version of mythweb did you patch against? It seems there are a few 
> >changes to mythweb recently that have to do with searches and it messes 
> >up the patch.
> 
> He probably didn't take into account the fact that I added an "hd" 
> checkbox the other day as part of my rendition of his hd: patch.

Alas, the troubles of two guys modifying the same lines in some code the
same evening.

Anyway, here's the patch against the current check in (and minus the hd:
flag -- though I thought, Chris, you had said you were tempted to use more
google syntax and fewer options checkboxes.  In any event, I find the canned
searches for HD non-series, at least today, satisfy the need for hd
searching, because there are a grand total of 2 non-series HD programs on
broadcast TV in the next 2 weeks -- the movie Minority Report and the
ever-repeating Cringely.)

The tar file is the same but I'll include it in this update in any event.

Notes:  Why are all the fetched parameters put in the big _SESSION array?
Am I missing something?  DO they need to go there if they are not going to
be used outside this fetch?

Also: While I have not done it, the thought is to remove the Movies item
from the toobar and just use the canned searches of various types.

Is there a way to get cvs diff to include all-new files in a patch?
the -N option seems to say it would do this but it does not.
-------------- next part --------------
? Makefile
? handy.php
? includes/canned.php
? themes/Default/handy.php
Index: search.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/search.php,v
retrieving revision 1.18
diff -u -r1.18 search.php
--- search.php	27 Feb 2005 23:24:06 -0000	1.18
+++ search.php	28 Feb 2005 22:19:36 -0000
@@ -11,6 +11,7 @@
 // Initialize the script, database, etc.
     require_once "includes/init.php";
     require_once "includes/sorting.php";
+    require_once "includes/canned.php";
 
 // Load all channels
     load_all_channels();
@@ -25,9 +26,11 @@
         $_SESSION['search']['search_category']      = _or($_GET['search_category'],      $_POST['search_category']);
         $_SESSION['search']['search_category_type'] = _or($_GET['search_category_type'], $_POST['search_category_type']);
     }
+
+
 // Individual search strings for different fields
-    elseif ($_GET['title'] || $_GET['subtitle'] || $_GET['description'] || $_GET['category'] || $_GET['category_type'] || $_GET['originalairdate']
-            || $_POST['title'] || $_POST['subtitle'] || $_POST['description'] || $_POST['category'] || $_POST['category_type'] || $_POST['originalairdate'] ) {
+    elseif ($_GET['title'] || $_GET['subtitle'] || $_GET['description'] || $_GET['category'] || $_GET['category_type'] || $_GET['originalairdate'] || $_GET['canned']
+            || $_POST['title'] || $_POST['subtitle'] || $_POST['description'] || $_POST['category'] || $_POST['category_type'] || $_POST['originalairdate'] || $_POST['canned'] ) {
         unset($_SESSION['search']);
         $_SESSION['search']['title']           = _or($_GET['title'],           $_POST['title']);
         $_SESSION['search']['subtitle']        = _or($_GET['subtitle'],        $_POST['subtitle']);
@@ -35,6 +38,7 @@
         $_SESSION['search']['category']        = _or($_GET['category'],        $_POST['category']);
         $_SESSION['search']['category_type']   = _or($_GET['category_type'],   $_POST['category_type']);
         $_SESSION['search']['originalairdate'] = _or($_GET['originalairdate'], $_POST['originalairdate']);
+        $_SESSION['search']['canned']          = _or($_GET['canned'],    $_POST['canned']);
     }
 // Update some universal search settings
     if ($_GET['search_exact'] || $_POST['search_exact'])
@@ -42,7 +46,10 @@
     if ($_GET['search_hd'] || $_POST['search_hd'])
         $_SESSION['search']['search_hd'] = _or($_GET['search_hd'], $_POST['search_hd']);
 
-// Start the query out as an array
+
+// Flags that apply in all cases
+    $nodups             = _or($_GET['nodups'],             $_POST['nodups']);
+
     $query       = array();
     $extra_query = array();
     if ($_SESSION['search']['search_exact'])
@@ -99,6 +106,17 @@
     // Individual-field search is an AND search
         $joiner = ' AND ';
     // Build the query
+        $cq = $_SESSION['search']['canned'];
+        if ($cq) {
+            if( $Canned[$cq] ) {
+                $query[] = $Canned[$cq];
+                # default nodups on here, unless explicitly set
+                if( $nodups != "0" )
+                    $nodups = true;
+            }
+         else
+            $Errors[] = "Unknown Canned query: " . $cq;
+        }
         if ($_SESSION['search']['title'])
             $query[] = "program.title$compare".search_escape($_SESSION['search']['title']);
         if (isset($_SESSION['search']['subtitle']))
@@ -129,6 +147,23 @@
             $query = "($query AND ".implode(' AND ', $extra_query).')';
     // Perform the query
         $Results =& load_all_program_data(time(), strtotime('+1 month'), NULL, false, $query);
+
+    // Remove dups from the results if requested
+        if( $nodups ) {
+            $seen = array();        // program ids already seen
+            foreach( $Results as $dex => $row ) {
+                $uniquer = $row->programid . $row->chanid;
+                if( $seen[$uniquer] ) {
+                    // add a new field to the old row
+                    $Results[$seen[$uniquer]]->extra_showings[] =
+                                $row->starttime;
+                    unset( $Results[$dex] );
+                } else {
+                    $seen[$uniquer] = $dex;
+                }
+            
+            }
+        }
     // Sort the results
         if (count($Results))
             sort_programs($Results, 'search_sortby');
Index: languages/English.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/languages/English.php,v
retrieving revision 1.47
diff -u -r1.47 English.php
--- languages/English.php	27 Feb 2005 23:24:06 -0000	1.47
+++ languages/English.php	28 Feb 2005 22:19:37 -0000
@@ -214,6 +214,15 @@
     'Key Bindings'       => '',
     'MythWeb Settings'   => '',
     'settings: overview' => 'This is the index page for the configuration settings...<p>It\'s incomplete, and will eventually get some nicer formatting.  For now, you can choose from the following:',
+// themes/.../handy.php
+    'handy: overview' => 'This page contains pre-prepared complex searches in the listings.',
+    'Movies' => '',
+    'Movies, 3 1/2 Stars or more' => '',
+    'Non-Series HDTV'  => '',
+    'All HDTV'         => '',
+    'Music Specials'                  => '',
+    'Non-Music Specials'                  => '',
+    'Science Fiction Movies'    => '',
 // themes/.../settings_channels.php
     'Please be warned that by altering this table without knowing what you are doing, you could seriously disrupt mythtv functionality.' => '',
 // themes/.../settings_keys.php
@@ -242,6 +251,7 @@
     'HD Only'                                    => '',
     'Manually Schedule'                          => '',
     'Movies'                                     => '',
+    'Searches'                                     => '',
     'MythMusic on the web.'                      => '',
     'MythVideo on the web.'                      => '',
     'MythWeb Weather.'                           => '',
Index: themes/Default/search.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/themes/Default/search.php,v
retrieving revision 1.20
diff -u -r1.20 search.php
--- themes/Default/search.php	5 Feb 2005 05:07:31 -0000	1.20
+++ themes/Default/search.php	28 Feb 2005 22:19:37 -0000
@@ -129,7 +129,16 @@
     <td><?php echo $show->subtitle?></td>
     <td><?php echo $show->description?></td>
     <td><?php echo $show->channel->channum.' - '.$show->channel->name?></td>
-    <td nowrap><?php echo strftime($_SESSION['date_search'], $show->starttime)?></td>
+    <td nowrap><?php
+            echo '<br><a href="program_detail.php?chanid='. $show->chanid.
+                '&starttime='.$show->starttime.'">'.
+                strftime($_SESSION['date_search'], $show->starttime) . '</a>';
+            if( $show->extra_showings )
+                foreach( $show->extra_showings as $showtime ) 
+                    echo '<br><a href="program_detail.php?chanid='.
+                        $show->chanid.'&starttime='.$showtime.'">'.
+                        strftime($_SESSION['date_search'],$showtime). '</a>';
+                ?></td>
     <td nowrap><?php echo nice_length($show->length)?></td>
 </tr><?php
             $prev_group = $cur_group;
Index: themes/Default/theme.php
===================================================================
RCS file: /var/lib/mythcvs/mythweb/themes/Default/theme.php,v
retrieving revision 1.51
diff -u -r1.51 theme.php
--- themes/Default/theme.php	28 Feb 2005 00:15:34 -0000	1.51
+++ themes/Default/theme.php	28 Feb 2005 22:19:38 -0000
@@ -155,6 +155,8 @@
                 <?/*&nbsp; | &nbsp;
                 <a href="index.php?mode=favourites"><?php echo t('Favorites') ?></a>*/?>
                 &nbsp; | &nbsp;
+                <a href="handy.php"><?php echo t('Searches') ?></a>
+                &nbsp; | &nbsp;
                 <a href="schedule_manually.php"><?php echo t('Manually Schedule') ?></a>
                 &nbsp; | &nbsp;
                 <a href="recording_schedules.php"><?php echo t('Recording Schedules') ?></a>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: newfiles.tar
Type: application/x-tar
Size: 10240 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20050228/72ba78b1/newfiles-0001.tar


More information about the mythtv-dev mailing list