<?php
/**
 * This is the template that displays the links to the available skins
 *
 * This file is not meant to be called directly.
 * It is meant to be called by an include in the _main.php template.
 *
 * This file is not a standard part of b2evolution.  It is a mild-mannered hack
 * for those interested in alphabetizing their skins list.  It seems to work well
 * with b2evolution version 0.9.0.11 but there are no guarantees expressed or
 * implied as to it's forward or backward compatibility with any other version.
 *
 * Written by EdB - {@link http://wonderwinds.com/}
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
 *
 * @package evoskins
 * @subpackage l33t_gray
 */
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

# $skin_list_style is either 'menu' or 'list'
if(!isset($skin_list_style)) $skin_list_style = 'list';
# for people who use 'menu' what will the button say?
if(!isset($skin_menu_button)) $skin_menu_button = T_('Get skin');
if(!isset($skin_menu_button_class)) $skin_menu_button_class = 'submit';

# this is what will start and end your skin section - affects both menu-style and list-style
if(!isset($skin_section_start)) $skin_section_start = '';
if(!isset($skin_section_end)) $skin_section_end = '';

# THIS SECTION IS FOR LIST-STYLE ONLY
# this is what will start and end your skin list
if(!isset($skin_list_start)) $skin_list_start = '<ul>';
if(!isset($skin_list_end)) $skin_list_end = '</ul>';
# this is what will separate your skin links
if(!isset($skin_item_start)) $skin_item_start = '<li>';
if(!isset($skin_item_end)) $skin_item_end = "</li>\n";
# This is additionnal markup before and after the current skin
if(!isset($skin_selected_before)) $skin_selected_before = '<em>';
if(!isset($skin_selected_after)) $skin_selected_after = ' (current skin)</em>';
# This is additionnal markup before and after the default skin
if(!isset($skin_default_before)) $skin_default_before = '<strong>';
if(!isset($skin_default_after)) $skin_default_after = ' (my skin!)</strong>';
# This is additionnal markup before and after the other skins
if(!isset($skin_other_before)) $skin_other_before = '';
if(!isset($skin_other_after)) $skin_other_after = '';

// ------ //

$skins_array = array();
for( skin_list_start(); skin_list_next(); ) 
{
$skins_array[] = skin_list_iteminfo( 'name', false );
if( skin_list_iteminfo( 'name', false ) == $skin ) $this_skin = skin_list_iteminfo( 'name', false );
if( skin_list_iteminfo( 'name', false ) == $Blog->get( 'default_skin' ) ) $def_skin = skin_list_iteminfo( 'name', false );
}
sort($skins_array);
reset($skins_array);
$skins_count = count($skins_array);

echo $skin_section_start;

switch( $skin_list_style ) 
{ 
case 'menu':
form_formstart( $Blog->dget( 'blogurl', 'raw' ), '', '', 'get', 'switcher' ) ?>
<fieldset><label for="set"></label> 
<select id="set" name="skin">
<?php 
for( $ii = 0; $ii < $skins_count; $ii++ )
{ 
	switch( $skins_array[$ii] ) 
	{
		case 'The_Skin_You_Want_To_Hide': // this hides a skin from the list and still be available to you via the address bar (for tweaking before publishing)
			break;
		default:
			echo '<option value="'.$skins_array[$ii];
			echo '"';
			if( $skins_array[$ii] == $this_skin ) echo ' selected="selected" ';
			echo '>'.$skins_array[$ii];
			echo "</option>\n";
	}
}
?>
</select>
<br />
<input type="submit" class="<?php echo $skin_menu_button_class ?>" value="<?php echo $skin_menu_button ?>" />
</fieldset>
</form>
<?php 
break;

case 'list':
echo $skin_list_start;
for($ii = 0; $ii < $skins_count; $ii++) 
{
switch( $skins_array[$ii] ) 
{
case 'The_Skin_You_Want_To_Hide': // this hides a skin from the list and still be available to you via the address bar (for tweaking before publishing)
$close_line = false;
break;
case $this_skin: // this is for the skin you are on
echo $skin_item_start;
echo $skin_selected_before;
echo $skins_array[$ii];
echo $skin_selected_after;
$close_line = true;
break;
case $def_skin: // this is for the default skin when you are not on it
$skin_alt_text = 'switch to the '.$skins_array[$ii].' skin';
$disp_this = url_add_param( get_bloginfo('blogurl'), 'skin='.$skins_array[$ii] );
$disp_this .= '" title="'.$skin_alt_text;
$disp_this .= '">'.$skins_array[$ii];
echo $skin_item_start;
echo $skin_default_before.'<a href="';
echo $disp_this.'</a>';
echo $skin_default_after;
$close_line = true;
break;
default: // reckon this is where most skins end up
$skin_alt_text = 'switch to the '.$skins_array[$ii].' skin';
$disp_this = url_add_param( get_bloginfo('blogurl'), 'skin='.$skins_array[$ii] );
$disp_this .= '" title="'.$skin_alt_text;
$disp_this .= '">'.$skins_array[$ii];
echo $skin_item_start;
echo $skin_other_before.'<a href="';
echo $disp_this.'</a>';
echo $skin_other_after;
$close_line = true;
break;
}
if( $close_line ) echo $skin_item_end."\n";
}
echo $skin_list_end . "\n";
unset($skins_array);
break;
}
echo $skin_section_end;

?>
