]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - themes/gforge/templates/userprefs.tmpl
Fix syntax error
[SourceForge/phpwiki.git] / themes / gforge / templates / userprefs.tmpl
1 <?php // -*-html-*- ?>
2 <!-- $Id$ -->
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')) 
12     and $isForm and $plugin == _("PreferencesInfo")) {
13     $isForm = false;
14 }
15 $time = time();
16 $user =& $request->getUser();
17 $pref =& $request->_prefs;
18
19 if (!$pref) return;
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 $OwnModificationsCB = HTML::input(array('type' => 'checkbox',
33                                      'name' => 'pref[ownModifications]',
34                                      'value' => '1',
35                                      'checked' => (bool) $pref->get('ownModifications')));
36 $MajorModificationsOnlyCB = HTML::input(array('type' => 'checkbox',
37                                      'name' => 'pref[majorModificationsOnly]',
38                                      'value' => '1',
39                                      'checked' => (bool) $pref->get('majorModificationsOnly')));
40 $DiffMenuItem = HTML::input(array('type' => 'checkbox',
41                                      'name' => 'pref[diffMenuItem]',
42                                      'value' => '1',
43                                      'checked' => (bool) $pref->get('diffMenuItem')));
44 $PageInfoMenuItem = HTML::input(array('type' => 'checkbox',
45                                      'name' => 'pref[pageInfoMenuItem]',
46                                      'value' => '1',
47                                      'checked' => (bool) $pref->get('pageInfoMenuItem')));
48 $PDFMenuItem = HTML::input(array('type' => 'checkbox',
49                                      'name' => 'pref[pdfMenuItem]',
50                                      'value' => '1',
51                                      'checked' => (bool) $pref->get('pdfMenuItem')));
52 $ChownMenuItem = HTML::input(array('type' => 'checkbox',
53                                      'name' => 'pref[chownMenuItem]',
54                                      'value' => '1',
55                                      'checked' => (bool) $pref->get('chownMenuItem')));
56 $SetaclMenuItem = HTML::input(array('type' => 'checkbox',
57                                      'name' => 'pref[setaclMenuItem]',
58                                      'value' => '1',
59                                      'checked' => (bool) $pref->get('setaclMenuItem')));
60 $RemoveMenuItem = HTML::input(array('type' => 'checkbox',
61                                      'name' => 'pref[removeMenuItem]',
62                                      'value' => '1',
63                                      'checked' => (bool) $pref->get('removeMenuItem')));
64 $RenameMenuItem = HTML::input(array('type' => 'checkbox',
65                                      'name' => 'pref[renameMenuItem]',
66                                      'value' => '1',
67                                      'checked' => (bool) $pref->get('renameMenuItem')));
68 $RevertMenuItem = HTML::input(array('type' => 'checkbox',
69                                      'name' => 'pref[revertMenuItem]',
70                                      'value' => '1',
71                                      'checked' => (bool) $pref->get('revertMenuItem')));
72 $LockMenuItem = HTML::input(array('type' => 'checkbox',
73                                      'name' => 'pref[lockMenuItem]',
74                                      'value' => '1',
75                                      'checked' => (bool) $pref->get('lockMenuItem')));
76 $BackLinksMenuItem = HTML::input(array('type' => 'checkbox',
77                                      'name' => 'pref[backLinksMenuItem]',
78                                      'value' => '1',
79                                      'checked' => (bool) $pref->get('backLinksMenuItem')));
80 $WatchPageMenuItem = HTML::input(array('type' => 'checkbox',
81                                      'name' => 'pref[watchPageMenuItem]',
82                                      'value' => '1',
83                                      'checked' => (bool) $pref->get('watchPageMenuItem')));
84 $RecentChangesMenuItem = HTML::input(array('type' => 'checkbox',
85                                      'name' => 'pref[recentChangesMenuItem]',
86                                      'value' => '1',
87                                      'checked' => (bool) $pref->get('recentChangesMenuItem')));
88 $SearchMenuItem = HTML::input(array('type' => 'checkbox',
89                                      'name' => 'pref[searchMenuItem]',
90                                      'value' => '1',
91                                      'checked' => (bool) $pref->get('searchMenuItem')));
92 $RandomPageMenuItem = HTML::input(array('type' => 'checkbox',
93                                      'name' => 'pref[randomPageMenuItem]',
94                                      'value' => '1',
95                                      'checked' => (bool) $pref->get('randomPageMenuItem')));
96 $SpecialPagesMenuItem = HTML::input(array('type' => 'checkbox',
97                                      'name' => 'pref[specialPagesMenuItem]',
98                                      'value' => '1',
99                                      'checked' => (bool) $pref->get('specialPagesMenuItem')));
100 $RelativeDatesCB = HTML::input(array('type' => 'checkbox',
101                                      'name' => 'pref[relativeDates]',
102                                      'value' => '1',
103                                      'checked' => (bool) $pref->get('relativeDates')));
104 $PageTrailCB = HTML::input(array('type' => 'checkbox',
105                                  'name' => 'pref[pageTrail]',
106                                  'value' => '1',
107                                  'checked' => (bool) $pref->get('pageTrail')));
108 $NoLinkIconsCB = HTML::input(array('type' => 'checkbox',
109                                    'name' => 'pref[noLinkIcons]',
110                                    'value' => '1',
111                                    'checked' => (bool) $pref->get('noLinkIcons')));
112 $GoogleLinkCB = HTML::input(array('type' => 'checkbox',
113                                   'name' => 'pref[googleLink]',
114                                   'value' => '1',
115                                   'checked' => (bool) $pref->get('googleLink')));
116 $DoubleClickCB = HTML::input(array('type' => 'checkbox',
117                                   'name' => 'pref[doubleClickEdit]',
118                                   'value' => '1',
119                                   'checked' => (bool) $pref->get('doubleClickEdit')));
120 if (!function_exists('selectedOption')) {
121   function selectedOption ($value, $label = false) {
122     return HTML::option(array('value' => $value,'selected'=>"selected"), ($label ? $label : $value) . "\n");
123   }
124   function unselectedOption ($value, $label = false) {
125     return HTML::option(array('value' => $value), ($label ? $label : $value) . "\n");
126   }
127 }
128
129 $SelectThemes = ''; $SelectLanguages = '';
130 $SelectThemesDesc = ''; $SelectLanguagesDesc = '';
131 if ( $isForm ) {
132     $SelectOptions = HTML(); 
133     if (!empty($available_themes) and is_array($available_themes)) {
134         if (!$pref->get('theme') or $pref->get('theme') == THEME)
135             $SelectOptions->pushContent(selectedOption("",_("<system theme>")));
136         else
137             $SelectOptions->pushContent(unselectedOption("",_("<system theme>")));
138         foreach ($available_themes as $theme) {
139             if ($theme == $pref->get('theme') and $theme != THEME)
140                 $SelectOptions->pushContent(selectedOption($theme));
141             else
142                 $SelectOptions->pushContent(unselectedOption($theme));
143         }
144         $SelectThemes = HTML::select(array('name' => "pref[theme]",'id' => 'theme'),
145                                      $SelectOptions);
146         $SelectThemesDesc = _("Personal theme:");
147     }
148     
149     $SelectOptions = HTML();
150     if (!empty($available_languages) and is_array($available_languages)) {
151         if (!$pref->get('lang') or $pref->get('lang') == DEFAULT_LANGUAGE)
152             $SelectOptions->pushContent(selectedOption("",_("<system language>")));
153         else
154             $SelectOptions->pushContent(unselectedOption("",_("<system language>")));
155         foreach ($available_languages as $lang) {
156             if ($lang == $pref->get('lang') and $lang != DEFAULT_LANGUAGE)
157                 $SelectOptions->pushContent(selectedOption($lang));
158             else
159                 $SelectOptions->pushContent(unselectedOption($lang));
160         }
161         $SelectLanguages = HTML::select(array('name' => "pref[lang]",'id' => 'lang'),
162                                         $SelectOptions);
163         $SelectLanguagesDesc = _("Personal language:");
164     } else {
165         if ($SelectThemes == '') {
166             $appearance = false;
167             $SelectThemesDesc = '';
168             $SelectLanguagesDesc = '';
169         }
170     }
171 } else {
172     $SelectThemesDesc = _("Personal theme:");
173     $SelectLanguagesDesc = _("Personal language:");
174     $SelectThemes = $pref->get('theme');
175     $SelectLanguages = $pref->get('lang');
176 }
177
178 if ($errmsg) $msg = HTML(HTML::h4(array('class' => 'errors'), $errmsg),HTML::hr());
179 ?>
180 <?= $errmsg ?>
181
182 <h2>
183 <?= fmt("User preferences for user %s", WikiLink($user->UserName())) ?>
184 </h2>
185
186 <?php if ($isForm) { ?>
187 <form action="<?=$request->getPostURL()?>" method="post">
188 <?php } else { 
189   $fill = "&nbsp;";
190   // See also plugin _AuthInfo
191   $authmethod = ENABLE_USER_NEW ? @$user->_authmethod : @$user->auth_how;
192 ?>
193 <?= HTML::pre(sprintf("%12s: [% 10s]  %s\n",_("UserId"),$pref->get('userid'), " from " . $authmethod),
194               sprintf("%12s: [% 10s]  %16s: [% 10s] | %8s: [%2s]\n","getId",$user->getId(),"getAuthenticatedId",$user->getAuthenticatedId(),"isSignedIn", $user->isSignedIn()),
195               //sprintf("%12s: [% 10s]\n",_("Password"),empty($pref->get('passwd')) ? _("<empty>") : _("<not empty>")),
196               sprintf("%12s: [% 10s]  %15s: [% 8s]\n",
197                       _("Auth Level"),$user->_level,_("Auth Method"),$authmethod),
198               sprintf("%12s: [% 10s]\n",_("HomePage"),$user->hasHomePage() ? (ENABLE_USER_NEW ? $user->_HomePagehandle->_pagename : $user->_homepage->_pagename ) : ''),
199               sprintf("%12s: [% 10s]\n",_("E-Mail"),$pref->get('email')),
200               //sprintf("%12s: [% 10s]\n",_("Notify"),$pref->get('notifyPages')),
201               sprintf("%12s: [% 10s] %16s: [% 10s] \n",_("Language"),$pref->get('lang'),_("Current Language"),$GLOBALS['LANG'])
202               ) ?>
203 <?php } ?>
204
205 <fieldset>
206 <legend><strong>User preferences for this project</strong></legend>
207 <table border="0" width="100%">
208 <?php if ($isForm and $user->mayChangePass()) { ?>
209   <tr><td colspan="3"><h3><?= ($request->getPref('passwd') ?  _("Change Password") :  _("Set Password")) ?></h3></td></tr>
210
211     <tr><td align="right"><?=_("New password")?>:</td>
212         <td><input type="password" name="pref[passwd]" size="16" maxlength="16" class="text" value="" /></td>
213         <td></td></tr>
214     <tr><td align="right"><?=_("Type it again")?>:</td>
215         <td><input type="password" name="pref[passwd2]" size="16" maxlength="16" class="text" value="" /></td>
216         <td></td></tr>
217 <?php } ?>
218
219 <?php if (ENABLE_USER_NEW) { ?>
220   <tr><td colspan="3"><h3><?=_("E-mail Notification")?></h3></td></tr>
221
222    <tr><td colspan="2">
223     <?=_("Get an email notification at changes of the following pages:")?>
224    </td></tr>
225    <tr>
226     <?php if ($isForm) { ?>
227       <td><textarea name="pref[notifyPages]" cols="40" rows="6"><?=$pref->get('notifyPages')?></textarea></td>
228     <td><p class="hint"><?=_("Enter pages seperated by space or comma. Wildcards (fileglobbing) allowed.")?></p></td>
229     <?php } else { ?>
230      <td><?=$pref->get('notifyPages')?></td><td></td>
231     <?php } ?>
232    </tr>
233 <?php } ?>
234
235 </table>
236 </fieldset>
237 <br />
238 <fieldset>
239 <legend><strong>Global user preferences (for all projects)</strong></legend>
240
241 <table border="0" width="100%">
242
243   <tr><td colspan="3"><h3><?=_("E-mail Notification")?></h3></td></tr>
244
245   <tr>
246       <td>
247          <p><?=_("Do not send my own modifications:")?></p>
248       </td>
249       <td>
250          <p><?= $OwnModificationsCB ?></p>
251       </td>
252       <td>
253          <p class="hint"><?=_("Check if you do not want to be notified of your own modifications.")?></p>
254       </td>
255   </tr>
256
257   <tr>
258       <td>
259          <p><?=_("Do not send minor modifications:")?></p>
260       </td>
261       <td>
262          <p><?= $MajorModificationsOnlyCB ?></p>
263       </td>
264       <td>
265          <p class="hint"><?=_("Check if you do not want to be notified of minor modifications.")?></p>
266       </td>
267   </tr>
268
269   <tr><td colspan="3"><h3><?=_("Menus")?></h3></td></tr>
270   <tr>
271      <td>
272        <fieldset>
273        <legend>Top Menu</legend>
274        <table cellpadding="0" cellspacing="0">
275          <tr>
276             <td>
277                <p><?= $DiffMenuItem ?> <?=_("Last Difference")?></p>
278             </td>
279          </tr>
280          <tr>
281             <td>
282                <p><?= $RevertMenuItem ?> <?=_("Revert")?></p>
283             </td>
284          </tr>
285          <?php if (defined('USE_EXTERNAL_HTML2PDF') and USE_EXTERNAL_HTML2PDF) { ?>
286            <tr>
287              <td>
288                 <p><?= $PDFMenuItem ?> <?=_("PDF")?></p>
289              </td>
290            </tr>
291          <?php } ?>
292          <tr>
293             <td>
294                <p><?= $LockMenuItem ?> <?=_("Lock")?></p>
295             </td>
296          </tr>
297          <tr>
298             <td>
299                <p><?= $ChownMenuItem ?> <?=_("Change Owner")?></p>
300             </td>
301          </tr>
302          <tr>
303             <td>
304                <p><?= $SetaclMenuItem ?> <?=_("Access Rights")?></p>
305             </td>
306          </tr>
307        </table>
308        </fieldset>
309     </td>
310
311      <td valign="top">
312        <fieldset>
313        <legend>Left Menu</legend>
314        <table cellpadding="0" cellspacing="0">
315          <tr>
316             <td>
317                <p><?= $SearchMenuItem ?> <?=_("Search")?></p>
318             </td>
319          </tr>
320          <tr>
321             <td>
322                <p><?= $RandomPageMenuItem ?> <?=_("RandomPage")?></p>
323             </td>
324          </tr>
325        </table>
326        </fieldset>
327     </td>
328
329     <td valign="top">
330       <p class="hint"><?=_("Check menu items to display.")?></p>
331     </td>
332   </tr>
333
334   <tr><td colspan="3"><h3><?=_("Appearance")?></h3></td></tr>
335
336   <tr><td colspan="3"><?=_("Here you can override site-specific default values.") ?></td></tr>
337       <tr><td align="right"><?= _("Show Page Trail")?></td>
338           <td><?=$PageTrailCB?></td>
339           <td><p class="hint"><?=_("Show Page Trail at top of page.")?></p></td></tr>
340       <tr><td align="right"><?=fmt("Hide %s:", WikiLink("Help:LinkIcons"))?></td>
341           <td><?=$NoLinkIconsCB?></td>
342           <td><p class="hint"><?=_("Hide or show LinkIcons.")?></p></td></tr>
343       <tr><td align="right"><?=fmt("Add %s:", WikiLink("Help:GoogleLink"))?></td>
344           <td><?=$GoogleLinkCB?></td>
345           <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>
346
347   <tr><td colspan="3"><h3><?=_("Edit Area Size")?></h3></td></tr>
348
349   <tr><td colspan="2">
350     <?=_("Height")?>:&nbsp;
351     <?php if ($isForm) { ?>
352      <input type="text" name="pref[editHeight]" size="4" maxlength="4" class="numeric"
353             value="<?=$pref->get('editHeight')?>" />
354     <?php } else { ?>
355       <?=$pref->get('editHeight')?>
356     <?php } ?>
357     &nbsp;&nbsp;<?=_("Width")?>:&nbsp;
358     <?php if ($isForm) { ?>
359      <input type="text" name="pref[editWidth]" size="4" maxlength="4" class="numeric"
360             value="<?=$pref->get('editWidth')?>" />
361     <?php } else { ?>
362       <?=$pref->get('editWidth')?>
363     <?php } ?>
364     </td>
365     <td><p class="hint">
366       <?=_("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>
367     </td></tr>
368
369   <tr><td colspan="3"><h3><?=_("Time Zone")?></h3></td></tr>
370
371   <tr><td colspan="2"><p>
372     <?=fmt("Add %s hours to the server's local time when reporting times.",
373            $timeOffsetInput)?>
374   </p></td><td>
375   <p class="hint">
376     <?=fmt("The current time at the server is %s.",
377             HTML::strong($WikiTheme->formatDateTime($serverTime)))?>
378     <?=fmt("With the current offset, this would be reported as %s.",
379            HTML::strong($WikiTheme->formatDateTime($time)))?>
380   </p>
381   </td></tr>
382
383   <tr><td colspan="3"><h3><?=_("Date Format")?></h3></td></tr>
384
385   <tr><td colspan="2"><p>
386     <?=_("Show relative dates using 'Today' and 'Yesterday'")?>:
387     <?= $RelativeDatesCB ?>
388   </p></td><td></td></tr>
389 </table>
390 </fieldset>
391
392 <?php if ($isForm) { ?>
393   <br />
394   <p><?=Button("submit:", _("Update Preferences"), 'wikiadmin')?>
395   <?=Button("submit:delete", _("Reset Preferences"), 'wikiadmin')?>
396   <?=Button("submit:cancel", _("Cancel"), 'button')?></p>
397
398 <?= HiddenInputs($request->getArgs(), false, array('pref')) ?>
399 </form>
400 <?php } ?>