Debug website module for multilanguage

This commit is contained in:
Laurent Destailleur 2020-12-19 13:03:40 +01:00
parent c112c807ac
commit fe93ee4d08
4 changed files with 47 additions and 15 deletions

View File

@ -107,9 +107,10 @@ class FormWebsite
* @param string $selected Selected value
* @param int $useempty 1=Add an empty value in list, 2=Add an empty value in list only if there is more than 2 entries.
* @param string $moreattrib More attributes on HTML select tag
* @param int $addjscombo Add js combo
* @return void
*/
public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '')
public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '', $addjscombo = 0)
{
global $langs, $conf, $user;
@ -128,7 +129,7 @@ class FormWebsite
$i = 0;
if ($num)
{
print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
print '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer minwidth200" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || ($useempty == 2 && $num > 1))
{
print '<option value="-1">&nbsp;</option>';
@ -149,6 +150,10 @@ class FormWebsite
}
print "</select>";
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
if ($addjscombo) {
print ajax_combobox('select'.$htmlname);
}
} else {
print $langs->trans("NoTypeOfPagePleaseEditDictionary");
}
@ -165,9 +170,10 @@ class FormWebsite
* @param string $selected Selected value
* @param int $useempty 1=Add an empty value in list
* @param string $moreattrib More attributes on HTML select tag
* @param int $addjscombo Add js combo
* @return string HTML select component with list of type of containers
*/
public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '')
public function selectSampleOfContainer($htmlname, $selected = '', $useempty = 0, $moreattrib = '', $addjscombo = 0)
{
global $langs, $conf, $user;
@ -190,7 +196,7 @@ class FormWebsite
}
$out = '';
$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
$out .= '<select id="select'.$htmlname.'" class="flat selectTypeOfContainer minwidth200" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
if ($useempty == 1 || $useempty == 2)
{
@ -210,6 +216,10 @@ class FormWebsite
}
$out .= "</select>";
if ($addjscombo) {
$out .= ajax_combobox('select'.$htmlname);
}
return $out;
}

View File

@ -252,7 +252,9 @@ ErrorValueLength=Length of field '<b>%s</b>' must be higher than '<b>%s</b>'
ErrorReservedKeyword=The word '<b>%s</b>' is a reserved keyword
ErrorNotAvailableWithThisDistribution=Not available with this distribution
ErrorPublicInterfaceNotEnabled=Public interface was not enabled
ErrorLanguageRequiredIfPageIsTranslationOfAnother=The language of new page must be defined if it is set as a translation of another page
ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother=The language of new page must not be the source language if it is set as a translation of another page
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.

View File

@ -100,7 +100,7 @@ EmptyPage=Empty page
ExternalURLMustStartWithHttp=External URL must start with http:// or https://
ZipOfWebsitePackageToImport=Upload the Zip file of the website template package
ZipOfWebsitePackageToLoad=or Choose an available embedded website template package
ShowSubcontainers=Include dynamic content
ShowSubcontainers=Show dynamic content
InternalURLOfPage=Internal URL of page
ThisPageIsTranslationOf=This page/container is a translation of
ThisPageHasTranslationPages=This page/container has translation

View File

