Help Control functions | > Module written by Matt Mecham | > Date started: 2nd April 2002 | | > Module Version Number: 1.0.0 | > DBA Checked: Tue 25th May 2004 +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_ACP' ) ) { print "

Incorrect access

You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'."; exit(); } class ad_stylesets { var $base_url; var $master_set = 1; function auto_run() { global $ibforums, $DB, $std; //----------------------------------------- // Kill globals - globals bad, Homer good. //----------------------------------------- $tmp_in = array_merge( $_GET, $_POST, $_COOKIE ); foreach ( $tmp_in as $k => $v ) { unset($$k); } //----------------------------------------- switch($ibforums->input['code']) { case 'wrapper': $this->list_wrappers(); break; case 'addset': $this->add_set(); break; case 'edit': $this->do_form('edit'); break; case 'doedit': $this->save_skin('edit'); break; case 'remove': $this->remove_splash(); break; case 'doremove': $this->do_remove(); break; //----------------------------------------- case 'export': $this->export(); break; case 'revertallform': $this->revert_all_form(); break; case 'dorevert': $this->do_revert_all(); break; case 'toggledefault': $this->set_toggle_default(); break; case 'togglevisible': $this->set_toggle_visible(); break; //----------------------------------------- // Export master //----------------------------------------- case 'exportmaster': $this->export_master(); break; case 'exportmacro': $this->export_macro(); break; //----------------------------------------- // Rebuild all //----------------------------------------- case 'rebuildalltemplates': $this->rebuild_all_templates(); break; //----------------------------------------- // Export bits //----------------------------------------- case 'exportbitschoose': $this->export_bits_choose(); break; case 'exportbitscomplete': $this->export_bits_complete(); break; default: $this->list_sets(); break; } } /*-------------------------------------------------------------------------*/ // EXPORT SOME TEMPLATE BITS TO SQL FILE (COMPLETE) /*-------------------------------------------------------------------------*/ function export_bits_complete() { global $ibforums, $DB, $std; $ids = array(); //----------------------------------------- // get ids... //----------------------------------------- foreach ($ibforums->input as $key => $value) { if ( preg_match( "/^id_(\d+)$/", $key, $match ) ) { if ($ibforums->input[$match[0]]) { $ids[] = $match[1]; } } } //----------------------------------------- // Got any? //----------------------------------------- if ( ! count( $ids ) ) { $ibforums->main_msg = "You must select SOME template bits to export!"; $this->export_bits_choose(); } $final_sql = ""; $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_templates', 'where' => 'suid IN ('.implode(",",$ids).')' ) ); $DB->simple_exec(); while( $r = $DB->fetch_row() ) { $content = preg_replace( "/'/", "\\'", $std->txt_safeslashes( $r['section_content'] ) ); $datavar = preg_replace( "/'/", "\\'", $std->txt_safeslashes( $r['func_data'] ) ); $content = str_replace( "\n", '\n', $content ); $final_sql .= "REPLACE INTO ibf_skin_templates SET set_id=1, group_name='{$r['group_name']}', func_name='{$r['func_name']}', section_content='$content', func_data='$datavar';\n"; } //@header("Content-type: text/plain"); //print $final_sql; //exit(); //----------------------------------------- // Print to browser //----------------------------------------- $ibforums->admin->show_download( $final_sql, 'templates_update.sql', '', 0 ); } /*-------------------------------------------------------------------------*/ // EXPORT SOME TEMPLATE BITS TO SQL FILE /*-------------------------------------------------------------------------*/ function export_bits_choose() { global $ibforums, $DB, $std; $all_templates = array(); $DB->simple_construct( array( 'select' => 'group_name,set_id,suid,func_name', 'from' => 'skin_templates', 'where' => 'set_id=1' ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $all_templates[ $r['group_name'] ][] = $r; } ksort( $all_templates ); //----------------------------------------- // Start output //----------------------------------------- $ibforums->admin->page_title = "Export Selected Template bits"; $ibforums->admin->page_detail = "Check the box of the bit you wish to export."; //----------------------------------------- // start form //----------------------------------------- $per_row = 3; $td_width = 100 / $per_row; $count = 0; $output = "\n"; $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code' , 'exportbitscomplete' ), 2 => array( 'act' , 'sets' ), ) ); $ibforums->html .= "
Template Bits
"; foreach( $all_templates as $group_name => $data ) { //----------------------------------------- // Start secondary table //----------------------------------------- $count = 0; $output .= "
$group_name
"; foreach( $all_templates[ $group_name ] as $r ) { $count++; $class = $count == 2 ? 'tdrow2' : 'tdrow1'; $output .= ""; if ($count == $per_row ) { $output .= "\n\n"; $count = 0; } } if ( $count > 0 and $count != $per_row ) { for ($i = $count ; $i < $per_row ; ++$i) { $output .= "\n"; } $output .= ""; } $output .= "\n
{$r['func_name']}
 
