it looks that this mod will only be good if only guest who can use this, cause basically members can switch styles through their Profile -> Display
to fix issues about 2 styles mixes together, here is the changes:
(1) OPEN header.php:
(2) REMOVE:
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
<?php
if ($pun_config['o_show_sswitch'] == '1')
echo '<link rel="stylesheet" type="text/css" href="style/imports/styleswitcher.php" />'."\n";
?>
(3) FIND:
if (defined('PUN_ADMIN_CONSOLE'))
echo '<link rel="stylesheet" type="text/css" href="style/imports/base_admin.css" />'."\n";
(4) BEFORE add:
if ($pun_config['o_show_sswitch'] == '1' && $pun_user['is_guest'])
{
$mysheet = str_replace('_cs', '', $_COOKIE['my_stylesheet']);
if ($mysheet == "")
echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'.css" />'."\n";
else
echo '<link rel="stylesheet" type="text/css" href="style/'.$mysheet.'" />'."\n";
echo '<link rel="stylesheet" type="text/css" href="style/imports/styleswitcher.php" />'."\n";
}
else
{
echo '<link rel="stylesheet" type="text/css" href="style/'.$pun_user['style'].'.css" />'."\n";
}
(5) FIND:
// START SUBST - <pun_style>
if ($pun_config['o_show_sswitch'] == '1')
{
$styles = array();
$d = dir(PUN_ROOT.'style/imports');
while (($entry = $d->read()) !== false)
{
if (substr($entry, strlen($entry)-4) == '.css' && $entry != 'base.css' && $entry != 'base_admin.css')
$styles[] = substr($entry, 0, strlen($entry)-4);
}
$d->close();
@natsort($styles);
$tpl_temp=$lang_common['Style switcher'].'<form name="thisform" action="style/imports/styleswitcher.php" method="post"><select name="sheet" onchange="document.thisform.submit()">';
$mysheet = $_COOKIE['my_stylesheet'];
$mysheet = substr($mysheet, 0, strlen($mysheet)-4);
while (list(, $temp) = @each($styles))
{
$fix_temp=str_replace('_', ' ', $temp);
$fix_temp=trim(str_replace(' cs', ' ', $fix_temp));
if ($mysheet == $temp)
// Alternative way to bookmark used sheet
//$tpl_temp=$tpl_temp."\t\t\t\t\t\t\t\t\t".'<optgroup label="'.$fix_temp.'"></optgroup>'."\n";
$tpl_temp=$tpl_temp."\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'" selected="selected">'.$fix_temp.'</option>'."\n";
else
$tpl_temp=$tpl_temp."\t\t\t\t\t\t\t\t\t".'<option value="'.$temp.'">'.$fix_temp.'</option>'."\n";
}
$tpl_temp=$tpl_temp."</select></form>";
$tpl_main = str_replace('<pun_style>',$tpl_temp, $tpl_main);
}
else
{
$tpl_main = str_replace('<pun_style>','<div class="block"></div>', $tpl_main);
}
// END SUBST - <pun_style>
(6) REPLACE with:
// START SUBST - <pun_style>
if ($pun_config['o_show_sswitch'] == '1' && $pun_user['is_guest'])
{
$styles = array();
$d = dir(PUN_ROOT.'style/imports');
while (($entry = $d->read()) !== false)
{
if (substr($entry, strlen($entry)-4) == '.css' && $entry != 'base.css' && $entry != 'base_admin.css')
$styles[] = substr($entry, 0, strlen($entry)-4);
}
$d->close();
@natsort($styles);
$tpl_temp=$lang_common['Style switcher'].'<form id="style" action="style/imports/styleswitcher.php" method="post"><select name="sheet">'."\n";
$mysheet = $_COOKIE['my_stylesheet'];
$mysheet = substr($mysheet, 0, strlen($mysheet)-4);
while (list(, $temp) = @each($styles))
{
$fix_temp=str_replace('_cs', '', $temp);
if ($mysheet == $temp)
$tpl_temp=$tpl_temp."\t\t\t".'<option value="'.$temp.'" selected="selected">[ '.$fix_temp.' ]</option>'."\n";
else
$tpl_temp=$tpl_temp."\t\t\t".'<option value="'.$temp.'">'.$fix_temp.'</option>'."\n";
}
$tpl_temp = $tpl_temp."\t\t\t".'<input type="submit" name="sswitch" value="Set" tabindex="0" />';
$tpl_temp = $tpl_temp."</select></form>";
$tpl_main = str_replace('<pun_style>',$tpl_temp, $tpl_main);
}
else
{
$tpl_main = str_replace('<pun_style>','<div class="block"></div>', $tpl_main);
}
// END SUBST - <pun_style>
that's makes the Style Switcher will works only for guest and added button to select style