@ -940,6 +940,7 @@ if ($action == 'addcontainer')
$objectpage->keywords = str_replace(array('<', '>'), '', GETPOST('WEBSITE_KEYWORDS', 'alphanohtml'));
$objectpage->allowed_in_frames = GETPOST('WEBSITE_ALLOWED_IN_FRAMES', 'aZ09');
$objectpage->htmlheader = GETPOST('htmlheader', 'none');
$objectpage->fk_page = (GETPOST('pageidfortranslation', 'int') > 0 ? GETPOST('pageidfortranslation', 'int') : 0);
$objectpage->author_alias = GETPOST('WEBSITE_AUTHORALIAS', 'alphanohtml');
$objectpage->object_type = GETPOST('WEBSITE_OBJECTCLASS');
$objectpage->fk_object = GETPOST('WEBSITE_OBJECTID');
@ -949,7 +950,7 @@ if ($action == 'addcontainer')
$sample = GETPOST('sample', 'alpha');
if (empty($sample)) $sample = 'empty';
$pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.$sample.'.html';
$pathtosample = DOL_DOCUMENT_ROOT.'/website/samples/page-sample-'.dol_sanitizeFileName($sample).'.html';
// Init content with content into pagetemplate.html, blogposttempltate.html, ...
$objectpage->content = make_substitutions(@file_get_contents($pathtosample), $substitutionarray);
@ -978,6 +979,22 @@ if ($action == 'addcontainer')
$error++;
$action = 'createcontainer';
}
if ($objectpage->fk_page > 0 && empty($objectpage->lang))
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorLanguageRequiredIfPageIsTranslationOfAnother"), null, 'errors');
$error++;
$action = 'createcontainer';
}
if ($objectpage->fk_page > 0 && !empty($objectpage->lang))
{
if ($objectpage->lang == $website->lang) {
$langs->load("errors");
setEventMessages($langs->trans("ErrorLanguageMustNotBeSourceLanguageIfPageIsTranslationOfAnother"), null, 'errors');
$error++;
$action = 'createcontainer';
}
}
}
if (!$error)
@ -3231,14 +3248,16 @@ if ($action == 'createsite')
print '</td></tr>';
print '<tr><td>';
print $langs->trans('OtherLanguages');
$htmltext = $langs->trans("Example").': fr,de,sv,it,pt';
print $form->textwithpicto($langs->trans('OtherLanguages'), $htmltext, 1, 'help', '', 0, 2);
print '</td><td>';
print '<input type="text" class="flat minwidth300" name="WEBSITE_OTHERLANG" value="'.dol_escape_htmltag($siteotherlang).'">';
print '</td></tr>';
print '<tr><td>';
$htmltext = $langs->trans("SetHereVirtualHost", DOL_DATA_ROOT.'/website/<i>websiteref</i>');
$htmltext = $langs->trans("SetHereVirtualHost", '{s1}');
$htmltext = str_replace('{s1}', DOL_DATA_ROOT.'/website/<i>websiteref</i>', $htmltext);
$htmltext .= '<br>';
$htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("ReadPerm"), DOL_DOCUMENT_ROOT);
$htmltext .= '<br>'.$langs->trans("CheckVirtualHostPerms", $langs->transnoentitiesnoconv("WritePerm"), '{s1}');
@ -3351,7 +3370,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
print ' ';
print $langs->trans("ImagesShouldBeSavedInto").' ';
$arraygrabimagesinto = array('root'=>$langs->trans("WebsiteRootOfImages"), 'subpage'=>$langs->trans("SubdirOfPage"));
print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ?GETPOST('grabimagesinto') : 'root');
print $form->selectarray('grabimagesinto', $arraygrabimagesinto, GETPOSTISSET('grabimagesinto') ? GETPOST('grabimagesinto') : 'root', 0, 0, 0, '', 0, 0, 0, '', '', 1);
print '<br>';
print '<input class="button" style="margin-top: 5px" type="submit" name="fetchexternalurl" value="'.dol_escape_htmltag($langs->trans("FetchAndCreate")).'">';
print '</td></tr>';
@ -3433,7 +3452,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
print $langs->trans('WEBSITE_TYPE_CONTAINER');
print '</td><td>';
print img_picto('', 'object_technic', 'class="paddingrightonly"').' ';
$formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ?GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container));
$formwebsite->selectTypeOfContainer('WEBSITE_TYPE_CONTAINER', (GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') ? GETPOST('WEBSITE_TYPE_CONTAINER', 'alpha') : $type_container), 0, '', 1);
print '</td></tr>';
if ($action == 'createcontainer')
@ -3441,7 +3460,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
print '<tr><td class="titlefield fieldrequired">';
print $langs->trans('WEBSITE_PAGE_EXAMPLE');
print '</td><td>';
print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample') ?GETPOST('sample', 'alpha') : 'empty'));
print $formwebsite->selectSampleOfContainer('sample', (GETPOSTISSET('sample') ? GETPOST('sample', 'alpha') : 'empty'), 0, '', 1);
print '</td></tr>';
}
@ -3561,7 +3580,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
$translationof = $objectpage->fk_page;
print '<span class="opacitymedium">'.$langs->trans('ThisPageIsTranslationOf').'</span> ';
print $formwebsite->selectContainer($website, 'pageidfortranslation', ($translationof ? $translationof : -1), 1, $action, 'minwidth300', array($objectpage->id));
if ($translationof > 0) {
if ($translationof > 0 && $sourcepage->lang) {
print $sourcepage->getNomUrl(2).' ('.$sourcepage->lang.')';
}
}
@ -3596,8 +3615,9 @@ if ($action == 'editmeta' || $action == 'createcontainer') // Edit properties of
$cate_arbo = $form->select_all_categories(Categorie::TYPE_WEBSITE_PAGE, '', 'parent', null, null, 1);
}
print '<tr class="visibleifsupplier"><td class="toptd">'.$form->editfieldkey('Categories', 'categories', '', $objectpage, 0).'</td><td colspan="3">';
print img_picto('', 'category', 'class="paddingright"').$form->multiselectarray('categories', $cate_arbo, (GETPOSTISSET('categories') ? GETPOST('categories', 'array') : $arrayselected), null, null, 'quatrevingtpercent widthcentpercentminusx');
print '<tr><td class="toptd">'.$form->editfieldkey('Categories', 'categories', '', $objectpage, 0).'</td><td>';
print img_picto('', 'category', 'class="paddingright"');
print $form->multiselectarray('categories', $cate_arbo, (GETPOSTISSET('categories') ? GETPOST('categories', 'array') : $arrayselected), null, null, 'quatrevingtpercent widthcentpercentminusx');
print "</td></tr>";
}