"; } $ibforums->html .= $output; $ibforums->html .= "
"; $ibforums->admin->output(); } /*-------------------------------------------------------------------------*/ // REBUILD TEMPLATES /*-------------------------------------------------------------------------*/ function rebuild_all_templates() { global $ibforums, $DB, $std; if ( $ibforums->input['removewarning'] == 1 ) { $DB->simple_exec_query( array( "delete" => "cache_store", "where" => "cs_key='skinpanic'" ) ); } $justdone = intval($ibforums->input['justdone']); $justdone = $justdone ? $justdone : 1; //----------------------------------------- // Get skins //----------------------------------------- $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id > '.$justdone, 'order' => 'set_skin_set_id', 'limit' => array( 0, 1 ) ) ); $DB->simple_exec(); //----------------------------------------- // Got a biggun? //----------------------------------------- $r = $DB->fetch_row(); if ( $r['set_skin_set_id'] ) { $ibforums->cache_func->_rebuild_all_caches( array($r['set_skin_set_id']) ); $ibforums->admin->redirect( "act=sets&code=rebuildalltemplates&justdone={$r['set_skin_set_id']}", "Rebuilt cache for skin set {$r['set_name']}
Proceeding to the next skin..." ); } else { $ibforums->main_msg = "All skin templates recached!"; $this->list_sets(); } } //----------------------------------------- // Export master skin set. //----------------------------------------- function export_master() { global $ibforums, $DB, $std; //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); //----------------------------------------- // Start... //----------------------------------------- $xml->xml_set_root( 'templateexport', array( 'exported' => time(), 'versionid' => '20000', 'type' => 'master' ) ); //----------------------------------------- // Get emo group //----------------------------------------- $xml->xml_add_group( 'templategroup' ); $DB->simple_construct( array( 'select' => 'group_name, section_content, func_name, func_data', 'from' => 'skin_templates', 'where' => 'set_id=1' ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $content = array(); foreach ( $r as $k => $v ) { $content[] = $xml->xml_build_simple_tag( $k, $v ); } $entry[] = $xml->xml_build_entry( 'template', $content ); } $xml->xml_add_entry_to_group( 'templategroup', $entry ); $xml->xml_format_document(); //----------------------------------------- // Send to browser. //----------------------------------------- $ibforums->admin->show_download( $xml->xml_document, 'ipb_templates.xml', '', 0 ); } //----------------------------------------- // Export master macros //----------------------------------------- function export_macro() { global $ibforums, $DB, $std; //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require( KERNEL_PATH.'class_xml.php' ); $xml = new class_xml(); //----------------------------------------- // Start... //----------------------------------------- $xml->xml_set_root( 'macroexport', array( 'exported' => time() ) ); //----------------------------------------- // Get emo group //----------------------------------------- $xml->xml_add_group( 'macrogroup' ); $DB->simple_construct( array( 'select' => 'macro_value,macro_replace', 'from' => 'skin_macro', 'where' => 'macro_set=1' ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $content = array(); foreach ( $r as $k => $v ) { $content[] = $xml->xml_build_simple_tag( $k, $v ); } $entry[] = $xml->xml_build_entry( 'macro', $content ); } $xml->xml_add_entry_to_group( 'macrogroup', $entry ); $xml->xml_format_document(); //----------------------------------------- // Send to browser. //----------------------------------------- $ibforums->admin->show_download( $xml->xml_document, 'ipb_macro.xml', '', 0 ); } //----------------------------------------- // ADD SET //----------------------------------------- function add_set() { global $ibforums, $DB, $std; //----------------------------------------- // Check for input //----------------------------------------- $new = array(); $message = array(); if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = "You cannot alter the master skin set"; $this->list_sets(); } if ( ! $ibforums->input['set_name'] ) { $ibforums->main_msg = "You must enter a skin set name."; $this->list_sets(); } if ( $ibforums->input['id'] == -1 ) { //----------------------------------------- // No parent... //----------------------------------------- $new['set_skin_set_parent'] = -1; $get_from_db = 1; } else { $new['set_skin_set_parent'] = $ibforums->input['id']; $get_from_db = $ibforums->input['id']; } $this_set = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$get_from_db ) ); $new['set_name'] = $ibforums->input['set_name']; $new['set_image_dir'] = $this_set['set_image_dir']; $new['set_hidden'] = $ibforums->input['hidden']; $new['set_default'] = 0; $new['set_css_method'] = $this_set['set_css_method']; $new['set_cache_css'] = $this_set['set_cache_css']; $new['set_cache_macro'] = $this_set['set_cache_macro']; $new['set_cache_wrapper'] = $this_set['set_cache_wrapper']; $DB->do_insert( 'skin_sets', $new ); $newid = $DB->get_insert_id(); //----------------------------------------- // Rebuild caches //----------------------------------------- $ibforums->cache_func->_rebuild_all_caches( array( $newid ) ); $ibforums->main_msg = 'Skin Set Added'; $ibforums->main_msg .= "
".implode("
", array_merge( $message, $ibforums->cache_func->messages) ); $this->list_sets(); } //----------------------------------------- // Revert customizations > DO //----------------------------------------- function do_revert_all() { global $ibforums, $DB, $std; //----------------------------------------- // Check for input //----------------------------------------- $message = array(); if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = "You cannot alter the master skin set"; $this->list_sets(); } $id = intval($ibforums->input['id']); //----------------------------------------- // Delete Templates? //----------------------------------------- if ( $ibforums->input['html'] ) { $DB->simple_exec_query( array( 'delete' => 'skin_templates', 'where' => 'set_id='.$id ) ); $message[] = 'Removed all custom HTML template bits...'; } //----------------------------------------- // Delete Macros? //----------------------------------------- if ( $ibforums->input['macro'] ) { $DB->simple_exec_query( array( 'delete' => 'skin_macro', 'where' => 'macro_set='.$id ) ); $message[] = 'Removed all custom replacement macros...'; } //----------------------------------------- // Delete Wrapper //----------------------------------------- if ( $ibforums->input['wrapper'] ) { $DB->simple_exec_query( array( 'update' => 'skin_sets', 'set' => "set_wrapper=''", 'where' => 'set_skin_set_id='.$id ) ); $message[] = 'Removed custom wrapper...'; } //----------------------------------------- // Delete Wrapper //----------------------------------------- if ( $ibforums->input['css'] ) { $DB->simple_exec_query( array( 'update' => 'skin_sets', 'set' => "set_css=''", 'where' => 'set_skin_set_id='.$id ) ); $message[] = 'Removed custom CSS...'; } //----------------------------------------- // Rebuild caches //----------------------------------------- $ibforums->cache_func->_rebuild_all_caches( array( $id ) ); $ibforums->main_msg = 'Skin set customizations removed'; $ibforums->main_msg .= "
".implode("
", array_merge( $message, $ibforums->cache_func->messages) ); $this->list_sets(); } //----------------------------------------- // Revert customizations form //----------------------------------------- function revert_all_form() { global $ibforums, $DB, $std; $templates = 0; $macros = 0; //----------------------------------------- // Check for input //----------------------------------------- if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = "You cannot alter the master skin set"; $this->list_sets(); } $ibforums->admin->page_detail = "Please note that this change cannot be undone!"; $ibforums->admin->page_title = "Revert Skin Set Customizations"; //----------------------------------------- // Get macro / template info //----------------------------------------- $DB->simple_construct( array( 'select' => 'count(*) as aerosmith', 'from' => 'skin_templates', 'where' => "set_id={$ibforums->input['id']}" ) ); $DB->simple_exec(); $r = $DB->fetch_row(); $templates = intval($r['aerosmith']); $DB->simple_construct( array( 'select' => 'count(*) as aerosmith', 'from' => 'skin_macro', 'where' => "macro_set={$ibforums->input['id']}" ) ); $DB->simple_exec(); $r = $DB->fetch_row(); $macros = intval($r['aerosmith']); //----------------------------------------- // Get the thingies //----------------------------------------- $this_set = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => "set_skin_set_id=".$ibforums->input['id'] ) ); //----------------------------------------- // Start the form //----------------------------------------- $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code', 'dorevert' ), 2 => array( 'act' , 'sets' ), 3 => array( 'id' , $ibforums->input['id'] ), ), "theAdminForm" ); $none = "No customizations to remove"; $html = $templates ? $ibforums->adskin->form_yes_no('html' , 0) : $none; $macro = $macros ? $ibforums->adskin->form_yes_no('macro' , 0) : $none; $wrapper = $this_set['set_wrapper'] ? $ibforums->adskin->form_yes_no('wrapper', 0) : $none; $css = $this_set['set_css'] ? $ibforums->adskin->form_yes_no('css' , 0) : $none; //----------------------------------------- // Start output //----------------------------------------- $ibforums->html .= "
Reverting Customizations in set {$this_set['set_name']}
Template HTML Customizations
Revert all template bit HTML customizations?
You have {$templates} template customizations
{$html}

