-
Notifications
You must be signed in to change notification settings - Fork 5
/
programTable.php
183 lines (164 loc) · 5.41 KB
/
programTable.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
include_once('config.php');
include_once( INSTALL_PATH . '/DBRecord.class.php' );
include_once( INSTALL_PATH . '/Smarty/Smarty.class.php' );
include_once( INSTALL_PATH . '/Settings.class.php' );
include_once( INSTALL_PATH . '/Keyword.class.php' );
$settings = Settings::factory();
$options = " WHERE starttime > '".date("Y-m-d H:i:s", time() + 300 )."'";
// 曜日
$weekofdays = array(
array( "name" => "月", "id" => 0, "selected" => "" ),
array( "name" => "火", "id" => 1, "selected" => "" ),
array( "name" => "水", "id" => 2, "selected" => "" ),
array( "name" => "木", "id" => 3, "selected" => "" ),
array( "name" => "金", "id" => 4, "selected" => "" ),
array( "name" => "土", "id" => 5, "selected" => "" ),
array( "name" => "日", "id" => 6, "selected" => "" ),
array( "name" => "なし", "id" => 7, "selected" => "" ),
);
$autorec_modes = $RECORD_MODE;
$autorec_modes[(int)($settings->autorec_mode)]['selected'] = "selected";
$search = "";
$use_regexp = 0;
$type = "*";
$category_id = 0;
$channel_id = 0;
$weekofday = 7;
$prgtime = 24;
// パラメータの処理
if(isset( $_POST['do_search'] )) {
if( isset($_POST['search'])){
$search = $_POST['search'];
if( isset($_POST['use_regexp']) && ($_POST['use_regexp']) ) {
$use_regexp = (int)($_POST['use_regexp']);
}
}
if( isset($_POST['type'])){
$type = $_POST['type'];
}
if( isset($_POST['category_id'])) {
$category_id = (int)($_POST['category_id']);
}
if( isset($_POST['station'])) {
$channel_id = (int)($_POST['station']);
}
if( isset($_POST['weekofday']) ) {
$weekofday = (int)($_POST['weekofday']);
}
if( isset($_POST['prgtime']) ) {
$prgtime = (int)($_POST['prgtime']);
}
}
$do_keyword = 0;
if( ($search != "") || ($type != "*") || ($category_id != 0) || ($channel_id != 0) )
$do_keyword = 1;
try{
$precs = Keyword::search( $search, $use_regexp, $type, $category_id, $channel_id, $weekofday, $prgtime );
$programs = array();
foreach( $precs as $p ) {
$ch = new DBRecord(CHANNEL_TBL, "id", $p->channel_id );
$cat = new DBRecord(CATEGORY_TBL, "id", $p->category_id );
$arr = array();
$arr['type'] = $p->type;
$arr['station_name'] = $ch->name;
$arr['starttime'] = $p->starttime;
$arr['endtime'] = $p->endtime;
$arr['title'] = $p->title;
$arr['description'] = $p->description;
$arr['id'] = $p->id;
$arr['cat'] = $cat->name_en;
$arr['rec'] = DBRecord::countRecords(RESERVE_TBL, "WHERE program_id='".$p->id."'");
array_push( $programs, $arr );
}
$k_category_name = "";
$crecs = DBRecord::createRecords(CATEGORY_TBL);
$cats = array();
$cats[0]['id'] = 0;
$cats[0]['name'] = "すべて";
$cats[0]['selected'] = $category_id == 0 ? "selected" : "";
foreach( $crecs as $c ) {
$arr = array();
$arr['id'] = $c->id;
$arr['name'] = $c->name_jp;
$arr['selected'] = $c->id == $category_id ? "selected" : "";
if( $c->id == $category_id ) $k_category_name = $c->name_jp;
array_push( $cats, $arr );
}
$types = array();
$types[0]['name'] = "すべて";
$types[0]['value'] = "*";
$types[0]['selected'] = $type == "*" ? "selected" : "";
if( $settings->gr_tuners != 0 ) {
$arr = array();
$arr['name'] = "GR";
$arr['value'] = "GR";
$arr['selected'] = $type == "GR" ? "selected" : "";
array_push( $types, $arr );
}
if( $settings->bs_tuners != 0 ) {
$arr = array();
$arr['name'] = "BS";
$arr['value'] = "BS";
$arr['selected'] = $type == "BS" ? "selected" : "";
array_push( $types, $arr );
// CS
if ($settings->cs_rec_flg != 0) {
$arr = array();
$arr['name'] = "CS";
$arr['value'] = "CS";
$arr['selected'] = $type == "CS" ? "selected" : "";
array_push( $types, $arr );
}
}
$k_station_name = "";
$crecs = DBRecord::createRecords(CHANNEL_TBL);
$stations = array();
$stations[0]['id'] = 0;
$stations[0]['name'] = "すべて";
$stations[0]['selected'] = (! $channel_id) ? "selected" : "";
foreach( $crecs as $c ) {
$arr = array();
$arr['id'] = $c->id;
$arr['name'] = $c->name;
$arr['selected'] = $channel_id == $c->id ? "selected" : "";
if( $channel_id == $c->id ) $k_station_name = $c->name;
array_push( $stations, $arr );
}
$weekofdays["$weekofday"]["selected"] = "selected" ;
// 時間帯
$prgtimes = array();
for( $i=0; $i < 25; $i++ ) {
array_push( $prgtimes,
array( "name" => ( $i == 24 ? "なし" : sprintf("%0d時~",$i) ),
"value" => $i,
"selected" => ( $i == $prgtime ? "selected" : "" ) )
);
}
$smarty = new Smarty();
$smarty->assign("sitetitle","番組検索");
$smarty->assign("do_keyword", $do_keyword );
$smarty->assign( "programs", $programs );
$smarty->assign( "cats", $cats );
$smarty->assign( "k_category", $category_id );
$smarty->assign( "k_category_name", $k_category_name );
$smarty->assign( "types", $types );
$smarty->assign( "k_type", $type );
$smarty->assign( "search" , $search );
$smarty->assign( "use_regexp", $use_regexp );
$smarty->assign( "stations", $stations );
$smarty->assign( "k_station", $channel_id );
$smarty->assign( "k_station_name", $k_station_name );
$smarty->assign( "weekofday", $weekofday );
$smarty->assign( "k_weekofday", $weekofdays["$weekofday"]["name"] );
$smarty->assign( "weekofday", $weekofday );
$smarty->assign( "weekofdays", $weekofdays );
$smarty->assign( "autorec_modes", $autorec_modes );
$smarty->assign( "prgtimes", $prgtimes );
$smarty->assign( "prgtime", $prgtime );
$smarty->display("programTable.html");
}
catch( exception $e ) {
exit( $e->getMessage() );
}
?>