Lang of web site is optional
This commit is contained in:
parent
895503d2eb
commit
5c48f6f405
@ -50,7 +50,7 @@ class FormAdmin
|
|||||||
* @param string $selected Language pre-selected
|
* @param string $selected Language pre-selected
|
||||||
* @param string $htmlname Name of HTML select
|
* @param string $htmlname Name of HTML select
|
||||||
* @param int $showauto Show 'auto' choice
|
* @param int $showauto Show 'auto' choice
|
||||||
* @param array $filter Array of keys to exclude in list
|
* @param array $filter Array of keys to exclude in list (opposite of $onlykeys)
|
||||||
* @param string $showempty '1'=Add empty value or string to show
|
* @param string $showempty '1'=Add empty value or string to show
|
||||||
* @param int $showwarning Show a warning if language is not complete
|
* @param int $showwarning Show a warning if language is not complete
|
||||||
* @param int $disabled Disable edit of select
|
* @param int $disabled Disable edit of select
|
||||||
@ -58,9 +58,10 @@ class FormAdmin
|
|||||||
* @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end
|
* @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end
|
||||||
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
|
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
|
||||||
* @param int $multiselect Make the combo a multiselect
|
* @param int $multiselect Make the combo a multiselect
|
||||||
|
* @param array $onlykeys Show only the following keys (opposite of $filter)
|
||||||
* @return string Return HTML select string with list of languages
|
* @return string Return HTML select string with list of languages
|
||||||
*/
|
*/
|
||||||
public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0, $multiselect = 0)
|
public function select_language($selected = '', $htmlname = 'lang_id', $showauto = 0, $filter = null, $showempty = '', $showwarning = 0, $disabled = 0, $morecss = '', $showcode = 0, $forcecombo = 0, $multiselect = 0, $onlykeys = array())
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
@ -96,11 +97,13 @@ class FormAdmin
|
|||||||
if ($showcode == 1) $valuetoshow=$key.' - '.$value;
|
if ($showcode == 1) $valuetoshow=$key.' - '.$value;
|
||||||
if ($showcode == 2) $valuetoshow=$value.' ('.$key.')';
|
if ($showcode == 2) $valuetoshow=$value.' ('.$key.')';
|
||||||
|
|
||||||
if ($filter && is_array($filter) && array_key_exists($key, $filter))
|
if ($filter && is_array($filter) && array_key_exists($key, $filter)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
elseif ($selected == $key)
|
if ($onlykeys && is_array($onlykeys) && ! array_key_exists($key, $onlykeys)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ($selected == $key)
|
||||||
{
|
{
|
||||||
$out.= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
|
$out.= '<option value="'.$key.'" selected>'.$valuetoshow.'</option>';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2016-2020 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -779,16 +779,15 @@ if ($action == 'addcontainer')
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$objectpage->title = GETPOST('WEBSITE_TITLE', 'alpha');
|
$objectpage->title = GETPOST('WEBSITE_TITLE', 'alphanohtml');
|
||||||
$objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha');
|
$objectpage->type_container = GETPOST('WEBSITE_TYPE_CONTAINER', 'aZ09');
|
||||||
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
$objectpage->pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha');
|
||||||
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alpha');
|
$objectpage->aliasalt = GETPOST('WEBSITE_ALIASALT', 'alphanohtml');
|
||||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alpha');
|
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml');
|
||||||
$objectpage->lang = GETPOST('WEBSITE_LANG', 'alpha');
|
|
||||||
$objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'alpha');
|
|
||||||
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
|
||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
|
|
||||||
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
|
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
|
||||||
|
$objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma');
|
||||||
|
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
||||||
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
||||||
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
|
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
|
||||||
|
|
||||||
$substitutionarray = array();
|
$substitutionarray = array();
|
||||||
@ -1417,8 +1416,7 @@ if ($action == 'updatemeta')
|
|||||||
$objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma');
|
$objectpage->otherlang = GETPOST('WEBSITE_OTHERLANG', 'aZ09comma');
|
||||||
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml');
|
$objectpage->description = GETPOST('WEBSITE_DESCRIPTION', 'alphanohtml');
|
||||||
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
$objectpage->image = GETPOST('WEBSITE_IMAGE', 'alpha');
|
||||||
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alpha');
|
$objectpage->keywords = GETPOST('WEBSITE_KEYWORDS', 'alphanohtml');
|
||||||
$objectpage->lang = GETPOST('WEBSITE_LANG', 'aZ09');
|
|
||||||
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
$objectpage->htmlheader = trim(GETPOST('htmlheader', 'none'));
|
||||||
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
|
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
|
||||||
|
|
||||||
@ -2704,7 +2702,7 @@ if ($action == 'editcss')
|
|||||||
$htmltext='';
|
$htmltext='';
|
||||||
print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG');
|
print $form->textwithpicto($langs->trans('MainLanguage'), $htmltext, 1, 'help', '', 0, 2, 'WEBSITE_LANG');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : ($object->lang ? $object->lang : $langs->defaultlang)), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2);
|
print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : ($object->lang ? $object->lang : '0')), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -2863,7 +2861,7 @@ if ($action == 'createsite')
|
|||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans('MainLanguage');
|
print $langs->trans('MainLanguage');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'alpha') : $langs->defaultlang), 'WEBSITE_LANG', 0, 0, 0, 0, 0, 'minwidth300', 2);
|
print $formadmin->select_language((GETPOSTISSET('WEBSITE_LANG') ? GETPOST('WEBSITE_LANG', 'aZ09comma') : '0'), 'WEBSITE_LANG', 0, null, 1, 0, 0, 'minwidth300', 2);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
@ -3098,7 +3096,25 @@ if ($action == 'editmeta' || $action == 'createcontainer')
|
|||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans('Language');
|
print $langs->trans('Language');
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print $formadmin->select_language($pagelang ? $pagelang : $langs->defaultlang, 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200');
|
$onlykeys = array();
|
||||||
|
if ($object->lang) $onlykeys[$object->lang] = $object->lang;
|
||||||
|
else $onlykeys[$langs->defaultlang] = $langs->defaultlang;
|
||||||
|
if ($object->otherlang) {
|
||||||
|
$tmparray = explode(',', $object->otherlang);
|
||||||
|
foreach($tmparray as $key) {
|
||||||
|
$tmpkey = trim($key);
|
||||||
|
if (strlen($key) == 2) {
|
||||||
|
$tmpkey = strtolower($key).'_'.strtoupper($tmpkey);
|
||||||
|
}
|
||||||
|
$onlykeys[$tmpkey] = $tmpkey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($object->lang) && empty($object->otherlang)) {
|
||||||
|
$onlykeys = null; // We keep full list of languages
|
||||||
|
}
|
||||||
|
print $formadmin->select_language($pagelang ? $pagelang : '', 'WEBSITE_LANG', 0, null, '1', 0, 0, 'minwidth200', 0, 0, 0, $onlykeys);
|
||||||
|
$htmltext = $langs->trans("AvailableLanguagesAreDefinedIntoWebsiteProperties");
|
||||||
|
print $form->textwithpicto('', $htmltext);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Translation of
|
// Translation of
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user