チェンジセット 36: trunk/install/php/viewepg.php

差分発生行の前後
無視リスト:
コミット日時:
2007/01/08 20:58:03 (17 年前)
コミッタ:
sorshi
ログメッセージ:

EPG番組表の表示スタイルを、横軸がそろうように改良。

ファイル:

凡例:

変更無し
追加
削除
更新
コピー
移動
  • trunk/install/php/viewepg.php

    r1 r36  
    44 http://www.dcc-jpl.com/soft/foltia/ 
    55 
    6 reserveprogram.php 
     6viewepg.php 
    77 
    88目的 
     
    2525<title>foltia:EPG</title> 
    2626</head> 
    27  
    2827<?php 
    29   include("./foltialib.php"); 
     28include("./foltialib.php"); 
    3029   
    3130$con = m_connect(); 
    32  
    3331$start = getgetnumform(start); 
    3432 
     
    3836  $start = ereg_replace( "[^0-9]", "", $start);  
    3937} 
    40  
    4138?> 
    42  
    4339<body BGCOLOR="#ffffff" TEXT="#494949" LINK="#0047ff" VLINK="#000000" ALINK="#c6edff" > 
    4440<div align="center"> 
     
    4642printhtmlpageheader(); 
    4743?> 
    48   <p align="left"><font color="#494949" size="6">番組表</font></p> 
     44  <p align="left"><font color="#494949" size="6">EPG番組表</font></p> 
    4945  <hr size="4"> 
    50 <p align="left">番組表を表示します。 
     46<p align="left">EPG番組表を表示します。 
    5147<?php  
    5248 
     
    111107 
    112108 
    113  
    114109if ($maxrows > $maxdisplay){ 
    115110//複数ページ 
     
    127122} 
    128123} 
    129  
    130  
    131         $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%'  ORDER BY stationid ASC , stationrecch OFFSET $offset LIMIT $maxdisplay  
     124//ココから新コード 
     125//・局リスト 
     126$query = "SELECT stationid, stationname, stationrecch, ontvcode  
     127FROM foltia_station  
     128WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     129ORDER BY stationid ASC , stationrecch  
     130OFFSET $offset LIMIT $maxdisplay  
     131"; 
     132$slistrs = m_query($con, $query, "DBクエリに失敗しました"); 
     133$stations =  pg_num_rows($slistrs); 
     134for ($i=0 ; $i < $stations ; $i++){ 
     135        $rowdata = pg_fetch_row($slistrs, $i); 
     136        $stationhash[$i] = $rowdata[3] ; 
     137
     138 
     139//・時間と全順番のハッシュ作る 
     140$epgstart = $start ; 
     141$epgend = calcendtime($start , (8*60)); 
     142 
     143$query = "SELECT DISTINCT startdatetime    
     144FROM foltia_epg 
     145WHERE foltia_epg.ontvchannel in ( 
     146        SELECT ontvcode  
     147        FROM foltia_station  
     148        WHERE \"ontvcode\" ~~ '%ontvjapan%'   
     149        ORDER BY stationid ASC , stationrecch  
     150        OFFSET $offset LIMIT $maxdisplay 
     151        ) 
     152AND startdatetime  >= $start   
     153AND startdatetime  < $epgend   
     154ORDER BY foltia_epg.startdatetime  ASC  "; 
     155 
     156$rs = m_query($con, $query, "DBクエリに失敗しました"); 
     157$colmnums =  pg_num_rows($rs); 
     158if ($colmnums == 0){ 
     159//番組データがない 
     160$colmnums = 2; 
     161}else{ 
     162        for ($i=0 ; $i < $colmnums ; $i++){ 
     163                $rowdata = pg_fetch_row($rs, $i); 
     164                $timetablehash["$rowdata[0]"] = $i; 
     165        } 
     166
     167//・局ごとに縦に配列入れていく 
     168for ($j=0 ; $j < $stations ; $j++){ 
     169        $rowdata = pg_fetch_row($slistrs, $j); 
     170        $stationname = $rowdata[3]; 
     171 
     172$epgstart = $start ; 
     173$epgend = calcendtime($start , (8*60)); 
     174$query = " 
     175SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory  ,ontvchannel  ,epgid  
     176FROM foltia_epg  
     177WHERE foltia_epg.ontvchannel = '$stationname' AND  
     178enddatetime  > $epgstart  AND  
     179startdatetime  < $epgend   
     180ORDER BY foltia_epg.startdatetime  ASC 
    132181        "; 
    133         $rs = m_query($con, $query, "DBクエリに失敗しました"); 
    134  
    135 //print "<!--$query  -->"; 
    136 $viewstations = pg_num_rows($rs); 
    137 print "</p> 
    138  <table width=\"100%\"  border=\"0\"> 
    139   <tbody> 
    140    <tr class=\"kyoku\"> 
    141 "; 
    142 for ($i=0 ; $i < $viewstations ; $i++){ 
    143         $rowdata = pg_fetch_row($rs, $i); 
    144         if ($rowdata[1] != ""){ 
    145         print "    <th scope=\"col\">$rowdata[1]</th>\n"; 
     182        $statiodh = m_query($con, $query, "DBクエリに失敗しました"); 
     183        $maxrowsstation = pg_num_rows($statiodh); 
     184if ($maxrowsstation == 0) { 
     185                //print("番組データがありません<BR>"); 
     186                $item[0]["$stationname"] =  "番組データがありません"; 
     187}else{ 
     188 
     189for ($srow = 0; $srow < $maxrowsstation ; $srow++) {  
     190          
     191$stationrowdata = pg_fetch_row($statiodh, $srow); 
     192 
     193$printstarttime = substr($stationrowdata[0],8,2) . ":" .  substr($stationrowdata[0],10,2); 
     194$tdclass = "t".substr($stationrowdata[0],8,2) .  substr($stationrowdata[0],10,2); 
     195$title = $stationrowdata[3]; 
     196$title = htmlspecialchars(z2h($title)); 
     197$desc = $stationrowdata[4]; 
     198$desc = htmlspecialchars(z2h($desc)); 
     199$height =  htmlspecialchars($stationrowdata[2]) * 3; 
     200$epgid =  htmlspecialchars($stationrowdata[7]); 
     201 
     202if (isset($timetablehash["$stationrowdata[0]"])){ 
     203        $number = $timetablehash["$stationrowdata[0]"]; 
     204}else{ 
     205        $number = 0; 
     206
     207$item["$number"]["$stationname"] =  "$printstarttime <A HREF=\"./reserveepg.php?epgid=$epgid\">$title</A> $desc"; 
     208}//for 
     209}//if 
     210 
     211//・局ごとに間隔決定 
     212//$item[$i][NHK] はヌルかどうか判定 
     213$dataplace = 0 ; //初期化 
     214$rowspan = 0; 
     215 
     216for ($i=1; $i <= $colmnums ; $i++){ 
     217        if ($i === ($colmnums - 1)){//最終行 
     218                $rowspan = $i - $dataplace + 1; 
     219                //そして自分自身にタグを 
     220                        if ($item[$i][$stationname] == ""){ 
     221                        $item[$i][$stationname]  = ""; 
     222                        }else{ 
     223                        $item[$i][$stationname]  = "<td>". $item[$i][$stationname] . "</td>"; 
     224                        $rowspan--; 
     225                        } 
     226                        //ROWSPAN 
     227                        if ($rowspan === 1 ){ 
     228                        $item[$dataplace][$stationname]  = "<td>". $item[$dataplace][$stationname] . "</td>"; 
     229                        }else{ 
     230                        $item[$dataplace][$stationname]  = "<td  rowspan = $rowspan>". $item[$dataplace][$stationname] . "</td>"; 
     231                        } 
     232 
     233        }elseif ($item[$i][$stationname] == ""){ 
     234        //ヌルなら 
     235                $item[$i][$stationname]  =  $item[$i][$stationname] ; 
     236        }else{ 
     237        //なんか入ってるなら 
     238                $rowspan = $i - $dataplace; 
     239                        if ($rowspan === 1 ){ 
     240                        $item[$dataplace][$stationname]  = "<td>". $item[$dataplace][$stationname] . "</td>"; 
     241                        }else{ 
     242                        $item[$dataplace][$stationname]  = "<td rowspan = $rowspan>". $item[$dataplace][$stationname] . "</td>"; 
     243                        } 
     244                $dataplace = $i; 
     245                 
    146246        } 
    147 
    148  
    149 print "  </tr> 
    150  
    151  <tr  valign = top> 
    152 "; 
    153 for ($i=0 ; $i < $viewstations ; $i++){ 
    154         $rowdata = pg_fetch_row($rs, $i); 
    155         if ($rowdata[3] != ""){ 
    156         print "<td>"; 
    157                 renderepgstation($con,$rowdata[3],$start); 
    158         print "</td>\n"; 
     247}//for 
     248}// end of for://・局ごとに縦に配列入れていく 
     249 
     250//・テーブルレンダリング 
     251print "<table>\n<tr>"; 
     252 
     253//ヘッダ 
     254for ($i=0;$i<$stations;$i++){ 
     255        $rowdata = pg_fetch_row($slistrs, $i); 
     256        print "<th>".htmlspecialchars($rowdata[1])."</th>" ; 
     257
     258//本体 
     259for ($l = 0 ;$l <  $colmnums; $l++){ 
     260        print "<tr>"; 
     261        for ($m = 0 ; $m < $stations ; $m++ ){ 
     262                $stationname = $stationhash[$m]; 
     263                print_r($item[$l]["$stationname"]); 
    159264        } 
    160 
    161  
    162 print " </tr> 
    163         </tbody> 
    164 </table> 
    165 "; 
    166  
     265        print "</tr>\n"; 
     266
     267print "</table>\n"; 
    167268 ?> 
    168269 
    169270</body> 
    170271</html> 
     272 
     273 
track feed