Beispiel #1
0
function sn_tpl_render_topnav(&$user, $planetrow)
{
    if (!is_array($user)) {
        return '';
    }
    global $lang, $config;
    $GET_mode = sys_get_param_str('mode');
    $template = gettemplate('topnav', true);
    /*
    $planetrow = $planetrow ? $planetrow : $user['current_planet'];
    
    sn_db_transaction_start();
    $planetrow = sys_o_get_updated($user, $planetrow, SN_TIME_NOW);
    sn_db_transaction_commit();
    $planetrow = $planetrow['planet'];
    */
    $ThisUsersPlanets = db_planet_list_sorted($user);
    // while ($CurPlanet = db_fetch($ThisUsersPlanets))
    foreach ($ThisUsersPlanets as $CurPlanet) {
        if (!$CurPlanet['destruyed']) {
            $fleet_listx = flt_get_fleets_to_planet($CurPlanet);
            $template->assign_block_vars('topnav_planets', array('ID' => $CurPlanet['id'], 'NAME' => $CurPlanet['name'], 'PLIMAGE' => $CurPlanet['image'], 'FLEET_ENEMY' => $fleet_listx['enemy']['count'], 'COORDS' => uni_render_coordinates($CurPlanet), 'SELECTED' => $CurPlanet['id'] == $user['current_planet'] ? ' selected' : ''));
        }
    }
    $fleet_flying_list = tpl_get_fleets_flying($user);
    tpl_topnav_event_build($template, $fleet_flying_list[0]);
    tpl_topnav_event_build($template, $fleet_flying_list[MT_EXPLORE], 'expedition');
    que_tpl_parse($template, QUE_RESEARCH, $user);
    $str_date_format = "%3\$02d %2\$0s %1\$04d {$lang['top_of_year']} %4\$02d:%5\$02d:%6\$02d";
    $time_now_parsed = getdate(SN_TIME_NOW);
    $time_local_parsed = getdate(defined('SN_CLIENT_TIME_LOCAL') ? SN_CLIENT_TIME_LOCAL : SN_TIME_NOW);
    if ($config->game_news_overview) {
        nws_render($template, "WHERE UNIX_TIMESTAMP(`tsTimeStamp`) >= {$user['news_lastread']}", $config->game_news_overview);
    }
    $notes_query = doquery("SELECT * FROM {{notes}} WHERE `owner` = {$user['id']} AND `sticky` = 1 ORDER BY priority DESC, time DESC");
    while ($note_row = db_fetch($notes_query)) {
        note_assign($template, $note_row);
    }
    $premium_lvl = mrc_get_level($user, false, UNIT_PREMIUM, true, true);
    $template->assign_vars(array('QUE_ID' => QUE_RESEARCH, 'QUE_HTML' => 'topnav', 'RESEARCH_ONGOING' => (bool) $user['que'], 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']), 'TIME_TEXT_LOCAL' => sprintf($str_date_format, $time_local_parsed['year'], $lang['months'][$time_local_parsed['mon']], $time_local_parsed['mday'], $time_local_parsed['hours'], $time_local_parsed['minutes'], $time_local_parsed['seconds']), 'GAME_BLITZ_REGISTER' => $config->game_blitz_register, 'GAME_BLITZ_REGISTER_TEXT' => $lang['sys_blitz_registration_mode_list'][$config->game_blitz_register], 'BLITZ_REGISTER_OPEN' => $config->game_blitz_register == BLITZ_REGISTER_OPEN, 'BLITZ_REGISTER_CLOSED' => $config->game_blitz_register == BLITZ_REGISTER_CLOSED, 'BLITZ_REGISTER_SHOW_LOGIN' => $config->game_blitz_register == BLITZ_REGISTER_SHOW_LOGIN, 'BLITZ_REGISTER_DISCLOSURE_NAMES' => $config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES, 'GAME_BLITZ' => $config->game_mode == GAME_BLITZ, 'USERS_ONLINE' => $config->var_online_user_count, 'USERS_TOTAL' => $config->users_amount, 'USER_RANK' => $user['total_rank'], 'USER_NICK' => $user['username'], 'USER_AVATAR' => $user['avatar'], 'USER_AVATARID' => $user['id'], 'USER_PREMIUM' => $premium_lvl, 'USER_RACE' => $user['player_race'], 'TOPNAV_CURRENT_PLANET' => $user['current_planet'], 'TOPNAV_MODE' => $GET_mode, 'TOPNAV_DARK_MATTER' => mrc_get_level($user, '', RES_DARK_MATTER), 'TOPNAV_DARK_MATTER_TEXT' => pretty_number(mrc_get_level($user, '', RES_DARK_MATTER)), 'TOPNAV_METAMATTER' => mrc_get_level($user, '', RES_METAMATTER), 'TOPNAV_METAMATTER_TEXT' => pretty_number(mrc_get_level($user, '', RES_METAMATTER)), 'TOPNAV_PAYMENT' => sn_module_get_active_count('payment') && !defined('SN_GOOGLE'), 'TOPNAV_MESSAGES_ADMIN' => $user['msg_admin'], 'TOPNAV_MESSAGES_PLAYER' => $user['mnl_joueur'], 'TOPNAV_MESSAGES_ALLIANCE' => $user['mnl_alliance'], 'TOPNAV_MESSAGES_ATTACK' => $user['mnl_attaque'], 'TOPNAV_MESSAGES_ALL' => $user['new_message'], 'TOPNAV_FLEETS_FLYING' => count($fleet_flying_list[0]), 'TOPNAV_FLEETS_TOTAL' => GetMaxFleets($user), 'TOPNAV_EXPEDITIONS_FLYING' => count($fleet_flying_list[MT_EXPLORE]), 'TOPNAV_EXPEDITIONS_TOTAL' => get_player_max_expeditons($user), 'TOPNAV_QUEST_COMPLETE' => get_quest_amount_complete($user['id']), 'GAME_NEWS_OVERVIEW' => $config->game_news_overview));
    if (defined('SN_RENDER_NAVBAR_PLANET') && SN_RENDER_NAVBAR_PLANET === true || $user['option_list'][OPT_INTERFACE]['opt_int_navbar_resource_force'] && SN_RENDER_NAVBAR_PLANET !== false) {
        tpl_set_resource_info($template, $planetrow);
        $template->assign_vars(array('SN_RENDER_NAVBAR_PLANET' => true, 'SN_NAVBAR_HIDE_FLEETS' => true));
    }
    return $template;
}
Beispiel #2
0
        }
        sn_db_transaction_commit();
        sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
        //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
    } catch (exception $e) {
        $note_id_edit = 0;
        sn_db_transaction_rollback();
        $result[] = array('STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, 'MESSAGE' => $lang[$e->getMessage()]);
    }
}
if (!$note_id_edit) {
    note_assign($template, array('id' => 0, 'time' => SN_TIME_NOW, 'priority' => 2, 'planet_type' => PT_PLANET, 'title' => $lang['note_new_title'], 'text' => $lang['note_new_text']));
}
$note_exist = false;
$notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, time DESC");
while ($note_row = db_fetch($notes_query)) {
    note_assign($template, $note_row);
    $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
}
$note_id_edit = $note_exist ? $note_id_edit : 0;
foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
    $template->assign_block_vars('note_priority', array('ID' => $note_priority_id, 'CLASS' => $note_priority_classes[$note_priority_id], 'TEXT' => $lang['sys_notes_priorities'][$note_priority_id]));
}
foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
    $template->assign_block_vars('planet_type', array('ID' => $planet_type_id, 'TEXT' => $planet_type_string));
}
foreach ($result as $result_data) {
    $template->assign_block_vars('result', $result_data);
}
$template->assign_vars(array('PAGE_HEADER' => $lang['note_page_header'], 'NOTE_ID_EDIT' => $note_id_edit, 'NOTE_FULL_RENDER' => true));
display($template);