Index: trunk/install/php/viewepg.php =================================================================== --- trunk/install/php/viewepg.php (リビジョン 1) +++ trunk/install/php/viewepg.php (リビジョン 36) @@ -4,5 +4,5 @@ http://www.dcc-jpl.com/soft/foltia/ -reserveprogram.php +viewepg.php 目的 @@ -25,10 +25,8 @@ foltia:EPG - -
@@ -46,7 +42,7 @@ printhtmlpageheader(); ?> -

番組表

+

EPG番組表


-

番組表を表示します。 +

EPG番組表を表示します。 $maxdisplay){ //複数ページ @@ -127,44 +122,152 @@ } } - - - $query = "SELECT stationid, stationname, stationrecch, ontvcode FROM foltia_station WHERE \"ontvcode\" ~~ '%ontvjapan%' ORDER BY stationid ASC , stationrecch OFFSET $offset LIMIT $maxdisplay +//ココから新コード +//・局リスト +$query = "SELECT stationid, stationname, stationrecch, ontvcode +FROM foltia_station +WHERE \"ontvcode\" ~~ '%ontvjapan%' +ORDER BY stationid ASC , stationrecch +OFFSET $offset LIMIT $maxdisplay +"; +$slistrs = m_query($con, $query, "DBクエリに失敗しました"); +$stations = pg_num_rows($slistrs); +for ($i=0 ; $i < $stations ; $i++){ + $rowdata = pg_fetch_row($slistrs, $i); + $stationhash[$i] = $rowdata[3] ; +} + +//・時間と全順番のハッシュ作る +$epgstart = $start ; +$epgend = calcendtime($start , (8*60)); + +$query = "SELECT DISTINCT startdatetime +FROM foltia_epg +WHERE foltia_epg.ontvchannel in ( + SELECT ontvcode + FROM foltia_station + WHERE \"ontvcode\" ~~ '%ontvjapan%' + ORDER BY stationid ASC , stationrecch + OFFSET $offset LIMIT $maxdisplay + ) +AND startdatetime >= $start +AND startdatetime < $epgend +ORDER BY foltia_epg.startdatetime ASC "; + +$rs = m_query($con, $query, "DBクエリに失敗しました"); +$colmnums = pg_num_rows($rs); +if ($colmnums == 0){ +//番組データがない +$colmnums = 2; +}else{ + for ($i=0 ; $i < $colmnums ; $i++){ + $rowdata = pg_fetch_row($rs, $i); + $timetablehash["$rowdata[0]"] = $i; + } +} +//・局ごとに縦に配列入れていく +for ($j=0 ; $j < $stations ; $j++){ + $rowdata = pg_fetch_row($slistrs, $j); + $stationname = $rowdata[3]; + +$epgstart = $start ; +$epgend = calcendtime($start , (8*60)); +$query = " +SELECT startdatetime , enddatetime , lengthmin , epgtitle , epgdesc , epgcategory ,ontvchannel ,epgid +FROM foltia_epg +WHERE foltia_epg.ontvchannel = '$stationname' AND +enddatetime > $epgstart AND +startdatetime < $epgend +ORDER BY foltia_epg.startdatetime ASC "; - $rs = m_query($con, $query, "DBクエリに失敗しました"); - -//print ""; -$viewstations = pg_num_rows($rs); -print "

- - - -"; -for ($i=0 ; $i < $viewstations ; $i++){ - $rowdata = pg_fetch_row($rs, $i); - if ($rowdata[1] != ""){ - print " \n"; + $statiodh = m_query($con, $query, "DBクエリに失敗しました"); + $maxrowsstation = pg_num_rows($statiodh); +if ($maxrowsstation == 0) { + //print("番組データがありません
"); + $item[0]["$stationname"] = "番組データがありません"; +}else{ + +for ($srow = 0; $srow < $maxrowsstation ; $srow++) { + +$stationrowdata = pg_fetch_row($statiodh, $srow); + +$printstarttime = substr($stationrowdata[0],8,2) . ":" . substr($stationrowdata[0],10,2); +$tdclass = "t".substr($stationrowdata[0],8,2) . substr($stationrowdata[0],10,2); +$title = $stationrowdata[3]; +$title = htmlspecialchars(z2h($title)); +$desc = $stationrowdata[4]; +$desc = htmlspecialchars(z2h($desc)); +$height = htmlspecialchars($stationrowdata[2]) * 3; +$epgid = htmlspecialchars($stationrowdata[7]); + +if (isset($timetablehash["$stationrowdata[0]"])){ + $number = $timetablehash["$stationrowdata[0]"]; +}else{ + $number = 0; +} +$item["$number"]["$stationname"] = "$printstarttime $title $desc"; +}//for +}//if + +//・局ごとに間隔決定 +//$item[$i][NHK] はヌルかどうか判定 +$dataplace = 0 ; //初期化 +$rowspan = 0; + +for ($i=1; $i <= $colmnums ; $i++){ + if ($i === ($colmnums - 1)){//最終行 + $rowspan = $i - $dataplace + 1; + //そして自分自身にタグを + if ($item[$i][$stationname] == ""){ + $item[$i][$stationname] = ""; + }else{ + $item[$i][$stationname] = ""; + $rowspan--; + } + //ROWSPAN + if ($rowspan === 1 ){ + $item[$dataplace][$stationname] = ""; + }else{ + $item[$dataplace][$stationname] = ""; + } + + }elseif ($item[$i][$stationname] == ""){ + //ヌルなら + $item[$i][$stationname] = $item[$i][$stationname] ; + }else{ + //なんか入ってるなら + $rowspan = $i - $dataplace; + if ($rowspan === 1 ){ + $item[$dataplace][$stationname] = ""; + }else{ + $item[$dataplace][$stationname] = ""; + } + $dataplace = $i; + } -} - -print " - - -"; -for ($i=0 ; $i < $viewstations ; $i++){ - $rowdata = pg_fetch_row($rs, $i); - if ($rowdata[3] != ""){ - print "\n"; +}//for +}// end of for://・局ごとに縦に配列入れていく + +//・テーブルレンダリング +print "
$rowdata[1]". $item[$i][$stationname] . "". $item[$dataplace][$stationname] . "". $item[$dataplace][$stationname] . "". $item[$dataplace][$stationname] . "". $item[$dataplace][$stationname] . "
"; - renderepgstation($con,$rowdata[3],$start); - print "
\n"; + +//ヘッダ +for ($i=0;$i<$stations;$i++){ + $rowdata = pg_fetch_row($slistrs, $i); + print "" ; +} +//本体 +for ($l = 0 ;$l < $colmnums; $l++){ + print ""; + for ($m = 0 ; $m < $stations ; $m++ ){ + $stationname = $stationhash[$m]; + print_r($item[$l]["$stationname"]); } -} - -print " - -
".htmlspecialchars($rowdata[1])."
-"; - + print "\n"; +} +print "\n"; ?> + +