Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+21 -3
View File
@@ -214,11 +214,10 @@ class Content extends Table
$this->where[] = array($class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'] . '=?', $container->_id);
}
$this->sortDirection = ( $this->sortDirection !== NULL ) ? $this->sortDirection : $container->_sortOrder;
if ( !$this->sortBy and ! empty( $container->_sortBy ) )
{
$this->sortBy = $class::$databaseTable . '.' . $class::$databasePrefix . $container->_sortBy;
$this->sortDirection = $container->_sortOrder;
}
if ( !$this->filter )
{
@@ -264,7 +263,7 @@ class Content extends Table
}
/* Set available sort options */
foreach ( array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views' ) as $k )
foreach ( array( 'updated', 'last_comment', 'title', 'rating', 'date', 'num_comments', 'num_reviews', 'views', 'num_helpful' ) as $k )
{
if ( isset( $class::$databaseColumnMap[ $k ] ) and !isset( $this->sortOptions[ $k ] ) )
{
@@ -395,6 +394,25 @@ class Content extends Table
/* @var Item $class */
/* @var array $databaseColumnMap */
$sortBy = $this->sortBy . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
/* If we are sorting by rating, we want to make sure we take into account the number of ratings */
if( array_key_exists( 'rating', $this->sortOptions ) and $this->sortBy == $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['rating'] )
{
if( isset( $class::$databaseColumnMap['rating_average'] ) )
{
$sortBy = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['rating_average'] . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
}
if( isset( $class::$databaseColumnMap['rating_hits'] ) )
{
$sortBy .= ',' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['rating_hits'] . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
}
elseif( isset( $class::$databaseColumnMap['num_reviews'] ) )
{
$sortBy .= ',' . $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['num_reviews'] . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
}
}
if ( IPS::classUsesTrait( $class, 'IPS\Content\Pinnable' ) and $this->honorPinned )
{
$column = $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['pinned'];
+34 -27
View File
@@ -208,7 +208,7 @@ class Db extends Table
{
unset( $advancedSearchValues[ $k ] );
}
break;
break;
case SEARCH_DATE_RANGE:
$timezone = ( Member::loggedIn()->timezone ? new DateTimeZone( Member::loggedIn()->timezone ) : NULL );
@@ -261,37 +261,44 @@ class Db extends Table
break;
case SEARCH_NODE:
$nodeClass = $options['class'];
$prop = $options['searchProp'] ?? '_id';
if ( !is_array( $v ) )
if( $v )
{
$v = array( $v );
}
$values = array();
foreach ( $v as $_v )
{
if ( !is_object( $_v ) )
$nodeClass = $options[ 'class' ];
$prop = $options[ 'searchProp' ]??'_id';
if( !is_array( $v ) )
{
if ( mb_substr( $_v, 0, 2 ) === 's.' )
{
$nodeClass = $nodeClass::$subnodeClass;
$_v = mb_substr( $_v, 2 );
}
try
{
$_v = $nodeClass::load( $_v );
}
catch ( OutOfRangeException $e )
{
continue;
}
$v = [$v];
}
$values[] = $_v->$prop;
$values = [];
foreach( $v as $_v )
{
if( !is_object( $_v ) )
{
if( mb_substr( $_v, 0, 2 ) === 's.' )
{
$nodeClass = $nodeClass::$subnodeClass;
$_v = mb_substr( $_v, 2 );
}
try
{
$_v = $nodeClass::load( $_v );
}
catch( OutOfRangeException $e )
{
continue;
}
}
$values[] = $_v->$prop;
}
$where[] = [$this->db->in( $k, $values )];
}
$where[] = array( $this->db->in( $k, $values ) );
else
{
unset( $advancedSearchValues[ $k ] );
}
break;
case SEARCH_NUMERIC:
case SEARCH_NUMERIC_TEXT:
switch ( $v[0] )