N°3750 data-input-type : change XHR detection method

I added WebPage::IsAjaxPage, but this wasn't a good idea as XHR isn't really related to the Page impl used !
Instead we're now using the new method \utils::IsXmlHttpRequest which is a copy of \Symfony\Component\HttpFoundation\Request::isXmlHttpRequest
Many thanks @Molkobain !
This commit is contained in:
Pierre Goiffon
2021-03-02 11:54:15 +01:00
parent a850d3b67c
commit 225c176f71
3 changed files with 16 additions and 11 deletions

View File

@@ -189,16 +189,26 @@ class utils
{
$sSAPIName = php_sapi_name();
$sCleanName = strtolower(trim($sSAPIName));
if ($sCleanName == 'cli')
{
if ($sCleanName == 'cli') {
return true;
}
else
{
} else {
return false;
}
}
/**
* @return bool true if we're in an XHR query
* @see \Symfony\Component\HttpFoundation\Request::IsXmlHttpRequest
*/
public static function IsXmlHttpRequest()
{
$sXhrHeaderName = 'X-Requested-With';
$sXhrHeaderIndexName = 'HTTP_'.str_replace('-', '_', strtoupper($sXhrHeaderName));
$sXhrHeader = $_SERVER[$sXhrHeaderIndexName] ?? null;
return ('XMLHttpRequest' === $sXhrHeader);
}
protected static $bPageMode = null;
/**
* @var boolean[]