Added some class="" to pagelist code
[specialops2.git] / theme.php
blob91df4ae02c9581f04565349f2942c35cee4752fb
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['save']) ) {
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 } elseif ( isset($_POST['preview']) ) {
59 $user->userheader();
60 echo '<p class="notice">This is a preview of your custom theme. Changes have not been saved.</p>';
61 } else {
62 $user->userheader();
65 $css_textbox = htmlspecialchars(
66 empty($_POST['user_css'])
67 ? (
68 file_exists('css/u'.$user->userid.'.css')
69 ? file_get_contents('css/u'.$user->userid.'.css')
70 : ''
72 : $_POST['user_css']
74 $themetype = isset($_POST['preview']) ? 0 : $user->theme;
77 <form id="theme" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>">
78 <button type="submit" name="save" accesskey="s">Save Settings (S)</button>
79 <fieldset class="content">
80 <legend><label><input type="radio" name="themetype" value="premade"<?php
81 echo 0 < $themetype ? ' checked="checked"' : '' ?>/> Premade Theme</label></legend>
82 <p><label>Select theme: <?php echo $premade_themes->display() ?></label></p>
83 <p><label><input type="checkbox" name="importpre"/> Set your custom theme to this</label></p>
84 </fieldset>
86 <fieldset class="content">
87 <legend><label><input type="radio" name="themetype" value="import"/> Import from user</label></legend>
88 <p><label>User name: <?php echo $user_themes->display() ?></label></p>
89 </fieldset>
91 <fieldset class="content">
92 <legend><label><input type="radio" name="themetype" value="custom"<?php
93 echo 0 == $themetype ? ' checked="checked"' : '' ?>/> Custom CSS</label></legend>
94 <textarea rows="20" cols="80" name="user_css" id="user_css"><?php echo $css_textbox ?></textarea>
95 <p><a href="css/">CSS Directory</a> <button type="submit" name="preview" accesskey="p">Preview (P)</button></p>
96 </fieldset>
97 </form>
99 <div id="theme-help">
100 <h3>CSS classes &amp; IDs:</h3>
101 <dl>
102 <dt><code>h1</code></dt>
103 <dd>Page title</dd>
104 <dt><code>body#so2-index</code>, [...]</dt>
105 <dd><code>&lt;body&gt;</code> tag for index.php</dd>
106 <dt><code>.nl</code>,
107 <code>#userheader</code>,
108 <code>#navbar</code></dt>
109 <dd>Generic navigation list, user navigation, page navigation</dd>
110 <dt><code>#messagelist</code>,
111 <code>#topiclist</code>,
112 <code>#boardlist</code></dt>
113 <dd>Message list/topic list/board list</dd>
114 <dt><code>.Messagelist_Default</code>,
115 <code>.Topiclist_Default</code>,
116 <code>.Boardlist_Default</code>,
117 [...]</dt>
118 <dd>Layout-specific classes for messagelist/topiclist/boardlist</dd>
119 <dt><code>.error</code>,
120 <code>.notice</code>,
121 <code>.info</code></dt>
122 <dd>Errors, important messages and informational messages</dd>
123 <dt><code>.c0</code>,
124 <code>.c1</code></dt>
125 <dd>Alternating rows in tables</dd>
126 <dt><code>.message</code>, <code>.thread</code></dt>
127 <dd>Messages in messagelist, threads (threaded view only)</dd>
128 <dt><code>.message > .info</code>, <code>.message > .content</code></dt>
129 <dd>Message header &amp; message body</dd>
130 <dt><code>.message.u100</code></dt>
131 <dd>Any messages posted by a user with userid 100</dd>
132 </dl>
133 </div>
135 <?php
136 $page->pagefooter();