Enhance multilangue support in website module

This commit is contained in:
Laurent Destailleur
2020-02-21 11:36:16 +01:00
parent 1f4b639ba0
commit 7909055ee8
12 changed files with 161 additions and 37 deletions

View File

@@ -158,6 +158,9 @@ class WebsitePage extends CommonObject
$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
// Remove spaces and be sure we have main language only
$this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
return $this->createCommon($user, $notrigger);
}
@@ -377,6 +380,22 @@ class WebsitePage extends CommonObject
$this->keywords = dol_trunc($this->keywords, 255, 'right', 'utf-8', 1);
if ($this->aliasalt) $this->aliasalt = ','.preg_replace('/,+$/', '', preg_replace('/^,+/', '', $this->aliasalt)).','; // content in database must be ',xxx,...,yyy,'
// Remove spaces and be sure we have main language only
$this->lang = preg_replace('/[_-].*$/', '', trim($this->lang)); // en_US or en-US -> en
if ($this->fk_page > 0) {
if (empty($this->lang)) {
$this->error = "ErrorLanguageMandatoryIfPageSetAsTranslationOfAnother";
return -1;
}
$tmppage = new WebsitePage($this->db);
$tmppage->fetch($this->fk_page);
if ($tmppage->lang == $this->lang) {
$this->error = "ErrorLanguageOfTranslatedPageIsSameThanThisPage";
return -1;
}
}
return $this->updateCommon($user, $notrigger);
}
@@ -513,7 +532,8 @@ class WebsitePage extends CommonObject
$label .= '<br>';
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref.'<br>';
$label .= '<b>'.$langs->trans('ID').':</b> '.$this->id.'<br>';
$label .= '<b>'.$langs->trans('Title').':</b> '.$this->title;
$label .= '<b>'.$langs->trans('Title').':</b> '.$this->title.'<br>';
$label .= '<b>'.$langs->trans('Language').':</b> '.$this->lang;
$url = DOL_URL_ROOT.'/website/index.php?websiteid='.$this->fk_website.'&pageid='.$this->id;