Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+52 -26
View File
@@ -12,7 +12,7 @@
namespace IPS\cms\Blocks;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -161,7 +161,7 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
{
try
{
if ( is_numeric( $block ) )
if ( \is_numeric( $block ) )
{
$block = static::load( $block );
}
@@ -213,11 +213,12 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
unset( \IPS\Data\Store::i()->$functionName );
}
$html = call_user_func( 'IPS\\Theme\\'. $functionName );
$themeFunction = 'IPS\\Theme\\'. $functionName;
$html = $themeFunction();
if( $block->getConfig('editor') == 'editor' )
{
$html = \IPS\Theme::i()->getTemplate( 'widgets', 'cms', 'front' )->Wysiwyg( $html, $orientation );
$html = \IPS\Theme::i()->getTemplate( 'widgets', 'cms', 'front' )->Wysiwyg( \IPS\Member::loggedIn()->language()->addToStack( "cms_block_content_{$block->id}" ), $orientation );
}
return $html;
@@ -238,7 +239,7 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
$block->widget()->template( array( $block, 'getTemplate' ) );
}
return $block->widget()->render();
return \IPS\Widget::parseOutput( $block->widget()->render() );
}
}
catch( \OutOfRangeException $ex )
@@ -254,13 +255,13 @@ class _Block extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function getTemplate()
{
$args = func_get_args();
$args = \func_get_args();
$functionName = 'content_template_for_block_' . $this->id;
unset( \IPS\Data\Store::i()->$functionName );
/* Still here */
if ( ! in_array( $functionName, array_keys( static::$calledTemplates ) ) )
if ( ! \in_array( $functionName, array_keys( static::$calledTemplates ) ) )
{
if ( ! isset( \IPS\Data\Store::i()->$functionName ) )
{
@@ -321,7 +322,7 @@ EOF;
{
$ids = iterator_to_array( \IPS\Db::i()->select( 'block_id', 'cms_blocks' )->setValueField('block_id') );
}
else if ( is_numeric( $ids ) )
else if ( \is_numeric( $ids ) )
{
$ids = array( $ids );
}
@@ -433,13 +434,12 @@ EOF;
*/
public function get__plugin_config()
{
return ( $this->plugin_config ? ( is_array( $this->plugin_config ) ? $this->plugin_config : json_decode( $this->plugin_config, TRUE ) ) : array() );
return ( $this->plugin_config ? ( \is_array( $this->plugin_config ) ? $this->plugin_config : json_decode( $this->plugin_config, TRUE ) ) : array() );
}
/**
* [Node] Get buttons to display in tree
* Example code explains return value
* @endcode
*
* @param string $url Base URL
* @param bool $subnode Is this a subnode?
* @return array
@@ -560,7 +560,7 @@ EOF;
if ( mb_substr( $block_plugin, 0, 8 ) === 'db_feed_' )
{
$databaseId = intval( mb_substr( $block_plugin, 8 ) );
$databaseId = \intval( mb_substr( $block_plugin, 8 ) );
$this->plugin = 'RecordFeed';
$this->plugin_config = array( 'cms_rf_database' => $databaseId );
@@ -583,7 +583,7 @@ EOF;
throw new \LogicException( 'cms_error_block_plugin_not_found' );
}
if ( is_callable( array( $this->widget(), 'configuration' ) ) )
if ( \is_callable( array( $this->widget(), 'configuration' ) ) )
{
$form->addTab( 'content_block_form_tab__feed' );
$this->widget()->configuration( $form );
@@ -615,7 +615,7 @@ EOF;
$useHow = NULL;
if ( $this->id )
{
if ( intval( $this->template ) or ( ! intval( $this->template ) and ! $this->content ) )
if ( \intval( $this->template ) or ( ! \intval( $this->template ) and ! $this->content ) )
{
$useHow = 'use';
}
@@ -638,15 +638,20 @@ EOF;
if ( $block_editor === 'editor' )
{
$form->add( new \IPS\Helpers\Form\Editor( 'block_content', $this->content, FALSE, array(
'app' => 'cms',
'key' => 'BlockContent',
'autoSaveKey' => 'block-content-' . ( $this->id ? $this->id : 'new' ),
'attachIds' => ( $this->id ) ? array( $this->id ) : NULL ), NULL, NULL, NULL, 'block_content_editor' ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'block_content', NULL, FALSE, array(
'key' => ( $this->id ) ? "cms_block_content_{$this->id}" : NULL,
'editor' => array(
'app' => 'cms',
'key' => 'BlockContent',
'autoSaveKey' => 'block-content-' . ( $this->id ? $this->id : 'new' ),
'attachIds' => ( $this->id ) ? array( $this->id ) : NULL
)
) ) );
}
else
{
$form->add( new \IPS\Helpers\Form\Codemirror( 'block_content', htmlentities( $this->content, ENT_DISALLOWED, 'UTF-8', TRUE ), FALSE, array(), function( $val ) {
$form->add( new \IPS\Helpers\Form\Codemirror( 'block_content', htmlentities( $this->content, ENT_DISALLOWED, 'UTF-8', TRUE ), FALSE, array( 'tagSource' => \IPS\Http\Url::internal( "app=cms&module=pages&controller=blocks&do=loadTags" ) ), function( $val ) {
if ( \IPS\Request::i()->block_editor == 'php' )
{
try
@@ -754,7 +759,7 @@ EOF;
{
if ( ! $values['block_key'] )
{
if ( is_array( $values['block_name'] ) )
if ( \is_array( $values['block_name'] ) )
{
reset( $values['block_name'] );
$values['block_key'] = \IPS\Http\Url\Friendly::seoTitle( $values['block_name'][ key( $values['block_name'] ) ] );
@@ -767,7 +772,7 @@ EOF;
/* Now test it */
try
{
$block = \IPS\cms\Blocks\Block::load( $this->key, 'block_key');
$block = \IPS\cms\Blocks\Block::load( $values['block_key'], 'block_key');
/* It's taken... */
if ( $this->id != $block->id )
@@ -787,17 +792,33 @@ EOF;
$values['plugin_app'] = \IPS\Request::i()->block_plugin_app;
/* configure widget related values */
if ( is_callable( array( $this->widget(), 'preConfig' ) ) )
if ( \is_callable( array( $this->widget(), 'preConfig' ) ) )
{
$values = $this->widget()->preConfig( $values );
}
/* Special advanced builder stuff */
if ( \in_array( 'IPS\Widget\Builder', class_implements( $this->widget() ) ) )
{
if( isset( $values['widget_adv__background_custom_image'] ) and $values['widget_adv__background_custom_image'] )
{
$values['widget_adv__background_custom_image'] = (string) $values['widget_adv__background_custom_image'];
}
}
if( isset( $values['show_on_all_devices'] ) and $values['show_on_all_devices'] )
{
$values['devices_to_show'] = array( 'Phone', 'Tablet', 'Desktop' );
}
unset( $values['show_on_all_devices'] );
/* Store config */
foreach( $values as $k => $v )
{
if ( ! in_array( $k, array( 'block_name', 'block_key', 'block_description', 'block_category', 'block_template_id', 'block_template_use_how', 'block_content', 'block_save_as_template', 'block_save_as_template_name' ) ) )
if ( ! \in_array( $k, array( 'block_name', 'block_key', 'block_description', 'block_category', 'block_template_id', 'block_template_use_how', 'block_content', 'block_save_as_template', 'block_save_as_template_name' ) ) )
{
if ( is_array( $v ) )
if ( \is_array( $v ) )
{
$theValue = NULL;
foreach( $v as $eachKey => $eachValue )
@@ -916,7 +937,7 @@ EOF;
$newTemplate = \IPS\cms\Templates::add( $templateArray );
$values['content'] = null;
$values['template'] = $newTemplate->id;
$values['template'] = $newTemplate->key;
}
else
{
@@ -929,6 +950,11 @@ EOF;
else if( isset( $values['block_content'] ) )
{
$values['template'] = 0;
if ( \IPS\Request::i()->block_editor === 'editor' )
{
\IPS\Lang::saveCustom( 'cms', "cms_block_content_{$this->id}", $values['block_content'] );
$values['block_content'] = NULL;
}
}
if ( isset( $values['block_category'] ) AND ( ! empty( $values['block_category'] ) OR $values['block_category'] === 0 ) )