Better select language component
This commit is contained in:
parent
83be1759b1
commit
378013b863
@ -305,7 +305,7 @@ function redirectToContainer($containerref, $containeraliasalt='',$containerid=0
|
||||
*/
|
||||
function includeContainer($containerref)
|
||||
{
|
||||
global $conf, $db, $langs, $mysoc, $user, $website;
|
||||
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $weblangs; // Very important. Required to have var available when running inluded containers.
|
||||
global $includehtmlcontentopened;
|
||||
global $websitekey;
|
||||
|
||||
|
||||
@ -22,11 +22,18 @@
|
||||
* The global variable $websitekey must be defined.
|
||||
*/
|
||||
|
||||
// Load website class
|
||||
include_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
||||
$website=new Website($db);
|
||||
$website->fetch(0,$websitekey);
|
||||
|
||||
$weblangs = dol_clone($langs);
|
||||
// Define $website and $weblangs
|
||||
if (! is_object($website))
|
||||
{
|
||||
$website=new Website($db);
|
||||
$website->fetch(0,$websitekey);
|
||||
}
|
||||
if (! is_object($weblangs))
|
||||
{
|
||||
$weblangs = dol_clone($langs);
|
||||
}
|
||||
if (GETPOST('l','aZ09')) $weblangs->setDefaultLang(GETPOST('l','aZ09'));
|
||||
|
||||
// Load websitepage class
|
||||
include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
||||
|
||||
@ -1089,7 +1089,7 @@ class Website extends CommonObject
|
||||
*/
|
||||
public function componentSelectLang($languagecodes=array('en_US','fr_FR','de_DE','es_ES'), $weblangs, $morecss='', $htmlname='')
|
||||
{
|
||||
$out = '';
|
||||
if (! is_object($weblangs)) return 'ERROR componentSelectLang called with parameter $weblangs not defined';
|
||||
|
||||
$languagecodeselected = $weblangs->defaultlang;
|
||||
$weblangs->load('languages');
|
||||
@ -1128,7 +1128,9 @@ class Website extends CommonObject
|
||||
if ($languagecodeselected)
|
||||
{
|
||||
$shortcode = strtolower(substr($languagecodeselected, -2));
|
||||
$out.= '<a href="'.$url.$languagecodeselected.'"><li><img height="12px" src="medias/image/common/flags/'.$shortcode.'.png" style="margin-right: 5px;"/>'.$weblangs->trans("Language_".$languagecodeselected);
|
||||
$label = $weblangs->trans("Language_".$languagecodeselected);
|
||||
if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
$out.= '<a href="'.$url.$languagecodeselected.'"><li><img height="12px" src="medias/image/common/flags/'.$shortcode.'.png" style="margin-right: 5px;"/>'.$label;
|
||||
$out.= '<span class="fa fa-caret-down" style="padding-left: 5px;" />';
|
||||
$out.= '</li></a>';
|
||||
}
|
||||
@ -1137,7 +1139,9 @@ class Website extends CommonObject
|
||||
{
|
||||
if ($languagecode == $languagecodeselected) continue; // Already output
|
||||
$shortcode = strtolower(substr($languagecode, -2));
|
||||
$out.= '<a href="'.$url.$languagecode.'"><li><img height="12px" src="medias/image/common/flags/'.$shortcode.'.png" style="margin-right: 5px;"/>'.$weblangs->trans("Language_".$languagecode);
|
||||
$label = $weblangs->trans("Language_".$languagecode);
|
||||
if ($shortcode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
|
||||
$out.= '<a href="'.$url.$languagecode.'"><li><img height="12px" src="medias/image/common/flags/'.$shortcode.'.png" style="margin-right: 5px;"/>'.$label;
|
||||
if (empty($i) && empty($languagecodeselected)) $out.= '<span class="fa fa-caret-down" style="padding-left: 5px;" />';
|
||||
$out.= '</li></a>';
|
||||
$i++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user