5 $page->title
= _('Theme Settings');
7 if ( ! ($user instanceof authuser
) ) {
8 $page->errorfooter('login');
11 if ( isset($_POST['submit']) ) {
13 switch ( $_POST['themetype'] ) {
15 $user->u_theme
= intval($_POST['premade_theme']);
16 if ( isset($_POST['importpre']) ) {
17 list($file) = $DB->query('SELECT `st_file` FROM `styles` WHERE `stid` = '.intval($_POST['premade_theme']))->fetch_row();
18 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/'.$file));
23 if ( file_exists('css/u'.intval($_POST['user_import']).'.css') )
24 file_put_contents('css/u'.$user->userid
.'.css', file_get_contents('css/u'.intval($_POST['user_import']).'.css'));
30 file_put_contents('css/u'.$user->userid
.'.css', $_POST['user_css']);
34 echo '<div class="notice">',_('Settings have been saved.'),'</div>';
39 //These are only used 2 times so it's not worth making a function to do it
40 $q = $DB->query('SELECT `stid`, `st_name` FROM `styles` ORDER BY `st_name` ASC');
41 $pre_selectbox = '<select name="premade_theme">'."\n";
42 while ($row = $q->fetch_row())
43 $pre_selectbox .= '<option value="'.$row[0].'"'.( $user->u_theme
== $row[0] ?
' selected="selected"' : '' ).'>'.$row[1]."</option>\n";
44 $pre_selectbox .= '</select>';
46 $q = $DB->query('SELECT `userid`, `u_name` FROM `users` WHERE `u_theme` = 0 ORDER BY `u_name` ASC');
47 $import_selectbox = '<select name="user_import">'."\n";
48 while ($row = $q->fetch_row())
49 $import_selectbox .= '<option value="'.$row[0].'">'.$row[1]."</option>\n";
50 $import_selectbox .= '</select>';
53 if ( file_exists('css/u'.$user->userid
.'.css') )
54 $css_textbox = file_get_contents('css/u'.$user->userid
.'.css');
58 echo '<form id="themeprefs" method="post" action="',$_SERVER['PHP_SELF'],'">
59 <fieldset class="content">
62 <input type="radio" id="premade" name="themetype" value="premade"',( $user->u_theme
> 0 ?
' checked="checked"' : '' ),'/>
63 <label for="premade">',_('Use a premade theme:'),'</label>
64 '.$pre_selectbox.'<br/>
65 <input type="checkbox" id="importpre" name="importpre"/>
66 <label for="importpre">',_('Set this as your custom theme (will overwrite anything currently there)'),'</label>
69 <input type="radio" id="import" name="themetype" value="import"/>
70 <label for="import">',_('Import a custom theme from a user:'),'</label>
74 <input type="radio" id="custom" name="themetype" value="custom"',( $user->u_theme
== 0 ?
' checked="checked"' : '' ),'/>
75 <label for="custom">',_('Use your own CSS:'),'</label>
76 <textarea rows="15" cols="80" name="user_css" id="user_css">'.$css_textbox.'</textarea>
80 <button type="submit" name="submit" value="save" accesskey="s">',_('Save Settings'),' (S)</button>