Macro Replacement Customizations
Revert all macro customizations?
You have {$macros} macro customizations
{$macro}

Board Header and Footer Wrapper Customizations
Revert Board Header and Footer Wrapper? {$wrapper}

Stylesheet (CSS) Customizations
Revert CSS? {$css}
Please note that all customizations will be lost if set to 'yes'
This cannot be undone and there are no more confirmation screens
"; $ibforums->html .= $ibforums->adskin->end_form_standalone("Process"); //----------------------------------------- // Output //----------------------------------------- $ibforums->admin->nav[] = array( 'act=sets' ,'Skin Manager Home' ); $ibforums->admin->nav[] = array( '' ,'Reverting all customizations in set '.$this_set['set_name'] ); $ibforums->admin->output(); } //----------------------------------------- // REMOVE SKIN SET FORM //----------------------------------------- function remove_splash() { global $ibforums, $DB, $std; $ibforums->admin->page_detail = "Please read this page carefully."; $ibforums->admin->page_title = "Removing Skin Set"; //----------------------------------------- // Get this skin set... //----------------------------------------- $this_set = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$ibforums->input['id'] ) ); $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code', 'doremove' ), 2 => array( 'act' , 'sets' ), 3 => array( 'id' , $ibforums->input['id'] ), ) ); $ibforums->adskin->td_header[] = array( " " , "100%" ); $ibforums->html .= $ibforums->adskin->start_table( "Remove Skin Set {$this_set['set_name']}" ); $ibforums->html .= $ibforums->adskin->add_td_row( array( "
PLEASE NOTE: This action cannot be undone

