Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -61,9 +61,9 @@ class _databases extends \IPS\Node\Controller
);
$table->mainColumn = 'database_name';
$table->quickSearch = 'word_custom';
$table->quickSearch = 'database_name';
$table->sortBy = $table->sortBy ?: 'word_custom';
$table->sortBy = $table->sortBy ?: 'database_name';
$table->sortDirection = $table->sortDirection ?: 'asc';
/* Parsers */
@@ -121,15 +121,19 @@ class _databases extends \IPS\Node\Controller
return \IPS\Db::i()->select( 'SUM(category_records)', 'cms_database_categories', array( 'category_database_id=?', $row['database_id'] ) )->first();
}
);
/* Buttons */
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
);
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'databases_add' ) )
{
/* Buttons */
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
);
}
/*if ( \IPS\Application::appIsEnabled('forums') )
{
@@ -225,6 +229,8 @@ class _databases extends \IPS\Node\Controller
*/
public function add()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_add' );
$form = new \IPS\Helpers\Form( 'form', 'next' );
$form->addTab( 'cms_database_add_new' );
@@ -259,6 +265,8 @@ class _databases extends \IPS\Node\Controller
*/
public function import()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_add' );
if ( !file_exists( \IPS\Request::i()->file ) or md5_file( \IPS\Request::i()->file ) !== \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'generic_error', '3T259/3', 403, '' );
@@ -284,7 +292,7 @@ class _databases extends \IPS\Node\Controller
if ( !is_array( $data ) )
{
$database = new \IPS\cms\Databases;
$database->key = uniqid();
$database->key = mt_rand();
$database->save();
/* Set default perms, these will be editable post DB import */
@@ -488,7 +496,13 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
/* Check to ensure we have the same field type, if not default to text so data is retained (buildHelper also does this */
if ( ! class_exists( '\IPS\cms\Fields\\' . mb_ucfirst( $attrs['field_type'] ) ) and ! class_exists( '\IPS\Helpers\Form\\' . mb_ucfirst( $attrs['field_type'] ) ) )
{
$attrs['field_type'] = 'Text';
}
$attrs['_skip_formatting'] = TRUE;
$originalFieldId = $attrs['field_id'];
@@ -761,23 +775,34 @@ class _databases extends \IPS\Node\Controller
}
}
}
unset( \IPS\Data\Store::i()->db_import_cat_map );
unset( \IPS\Data\Store::i()->db_import_cat_parent_map );
unset( \IPS\Data\Store::i()->db_import_field_map );
}
$databaseId = \IPS\Data\Store::i()->db_import_db_id;
unset( \IPS\Data\Store::i()->db_import_db_id );
$database = \IPS\cms\Databases::load( $databaseId );
/* SORT IT OUT! */
if ( isset( \IPS\Data\Store::i()->db_import_field_map ) )
{
$map = \IPS\Data\Store::i()->db_import_field_map;
$sortId = intval( mb_substr( $database->field_sort, 6 ) );
if ( isset( $map[ $sortId ] ) )
{
$database->field_sort = 'field_' . $map[ $sortId ];
$database->save();
}
}
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
\IPS\cms\Templates::fixTemplateTags( $database->$name );
}
unset( \IPS\Data\Store::i()->db_import_db_id );
unset( \IPS\Data\Store::i()->db_import_cat_map );
unset( \IPS\Data\Store::i()->db_import_cat_parent_map );
unset( \IPS\Data\Store::i()->db_import_field_map );
@unlink( \IPS\Request::i()->file );
/* Done */
@@ -1147,6 +1172,24 @@ class _databases extends \IPS\Node\Controller
}
}
/**
* Resynchronise article comment counts
*
* @return void
*/
public function rebuildCommentCounts()
{
if ( isset( \IPS\Request::i()->process ) )
{
\IPS\Task::queue( 'core', 'RebuildItemCounts', array( 'class' => 'IPS\cms\Records' . \IPS\Request::i()->id ), 3, array( 'class' ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=form&id=' . \IPS\Request::i()->id ), 'database_rebuild_added' );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'databases', 'cms', 'admin' )->rebuildCommentCounts( \IPS\Request::i()->id );
}
}
/**
* Add/Edit
*
@@ -1178,7 +1221,7 @@ class _databases extends \IPS\Node\Controller
{
$new = TRUE;
$current = new \IPS\cms\Databases;
$current->key = uniqid(); # This is modified below to use a proper key
$current->key = mt_rand(); # This is modified below to use a proper key
$current->featured_settings = NULL;
$current->fixed_field_perms = NULL;
$current->save();
@@ -1203,7 +1246,7 @@ class _databases extends \IPS\Node\Controller
{
if ( is_array( $values['database_name'] ) )
{
$keyToUse = uniqid();
$keyToUse = mt_rand();
foreach( $values['database_name'] as $langId => $word )
{
if ( ! empty( $word ) )
@@ -1228,7 +1271,7 @@ class _databases extends \IPS\Node\Controller
/* It's taken... */
if ( $current->id != $database->id )
{
$current->key .= '_' . uniqid();
$current->key .= '_' . mt_rand();
}
}
catch( \OutOfRangeException $ex )
@@ -1415,7 +1458,7 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Db::i()->insert( 'cms_page_widget_areas', array(
'area_page_id' => $newPage->id,
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => uniqid(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => mt_rand(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_area' => 'col1',
'area_orientation' => 'horizontal'
) );
@@ -1771,7 +1814,11 @@ class _databases extends \IPS\Node\Controller
if ( $current )
{
$rebuildUrl = \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&id=' . $current->id . '&do=rebuildTopicContent' );
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', NULL, array( 'sprintf' => array( $rebuildUrl ) ) );
$rebuildUrlCounts = \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&id=' . $current->id . '&do=rebuildCommentCounts' );
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' ) . ' ' .
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', NULL, array( 'sprintf' => array( $rebuildUrl ) ) ) . ' ' .
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_comments__rebuild', NULL, array( 'sprintf' => array( $rebuildUrlCounts ) ) );
}
else
{
@@ -1824,7 +1871,7 @@ class _databases extends \IPS\Node\Controller
/* Overwrite field */
$field = new \IPS\Helpers\Form\Translatable( 'page_name', FALSE, NULL, array( 'app' => 'cms', 'key' => NULL, 'maxLength' => 64 ), function( $val )
{
if ( empty( $val ) AND \IPS\Request::i()->database_create_page === 'new' )
if ( !trim( $val[ \IPS\Lang::defaultLanguage() ] ) AND \IPS\Request::i()->database_create_page === 'new' )
{
throw new \DomainException('form_required');
}
@@ -144,26 +144,35 @@ class _records extends \IPS\Dispatcher\Controller
/* Buttons */
$table->rowButtons = function( $row )
{
return array(
'edit' => array(
'title' => 'edit',
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=form' ),
'data' => array()
),
'move' => array(
$return = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'records_edit' ) )
{
$return['edit'] = array(
'title' => 'edit',
'icon' => 'pencil',
'link' => \IPS\Http\Url::internal('app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=form'),
'data' => array()
);
}
$return['move'] = array(
'title' => 'move',
'icon' => 'arrow-right',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&do=select&move=' . $row['primary_id_field'] ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('database_select_category' ) )
),
'delete' => array(
);
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'records_delete' ) )
{
$return['delete'] = array(
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id . '&id=' . $row['primary_id_field'] . '&do=delete' ),
'data' => array( 'delete' => '' )
),
);
);
}
return $return;
};
$table->parsers = array(
@@ -244,7 +253,7 @@ class _records extends \IPS\Dispatcher\Controller
}
catch( \OutofRangeException $ex )
{
\IPS\Output::i()->error( 'no_permission', '2T253/1', 403, '' );
\IPS\Output::i()->error( 'no_module_permission', '2T253/1', 403, '' );
}
/* Clear guest page caches */
@@ -323,6 +332,8 @@ class _records extends \IPS\Dispatcher\Controller
*/
public function form()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'records_edit' );
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$title = \IPS\Member::loggedIn()->language()->addToStack('content_record_db_title', TRUE, array( 'sprintf' => array( $database->_title ) ) );
@@ -450,7 +461,7 @@ class _records extends \IPS\Dispatcher\Controller
/* Claim attachments */
foreach( $fieldClass::data() as $key => $field )
{
if ( ucfirst( $field->type ) === 'Editor' )
if ( mb_ucfirst( $field->type ) === 'Editor' )
{
\IPS\File::claimAttachments( 'RecordField_'. $field->id , $current->id, NULL, 'RecordField_'. $field->id, FALSE );
}
@@ -85,11 +85,11 @@ class _ajax extends \IPS\Dispatcher\Controller
/* Find it from the normal template system */
if ( isset( \IPS\Request::i()->block_app ) )
{
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, mt_rand() );
}
else
{
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, uniqid() );
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, mt_rand() );
}
$location = $plugin->getTemplateLocation();
@@ -99,7 +99,7 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( ! isset( \IPS\Request::i()->noencode ) OR ! \IPS\Request::i()->noencode )
{
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], \IPS\HTMLENTITIES, 'UTF-8', TRUE );
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], ENT_DISALLOWED, 'UTF-8', TRUE );
}
$templateArray = array(
@@ -142,7 +142,7 @@ class _ajax extends \IPS\Dispatcher\Controller
'template_key' => $template->key,
'template_title' => $template->title,
'template_desc' => $template->desc,
'template_content' => ( isset( \IPS\Request::i()->noencode ) AND \IPS\Request::i()->noencode ) ? $template->content : htmlentities( $template->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ),
'template_content' => ( isset( \IPS\Request::i()->noencode ) AND \IPS\Request::i()->noencode ) ? $template->content : htmlentities( $template->content, ENT_DISALLOWED, 'UTF-8', TRUE ),
'template_location' => $template->location,
'template_group' => $template->group,
'template_container' => $template->container,
+81 -1
View File
@@ -195,6 +195,86 @@ class _media extends \IPS\Node\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->media( $output );
}
}
/**
* Replace an existing file
*
* @return void
*/
public function replace()
{
if( !isset( \IPS\Request::i()->id ) OR !\IPS\Request::i()->id )
{
\IPS\Output::i()->error( 'missing_media_file', '3T334/2', 404, '' );
}
try
{
$media = \IPS\cms\Media::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'missing_media_file', '3T334/3', 404, '' );
}
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => FALSE, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( $values = $form->values() )
{
$existingFileExtension = mb_substr( $media->filename_stored, mb_strrpos( $media->filename_stored, '.' ) + 1 );
$newFileExtension = mb_substr( $values['media_filename']->originalFilename, mb_strrpos( $values['media_filename']->originalFilename, '.' ) + 1 );
/* If we have the same extension, we will just retain the same filename */
if( $existingFileExtension == $newFileExtension )
{
$media->file_object = (string) \IPS\File::create( 'cms_Media', $media->filename_stored, $values['media_filename']->contents(), 'pages_media', TRUE, NULL, FALSE );
}
/* Otherwise we need to update the rest of the file info too */
else
{
$media->is_image = $values['media_filename']->isImage();
$media->filename = $values['media_filename']->originalFilename;
$media->filename_stored = $media->parent . '_' . $media->filename;
$media->file_object = (string) \IPS\File::create( 'cms_Media', $media->filename_stored, $values['media_filename']->contents(), 'pages_media', TRUE, NULL, FALSE );
}
$media->setFullPath( ( $media->parent ? \IPS\cms\Media\Folder::load( $media->parent )->path : '' ) );
$media->save();
/* Remove the original as we created a copy with a slightly altered filename */
try
{
$values['media_filename']->delete();
}
catch( \Exception $ex ) { }
if ( \IPS\Request::i()->isAjax() )
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $media->parent );
$rows = array();
foreach ( $data as $id => $row )
{
if ( $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
\IPS\Output::i()->sendOutput( json_encode( array( 'fileID' => $media->id, 'folderID' => $media->parent, 'rows' => $rows ) ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=media' ) );
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'upload', $form, FALSE );
}
/**
* Upload items
@@ -206,7 +286,7 @@ class _media extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf', 'svg' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( ! isset( \IPS\Request::i()->media_parent ) and ! \IPS\Request::i()->media_parent )
{
@@ -240,6 +240,17 @@ class _pages extends \IPS\Node\Controller
/* Clear Sidebar Caches */
\IPS\Widget::deleteCaches();
/* Possible gateway choice changed and thusly menu and page_urls will change */
if ( isset( \IPS\Data\Store::i()->pages_page_urls ) )
{
unset( \IPS\Data\Store::i()->pages_page_urls );
}
if ( isset( \IPS\Data\Store::i()->frontNavigation ) )
{
unset( \IPS\Data\Store::i()->frontNavigation );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
}
@@ -467,6 +478,12 @@ FILE;
/* No default found in destination folder, do nothing */
}
}
/* If page filename changes or the folder ID changes, we need to clear front navigation cache*/
if( $old !== NULL AND ( $old->folder_id != $new->folder_id OR $old->seo_name != $new->seo_name ) )
{
unset( \IPS\Data\Store::i()->pages_page_urls );
}
parent::_afterSave( $old, $new, $lastUsedTab );
}
@@ -93,7 +93,7 @@ class _templates extends \IPS\Dispatcher\Controller
/* Open XML file */
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
$prefix = date('m') . '_' . date('d') . '_' . date('y') . '_';
$prefix = 'm' . date('m') . '_' . date('d') . '_' . date('y') . '_';
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
if ( ! @$xml->read() )
@@ -710,7 +710,7 @@ class _templates extends \IPS\Dispatcher\Controller
list( $widgetApp, $widgetKey ) = explode( '__', $values['block_template_plugin_import'] );
/* Find it from the normal template system */
$plugin = \IPS\Widget::load( \IPS\Application::load( $widgetApp ), $widgetKey, uniqid(), array() );
$plugin = \IPS\Widget::load( \IPS\Application::load( $widgetApp ), $widgetKey, mt_rand(), array() );
$location = $plugin->getTemplateLocation();