<?php
get_header("home");

// Control de Categorías
$cats        = get_categories(array('hide_empty' => 0, 'parent' => 1));
$categorias  = array();

foreach ($cats as $cat) {

    $data = iron_tunnels_get_category_data($cat->term_id);
    $categorias[$data->category_order] = array(
                                                "title"   =>$cat->name,
                                                "id"      =>$cat->term_id,
                                                "desc"    =>$cat->category_description,
                                                "img"     =>$data->image,
                                                "bg_atts" =>$data->bg_att
                                               );
    
    $categorias[$data->category_order]['frases'] = iron_tunnels_get_category_phrases($cat->term_id);
    if (sizeof($categorias[$data->category_order]['frases']) == 0) $categorias[$data->category_order]['frases'] = array($cat->category_description);
}

ksort($categorias);
$firstOrden = "1";
?>
<style>

div#intro-middle {
padding: 40px 0 0 40px;
}

.intro-middle-box p{
    font-size: 12px;
    margin-bottom: 12px;
}

#pass-restore {
    margin-top: 50px;
}
form.standard-form input[type="password"] {
    padding: 0px 3px;
    border: 1px solid #D9D9D9;
    border-radius: 5px;
    height: 23px;
    width: 149px;
    background: none;
    margin-bottom: 10px;
}

</style>

<div id="intro-container">

    <div id="header">
        <?php echo header_home_links_registration( $_COOKIE['LANG'] ); ?>
    </div>

    <div class="iron-lang">
        <a href="<?php echo site_url(); ?>?lang=es">Castellano</a>
        &nbsp;|&nbsp;
        <a href="<?php echo site_url(); ?>?lang=eu">Euskera</a>
        &nbsp;|&nbsp;
        <a href="<?php echo site_url(); ?>?lang=en">English</a>
    </div>
    
    <div id="intro-middle">
        <div class="intro-middle-box">

        <?php if ( bp_account_was_activated() ) { ?>

                <h2 class="widgettitle"><?php _e( 'Cuenta Activada', 'buddypress' ) ?></h2>
                <?php
                    do_action( 'bp_before_activate_content' );
                    
                    if ( isset( $_GET['e'] ) ) { 
                        echo '<p>' . __( 'Tu cuenta ha sido activada! Los detalles de la misma han sido enviados a tu cuenta de correo.', 'buddypress' ) . '</p>';
                    } else { 
                        echo '<p>' . __( 'Tu cuenta ha sido activada!<p>Por &uacute;ltimo, introduce tus datos de acceso para entrar, recuerda actualizar tu contrase&ntilde;a desde la secci&oacute;n <i>Mi perfil</i>.</p><p>Esperamos que disfrutes de Kronikoen Sarea !</p>', 'buddypress' ) . '</p>';
                    }
                    
              } else {
            ?>
            <h2 class="widgettitle"><?php _e( 'Cuenta Activada', 'buddypress' ) ?></h2>
            <p><?php _e( 'Tu cuenta ha sido activada!<p>Por &uacute;ltimo, introduce tus datos de acceso para entrar, recuerda actualizar tu contrase&ntilde;a desde la secci&oacute;n <i>Mi perfil</i>.</p><p>Esperamos que disfrutes de Kronikoen Sarea !</p>', 'buddypress' ) ?></p>
        <?php 
        /*?>
            <h3><?php _e( 'Activa tu Cuenta', 'buddypress' ) ?></h3>
            <?php do_action( 'bp_before_activate_content' ) ?>
            <p><?php _e( 'Por favor, escribe una clave v&aacute;lida.', 'buddypress' ) ?></p>
            <form action="" method="get" class="standard-form" id="activation-form">
                <label for="key"><?php _e( 'C&oacute;digo de activaci&oacute;n:', 'buddypress' ) ?></label>
                <input type="text" name="key" id="key" value="" />
                <p class="submit">
                    <input type="submit" name="submit" value="<?php _e( 'Activar Cuenta', 'buddypress' ) ?> &rarr;" />
                </p>
            </form>
        <?php */} ?>

        </div>
        
        <div class="intro-middle-box nomargin">
                <?php
                // If Iron PrivateSite Registration is active
                if (get_site_option('iron_privatesite_registration') == 1) { ?>
    
                    <div class="connect-bits">
                        <?php //do_action('fbc_display_login_button')
                        if (function_exists('jfb_output_facebook_btn') || function_exists('twit_connect')) {
                            echo '<p class="connect-text">'. iron_tunnels_display_register_addtext(). '</p>';
                        }

                        if (function_exists('jfb_output_facebook_btn')){
                            jfb_output_facebook_btn();
                        }

                        if (function_exists('twit_connect')){
                            twit_connect();
                        }

                        if (function_exists('custom_fb_login_button') and defined('IRON_FBCONNECT_VERSION')) {
                            custom_fb_login_button();
                        }

                        global $wpdb;

                        $i = 0;
                        foreach($_COOKIE as $key => $value) {

                            if (preg_match("/kc[0-9*]/", $key)) {
                                $key = str_replace("kc","",$key);

                                if (!is_numeric($key)) {
                                    continue;
                                }

                                if ($i == 0) {
                                    $i++;
                                    echo '<br style="clear:both;" />';
                                }

                                $query = "Select * from `".$wpdb->prefix."kconnect_satellites` where id = ".$key;
                                $site = array_shift($wpdb->get_results($query));

                                if (isset($site->siteName) and isset($site->logo) and ! empty($site->logo)) {
                                    echo '<a href="'.home_url().'?kc='.$key.'" style="float:right;">
                                    <img src="'.home_url().'/wp-content/plugins/irontec-kronet-connect/images/'.$site->logo.'" alt="'.$site->siteName.'"
                                    title="'.$site->siteName.'" style="float: right; height: 18px; margin-right: 3px;" /></a>';

                                } else if (isset($site->siteName)) {
                                    echo '<a href="'.home_url().'?kc='.$key.'" style="float: right; display:block;height: 18px; margin-right: 3px;">'.$site->siteName.'</a>';
                                }
                            }
                        }
                 } else { ?>
                    <div class="connect-bits">
                        <?php echo '<p style="font-size: 12px; color: #555; margin: 5px; padding: 10px; text-align: justify;">Este es un sitio privado. Para poder acceder es necesario recibir una <b>invitaci&oacute;n</b> por parte de los administradores del sitio.</p>'; ?>
                    </div>
            <?php } ?>
            </div> <!-- #intro-login-box -->
        </div> <!-- .intro-middle-box nomargin -->
    </div> <!-- .intro-middle -->
</div>
<?php
if (function_exists('jfb_output_facebook_init')) {
    jfb_output_facebook_init();
    jfb_output_facebook_callback();
}
get_footer("home"); ?>