Version 4.7.0

This commit is contained in:
Neo committed 2025-12-19 16:00:35 -08:00
1 parent 517a5e1f70
commit 8ba7d43898
1933 files changed
+65613 -11332

No files matched your search

@@ -40,6 +40,8 @@ class _categories extends \IPS\Node\Controller
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_use' );
/* This controller can not be accessed without a database ID */
if( !\IPS\Request::i()->database_id )
{
@@ -40,7 +40,7 @@ class _databases extends \IPS\Node\Controller
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_manage' );
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_use' );
parent::execute();
}
@@ -293,7 +293,7 @@ class _databases extends \IPS\Node\Controller
if ( ! @$xml->read() )
{
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
\IPS\Output::i()->error( 'xml_upload_invalid', '2T259/5', 403, '' );
}
/* Is this the first batch? */
@@ -1554,7 +1554,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_databases.js', 'cms', 'admin' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $current ? "content_db_" . $current->id : 'add', $form, FALSE );
\IPS\Output::i()->title = ( $current ) ? \IPS\Member::loggedIn()->language()->addToStack('cms_editing_database', NULL, array( 'sprintf' => array( $current->_title ) ) ) : \IPS\Member::loggedIn()->language()->addToStack('cms_adding_database');
\IPS\Output::i()->title = ( $current ) ? \IPS\Member::loggedIn()->language()->addToStack( 'cms_editing_database', FALSE, array( 'sprintf' => array( $current->_title ) ) ) : \IPS\Member::loggedIn()->language()->addToStack('cms_adding_database');
}
/**
@@ -1599,7 +1599,7 @@ class _databases extends \IPS\Node\Controller
if ( $disabled === TRUE )
{
$form->hiddenValues['database_use_categories_impossible'] = TRUE;
\IPS\Member::loggedIn()->language()->words['database_use_categories_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_use_categories_impossible', NULL, array( 'sprintf' => array( $current->numberOfCategories() ) ) );
\IPS\Member::loggedIn()->language()->words['database_use_categories_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_use_categories_impossible', FALSE, array( 'sprintf' => array( $current->numberOfCategories() ) ) );
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_use_as_page_title' , $current ? $current->use_as_page_title : 1, FALSE, array(
@@ -1881,8 +1881,8 @@ class _databases extends \IPS\Node\Controller
$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 ) ) );
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', FALSE, array( 'sprintf' => array( $rebuildUrl ) ) ) . ' ' .
\IPS\Member::loggedIn()->language()->addToStack( 'database_forum_comments__rebuild', FALSE, array( 'sprintf' => array( $rebuildUrlCounts ) ) );
}
else
{
@@ -43,7 +43,8 @@ class _fields extends \IPS\Node\Controller
$this->url = $this->url->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id ) );
$this->nodeClass = '\IPS\cms\Fields' . \IPS\Request::i()->database_id;
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_use' );
\IPS\Dispatcher::i()->checkAcpPermission( 'cms_fields_manage' );
parent::execute();
}
@@ -36,7 +36,8 @@ class _records extends \IPS\Dispatcher\Controller
public function execute()
{
$this->url = $this->url->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id ) );
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_use' );
\IPS\Dispatcher::i()->checkAcpPermission( 'records_manage' );
parent::execute();
}
@@ -506,13 +507,6 @@ class _records extends \IPS\Dispatcher\Controller
$changeAuthor = TRUE;
}
}
else
{
if ( $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
}
}
/* Just editing, thanks */
if ( ! $new )
+12 -4
View File
@@ -193,6 +193,11 @@ class _ajax extends \IPS\Dispatcher\Controller
{
$where[] = array( 'template_user_created=1 and template_user_edited=1' );
}
if ( isset( \IPS\Request::i()->type ) )
{
$where[] = array( 'template_type=?', \IPS\Request::i()->type );
}
$select = \IPS\Db::i()->select(
'*',
@@ -236,14 +241,17 @@ class _ajax extends \IPS\Dispatcher\Controller
$tags['cms_error_page']['{error_code}'] = 'cms_error_page_code';
}
foreach( \IPS\cms\Databases::roots( NULL, NULL ) as $id => $db )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'databases_use' ) )
{
if ( ! $db->page_id )
foreach ( \IPS\cms\Databases::roots( NULL, NULL ) as $id => $db )
{
$tags['cms_tag_databases']['{database="' . $db->key . '"}'] = $db->_title;
if ( !$db->page_id )
{
$tags['cms_tag_databases']['{database="' . $db->key . '"}'] = $db->_title;
}
}
}
foreach( \IPS\cms\Blocks\Block::roots( NULL, NULL ) as $id => $block )
{
$tags['cms_tag_blocks']['{block="' . $block->key . '"}'] = $block->_title;
@@ -169,16 +169,19 @@ class _blocks extends \IPS\Node\Controller
}
$disabled = array();
foreach( \IPS\cms\Databases::databases() as $db )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'databases', 'databases_use' ) )
{
if ( $db->page_id )
foreach ( \IPS\cms\Databases::databases() as $db )
{
$plugins[ \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' ) ][ 'db_feed_' . $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name', NULL, array( 'sprintf' => array( $db->_title ) ) );
}
else
{
$disabled[] = 'db_feed_' . $db->id;
$plugins[ \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' ) ][ 'db_feed_' . $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name_disabled', NULL, array( 'sprintf' => array( $db->_title ) ) );
if ( $db->page_id )
{
$plugins[\IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' )]['db_feed_' . $db->id] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name', FALSE, array('sprintf' => array($db->_title)) );
}
else
{
$disabled[] = 'db_feed_' . $db->id;
$plugins[\IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' )]['db_feed_' . $db->id] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name_disabled', FALSE, array('sprintf' => array($db->_title)) );
}
}
}
@@ -119,7 +119,7 @@ class _media extends \IPS\Node\Controller
if ( \IPS\Theme::designersModeEnabled() )
{
$link = \IPS\Http\Url::internal( 'app=core&module=customization&controller=themes&do=designersmode' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack('cms_media_designer_mode_warning', NULL, array( 'sprintf' => array( $link ) ) ), 'information', NULL, FALSE );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'cms_media_designer_mode_warning', FALSE, array( 'sprintf' => array( $link ) ) ), 'information', NULL, FALSE );
}
else
{
@@ -307,7 +307,7 @@ FILE;
if ( isset( static::$pageToDatabaseMap[ $page->id ] ) )
{
$badge = array( 0 => 'style7', 1 => \IPS\Member::loggedIn()->language()->addToStack( 'page_database_display', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack('content_db_' . static::$pageToDatabaseMap[ $page->id ] ) ) ) ) );
$badge = array( 0 => 'style7', 1 => \IPS\Member::loggedIn()->language()->addToStack( 'page_database_display', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack('content_db_' . static::$pageToDatabaseMap[ $page->id ] ) ) ) ) );
}
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( \IPS\Http\url::internal('app=cms&module=pages&controller=pages'), true ), "", 'file-text-o', NULL, FALSE, NULL, NULL, $badge, FALSE, FALSE, FALSE );
}
@@ -253,7 +253,7 @@ class _templates extends \IPS\Dispatcher\Controller
$lang = NULL;
if( !empty( $values['lang'] ) )
{
$lang = $values['lang'] == 'updated' ? 'app_now_updated' : 'app_now_installed';
$lang = $values['lang'] == 'updated' ? 'application_now_updated' : 'application_now_installed';
}
if( !empty( $values['marketplace'] ) )
@@ -330,7 +330,7 @@ class _templates extends \IPS\Dispatcher\Controller
if ( \IPS\Theme::designersModeEnabled() )
{
$link = \IPS\Http\Url::internal( 'app=core&module=customization&controller=themes&do=designersmode' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack('cms_theme_designer_mode_warning', NULL, array( 'sprintf' => array( $link ) ) ), 'information', NULL, FALSE );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'cms_theme_designer_mode_warning', FALSE, array( 'sprintf' => array( $link ) ) ), 'information', NULL, FALSE );
}
else
{
@@ -613,6 +613,14 @@ class _templates extends \IPS\Dispatcher\Controller
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_group_new', NULL, FALSE, array( 'regex' => '/^([a-z_][a-z0-9_]+?)?$/' ), function( $val ) {
/* PHP Keywords cannot be used as template names - so make sure the full template name is not in the list */
$keywords = array( 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor' );
if ( \in_array( $val, $keywords ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'template_reserved_word', FALSE, array( 'htmlsprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $keywords ) ) ) ) );
}
try
{
$count = \IPS\Db::i()->select( 'COUNT(*)', 'cms_templates', array( "LOWER(template_group)=?", mb_strtolower( str_replace( ' ', '_', $val ) ) ) )->first();
@@ -997,10 +1005,10 @@ class _templates extends \IPS\Dispatcher\Controller
$names[] = $db->_title;
}
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'cms_database_template_used_in', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) ), 'ipsMessage ipsMessage_info' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'cms_database_template_used_in', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) ), 'ipsMessage ipsMessage_info' );
}
$form->add( new \IPS\Helpers\Form\Text( 'cms_database_group_name', \IPS\cms\Templates::readableGroupName( \IPS\Request::i()->group ), NULL, array( 'regex' => '/^([A-Z_][A-Z0-9_\.\s]+?)$/i' ), function( $val ) {
$form->add( new \IPS\Helpers\Form\Text( 'cms_database_group_name', \IPS\Request::i()->group, NULL, array( 'regex' => '/^([a-z_][a-z0-9_]+?)?$/' ), function( $val ) {
/* PHP Keywords cannot be used as template names - so make sure the full template name is not in the list */
$keywords = array( 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor' );
@@ -1022,7 +1030,7 @@ class _templates extends \IPS\Dispatcher\Controller
if ( $values = $form->values() )
{
$new = str_replace( ' ', '_', $values['cms_database_group_name'] );
$new = str_replace( ' ', '_', mb_strtolower( $values['cms_database_group_name'] ) );
if ( $new != \IPS\Request::i()->group )
{
@@ -61,7 +61,7 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( $database->use_categories )
{
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', NULL, array( 'sprintf' => array( $record->container()->_title ) ) );
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', FALSE, array( 'sprintf' => array( $record->container()->_title ) ) );
}
$results[] = array(
@@ -102,8 +102,8 @@ class _category extends \IPS\cms\Databases\Controller
}
/* we need this language later (and in Widgets\DatabaseFilters which is executed just before output) */
\IPS\Member::loggedIn()->language()->words['cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', NULL, array( 'sprintf' => $database->recordWord() ) );
\IPS\Member::loggedIn()->language()->words['cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', FALSE, array( 'sprintf' => $database->recordWord() ) );
/* Check cookie */
$where = array();
$cookie = $category->getFilterCookie();
@@ -120,7 +120,7 @@ class _category extends \IPS\cms\Databases\Controller
$field = new \IPS\cms\Fields;
$field->id = 'cms_record_i_started';
\IPS\Member::loggedIn()->language()->words['content_field_cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', NULL, array( 'sprintf' => $database->recordWord() ) );
\IPS\Member::loggedIn()->language()->words['content_field_cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', FALSE, array( 'sprintf' => $database->recordWord() ) );
static::$activeFilters['cms_record_i_started'] = array( 'field' => $field, 'value' => \IPS\Member::loggedIn()->language()->addToStack('content_field_cms_record_i_started_on') );
continue;
@@ -277,7 +277,7 @@ class _category extends \IPS\cms\Databases\Controller
$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 ) ) ) ) );
$table->title = \IPS\Member::loggedIn()->language()->addToStack( $database->use_categories ? 'x_records_in_this_category' : 'x_records' , FALSE, array( 'sprintf' => array( $category->_items, $database->recordWord( $category->_items ) ) ) );
/* Set up sort fields to allow sorting numerically or by date */
$sortFields = $customFields;
@@ -286,19 +286,20 @@ class _category extends \IPS\cms\Databases\Controller
{
if ( $table->sortBy == $RecordsClass::$databaseTable . '.' . 'field_' . $id OR $table->sortBy == 'field_' . $id )
{
if ( $obj->type == 'Number' )
if ( \in_array( $obj->type, array( 'Number', 'Date' ) ) )
{
$table->sortOptions[ $table->sortBy ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
break;
}
elseif( $obj->type == 'Date' )
{
$table->sortOptions[ $table->sortBy ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
$fieldName = $table->sortBy;
if ( mb_strstr( $table->sortBy, '.' ) )
{
list( $db, $fieldName ) = explode( '.', $table->sortBy );
}
$table->sortOptions[ $fieldName ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
break;
}
}
}
/* Make sure table doesn't add breadcrumbs if we're not using categories */
if ( ! $database->use_categories )
{
@@ -438,14 +439,10 @@ class _category extends \IPS\cms\Databases\Controller
$table->advancedSearch['sort_by'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
}
if ( \in_array( $obj->type, array( 'Date', 'DateRange' ) ) )
if ( \in_array( $obj->type, array( 'Date', 'DateRange', 'Number' ) ) )
{
$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;
@@ -583,6 +580,9 @@ class _category extends \IPS\cms\Databases\Controller
{
$table->sortOptions[ $values['sort_by'] ] = $values['sort_by'];
}
/* Ensure we remove any duplicates added by the advanced sort form */
$table->sortOptions = array_unique( $table->sortOptions );
$table->sortBy = $values['sort_by'];
$table->sortDirection = $values['sort_direction'];
@@ -686,13 +686,19 @@ class _category extends \IPS\cms\Databases\Controller
{
foreach ( $category->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
}
}
/* Node handler does not support keywords, so we need to do it manually */
if ( $category->meta_keywords )
{
\IPS\Output::i()->metaTags['keywords'] = $category->meta_keywords;
}
/* Update location */
$permissions = $category->permissions();
\IPS\Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_db_cat', array( 'content_db_' . $database->id => TRUE, 'content_cat_name_' . $category->id => TRUE ) );
@@ -84,11 +84,18 @@ class _topic extends \IPS\Dispatcher\Controller
$form->hiddenValues['topic_id'] = \IPS\Request::i()->id;
$form->add( new \IPS\Helpers\Form\Node( 'database', NULL, TRUE, array( 'class' => '\IPS\cms\Databases', 'permissionCheck' => function( $row )
{
/* If this database does not have a title or content field, we cannot copy. */
if ( !$row->field_title OR !$row->field_content )
{
return FALSE;
}
/* If this database is not on a page, then we cannot copy. */
if ( !$row->page_id )
{
return FALSE;
}
return $row->can( 'add' );
} ) ) );
if ( $values = $form->values() )
@@ -115,7 +122,7 @@ class _topic extends \IPS\Dispatcher\Controller
if ( !$database->use_categories )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$data['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $data['database_id'], 'category_id' => $database->default_category ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$data['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => $data['database_id'], 'category_id' => $database->default_category ) ) );
}
$catClass = 'IPS\cms\Categories' . $data['database_id'];
@@ -128,7 +135,7 @@ class _topic extends \IPS\Dispatcher\Controller
if ( $values = $form->values() )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$values['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $values['database_id'], 'category_id' => $values['select_category']->_id ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$values['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => $values['database_id'], 'category_id' => $values['select_category']->_id ) ) );
}
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
@@ -152,6 +159,15 @@ class _topic extends \IPS\Dispatcher\Controller
\IPS\Output::i()->error( 'node_error', '2T353/2', 404, '' );
}
try
{
$page = \IPS\cms\Pages\Page::load( $database->page_id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2T353/4', 404, '' );
}
$recordClass = 'IPS\cms\Records' . $database->_id;
$commentClass = 'IPS\cms\Comments' . $database->_id;
$fieldClass = 'IPS\cms\Fields' . $database->_id;
@@ -323,7 +339,7 @@ class _topic extends \IPS\Dispatcher\Controller
\IPS\Output::i()->breadcrumb[] = array( $this->topic->url(), $this->topic->mapped( 'title' ) );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\cms\Theme::i()->getTemplate( $database->template_form, 'cms', 'database' ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::load( $database->page_id ), \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ), $hasModOptions );
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\cms\Theme::i()->getTemplate( $database->template_form, 'cms', 'database' ), 'recordForm' ), NULL, $category, $database, $page, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ), $hasModOptions );
}
/**
@@ -23,128 +23,6 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _builder extends \IPS\core\modules\front\system\widgets
{
/**
* Preview a block (from the ACP or elsewhere dynamically)
*
* @return html
*/
public function previewBlock()
{
if ( !\IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'blocks', 'block_manage' ) )
{
\IPS\Output::i()->error( 'no_module_permission', '3T419/1', 403, '' );
}
$output = "";
if ( \IPS\Request::i()->_key )
{
try
{
$key = \IPS\Request::i()->_key;
$data = \IPS\Data\Store::i()->$key;
unset( \IPS\Data\Store::i()->$key );
}
catch( \OutOfRangeException $e )
{
$data = array();
}
}
if ( isset( $data['block_plugin'] ) )
{
$block = new \IPS\cms\Blocks\Block;
$block->type = "plugin";
$block->plugin = $data['block_plugin'];
$block->plugin_app = ( isset( $data['block_plugin_app'] ) ) ? $data['block_plugin_app'] : $data['block_app'];
if( isset( $data['block_plugin_plugin'] ) )
{
$block->plugin_plugin = $data['block_plugin_plugin'];
}
$block->key = md5( mt_rand() );
$params = array();
$block->content = NULL;
if ( isset( $data['_sending'] ) )
{
foreach( explode( ",", $data['_sending'] ) as $field )
{
/* Multi-Selects will pass their parameters through as an array, so we need to make sure we check those properly to include all options. */
if ( mb_strstr( $field, '[]' ) !== FALSE )
{
$field = str_replace( '[]', '', $field );
$isArray = TRUE;
}
else
{
$isArray = FALSE;
}
if ( $field and isset( $data[ $field ] ) )
{
if ( $field == 'block_content' )
{
$block->content = $data[ $field ];
if ( isset( $data['template_params'] ) )
{
$block->template_params = $data['template_params'];
}
continue;
}
if( mb_strpos( $field, "widget_feed_container_" ) !== FALSE )
{
/* On means that the all checkbox is ticked */
$params[ 'widget_feed_container'] = $data[ $field ] == 'on' ? 0 : ( \is_array( $data[ $field ] ) ? $data[ $field ] : explode( ',', $data[ $field ] ) );
continue;
}
/* We need to handle tags special */
if( $field == 'widget_feed_tags' )
{
$params[ $field ] = $data[ $field ] ? explode( ',', $data[ $field ] ) : array();
continue;
}
/* We need to handle authors special */
if( $field == 'widget_feed_author' )
{
$params[ $field ] = $data[ $field ] ? array( \IPS\Member::load( $data[ $field ], 'name' )->member_id ) : array();
continue;
}
/* Is it an array? */
if ( $isArray )
{
foreach( $data[ $field ] AS $multi )
{
$params[ $field ][] = $multi;
}
continue;
}
$params[ $field ] = $data[ $field ];
}
}
}
$block->plugin_config = json_encode( $params );
/* Template stuffs */
if ( $data['block_template_use_how'] == 'copy' )
{
$block->widget()->template( array( $block, 'getTemplate' ) );
}
$output = $block->widget()->render();
}
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ), 200, 'text/html' );
}
/**
* Get Output For Adding A New Block