Version 4.3.6

This commit is contained in:
Neo committed 2025-12-19 05:49:12 -08:00
1 parent fe1acf984a
commit 1a0c7fd3c2
609 files changed
+14707 -5726

No files matched your search

@@ -184,16 +184,16 @@ class _category extends \IPS\cms\Databases\Controller
$sortFields[ $database->field_title ] = $fieldClass::load( $database->field_title );
foreach( $sortFields as $id => $obj )
{
if ( $table->sortBy == 'field_' . $id )
if ( $table->sortBy == $RecordsClass::$databaseTable . '.' . 'field_' . $id OR $table->sortBy == 'field_' . $id )
{
if ( $obj->type == 'Number' )
{
$table->sortBy = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
$table->sortOptions[ $table->sortBy ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
break;
}
elseif( $obj->type == 'Date' )
{
$table->sortBy = 'CAST(`field_' . $id . '` AS UNSIGNED)';
$table->sortOptions[ $table->sortBy ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
break;
}
}
@@ -231,7 +231,7 @@ class _category extends \IPS\cms\Databases\Controller
}
$sortBy = array(
'record_last_comment' => 'content_record_last_comment',
'record_updated' => 'content_record_last_updated',
'record_comments' => 'content_record_comments',
'record_views' => 'content_record_views',
'field_' . $database->field_title => 'content_record_title',
@@ -241,6 +241,9 @@ class _category extends \IPS\cms\Databases\Controller
/* Ensure we have all sort options available */
$table->sortOptions = array_unique( array_merge( $table->sortOptions, array_combine( array_keys( $sortBy ), array_keys( $sortBy ) ) ) );
/* To avoid confusion, label 'updated' as 'Recently Updated' as last comment */
\IPS\Member::loggedIn()->language()->words[ $table->langPrefix . 'sort_updated' ] = \IPS\Member::loggedIn()->language()->addToStack('content_record_last_comment');
if ( !isset( $sortBy[ $database->field_sort ] ) )
{
switch ( $database->field_sort )
@@ -325,7 +328,18 @@ class _category extends \IPS\cms\Databases\Controller
$table->advancedSearch['sort_by'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
}
$table->sortOptions[ 'field_' . $obj->id ] = isset( $table->sortOptions[ 'field_' . $obj->id ] ) ? $table->sortOptions[ 'field_' . $obj->id ] : 'field_' . $obj->id;
if ( in_array( $obj->type, array( 'Date', 'DateRange' ) ) )
{
$table->sortOptions[ 'field_' . $obj->id ] = 'CAST(`field_' . $obj->id . '` AS UNSIGNED)';
}
else if ( $obj->type == 'Number' )
{
$table->sortOptions[ 'field_' . $obj->id ] = 'LENGTH(`field_' . $obj->id . '`) ' . $table->sortDirection . ',`field_' . $obj->id . '`';
}
else
{
$table->sortOptions[ 'field_' . $obj->id ] = isset( $table->sortOptions[ 'field_' . $obj->id ] ) ? $table->sortOptions[ 'field_' . $obj->id ] : 'field_' . $obj->id;
}
}
$table->advancedSearchCallback = function( $table, $values ) use ( $database, $sortBy, $customFields )
@@ -414,17 +428,18 @@ class _category extends \IPS\cms\Databases\Controller
{
if ( isset( $customFields[ mb_substr( $values['sort_by'], 6 ) ] ) and $customFields[ mb_substr( $values['sort_by'], 6 ) ]->type == 'Number' )
{
$table->sortBy = 'LENGTH(`' . $values['sort_by'] . '`) ' . $table->sortDirection . ',`' . $values['sort_by'] . '`';
$table->sortOptions[ $values['sort_by'] ] = 'LENGTH(`' . $values['sort_by'] . '`) ' . $table->sortDirection . ',`' . $values['sort_by'] . '`';
}
elseif( isset( $customFields[ mb_substr( $values['sort_by'], 6 ) ] ) and $customFields[ mb_substr( $values['sort_by'], 6 ) ]->type == 'Date' )
{
$table->sortBy = 'CAST(`' . $values['sort_by'] . '` AS UNSIGNED)';
$table->sortOptions[ $values['sort_by'] ] = 'CAST(`' . $values['sort_by'] . '` AS UNSIGNED)';
}
else
{
$table->sortBy = $values['sort_by'];
$table->sortOptions[ $values['sort_by'] ] = $values['sort_by'];
}
$table->sortBy = $values['sort_by'];
$table->sortDirection = $values['sort_direction'];
}