Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Table Builder using an array datasource
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 18 Feb 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -38,6 +38,11 @@ class _Custom extends Table
|
||||
*/
|
||||
public $count = 0;
|
||||
|
||||
/**
|
||||
* Number of pages
|
||||
*/
|
||||
public $pages = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -47,6 +52,7 @@ class _Custom extends Table
|
||||
public function __construct( $dataSource, \IPS\Http\Url $baseUrl )
|
||||
{
|
||||
$this->dataSource = $dataSource;
|
||||
$this->count = count( $this->dataSource );
|
||||
|
||||
return parent::__construct( $baseUrl );
|
||||
}
|
||||
@@ -60,9 +66,10 @@ class _Custom extends Table
|
||||
*/
|
||||
public function getRows( $advancedSearchValues )
|
||||
{
|
||||
/* Sort out paging */
|
||||
$this->count = count( $this->dataSource );
|
||||
$this->pages = ceil( $this->count / $this->limit );
|
||||
if ( ! $this->pages )
|
||||
{
|
||||
$this->pages = ceil( $this->count / $this->limit );
|
||||
}
|
||||
|
||||
/* Get them */
|
||||
$rows = array();
|
||||
@@ -86,23 +93,17 @@ class _Custom extends Table
|
||||
/* Add it to the array */
|
||||
$rows[ $i ] = $row;
|
||||
}
|
||||
|
||||
|
||||
/* Quicksearch */
|
||||
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 )
|
||||
{
|
||||
return mb_strpos( $row[ $quickSearchColumn ], trim( \IPS\Request::i()->quicksearch ) ) !== FALSE;
|
||||
return mb_strpos( mb_strtolower( $row[ $quickSearchColumn ] ), mb_strtolower( 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[ key( $rows ) ][ $this->sortBy ] ) )
|
||||
{
|
||||
@@ -120,6 +121,12 @@ class _Custom extends Table
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Limit */
|
||||
if ( $this->limit and $this->count > $this->limit )
|
||||
{
|
||||
$rows = array_slice( $rows, ( $this->limit * ( $this->page - 1 ) ), $this->limit );
|
||||
}
|
||||
|
||||
/* Apply parsers */
|
||||
foreach( $rows as $i => $row )
|
||||
|
||||
Reference in new issue
Block a user