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'];
}
@@ -163,10 +163,29 @@ class _index extends \IPS\cms\Databases\Controller
*/
protected function form()
{
/* If the page is the default page and Pages is the default app, the node selector cannot find the page as it bypasses the Database dispatcher */
if ( \IPS\cms\Pages\Page::$currentPage === NULL and \IPS\cms\Databases\Dispatcher::i()->databaseId === NULL and isset( \IPS\Request::i()->page_id ) )
{
try
{
\IPS\cms\Pages\Page::$currentPage = \IPS\cms\Pages\Page::load( \IPS\Request::i()->page_id );
$database = \IPS\cms\Pages\Page::$currentPage->getDatabase();
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'content_err_page_404', '2T389/1', 404, '' );
}
}
else if ( \IPS\cms\Pages\Page::$currentPage === NULL and \IPS\cms\Databases\Dispatcher::i()->databaseId === NULL and isset( \IPS\Request::i()->d ) )
{
\IPS\cms\Pages\Page::$currentPage = \IPS\cms\Pages\Page::loadByDatabaseId( \IPS\Request::i()->d );
}
$form = new \IPS\Helpers\Form( 'select_category', 'continue' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Node( 'category', NULL, TRUE, array(
'url' => \IPS\cms\Pages\Page::$currentPage->url()->setQueryString('do', 'form'),
'url' => \IPS\cms\Pages\Page::$currentPage->url()->setQueryString( array( 'do' => 'form', 'page_id' => \IPS\cms\Pages\Page::$currentPage->id ) ),
'class' => 'IPS\cms\Categories' . \IPS\cms\Databases\Dispatcher::i()->databaseId,
'permissionCheck' => function( $node )
{
@@ -262,17 +262,17 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $record->averageReviewRating(),
'ratingCount' => $record->rating_hits,
'reviewCount' => $record->record_reviews,
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
);
}
elseif( $record->container()->allow_rating )
elseif( $record->container()->allow_rating AND $record->averageRating() AND $record->numberOfRatings() )
{
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $record->averageRating(),
'ratingCount' => $record->numberOfRatings(),
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
);
}
@@ -605,10 +605,21 @@ class _record extends \IPS\Content\Controller
$title = \IPS\Member::loggedIn()->language()->addToStack( 'content_record_form_edit_record', FALSE, array( 'sprintf' => array( $record->_title ) ) );
$formElements = $recordClass::formElements( $record, $category );
if ( \IPS\Request::i()->id AND ! $record->canEdit() )
// We check if the form has been submitted to prevent the user loosing their content
if ( isset( \IPS\Request::i()->form_submitted ) )
{
\IPS\Output::i()->error( 'module_no_permission', '2T252/D', 403, '' );
if ( ! $record->couldEdit() )
{
\IPS\Output::i()->error( 'module_no_permission', '2T252/G', 403, '' );
}
}
else
{
if ( ! $record->canEdit() )
{
\IPS\Output::i()->error( 'module_no_permission', '2T252/D', 403, '' );
}
}
$form = new \IPS\Helpers\Form( 'form', isset( \IPS\Member::loggedIn()->language()->words[ $recordClass::$formLangPrefix . '_save' ] ) ? $recordClass::$formLangPrefix . '_save' : 'save' );