Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+49 -20
View File
@@ -27,7 +27,17 @@ class _Custom extends Table
* @brief Data
*/
protected $dataSource;
/**
* @brief Parse Source
*/
public $parseSource = TRUE;
/**
* Number of results
*/
public $count = 0;
/**
* Constructor
*
@@ -50,6 +60,10 @@ class _Custom extends Table
*/
public function getRows( $advancedSearchValues )
{
/* Sort out paging */
$this->count = count( $this->dataSource );
$this->pages = ceil( $this->count / $this->limit );
/* Get them */
$rows = array();
foreach ( $this->dataSource as $i => $data )
@@ -64,29 +78,13 @@ class _Custom extends Table
{
continue;
}
/* Parse if necessary */
if( isset( $this->parsers[ $k ] ) )
{
$v = call_user_func( $this->parsers[ $k ], $v, $data );
}
else
{
$v = htmlentities( $v, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
}
/* Add to array */
$row[ $k ] = $v;
}
/* Add in some buttons if necessary */
if( $this->rowButtons !== NULL )
{
$row['_buttons'] = call_user_func( $this->rowButtons, $row, $i );
}
/* Add it to the array */
$rows[] = $row;
$rows[ $i ] = $row;
}
/* Quicksearch */
@@ -95,12 +93,18 @@ class _Custom extends Table
$quickSearchColumn = $this->quickSearch;
$rows = array_filter( $rows, is_callable( $this->quickSearch ) ? $this->quickSearch : function( $row ) use ( $quickSearchColumn )
{
return mb_strpos( $row[ $quickSearchColumn ], \IPS\Request::i()->quicksearch ) !== FALSE;
return mb_strpos( $row[ $quickSearchColumn ], trim( \IPS\Request::i()->quicksearch ) ) !== FALSE;
} );
}
/* Limit */
if ( $this->limit and $this->count > $this->limit )
{
$rows = array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit );
}
/* Do we need to sort? */
if( !empty( $rows ) and $this->sortBy and isset( $rows[0][ $this->sortBy ] ) )
if( !empty( $rows ) and $this->sortBy and isset( $rows[ key( $rows ) ][ $this->sortBy ] ) )
{
$sortBy = $this->sortBy;
$sortDirection = $this->sortDirection;
@@ -116,6 +120,31 @@ class _Custom extends Table
}
});
}
/* Apply parsers */
foreach( $rows as $i => $row )
{
foreach( $row as $k => $v )
{
/* Parse if necessary */
if( isset( $this->parsers[ $k ] ) )
{
$v = call_user_func( $this->parsers[ $k ], $v, $this->dataSource[ $i ] );
}
else
{
$v = htmlspecialchars( $v, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
}
$rows[ $i ][ $k ] = $v;
}
/* Add in some buttons if necessary */
if( $this->rowButtons !== NULL )
{
$rows[ $i ]['_buttons'] = call_user_func( $this->rowButtons, $row, $i );
}
}
return $rows;
}