plugins/EnaniumBackgrounds.php
changeset 2 178d22e361d6
parent 1 b69d36dc637e
child 3 f0a844799a0c
equal deleted inserted replaced
1:b69d36dc637e 2:178d22e361d6
    13 // $plugins->attachHook('enanium_search_form', 'enanium_paint_bg_controls();');
    13 // $plugins->attachHook('enanium_search_form', 'enanium_paint_bg_controls();');
    14 $plugins->attachHook('enanium_main_header', 'enanium_paint_bg_controls();');
    14 $plugins->attachHook('enanium_main_header', 'enanium_paint_bg_controls();');
    15 $plugins->attachHook('compile_template', 'enanium_add_headers();');
    15 $plugins->attachHook('compile_template', 'enanium_add_headers();');
    16 $plugins->attachHook('acl_rule_init', '$this->addAdminNode("adm_cat_appearance", "enaniumbg_acppage", "EnaniumConfig", scriptPath . "/plugins/enaniumbg/icons/garden.png");');
    16 $plugins->attachHook('acl_rule_init', '$this->addAdminNode("adm_cat_appearance", "enaniumbg_acppage", "EnaniumConfig", scriptPath . "/plugins/enaniumbg/icons/garden.png");');
    17 
    17 
    18 $ebg_images = array('default', 'aqua', 'blinds', 'dune', 'freshflower', 'garden', 'greenmeadow', 'ladybird', 'raindrops', 'storm', 'twowings', 'wood', 'yellowflower');
    18 $ebg_system_images = array('default', 'aqua', 'blinds', 'dune', 'freshflower', 'garden', 'greenmeadow', 'ladybird', 'raindrops', 'storm', 'twowings', 'wood', 'yellowflower');
       
    19 $ebg_images = array();
    19 
    20 
    20 $ebg_outsiders = array();
    21 $ebg_outsiders = array();
    21 if ( $dr = @opendir(ENANO_ROOT . '/plugins/enaniumbg') )
    22 if ( $dr = @opendir(ENANO_ROOT . '/plugins/enaniumbg') )
    22 {
    23 {
    23   while ( $dh = @readdir($dr) )
    24   while ( $dh = @readdir($dr) )
    28     if ( !preg_match('/\.jpg$/', $dh) )
    29     if ( !preg_match('/\.jpg$/', $dh) )
    29       continue;
    30       continue;
    30     
    31     
    31     $dh = preg_replace('/\.jpg$/', '', $dh);
    32     $dh = preg_replace('/\.jpg$/', '', $dh);
    32     
    33     
    33     if ( in_array($dh, $ebg_images) )
    34     if ( in_array($dh, $ebg_system_images) )
       
    35     {
       
    36       $ebg_images[] = $dh;
    34       continue;
    37       continue;
       
    38     }
    35     
    39     
    36     if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/icons/$dh.png") )
    40     if ( !file_exists(ENANO_ROOT . "/plugins/enaniumbg/icons/$dh.png") )
    37       continue;
    41       continue;
    38     
    42     
    39     $ebg_outsiders[] = $dh;
    43     $ebg_outsiders[] = $dh;
    42 }
    46 }
    43 unset($dh, $dr);
    47 unset($dh, $dr);
    44 
    48 
    45 function enanium_paint_bg_controls()
    49 function enanium_paint_bg_controls()
    46 {
    50 {
    47   global $ebg_images, $ebg_outsiders;
    51   global $ebg_system_images, $ebg_images, $ebg_outsiders;
    48   global $lang;
    52   global $lang;
    49   
    53   
    50   if ( !getConfig('enanium_show_switcher', 1) )
    54   if ( !getConfig('enanium_show_switcher', 1) )
    51     return;
    55     return;
    52   
    56   
    53   ?>
    57   ?>
    54   <div id="enanium_bg_list">
    58   <div id="enanium_bg_list">
    55     <?php
    59     <?php
    56     foreach ( $ebg_images as $i => $image )
    60     foreach ( $ebg_system_images as $i => $image )
    57     {
    61     {
       
    62       if ( !in_array($image, $ebg_images) )
       
    63         continue;
       
    64       
    58       $sel = ( $image == getConfig('enanium_bg', 'default') ) ? ' class="selected"' : '';
    65       $sel = ( $image == getConfig('enanium_bg', 'default') ) ? ' class="selected"' : '';
    59       echo '<a' . $sel . ' href="#bg:' . $image . '" id="ebg_' . $image . '" onclick="enanium_change_bg(\'' . $image . '\', this); return false;" title="' . $lang->get('enaniumbg_' . $image) . '">';
    66       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);
    67       echo enanium_generate_sprite(scriptPath . '/plugins/enaniumbg/icons/sprite.png', 16, 16, 0, $i * 16);
    61       echo '</a>';
    68       echo '</a>';
    62     }
    69     }