mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
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:
@@ -2452,7 +2452,7 @@ JS
|
||||
|
||||
// N°3750 refresh container data-input-type attribute if in an Ajax context
|
||||
// indeed in such a case we're only returning the field value content and not the parent container, so we need to update it !
|
||||
if (WebPage::IsAjaxPage($oPage)) {
|
||||
if (utils::IsXmlHttpRequest()) {
|
||||
$sHTMLValue .= <<<HTML
|
||||
<script>
|
||||
$("[data-input-id='$iId']").data("input-type", "$sInputType");
|
||||
|
||||
@@ -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[]
|
||||
|
||||
@@ -1491,9 +1491,4 @@ EOD
|
||||
{
|
||||
return $this->sTemplateRelPath;
|
||||
}
|
||||
|
||||
public static function IsAjaxPage(WebPage $oPage)
|
||||
{
|
||||
return ($oPage instanceof AjaxPage);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user