5 * @author Ant P <p@cpi.merseine.nu>
6 * @license file://COPYING
11 SO2
::$Page->title
= 'Theme Settings';
13 if ( ! (SO2
::$User instanceof User_Authenticated
) ) {
14 SO2
::$Page->message(Page
::ERR_LOGIN
);
16 SO2
::$Page->usernav
['General Options'] = 'options';
18 $advancedmode = HTML_Checkbox
::factory(array(
19 'enable' => 'Use Advanced Theme',
20 'append' => 'Additive (add after the selected basic theme)'
22 $premademode = HTML_Radiobutton
::factory('themetype', array(
23 'system' => 'Premade theme: ',
24 'user' => 'Another user\'s custom theme: '
25 ), (isset($_POST['themetype']) ?
$_POST['themetype'] : SO2
::$User->theme_type
));
27 $importpremade = new HTML_Checkbox('importpre', 'Import basic theme to advanced');
29 $premade_themes = new HTML_Select('premade_theme');
30 $user_themes = new HTML_Select('user_theme');
31 if ( 'system' == SO2
::$User->theme_type
) {
32 $premade_themes->default = SO2
::$User->theme_id
;
34 $user_themes->default = SO2
::$User->theme_id
;
37 $premade_themes->add_item(0, '(No CSS)');
38 $premade_themes->array_fill(SO2
::$DB->query('SELECT themeid, theme_name FROM themes ORDER BY theme_name ASC')->fetchAll());
40 if ( isset($_POST['save']) ) {
41 SO2
::$DB->beginTransaction();
43 // Do stuff for premade theme
44 if ( $premademode['system']->is_selected() ) {
45 $premade_themes->check_value($_POST['premade_theme']);
46 $premade_themes->default = intval($_POST['premade_theme']);
48 if ( $importpremade->value
&& intval($_POST['premade_theme']) != 0 ) {
49 $filename = SO2
::$DB->q('SELECT css_file FROM themes WHERE themeid = ?', $_POST['premade_theme'],
50 SO2_PDO
::QVALUE
).'.css';
52 SO2
::$User->theme_type
= 'system';
53 SO2
::$User->theme_id
= intval($_POST['premade_theme']);
56 // Do stuff for user-made theme
57 elseif ( $premademode['user']->is_selected() ) {
58 $user_themes->default = intval($_POST['user_theme']);
60 if ( $importpremade->value
&& file_exists('css/'.$filename) ) {
61 $filename = "u{$_POST['user_theme']}.css";
63 SO2
::$User->theme_type
= 'user';
64 SO2
::$User->theme_id
= intval($_POST['user_theme']);
68 // Import premade theme
69 if ( $importpremade->is_selected() && isset($filename) ) {
70 copy('css/'.$filename, 'css/u'.SO2
::$User->userid
.'.css');
71 $advancedmode['enable']->value
= true;
72 $advancedmode['append']->value
= false;
74 // Save CSS if advanced mode is enabled
75 elseif ( $advancedmode['enable']->is_selected() ) {
76 file_put_contents('css/u'.SO2
::$User->userid
.'.css', str_replace("\r\n", "\n", $_POST['user_css']));
78 // Clean up empty files
79 elseif ( empty($_POST['css']) && file_exists('css/u'.SO2
::$User->userid
.'.css') ) {
80 unlink('css/u'.SO2
::$User->userid
.'.css');
83 // Update user settings
84 if ( $advancedmode['enable']->is_selected() && ! $advancedmode['append']->is_selected() ) {
85 SO2
::$User->theme_type
= 'system';
86 SO2
::$User->theme_id
= 0;
88 SO2
::$User->custom_css
= $advancedmode['enable']->value
;
89 $importpremade->value
= false;
93 SO2
::$Page->message('Settings have been saved.', E_USER_NOTICE
);
94 } elseif ( isset($_POST['preview']) ) {
95 SO2
::$Page->message('This is a preview of your custom theme. Changes have not been saved.', E_USER_NOTICE
);
97 SO2
::$Page->pageheader();
99 $user_themes->array_fill(SO2
::$DB->query('SELECT userid, alias FROM users WHERE custom_css = 1 AND theme_type = "system" '.
100 'AND theme_id = 0 ORDER BY alias ASC')->fetchAll());
103 <form id
="theme" method
="post" action
="<?php echo $_SERVER['PHP_SELF'] ?>">
104 <fieldset
class="content">
105 <legend
>Basic Themes
</legend
>
106 <p
><?php
echo $premademode['system'], $premade_themes ?
></p
>
107 <p
><?php
if ( count($user_themes) ) echo $premademode['user'], $user_themes ?
></p
>
108 <p
><?php
echo $importpremade ?
></p
>
111 <p
><button type
="submit" name
="save" accesskey
="s">Save
Settings (S
)</button
></p
>
113 <fieldset
class="content">
114 <legend
><?php
echo $advancedmode['enable'] ?
></legend
>
116 <p
><?php
echo $advancedmode['append'] ?
></p
>
118 <legend
>Edit CSS
</legend
>
119 <textarea rows
="20" cols
="80" name
="user_css"><?php
120 if ( isset($_POST['preview'], $_POST['user_css']) )
121 echo htmlspecialchars($_POST['user_css']);
122 elseif ( file_exists('css/u'.SO2
::$User->userid
.'.css') )
123 echo htmlspecialchars(file_get_contents('css/u'.SO2
::$User->userid
.'.css'));
125 <p
><a href
="css/">CSS Directory
</a
> |
<button type
="submit" name
="preview" accesskey
="p">Preview (P
)</button
></p
>
128 <h3
>CSS examples
</h3
>
130 <li
>Make page title right
-aligned
: <code
>h1
{ text
-align
: right
}</code
></li
>
131 <li
>Increase the font size of the board
list: <code
>#so2-index { font-size: 1.1em }</code></li>
132 <li
>Lock the navigation menus to the left of the screen
: <code
>.nl
{ position
: fixed
; left
: 0 }</code
></li
>
133 <li
>Make the messagelist fixed width
: <code
>#messagelist { max-width: 60em }</code></li>
134 <li
>Decrease the indent on threaded messagelists
: <code
>.Messagelist_Threaded
.thread
{ margin
-left
: 0.2em
}</code
></li
>
135 <li
>Give IRC layout a monospace font
: <code
>.Messagelist_Flat
.Messagestyle_IRC
{ font
-family
: monospace
}</code
></li
>
136 <li
>Highlight all errors
, notices
and info messages
: <code
>.error
, .notice
, .info
{ color
: #f00 }</code></li>
137 <li
>Give alternating table rows different colours
: <code
>.c0
{ background
: #fff } .c1 { background: #ddd }</code></li>
138 <li
>Hide threads below a certain depth until clicked on
:
139 <pre
>.thread
.thread
.message
> .content
{ display
: none
} .message
:target
> .content
{ display
: block
}</pre
></li
>
140 <li
>Block anything posted by the user with userid
#24: <code>.u24 { display: none !important }</code></li>