Ticket #400: search_from_program_details.diff
File search_from_program_details.diff, 12.3 KB (added by , 19 years ago) |
---|
-
mythweb/themes/Default/program_detail.php
105 105 <dl> 106 106 <?php if (strlen($program->category)) { ?> 107 107 <dt><?php echo t('Category') ?>: </dt> 108 <dd>< ?php echo $program->category ?></dd>108 <dd><a href="search.php?searchstr=<?php echo urlencode($program->category) ?>&search_category=1"><?php echo $program->category ?></a></dd> 109 109 <?php } 110 110 if (strlen($program->airdate)) { 111 111 ?> 112 112 <dt><?php echo t('Original Airdate') ?>: </dt> 113 <dd>< ?php echo $program->airdate ?></dd>113 <dd><a href="search.php?originalairdate=<?php echo urlencode($program->airdate) ?>"><?php echo $program->airdate ?></a></dd> 114 114 <?php } 115 115 if (strlen($program->rating)) { 116 116 ?> … … 122 122 ?>: </dt> 123 123 <dd><?php echo $program->rating ?></dd> 124 124 <?php } 125 if ($program->get_credits('host')) { 125 $credit_types = array('host' => 'Hosted by', 126 'presenter' => 'Presented by', 127 'actor' => 'Cast', 128 'guest_star' => 'Guest Starring', 129 'director' => 'Directed by', 130 'producer' => 'Produced by', 131 'executive_producer' => 'Exec. Producer', 132 'writer' => 'Written by'); 133 foreach (array_keys($credit_types) as $c) { 134 if ($program->get_credits($c)) { 126 135 ?> 127 <dt><?php echo t('Hosted by') ?>: </dt> 128 <dd><?php echo $program->get_credits('host') ?></dd> 129 <?php } 130 if ($program->get_credits('presenter')) { 136 <dt><?php echo t($credit_types[$c]) ?>: </dt><dd> 137 <?php 138 $peeplist = array(); 139 foreach (explode(',', $program->get_credits($c)) as $peep) { 140 $peep = trim($peep); 141 $peeplist[] = "<a href='search.php?name=" . urlencode($peep) . "'>$peep</a>"; 142 } 143 print implode(', ', $peeplist); 144 ?></dd> 145 <?php } 146 } 131 147 ?> 132 <dt><?php echo t('Presented by') ?>: </dt>133 <dd><?php echo $program->get_credits('presenter') ?></dd>134 <?php }135 if ($program->get_credits('actor')) {136 ?>137 <dt><?php echo t('Cast') ?>: </dt>138 <dd><?php echo $program->get_credits('actor') ?></dd>139 <?php }140 if ($program->get_credits('guest_star')) {141 ?>142 <dt><?php echo t('Guest Starring') ?>: </dt>143 <dd><?php echo $program->get_credits('guest_star') ?></dd>144 <?php }145 if ($program->get_credits('director')) {146 ?>147 <dt><?php echo t('Directed by') ?>: </dt>148 <dd><?php echo $program->get_credits('director') ?></dd>149 <?php }150 if ($program->get_credits('producer')) {151 ?>152 <dt><?php echo t('Produced by') ?>: </dt>153 <dd><?php echo $program->get_credits('producer') ?></dd>154 <?php }155 if ($program->get_credits('executive_producer')) {156 ?>157 <dt><?php echo t('Exec. Producer') ?>: </dt>158 <dd><?php echo $program->get_credits('executive_producer') ?></dd>159 <?php }160 if ($program->get_credits('writer')) {161 ?>162 <dt><?php echo t('Written by') ?>: </dt>163 <dd><?php echo $program->get_credits('writer') ?></dd>164 <?php } ?>165 148 </dl> 166 149 </div> 167 150 <?php } ?> -
mythweb/search.php
15 15 // Load all channels 16 16 load_all_channels(); 17 17 18 // A single search string passed in 19 if ($_GET['searchstr'] || $_POST['searchstr']) { 18 $program_search_fields = array('title', 'subtitle', 'descr', 'category', 'category_type', 'originalairdate', 'name'); 19 20 // A single search string passed in, OR search 21 if (array_key_exists('searchstr', $_REQUEST)) { 20 22 unset($_SESSION['search']); 21 $_SESSION['search']['searchstr'] = _or($_GET['searchstr'], $_POST['searchstr']); 22 $_SESSION['search']['search_title'] = _or($_GET['search_title'], $_POST['search_title']); 23 $_SESSION['search']['search_subtitle'] = _or($_GET['search_subtitle'], $_POST['search_subtitle']); 24 $_SESSION['search']['search_description'] = _or($_GET['search_description'], $_POST['search_description']); 25 $_SESSION['search']['search_category'] = _or($_GET['search_category'], $_POST['search_category']); 26 $_SESSION['search']['search_category_type'] = _or($_GET['search_category_type'], $_POST['search_category_type']); 23 $_SESSION['search']['searchstr'] = $_REQUEST['searchstr']; 24 foreach ($program_search_fields as $e) { 25 $e = "search_$e"; 26 if (array_key_exists($e, $_REQUEST)) { 27 $_SESSION['search'][$e] = $_REQUEST[$e]; 28 } 29 } 27 30 } 28 31 29 30 // Individual search strings for different fields 31 elseif ($_GET['title'] || $_GET['subtitle'] || $_GET['description'] || $_GET['category'] || $_GET['category_type'] || $_GET['originalairdate'] 32 || $_POST['title'] || $_POST['subtitle'] || $_POST['description'] || $_POST['category'] || $_POST['category_type'] || $_POST['originalairdate'] ) { 33 unset($_SESSION['search']); 34 $_SESSION['search']['title'] = _or($_GET['title'], $_POST['title']); 35 $_SESSION['search']['subtitle'] = _or($_GET['subtitle'], $_POST['subtitle']); 36 $_SESSION['search']['description'] = _or($_GET['description'], $_POST['description']); 37 $_SESSION['search']['category'] = _or($_GET['category'], $_POST['category']); 38 $_SESSION['search']['category_type'] = _or($_GET['category_type'], $_POST['category_type']); 39 $_SESSION['search']['originalairdate'] = _or($_GET['originalairdate'], $_POST['originalairdate']); 32 // Individual search strings for different fields, AND search 33 else { 34 $first = 1; 35 foreach ($program_search_fields as $e) { 36 if (array_key_exists($e, $_REQUEST)) { 37 if ($first) { 38 unset($_SESSION['search']); 39 $first = 0; 40 } 41 $_SESSION['search'][$e] = $_REQUEST[$e]; 42 } 43 } 40 44 } 41 45 // Update some universal search settings 42 if ($_ GET['search_exact'] || $_POST['search_exact'])43 $_SESSION['search']['search_exact'] = _or($_GET['search_exact'], $_POST['search_exact']);44 if ($_ GET['search_hd'] || $_POST['search_hd'])45 $_SESSION['search']['search_hd'] = _or($_GET['search_hd'], $_POST['search_hd']);46 if ($_REQUEST['search_exact']) 47 $_SESSION['search']['search_exact'] = $_REQUEST['search_exact']; 48 if ($_REQUEST['search_hd']) 49 $_SESSION['search']['search_hd'] = $_REQUEST['search_hd']; 46 50 47 51 // Flags that apply in all cases 48 $nodups = _or($_GET['nodups'], $_POST['nodups']);52 $nodups = $_REQUEST['nodups']; 49 53 54 // Debugging 55 // print_r($_SESSION['search']); exit; 56 50 57 // Start the query 51 58 $search_name = ''; 52 59 $query = array(); … … 99 106 else 100 107 $search = search_escape($search_str); 101 108 // Build the query 102 if ($_SESSION['search']['search_title']) 103 $query[] = "program.title$compare$search"; 104 if ($_SESSION['search']['search_subtitle']) 105 $query[] = "program.subtitle$compare$search"; 106 if ($_SESSION['search']['search_description']) 107 $query[] = "program.description$compare$search"; 108 if ($_SESSION['search']['search_category']) 109 $query[] = "program.category$compare$search"; 110 if ($_SESSION['search']['search_category_type']) 111 $query[] = "program.category_type$compare$search"; 109 foreach ($program_search_fields as $e) { 110 if (array_key_exists("search_$e", $_SESSION['search'])) { 111 $query[] = "program.$e$compare$search"; 112 } 113 } 112 114 // No query formed - default to quicksearch 113 115 if (!count($query)) { 114 116 $query[] = "program.title$compare$search"; … … 121 123 // Individual-field search is an AND search 122 124 $joiner = ' AND '; 123 125 // Build the query 124 if ($_SESSION['search']['title']) 125 $query[] = "program.title$compare".search_escape($_SESSION['search']['title']); 126 if (isset($_SESSION['search']['subtitle'])) 127 $query[] = "program.subtitle$compare".search_escape($_SESSION['search']['subtitle']); 128 if (isset($_SESSION['search']['description'])) 129 $query[] = "program.description$compare".search_escape($_SESSION['search']['description']); 130 if (isset($_SESSION['search']['category'])) 131 $query[] = "program.category$compare".search_escape($_SESSION['search']['category']); 132 if (isset($_SESSION['search']['category_type'])) 133 $query[] = "program.category_type$compare".search_escape($_SESSION['search']['category_type']); 134 if (isset($_SESSION['search']['originalairdate'])) 135 $query[] = "program.originalairdate > NOW()"; 126 $search_name_list = array(); 127 foreach ($program_search_fields as $e) { 128 if (isset($_SESSION['search'][$e])) { 129 if ($e == 'originalairdate') { 130 $search_name_list[] = "originally aired " . $_SESSION['search'][$e]; 131 if (strstr($_SESSION['search']['originalairdate'], '-')) { 132 $query[] = "program.originalairdate = '".$_SESSION['search'][$e]."'"; 133 } else { 134 $query[] = "program.originalairdate LIKE '".$_SESSION['search'][$e]."-%'"; 135 } 136 } elseif ($e == 'name') { 137 $query[] = "people.$e$compare".search_escape($_SESSION['search'][$e]); 138 $search_name_list[] = "cast or crew includes " . $_SESSION['search'][$e]; 139 } else { 140 $query[] = "program.$e$compare".search_escape($_SESSION['search'][$e]); 141 $search_name_list[] = "$e is " . $_SESSION['search'][$e]; 142 } 143 } 144 } 145 $search_name = implode(', ', $search_name_list); 136 146 } 137 147 138 148 // No query? -
mythweb/includes/programs.php
107 107 trigger_error("load_all_program_data() attempted with an empty \$Channels array", FATAL); 108 108 $these_channels = implode(',', $these_channels); 109 109 // Build the sql query, and execute it 110 $query = 'SELECT program.*,'110 $query = 'SELECT distinct program.*,' 111 111 .' UNIX_TIMESTAMP(program.starttime) AS starttime_unix,' 112 112 .' UNIX_TIMESTAMP(program.endtime) AS endtime_unix,' 113 113 .' CONCAT(repeat('.escape(star_character).', program.stars * '.escape(max_stars).'), IF((program.stars * '.escape(max_stars).' * 10) % 10, "½", "")) AS starstring,' 114 114 .' IFNULL(programrating.system, "") AS rater,' 115 115 .' IFNULL(programrating.rating, "") AS rating' 116 116 .' FROM program LEFT JOIN programrating USING (chanid, starttime)' 117 .' LEFT JOIN credits USING (chanid, starttime)' 118 .' LEFT JOIN people USING (person)' 117 119 .' WHERE'; 118 120 // Only loading a single channel worth of information 119 121 if ($chanid > 0)