new css omgomgomg ^_^_^_^^ *jizz*
[specialops2.git] / theme.php
blob2f4696135ebbc82b040f72752a15f3f4a829da36
1 <?php
2 /**
3 * Theme Editor
5 * @author Anthony Parsons (xmpp:ant@specialops.ath.cx)
6 * @license file://COPYING
7 * @version $Id$
8 */
10 require 'con.php';
11 $page->title = 'Theme Settings';
13 if ( ! ($user instanceof User_Authenticated) ) {
14 $page->errorfooter('login');
16 $user->userlinks['General Settings'] = 'options';
18 $premade_themes = new HTML_Select('premade_theme', 2, $user->theme);
19 $user_themes = new HTML_Select('user_theme', 2);
21 $premade_themes->db_fill($DB->query('SELECT `themeid`, `theme_name` FROM `themes` ORDER BY `theme_name` ASC', MYSQLI_USE_RESULT));
22 $user_themes->db_fill($DB->query('SELECT `userid`, `alias` FROM `users` WHERE `theme` = 0 ORDER BY `alias` ASC', MYSQLI_USE_RESULT));
24 if ( isset($_POST['submit']) ) {
25 try {
26 switch ( $_POST['themetype'] ) {
27 case 'premade':
28 $premade_themes->check_value($_POST['premade_theme']);
29 $premade_themes->default = intval($_POST['premade_theme']);
31 if ( isset($_POST['importpre']) ) {
32 list($f) = $DB->query('SELECT `css_file` FROM `themes`
33 WHERE `themeid` = '.intval($_POST['premade_theme']))->fetch_row();
34 file_put_contents('css/u'.$user->userid.'.css', file_get_contents('css/'.$f.'.css'));
35 $user->theme = 0;
36 } else {
37 $user->theme = intval($_POST['premade_theme']);
39 break;
41 case 'import':
42 $user_themes->check_value($_POST['user_theme']);
43 file_put_contents('css/u'.$user->userid.'.css', file_get_contents('css/u'.intval($_POST['user_theme']).'.css'));
44 $user->theme = 0;
45 break;
47 case 'custom':
48 $user->theme = 0;
49 file_put_contents('css/u'.$user->userid.'.css', str_replace("\r\n", "\n", $_POST['user_css']));
52 $user->userheader();
53 echo '<p class="notice">Settings have been saved.</p>';
54 } catch ( Exception $e ) {
55 $user->userheader();
56 echo '<p class="error">',$e->getMessage(),'</p>';
58 } else {
59 $user->userheader();
62 if ( file_exists('css/u'.$user->userid.'.css') ) {
63 $css_textbox = htmlspecialchars(file_get_contents('css/u'.$user->userid.'.css'));
64 } else {
65 $css_textbox = '';
69 <form id="theme" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
71 <fieldset class="content">
72 <legend><label><input type="radio" name="themetype" value="premade"<?php
73 echo 0 < $user->theme ? ' checked="checked"' : '' ?>/> Premade Theme</label></legend>
74 <p><label>Select theme: <?php echo $premade_themes->display() ?></label></p>
75 <p><label><input type="checkbox" name="importpre"/> Set your custom theme to this</label></p>
76 </fieldset>
78 <fieldset class="content">
79 <legend><label><input type="radio" name="themetype" value="import"/> Import from user</label></legend>
80 <p><label>User name: <?php echo $user_themes->display() ?></label></p>
81 </fieldset>
83 <fieldset class="content">
84 <legend><label><input type="radio" name="themetype" value="custom"<?php
85 echo 0 == $user->theme ? ' checked="checked"' : '' ?>/> Custom CSS</label></legend>
86 <textarea rows="20" cols="80" name="user_css" id="user_css"><?php echo $css_textbox ?></textarea>
87 </fieldset>
89 <button type="submit" name="submit" accesskey="s">Save Settings (S)</button>
90 </form>
92 <h3>CSS classes &amp; IDs:</h3>
93 <dl>
94 <dt><code>h1</code></dt>
95 <dd>Page title</dd>
96 <dt><code>body#so2-index</code>, [...]</dt>
97 <dd><code>&lt;body&gt;</code> tag for index.php</dd>
98 <dt><code>.nl</code>,
99 <code>#userheader</code>,
100 <code>#navbar</code></dt>
101 <dd>Generic navigation list, user navigation, page navigation</dd>
102 <dt><code>#messagelist</code>,
103 <code>#topiclist</code>,
104 <code>#boardlist</code></dt>
105 <dd>Message list/topic list/board list</dd>
106 <dt><code>.Messagelist_Default</code>,
107 <code>.Topiclist_Default</code>,
108 <code>.Boardlist_Default</code>,
109 [...]</dt>
110 <dd>Layout-specific classes for messagelist/topiclist/boardlist</dd>
111 <dt><code>.error</code>,
112 <code>.notice</code>,
113 <code>.info</code></dt>
114 <dd>Errors, important messages and informational messages</dd>
115 <dt><code>.c0</code>,
116 <code>.c1</code></dt>
117 <dd>Alternating rows in tables</dd>
118 <dt><code>.message</code>, <code>.thread</code></dt>
119 <dd>Messages in messagelist, threads (threaded view only)</dd>
120 </dl>
122 <?php
123 $page->pagefooter();