5 $page->title
= _('Theme Settings');
7 if ( ! ($user instanceof authuser
) ) {
8 $page->errorfooter('login');
11 $premade_themes = new form_select('premade_theme', 2, $user->u_theme
);
12 $tmp = $DB->query('SELECT `stid`, `st_name` FROM `styles` ORDER BY `st_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`, `u_name` FROM `users` WHERE `u_theme` = 0 ORDER BY `u_name` 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 $user->u_theme
= intval($_POST['premade_theme']);
27 if ( isset($_POST['importpre']) ) {
28 list($file) = $DB->query('SELECT `st_file` FROM `styles` WHERE `stid` = '.intval($_POST['premade_theme']))->fetch_row();
29 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/'.$file));
34 $user_themes->check_value($_POST['user_theme']);
35 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/u'.intval($_POST['user_theme']).'.css'));
41 file_put_contents('css/u'.$user->userid
.'.css', $_POST['user_css']);
45 echo '<div class="notice">',_('Settings have been saved.'),'</div>';
46 } catch ( Exception
$e ) {
48 echo '<div class="error">',$e->getMessage(),'</div>';
53 if ( file_exists('css/u'.$user->userid
.'.css') )
54 $css_textbox = file_get_contents('css/u'.$user->userid
.'.css');
60 echo '<form method="post" action="',$_SERVER['PHP_SELF'],'">
64 <th scope="col">',_('Theme Type'),'</th>
65 <th scope="col">',_('Detailed Settings'),'</th>
70 <tr class="content c',(++
$a&1),'">
71 <td><label><input type="radio" name="themetype" value="premade"',( $user->u_theme
> 0 ?
' checked="checked"' : '' ),'/> ',_('Premade'),'</label></td>
72 <td><label>',_('Select theme: '),$premade_themes->display(),
74 <label><input type="checkbox" name="importpre"/> ',_('Set this as your custom theme (will overwrite anything currently there)'),'</label></td>
76 <tr class="content c',(++
$a&1),'">
77 <td><label><input type="radio" name="themetype" value="import"/> ',_('Import user theme'),'</label></td>
78 <td><label>',_('User name: '),$user_themes->display(),
81 <tr class="content c',(++
$a&1),'">
82 <td><label><input type="radio" name="themetype" value="custom"',( $user->u_theme
== 0 ?
' checked="checked"' : '' ),'/> ',_('Custom CSS'),'</label></td>
83 <td><label>CSS:<br/><textarea rows="20" cols="100" name="user_css" id="user_css">',$css_textbox,'</textarea></label></td>
88 <button type="submit" name="submit" value="save" accesskey="s">',_('Save Settings'),' (S)</button>