]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/default/templates/userprefs.tmpl
optimized timezone popup code a bit
[SourceForge/phpwiki.git] / themes / default / templates / userprefs.tmpl
1 <?php // -*-html-*-
2 /**
3  * Variation of stdlib/TimezoneOffset, which is broken on my
4  * system. TimezoneOffset always returns my time zone irregarless what
5  * value is fed to it (TimezoneOffset(time()+$z*60*60) doesn't work...).
6  */
7 function hTimezoneOffset ($h, $use_colon = true) {
8     $secs = $h*60*60;
9     if ($secs < 0) {
10         $sign = '-';
11         $secs = -$secs;
12     }
13     else {
14         $sign = '+';
15     }
16     $colon = $use_colon ? ':' : '';
17     $mins = intval(($secs + 30) / 60);
18     return sprintf("%s%02d%s%02d",
19                    $sign, $mins / 60, $colon, $mins % 60);
20 }
21 // default to server's timezone if user's pref not chosen yet
22 if ($PreftimeOffset = $request->getPref('timeOffset'))
23     $defaultOffset = $PreftimeOffset;
24 else
25     $defaultOffset = TimezoneOffset(false, true);
26
27 // generate the popup menu
28 $select = HTML();
29 for ($z = -14; $z < 12; $z++) {
30     $tz_val = hTimezoneOffset($z, false);
31     $tz_string = sprintf("GMT %s", hTimezoneOffset($z));
32
33     $selected = $defaultOffset == $tz_val ? array('selected' => 'selected') : array();
34     $select->pushContent(HTML::option(array_merge(array('value' => $tz_val),
35                                                   $selected),
36                                       $tz_string));
37     $z = $z-0.5;
38 }
39 $TimeZoneSelect = HTML::select(array('name' => "pref[timeOffset]"), $select);
40
41 ?>
42 <!-- $Id: userprefs.tmpl,v 1.8 2002-02-02 23:18:40 carstenklapp Exp $ -->
43 <form action="<?=WikiURL($page)?>" method="post">
44   <input type="hidden" name="pagename" value="<?=$request->getArg('pagename')?>" />
45   <blockquote>
46   <table>
47     <tr>
48       <td colspan="2"><h2><?=_("Edit Area Size")?></h2></td>
49     </tr><tr>
50       <td align="right"><?=_("Height")?></td>
51       <td>
52         <input type="text" name="pref[editHeight]" size="4"
53                value="<?=$request->getPref('editHeight')?>" />
54       </td>
55     </tr>
56     <tr>
57       <td align="right"><?=_("Width")?></td>
58       <td>
59         <input type="text" name="pref[editWidth]" size="4"
60                value="<?=$request->getPref('editWidth')?>" />
61       </td>
62     </tr>
63
64     <tr>
65       <td colspan="2"><h2><?=_("Time Zone")?></h2></td>
66     </tr><tr>
67       <td align="right"><?=_("Server time:")?></td>
68       <td><?= Rfc2822DateTime() ?></td>
69     </tr><tr>
70       <td align="right"><?=_("Your time:")?></td>
71       <td>
72         <?= $TimeZoneSelect ?> (unimplemented)
73       </td>
74     </tr>
75   </table>
76   </blockquote>
77   <hr />
78   <?=Button("submit:", _("Update Preferences"))?>
79 </form>