Continuing will permanently remove any customizations to this skin set, including template HTML, CSS, Wrappers and custom macros.

Any children of this skin set will be set as 'root' skins without a parent. ", ) ); $ibforums->html .= $ibforums->adskin->end_form("Permanently Remove Set {$this_set['set_name']}"); $ibforums->html .= $ibforums->adskin->end_table(); $ibforums->admin->output(); } //----------------------------------------- // TOGGLE DEFAULT SKIN //----------------------------------------- function set_toggle_default() { global $ibforums, $DB, $std; $affected_ids = array(); $children = array(); $message = array(); //----------------------------------------- // Check for input //----------------------------------------- if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = 'You cannot alter the master skin set'; $this->list_sets(); } //----------------------------------------- // Set as default //----------------------------------------- $DB->do_update( 'skin_sets', array( 'set_default' => 0 ), "" ); $DB->do_update( 'skin_sets', array( 'set_default' => 1, 'set_hidden' => 0 ), "set_skin_set_id =".$ibforums->input['id'] ); //----------------------------------------- // Rebuild caches and relationships? //----------------------------------------- $ibforums->cache_func->_rebuild_all_caches( array( $ibforums->input['id'] ) ); $ibforums->main_msg = 'Skin set to default'; $this->list_sets(); } //----------------------------------------- // TOGGLE VISIBILITY //----------------------------------------- function set_toggle_visible() { global $ibforums, $DB, $std; $affected_ids = array(); $children = array(); $message = array(); //----------------------------------------- // Check for input //----------------------------------------- if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = 'You cannot alter the master skin set'; $this->list_sets(); } //----------------------------------------- // Get current skin //----------------------------------------- $skin = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$ibforums->input['id'] ) ); $hidden = 1; if ( $skin['set_hidden'] ) { $hidden = 0; } $DB->do_update( 'skin_sets', array( 'set_hidden' => $hidden ), 'set_skin_set_id='.$ibforums->input['id'] ); //----------------------------------------- // Rebuild caches and relationships? //----------------------------------------- $ibforums->cache_func->_rebuild_all_caches( array( $ibforums->input['id'] ) ); $ibforums->main_msg = 'Skin set visibility changed'; $this->list_sets(); } //----------------------------------------- // DO REMOVE SKIN SET //----------------------------------------- function do_remove() { global $ibforums, $DB, $std; $affected_ids = array(); $children = array(); $message = array(); //----------------------------------------- // Check for input //----------------------------------------- if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } if ( $ibforums->input['id'] == 1 ) { $ibforums->main_msg = 'You cannot alter the master skin set'; $this->list_sets(); } //----------------------------------------- // Get this skin set... //----------------------------------------- $this_set = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id='.$ibforums->input['id'] ) ); //----------------------------------------- // Can we remove? //----------------------------------------- if ( $this_set['set_default'] == 1 ) { $ibforums->main_msg = 'IPB cannot remove this skin as it is set as the default skin, please set another skin set to default and try again.'; $this->list_sets(); } $this_count = $DB->simple_exec_query( array( 'select' => 'count(*) as jazzyjeff', 'from' => 'skin_sets' ) ); if ( $this_count['jazzyjeff'] == 2 ) { $ibforums->main_msg = 'IPB cannot remove this skin as it is the last editable skin set you currently have.'; $this->list_sets(); } //----------------------------------------- // Get any children //----------------------------------------- $DB->simple_construct( array( 'select' => 'set_skin_set_id, set_skin_set_parent', 'from' => 'skin_sets', 'where' => "set_skin_set_parent=".$ibforums->input['id']) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $affected_ids[] = $r['set_skin_set_id']; $children[] = $r['set_skin_set_id']; } //----------------------------------------- // Update children to root //----------------------------------------- if ( count($children) ) { $DB->do_update( 'skin_sets', array( 'set_skin_set_parent' => '-1' ), 'set_skin_set_id IN ('.implode(',',$children).')' ); } //----------------------------------------- // Members using this skin? //----------------------------------------- $DB->do_update( 'members', array( 'skin' => '' ), 'skin='.$ibforums->input['id'] ); //----------------------------------------- // Delete the skin... //----------------------------------------- $DB->simple_exec_query( array( 'delete' => 'skin_sets', 'where' => 'set_skin_set_id='.$ibforums->input['id']) ); //----------------------------------------- // Remove macros... //----------------------------------------- $DB->simple_exec_query( array( 'delete' => 'skin_macro', 'where' => 'macro_set='.$ibforums->input['id']) ); //----------------------------------------- // Remove templates... //----------------------------------------- $DB->simple_exec_query( array( 'delete' => 'skin_templates', 'where' => 'set_id='.$ibforums->input['id']) ); //----------------------------------------- // Remove template cache... //----------------------------------------- $DB->simple_exec_query( array( 'delete' => 'skin_templates_cache', 'where' => 'template_set_id='.$ibforums->input['id']) ); //----------------------------------------- // Remove CSS file... //----------------------------------------- @unlink( CACHE_PATH.'style_images/css_'.$ibforums->input['id'].'.css' ); $message[] = 'Clean up: removing CSS cache file...'; //----------------------------------------- // Remove CACHE folder //----------------------------------------- $ibforums->admin->rm_dir( CACHE_PATH.'skin_cache/cacheid_'.$ibforums->input['id'] ); $message[] = 'Clean up: removing HTML templates cache folder...'; //----------------------------------------- // Rebuild caches and relationships? //----------------------------------------- if ( count($affected_ids) ) { $ibforums->cache_func->_rebuild_all_caches($affected_ids); } $ibforums->cache_func->_rebuild_skin_id_cache(); $ibforums->main_msg = 'Skin set removed'; $ibforums->main_msg .= "
".implode("
", array_merge( $message, $ibforums->cache_func->messages) ); $this->list_sets(); } //----------------------------------------- // ADD / EDIT SKIN SETS //----------------------------------------- function save_skin( $type='add' ) { global $ibforums, $DB, $std; //----------------------------------------- // Fix up incoming //----------------------------------------- //img / prt if ($type == 'edit') { if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } } if ($ibforums->input['set_name'] == "") { $ibforums->admin->error("You must specify a name for this skin pack ID"); } $this_set = $DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => 'set_skin_set_id = '.$ibforums->input['id'] ) ); //----------------------------------------- // Init var //----------------------------------------- $barney = array( 'set_name' => $std->txt_stripslashes($_POST['set_name']), 'set_css_method' => $ibforums->input['set_css_method'], 'set_hidden' => $ibforums->input['set_hidden'], 'set_image_dir' => $ibforums->input['set_image_dir'], 'set_author_email' => $ibforums->input['set_author_email'], 'set_author_url' => $ibforums->input['set_author_url'], 'set_author_name' => $ibforums->input['set_author_name'], 'set_skin_set_parent' => $ibforums->input['set_skin_set_parent'], 'set_emoticon_folder' => $ibforums->input['set_emoticon_folder'], ); if ($type == 'add') { } else { //----------------------------------------- // Did we set it to default? //----------------------------------------- if ( $ibforums->input['set_default'] ) { $DB->do_update( 'skin_sets', array( 'set_default' => 0 ), 'set_skin_set_id <> '.$ibforums->input['id'] ); $barney['set_default'] = 1; } //----------------------------------------- // Did the parent change? //----------------------------------------- $affected_ids = array(); if ( $ibforums->input['prt'] != $ibforums->input['set_skin_set_parent'] ) { $affected_ids[ $this_set['set_skin_set_id'] ] = $this_set['set_skin_set_id']; //----------------------------------------- // Any kids? //----------------------------------------- $children = array(); $child_id = array(); $DB->simple_construct( array( 'select' => 'set_skin_set_id', 'from' => 'skin_sets', 'where' => 'set_skin_set_parent='.$this_set['set_skin_set_id'] ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $children[] = $r; $child_id[] = $r['set_skin_set_id']; $affected_ids[ $r['set_skin_set_id'] ] = $r['set_skin_set_id']; } if ( count($children) ) { //----------------------------------------- // Move children to direct root children //----------------------------------------- $DB->simple_exec_query( array( 'update' => 'skin_sets', 'set' => 'set_skin_set_parent = -1', 'where' => 'set_skin_set_id IN ('.implode(",",$child_id).')' ) ); } } if ( $ibforums->input['css'] != $ibforums->input['set_css_method'] ) { if ( $ibforums->input['set_css_method'] ) { //----------------------------------------- // Caching switched on... //----------------------------------------- $affected_ids[ $this_set['set_skin_set_id'] ] = $this_set['set_skin_set_id']; } } //----------------------------------------- // Img dir changed? recache css //----------------------------------------- if ( $ibforums->input['img'] != $ibforums->input['set_image_dir'] ) { $affected_ids[ $this_set['set_skin_set_id'] ] = $this_set['set_skin_set_id']; } $DB->do_update( 'skin_sets', $barney, "set_skin_set_id=".$ibforums->input['id'] ); //----------------------------------------- // Rebuild caches and relationships? //----------------------------------------- $ibforums->cache_func->_rebuild_all_caches($affected_ids); $ibforums->main_msg = 'Skin Settings Updated'; $ibforums->main_msg .= "
".implode("
", $ibforums->cache_func->messages); $ibforums->admin->done_screen("Skin Set Updated", "Manage Skin Sets", "act=sets", 'redirect' ); } } //----------------------------------------- // ADD / EDIT SETS //----------------------------------------- function do_form( $type='add' ) { global $ibforums, $DB, $std; //----------------------------------------- // Check for input //----------------------------------------- $sets = array(); $parents = array( 0=> array( '-1', 'No parent' ) ); $row = array(); if ($ibforums->input['id'] == "") { $ibforums->admin->error("You must specify an existing skin set ID, go back and try again"); } //----------------------------------------- $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_sets' ) ); $DB->simple_exec(); while ( $r = $DB->fetch_row() ) { $sets[ $r['set_skin_set_id'] ] = $r; if ( ($r['set_skin_set_parent'] < 0 and $r['set_skin_set_id'] != 1 ) and ( $ibforums->input['id'] != $r['set_skin_set_id'] ) ) { $parents[] = array( $r['set_skin_set_id'], $r['set_name'] ); } if ( $ibforums->input['id'] == $r['set_skin_set_id'] ) { $row = $r; } } //----------------------------------------- if ($type == 'add') { $code = 'doadd'; $button = 'Create New Skin Set'; $row['set_name'] = $row['set_name']; $row['set_default'] = 0; } else { $code = 'doedit'; $button = 'Edit Skin Settings'; } //----------------------------------------- // Image dir //----------------------------------------- $dirs = array(); $dh = opendir( CACHE_PATH.'style_images' ); while ( $file = readdir( $dh ) ) { if (($file != ".") && ($file != "..")) { if ( is_dir(CACHE_PATH.'style_images/'.$file) ) { $dirs[] = array( $file, $file ); } } } closedir( $dh ); //----------------------------------------- // Emoticons dir //----------------------------------------- $emodirs = array(); $dh = opendir( CACHE_PATH.'style_emoticons' ); while ( $file = readdir( $dh ) ) { if (($file != ".") && ($file != "..")) { if ( is_dir(CACHE_PATH.'style_emoticons/'.$file) ) { $emodirs[] = array( $file, $file ); } } } closedir( $dh ); if ( is_writeable( CACHE_PATH."style_images" ) ) { $cssextra = $ibforums->adskin->form_yes_no('set_css_method', $row['set_css_method']); } else { $cssextra = "Unavailable, IPB cannot write into your 'style_images' folder"; } //----------------------------------------- $ibforums->admin->page_detail = "Please configure the settings below."; $ibforums->admin->page_title = "Manage Skin Sets"; //----------------------------------------- $ibforums->html .= $ibforums->adskin->start_form( array( 1 => array( 'code', $code ), 2 => array( 'act' , 'sets' ), 3 => array( 'id' , $ibforums->input['id'] ), 4 => array( 'img' , $row['set_image_dir'] ), 5 => array( 'prt' , $row['set_skin_set_parent'] ), 6 => array( 'css' , $row['set_css_method'] ), ), "theAdminForm" ); //----------------------------------------- // Start output //----------------------------------------- $ibforums->html .= "
$button
Basics "; if ( $row['set_default'] ) { $ibforums->html .= ""; } else { $ibforums->html .= ""; } $ibforums->html .= "
Set Title ".$ibforums->adskin->form_input('set_name', $row['set_name'])."
Hide from members? ".$ibforums->adskin->form_yes_no('set_hidden', $row['set_hidden'])."
Set as default skin? Skin set as default already.
Set as default skin? ".$ibforums->adskin->form_checkbox('set_default', $row['set_default'])."
Skin Set Parent? ".$ibforums->adskin->form_dropdown('set_skin_set_parent', $parents, $row['set_skin_set_parent'])."

