Ticket #2841: chansort.diff

File chansort.diff, 7.5 KB (added by jochen, 17 years ago)

Version 1

  • modules/tv/init.php

     
    1616    $Settings['tv'] = array('name'    => t('TV'),
    1717                            'choices' => array('session'  => t('My Session'),
    1818                                               'channels' => t('Channel Info'),
     19                                               'chanlist' => t('Channel Sorting'),
    1920                                              ),
    2021                            'default' => 'session',
    2122                           );
  • modules/tv/set_chanlist.php

     
     1<?php
     2/**
     3 * Configure MythTV Channels
     4 *
     5 * @url         $URL: http://svn.mythtv.org/svn/trunk/mythplugins/mythweb/modules/settings/channels.php $
     6 * @date        $Date: 2006-06-24 21:03:10 +0200 (Sa, 24 Jun 2006) $
     7 * @version     $Revision: 10290 $
     8 * @author      $Author: xris $
     9 * @license     GPL
     10 *
     11 * @package     MythWeb
     12 * @subpackage  Settings
     13 *
     14/**/
     15
     16// Save?
     17    if ($_POST['listhiddenchannels']) {
     18    // Parse the post variables and save each group of channel info
     19        $arrvis = explode("|",$_POST['listvisiblechannels']);
     20        $arrhid = explode("|",$_POST['listhiddenchannels']);
     21       
     22        $cnt = 0;
     23        for ($i=0;$i<sizeof($arrvis)-1;$i++)
     24        {
     25          $cnt++;
     26          $chanid = trim($arrvis[$i]);
     27 
     28            // Not deleting so grab values that can be empty
     29                $query = 'UPDATE channel SET channum       = ?,
     30                                             visible       = ?,
     31                                             useonairguide = ?';
     32                $query_params[] = $cnt;
     33                $query_params[] = '1';
     34                $query_params[] = '1';
     35        // Submit the query
     36            $db->query($query.' WHERE chanid=?',
     37                       $query_params,
     38                       $chanid
     39                      );
     40            unset($query_params);
     41            //echo "chid: $chanid  &nbsp;&nbsp;&nbsp; nr: $cnt <br>";
     42        }
     43       
     44        for ($i=0;$i<sizeof($arrhid)-1;$i++)
     45        {
     46          $cnt++;
     47          $chanid = trim($arrhid[$i]);
     48            // Not deleting so grab values that can be empty
     49                $query = 'UPDATE channel SET channum = ?, visible = ?, useonairguide = ?';
     50                $query_params[] = $cnt;
     51                $query_params[] = '0';
     52                $query_params[] = '0';
     53        // Submit the query
     54            $db->query($query.' WHERE chanid=?',
     55                       $query_params,
     56                       $chanid
     57                      );
     58            unset($query_params);
     59
     60
     61        }
     62    }
     63
     64// Load all of the channel data from the database
     65    $Channels = array();
     66    $sh = $db->query('SELECT * FROM channel WHERE visible = \'1\' ORDER BY CAST(channum AS SIGNED);');
     67    while ($row = $sh->fetch_assoc()) {
     68        $Channels[] = $row;
     69    }
     70    $sh->finish();
     71
     72    $ChannelsHidden = array();
     73    $sh = $db->query('SELECT * FROM channel WHERE visible = \'0\' ORDER BY name;');
     74    while ($row = $sh->fetch_assoc()) {
     75        $ChannelsHidden[] = $row;
     76    }
     77    $sh->finish();
  • modules/tv/tmpl/default/set_chanlist.php

     
     1<script>
     2function showidx()
     3{
     4  var selvis = document.getElementById("visiblechannels");
     5  var myidx = document.getElementById("myindex");
     6  var idx = selvis.selectedIndex;
     7 
     8  myidx.innerHTML = idx + 1;
     9
     10}
     11
     12function showchan()
     13{
     14  var selvis = document.getElementById("visiblechannels");
     15  var selhid = document.getElementById("hiddenchannels");
     16  var idx = selhid.selectedIndex;
     17 
     18  while (idx >= 0)
     19  {
     20   var newEintrag = document.createElement("option");
     21   newEintrag.text = selhid[idx].text;
     22   newEintrag.value = selhid[idx].value;
     23   selvis.add(newEintrag, null);
     24   selhid.remove(idx);
     25   idx = selhid.selectedIndex;
     26  }
     27  showidx();
     28}
     29
     30function hidechan()
     31{
     32  var selvis = document.getElementById("visiblechannels");
     33  var selhid = document.getElementById("hiddenchannels");
     34  var idx = selvis.selectedIndex;
     35 
     36  while (idx >= 0)
     37  {
     38   var newEintrag = document.createElement("option");
     39   newEintrag.text = selvis[idx].text;
     40   newEintrag.value = selvis[idx].value;
     41   selhid.add(newEintrag, null);
     42   selvis.remove(idx);
     43   idx = selvis.selectedIndex;
     44  }
     45
     46  showidx();
     47}
     48
     49function moveup()
     50{
     51  var selvis = document.getElementById("visiblechannels");
     52  var idx = selvis.selectedIndex;
     53 
     54  if (idx > 0)
     55  {
     56   var tmp
     57   tmp = selvis[idx].text;
     58   selvis[idx].text = selvis[idx-1].text;
     59   selvis[idx-1].text = tmp;
     60   
     61   tmp = selvis[idx].value
     62   selvis[idx].value = selvis[idx-1].value;
     63   selvis[idx-1].value = tmp;
     64   
     65   selvis.selectedIndex = idx - 1;
     66  }
     67  showidx();
     68}
     69
     70function movedown()
     71{
     72  var selvis = document.getElementById("visiblechannels");
     73  var idx = selvis.selectedIndex;
     74  var max = selvis.length;
     75 
     76  if (idx >= 0 && idx < max - 1)
     77  {
     78   var tmp
     79   tmp = selvis[idx].text;
     80   selvis[idx].text = selvis[idx+1].text;
     81   selvis[idx+1].text = tmp;
     82   
     83   tmp = selvis[idx].value
     84   selvis[idx].value = selvis[idx+1].value;
     85   selvis[idx+1].value = tmp;
     86   
     87   selvis.selectedIndex = idx + 1;
     88  }
     89  showidx();
     90}
     91
     92function saveit()
     93{
     94  var selvis = document.getElementById("visiblechannels");
     95  var selhid = document.getElementById("hiddenchannels");
     96  var cntvis = selvis.length;
     97  var cnthid = selhid.length;
     98  var listvis = document.getElementById("listvisiblechannels");
     99  var listhid = document.getElementById("listhiddenchannels");
     100  var myform = document.getElementById("myform");
     101  var wrt = 0, lst = "";
     102 
     103  for(i=0;i<cntvis;i++)
     104  {
     105    wrt = selvis[i].value;
     106    lst = lst + wrt + "|";
     107  } 
     108  listvis.value = lst;
     109  lst = "";
     110  wrt = 0;
     111 
     112  for(i=0;i<cnthid;i++)
     113  {
     114    wrt = selhid[i].value;
     115    lst = lst + wrt + "|";
     116  } 
     117  listhid.value = lst;
     118 
     119  myform.submit();
     120}
     121
     122
     123
     124</script>
     125
     126
     127<form class="form" method="post" id="myform" action="<?php echo root ?>settings/tv/chanlist">
     128<center>
     129
     130<table>
     131<tr>
     132<td>Visible Channels</td>
     133<td></td>
     134<td>Hidden Channels</td>
     135</tr>
     136
     137<tr>
     138<td>
     139<select multiple id=visiblechannels name=visiblechannels size=22 onclick="javascript:showidx()">
     140<?php
     141foreach ($Channels as $channel) {
     142?>
     143<option value="<?php echo $channel['chanid']; ?> "><?php echo $channel['name']; ?></option>
     144<?php
     145}
     146?>
     147</select>
     148</td>
     149<td>
     150<div id=myindex>0</div>
     151<br><br>
     152
     153<input type=button onclick="javascript:hidechan()" value="--&gt; hide channel"><br>
     154<input type=button onclick="javascript:showchan()" value="&lt;-- show channel"><br>
     155<br><br>
     156<input type=button onclick="javascript:moveup()" value="move up"><br>
     157<input type=button onclick="javascript:movedown()" value="move down"><br>
     158</td>
     159<td>
     160<select multiple id=hiddenchannels name=hiddenchannels size=22>
     161<?php
     162foreach ($ChannelsHidden as $channel) {
     163?>
     164<option value="<?php echo $channel['chanid']; ?> "><?php echo $channel['name']; ?></option>
     165<?php
     166}
     167?>
     168</select>
     169</td>
     170</tr>
     171</table>
     172
     173
     174<p align="center">
     175<input type="hidden" name="listvisiblechannels" id="listvisiblechannels" value="">
     176<input type="hidden" name="listhiddenchannels" id="listhiddenchannels" value="">
     177
     178<input type="button" onclick="javascript:saveit()" name="save" value="<?php echo t('Save') ?>">
     179</p>
     180
     181</form>