<?php
include_once CMBD_PLUGIN_DIR . '/backend/classes/SettingsView.php';
$settingsView = new CMBD_SettingsView();

$tabs = array(
    'installation' => 'Installation Guide',
    'general'      => 'General',
    'statistics'   => 'Statistics',
    'api'		   => 'API',
    'taxonomies'   => 'Taxonomies',
    'business'     => 'Business Page',
    'advertisement'=> 'Advertisement',
    'index'        => 'Business Directory',
    'appearance'   => 'Directory Appearance',
    'categorylist' => 'Category List',
    'customcss'    => 'Custom CSS',
    'labels'	   => 'Labels',
    'rating'	   => 'CM Star Rating Settings',
    'shortcodes'   => 'Supported Shortcodes',
	'upgrade'      => 'Upgrade',
);
$tabs = apply_filters( 'cmbd_settings_pages', $tabs );

if ( !function_exists( 'cmbd_settings_radio' ) ) {
    function cmbd_settings_radio( $name, $options, $currentValue ) {
        $result = '';
        foreach ( $options as $value => $text ) {
            $result .= sprintf( '<div style="margin-bottom:0.5em;"><input type="radio" name="%s" id="%s_%s" value="%s"%s />'
            . '<label for="%s_%s"> %s</label></div>', $name, $name, $value, $value, ( $currentValue == $value ? ' checked="checked"' : '' ), $name, $value, $text
            );
        }
        return $result;
    }
}
?>
<div class="clear"></div>
<?php do_action( 'CMBD_show_messages' ); ?>
<?php
if ( !empty( $messages ) ):
    foreach ( $messages as $message ):
        ?><div class="updated"><p><?php echo $message; ?></p></div><?php
    endforeach;
endif;
?>
<?php
require('settings/top.phtml');
$settingsTabsArrayBase = array();
$settingsTabsArray     = apply_filters( 'cmbd-settings-tabs-array', $settingsTabsArrayBase );
?>
<form method="post" enctype="multipart/form-data" id="cm-business-directory-settings-form">
    <div id="tabs">
        <ul>
			<?php foreach ( $tabs as $id => $name ): ?>
                <li><a href="#tab_<?php echo esc_attr( $id ); ?>"><?php echo $name; ?></a></li>
                <?php
            endforeach;
            if ( !empty( $settingsTabsArray ) ) {
                foreach ( $settingsTabsArray as $id => $name ):
                    ?>
                    <li><a href="#tab_<?php echo esc_attr( $id ); ?>"><?php echo $name; ?></a></li>
                    <?php
                endforeach;
            }
            ?>
        </ul>
        <?php
		foreach ( $tabs as $id => $name ): ?>
            <div id="tab_<?php echo esc_attr( $id ); ?>" class="tab-content">
                <?php require('settings/' . $id . '.phtml'); ?>
            </div>
            <?php
        endforeach;
        if ( !empty( $settingsTabsArray ) ) {
            foreach ( $settingsTabsArray as $tabKey => $tabLabel ) {
                $filterName = 'cmbd-custom-settings-tab-content-' . $tabKey;
                echo'<div id="tab_' . $tabKey . '" class="tab-content">';
                echo apply_filters( $filterName, '' );
                echo '</div>';
            }
        }
        ?>
    </div>
    <?php wp_nonce_field( 'dg@3vasdHHT4$bsdcs_SDdSS34637', 'cmbd_nonce' ); ?>
	<br>
    <input type="submit" class="cmbd-button button-primary" value="Update" />
</form>