Fix hreflang tag (must include itself)
This commit is contained in:
parent
3f0fd9b82a
commit
0e063a3bb3
@ -123,14 +123,17 @@ function dolSavePageContent($filetpl, Website $object, WebsitePage $objectpage)
|
|||||||
$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
|
$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
|
||||||
$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
|
$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
|
||||||
// Add translation reference (main language)
|
// Add translation reference (main language)
|
||||||
$translationof = $objectpage->fk_page;
|
if ($object->isMultiLang()) {
|
||||||
if ($translationof) {
|
$tplcontent .= '<link rel="alternate" hreflang="'.$shortlangcode.'" href="'.($object->fk_default_home == $objectpage->id ? '/' : '/'.$objectpage->pageurl.'.php').'" />'."\n";
|
||||||
$tmppage = new WebsitePage($db);
|
$translationof = $objectpage->fk_page;
|
||||||
$tmppage->fetch($translationof);
|
if ($translationof) {
|
||||||
if ($tmppage->id > 0) {
|
$tmppage = new WebsitePage($db);
|
||||||
$tmpshortlangcode = '';
|
$tmppage->fetch($translationof);
|
||||||
if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en
|
if ($tmppage->id > 0) {
|
||||||
$tplcontent .= '<link rel="alternate" hreflang="'.$tmpshortlangcode.'" href="'.($object->fk_default_home == $tmppage->id ? '/' : '/'.$tmppage->pageurl.'.php').'" />'."\n";
|
$tmpshortlangcode = '';
|
||||||
|
if ($tmppage->lang) $tmpshortlangcode = preg_replace('/[_-].*$/', '', $tmppage->lang); // en_US or en-US -> en
|
||||||
|
$tplcontent .= '<link rel="alternate" hreflang="'.$tmpshortlangcode.'" href="'.($object->fk_default_home == $tmppage->id ? '/' : '/'.$tmppage->pageurl.'.php').'" />'."\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Add canonical reference
|
// Add canonical reference
|
||||||
|
|||||||
@ -63,6 +63,11 @@ if ($pageid > 0)
|
|||||||
|
|
||||||
if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {
|
if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) {
|
||||||
header("X-Content-Type-Options: nosniff");
|
header("X-Content-Type-Options: nosniff");
|
||||||
|
/* TODO Manage allow_frames flag on websitepage.
|
||||||
|
if (empty($websitepage->allow_frames) && empty($conf->global->WEBSITE_ALLOW_FRAMES_ON_ALL_PAGES)) {
|
||||||
|
header("X-Frame-Options: SAMEORIGIN");
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
// A lang was forced, so we change weblangs init
|
// A lang was forced, so we change weblangs init
|
||||||
|
|||||||
@ -1137,7 +1137,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0)
|
|||||||
header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
|
header("X-Content-Type-Options: nosniff"); // With the nosniff option, if the server says the content is text/html, the browser will render it as text/html (note that most browsers now force this option to on)
|
||||||
if (!defined('XFRAMEOPTIONS_ALLOWALL')) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
|
if (!defined('XFRAMEOPTIONS_ALLOWALL')) header("X-Frame-Options: SAMEORIGIN"); // Frames allowed only if on same domain (stop some XSS attacks)
|
||||||
else header("X-Frame-Options: ALLOWALL");
|
else header("X-Frame-Options: ALLOWALL");
|
||||||
//header("X-XSS-Protection: 1"); // XSS protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated.
|
//header("X-XSS-Protection: 1"); // XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated.
|
||||||
if (!defined('FORCECSP'))
|
if (!defined('FORCECSP'))
|
||||||
{
|
{
|
||||||
//if (! isset($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY))
|
//if (! isset($conf->global->MAIN_HTTP_CONTENT_SECURITY_POLICY))
|
||||||
|
|||||||
@ -1161,6 +1161,18 @@ class Website extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return if web site is a multilanguage web site. Return false if there is only 0 or 1 language.
|
||||||
|
*
|
||||||
|
* @return boolean True if web site is a multilanguage web site
|
||||||
|
*/
|
||||||
|
public function isMultiLang()
|
||||||
|
{
|
||||||
|
// TODO Can edit list of languages of web site. Return false if there is only 0 or 1 language.
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component to select language inside a container (Full CSS Only)
|
* Component to select language inside a container (Full CSS Only)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -25,7 +25,7 @@ define('NOSCANPOSTFORINJECTION', 1);
|
|||||||
define('NOSTYLECHECK', 1);
|
define('NOSTYLECHECK', 1);
|
||||||
define('USEDOLIBARREDITOR', 1);
|
define('USEDOLIBARREDITOR', 1);
|
||||||
|
|
||||||
header('X-XSS-Protection:0');
|
//header('X-XSS-Protection:0'); // Disable XSS filtering protection of some browsers (note: use of Content-Security-Policy is more efficient). Disabled as deprecated.
|
||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user