Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Helpers\Table;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -51,7 +51,7 @@ class _Custom extends Table
|
||||
public function __construct( $dataSource, \IPS\Http\Url $baseUrl )
|
||||
{
|
||||
$this->dataSource = $dataSource;
|
||||
$this->count = count( $this->dataSource );
|
||||
$this->count = \count( $this->dataSource );
|
||||
|
||||
return parent::__construct( $baseUrl );
|
||||
}
|
||||
@@ -74,13 +74,13 @@ class _Custom extends Table
|
||||
$rows = array();
|
||||
foreach ( $this->dataSource as $i => $data )
|
||||
{
|
||||
$row = $this->include ? array_combine( $this->include, array_fill( 0, count( $this->include ), NULL ) ) : array();
|
||||
$row = $this->include ? array_combine( $this->include, array_fill( 0, \count( $this->include ), NULL ) ) : array();
|
||||
|
||||
/* Get the columns from the XML */
|
||||
foreach ( $data as $k => $v )
|
||||
{
|
||||
/* Are we including this one? */
|
||||
if( ( $this->include !== NULL and !in_array( $k, $this->include ) ) or ( $this->exclude !== NULL and in_array( $k, $this->exclude ) ) )
|
||||
if( ( $this->include !== NULL and !\in_array( $k, $this->include ) ) or ( $this->exclude !== NULL and \in_array( $k, $this->exclude ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -97,10 +97,13 @@ class _Custom extends Table
|
||||
if ( $this->quickSearch !== NULL and \IPS\Request::i()->quicksearch )
|
||||
{
|
||||
$quickSearchColumn = $this->quickSearch;
|
||||
$rows = array_filter( $rows, is_callable( $this->quickSearch ) ? $this->quickSearch : function( $row ) use ( $quickSearchColumn )
|
||||
$rows = array_filter( $rows, \is_callable( $this->quickSearch ) ? $this->quickSearch : function( $row ) use ( $quickSearchColumn )
|
||||
{
|
||||
return mb_strpos( mb_strtolower( $row[ $quickSearchColumn ] ), mb_strtolower( trim( \IPS\Request::i()->quicksearch ) ) ) !== FALSE;
|
||||
} );
|
||||
|
||||
$this->count = \count( $rows );
|
||||
$this->pages = ceil( $this->count / $this->limit );
|
||||
}
|
||||
|
||||
/* Do we need to sort? */
|
||||
@@ -124,7 +127,7 @@ class _Custom extends Table
|
||||
/* Limit */
|
||||
if ( $this->limit and $this->count > $this->limit )
|
||||
{
|
||||
$rows = array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit, TRUE );
|
||||
$rows = \array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit, TRUE );
|
||||
}
|
||||
|
||||
/* Apply parsers */
|
||||
@@ -135,7 +138,8 @@ class _Custom extends Table
|
||||
/* Parse if necessary */
|
||||
if( isset( $this->parsers[ $k ] ) )
|
||||
{
|
||||
$v = call_user_func( $this->parsers[ $k ], $v, $this->dataSource[ $i ] );
|
||||
$parserFunction = $this->parsers[ $k ];
|
||||
$v = $parserFunction( $v, $this->dataSource[ $i ] );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -148,7 +152,8 @@ class _Custom extends Table
|
||||
/* Add in some buttons if necessary */
|
||||
if( $this->rowButtons !== NULL )
|
||||
{
|
||||
$rows[ $i ]['_buttons'] = call_user_func( $this->rowButtons, $row, $i );
|
||||
$rowButtons = $this->rowButtons;
|
||||
$rows[ $i ]['_buttons'] = $rowButtons( $row, $i );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user