# HG changeset patch
# User Dan
# Date 1241974402 14400
# Node ID b69d36dc637e59dbeb4a102377d4517e94ccbcf1
# Parent e8db3e01769120985da5fd51b83e39b22b628fe9
Added several configurability features.
diff -r e8db3e017691 -r b69d36dc637e plugins/EnaniumBackgrounds.php
--- a/plugins/EnaniumBackgrounds.php Fri Apr 17 00:02:18 2009 -0400
+++ b/plugins/EnaniumBackgrounds.php Sun May 10 12:53:22 2009 -0400
@@ -13,6 +13,7 @@
// $plugins->attachHook('enanium_search_form', 'enanium_paint_bg_controls();');
$plugins->attachHook('enanium_main_header', 'enanium_paint_bg_controls();');
$plugins->attachHook('compile_template', 'enanium_add_headers();');
+$plugins->attachHook('acl_rule_init', '$this->addAdminNode("adm_cat_appearance", "enaniumbg_acppage", "EnaniumConfig", scriptPath . "/plugins/enaniumbg/icons/garden.png");');
$ebg_images = array('default', 'aqua', 'blinds', 'dune', 'freshflower', 'garden', 'greenmeadow', 'ladybird', 'raindrops', 'storm', 'twowings', 'wood', 'yellowflower');
@@ -21,14 +22,17 @@
{
while ( $dh = @readdir($dr) )
{
- if ( $dh == '.' || $dh == '..' || is_dir(ENANO_ROOT . "/plugins/enaniumbg/$dr") )
+ if ( $dh == '.' || $dh == '..' || is_dir(ENANO_ROOT . "/plugins/enaniumbg/$dh") )
continue;
- if ( in_array($dh, $ebg_images) || !preg_match('/\.jpg$/', $dh) )
+ if ( !preg_match('/\.jpg$/', $dh) )
continue;
$dh = preg_replace('/\.jpg$/', '', $dh);
+ if ( in_array($dh, $ebg_images) )
+ continue;
+
if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/icons/$dh.png") )
continue;
@@ -43,16 +47,26 @@
global $ebg_images, $ebg_outsiders;
global $lang;
+ if ( !getConfig('enanium_show_switcher', 1) )
+ return;
+
?>
theme != 'enanium' )
return;
- $template->add_header('');
- $template->add_header('');
+ $repeat = getConfig('enanium_background_repeat', 'no-repeat');
+ $attachment = getConfig('enanium_background_attachment', 'fixed');
+ $position = getConfig('enanium_background_position', 'center top');
+
+ if ( getConfig('enanium_show_switcher', 1) )
+ {
+ $template->add_header('');
+
+ $addheader = <<
+ var enanium_bg_repeat = '$repeat';
+ var enanium_bg_attachment = '$attachment';
+ var enanium_bg_position = '$position';
+
+EOF;
+ $template->add_header($addheader);
+ $template->add_header('');
+ }
+
+ if ( ($img = getConfig('enanium_bg', 'default')) !== 'default' )
+ {
+ if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/$img.jpg") )
+ return;
+
+ $scriptpath = scriptPath;
+ $addheader = <<
+ body {
+ background-image: url({$scriptpath}/plugins/enaniumbg/{$img}.jpg);
+ background-color: #000000;
+ background-repeat: $repeat;
+ background-attachment: $attachment;
+ background-position: $position;
+ }
+ td#cell-content {
+ background-color: transparent;
+ background-image: url({$scriptpath}/plugins/enaniumbg/transw70.png);
+ }
+
+EOF;
+ $template->add_header($addheader);
+ }
}
function enanium_generate_sprite($sprite, $width, $height, $start_x, $start_y)
@@ -77,6 +132,133 @@
return '';
}
+function page_Admin_EnaniumConfig()
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ global $lang;
+
+ if ( isset($_POST['enanium_bg']) )
+ {
+ $bg = $_POST['enanium_bg'];
+ if ( file_exists(ENANO_ROOT . "/plugins/enaniumbg/$bg.jpg") )
+ setConfig('enanium_bg', $bg);
+
+ $val = isset($_POST['show_switcher']) ? '1' : '0';
+ setConfig('enanium_show_switcher', $val);
+
+ setConfig('enanium_background_repeat', $_POST['background_repeat']);
+ setConfig('enanium_background_attachment', $_POST['background_attachment']);
+ setConfig('enanium_background_position', $_POST['background_position']);
+
+ echo '' . $lang->get('enaniumbg_acp_msg_changes_saved') . '
';
+ }
+
+ acp_start_form();
+ ?>
+
+
+
{
@@ -99,7 +281,28 @@
storm: 'Storm',
twowings: 'Two Wings',
wood: 'Wood',
- yellowflower: 'Yellow flower'
+ yellowflower: 'Yellow flower',
+
+ acp_th: 'Enanium background configuration',
+ acp_field_default_bg: 'Default background:',
+ acp_field_default_bg_hint: 'Tip: 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.',
+ acp_field_show_switcher: 'Show background switcher:',
+ acp_field_show_switcher_hint: 'If the switcher is turned off, the background selected above will always be used.',
+
+ acp_field_tile: 'Allow background to be tiled:',
+ acp_field_tile_hint: 'If this is off, the background will be letterboxed and/or pillarboxed if the screen is too small.',
+ acp_field_tile_tile: 'Tile',
+ acp_field_tile_norepeat: 'Don\'t tile',
+
+ acp_field_scroll: 'Scroll background image with page:',
+ acp_field_scroll_hint: 'This may produce undesired results if "%this.enaniumbg_acp_field_tile_norepeat%" is selected.',
+ acp_field_scroll_fixed: 'Background fixed and always in view',
+ acp_field_scroll_scroll: 'Scroll background',
+
+ acp_field_anchor: 'Background position anchor:',
+
+ acp_msg_changes_saved: 'Your changes have been saved.',
+ acppage: 'Enanium configuration',
}
}
}
diff -r e8db3e017691 -r b69d36dc637e plugins/enaniumbg/enaniumbg.js
--- a/plugins/enaniumbg/enaniumbg.js Fri Apr 17 00:02:18 2009 -0400
+++ b/plugins/enaniumbg/enaniumbg.js Sun May 10 12:53:22 2009 -0400
@@ -11,16 +11,16 @@
body.style.backgroundImage = 'url(' + cdnPath + '/themes/enanium/images/background.gif)';
body.style.backgroundRepeat = 'repeat';
body.style.backgroundAttachment = 'scroll';
- cw.style.backgroundImage = null;
+ cw.style.backgroundImage = 'none';
cw.style.backgroundColor = '#ffffff';
}
else
{
- body.style.backgroundRepeat = 'no-repeat';
- body.style.backgroundPosition = 'center top';
+ body.style.backgroundRepeat = enanium_bg_repeat;
+ body.style.backgroundAttachment = enanium_bg_attachment;
+ body.style.backgroundPosition = enanium_bg_position;
body.style.backgroundColor = '#000000';
body.style.backgroundImage = 'url(' + scriptPath + '/plugins/enaniumbg/' + image + '.jpg)';
- body.style.backgroundAttachment = 'fixed';
cw.style.backgroundImage = 'url(' + scriptPath + '/plugins/enaniumbg/transw70.png)';
cw.style.backgroundColor = 'transparent';
}