Skip to content

Commit

Permalink
sync with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
nightflyza committed Jan 13, 2025
1 parent 32510eb commit 0d1c236
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 5 deletions.
2 changes: 1 addition & 1 deletion RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.5 rev 112
0.0.5 rev 113
82 changes: 78 additions & 4 deletions api/libs/api.astral.php
Original file line number Diff line number Diff line change
Expand Up @@ -2547,16 +2547,18 @@ function wf_CleanDiv() {
* @param bool $addFooter
* @param string $footerOpts
* @param string $footerTHOpts
* @param bool $serverSide Use server-side processing?
*
* @return string
*/
function wf_JqDtLoader($columns, $ajaxUrl, $saveState = false, $objects = 'users', $rowsCount = 100, $opts = '', $addFooter = false, $footerOpts = '', $footerTHOpts = '') {
function wf_JqDtLoader($columns, $ajaxUrl, $saveState = false, $objects = 'users', $rowsCount = 100, $opts = '', $addFooter = false, $footerOpts = '', $footerTHOpts = '', $serverSide = false) {

$tableId = 'jqdt_' . md5($ajaxUrl);
$result = '';
$saveState = ($saveState) ? 'true' : 'false';
$opts = (!empty($opts)) ? $opts . ',' : '';

$sside = ($serverSide) ? '"serverSide": true,' : '';
$lenMenu=($serverSide) ? '[[10, 25, 50, 100, 200], [10, 25, 50, 100, 200]]' : '[[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "' . __('All') . '"]]';
$jq_dt = wf_tag('script', false, '', ' type="text/javascript" charset="utf-8"');
$jq_dt .= '
$(document).ready(function() {
Expand Down Expand Up @@ -2589,7 +2591,8 @@ function wf_JqDtLoader($columns, $ajaxUrl, $saveState = false, $objects = 'users
"iDisplayLength": ' . $rowsCount . ',
"sAjaxSource": \'' . $ajaxUrl . '\',
"bDeferRender": true,
"lengthMenu": [[10, 25, 50, 100, 200, -1], [10, 25, 50, 100, 200, "' . __('All') . '"]],
' . $sside . '
"lengthMenu": '.$lenMenu.',
' . $opts . '
"bJQueryUI": true
} );
Expand Down Expand Up @@ -4429,6 +4432,46 @@ class wf_JqDtHelper {
*/
protected $allRows = array();

/**
* Total available records count
*
* @var int
*/
protected $rowsTotalCount = 0;
/**
* Filtered rows count
*
* @var int
*/
protected $rowsFilteredCount = 0;
/**
* The draw counter that this object is a response to
*
* @var int
*/
protected $draw = 0;
/**
* Server side processing flag
*
* @var bool
*/
protected $sSideFlag = true;

public function __construct($serverSideProcessing = false) {
$this->setServerSideProcessing($serverSideProcessing);
}

/**
* Sets the server-side processing state.
*
* @param bool $state
*
* @return void
*/
public function setServerSideProcessing($state = false) {
$this->sSideFlag = $state;
}

/**
* Adds new row to elements array, dont forget unset() data in your loop, after adding new row.
*
Expand All @@ -4452,17 +4495,48 @@ public function addRow($data) {
* @return string
*/
protected function renderJson() {
$result = array("aaData" => $this->allRows);
$result = array();
if ($this->sSideFlag) {
$result += array(
'draw' => 0,
'recordsTotal' => $this->rowsTotalCount,
'recordsFiltered' => $this->rowsFilteredCount
);
}
$result += array("aaData" => $this->allRows);
$result = json_encode($result);
return ($result);
}

/**
* Sets total rows count
*
* @param int $count
*
* @return void
*/
public function setTotalRowsCount($count) {
$this->rowsTotalCount = $count;
}

/**
* Sets filtered rows count
*
* @param int $count
*
* @return void
*/
public function setFilteredRowsCount($count) {
$this->rowsFilteredCount = $count;
}

/**
* Renders empty page JSON data for background ajax requests
*
* @return void
*/
public function getJson() {
header('Content-Type: application/json');
die($this->renderJson());
}

Expand Down

0 comments on commit 0d1c236

Please sign in to comment.