Version 4.3.0
This commit is contained in:
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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -53,7 +53,12 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $database->id, array_merge( array( implode( ' OR ', $where ) ), $binds ), 'LENGTH(' . $field . ') ASC', array( 0, 20 ) ) as $row )
|
||||
{
|
||||
$record = $class::constructFromData( $row );
|
||||
|
||||
|
||||
if ( ! $record->canView() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $database->use_categories )
|
||||
{
|
||||
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', NULL, array( 'sprintf' => array( $record->container()->_title ) ) );
|
||||
|
||||
@@ -79,7 +79,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$category = $catClass::loadAndCheckPerms( \IPS\cms\Databases\Dispatcher::i()->categoryId, 'read' );
|
||||
$category = $catClass::loadAndCheckPerms( \IPS\cms\Databases\Dispatcher::i()->categoryId );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -169,17 +169,20 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$where = NULL;
|
||||
}
|
||||
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId, $category->url(), $where, $category, NULL, 'view', isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId, $category->url(), $where, $category, NULL, 'read', isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
|
||||
$table->tableTemplate = array( \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' ), 'categoryTable' );
|
||||
$table->rowsTemplate = array( \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' ), 'recordRow' );
|
||||
$table->baseUrl = $table->baseUrl->setQueryString( 'd', \IPS\cms\Databases\Dispatcher::i()->databaseId );
|
||||
$table->hover = TRUE;
|
||||
$table->sortBy = ( isset( \IPS\Request::i()->sortby ) ) ? \IPS\Request::i()->sortby : ( $database->field_sort ? $database->field_sort : 'record_last_comment' );
|
||||
$table->sortBy = ( isset( \IPS\Request::i()->sortby ) ) ? \IPS\Request::i()->sortby : ( $database->field_sort ? $RecordsClass::$databaseTable . '.' . $RecordsClass::$databasePrefix . $database->field_sort : 'record_last_comment' );
|
||||
$table->sortDirection = ( isset( \IPS\Request::i()->sortdirection ) ) ? \IPS\Request::i()->sortdirection : ( $database->field_direction ? $database->field_direction : 'desc' );
|
||||
$table->limit = $database->field_perpage ? $database->field_perpage : 25;
|
||||
$table->title = \IPS\Member::loggedIn()->language()->addToStack( $database->use_categories ? 'x_records_in_this_category' : 'x_records' , FALSE, array( 'sprintf' => array( $RecordsClass::contentCount( $category, FALSE ), $database->recordWord( $RecordsClass::contentCount( $category, FALSE ) ) ) ) );
|
||||
|
||||
foreach( $customFields as $id => $obj )
|
||||
|
||||
/* Set up sort fields to allow sorting numerically or by date */
|
||||
$sortFields = $customFields;
|
||||
$sortFields[ $database->field_title ] = $fieldClass::load( $database->field_title );
|
||||
foreach( $sortFields as $id => $obj )
|
||||
{
|
||||
if ( $table->sortBy == 'field_' . $id )
|
||||
{
|
||||
@@ -269,7 +272,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
unset ( $table->sortOptions['last_comment'] );
|
||||
unset ( $table->sortOptions['num_comments'] );
|
||||
}
|
||||
|
||||
|
||||
if ( !$database->options['reviews'] )
|
||||
{
|
||||
unset ( $table->sortOptions['num_reviews'] );
|
||||
@@ -424,7 +427,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
|
||||
$table->sortDirection = $values['sort_direction'];
|
||||
}
|
||||
|
||||
|
||||
/* Cutoff */
|
||||
$days = NULL;
|
||||
if ( isset( $values['time_frame'] ) )
|
||||
@@ -540,7 +543,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$category = $categoryClass::loadAndCheckPerms( \IPS\cms\Databases\Dispatcher::i()->categoryId );
|
||||
$fieldsClass = '\IPS\cms\Fields' . \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( 'content_record_form_new_record', FALSE, array( 'sprintf' => array( $database->recordWord( 1, TRUE ) ) ) );
|
||||
|
||||
|
||||
$form = $recordClass::create( $category );
|
||||
$form->class = 'ipsForm_vertical';
|
||||
|
||||
@@ -561,7 +564,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
\IPS\Output::i()->allowDefaultWidgets = FALSE;
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\cms\Pages\Page::$currentPage->getWidgets();
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output = \IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/form.css', 'cms', 'front' ) );
|
||||
|
||||
|
||||
@@ -31,6 +31,14 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
*/
|
||||
public function manage()
|
||||
{
|
||||
/* If the Databases module is set as default we end up here, but not routed through the database dispatcher which means the
|
||||
database ID isn't set. In that case, just re-route back through the pages controller which handles everything. */
|
||||
if( \IPS\cms\Databases\Dispatcher::i()->databaseId === NULL )
|
||||
{
|
||||
$pages = new \IPS\cms\modules\front\pages\page;
|
||||
return $pages->manage();
|
||||
}
|
||||
|
||||
$database = \IPS\cms\Databases::load( \IPS\cms\Databases\Dispatcher::i()->databaseId );
|
||||
|
||||
/* Not using categories? */
|
||||
@@ -103,7 +111,7 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
|
||||
$where = ( $database->featured_settings['featured'] ) ? array( array( 'record_featured=?', 1 ) ) : NULL;
|
||||
|
||||
if ( isset( $database->featured_settings['categories'] ) and count( $database->featured_settings['categories'] ) AND is_array( $database->featured_settings['categories'] ) )
|
||||
if ( isset( $database->featured_settings['categories'] ) and is_array( $database->featured_settings['categories'] ) and count( $database->featured_settings['categories'] ) )
|
||||
{
|
||||
$categoryField = "`cms_custom_database_{$database->_id}`.`category_id`";
|
||||
$where[] = array( \IPS\Db::i()->in( $categoryField, array_values( $database->featured_settings['categories'] ) ) );
|
||||
|
||||
@@ -182,8 +182,8 @@ class _record extends \IPS\Content\Controller
|
||||
'url' => (string) $record->url(),
|
||||
'discussionUrl' => (string) $record->url(),
|
||||
'mainEntityOfPage' => (string) $record->url(),
|
||||
'name' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'headline' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'name' => $record->_title,
|
||||
'headline' => $record->_title,
|
||||
'text' => strip_tags( $record->truncated() ),
|
||||
'articleBody' => strip_tags( $record->truncated() ),
|
||||
'dateCreated' => \IPS\DateTime::ts( $record->record_saved )->format( \IPS\DateTime::ISO8601 ),
|
||||
@@ -191,20 +191,19 @@ class _record extends \IPS\Content\Controller
|
||||
'dateModified' => \IPS\DateTime::ts( $record->record_edit_time ?: ( $record->record_publish_date ?: $record->record_saved ) )->format( \IPS\DateTime::ISO8601 ),
|
||||
'pageStart' => 1,
|
||||
'pageEnd' => $record->commentPageCount(),
|
||||
/* Image is required */
|
||||
'image' => $record->record_image ? (string) \IPS\File::get( 'cms_Records', $record->record_image )->url : \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
|
||||
'name' => \IPS\Member::load( $record->member_id )->name,
|
||||
'image' => \IPS\Member::load( $record->member_id )->get_photo()
|
||||
),
|
||||
'publisher' => array(
|
||||
'@type' => 'Organization',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
|
||||
'name' => \IPS\Member::load( $record->member_id )->name,
|
||||
'image' => \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
'logo' => \IPS\Member::load( $record->member_id )->get_photo()
|
||||
'logo' => array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
)
|
||||
),
|
||||
'interactionStatistic' => array(
|
||||
array(
|
||||
@@ -220,6 +219,44 @@ class _record extends \IPS\Content\Controller
|
||||
),
|
||||
);
|
||||
|
||||
/* Do we have a real author? */
|
||||
if( $record->member_id )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['author']['url'] = (string) \IPS\Member::load( $record->member_id )->url();
|
||||
\IPS\Output::i()->jsonLd['article']['publisher']['url'] = (string) \IPS\Member::load( $record->member_id )->url();
|
||||
}
|
||||
|
||||
/* Image is required */
|
||||
if( $record->record_image )
|
||||
{
|
||||
try
|
||||
{
|
||||
$imageObj = \IPS\File::get( 'cms_Records', $record->record_image );
|
||||
$imageDims = $imageObj->getImageDimensions();
|
||||
|
||||
\IPS\Output::i()->jsonLd['article']['image'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => (string) $imageObj->url,
|
||||
'width' => $imageDims[0],
|
||||
'height' => $imageDims[1]
|
||||
);
|
||||
}
|
||||
/* File doesn't exist */
|
||||
catch ( \RuntimeException $e ){}
|
||||
catch ( \DomainException $e ){}
|
||||
}
|
||||
else
|
||||
{
|
||||
$photoVars = explode( 'x', \IPS\THUMBNAIL_SIZE );
|
||||
|
||||
\IPS\Output::i()->jsonLd['article']['image'] = array(
|
||||
'@type' => 'ImageObject',
|
||||
'url' => \IPS\Member::load( $record->member_id )->get_photo(),
|
||||
'width' => $photoVars[0],
|
||||
'height' => $photoVars[1]
|
||||
);
|
||||
}
|
||||
|
||||
if( $record->averageReviewRating() )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
|
||||
@@ -230,6 +267,14 @@ class _record extends \IPS\Content\Controller
|
||||
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
|
||||
);
|
||||
}
|
||||
elseif( $record->container()->allow_rating )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => $record->averageRating(),
|
||||
'ratingCount' => $record->numberOfRatings(),
|
||||
);
|
||||
}
|
||||
|
||||
if( $record::database()->options['reviews'] )
|
||||
{
|
||||
@@ -251,7 +296,15 @@ class _record extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
\IPS\Output::i()->contextualSearchOptions = array();
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $record::$title ) ) ) ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ), 'nodes' => $record->_id );
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $record::$title ) ) ) ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( get_class( $record ), 4 ) ) ), 'item' => $record->_id );
|
||||
|
||||
try
|
||||
{
|
||||
$container = $record->container();
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_categories' ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( get_class( $record ), 4 ) ) ), 'nodes' => $container->_id );
|
||||
}
|
||||
catch ( \BadMethodCallException $e ) { }
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $record->container()->_template_display, 'cms', 'database' )->record( $record, $comments, $form, $nextUnread );
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,15 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
'database' => array( $this, '_database' ),
|
||||
'category' => array( $this, '_category' ),
|
||||
), \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ), FALSE );
|
||||
|
||||
|
||||
/* Set Breadcrumb */
|
||||
foreach ( $this->topic->container()->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( $this->topic->container()->url(), $this->topic->container()->_title );
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
|
||||
\IPS\Output::i()->output = (string) $wizard;
|
||||
}
|
||||
@@ -152,12 +160,21 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
$contentField = "field_{$database->field_content}";
|
||||
|
||||
$fakeRecord = new $recordClass;
|
||||
$fakeRecord->$titleField = $this->topic->mapped('title');
|
||||
$fakeRecord->$contentField = $this->topic->content();
|
||||
$fakeRecord->$titleField = $this->topic->mapped('title');
|
||||
$fakeRecord->$contentField = $this->topic->content();
|
||||
$fakeRecord->category_id = \IPS\Request::i()->category_id;
|
||||
|
||||
if( $fakeRecord->_forum_record AND $fakeRecord->_forum_comments )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_assoc_desc' ), $recordClass::_definiteArticle(), $recordClass::_definiteArticle() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
|
||||
\IPS\Member::loggedIn()->language()->words['copy_author_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_author_desc' ), $recordClass::_definiteArticle() );
|
||||
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
$form->hiddenValues['record_category_id'] = $category->_id;
|
||||
@@ -175,7 +192,14 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $database->options['comments'] )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE, FALSE, array( 'togglesOn' => array( 'comments_show_message' ) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'comments_show_message', TRUE, FALSE, array( 'togglesOn' => array( 'comments_meta_message', 'comments_meta_color' ) ), NULL, NULL, NULL, 'comments_show_message' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Editor( 'comments_meta_message', \IPS\Member::loggedIn()->language()->addToStack('default_copyposts_message'), FALSE, array( 'app' => 'core', 'key' => 'Meta', 'autoSaveKey' => "meta-message-new", 'attachIds' => NULL ), NULL, NULL, NULL, 'comments_meta_message' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Custom( 'comments_meta_color', 'none', FALSE, array( 'getHtml' => function( $element )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'forms', 'core', 'front' )->colorSelection( $element->name, $element->value );
|
||||
} ), NULL, NULL, NULL, 'comments_meta_color' ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_author', TRUE ) );
|
||||
@@ -188,9 +212,29 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
$comments = $values['copy_comments'];
|
||||
unset( $values['copy_comments'] );
|
||||
}
|
||||
|
||||
/* Determine if we are showing a meta message after */
|
||||
$metaMessage = NULL;
|
||||
|
||||
/* We will only be sowing the message if we are copying comments */
|
||||
if( $comments )
|
||||
{
|
||||
if ( array_key_exists( 'comments_show_message', $values ) )
|
||||
{
|
||||
$metaMessage = array( 'show' => $values['comments_show_message'], 'message' => $values['comments_meta_message'], 'color' => $values['comments_meta_color'] );
|
||||
}
|
||||
}
|
||||
unset( $values['comments_show_message'], $values['comments_meta_message'], $values['comments_meta_color'] );
|
||||
|
||||
/* Figure out author */
|
||||
$author = $values['copy_author'];
|
||||
unset( $values['copy_author'] );
|
||||
|
||||
/* If we are copying comments and we use the forums for comments, skip creating a topic as we will just reassocciate */
|
||||
if( $comments AND $fakeRecord->_forum_record AND $fakeRecord->_forum_comments )
|
||||
{
|
||||
$recordClass::$skipTopicCreation = true;
|
||||
}
|
||||
|
||||
$record = $recordClass::createFromForm( $values, $category );
|
||||
|
||||
@@ -198,10 +242,40 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$record->changeAuthor( $this->topic->author() );
|
||||
}
|
||||
|
||||
if ( $comments )
|
||||
|
||||
if( $metaMessage !== NULL )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
|
||||
if( $metaMessage['show'] )
|
||||
{
|
||||
$id = $record->addMessage( $metaMessage['message'], $metaMessage['color'] );
|
||||
\IPS\File::claimAttachments( "meta-message-new", $id, NULL, 'core_ContentMessages' );
|
||||
}
|
||||
}
|
||||
|
||||
/* If the record syncs with the forums and we are copying topics, just associate with the existing topic */
|
||||
if( $comments AND $record->_forum_record AND $record->_forum_comments )
|
||||
{
|
||||
$record->record_topicid = $this->topic->tid;
|
||||
$record->save();
|
||||
|
||||
/* Reload using the proper class so first and last comment data can be rebuilt properly */
|
||||
$class = 'IPS\cms\Records\RecordsTopicSync' . $database->_id;
|
||||
$class::load( $this->topic->tid )->rebuildFirstAndLastCommentData();
|
||||
|
||||
try
|
||||
{
|
||||
/* If the database is on a page, go to the record */
|
||||
\IPS\Output::i()->redirect( $record->url() );
|
||||
}
|
||||
catch( \LogicException $e )
|
||||
{
|
||||
/* If it is NOT then go back to the topic */
|
||||
\IPS\Output::i()->redirect( $this->topic->url() );
|
||||
}
|
||||
}
|
||||
elseif ( $comments )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -257,7 +331,9 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function comments()
|
||||
{
|
||||
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
|
||||
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
|
||||
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
|
||||
$commentClass = $recordClass::$commentClass;
|
||||
|
||||
@@ -39,7 +39,7 @@ class _builder extends \IPS\core\modules\front\system\widgets
|
||||
$block->plugin = \IPS\Request::i()->block_plugin;
|
||||
$block->plugin_app = ( isset( \IPS\Request::i()->block_plugin_app ) ) ? \IPS\Request::i()->block_plugin_app : \IPS\Request::i()->block_app;
|
||||
$block->plugin_plugin = \IPS\Request::i()->block_plugin_plugin;
|
||||
$block->key = md5( uniqid() );
|
||||
$block->key = md5( mt_rand() );
|
||||
|
||||
$params = array();
|
||||
$block->content = NULL;
|
||||
|
||||
Reference in new issue
Block a user