Deleted the ricer gettext crap in post.php
[specialops2.git] / theme.php
blobced2d7a8f07074be35116222a474d7d8cf7e156f
1 <?php
2 // $Id$
4 require 'con.php';
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']) ) {
22 try {
23 switch ( $_POST['themetype'] ) {
24 case 'premade' :
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));
31 break;
33 case 'import' :
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'));
36 $user->u_theme = 0;
37 break;
39 case 'custom' :
40 $user->u_theme = 0;
41 file_put_contents('css/u'.$user->userid.'.css', $_POST['user_css']);
44 $user->userheader();
45 echo '<div class="notice">',_('Settings have been saved.'),'</div>';
46 } catch ( Exception $e ) {
47 $user->userheader();
48 echo '<div class="error">',$e->getMessage(),'</div>';
50 } else
51 $user->userheader();
53 if ( file_exists('css/u'.$user->userid.'.css') )
54 $css_textbox = file_get_contents('css/u'.$user->userid.'.css');
55 else
56 $css_textbox = '';
58 $a = 1;
60 echo '<form method="post" action="',$_SERVER['PHP_SELF'],'">
61 <table id="theme">
62 <thead>
63 <tr>
64 <th scope="col">',_('Theme Type'),'</th>
65 <th scope="col">',_('Detailed Settings'),'</th>
66 </tr>
67 </thead>
69 <tbody>
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(),
73 ' </label><br/>
74 <label><input type="checkbox" name="importpre"/> ',_('Set this as your custom theme (will overwrite anything currently there)'),'</label></td>
75 </tr>
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(),
79 ' </label></td>
80 </tr>
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>
84 </tr>
85 </tbody>
86 </table>
88 <button type="submit" name="submit" value="save" accesskey="s">',_('Save Settings'),' (S)</button>
89 </form>';
91 $page->pagefooter();