[10.0.09.dev] sélecteur de langues dans le menu
This commit is contained in:
parent
ed0123a14a
commit
8197cf4686
@ -35,7 +35,7 @@ class common {
|
|||||||
const TEMP_DIR = 'site/tmp/';
|
const TEMP_DIR = 'site/tmp/';
|
||||||
|
|
||||||
// Numéro de version
|
// Numéro de version
|
||||||
const ZWII_VERSION = '10.0.08.dev';
|
const ZWII_VERSION = '10.0.09.dev';
|
||||||
|
|
||||||
public static $actions = [];
|
public static $actions = [];
|
||||||
public static $coreModuleIds = [
|
public static $coreModuleIds = [
|
||||||
@ -184,8 +184,8 @@ class common {
|
|||||||
// Déterminer la langue du visiteur
|
// Déterminer la langue du visiteur
|
||||||
// --------------------------------
|
// --------------------------------
|
||||||
// 1 Langue sélectionnée par l'utilisateur prioritaire
|
// 1 Langue sélectionnée par l'utilisateur prioritaire
|
||||||
if (isset($_COOKIE['ZWII_USER_I18N'])) {
|
if (isset($_SESSION['ZWII_USER_I18N'])) {
|
||||||
$i18nPOST = $_COOKIE['ZWII_USER_I18N'];
|
$i18nPOST = $_SESSION['ZWII_USER_I18N'];
|
||||||
} else {
|
} else {
|
||||||
$i18nPOST = '';
|
$i18nPOST = '';
|
||||||
}
|
}
|
||||||
@ -362,13 +362,13 @@ class common {
|
|||||||
*/
|
*/
|
||||||
public function geti18n() {
|
public function geti18n() {
|
||||||
// Vérifier l'existence du fichier de langue
|
// Vérifier l'existence du fichier de langue
|
||||||
if (isset ($_COOKIE["ZWII_USER_I18N"]) &&
|
if (isset ($_SESSION['ZWII_USER_I18N']) &&
|
||||||
key_exists($_COOKIE["ZWII_USER_I18N"], $this->i18nInstalled())) {
|
key_exists($_SESSION['ZWII_USER_I18N'], $this->i18nInstalled())) {
|
||||||
return ($_COOKIE["ZWII_USER_I18N"]);
|
return ($_SESSION['ZWII_USER_I18N']);
|
||||||
} else {
|
} else {
|
||||||
// La valeur du cookie n'est pas une version installée, remettre à fr
|
// La valeur du cookie n'est pas une version installée, remettre à fr
|
||||||
if (isset ($_COOKIE["ZWII_USER_I18N"])) {
|
if (isset ($_SESSION['ZWII_USER_I18N'])) {
|
||||||
helper::deleteCookie("ZWII_USER_I18N");
|
unset($_SESSION['ZWII_USER_I18N']);
|
||||||
$this->seti18n();
|
$this->seti18n();
|
||||||
}
|
}
|
||||||
return ('fr');
|
return ('fr');
|
||||||
@ -383,7 +383,7 @@ class common {
|
|||||||
*/
|
*/
|
||||||
public function seti18n($lan = 'fr') {
|
public function seti18n($lan = 'fr') {
|
||||||
// Sauvegarder la sélection
|
// Sauvegarder la sélection
|
||||||
return (setcookie('ZWII_USER_I18N',$lan,strtotime("+1 year"), helper::baseUrl(false, false)));
|
$_SESSION['ZWII_USER_I18N'] = $lan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2226,7 +2226,6 @@ class layout extends common {
|
|||||||
// Fermeture du bloc copyright
|
// Fermeture du bloc copyright
|
||||||
$items .= '</span></div>';
|
$items .= '</span></div>';
|
||||||
$items .= $this->geti18n();
|
$items .= $this->geti18n();
|
||||||
echo $items;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2407,20 +2406,7 @@ class layout extends common {
|
|||||||
$items .= '</ul>';
|
$items .= '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Menu de langue
|
|
||||||
if (sizeof($this->i18nInstalled()) > 1) {
|
|
||||||
$items .= '<li><form method="POST" action="' . helper::baseUrl(true) . 'i18n/lan" id="barFormSelectLanguage">';
|
|
||||||
$items .= '<select id="barSelectLanguage" name="i18nSelect" >';
|
|
||||||
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
|
||||||
$items .= '<option ';
|
|
||||||
$items .= 'value="' . $itemKey .'"';
|
|
||||||
if ($this->geti18n() === $itemKey) {
|
|
||||||
$items .= ' selected';
|
|
||||||
}
|
|
||||||
$items .= ' ><img src=core/vendor/icon-flags/svg/"' . $itemKey . '.svg>' . $item . '</option>';
|
|
||||||
}
|
|
||||||
$items .= '</select></form></li>';
|
|
||||||
}
|
|
||||||
// Lien de connexion
|
// Lien de connexion
|
||||||
if(
|
if(
|
||||||
(
|
(
|
||||||
@ -2435,8 +2421,19 @@ class layout extends common {
|
|||||||
strip_tags(str_replace('/', '_', $this->getUrl())) .
|
strip_tags(str_replace('/', '_', $this->getUrl())) .
|
||||||
'">Connexion</a></li>';
|
'">Connexion</a></li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Menu de langues
|
||||||
|
if (sizeof($this->i18nInstalled()) > 1) {
|
||||||
|
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
||||||
|
$items .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||||
|
$items .= '<input type="image" alt="'.$itemKey.'" class="flag" name="'.$itemKey.'" src="' . helper::baseUrl() .'core/vendor/icon-flags/svg/'. $itemKey .'.svg" data-tippy-content="'. $item .'" />';
|
||||||
|
$items .= '</form></li>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Retourne les items du menu
|
// Retourne les items du menu
|
||||||
echo '<ul class="navLevel1">' . $items . '</ul>';
|
echo '<ul class="navLevel1">' . $items . '</ul>';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2537,7 +2534,7 @@ class layout extends common {
|
|||||||
public function showMetaTitle() {
|
public function showMetaTitle() {
|
||||||
echo '<title>' . $this->core->output['metaTitle'] . '</title>';
|
echo '<title>' . $this->core->output['metaTitle'] . '</title>';
|
||||||
echo '<meta property="og:title" content="' . $this->core->output['metaTitle'] . '" />';
|
echo '<meta property="og:title" content="' . $this->core->output['metaTitle'] . '" />';
|
||||||
echo '<link rel="canonical" href="'. helper::baseUrl(true).$this->getUrl() .'" />';
|
echo '<link rel="canonical" href="'. helper::baseUrl().$this->getUrl() .'" />';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2611,9 +2608,8 @@ class layout extends common {
|
|||||||
if($this->getUser('group') >= self::GROUP_MODERATOR) {
|
if($this->getUser('group') >= self::GROUP_MODERATOR) {
|
||||||
// ne pas afficher la barre de langue pour une seule
|
// ne pas afficher la barre de langue pour une seule
|
||||||
// Sélection des langues installées
|
// Sélection des langues installées
|
||||||
echo $this->geti18n();
|
|
||||||
if (sizeof($this->i18nInstalled()) > 1) {
|
if (sizeof($this->i18nInstalled()) > 1) {
|
||||||
$leftItems .= '<li><form method="POST" action="' . helper::baseUrl(true) . 'i18n" id="barFormSelectLanguage">';
|
$leftItems .= '<li><form method="POST" action="' . helper::baseUrl() . 'i18n/lang" id="barFormSelectLanguage">';
|
||||||
$leftItems .= '<select id="barSelectLanguage" name="i18nSelect" >';
|
$leftItems .= '<select id="barSelectLanguage" name="i18nSelect" >';
|
||||||
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
foreach ($this->i18nInstalled() as $itemKey => $item) {
|
||||||
$leftItems .= '<option ';
|
$leftItems .= '<option ';
|
||||||
|
@ -542,6 +542,13 @@ ul .menuSideChild, li .menuSideChild {
|
|||||||
padding-left:10px;
|
padding-left:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Icones de langues du menu */
|
||||||
|
nav .flag {
|
||||||
|
width: 30px;
|
||||||
|
padding: 5px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Corps */
|
/* Corps */
|
||||||
@media (min-width:769px) {
|
@media (min-width:769px) {
|
||||||
|
@ -16,40 +16,15 @@ class i18n extends common {
|
|||||||
|
|
||||||
public static $actions = [
|
public static $actions = [
|
||||||
'index' => self::GROUP_MODERATOR,
|
'index' => self::GROUP_MODERATOR,
|
||||||
'lan' => self::GROUP_VISITOR
|
'lang' => self::GROUP_VISITOR
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function lan () {
|
|
||||||
// Traitement du changement de langue
|
|
||||||
if (isset($_POST['i18nSelect'])) {
|
|
||||||
$this->seti18n($_POST['i18nSelect']);
|
|
||||||
// Valeurs en sortie sans post
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl(false),
|
|
||||||
'notification' => 'Langue modifiée',
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration
|
* Configuration
|
||||||
*/
|
*/
|
||||||
public function index() {
|
public function index() {
|
||||||
// Traitement du changement de langue
|
|
||||||
if (isset($_POST['i18nSelect'])) {
|
|
||||||
$this->seti18n($_POST['i18nSelect']);
|
|
||||||
// Valeurs en sortie sans post
|
|
||||||
$this->addOutput([
|
|
||||||
'redirect' => helper::baseUrl(false),
|
|
||||||
'notification' => 'Langue modifiée',
|
|
||||||
'state' => true
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retour du formulaire
|
|
||||||
if($this->isPost()) {
|
if($this->isPost()) {
|
||||||
// Et faire un backup
|
// Et faire un backup
|
||||||
// Fonction à révoir dans core.php
|
// Fonction à révoir dans core.php
|
||||||
@ -117,4 +92,35 @@ class i18n extends common {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Traitement du changement de langues
|
||||||
|
*/
|
||||||
|
public function lang() {
|
||||||
|
if ( isset($_POST)) {
|
||||||
|
// Clic dans le menu par l'utilisateur
|
||||||
|
if (strlen(array_keys($_POST)[0]) === 4) {
|
||||||
|
$lan = substr(array_keys($_POST)[0],0,2);
|
||||||
|
// Clic dans le menu de la barre d'administration
|
||||||
|
} elseif ( isset($_POST['i18nSelect'])) {
|
||||||
|
$lan = $_POST['i18nSelect'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Traitement du changement de langue
|
||||||
|
if (isset($lan)) {
|
||||||
|
$this->seti18n($lan);
|
||||||
|
// Valeurs en sortie sans post
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl(false),
|
||||||
|
'notification' => 'Langue modifiée',
|
||||||
|
'state' => true
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
$this->addOutput([
|
||||||
|
'redirect' => helper::baseUrl(false)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
53
core/vendor/icon-flags/svg/en.svg
vendored
53
core/vendor/icon-flags/svg/en.svg
vendored
@ -1 +1,52 @@
|
|||||||
<?xml version="1.0"?><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25 15" width="800" height="480"><rect width="25" height="15" fill="#FFF"/><g fill="#CE1124"><rect width="3" height="15" x="11"/><rect width="25" height="3" y="6"/></g></svg>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<!-- Created with Sodipodi ("http://www.sodipodi.com/") -->
|
||||||
|
<!-- /Creative Commons Public Domain -->
|
||||||
|
<!--
|
||||||
|
|
||||||
|
<rdf:RDF xmlns="http://web.resource.org/cc/"
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||||
|
<Work rdf:about="">
|
||||||
|
<dc:title>New Zealand, Australia, United Kingdom, United States,
|
||||||
|
Bosnia and Herzegovina, Azerbaijan, Armenia, Bahamas, Belgium, Benin,
|
||||||
|
Bulgaria, Estonia, Finland, Gabon, Gambia, Germany, Greece, Greenland,
|
||||||
|
Guinea, Honduras, Israel, Jamaica, Jordan, and Romania Flags</dc:title>
|
||||||
|
<dc:rights><Agent>
|
||||||
|
<dc:title>Daniel McRae</dc:title>
|
||||||
|
</Agent></dc:rights>
|
||||||
|
<license rdf:resource="http://web.resource.org/cc/PublicDomain" />
|
||||||
|
</Work>
|
||||||
|
|
||||||
|
<License rdf:about="http://web.resource.org/cc/PublicDomain">
|
||||||
|
<permits rdf:resource="http://web.resource.org/cc/Reproduction" />
|
||||||
|
<permits rdf:resource="http://web.resource.org/cc/Distribution" />
|
||||||
|
<permits rdf:resource="http://web.resource.org/cc/DerivativeWorks" />
|
||||||
|
</License>
|
||||||
|
</rdf:RDF>
|
||||||
|
-->
|
||||||
|
<svg id="svg1" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="480" width="640" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||||
|
<metadata id="metadata2995">
|
||||||
|
<rdf:RDF>
|
||||||
|
<cc:Work rdf:about="">
|
||||||
|
<dc:format>image/svg+xml</dc:format>
|
||||||
|
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||||
|
</cc:Work>
|
||||||
|
</rdf:RDF>
|
||||||
|
</metadata>
|
||||||
|
<defs id="defs3">
|
||||||
|
<clipPath id="clipPath8673" clipPathUnits="userSpaceOnUse">
|
||||||
|
<rect id="rect8675" fill-opacity="0.67" height="512" width="682.67" y="-.0000028613" x="-85.333"/>
|
||||||
|
</clipPath>
|
||||||
|
</defs>
|
||||||
|
<g id="flag" clip-path="url(#clipPath8673)" transform="matrix(.93750 0 0 .93750 80 .0000026825)">
|
||||||
|
<g id="g578" stroke-width="1pt" transform="matrix(17.067 0 0 17.067 -256 -0.0000024)">
|
||||||
|
<rect id="rect124" height="30" width="60" y="0" x="0" fill="#006"/>
|
||||||
|
<g id="g584">
|
||||||
|
<path id="path146" d="m0 0v3.3541l53.292 26.646h6.708v-3.354l-53.292-26.646h-6.708zm60 0v3.354l-53.292 26.646h-6.708v-3.354l53.292-26.646h6.708z" fill="#fff"/>
|
||||||
|
<path id="path136" d="m25 0v30h10v-30h-10zm-25 10v10h60v-10h-60z" fill="#fff"/>
|
||||||
|
<path id="path141" d="m0 12v6h60v-6h-60zm27-12v30h6v-30h-6z" fill="#c00"/>
|
||||||
|
<path id="path150" d="m0 30 20-10h4.472l-20 10h-4.472zm0-30 20 10h-4.472l-15.528-7.7639v-2.2361zm35.528 10 20-10h4.472l-20 10h-4.472zm24.472 20-20-10h4.472l15.528 7.764v2.236z" fill="#c00"/>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 247 B After Width: | Height: | Size: 2.5 KiB |
Loading…
Reference in New Issue
Block a user