OSDN Git Service

modified: index.php
authorSushi-k <epgrec@park.mda.or.jp>
Mon, 27 Jul 2009 10:43:45 +0000 (19:43 +0900)
committerSushi-k <epgrec@park.mda.or.jp>
Mon, 27 Jul 2009 10:43:45 +0000 (19:43 +0900)
index.php
templates/index.html

index 921b793..0449e46 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -4,12 +4,24 @@ include_once("config.php");
 include_once( INSTALL_PATH . "/DBRecord.class.php" );\r
 include_once( INSTALL_PATH . "/Smarty/Smarty.class.php" );\r
 include_once( INSTALL_PATH . "/reclib.php" );\r
+include_once( INSTALL_PATH . "/Settings.class.php" );\r
+\r
+// 設定ファイルの有無を検査する\r
+if( ! file_exists( INSTALL_PATH."/settings/config.xml") ) {\r
+    header( "Content-Type: text/html;charset=utf-8" );\r
+    exit( "<script type=\"text/javascript\">\n" .\r
+          "<!--\n".\r
+         "window.open(\"".$url."\",\"_self\");".\r
+         "// -->\n</script>" );\r
+}\r
+\r
+$settings = Settings::factory();\r
 \r
 $DAY_OF_WEEK = array( "(日)","(月)","(火)","(水)","(木)","(金)","(土)" );\r
 \r
 // パラメータの処理\r
 // 表示する長さ(時間)\r
-$program_length = 8;\r
+$program_length = $settings->program_length;\r
 if( isset( $_GET['length']) ) $program_length = (int) $_GET['length'];\r
 // 地上=GR/BS=BS\r
 $type = "GR";\r
@@ -36,11 +48,11 @@ $last_time = $top_time + 3600 * $program_length;
  if( $type == "BS" ) $channel_map = $BS_CHANNEL_MAP;\r
  else if( $type == "GR" ) $channel_map = $GR_CHANNEL_MAP;\r
  $st = 0;\r
