root/modules/branches/2.4/daynight/page.daynight.php

Revision 5762, 7.0 kB (checked in by p_lindheimer, 5 years ago)

#2604: fix mal-formed html select tags causing problems with some browsers or proxies

Line 
1 <?php
2 /* $Id: page.ivr.php 3790 2007-02-16 18:52:53Z p_lindheimer $ */
3 //Copyright (C) 2007 Atengo LLC (info@atengo.net)
4 //
5 //This program is free software; you can redistribute it and/or
6 //modify it under the terms of the GNU General Public License
7 //as published by the Free Software Foundation; either version 2
8 //of the License, or (at your option) any later version.
9 //
10 //This program is distributed in the hope that it will be useful,
11 //but WITHOUT ANY WARRANTY; without even the implied warranty of
12 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 //GNU General Public License for more details.
14
15 $dispnum = "daynight"; //used for switch on config.php
16
17 $action = isset($_REQUEST['action'])?$_REQUEST['action']:'';
18 $password = isset($_REQUEST['password'])?$_REQUEST['password']:'';
19 $fc_description = isset($_REQUEST['fc_description'])?$_REQUEST['fc_description']:'';
20
21 isset($_REQUEST['itemid'])?$itemid=mysql_real_escape_string($_REQUEST['itemid']):$itemid='';
22
23
24 $fcc = new featurecode('daynight', 'toggle-mode');
25 $fc = $fcc->getCodeActive();
26 unset($fcc);
27
28 $daynightcodes = daynight_list();
29 ?>
30
31 </div> <!-- end content div so we can display rnav properly-->
32
33 <!-- right side menu -->
34 <div class="rnav"><ul>
35     <li><a id="<?php echo ($itemid=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>&action=add"><?php echo _("Add Day/Night Code")?></a></li>
36 <?php
37 if (isset($daynightcodes)) {
38     foreach ($daynightcodes as $code) {
39         $dnobj = daynight_get_obj($code['ext']);
40         $color = $dnobj['state'] == 'DAY' ? "style='color:green'" : "style='color:red'";
41         echo "<li><a $color id=\"".($itemid==$code['ext'] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&itemid=".urlencode($code['ext'])."&action=edit\">($fc{$code['ext']}) {$code['dest']}</a></li>";
42     }
43 }
44 ?>
45 </ul></div>
46 <?php
47
48 switch ($action) {
49     case "add":
50         daynight_show_edit($_POST,'add');
51         break;
52     case "edit":
53         daynight_show_edit($_POST);
54         break;
55     case "edited":
56             daynight_edit($_POST,$itemid);
57             redirect_standard('itemid');
58             break;
59     case "delete":
60             daynight_del($itemid);
61             redirect_standard();
62             break;
63     default:
64         daynight_show_edit($_POST,'add');
65         break;
66 }
67
68 function daynight_show_edit($post, $add="") {
69     global $db;
70     global $itemid;
71
72     $fcc = new featurecode('daynight', 'toggle-mode');
73     $code = $fcc->getCodeActive().$itemid;
74     unset($fcc);
75
76     $dests = daynight_get_obj($itemid);
77     $password = isset($dests['password'])?$dests['password']:'';
78     $fc_description = isset($dests['fc_description'])?$dests['fc_description']:'';
79     $state = isset($dests['state'])?$dests['state']:'DAY';
80 ?>
81     <div class="content">
82     <h2><?php echo _("Day / Night Mode Control"); ?></h2>
83
84 <?php
85     $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=delete';
86 ?>
87 <?php        if ($itemid != ""){ ?>
88     <a href="<?php echo $delURL ?>"><?php echo _("Delete Day/Night Feature Code:")?> <?php echo $code; ?></a><br />
89 <?php
90                     $usage_list = framework_display_destination_usage(daynight_getdest($itemid));
91                     if (!empty($usage_list)) {
92 ?>
93                         <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
94 <?php
95                     }
96 ?>
97 <?php        } ?>
98
99     <form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return prompt_onsubmit();">
100     <input type="hidden" name="action" value="edited" />
101     <input type="hidden" name="display" value="daynight" />
102     <input name="Submit" type="submit" style="display:none;" value="save" />
103     <table>
104     <tr>
105         <td colspan=2><hr />
106         </td>
107     </tr>
108     <tr>
109         <td colspan="2">   
110         <input name="Submit" type="submit" value="<?php echo _("Save")?>">
111         <?php if ($itemid != '') echo "&nbsp ".sprintf(_("Use feature code: %s to toggle DAY/NIGHT mode"),"<strong>".$code."</strong>")?>
112         </td>
113     </tr>
114     <tr>
115         <td colspan=2>
116         <hr />
117         </td>
118     </tr>
119     <tr>
120         <td><a href="#" class="info"><?php echo _("Day/Night Feature Code Index:")?>
121         <span><?php echo _("There are a total of 10 Feature code objects, 0-9, each can control a call flow and be toggled using the day/night feature code plus the index.")?>
122         </span></a>
123         </td>
124         <td>
125 <?php
126             if ($add == "add" && $itemid =="") {
127 ?>
128             <select name="itemid">
129             <?php
130                 $ids = daynight_get_avail();
131                 foreach ($ids as $id) {
132                     echo '<option value="'.$id.'" >'.$id.'</option>';
133                 }
134             ?>
135             </select>
136 <?php
137             } else {
138 ?>
139         <input readonly="yes" size="1" type="text" name="itemid" value="<?php  echo $itemid ?>">
140 <?php
141         }
142 ?>
143         </td>
144     </tr>
145     <tr>
146         <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("Description for this Day/Night Control")?></span></a></td>
147         <td><input size="40" type="text" name="fc_description" value="<?php  echo $fc_description ?>">
148         </td>
149     </tr>
150     <tr>
151         <td><a href="#" class="info"><?php echo _("Current Mode:")?>
152         <span><?php echo _("This will change the current state for this Day/Night Mode Control, or set the intial state when creating a new one.")?>
153         </span></a>
154         </td>
155         <td>
156             <select name="state">
157                 <option value="DAY" <?php echo ($state == 'DAY' ? 'SELECTED':'') ?> >Day</option>
158                 <option value="NIGHT" <?php echo ($state == 'NIGHT' ? 'SELECTED':'') ?> >Night</option>
159             </select>
160         </td>
161     </tr>
162     <tr>
163         <td><a href="#" class="info"><?php echo _("Optional Password")?>:<span><?php echo _('You can optionally include a password to authenticate before toggling the day/night mode. If left blank anyone can use the feature code will be un-protected')?></span></a></td>
164         <td><input size="12" type="text" name="password" value="<?php  echo $password ?>">
165         </td>
166     </tr>
167     <tr>
168         <td colspan=2>
169         <hr />
170         </td>
171     </tr>
172 <?php
173     // Draw the destinations
174     // returns an array, $dest['day'], $dest['night']
175     // and puts null if nothing set
176
177     drawdestinations(0, _("DAY"),   isset($dests['day'])?$dests['day']:'');
178     drawdestinations(1, _("NIGHT"), isset($dests['night'])?$dests['night']:'');
179
180     //TODO: Check to make sure a destination radio button was checked, and if custom, that it was not blank
181     //
182 ?>
183     <tr>
184         <td colspan=2>   
185         <input name="Submit" type="submit" value="<?php echo _("Save")?>">
186         <?php if ($itemid != '') echo "&nbsp ".sprintf(_("Use feature code: %s to toggle DAY/NIGHT mode"),"<strong>".$code."</strong>")?>
187         </td>
188     </tr>
189     <tr>
190         <td colspan=2>
191         <hr />
192         </td>
193     </tr>
194     </table>
195
196     <script language="javascript">
197     <!--
198     var theForm = document.prompt;
199
200     function prompt_onsubmit() {
201         var msgInvalidPassword = "<?php echo _('Please enter a valid numeric password, only numbers are allowed'); ?>";
202
203         defaultEmptyOK = true;
204         if (!isInteger(theForm.password.value))
205             return warnInvalid(theForm.password, msgInvalidPassword);
206         return true;
207     }
208     //-->
209     </script>
210
211     </form>
212     </div>
213 <?php
214 } //daynight function
215
216
217 // count is for the unique identifier
218 // dest is the target
219 //
220 function drawdestinations($count, $mode, $dest) { ?>
221     <tr>
222         <td style="text-align:right;">
223         <a href="#" class="info"><strong><?php echo _("$mode")?></strong><span><?php echo _("Destination to use when set to $mode mode")?></span></a>
224         </td>
225         <td>
226             <table> <?php echo drawselects($dest,$count); ?>
227             </table>
228         </td>
229     </tr>
230     <tr><td colspan=2><hr /></td></tr>
231 <?php
232 }
233 ?>
234
Note: See TracBrowser for help on using the browser.