Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+81 -13
View File
@@ -2,9 +2,10 @@
/**
* @brief Block Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 19 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -47,6 +48,11 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
* @brief [ActiveRecord] Database ID Fields
*/
protected static $databaseIdFields = array('block_key');
/**
* @brief [ActiveRecord] Multiton Map
*/
protected static $multitonMap = array();
/**
* @brief [Node] Parent ID Database Column
@@ -239,7 +245,7 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
unset( \IPS\Data\Store::i()->$functionName );
/* Still here */
if ( ! in_array( $functionName, array_keys( self::$calledTemplates ) ) )
if ( ! in_array( $functionName, array_keys( static::$calledTemplates ) ) )
{
if ( ! isset( \IPS\Data\Store::i()->$functionName ) )
{
@@ -252,8 +258,10 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
{
try
{
$template = \IPS\cms\Templates::load( $this->template );
return call_user_func_array( array( \IPS\cms\Theme::i()->getTemplate( $template->group, 'cms', $template->location ), $template->title ), $args );
$template = \IPS\cms\Templates::load( $this->template );
$object = \IPS\cms\Theme::i()->getTemplate( $template->group, 'cms', $template->location );
$title = $template->title;
return $object->$title( ...$args );
}
catch( \OutOfRangeException $ex )
{
@@ -280,10 +288,10 @@ EOF;
$class = "\IPS\Theme\\class_{$functionName}";
/* Init */
self::$calledTemplates[ $functionName ] = new $class();
static::$calledTemplates[ $functionName ] = new $class();
}
return call_user_func_array( array( self::$calledTemplates[ $functionName ], 'run' ), $args );
return static::$calledTemplates[ $functionName ]->run( ...$args );
}
/**
@@ -623,7 +631,12 @@ EOF;
}
else
{
$form->add( new \IPS\Helpers\Form\Codemirror( 'block_content', $this->content, FALSE, array(), NULL, NULL, NULL, 'block_content' ) );
$form->add( new \IPS\Helpers\Form\Codemirror( 'block_content', htmlentities( $this->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ), FALSE, array(), function( $val ) {
if ( mb_strpos( $val, '{block="' . \IPS\Request::i()->block_key . '"}' ) !== FALSE )
{
throw new \DomainException('block_content_recursive_error');
}
}, NULL, NULL, 'block_content' ) );
}
if ( $block_type === 'plugin' and ! $this->id )
@@ -653,6 +666,12 @@ EOF;
}
$form->hiddenValues['template_params'] = ( $this->id ) ? $this->template_params : '';
/* If we are editing, we can save and reload */
if( $this->id )
{
$form->canSaveAndReload = true;
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'templates/view.css', 'cms', 'admin' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'blocks/form.css', 'cms', 'admin' ) );
@@ -682,6 +701,10 @@ EOF;
}
$config = array();
if( isset( $values['language_key'] ) )
{
$config['language_key'] = $values['language_key'];
}
if( isset( $values['block_name'] ) )
{
@@ -704,11 +727,12 @@ EOF;
{
if ( is_array( $values['block_name'] ) )
{
$values['block_key'] = \IPS\Http\Url::seoTitle( $values['block_name'][ key( $values['block_name'] ) ] );
reset( $values['block_name'] );
$values['block_key'] = \IPS\Http\Url\Friendly::seoTitle( $values['block_name'][ key( $values['block_name'] ) ] );
}
else
{
$values['block_key'] = \IPS\Http\Url::seoTitle( $values['block_name'] );
$values['block_key'] = \IPS\Http\Url\Friendly::seoTitle( $values['block_name'] );
}
/* Now test it */
@@ -758,6 +782,11 @@ EOF;
{
$theValue[ $eachKey ] = $eachValue;
}
elseif ( $eachKey === 'start' or $eachKey === 'end' )
{
/* date ranges */
$theValue[ $eachKey ] = $eachValue;
}
else
{
$theValue[] = $eachValue;
@@ -816,7 +845,7 @@ EOF;
$templateArray = array(
'key' => 'template_' . $templateBit['template_name'] . '.' . uniqid(),
'title' => str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $templateBit['template_name'] . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
'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',
@@ -836,7 +865,7 @@ EOF;
$templateArray = array(
'key' => 'template_' . $template->name . '.' . uniqid(),
'title' => str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['block_save_as_template_name'] ? $values['block_save_as_template_name'] : $template->name . '_' . \IPS\Member::loggedIn()->language()->get('copy_noun') ) ),
'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',
@@ -950,4 +979,43 @@ EOF;
throw new \OutOfRangeException;
}
/**
* [ActiveRecord] Duplicate
*
* @return void
*/
public function __clone()
{
parent::__clone();
if( $this->skipCloneDuplication === TRUE )
{
return;
}
/* Copy language bits to make them unique */
$config = $this->_plugin_config;
$wordKey = 'widget_title_' . md5( uniqid() );
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 .= '_' . uniqid();
$this->save();
}
}