- $prec = new DBRecord(TBL_PREFIX.PROGRAM_TBL);\r
+ $prec = new DBRecord($settings->tbl_prefix.PROGRAM_TBL);\r
  foreach( $channel_map as $channel_disc => $channel ) {\r
        $prev_end = $top_time;\r
        try {\r
-               $crec = new DBRecord( TBL_PREFIX . CHANNEL_TBL, "channel_disc", $channel_disc );\r
+               $crec = new DBRecord( $settings->tbl_prefix . CHANNEL_TBL, "channel_disc", $channel_disc );\r
                $programs[$st]["station_name"]  = $crec->name;\r
                \r
                $reca = $prec->fetch_array( "channel_disc", $channel_disc,\r
@@ -54,9 +66,9 @@ $last_time = $top_time + 3600 * $program_length;
                        // 前プログラムとの空きを調べる\r
                        $start = toTimestamp( $prg['starttime'] );\r
                        if( $start - $prev_end ) {\r
-                               $height = ($start-$prev_end) / 60;\r
+                               $height = ($start-$prev_end) * $settings->height_per_hour / 3600;\r
                                if( $height > 0.5 ) {\r
-                                       $height = (int)($height * 2);\r
+                                       $height = (int)$height;\r
                                        $programs[$st]['list'][$num]['category_none'] = "none";\r
                                        $programs[$st]['list'][$num]['height'] = $height;\r
                                        $programs[$st]['list'][$num]['title'] = "";\r
@@ -67,18 +79,18 @@ $last_time = $top_time + 3600 * $program_length;
                        }\r
                        $prev_end = toTimestamp( $prg['endtime'] );\r
                        \r
-                       $height = (int)((toTimestamp($prg['endtime']) - toTimestamp($prg['starttime'])) / 30);\r
+                       $height = (int)((toTimestamp($prg['endtime']) - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600);\r
                        // $top_time より早く始まっている番組\r
                        if( toTimestamp($prg['starttime']) <$top_time ) {\r
-                               $height = (int)((toTimestamp($prg['endtime']) - $top_time ) / 30);\r
+                               $height = (int)((toTimestamp($prg['endtime']) - $top_time ) * $settings->height_per_hour / 3600);\r
                        }\r
                        // $last_time より遅く終わる番組\r
                        if( toTimestamp($prg['endtime']) > $last_time ) {\r
-                               $height = (int)(($last_time - toTimestamp($prg['starttime'])) / 30);\r
+                               $height = (int)(($last_time - toTimestamp($prg['starttime'])) * $settings->height_per_hour / 3600);\r
                        }\r
                        \r
                        // プログラムを埋める\r
-                       $cat = new DBRecord( TBL_PREFIX . CATEGORY_TBL, "id", $prg['category_id'] );\r
+                       $cat = new DBRecord( $settings->tbl_prefix . CATEGORY_TBL, "id", $prg['category_id'] );\r
                        $programs[$st]['list'][$num]['category_name'] = $cat->name_en;\r
                        $programs[$st]['list'][$num]['height'] = $height;\r
                        $programs[$st]['list'][$num]['title'] = $prg['title'];\r
@@ -88,7 +100,7 @@ $last_time = $top_time + 3600 * $program_length;
                        $programs[$st]['list'][$num]['duration'] = "" . (toTimestamp($prg['endtime']) - toTimestamp($prg['starttime']));\r
                        $programs[$st]['list'][$num]['channel'] = ($prg['type'] == "GR" ? "地上D" : "BS" ) . ":". $prg['channel'] . "ch";\r
                        $programs[$st]['list'][$num]['id'] = "" . ($prg['id']);\r
-                       $programs[$st]['list'][$num]['rec'] = DBRecord::countRecords( TBL_PREFIX.RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" );\r
+                       $programs[$st]['list'][$num]['rec'] = DBRecord::countRecords( $settings->tbl_prefix.RESERVE_TBL, "WHERE complete = '0' AND program_id = '".$prg['id']."'" );\r
                        $num++;\r
                }\r
        }\r
@@ -97,9 +109,9 @@ $last_time = $top_time + 3600 * $program_length;
        }\r
        // 空きを埋める\r
        if( $last_time - $prev_end ) {\r
-               $height = ($last_time - $prev_end) / 60;\r
+               $height = ($last_time - $prev_end) * $settings->height_per_hour / 3600;\r
                if( $height > 0.5 ) {\r
-                       $height = (int)($height * 2);\r
+                       $height = (int)$height;\r
                        $programs[$st]['list'][$num]['category_name'] = "none";\r
                        $programs[$st]['list'][$num]['height'] = $height;\r
                        $programs[$st]['list'][$num]['title'] = "";\r
@@ -113,7 +125,7 @@ $last_time = $top_time + 3600 * $program_length;
  $prec = null;\r
  \r
  // 局の幅\r
- $ch_set_width = 150;\r
+ $ch_set_width = $settings->ch_set_width;\r
  // 全体の幅\r
  $chs_width = $ch_set_width * count( $channel_map );\r
  \r
@@ -123,7 +135,7 @@ $last_time = $top_time + 3600 * $program_length;
  $smarty = new Smarty();\r
  \r
  // カテゴリ一覧\r
- $crec = DBRecord::createRecords( TBL_PREFIX . CATEGORY_TBL );\r
+ $crec = DBRecord::createRecords( $settings->tbl_prefix . CATEGORY_TBL );\r
  $cats = array();\r
  $num = 0;\r
  foreach( $crec as $val ) {\r
@@ -138,13 +150,13 @@ $last_time = $top_time + 3600 * $program_length;
  // タイプ選択\r
  $types = array();\r
  $i = 0;\r
- if( BS_TUNERS ) {\r
+ if( $settings->bs_tuners ) {\r
        $types[$i]['selected'] = $type == "BS" ? 'class="selected"' : "";\r
        $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=BS&length=".$program_length."&time=".date( "YmdH", $top_time);\r
        $types[$i]['name'] = "BS";\r
        $i++;\r
  }\r
- if( GR_TUNERS ) {\r
+ if( $settings->gr_tuers ) {\r
        $types[$i]['selected'] = $type == "GR" ? 'class="selected"' : "";\r
        $types[$i]['link'] = $_SERVER['SCRIPT_NAME'] . "?type=GR&length=".$program_length."&time=".date( "YmdH", $top_time);\r
        $types[$i]['name'] = "地上デジタル";\r
@@ -187,8 +199,9 @@ $last_time = $top_time + 3600 * $program_length;
  \r
  $smarty->assign( "tvtimes", $tvtimes );\r
  $smarty->assign( "programs", $programs );\r
- $smarty->assign( "ch_set_width", $ch_set_width );\r
+ $smarty->assign( "ch_set_width", $settings->ch_set_width );\r
  $smarty->assign( "chs_width", $chs_width );\r
+ $smarty->assign( "height_per_hour", $settings->height_per_hour );\r
 \r
 // date("Y-m-d H:i:s", $timestamp);\r
  \r
index bc62220..11b5538 100755 (executable)
@@ -326,7 +326,7 @@ h2 {padding: 4px}
 #tvtimes,#tvtimes2, .tvtimeDM {width:40px;}
 #tv_chs {padding-left:40px;padding-right:40px;}
 .tvtime {
-       height:120px;
+       height:{/literal}{$height_per_hour}{literal}px;
        color:#EEE;
        text-align:center;
        font-weight:bold;
@@ -336,7 +336,10 @@ h2 {padding: 4px}
        background-position: left bottom;
 }
 #tvtable div.tvtimetop {padding:8px 0px;}
-#tvtable div.ch_set {width:150px;float:left;background-color:#BBB;}
+
+#tvtable div.ch_set {width:{/literal}{$ch_set_width}{literal}px;float:left;background-color:#BBB;}
+
+
 #tvtable div.ch_title, #tvtable div.prg {margin-right:2px;}
 #tvtable div.ch_title {padding:8px 0px;background-color:#333;color:#DDD;font-weight:bold;text-align:center}
 #tvtable div.prg {
@@ -376,7 +379,7 @@ h2 {padding: 4px}
 #tvtable div.prg_hover  {background-color: #28D;color:#EFF}
 
 #float_titles { z-index:100}
-#float_titles div.ch_title {width:150px;float:left;color:#FFF;font-weight:bold;text-align:center}
+#float_titles div.ch_title {width:{/literal}{$ch_set_width}{literal}px;float:left;color:#FFF;font-weight:bold;text-align:center}
 #float_titles div.ch_title div{padding:8px 0px;margin:0 6px 0 4px;background-image: url(imgs/trancBG50.png);}
 
 #float_follows {position:absolute;}