6 require "channels.php";
14 // connect to main database
16 switch( $dconf['dbtype'] ){
18 $myc = sql_doconnect();
26 <title
>Channel details
</title
>
27 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
28 <link href
="css/nonametv.css" rel
=stylesheet
>
29 <script language
="JavaScript1.2" src
="js/common.js"></script
>
31 <body bgcolor
="#FFFFFF" text
="#000000">
35 function channelform( $ch )
41 print "<h1>Edit channel details: " . $ch['id'] . "</h1>\n";
42 print "<form name=channel action=\"editchannel.php\" method=post>\n";
48 print " <input type=\"hidden\" name=\"id\" value=\"" . $ch['id'] . "\">\n";
53 print " <tr class=\"tableTitle\">\n";
54 print " <td colspan=\"2\">General channel settings</td>\n";
58 print " <td class=\"tableBody\">\n";
59 print " <div align=\"right\">ID</div>\n";
61 print " <td class=\"tableBody\">";
70 print "<input type=\"text\" name=\"id\" value=\"" . $ch['id'] . "\" size=\"12\" maxlength=\"12\">\n";
76 print " <td class=\"tableBody\">\n";
77 print " <div align=\"right\">Display Name</div>\n";
79 print " <td class=\"tableBody\">\n";
80 print " <input type=\"text\" name=\"display_name\" value=\"" . $ch['display_name'] . "\" size=\"100\" maxlength=\"100\">\n";
85 print " <td class=\"tableBody\">\n";
86 print " <div align=\"right\">XMLTV ID</div>\n";
88 print " <td class=\"tableBody\">\n";
89 print " <input type=\"text\" name=\"xmltvid\" value=\"" . $ch['xmltvid'] . "\" size=\"100\" maxlength=\"100\">\n";
94 print " <td class=\"tableBody\">\n";
95 print " <div align=\"right\">Channel group</div>\n";
97 print " <td class=\"tableBody\">\n";
98 print " <select name=\"chgroup\">\n";
100 while( list( $gk , $gv ) = each($chgdb) ){
101 print " <option value=\"" . $gv['abr'] . "\">" . $gv['display_name'] . "</option>\n";
103 print " </select>\n";
107 print " <tr class=\"tableTitle\">\n";
108 print " <td colspan=\"2\">Importer settings</td>\n";
112 print " <td class=\"tableBody\">\n";
113 print " <div align=\"right\">Grabber</div>\n";
115 print " <td class=\"tableBody\">\n";
116 print " <input type=\"text\" name=\"grabber\" value=\"" . $ch['grabber'] . "\" size=\"100\" maxlength=\"100\">\n";
121 print " <td class=\"tableBody\">\n";
122 print " <div align=\"right\">Grabber Info</div>\n";
124 print " <td class=\"tableBody\">\n";
125 print " <input type=\"text\" name=\"grabber_info\" value=\"" . $ch['grabber_info'] . "\" size=\"100\" maxlength=\"100\">\n";
129 print " <tr class=\"tableTitle\">\n";
130 print " <td colspan=\"2\">Exporter settings</td>\n";
134 print " <td class=\"tableBody\">\n";
135 print " <div align=\"right\">Export</div>\n";
137 print " <td class=\"tableBody\">\n";
138 print " <input type=\"checkbox\" name=\"export\" value=\"1\"" ;
139 if( $ch['export'] == '1' ) print " checked";
140 print "> check if you want to export this channel\n";
145 print " <td class=\"tableBody\">\n";
146 print " <div align=\"right\">Logo</div>\n";
148 print " <td class=\"tableBody\">\n";
149 print " <input type=\"checkbox\" name=\"logo\" value=\"1\"" ;
150 if( $ch['logo'] == '1' ) print " checked";
151 print "> check if you have logo available for this channel<br>\n";
155 print " <tr class=\"tableTitle\">\n";
156 print " <td colspan=\"2\">Additional settings</td>\n";
160 print " <td class=\"tableBody\">\n";
161 print " <div align=\"right\">Default Program Type</div>\n";
163 print " <td class=\"tableBody\">\n";
164 print " <input type=\"text\" name=\"def_pty\" value=\"" . $ch['def_pty'] . "\" size=\"100\" maxlength=\"100\">\n";
169 print " <td class=\"tableBody\">\n";
170 print " <div align=\"right\">Default Category</div>\n";
172 print " <td class=\"tableBody\">\n";
173 print " <input type=\"text\" name=\"def_cat\" value=\"" . $ch['def_cat'] . "\" size=\"100\" maxlength=\"100\">\n";
178 print " <td class=\"tableBody\">\n";
179 print " <div align=\"right\">Language used for schedules</div>\n";
181 print " <td class=\"tableBody\">\n";
182 print " <input type=\"text\" name=\"sched_lang\" value=\"" . $ch['sched_lang'] . "\" size=\"100\" maxlength=\"100\">\n";
187 print " <td class=\"tableBody\">\n";
188 print " <div align=\"right\">OK if empty</div>\n";
190 print " <td class=\"tableBody\">\n";
191 print " <input type=\"checkbox\" name=\"empty_ok\" value=\"1\"" ;
192 if( $ch['empty_ok'] == '1' ) print " checked";
193 print "> check if it is ok to have no data for this channel<br>\n";
198 print " <td class=\"tableBody\">\n";
199 print " <div align=\"right\">Channel url</div>\n";
201 print " <td class=\"tableBody\">\n";
202 print " <input type=\"text\" name=\"url\" value=\"" . $ch['url'] . "\" size=\"100\" maxlength=\"100\">\n";
208 if( $action == 'new' ){
209 print " <input type=\"submit\" value=\"Add\" class=\"gumb\" name=\"Add\">\n";
211 if( $action == 'none' ){
212 print " <input type=\"submit\" value=\"Update\" class=\"gumb\" name=\"Update\">\n";
213 print " <input type=\"submit\" value=\"Delete\" class=\"gumb\" name=\"Delete\">\n";
215 print " <input type=\"button\" value=\"Cancel\" class=\"gumb\" onClick=\"javascript:window.history.back()\">\n";
218 print "<script language=javascript>\n";
219 print " setCtrlValue( window.document.channel.chgroup , \"" . $ch['chgroup'] . "\" );\n";
227 // arguments from the command line/url
228 if( $debug ) dbg( "REQUEST" , $_REQUEST );
229 if( isset($_REQUEST['action']) ) $action = $_REQUEST['action'];
230 if( isset($_REQUEST['channel']) ) $channelarg = $_REQUEST['channel'];
233 if( $debug ) dbg( "_POST" , $_POST );
235 if(isset($_POST['id'])) $channelpost['id'] = $_POST['id'];
236 if(isset($_POST['display_name'])) $channelpost['display_name'] = $_POST['display_name'];
237 if(isset($_POST['xmltvid'])) $channelpost['xmltvid'] = $_POST['xmltvid'];
238 if(isset($_POST['chgroup'])) $channelpost['chgroup'] = $_POST['chgroup'];
239 if(isset($_POST['grabber'])) $channelpost['grabber'] = $_POST['grabber'];
240 if(isset($_POST['export'])) $channelpost['export'] = $_POST['export'];
241 if(isset($_POST['grabber_info'])) $channelpost['grabber_info'] = $_POST['grabber_info'];
242 if(isset($_POST['logo'])) $channelpost['logo'] = $_POST['logo'];
243 if(isset($_POST['def_pty'])) $channelpost['def_pty'] = $_POST['def_pty'];
244 if(isset($_POST['def_cat'])) $channelpost['def_cat'] = $_POST['def_cat'];
245 if(isset($_POST['sched_lang'])) $channelpost['sched_lang'] = $_POST['sched_lang'];
246 if(isset($_POST['empty_ok'])) $channelpost['empty_ok'] = $_POST['empty_ok'];
247 if(isset($_POST['url'])) $channelpost['url'] = $_POST['url'];
249 if( $debug ) dbg( "channelpost" , $channelpost );
251 // set default values if not set
252 if( isset($channelpost) ) $channelpost = set_channel_defaults( $channelpost );
254 // convert to lowercase
255 if( $dconf['lowercase'] && isset($channelpost) ){
256 $channelpost['xmltvid'] = strtolower( $channelpost['xmltvid'] );
262 if( isset($_POST['Add']) && $_POST['Add'] == 'Add' ) $action = 'add';
263 if( isset($_POST['Update']) && $_POST['Update'] == 'Update' ) $action = 'update';
264 if( isset($_POST['Delete']) && $_POST['Delete'] == 'Delete' ) $action = 'delete';
267 // check if there is already a channel with this name
269 if( $action != 'new' ){
270 switch( $dconf['dbtype'] ){
273 // first try to find from posted data
274 if( !$found && isset($channelpost['id']) ) $found = sql_findChannel( $myc , 'id' , $channelpost['id'] );
275 if( $debug && $found ){
276 dbg( "sql: found from posted data" , $found );
279 // if !found with posted data
280 // try to find with data from arguments
281 if( !$found && $channelarg ) $found = sql_findChannel( $myc , 'id' , $channelarg );
282 if( $debug && $found ){
283 dbg( "sql: found from arguments" , $found );
293 if( $found == false ){
295 case 'none': // if action==none -> this is edit, so it must be found
296 print ("<h3>Invalid channel: " . $channelarg . " </h3>\n");
298 case 'new': // if action==new -> we need blank form for new channel
299 if( $channelarg ) $channel['id'] = $channelarg; else $channel['id'] = '';
300 $channel = set_channel_defaults( $channel );
303 //dbg($action,"...");
307 else $channel = $found;
309 // remember current dhcp group
310 // on delete or update channel should be removed from old group
311 //$channel[olddhcpgroup] = $channel[dhcpgroup];
316 $chgdb = load_channelgroups( $myc );
317 channelform( $channel );
320 if( $found && !strcasecmp($found['id'],$channelpost['id'] )){
321 print "<h1>Channel with ID " . $channelpost['id'] . " exists</h1>\n";
322 reloadUrl('Continue','channelslist.php');
323 print "<script language=\"javascript\">\n";
324 print " url = 'showchannel.php?name=" . $found[name
] . "';\n";
325 print " openDialog( url , 'showchannel' , 'width=300,height=300,resizable=yes,scrollbars=yes,status=yes' );\n";
329 switch( $dconf['dbtype'] ){
331 sql_addChannel( $myc , $channelpost );
335 print "<h1>Channel " . $channelpost['id'] . " added</h1>\n";
336 reloadUrl('Continue','channelslist.php');
337 addlog(true,"Channel " . $channelpost['id'] . " added" );
340 switch( $dconf['dbtype'] ){
342 sql_updateChannel( $myc , $channelpost );
346 print "<h1>Channel " . $channelpost['id'] . " updated</h1>\n";
347 reloadUrl('Continue','channelslist.php');
348 addlog(true,"Channel " . $channelpost['id'] . " updated" );
351 switch( $dconf['dbtype'] ){
353 sql_deleteChannel( $myc , $channelpost );
356 print "<h1>Channel " . $channelpost['id'] . " deleted</h1>\n";
357 reloadUrl('Continue','channelslist.php');
358 addlog(true,"Channel " . $channelpost['id'] . " deleted" );
363 // disconnect from main database
365 switch( $dconf['dbtype'] ){
367 sql_dodisconnect( $myc );