CSS Options
Cache CSS to text files?
This will reduce the size of the HTML as the CSS will be in a browser cachable file.
".$cssextra."
Warning: Changing this value will re-cache any cached stylesheet information. Please make sure that you have synchronized any cache files with the database.

Image Options
Use image directory?
The image directory will be used in place of <#IMG_DIR#> in CSS and macro replacements.
style_images/ ".$ibforums->adskin->form_dropdown('set_image_dir', $dirs, $row['set_image_dir'])."
Use emoticons set?
Choose which set of emoticons to assign to this skin.
style_emoticons/ ".$ibforums->adskin->form_dropdown('set_emoticon_folder', $emodirs, $row['set_emoticon_folder'])."

Set Author
Set Author Name
*Optional
".$ibforums->adskin->form_input('set_author_name', $row['set_author_name'])."
Set Author Email Address
*Optional
".$ibforums->adskin->form_input('set_author_email', $row['set_author_email'])."
Set Author Website Address
*Optional
".$ibforums->adskin->form_input('set_author_url', $row['set_author_url'])."
"; //----------------------------------------- $ibforums->html .= $ibforums->adskin->end_form_standalone($button); //----------------------------------------- $ibforums->admin->output(); } //----------------------------------------- // SHOW ALL SKIN SETS //----------------------------------------- function list_sets() { global $ibforums, $DB, $std; $form_array = array(); $this_set = ""; $forums = array(); $forum_skins = array(); $macro_array = array(); $template_array = array(); $ibforums->admin->page_detail = "Simply click on the title of the skin set you wish to edit and select from one of the options from the pop-up menu."; $ibforums->admin->page_title = "Manage Skin Sets"; //----------------------------------------- // Get forum names //----------------------------------------- $DB->simple_construct( array( 'select' => 'id, name, skin_id', 'from' => 'forums' ) ); $DB->simple_exec(); while ( $f = $DB->fetch_row() ) { $forums[ $f['id'] ] = $f['name']; if ( $f['skin_id'] != "") { $forum_skins[ $f['skin_id'] ][] = $f['name']; } } //----------------------------------------- // Get macro / template info //----------------------------------------- $DB->cache_add_query( 'stylesets_list_sets_templates', array() ); $DB->cache_exec_query(); while ( $r = $DB->fetch_row() ) { $template_array[ $r['set_id'] ] = 1; } $DB->cache_add_query( 'stylesets_list_sets_macros', array() ); $DB->cache_exec_query(); while ( $r = $DB->fetch_row() ) { $macro_array[ $r['macro_set'] ] = 1; } //----------------------------------------- // Start of HTML Output //----------------------------------------- $ibforums->html .= "
Skin Sets  
"; $ibforums->html .= "
\n
\n"; //----------------------------------------- // GET SKINS //----------------------------------------- $skin_sets = array(); $last_id = 0; $default_skin = ""; $DB->simple_construct( array( 'select' => '*', 'from' => 'skin_sets', 'order' => 'set_skin_set_parent, set_skin_set_id ASC' ) ); $DB->simple_exec(); $no_sets = 0; $i_sets = 0; while ( $row = $DB->fetch_row() ) { $skins[ $row['set_skin_set_id'] ] = $row; if ( $row['set_skin_set_parent'] == -1 ) { $no_sets++; } } //----------------------------------------- // Loop-de-loop //----------------------------------------- foreach( $skins as $r ) { $i_sets++; $skin_sets[ $r['set_skin_set_id'] ] = $r; $skin_sets[ $r['set_skin_set_parent'] ]['_lastid'] = $r['set_skin_set_id']; $skin_sets[ $r['set_skin_set_parent'] ]['_children'][] = $r['set_skin_set_id']; $extra = ""; $forums = "Not used in forums"; //----------------------------------------- // Used in forums? //----------------------------------------- if ( is_array($forum_skins[ $r['set_skin_set_id'] ]) ) { if ( count($forum_skins[ $r['set_skin_set_id'] ]) > 0 ) { $extra = "Used in forums:".implode( ",", $forum_skins[ $r['set_skin_set_id'] ] ); $forums = ""; } } $this->unaltered = "- "; $this->altered = "+ "; $this->inherited = "| "; //----------------------------------------- // Default / Hidden? //----------------------------------------- $div_start = "
 "; $default = "Not Default"; $hidden = "visible"; $folder_icon = 'skin_folder.gif'; $menu_text = "Root Skin"; $remove_set = "Remove Skin Set..."; $restore_all = ""; $margin_left = '40'; $css_extra = ""; $newskin = ""; //----------------------------------------- // Child of master, middle skin // or last skin? //----------------------------------------- if ( $i_sets >= $no_sets ) { $line_image = " "; } else { $line_image = " "; } //----------------------------------------- // Hidden? //----------------------------------------- if ($r['set_hidden'] == 1) { $hidden = "Invisible"; $folder_icon = 'skin_folder_hidden.gif'; $css_extra = 'color:#7F7FAA'; } //----------------------------------------- // Default? //----------------------------------------- if ($r['set_default'] == 1) { $default = "Not Default"; $default_skin = $r['set_name']; } //----------------------------------------- // IPB Master? //----------------------------------------- if ( $r['set_skin_set_id'] == 1 ) { $remove_set = ""; $folder_icon = 'skin_folder_master.gif'; $menu_text = "Master"; $margin_left = '20'; $line_image = ""; $css_extra = "color:gray"; $hidden = ""; $default = ""; $forums = ""; $export_button = ""; } else { //----------------------------------------- // Not.. //----------------------------------------- $export_button = $ibforums->adskin->js_make_button( 'Export', "{$ibforums->adskin->base_url}&act=import&code=showexportpage&id={$r['set_skin_set_id']}", "realdarkbutton", "Export skin set" ); $restore_all = "
 Revert All Skin Customizations...
