Implement language selection link

This commit is contained in:
Eike Foken
2011-08-07 21:50:27 +02:00
parent 1512b07dc0
commit e3608e413b
2 changed files with 56 additions and 3 deletions

View File

@@ -0,0 +1,54 @@
<?php defined('BASEPATH') || exit("No direct script access allowed");
/**
* Extends CI's Language helpers.
*
* @author Eike Foken <kontakt@eikefoken.de>
*/
/**
* Generates a link for language selection.
*
* @access public
* @param string $img_folder Folder of the images for the language selection
* @param boolean $index_page Should index_page be added to the JavaScript path
* @return string
*/
if (!function_exists('lang_select')) {
function lang_select($img_folder = '', $index_page = false) {
$CI =& get_instance();
$link = '<a';
if ($CI->config->item('lang_selected') == 'en') {
$link .= ' href="' . $CI->config->site_url('de') . '">';
if (isset($img_folder) && $img_folder != '') {
if ($index_page === true) {
$link .= '<img src="' . $CI->config->site_url($img_folder . '/lang_en.png') . '" />';
} else {
$link .= '<img src="' . $CI->config->slash_item('base_url') . $img_folder . '/lang_en.png" />';
}
}
$link .= ' English';
} else if ($CI->config->item('lang_selected') == 'de') {
$link .= ' href="' . $CI->config->site_url('en') . '" >';
if (isset($img_folder) && $img_folder != '') {
if ($index_page === true) {
$link .= '<img src="' . $CI->config->site_url($img_folder . '/lang_de.png') . '" />';
} else {
$link .= '<img src="' . $CI->config->slash_item('base_url') . $img_folder . '/lang_de.png" />';
}
}
$link .= ' Deutsch';
}
$link .= "</a>\n";
return $link;
}
}
/* End of file MY_language_helper.php */
/* Location: ./application/helpers/MY_language_helper.php */

View File

@@ -20,9 +20,8 @@
<body>
<div id="header">
<h1><a href="<?=base_url()?>"><img src="<?=site_url('assets/images/logo.gif')?>" /></a></h1>
<div class="menu">Hallo <a href="#"><?=$this->user->profile()->firstname?> <?=$this->user->profile()->lastname?></a>! | <a href="#">Hilfe</a> | <?=anchor('settings', "Einstellungen");?> | <?=anchor('auth/logout', "Logout");?></div>
<h1><?=anchor('', img('assets/images/logo.gif'))?></h1>
<div class="menu">Hallo <a href="<?=site_url('');?>"><?=$this->user->profile()->firstname;?> <?=$this->user->profile()->lastname;?></a>! | <?=lang_select('assets/images');?> | <a href="#">Hilfe</a> | <?=anchor('settings', "Einstellungen");?> | <?=anchor('auth/logout', "Logout");?></div>
</div>
<div id="wrapper">