Ticket #2181: calendar.diff

File calendar.diff, 13.8 KB (added by jochen, 18 years ago)

Calendar Patch V1.0

  • calendar.php

     
     1<?php
     2$monthliste = '"'.t("January").'","'.t("February").'","'.t("March").'","'.t("April").'","'.t("May").'","'.t("June").'","'.t("July").'","'.t("August").'","'.t("September").'","'.t("October").'","'.t("November").'","'.t("December").'"';
     3$list_starttime = intVal($_GET['time']);
     4
     5// Find out how many days into the past we should bother checking
     6$result = mysql_query('SELECT TO_DAYS(min(starttime)) - TO_DAYS(NOW()) FROM program')
     7or trigger_error('SQL Error: '.mysql_error(), FATAL);
     8list($min_days) = mysql_fetch_row($result);
     9mysql_free_result($result);
     10// Find out how many days into the future we should bother checking
     11$result = mysql_query('SELECT TO_DAYS(max(starttime)) - TO_DAYS(NOW()) FROM program')
     12or trigger_error('SQL Error: '.mysql_error(), FATAL);
     13list($max_days) = mysql_fetch_row($result);
     14mysql_free_result($result);
     15// Print out the list
     16for ($i=$min_days;$i<=$max_days;$i++) {
     17    $time = mktime(0,0,0, date('m'), date('d') + $i, date('Y'));
     18    $date = date("Y-m-d", $time);
     19    $arr .= $date."|" ;
     20}
     21?>
     22<html>
     23<head>
     24<style>
     25b           {font-weight: 900;}
     26body    {margin: 1px; font-family: Verdana; cursor: default}
     27td              { font-size: 7pt}
     28a:link  {color: black;font-decoration: none;text-decoration: none;}
     29a:visited{color: black; text-decoration: none;}
     30a:hover.my{color: black;text-decoration: underline;}
     31a:link.spe      {color: black; font-weight: bolder; }
     32a:visited.spe   {color: black; }
     33.arrow  {font-weight: bold}
     34.prevnext       {background: none; color: gray; text-align:center;}
     35.thismonth      {background: white; color: black; text-align:center;}
     36.mytoday        {background: lightgray; color: white; text-align:center;}
     37.today  {color: blue; text-align:center; font-weight: 900;}
     38</style>
     39</head>
     40
     41<body bgcolor=white scroll=no onSelectStart="window.event.returnValue = false" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
     42   
     43<table border=0 width=126 heigth=129 cellspacing=0 cellpadding=0>
     44  <tr>
     45    <td height="16" colspan=7 align=center bgcolor="#CCCCCC" id="IDToday"><a class=my href=javascript:ShowAK()><? echo date("l, j.n.Y",time());?></a></td>
     46  </tr>
     47
     48  <tr>
     49    <td height="1" colspan=7 align=center bgcolor="#000000"></td>
     50  </tr>
     51
     52  <tr height=10>
     53    <td valign=center align=center bgcolor="#CCCCCC"><a id=ID_Prev class=spe target=_self href=javascript:ShowPrevMonth(true)><img src="<?php echo skin_url ?>img/left.gif" border=0></a></td>
     54    <td colspan=5 align=center bgcolor="#CCCCCC"><a class=my href=javascript:ShowMonth()><div id="IDCaption">&nbsp;</div></a></td>
     55    <td valign=center align=center bgcolor="#CCCCCC"><a id=ID_Next class=spe target=_self href=javascript:ShowNextMonth(true)><img src="<?php echo skin_url ?>img/right.gif" border=0></a></td>
     56  </tr>
     57  <tr>
     58    <td width="18" align="center"> <font color="#000000">M</font></td>
     59    <td width="18" align="center"> <font color="#000000">D</font></td>
     60    <td width="18" align="center"> <font color="#000000">M</font></td>
     61    <td width="18" align="center"> <font color="#000000">D</font></td>
     62    <td width="18" align="center"> <font color="#000000">F</font></td>
     63    <td width="18" align="center"> <font color="#000000">S</font></td>
     64    <td width="18" align="center"> <font color="#000000">S</font></td>
     65  </tr>
     66   <tr><td height="1" colspan=7 bgcolor="#666666"></td></tr>
     67 <tr height=12>
     68    <td id=dt_1></td>
     69    <td id=dt_2></td>
     70    <td id=dt_3></td>
     71    <td id=dt_4></td>
     72    <td id=dt_5></td>
     73    <td id=dt_6></td>
     74    <td id=dt_7></td>
     75  </tr>
     76  <tr height=12>
     77    <td id=dt_8></td>
     78    <td id=dt_9></td>
     79    <td id=dt_10></td>
     80    <td id=dt_11></td>
     81    <td id=dt_12></td>
     82    <td id=dt_13></td>
     83    <td id=dt_14></td>
     84  </tr>
     85  <tr height=12>
     86    <td id=dt_15></td>
     87    <td id=dt_16></td>
     88    <td id=dt_17></td>
     89    <td id=dt_18></td>
     90    <td id=dt_19></td>
     91    <td id=dt_20></td>
     92    <td id=dt_21></td>
     93  </tr>
     94  <tr height=12>
     95    <td id=dt_22></td>
     96    <td id=dt_23></td>
     97    <td id=dt_24></td>
     98    <td id=dt_25></td>
     99    <td id=dt_26></td>
     100    <td id=dt_27></td>
     101    <td id=dt_28></td>
     102  </tr>
     103  <tr height=12>
     104    <td id=dt_29></td>
     105    <td id=dt_30></td>
     106    <td id=dt_31></td>
     107    <td id=dt_32></td>
     108    <td id=dt_33></td>
     109    <td id=dt_34></td>
     110    <td id=dt_35></td>
     111  </tr>
     112  <tr height=12>
     113    <td id=dt_36></td>
     114    <td id=dt_37></td>
     115    <td id=dt_38></td>
     116    <td id=dt_39></td>
     117    <td id=dt_40></td>
     118    <td id=dt_41></td>
     119    <td id=dt_42></td>
     120  </tr>
     121  <tr>
     122  <td height="1" colspan=7></td>
     123  </tr>
     124  <tr height=12>
     125    <td valign=center align=center bgcolor="#CCCCCC"><a class=spe target=_self href=javascript:ShowPrevYear(true)><img src="<?php echo skin_url ?>img/left.gif" border=0></a></td>
     126    <td colspan=5 align=center bgcolor="#CCCCCC" id="IDBottom"> jahr</td>
     127    <td valign=center align=center bgcolor="#CCCCCC"><a class=spe target=_self href=javascript:ShowNextYear(true)><img src="<?php echo skin_url ?>img/right.gif" border=0></a></td>
     128  </tr>
     129 
     130</table>
     131   
     132
     133
     134<script>
     135// Zum verhindern das markiert wird!
     136function disableselect(e){
     137  return false
     138}
     139function reEnable(){
     140  return true
     141}
     142
     143document.onselectstart=new Function ("return false")
     144if (window.sidebar)
     145 {
     146 document.onmousedown=disableselect
     147 document.onclick=reEnable
     148 }
     149
     150
     151
     152//Konstanten kalender...
     153    var cnt = 0;
     154
     155    // constants
     156    var c_base = 0;  // 0 - Sunday based week, 1 - Monday based week, etc.
     157
     158    // global variables
     159    var g_month, g_year;
     160
     161    var txt
     162
     163    function numDays(Month, Year)
     164      {
     165      // day 0 of the next month is the last day of this month
     166      return new Date(Year, Month + 1, 0).getDate();
     167      }
     168
     169    function showMonth (Month, Year, HideFocus)
     170      {
     171
     172      var evliste = "<? echo $arr; ?> "
     173
     174        for (tmp=1; tmp<43; tmp++)
     175        {
     176                fld = document.getElementById("dt_"+tmp);
     177                fld.style.background = "#ffffff";
     178        }
     179        cnt = 0;
     180
     181      g_month = Month, g_year = Year;
     182
     183        var Monate = new Array(<?php echo $monthliste; ?>);
     184
     185      document.getElementById("IDCaption").innerHTML = Monate[g_month] + " " + Year;
     186      document.getElementById("IDBottom").innerHTML = Year;
     187
     188
     189      // tdColl = document.all.tags("td");
     190
     191      // get offset of the 1st day of the month
     192      theFirst = new Date(Year, Month, 1);
     193      offset = theFirst.getDay() - c_base;
     194      if (offset <= 0)
     195        offset += 7;
     196
     197      // fill out the previous month
     198      nDays = numDays(Month - 1, Year); // OK for Month - 1 == -1 (Dec of previous year)
     199      for (tdIndex = 1; tdIndex < offset; tdIndex++)
     200        with (document.getElementById("dt_" + tdIndex))
     201          {
     202          className = "prevnext";
     203          innerHTML = "<div onclick=clickPrev()>" + (nDays - offset + 1 + tdIndex) + "</div>";
     204          }
     205
     206      // fill out this month
     207      nDays = numDays(Month, Year);
     208      now = new Date();
     209
     210      isMonthYear = (Month == now.getMonth()) && (Year == now.getFullYear());
     211      for (date = 1; date <= nDays; date++, tdIndex++)
     212        {
     213        var addn1, addn2
     214        addn1="";addn2="";
     215       
     216        if ((Number(Month)+1) < 10)
     217            addn1 = "0";
     218        if (date < 10)
     219            addn2 = "0";
     220               
     221            txt = "<div onClick=FillDate(\"" + Year + addn1 + (Number(Month)+1) + addn2 + date + "\",\"" + tdIndex + "\")>" + date + "</div>";
     222       
     223
     224
     225
     226
     227
     228
     229
     230        with (document.getElementById("dt_" + tdIndex))
     231          {
     232          isToday = isMonthYear && (date == now.getDate());
     233          className = isToday ? "today" : "thismonth";
     234
     235          // var such = ("|" + date +"."+(Number(Month)+1)+"."+ Year);
     236         
     237          var nummon = (Number(Month)+1);
     238          var nummonS = nummon.toString();
     239          var numdateS = date.toString();
     240          if (nummonS.length == 1) {nummonS = "0" + nummonS;}
     241          if (numdateS.length == 1) {numdateS = "0" + numdateS;}
     242         
     243          var such = ("|" + Year + "-" + nummonS + "-"+ numdateS);
     244
     245          var Ergebnis = evliste.indexOf(such);
     246          if(Ergebnis != -1)
     247           { innerHTML = "<b>" + txt + "</b>"; }
     248           else
     249            innerHTML = txt;
     250         
     251          }
     252        }
     253
     254      // fill out the next month
     255      for (date = 1 ; tdIndex < 43; date++, tdIndex++)
     256          with (document.getElementById("dt_" + tdIndex))
     257          {
     258          className = "prevnext";
     259          innerHTML = "<div onclick=clickNext()>" + date +"</div>";
     260          }
     261
     262      }
     263
     264    function clickPrev()
     265      {
     266      ShowPrevMonth(true)
     267      }
     268
     269    function clickNext()
     270      {
     271      ShowNextMonth(true)
     272      }
     273
     274    function ShowPrevMonth(HideFocus)
     275      {
     276      if (g_month == 0)
     277        showMonth(11, g_year - 1, HideFocus);
     278      else
     279        showMonth(g_month - 1, g_year, HideFocus);
     280      }
     281
     282    function ShowPrevYear(HideFocus)
     283      {
     284        showMonth(g_month, g_year -1, HideFocus);
     285      }
     286     
     287    function ShowThisMonth(HideFocus)
     288      {
     289      now = new Date();
     290      showMonth(now.getMonth(), now.getFullYear(), HideFocus);
     291      }
     292
     293    function ShowNextMonth(HideFocus)
     294      {
     295      if (g_month == 11)
     296        showMonth(0, g_year + 1, HideFocus);
     297      else
     298        showMonth(g_month + 1, g_year, HideFocus);
     299      }
     300    function ShowNextYear(HideFocus)
     301      {
     302        showMonth(g_month, g_year + 1, HideFocus);
     303      }
     304    function FillDate(MyDate, SNr)
     305      {
     306
     307        var tmp;
     308        var fld;
     309
     310        for (tmp=1; tmp<43; tmp++)
     311        {
     312                fld = document.getElementById("dt_"+tmp);
     313                fld.style.background = "#ffffff";
     314        }
     315
     316
     317        fld = document.getElementById("dt_"+SNr);
     318
     319        fld.style.background = "#cccccc";
     320       
     321        parent.location.href = "<?php echo root; ?>tv/list?hour=<?php echo date('H', $list_starttime); ?>&date=" + MyDate;
     322      }
     323     function FillDate2(tag,monat,jahr)
     324      {
     325
     326        showMonth(monat-1, jahr , 0);
     327       
     328        var tmp;
     329        var fld;
     330
     331        for (tmp=1; tmp<43; tmp++)
     332        {
     333                fld = document.getElementById("dt_"+tmp);
     334                fld.style.background = "#ffffff";
     335        }
     336
     337
     338        fld = document.getElementById("dt_"+tag);
     339
     340        fld.style.background = "#cccccc";
     341
     342      }
     343    function DoIt()
     344      {
     345      <? $mydate = date("j.n.Y",$list_starttime); ?>
     346      var dtm = "<? echo @$mydate; ?>";
     347      // alert (dtm);
     348      if (dtm != "")
     349      {
     350      var tag, monat, jahr
     351
     352      tag = dtm.substr(0,dtm.indexOf("."));
     353      monat = dtm.substr(dtm.indexOf(".")+1,dtm.lastIndexOf(".")-dtm.indexOf(".")-1);
     354      jahr = dtm.substr(dtm.lastIndexOf(".")+1,4);
     355      FillDate2(Number(tag)+1,Number(monat),Number(jahr));
     356      }
     357      }
     358
     359   DoIt();
     360
     361
     362 function ShowAK()
     363        {
     364        for (tmp=1; tmp<43; tmp++)
     365         {
     366                fld = document.getElementById("dt_"+tmp);
     367                fld.style.background = "#ffffff";
     368         }
     369        DoIt();
     370        parent.location.href = "<?php echo root; ?>tv/list?hour=<?php echo date('H', $list_starttime); ?>&date=<? echo date("Ymd",time());?>";
     371        }
     372
     373 function ShowMonth()
     374        {
     375        }
     376  </script>
     377</html>
  • handler.php

     
    5454    require_once "includes/recording_schedules.php";
    5555
    5656// Unknown section?  Use the default
    57     if (!in_array($Path[1], array('detail', 'channel', 'search', 'movies'))
     57    if (!in_array($Path[1], array('detail', 'channel', 'search', 'movies', 'calendar'))
    5858            && empty($Modules['tv']['links'][$Path[1]]))
    5959        $Path[1] = 'list';
    6060
  • tmpl/default/list.php

     
    6060                        echo ' SELECTED';
    6161                    echo '>'.strftime($_SESSION['time_format'], strtotime("$h:00")).'</option>';
    6262                }
    63                 ?></select></td>
    64             <td align="right"><?php echo t('Date') ?>:&nbsp;</td>
    65             <td style="vertical-align:middle;" nowrap><img src="<?php echo skin_url ?>img/left.gif" onclick="MoveProgramListing(-1)">
    66                 <select name="date" onchange="get_element('program_listing').submit()"><?php
    67             // Find out how many days into the past we should bother checking
    68                 $result = mysql_query('SELECT TO_DAYS(min(starttime)) - TO_DAYS(NOW()) FROM program')
    69                     or trigger_error('SQL Error: '.mysql_error(), FATAL);
    70                 list($min_days) = mysql_fetch_row($result);
    71                 mysql_free_result($result);
    72             // Find out how many days into the future we should bother checking
    73                 $result = mysql_query('SELECT TO_DAYS(max(starttime)) - TO_DAYS(NOW()) FROM program')
    74                     or trigger_error('SQL Error: '.mysql_error(), FATAL);
    75                 list($max_days) = mysql_fetch_row($result);
    76                 mysql_free_result($result);
    77             // Print out the list
    78                 for ($i=$min_days;$i<=$max_days;$i++) {
    79                     $time = mktime(0,0,0, date('m'), date('d') + $i, date('Y'));
    80                     $date = date("Ymd", $time);
    81                     echo "<option value=\"$date\"";
    82                     if ($date == date("Ymd", $list_starttime)) echo " selected";
    83                     echo ">".strftime($_SESSION['date_listing_jump'] , $time)."</option>";
    84                 }
    85                 ?></select>
    86                 <img src="<?php echo skin_url ?>img/right.gif" onclick="MoveProgramListing(+1)"></td>
     63                ?></select><input type=hidden name=date value="<?php echo date("Ymd", $list_starttime); ?>"></td>               
     64            <td style="vertical-align:middle;" nowrap>
     65                <iframe src="<?php echo root ?>tv/calendar?time=<?php echo $list_starttime; ?>" width=128 height=137 scrolling="no" frameborder=0></iframe>
     66            </td>
    8767            <td align="center"><noscript><input type="submit" class="submit" value="<?php echo t('Jump') ?>"></noscript></td>
    8868
    8969