0
|
1 |
<?php
|
|
2 |
/**!info**
|
|
3 |
{
|
|
4 |
"Plugin Name" : "Enanium backgrounds",
|
|
5 |
"Plugin URI" : "http://enanocms.org/plugin/enaniumbg",
|
|
6 |
"Description" : "Provides several additional background images for Enanium.",
|
|
7 |
"Author" : "Dan Fuhry",
|
|
8 |
"Version" : "1.1.6",
|
|
9 |
"Author URI" : "http://enanocms.org/"
|
|
10 |
}
|
|
11 |
**!*/
|
|
12 |
|
|
13 |
// $plugins->attachHook('enanium_search_form', 'enanium_paint_bg_controls();');
|
|
14 |
$plugins->attachHook('enanium_main_header', 'enanium_paint_bg_controls();');
|
|
15 |
$plugins->attachHook('compile_template', 'enanium_add_headers();');
|
1
|
16 |
$plugins->attachHook('acl_rule_init', '$this->addAdminNode("adm_cat_appearance", "enaniumbg_acppage", "EnaniumConfig", scriptPath . "/plugins/enaniumbg/icons/garden.png");');
|
0
|
17 |
|
|
18 |
$ebg_images = array('default', 'aqua', 'blinds', 'dune', 'freshflower', 'garden', 'greenmeadow', 'ladybird', 'raindrops', 'storm', 'twowings', 'wood', 'yellowflower');
|
|
19 |
|
|
20 |
$ebg_outsiders = array();
|
|
21 |
if ( $dr = @opendir(ENANO_ROOT . '/plugins/enaniumbg') )
|
|
22 |
{
|
|
23 |
while ( $dh = @readdir($dr) )
|
|
24 |
{
|
1
|
25 |
if ( $dh == '.' || $dh == '..' || is_dir(ENANO_ROOT . "/plugins/enaniumbg/$dh") )
|
0
|
26 |
continue;
|
|
27 |
|
1
|
28 |
if ( !preg_match('/\.jpg$/', $dh) )
|
0
|
29 |
continue;
|
|
30 |
|
|
31 |
$dh = preg_replace('/\.jpg$/', '', $dh);
|
|
32 |
|
1
|
33 |
if ( in_array($dh, $ebg_images) )
|
|
34 |
continue;
|
|
35 |
|
0
|
36 |
if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/icons/$dh.png") )
|
|
37 |
continue;
|
|
38 |
|
|
39 |
$ebg_outsiders[] = $dh;
|
|
40 |
}
|
|
41 |
closedir($dr);
|
|
42 |
}
|
|
43 |
unset($dh, $dr);
|
|
44 |
|
|
45 |
function enanium_paint_bg_controls()
|
|
46 |
{
|
|
47 |
global $ebg_images, $ebg_outsiders;
|
|
48 |
global $lang;
|
|
49 |
|
1
|
50 |
if ( !getConfig('enanium_show_switcher', 1) )
|
|
51 |
return;
|
|
52 |
|
0
|
53 |
?>
|
|
54 |
<div id="enanium_bg_list">
|
|
55 |
<?php
|
|
56 |
foreach ( $ebg_images as $i => $image )
|
|
57 |
{
|
1
|
58 |
$sel = ( $image == getConfig('enanium_bg', 'default') ) ? ' class="selected"' : '';
|
0
|
59 |
echo '<a' . $sel . ' href="#bg:' . $image . '" id="ebg_' . $image . '" onclick="enanium_change_bg(\'' . $image . '\', this); return false;" title="' . $lang->get('enaniumbg_' . $image) . '">';
|
|
60 |
echo enanium_generate_sprite(scriptPath . '/plugins/enaniumbg/icons/sprite.png', 16, 16, 0, $i * 16);
|
|
61 |
echo '</a>';
|
|
62 |
}
|
1
|
63 |
foreach ( $ebg_outsiders as $image )
|
|
64 |
{
|
|
65 |
$sel = ( $image == getConfig('enanium_bg', 'default') ) ? ' class="selected"' : '';
|
|
66 |
echo '<a' . $sel . ' href="#bg:' . $image . '" id="ebg_' . $image . '" onclick="enanium_change_bg(\'' . $image . '\', this); return false;" title="' . htmlspecialchars(ucwords(str_replace('_', ' ', $image))) . '">';
|
|
67 |
echo '<img alt=" " src="' . scriptPath . '/plugins/enaniumbg/icons/' . $image . '.png" />';
|
|
68 |
echo '</a>';
|
|
69 |
}
|
0
|
70 |
?>
|
|
71 |
</div>
|
|
72 |
<?php
|
|
73 |
}
|
|
74 |
|
|
75 |
function enanium_add_headers()
|
|
76 |
{
|
|
77 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
1
|
78 |
global $ebg_images, $ebg_outsiders;
|
0
|
79 |
global $lang;
|
|
80 |
|
|
81 |
if ( $template->theme != 'enanium' )
|
|
82 |
return;
|
|
83 |
|
1
|
84 |
$repeat = getConfig('enanium_background_repeat', 'no-repeat');
|
|
85 |
$attachment = getConfig('enanium_background_attachment', 'fixed');
|
|
86 |
$position = getConfig('enanium_background_position', 'center top');
|
|
87 |
|
|
88 |
if ( getConfig('enanium_show_switcher', 1) )
|
|
89 |
{
|
|
90 |
$template->add_header('<link rel="stylesheet" type="text/css" href="' . scriptPath . '/plugins/enaniumbg/enaniumbg.css" />');
|
|
91 |
|
|
92 |
$addheader = <<<EOF
|
|
93 |
<script type="text/javascript">
|
|
94 |
var enanium_bg_repeat = '$repeat';
|
|
95 |
var enanium_bg_attachment = '$attachment';
|
|
96 |
var enanium_bg_position = '$position';
|
|
97 |
</script>
|
|
98 |
EOF;
|
|
99 |
$template->add_header($addheader);
|
|
100 |
$template->add_header('<script type="text/javascript" src="' . scriptPath . '/plugins/enaniumbg/enaniumbg.js"></script>');
|
|
101 |
}
|
|
102 |
|
|
103 |
if ( ($img = getConfig('enanium_bg', 'default')) !== 'default' )
|
|
104 |
{
|
|
105 |
if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/$img.jpg") )
|
|
106 |
return;
|
|
107 |
|
|
108 |
$scriptpath = scriptPath;
|
|
109 |
$addheader = <<<EOF
|
|
110 |
<style type="text/css">
|
|
111 |
body {
|
|
112 |
background-image: url({$scriptpath}/plugins/enaniumbg/{$img}.jpg);
|
|
113 |
background-color: #000000;
|
|
114 |
background-repeat: $repeat;
|
|
115 |
background-attachment: $attachment;
|
|
116 |
background-position: $position;
|
|
117 |
}
|
|
118 |
td#cell-content {
|
|
119 |
background-color: transparent;
|
|
120 |
background-image: url({$scriptpath}/plugins/enaniumbg/transw70.png);
|
|
121 |
}
|
|
122 |
</style>
|
|
123 |
EOF;
|
|
124 |
$template->add_header($addheader);
|
|
125 |
}
|
0
|
126 |
}
|
|
127 |
|
|
128 |
function enanium_generate_sprite($sprite, $width, $height, $start_x, $start_y)
|
|
129 |
{
|
|
130 |
$start_x = 0 - $start_x;
|
|
131 |
$start_y = 0 - $start_y;
|
|
132 |
return '<img alt=" " src="' . cdnPath . '/images/spacer.gif" width="' . $width . '" height="' . $height . '" style="background-image: url(\'' . $sprite . '\'); background-repeat: no-repeat; background-position: ' . $start_x . 'px ' . $start_y . 'px;" />';
|
|
133 |
}
|
|
134 |
|
1
|
135 |
function page_Admin_EnaniumConfig()
|
|
136 |
{
|
|
137 |
global $db, $session, $paths, $template, $plugins; // Common objects
|
|
138 |
global $lang;
|
|
139 |
|
|
140 |
if ( isset($_POST['enanium_bg']) )
|
|
141 |
{
|
|
142 |
$bg = $_POST['enanium_bg'];
|
|
143 |
if ( file_exists(ENANO_ROOT . "/plugins/enaniumbg/$bg.jpg") )
|
|
144 |
setConfig('enanium_bg', $bg);
|
|
145 |
|
|
146 |
$val = isset($_POST['show_switcher']) ? '1' : '0';
|
|
147 |
setConfig('enanium_show_switcher', $val);
|
|
148 |
|
|
149 |
setConfig('enanium_background_repeat', $_POST['background_repeat']);
|
|
150 |
setConfig('enanium_background_attachment', $_POST['background_attachment']);
|
|
151 |
setConfig('enanium_background_position', $_POST['background_position']);
|
|
152 |
|
|
153 |
echo '<div class="info-box">' . $lang->get('enaniumbg_acp_msg_changes_saved') . '</div>';
|
|
154 |
}
|
|
155 |
|
|
156 |
acp_start_form();
|
|
157 |
?>
|
|
158 |
<div class="tblholder">
|
|
159 |
<table border="0" cellspacing="1" cellpadding="4">
|
|
160 |
<tr>
|
|
161 |
<th colspan="2"><?php echo $lang->get('enaniumbg_acp_th'); ?></th>
|
|
162 |
</tr>
|
|
163 |
<tr>
|
|
164 |
<td class="row2" style="width: 50%;">
|
|
165 |
<?php echo $lang->get('enaniumbg_acp_field_default_bg'); ?><br />
|
|
166 |
<small><?php echo $lang->get('enaniumbg_acp_field_default_bg_hint'); ?></small>
|
|
167 |
</td>
|
|
168 |
<td class="row1" style="width: 50%;">
|
|
169 |
<select name="enanium_bg">
|
|
170 |
<?php
|
|
171 |
global $ebg_images, $ebg_outsiders;
|
|
172 |
if ( !empty($ebg_outsiders) )
|
|
173 |
{
|
|
174 |
foreach ( $ebg_outsiders as $image )
|
|
175 |
{
|
|
176 |
$sel = $image == getConfig('enanium_bg', 'default') ? 'selected="selected" ' : '';
|
|
177 |
echo '<option ' . $sel . 'value="' . $image . '">' . ucwords(str_replace('_', ' ', $image)) . '</option>';
|
|
178 |
}
|
|
179 |
echo '<option disabled="disabled" value="">--------------------</option>';
|
|
180 |
}
|
|
181 |
foreach ( $ebg_images as $image )
|
|
182 |
{
|
|
183 |
$sel = $image == getConfig('enanium_bg', 'default') ? 'selected="selected" ' : '';
|
|
184 |
echo '<option ' . $sel . 'value="' . $image . '">' . $lang->get("enaniumbg_$image") . '</option>';
|
|
185 |
}
|
|
186 |
?>
|
|
187 |
</select>
|
|
188 |
</td>
|
|
189 |
</tr>
|
|
190 |
<tr>
|
|
191 |
<td class="row2">
|
|
192 |
<label for="ebg_chk_show_switcher"><?php echo $lang->get('enaniumbg_acp_field_show_switcher'); ?></label><br />
|
|
193 |
<small><?php echo $lang->get('enaniumbg_acp_field_show_switcher_hint'); ?></small>
|
|
194 |
</td>
|
|
195 |
<td class="row1">
|
|
196 |
<input id="ebg_chk_show_switcher" type="checkbox" name="show_switcher" <?php echo getConfig('enanium_show_switcher', 1) == '1' ? 'checked="checked" ' : ''; ?>/>
|
|
197 |
</td>
|
|
198 |
</tr>
|
|
199 |
<tr>
|
|
200 |
<td class="row2">
|
|
201 |
<?php echo $lang->get('enaniumbg_acp_field_tile'); ?><br />
|
|
202 |
<small><?php echo $lang->get('enaniumbg_acp_field_tile_hint'); ?></small>
|
|
203 |
</td>
|
|
204 |
<td class="row1">
|
|
205 |
<label>
|
|
206 |
<input type="radio" name="background_repeat" value="repeat" <?php echo getConfig('enanium_background_repeat', 'no-repeat') == 'repeat' ? 'checked="checked" ' : ''; ?>/>
|
|
207 |
<?php echo $lang->get('enaniumbg_acp_field_tile_tile'); ?>
|
|
208 |
</label><br />
|
|
209 |
<label>
|
|
210 |
<input type="radio" name="background_repeat" value="no-repeat" <?php echo getConfig('enanium_background_repeat', 'no-repeat') == 'no-repeat' ? 'checked="checked" ' : ''; ?>/>
|
|
211 |
<?php echo $lang->get('enaniumbg_acp_field_tile_norepeat'); ?>
|
|
212 |
</label>
|
|
213 |
</td>
|
|
214 |
</tr>
|
|
215 |
<tr>
|
|
216 |
<td class="row2">
|
|
217 |
<?php echo $lang->get('enaniumbg_acp_field_scroll'); ?><br />
|
|
218 |
<small><?php echo $lang->get('enaniumbg_acp_field_scroll_hint'); ?></small>
|
|
219 |
</td>
|
|
220 |
<td class="row1">
|
|
221 |
<label>
|
|
222 |
<input type="radio" name="background_attachment" value="fixed" <?php echo getConfig('enanium_background_attachment', 'fixed') == 'fixed' ? 'checked="checked" ' : ''; ?>/>
|
|
223 |
<?php echo $lang->get('enaniumbg_acp_field_scroll_fixed'); ?>
|
|
224 |
</label><br />
|
|
225 |
<label>
|
|
226 |
<input type="radio" name="background_attachment" value="scroll" <?php echo getConfig('enanium_background_attachment', 'fixed') == 'scroll' ? 'checked="checked" ' : ''; ?>/>
|
|
227 |
<?php echo $lang->get('enaniumbg_acp_field_scroll_scroll'); ?>
|
|
228 |
</label>
|
|
229 |
</td>
|
|
230 |
</tr>
|
|
231 |
<tr>
|
|
232 |
<td class="row2">
|
|
233 |
<?php echo $lang->get('enaniumbg_acp_field_anchor'); ?>
|
|
234 |
</td>
|
|
235 |
<td class="row1">
|
|
236 |
<table border="0" style="background-color: transparent; width: 120px; padding: 5px; border: 1px solid #404040;">
|
|
237 |
<?php
|
|
238 |
foreach ( array('top', 'center', 'bottom') as $ypos )
|
|
239 |
{
|
|
240 |
echo '<tr>';
|
|
241 |
foreach ( array('left', 'center', 'right') as $xpos )
|
|
242 |
{
|
|
243 |
?><td style="width: 40px; line-height: 30px; text-align: center;"><input type="radio" name="background_position" value="<?php echo "$xpos $ypos"; ?>" <?php echo getConfig('enanium_background_position', 'center top') == "$xpos $ypos" ? 'checked="checked" ' : ''; ?>/><?php
|
|
244 |
}
|
|
245 |
echo '</tr>';
|
|
246 |
}
|
|
247 |
?>
|
|
248 |
</table>
|
|
249 |
</td>
|
|
250 |
</tr>
|
|
251 |
<tr>
|
|
252 |
<th class="subhead" colspan="2">
|
|
253 |
<input type="submit" value="<?php echo $lang->get('etc_save_changes'); ?>" />
|
|
254 |
</th>
|
|
255 |
</tr>
|
|
256 |
</table>
|
|
257 |
</div>
|
|
258 |
</form>
|
|
259 |
<?php
|
|
260 |
}
|
|
261 |
|
0
|
262 |
/**!language**
|
|
263 |
<code>
|
|
264 |
{
|
|
265 |
eng: {
|
|
266 |
categories: ['meta', 'enaniumbg'],
|
|
267 |
strings: {
|
|
268 |
meta: {
|
|
269 |
enaniumbg: 'Enanium backgrounds',
|
|
270 |
},
|
|
271 |
enaniumbg: {
|
|
272 |
default: 'Default',
|
|
273 |
aqua: 'Aqua',
|
|
274 |
blinds: 'Blinds',
|
|
275 |
dune: 'Dune',
|
|
276 |
freshflower: 'Fresh flower',
|
|
277 |
garden: 'Garden',
|
|
278 |
greenmeadow: 'Greenmeadow',
|
|
279 |
ladybird: 'Ladybird',
|
|
280 |
raindrops: 'Raindrops',
|
|
281 |
storm: 'Storm',
|
|
282 |
twowings: 'Two Wings',
|
|
283 |
wood: 'Wood',
|
1
|
284 |
yellowflower: 'Yellow flower',
|
|
285 |
|
|
286 |
acp_th: 'Enanium background configuration',
|
|
287 |
acp_field_default_bg: 'Default background:',
|
|
288 |
acp_field_default_bg_hint: '<b>Tip:</b> You can add more backgrounds to Enanium! Upload a JPEG image to plugins/enaniumbg/. Then, upload a 16x16 icon of the image, with the same filename, to plugins/enaniumbg/icons/. The plugin will automatically add the image to the list here and to the switcher, if enabled.',
|
|
289 |
acp_field_show_switcher: 'Show background switcher:',
|
|
290 |
acp_field_show_switcher_hint: 'If the switcher is turned off, the background selected above will always be used.',
|
|
291 |
|
|
292 |
acp_field_tile: 'Allow background to be tiled:',
|
|
293 |
acp_field_tile_hint: 'If this is off, the background will be letterboxed and/or pillarboxed if the screen is too small.',
|
|
294 |
acp_field_tile_tile: 'Tile',
|
|
295 |
acp_field_tile_norepeat: 'Don\'t tile',
|
|
296 |
|
|
297 |
acp_field_scroll: 'Scroll background image with page:',
|
|
298 |
acp_field_scroll_hint: 'This may produce undesired results if "%this.enaniumbg_acp_field_tile_norepeat%" is selected.',
|
|
299 |
acp_field_scroll_fixed: 'Background fixed and always in view',
|
|
300 |
acp_field_scroll_scroll: 'Scroll background',
|
|
301 |
|
|
302 |
acp_field_anchor: 'Background position anchor:',
|
|
303 |
|
|
304 |
acp_msg_changes_saved: 'Your changes have been saved.',
|
|
305 |
acppage: 'Enanium configuration',
|
0
|
306 |
}
|
|
307 |
}
|
|
308 |
}
|
|
309 |
}
|
|
310 |
</code>
|
|
311 |
**!*/
|
|
312 |
|