]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/default/templates/userprefs.tmpl
WikiGroup refactoring:
[SourceForge/phpwiki.git] / themes / default / templates / userprefs.tmpl
1 <?php // -*-html-*- ?>
2 <!-- $Id: userprefs.tmpl,v 1.55 2004-06-25 14:29:22 rurban Exp $ -->
3 <?php
4 // Todo: Move the logic and code to the plugin
5 // This is very experimental and the read-only part an ugly hack so far.
6 foreach (explode(',','errmsg,isForm') as $var) {
7     if (empty($$var)) $$var = false;
8 }
9
10 $plugin = $request->getArg('pagename');
11 if ($request->isActionPage($request->getArg('pagename')) and 
12     $plugin != _("PreferencesInfo") and $plugin != _("_PreferencesInfo")) {
13     $isForm = true;
14 }
15
16 $time = time();
17 $user = &$request->getUser();
18 $pref = &$request->_prefs;
19
20 $offset = $pref->get('timeOffset');
21 $serverTime = $time - $offset * 3600;
22 if ( $isForm )
23     $timeOffsetInput = HTML::input(array('type' => "text",
24                                          'size' => 6,
25                                          'maxlength' => 6,
26                                          'name' => "pref[timeOffset]",
27                                          'class' => "numeric",
28                                          'value' => $offset));
29 else
30     $timeOffsetInput = $pref->get('timeOffset');
31
32 $RelativeDatesCB = HTML::input(array('type' => 'checkbox',
33                                      'name' => 'pref[relativeDates]',
34                                      'value' => '1',
35                                      'checked' => (bool) $pref->get('relativeDates')));
36 $NoLinkIconsCB = HTML::input(array('type' => 'checkbox',
37                                    'name' => 'pref[noLinkIcons]',
38                                    'value' => '1',
39                                    'checked' => (bool) $pref->get('noLinkIcons')));
40 $GoogleLinkCB = HTML::input(array('type' => 'checkbox',
41                                   'name' => 'pref[googleLink]',
42                                   'value' => '1',
43                                   'checked' => (bool) $pref->get('googleLink')));
44 if (!function_exists('selectedOption')) {
45   function selectedOption ($value, $label = false) {
46     return HTML::option(array('value' => $value,'selected'=>"selected"), ($label ? $label : $value) . "\n");
47   }
48   function unselectedOption ($value, $label = false) {
49     return HTML::option(array('value' => $value), ($label ? $label : $value) . "\n");
50   }
51 }
52
53 $SelectThemes = ''; $SelectLanguages = '';
54 $SelectThemesDesc = ''; $SelectLanguagesDesc = '';
55 if ( $isForm ) {
56     $SelectOptions = HTML(); 
57     if (!empty($available_themes) and is_array($available_themes)) {
58         if (!$pref->get('theme') or $pref->get('theme') == THEME)
59             $SelectOptions->pushContent(selectedOption("",_("<system theme>")));
60         else
61             $SelectOptions->pushContent(unselectedOption("",_("<system theme>")));
62         foreach ($available_themes as $theme) {
63             if ($theme == $pref->get('theme') and $theme != THEME)
64                 $SelectOptions->pushContent(selectedOption($theme));
65             else
66                 $SelectOptions->pushContent(unselectedOption($theme));
67         }
68         $SelectThemes = HTML::select(array('name' => "pref[theme]",'id' => 'theme'),
69                                      $SelectOptions);
70         $SelectThemesDesc = _("Personal theme:");
71     }
72     
73     $SelectOptions = HTML();
74     if (!empty($available_languages) and is_array($available_languages)) {
75         if (!$pref->get('lang') or $pref->get('lang') == DEFAULT_LANGUAGE)
76             $SelectOptions->pushContent(selectedOption("",_("<system language>")));
77         else
78             $SelectOptions->pushContent(unselectedOption("",_("<system language>")));
79         foreach ($available_languages as $lang) {
80             if ($lang == $pref->get('lang') and $lang != DEFAULT_LANGUAGE)
81                 $SelectOptions->pushContent(selectedOption($lang));
82             else
83                 $SelectOptions->pushContent(unselectedOption($lang));
84         }
85         $SelectLanguages = HTML::select(array('name' => "pref[lang]",'id' => 'lang'),
86                                         $SelectOptions);
87         $SelectLanguagesDesc = _("Personal language:");
88     } else {
89         if ($SelectThemes == '') {
90             $appearance = false;
91             $SelectThemesDesc = '';
92             $SelectLanguagesDesc = '';
93         }
94     }
95 } else {
96     $SelectThemesDesc = _("Personal theme:");
97     $SelectLanguagesDesc = _("Personal language:");
98     $SelectThemes = $pref->get('theme');
99     $SelectLanguages = $pref->get('lang');
100 }
101
102 if ($errmsg) $msg = HTML(HTML::h4(array('class' => 'errors'), $errmsg),HTML::hr());
103 ?>
104 <?= $errmsg ?>
105
106 <?= fmt("User preferences for user '%s':", $user->UserName()) ?>
107
108 <?php if ($isForm) { ?>
109 <form action="<?=$request->getPostURL()?>" method="post">
110 <?php } else { 
111   $user = $request->_user; 
112   $fill = "&nbsp;";
113   // See also plugin _AuthInfo
114 ?>
115 <?= HTML::pre(sprintf("%12s: [% 10s]  %s\n",_("UserId"),$pref->get('userid'), " from " . (ENABLE_USER_NEW ? $request->_user->_authmethod : $request->_user->auth_how)),
116               sprintf("%12s: [% 10s]  %16s: [% 10s] | %8s: [%2s]\n","getId",$user->getId(),"getAuthenticatedId",$user->getAuthenticatedId(),"isSignedIn", $user->isSignedIn()),
117               //sprintf("%12s: [% 10s]\n",_("Password"),empty($pref->get('passwd')) ? _("<empty>") : _("<not empty>")),
118               sprintf("%12s: [% 10s]  %15s: [% 8s]\n",
119                       _("Auth Level"),$user->_level,_("Auth Method"),$user->_authmethod),
120               sprintf("%12s: [% 10s]\n",_("HomePage"),$user->hasHomePage() ? (ENABLE_USER_NEW ? $user->_HomePagehandle->_pagename : $user->_homepage->_pagename ) : ''),
121               sprintf("%12s: [% 10s]\n",_("E-Mail"),$pref->get('email')),
122               //sprintf("%12s: [% 10s]\n",_("Notify"),$pref->get('notifyPages')),
123               sprintf("%12s: [% 10s] %16s: [% 10s] \n",_("Theme"), $pref->get('theme'), _("Current Theme"),$WikiTheme->_name),
124               sprintf("%12s: [% 10s] %16s: [% 10s] \n",_("Language"),$pref->get('lang'),_("Current Language"),$GLOBALS['LANG'])
125               ) ?>
126 <?php } ?>
127
128 <table border="0">
129 <?php if ($isForm and $user->mayChangePass()) { ?>
130   <tr><td colspan="3"><h2><?= ($request->getPref('passwd') ?  _("Change Password") :  _("Set Password")) ?></h2></td></tr>
131
132     <tr><td align="right"><?=_("New password")?>:</td>
133         <td><input type="password" name="pref[passwd]" size="16" maxlength="16" class="text" value="" /></td>
134         <td></td></tr>
135     <tr><td align="right"><?=_("Type it again")?>:</td>
136         <td><input type="password" name="pref[passwd2]" size="16" maxlength="16" class="text" value="" /></td>
137         <td></td></tr>
138 <?php } ?>
139
140 <?php if (ENABLE_USER_NEW) { ?>
141   <tr><td colspan="3"><h2><?=_("E-mail")?></h2></td></tr>
142
143   <tr><td><?=_("Your E-Mail:")?></td>
144   <td>
145   <?php if ($isForm) { ?>
146      <input type="text" name="pref[email]" size="30" maxlength="60"
147             value="<?=$pref->get('email')?>" />
148   <?php } else { ?>
149      '<?= $pref->get('email') ?>'
150   <?php } ?>
151   &nbsp;&nbsp;<?= _("Status:") ?>&nbsp;&nbsp;
152   <?php if ($pref->get('emailVerified')) { ?>
153     <?= _("Email verified.") ?>
154   <?php } else { ?>
155     <?= _("Email not yet verified.") ?>
156   <?php } ?>
157   </td><td><p class="hint"><?=_("Note, that user accounts with bouncing emails will be disabled.")?></p></td></tr>
158
159    <tr><td colspan="2">
160     <?=_("Get an email notification at changes of the following pages:")?><br />
161     <?php if ($isForm) { ?>
162       <blockquote><textarea name="pref[notifyPages]" cols="50" rows="4"><?=$pref->get('notifyPages')?></textarea></blockquote></td>
163     <td><p class="hint"><?=_("Enter pages seperated by space or comma. Wildcards (fileglobbing) allowed.")?></p></td>
164     <?php } else { ?>
165      <td><?=$pref->get('notifyPages')?></td><td></td>
166     <?php } ?>
167    </tr>
168 <?php } ?>
169
170   <tr><td colspan="3"><h2><?=_("Appearance")?></h2></td></tr>
171
172   <tr><td colspan="2"><?=_("Here you can override site-specific default values.") ?></td>
173       <td><span class="hint"><?= _("Currently not recommended!") ?></span></td></tr>
174   <?php /* Alternatively this could be done with <fieldset> and <legend>. */ ?>
175       <tr><td align="right"><?=$SelectThemesDesc?></td>
176           <td><?= $SelectThemes ?></td>
177           <td><span class="hint"><?=_("System default:")?> <?= THEME ?></span></td></tr>
178       <tr><td align="right"><?=$SelectLanguagesDesc?></td>
179           <td><?= $SelectLanguages ?></td>
180           <td><span class="hint"><?=_("System default:")?> <?= DEFAULT_LANGUAGE ?></span></td></tr>
181       <tr><td align="right"><?=fmt("Hide %s:", WikiLink("LinkIcons"))?></td>
182           <td><?=$NoLinkIconsCB?></td>
183           <td><p class="hint"><?=_("Hide or show LinkIcons (if supported by the current theme). Useful for text-only browsers or slow connections.")?></p></td></tr>
184       <tr><td align="right"><?=fmt("Add %s:", WikiLink("GoogleLink"))?></td>
185           <td><?=$GoogleLinkCB?></td>
186           <td><p class="hint"><?=fmt("Add Google links to unknown pages behind the '?', and the create action behind the pagename instead. See %s.",WikiLink("MeatBall:GooglePrompt"))?></p></td></tr>
187
188
189   <tr><td colspan="3"><h2><?=_("Edit Area Size")?></h2></td></tr>
190
191   <tr><td colspan="2">
192     <?=_("Height")?>:&nbsp;
193     <?php if ($isForm) { ?>
194      <input type="text" name="pref[editHeight]" size="4" maxlength="4" class="numeric"
195             value="<?=$pref->get('editHeight')?>" />
196     <?php } else { ?>
197       <?=$pref->get('editHeight')?>
198     <?php } ?>
199     &nbsp;&nbsp;<?=_("Width")?>:&nbsp;
200     <?php if ($isForm) { ?>
201      <input type="text" name="pref[editWidth]" size="4" maxlength="4" class="numeric"
202             value="<?=$pref->get('editWidth')?>" />
203     <?php } else { ?>
204       <?=$pref->get('editWidth')?>
205     <?php } ?>
206     </td>
207     <td><p class="hint">
208       <?=_("Note that many browsers will automatically adjust the width of the editing area so that it fills the browser window.  In this case, the width preference will be ignored.")?></p>
209     </td></tr>
210
211   <tr><td colspan="3"><h2><?=_("Time Zone")?></h2></td></tr>
212
213   <tr><td colspan="2"><p>
214     <?=fmt("Add %s hours to the server's local time when reporting times.",
215            $timeOffsetInput)?>
216   </p></td><td>
217   <p class="hint">
218     <?=fmt("The current time at the server is %s.",
219             HTML::strong($WikiTheme->formatDateTime($serverTime)))?>
220     <?=fmt("With the current offset, this would be reported as %s.",
221            HTML::strong($WikiTheme->formatDateTime($time)))?>
222   </p>
223   </td></tr>
224
225   <tr><td colspan="3"><h2><?=_("Date Format")?></h2></td></tr>
226
227   <tr><td colspan="2"><p>
228     <?=_("Show relative dates using 'Today' and 'Yesterday'")?>:
229     <?= $RelativeDatesCB ?>
230   </p></td><td></td></tr>
231 </table>
232
233 <?php if ($isForm) { ?>
234   <hr />
235   <p><?=Button("submit:", _("Update Preferences"), 'wikiadmin')?>
236   <?=Button("submit:delete", _("Remove Preferences"), 'wikiadmin')?>
237   <?=Button("submit:cancel", _("Cancel"), 'button')?></p>
238
239 <?= HiddenInputs($request->getArgs(), false, array('pref')) ?>
240 </form>
241 <?php } ?>