mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
N°3648 - FIx size of DataTable
This commit is contained in:
61
sources/application/WebPage/JsonPage.php
Normal file
61
sources/application/WebPage/JsonPage.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2021 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
class JsonPage extends WebPage
|
||||
{
|
||||
protected $aData = [];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function GetData(): array
|
||||
{
|
||||
return $this->aData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aData
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function SetData(array $aData)
|
||||
{
|
||||
$this->aData = $aData;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $aDataRow
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function AddData(array $aDataRow)
|
||||
{
|
||||
$this->aData[] = $aDataRow;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function output()
|
||||
{
|
||||
$this->add_header('Content-type: application/json');
|
||||
|
||||
foreach ($this->a_headers as $s_header) {
|
||||
header($s_header);
|
||||
}
|
||||
|
||||
$aScripts = array_merge($this->a_init_scripts, $this->a_scripts, $this->a_ready_scripts);
|
||||
|
||||
$aJson = [
|
||||
'data' => $this->aData,
|
||||
'scripts' => $aScripts,
|
||||
];
|
||||
|
||||
echo json_encode($aJson);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user