Version 4.6.0

This commit is contained in:
Neo committed 2025-12-19 05:55:31 -08:00
1 parent f79dcf067a
commit 517a5e1f70
2036 files changed
+110041 -26162

No files matched your search

+40 -65
View File
@@ -492,9 +492,16 @@ EOF;
'app' => 'cms',
'key' => ( $this->id ? "content_block_name_" . $this->id . '_desc' : NULL )
) ) );
$nodeContainer = $this->id ? $this->category :
( \IPS\Request::i()->parent ?: \IPS\cms\Blocks\Container::load( ( $block_type == 'custom' ? 'block_custom' : 'block_plugins' ), 'container_key' )->id );
try
{
$nodeContainer = $this->id ? $this->category :
( \IPS\Request::i()->parent ?: \IPS\cms\Blocks\Container::load( ( $block_type == 'custom' ? 'block_custom' : 'block_plugins' ), 'container_key' )->id );
}
catch( \OutOfRangeException $e )
{
$nodeContainer = NULL;
}
$form->add( new \IPS\Helpers\Form\Node( 'block_category', $nodeContainer, TRUE, array(
'class' => '\IPS\cms\Blocks\Container',
'subnodes' => false
@@ -728,6 +735,9 @@ EOF;
\IPS\File::claimAttachments( ( $this->id ) ? 'block-content-' . $this->id : 'block-content-new', $this->id );
}
$this->type = \IPS\Request::i()->block_type;
$values['type'] = $this->type;
if ( ! $this->id )
{
$this->active = 1;
@@ -752,9 +762,6 @@ EOF;
unset ( $values['block_description'] );
}
$this->type = \IPS\Request::i()->block_type;
$values['type'] = $this->type;
if( isset( $values['block_key'] ) )
{
if ( ! $values['block_key'] )
@@ -883,6 +890,17 @@ EOF;
/* We're using a copy */
if ( isset( $values['block_save_as_template'] ) AND $values['block_save_as_template'] )
{
$templateArray = array(
'desc' => null,
'content' => $values['block_content'],
'location' => 'block',
'group' => \IPS\Request::i()->block_plugin,
'container' => null,
'rel_id' => 0,
'user_created' => 1,
'user_edited' => 0,
);
if ( $values['block_template_id'] == '_default_' )
{
/* Find it from the normal template system */
@@ -893,19 +911,9 @@ EOF;
$templateBits = \IPS\Theme::master()->getRawTemplates( $location['app'], $location['location'], $location['group'], \IPS\Theme::RETURN_ALL );
$templateBit = $templateBits[ $location['app'] ][ $location['location'] ][ $location['group'] ][ $location['name'] ];
$templateArray = array(
'key' => 'template_' . $templateBit['template_name'] . '.' . mt_rand(),
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $templateBit['template_name'] . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
'desc' => null,
'content' => $values['block_content'],
'location' => 'block',
'group' => \IPS\Request::i()->block_plugin,
'container' => null,
'rel_id' => 0,
'user_created' => 1,
'user_edited' => 0,
'params' => $templateBit['template_data']
);
$templateArray['key'] = 'template_' . $templateBit['template_name'] . '.' . mt_rand();
$templateArray['title'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $templateBit['template_name'] . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) );
$templateArray['params'] = $templateBit['template_data'];
}
else
{
@@ -913,19 +921,9 @@ EOF;
{
$template = \IPS\cms\Templates::load( $values['block_template_id'] );
$templateArray = array(
'key' => 'template_' . $template->name . '.' . mt_rand(),
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $template->name . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
'desc' => null,
'content' => $values['block_content'],
'location' => 'block',
'group' => \IPS\Request::i()->block_plugin,
'container' => null,
'rel_id' => 0,
'user_created' => 1,
'user_edited' => 0,
'params' => $template->params
);
$templateArray['key'] = 'template_' . $template->name . '.' . mt_rand();
$templateArray['title'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $template->name . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) );
$templateArray['params'] = $template->params;
}
catch( \OutOfRangeException $ex )
{
@@ -933,6 +931,12 @@ EOF;
}
}
/* Make sure template name is unique within the group */
if( \IPS\Db::i()->select( 'COUNT(*)', 'cms_templates', array( 'template_title=? and template_location=? and template_group=?', $templateArray['title'], $templateArray['location'], $templateArray['group'] ) )->first() )
{
$templateArray['title'] = $templateArray['title'] . '_' . time();
}
/* Save */
$newTemplate = \IPS\cms\Templates::add( $templateArray );
@@ -1036,41 +1040,12 @@ EOF;
}
/**
* [ActiveRecord] Duplicate
* [Node] Does the currently logged in user have permission to copy this node?
*
* @return void
* @return bool
*/
public function __clone()
public function canCopy()
{
parent::__clone();
if( $this->skipCloneDuplication === TRUE )
{
return;
}
/* Copy language bits to make them unique */
$config = $this->_plugin_config;
$wordKey = 'widget_title_' . md5( mt_rand() );
if ( isset( $config['language_key'] ) )
{
try
{
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', array( 'word_key=?', $config['language_key'] ) ) as $row )
{
unset( $row['word_id'] );
$row['word_key'] = $wordKey;
\IPS\Db::i()->insert( 'core_sys_lang_words', $row );
}
}
catch( \Exception $ex ) { }
$config['language_key'] = $wordKey;
$this->plugin_config = json_encode( $config );
}
$this->key .= '_' . mt_rand();
$this->save();
return FALSE;
}
}