5 $page->title
= _('Theme Settings');
7 if ( ! ($user instanceof authuser
) ) {
8 $page->errorfooter('login');
11 $premade_themes = new form_select('premade_theme', 2, $user->theme
);
12 $tmp = $DB->query('SELECT `themeid`, `theme_name` FROM `themes` ORDER BY `theme_name` ASC');
13 while ( $row = $tmp->fetch_row() )
14 $premade_themes->add_item($row[0], $row[1]);
16 $user_themes = new form_select('user_theme', 2);
17 $tmp = $DB->query('SELECT `userid`, `alias` FROM `users` WHERE `theme` = 0 ORDER BY `alias` ASC');
18 while ( $row = $tmp->fetch_row() )
19 $user_themes->add_item($row[0], $row[1]);
21 if ( isset($_POST['submit']) ) {
23 switch ( $_POST['themetype'] ) {
25 $premade_themes->check_value($_POST['premade_theme']);
26 $premade_themes->default = $user->theme
= intval($_POST['premade_theme']);
28 if ( isset($_POST['importpre']) ) {
29 list($f) = $DB->query('SELECT `css_file` FROM `themes`
30 WHERE `themeid` = '.intval($_POST['premade_theme']))->fetch_row();
31 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/'.$f));
36 $user_themes->check_value($_POST['user_theme']);
37 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/u'.intval($_POST['user_theme']).'.css'));
43 file_put_contents('css/u'.$user->userid
.'.css', $_POST['user_css']);
47 echo '<div class="notice">',_('Settings have been saved.'),'</div>';
48 } catch ( Exception
$e ) {
50 echo '<div class="error">',$e->getMessage(),'</div>';
55 if ( file_exists('css/u'.$user->userid
.'.css') )
56 $css_textbox = file_get_contents('css/u'.$user->userid
.'.css');
62 echo '<form method="post" action="',$_SERVER['PHP_SELF'],'">
66 <th scope="col">',_('Theme Type'),'</th>
67 <th scope="col">',_('Detailed Settings'),'</th>
72 <tr class="content c',(++
$a&1),'">
73 <td><label><input type="radio" name="themetype" value="premade"',( $user->theme
> 0 ?
' checked="checked"' : '' ),'/> ',_('Premade'),'</label></td>
74 <td><label>',_('Select theme: '),$premade_themes->display(),
76 <label><input type="checkbox" name="importpre"/> ',_('Set this as your custom theme (will overwrite anything currently there)'),'</label></td>
78 <tr class="content c',(++
$a&1),'">
79 <td><label><input type="radio" name="themetype" value="import"/> ',_('Import user theme'),'</label></td>
80 <td><label>',_('User name: '),$user_themes->display(),
83 <tr class="content c',(++
$a&1),'">
84 <td><label><input type="radio" name="themetype" value="custom"',( $user->theme
== 0 ?
' checked="checked"' : '' ),'/> ',_('Custom CSS'),'</label></td>
85 <td><label>CSS:<br/><textarea rows="20" cols="60" name="user_css" id="user_css">',$css_textbox,'</textarea></label></td>
90 <button type="submit" name="submit" value="save" accesskey="s">',_('Save Settings'),' (S)</button>