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

+3 -3
View File
@@ -54,7 +54,7 @@ class _Content extends Table
public $sortOptions = array();
/**
* @brief Honor the pinned flag for sorting. Default exclusions include vnc and activity streams
* @brief Honor the pinned flag for sorting. Will be set to false in stream-like views
*/
protected $honorPinned = TRUE;
@@ -247,8 +247,8 @@ class _Content extends Table
}
/* Get results */
$it = $class::getItemsWithPermission( $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $this->permCheck, $this->includeHiddenContent, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, FALSE, $this->joins );
$this->count = $it->count( TRUE );
$this->count = $class::getItemsWithPermission( $where, $sortBy, NULL, $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, TRUE, $this->joins );
$it = $class::getItemsWithPermission( $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, FALSE, $this->joins );
$this->pages = ceil( $this->count / $this->limit );
$rows = iterator_to_array( $it );
+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;
}
+14 -7
View File
@@ -99,7 +99,7 @@ class _Db extends Table
{
if ( is_callable( $this->quickSearch ) )
{
$where[] = call_user_func( $this->quickSearch, \IPS\Request::i()->quicksearch );
$where[] = call_user_func( $this->quickSearch, trim( \IPS\Request::i()->quicksearch ) );
}
else
{
@@ -112,7 +112,7 @@ class _Db extends Table
$_where[] = "LOWER(`{$c}`) LIKE CONCAT( '%', ?, '%' )";
}
$where[] = array_merge( array( '(' . implode( ' OR ', $_where ) . ')' ), array_fill( 0, count( $_where ), mb_strtolower( \IPS\Request::i()->quicksearch ) ) );
$where[] = array_merge( array( '(' . implode( ' OR ', $_where ) . ')' ), array_fill( 0, count( $_where ), mb_strtolower( trim( \IPS\Request::i()->quicksearch ) ) ) );
}
}
@@ -164,7 +164,14 @@ class _Db extends Table
break;
case SEARCH_SELECT:
$where[] = array( "{$k}=?", $v );
if ( isset( $options['multiple'] ) AND $options['multiple'] === TRUE )
{
$where[] = array( \IPS\Db::i()->in( $k, $v ) );
}
else
{
$where[] = array( "{$k}=?", $v );
}
break;
case SEARCH_MEMBER:
@@ -262,7 +269,7 @@ class _Db extends Table
{
foreach( $this->joins as $join )
{
$query->join( $join['from'], ( isset( $join['where'] ) ? $join['where'] : null ), 'LEFT' );
$query->join( $join['from'], ( isset( $join['where'] ) ? $join['where'] : null ), ( isset( $join['type'] ) ) ? $join['type'] : 'LEFT' );
}
}
@@ -337,7 +344,7 @@ class _Db extends Table
{
$select->setKeyField( $this->keyField );
}
foreach ( $select as $rowId => $row )
{
/* Add in any 'custom' fields */
@@ -349,7 +356,7 @@ class _Db extends Table
{
$row[ $k ] = isset( $_row[ $k ] ) ? $_row[ $k ] : NULL;
}
if( !empty( $advancedSearchValues ) )
{
foreach ( $advancedSearchValues as $k => $v )
@@ -369,7 +376,7 @@ class _Db extends Table
}
else
{
$v = htmlentities( $v, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
$v = htmlspecialchars( $v, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
}
/* Are we including this one? */