diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index ff83d9136aa..2b3e20f1895 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -86,7 +86,7 @@ function dolSavePageAlias($filealias, $object, $objectpage) * @param WebsitePage $objectpage Object websitepage * @return boolean True if OK */ -function dolSavePageContent($filetpl, $object, $objectpage) +function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage) { global $conf; @@ -122,7 +122,19 @@ function dolSavePageContent($filetpl, $object, $objectpage) $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; + // Add translation reference (main language) + $translationof = $objectpage->fk_page; + if ($translationof) { + $tmppage = new WebsitePage($db); + $tmppage->fetch($translationof); + if ($tmppage->id > 0) { + $tplcontent .= ''."\n"; + } + } + // Add canonical reference $tplcontent .= ''."\n"; + // Add manifest.json on homepage + $tplcontent .= 'use_manifest) { print \'\'."\n"; } ?>'."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql index 340b3720dd7..b4d956129a7 100644 --- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql +++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql @@ -539,3 +539,5 @@ ALTER TABLE llx_mrp_production ADD CONSTRAINT fk_mrp_production_stock_movement F ALTER TABLE llx_mrp_production ADD INDEX idx_mrp_production_fk_mo (fk_mo); ALTER TABLE llx_emailcollector_emailcollector ADD UNIQUE INDEX uk_emailcollector_emailcollector_ref(ref, entity); + +ALTER TABLE llx_website ADD COLUMN use_manifest integer; diff --git a/htdocs/install/mysql/tables/llx_website.sql b/htdocs/install/mysql/tables/llx_website.sql index b5764565a34..645343544a4 100644 --- a/htdocs/install/mysql/tables/llx_website.sql +++ b/htdocs/install/mysql/tables/llx_website.sql @@ -27,7 +27,8 @@ CREATE TABLE llx_website maincolor varchar(16), maincolorbis varchar(16), status integer DEFAULT 1, - fk_default_home integer, + fk_default_home integer, + use_manifest integer, virtualhost varchar(255), fk_user_creat integer, fk_user_modif integer, diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index de8c947512d..f45298e082a 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -96,6 +96,11 @@ class Website extends CommonObject */ public $virtualhost; + /** + * @var int + */ + public $use_manifest; + /** * List of containers * @@ -237,6 +242,7 @@ class Website extends CommonObject $sql .= " t.description,"; $sql .= " t.status,"; $sql .= " t.fk_default_home,"; + $sql .= " t.use_manifest,"; $sql .= " t.virtualhost,"; $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; @@ -264,6 +270,7 @@ class Website extends CommonObject $this->status = $obj->status; $this->fk_default_home = $obj->fk_default_home; $this->virtualhost = $obj->virtualhost; + $this->use_manifest = $obj->use_manifest; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->date_creation = $this->db->jdate($obj->date_creation); @@ -425,6 +432,7 @@ class Website extends CommonObject $sql .= ' description = '.(isset($this->description) ? "'".$this->db->escape($this->description)."'" : "null").','; $sql .= ' status = '.(isset($this->status) ? $this->status : "null").','; $sql .= ' fk_default_home = '.(($this->fk_default_home > 0) ? $this->fk_default_home : "null").','; + $sql .= ' use_manifest = '.((int) $this->use_manifest).','; $sql .= ' virtualhost = '.(($this->virtualhost != '') ? "'".$this->db->escape($this->virtualhost)."'" : "null").','; $sql .= ' fk_user_modif = '.(!isset($this->fk_user_modif) ? $user->id : $this->fk_user_modif).','; $sql .= ' date_creation = '.(!isset($this->date_creation) || dol_strlen($this->date_creation) != 0 ? "'".$this->db->idate($this->date_creation)."'" : 'null').','; diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index b6371c14df7..abdb8d323eb 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -74,6 +74,10 @@ class WebsitePage extends CommonObject * @var string keywords */ public $keywords; + /** + * @var string language code ('en', 'fr', 'en-gb', ..) + */ + public $lang; public $htmlheader; public $content; diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 1d94eadf626..df479f0cd36 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -1059,6 +1059,7 @@ if ($action == 'updatecss') if (!$error) { $object->virtualhost = GETPOST('virtualhost', 'alpha'); + $object->use_manifest = GETPOST('use_manifest', 'alpha'); $result = $object->update($user); if ($result < 0) @@ -2738,10 +2739,9 @@ if ($action == 'editcss') $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); print '