Ticket #1419: fix_category_sort.2.patch

File fix_category_sort.2.patch, 11.1 KB (added by anonymous, 14 years ago)
  • includes/sorting.php

    diff -NBurp mythweb-old/includes/sorting.php mythweb/includes/sorting.php
    old new  
    7070        isset($_GET['reverse']) or $_GET['reverse'] = $_POST['reverse'];
    7171        isset($_GET['sortby'])  or $_GET['sortby']  = $_POST['sortby'];
    7272    // Now we build an array the user's sort preferences
    73         if (!is_array($_SESSION[$session]) || !count($_SESSION[$session]))
     73        if (!is_array($_SESSION[$session]) || !count($_SESSION[$session])) {
    7474            $_SESSION[$session] = array(array('field' => 'airdate',
    7575                                              'reverse' => false),
    7676                                        array('field' => 'title',
    7777                                              'reverse' => false));
     78        }
    7879    // If we were given a sort parameter, let's put it into the sort preferences
    7980        if ($_GET['sortby']) {
    8081            $_GET['sortby'] = strtolower($_GET['sortby']);
    81             if (!function_exists('by_'.$_GET['sortby']))
     82            if (!function_exists('by_'.$_GET['sortby'])) {
    8283                $_GET['sortby'] = 'title';
     84            }
    8385        // This sortby method is the first element in the sort array, let's reverse it (unless told otherwise)
    8486            if ($_SESSION[$session][0]['field'] == $_GET['sortby']) {
    85                 if (isset($_GET['reverse']))
     87                if (isset($_GET['reverse'])) {
    8688                    $_SESSION[$session][0]['reverse'] = ($_GET['reverse'] > 0 || eregi('^y', $_GET['reverse'])) ? true : false;
    87                 else
     89                }
     90                else {
    8891                    $_SESSION[$session][0]['reverse'] = $_SESSION[$session][0]['reverse'] ? false : true;
     92                }
    8993            }
    9094        // Otherwise, we need to parse the array, and add the current choice to the top
    9195            else {
    9296            // Scan the sort array for any entries matching the current choice, and remove them
    9397                foreach ($_SESSION[$session] as $key => $sort) {
    9498                // Found a match, or an old/accidental sort method - remove the sort entry
    95                     if ($sort['field'] == $_GET['sortby'] || !function_exists('by_'.$sort['field']))
     99                    if ($sort['field'] == $_GET['sortby'] || !function_exists('by_'.$sort['field'])) {
    96100                        unset($_SESSION[$session][$key]);
     101                    }
    97102                }
    98103            // Add this choice to the top of the list
    99104                array_unshift($_SESSION[$session], array('field'   => $_GET['sortby'],
    100                                                          'reverse' => $_GET['reverse'] ? true : false));
     105                                                         'reverse' => $_GET['reverse'] ? false : false));
    101106            }
    102107        }
    103108    // No sortby, but requested a reversal of the main field
    104         elseif ($_GET['reverse'])
     109        elseif ($_GET['reverse']) {
    105110            $_SESSION[$session][0]['reverse'] = $_SESSION[$session][0]['reverse'] ? false : true;
     111        }
     112        else {
     113          $_SESSION[$session][0]['reverse'] = false;
     114        }
    106115    // Once we've processed the information, we should make sure that we're actually sorting an array
    107         if (!count($programs))
     116        if (!count($programs)) {
    108117            return;
     118        }
    109119    // Now we just need to sort the array
    110120        $GLOBALS['user_sort_choice'] = &$_SESSION[$session];
    111121        usort($programs, 'by_user_choice');
  • modules/video/edit.php

    diff -NBurp mythweb-old/modules/video/edit.php mythweb/modules/video/edit.php
    old new if (isset($_POST['submit'])) { 
    4444?>
    4545<html>
    4646<head>
    47 <script language="JavaScript">
     47<script type="text/javascript">
    4848<!--
    4949    function refreshParent() {
    5050        window.opener.location.href = window.opener.location.href;
    if (isset($_POST['submit'])) { 
    9999<table width="302" border="0" cellspacing="0" cellpadding="3">
    100100<tr>
    101101    <td width="99">Title:</td>
    102     <td width="301"><input name="title" type="text" value="<?php if (isset($title)) print $title ?>"></td>
     102    <td width="301"><input name="title" type="text" value="<?php if (isset($title)) echo $title ?>"></td>
    103103</tr><tr>
    104104    <td>Director:</td>
    105     <td><input name="director" type="text" value="<?php if (isset($director)) print $director ?>"></td>
     105    <td><input name="director" type="text" value="<?php if (isset($director)) echo $director ?>"></td>
    106106</tr><tr>
    107107    <td>Plot:</td>
    108     <td><textarea name="plot" rows="5" cols="30" wrap="VIRTUAL"><?php if (isset($plot)) print $plot ?></textarea></td>
     108    <td><textarea name="plot" rows="5" cols="30" wrap="VIRTUAL"><?php if (isset($plot)) echo $plot ?></textarea></td>
    109109</tr><tr>
    110110    <td>Category:</td>
    111111    <td><select name="category">
    if (isset($_POST['submit'])) { 
    122122        ?></select></td>
    123123</tr><tr>
    124124    <td>Rating:</td>
    125     <td><input name="rating" type="text" value="<?php if (isset($rating)) print $rating ?>"></td>
     125    <td><input name="rating" type="text" value="<?php if (isset($rating)) echo $rating ?>"></td>
    126126</tr><tr>
    127127    <td>IMDB:</td>
    128     <td><input name="inetref" type="text" value="<?php if (isset($inetref)) print $inetref ?>"></td>
     128    <td><input name="inetref" type="text" value="<?php if (isset($inetref)) echo $inetref ?>"></td>
    129129</tr><tr>
    130130    <td>Year:</td>
    131     <td><input name="year" type="text" size=4 value="<?php if (isset($year)) print $year ?>"></td>
     131    <td><input name="year" type="text" size=4 value="<?php if (isset($year)) echo $year ?>"></td>
    132132</tr><tr>
    133133    <td>Userrating:</td>
    134     <td><input name="userrating" type="text" size=3 value="<?php if (isset($userrating)) print $userrating ?>"></td>
     134    <td><input name="userrating" type="text" size=3 value="<?php if (isset($userrating)) echo $userrating ?>"></td>
    135135</tr><tr>
    136136    <td>Length:</td>
    137     <td><input name="length" type="text" size=3 value="<?php if (isset($length)) print $length ?>"> in minutes</td>
     137    <td><input name="length" type="text" size=3 value="<?php if (isset($length)) echo $length ?>"> in minutes</td>
    138138</tr><tr>
    139139    <td></td>
    140     <td><input type="hidden" name="intid" value="<?php if (isset($_REQUEST['intid'])) print $_REQUEST['intid'] ?>">
     140    <td><input type="hidden" name="intid" value="<?php if (isset($_REQUEST['intid'])) echo $_REQUEST['intid'] ?>">
    141141       <input type="submit" name="submit" value="submit"></td>
    142142</tr>
    143143</table>
  • themes/default/video/video.php

    diff -NBurp mythweb-old/themes/default/video/video.php mythweb/themes/default/video/video.php
    old new  
    2020    require_once theme_dir.'/header.php';
    2121?>
    2222
    23 <SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
     23<script type="text/javascript">
    2424<!--Hide script from old browsers
    2525
    2626function newWindow(newContent)
    function newWindow(newContent) 
    2929 }
    3030
    3131 //Stop hiding script from old browsers -->
    32  </SCRIPT>
     32 </script>
    3333<table width="100%" border="0" cellpadding="4" cellspacing="2" class="list small">
    3434<tr class="menu">
    3535<td>
    3636<?php
    37     echo '<form action="'.root."video\" method=\"GET\">\n";
     37    echo '<form action="'.root."video\" method=\"get\">\n";
    3838    echo t('Display') . ": ";
    3939    echo "<select name=\"category\">\n";
    4040    echo '<option value="-1"';
    function newWindow(newContent) 
    6161<?php   if (show_video_covers) { ?>
    6262    <td><?php echo t('cover') ?></td>
    6363<?php   } ?>
    64     <td><a href="<?php echo root ?>video?sortby=title"><?php    echo t('title') ?></a></td>
    65     <td><a href="<?php echo root ?>video?sortby=director"><?php echo t('director') ?></a></td>
     64    <td><a href="<?php echo root ?>video?sortby=title<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php    echo t('title') ?></a></td>
     65    <td><a href="<?php echo root ?>video?sortby=director<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php echo t('director') ?></a></td>
    6666    <td><?php echo t('plot')     ?></td>
    67     <td><a href="<?php echo root ?>video?sortby=category"><?php echo t('category') ?></a></td>
    68     <td><?php echo t('rating')   ?></a></td>
    69     <td><?php echo t('IMDB')     ?></a></td>
    70     <td><a href="<?php echo root ?>video?sortby=length"><?php     echo t('length') ?></a></td>
    71     <td><a href="<?php echo root ?>video?sortby=userrating"><?php echo t('imdb rating') ?></a></td>
    72     <td><a href="<?php echo root ?>video?sortby=year"><?php       echo t('year') ?></a></td>
    73     <td><?php echo t('Edit') ?></a></td>
     67    <td><a href="<?php echo root ?>video?sortby=category<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php echo t('category') ?></a></td>
     68    <td><?php echo t('rating')   ?></td>
     69    <td><?php echo t('IMDB')     ?></td>
     70    <td><a href="<?php echo root ?>video?sortby=length<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php     echo t('length') ?></a></td>
     71    <td><a href="<?php echo root ?>video?sortby=userrating<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php echo t('imdb rating') ?></a></td>
     72    <td><a href="<?php echo root ?>video?sortby=year<?php echo $_GET['category'] ? ('&amp;category=' . $_GET['category']) : ''?>"><?php       echo t('year') ?></a></td>
     73    <td><?php echo t('Edit') ?></td>
    7474</tr><?php
    7575    $row = 0;
    7676    foreach ($All_Shows as $show) {
    7777    ?><tr class="recorded">
    7878    <td><?php
    7979        if (show_video_covers && file_exists(video_img_path.'/'.basename($show->coverfile)))
    80             echo '<a href="'.$show->url.'"><img id="'.html_entities($show->filename).'" src="'.video_img_path.'/'.basename($show->coverfile).'" width="'.video_img_width.'" height="'.video_img_height.'">';
     80            echo '<a href="'.$show->url.'"><img src="'.video_img_path.'/'.basename($show->coverfile).'" width="'.video_img_width.'" height="'.video_img_height.'" alt="' . html_entities($show->title) . '"/></a>';
    8181        else
    8282            echo '&nbsp;';
    8383    ?></td>
    8484    <td><?php echo '<a href="'.$show->url.'">'.html_entities($show->title).'</a>' ?></td>
    85     <td><?php echo $show->director                   ?></td>
    86     <td><?php echo $show->plot                       ?></td>
    87     <td><?php echo $Category_String[$show->category] ?></td>
     85    <td><?php echo html_entities($show->director)                   ?></td>
     86    <td><?php echo html_entities($show->plot)                       ?></td>
     87    <td><?php echo html_entities($Category_String[$show->category]) ?></td>
    8888    <td><?php echo $show->rating                     ?></td>
    8989    <td><a href="http://www.imdb.com/Title?<?php echo $show->inetref ?>"><?php echo $show->inetref ?></a></td>
    9090    <td nowrap><?php echo nice_length($show->length * 60) ?></td>
    9191    <td nowrap><?php echo $show->userrating ?></td>
    9292    <td nowrap><?php echo $show->year ?></td>
    93     <td><a href="javascript:newWindow ('<?php echo root ?>video/edit?intid=<?php echo $show->intid ?>')" ><?php echo t('Edit') ?></a>
     93    <td><a href="javascript:newWindow('<?php echo root ?>video/edit?intid=<?php echo $show->intid ?>')"><?php echo t('Edit') ?></a>
    9494<?php
    9595        $row++;
    9696    }