"; if ( $r['set_skin_set_parent'] >= 0 ) { //----------------------------------------- // Child though... //----------------------------------------- if ( $folder_icon != 'skin_folder_hidden.gif' ) { $folder_icon = 'skin_folder_children.gif'; } $menu_text = "Child's"; $margin_left = '70'; $line_image = ""; } else { $newskin = "
 Add New Child Skin Set...
"; } } //----------------------------------------- // Skin opts //----------------------------------------- $menulist = " $div_startEdit $menu_text Template HTML
$div_startEdit $menu_text Stylesheet (CSS Advanced Mode)
$div_startEdit $menu_text Colours (CSS Easy Mode)
$div_startEdit $menu_text Replacement Macros
 Edit Settings...
{$restore_all} {$newskin}
 {$remove_set}
"; } $menulist .= ""; //----------------------------------------- // Add skin row //----------------------------------------- $skin_sets[ $r['set_skin_set_id'] ]['_html'] = "
{$line_image}  ".$std->txt_stripslashes($r['set_name'])."$menulist $forums $hidden $default ". $export_button ."
"; $form_array[] = array( $r['set_skin_set_id'], $r['set_name'] ); } //header("content-type: text/plain"); print_r($skin_sets); exit(); //----------------------------------------- // Show root forums //----------------------------------------- foreach( $skin_sets as $id => $data ) { if ( $data['set_skin_set_parent'] == -1 ) { $wrapper_icon = $this->_get_status_of_parent( $data['set_wrapper'] ); $css_icon = $this->_get_status_of_parent( $data['set_css'] ); $templates_icon = $this->_get_status_of_parent( $template_array[ $data['set_skin_set_id'] ] ); $macro_icon = $this->_get_status_of_parent( $macro_array[ $data['set_skin_set_id'] ] ); //----------------------------------------- // Fix n' stitch //----------------------------------------- $data['_html'] = str_replace( '' , $wrapper_icon , $data['_html'] ); $data['_html'] = str_replace( '', $templates_icon, $data['_html'] ); $data['_html'] = str_replace( '' , $css_icon , $data['_html']); $data['_html'] = str_replace( '' , $macro_icon , $data['_html'] ); $ibforums->html .= $data['_html']."\n"; } } //----------------------------------------- // Show any children //----------------------------------------- foreach( $skin_sets as $id => $data ) { if ( is_array( $data['_children'] ) and count( $data['_children'] ) > 0 ) { $html = ""; foreach( $data['_children'] as $cid ) { $image = ""; if ( $cid == $data['_lastid'] ) { //----------------------------------------- // Last skin, show L //----------------------------------------- $image = 'skin_line_l.gif'; } else { //----------------------------------------- // First skin, show T //----------------------------------------- $image = 'skin_line_t.gif'; } $skin_sets[ $cid ]['_html'] = str_replace( "", " ", $skin_sets[ $cid ]['_html'] ); //----------------------------------------- // (un)altered icons: //----------------------------------------- $wrapper_icon = $this->_get_status_of_child($skin_sets[ $cid ]['set_wrapper'] , $skin_sets[ $id ]['set_wrapper'] ); $css_icon = $this->_get_status_of_child($skin_sets[ $cid ]['set_css'] , $skin_sets[ $id ]['set_css'] ); $templates_icon = $this->_get_status_of_child($template_array[ $cid ] , $template_array[ $id ]); $macro_icon = $this->_get_status_of_child($macro_array[ $cid ] , $macro_array[ $id ] ); //----------------------------------------- // Fix n' stitch //----------------------------------------- $skin_sets[ $cid ]['_html'] = str_replace( '' , $wrapper_icon , $skin_sets[ $cid ]['_html'] ); $skin_sets[ $cid ]['_html'] = str_replace( '', $templates_icon, $skin_sets[ $cid ]['_html'] ); $skin_sets[ $cid ]['_html'] = str_replace( '' , $css_icon , $skin_sets[ $cid ]['_html'] ); $skin_sets[ $cid ]['_html'] = str_replace( '' , $macro_icon , $skin_sets[ $cid ]['_html'] ); $html .= $skin_sets[ $cid ]['_html']; } $ibforums->html = str_replace( "", $html, $ibforums->html ); } } $ibforums->html .= ""; //----------------------------------------- // Add in default skin name //----------------------------------------- $ibforums->html = str_replace( '', $default_skin, $ibforums->html ); $ibforums->html .= "
 
"; $ibforums->html .= ""; //----------------------------------------- // Show altered / unaltered // legend //----------------------------------------- $ibforums->html .= "
Child skin set pop-up menu legend:
{$this->altered} This item has been customized for this skin set.
{$this->unaltered} This item has not been customized from the master skin set.
{$this->inherited} This item has inherited customizations from the parent skin set. "; if ( IN_DEV ) { $ibforums->html .= "
DEV: Export Master HTML · Export Template Bits · Export Master Macros
"; } $ibforums->admin->output(); } //----------------------------------------- // Get status of a child //----------------------------------------- function _get_status_of_child($this_item, $parent_item) { if ( $this_item ) { return $this->altered; } else if ( $parent_item ) { return $this->inherited; } else { return $this->unaltered; } } //----------------------------------------- // Get status of a parent //----------------------------------------- function _get_status_of_parent($this_item) { if ( ! $this_item ) { return $this->unaltered; } else { return $this->altered; } } } ?>