Version 5.0.0 beta 9
This commit is contained in:
1 parent
214f649f1d
commit
56979f8ee8
202 files changed
+4403
-1123
No files matched your search
@@ -14,6 +14,7 @@ namespace IPS\cms\Blocks;
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Application;
|
||||
use IPS\cms\Pages\Page;
|
||||
@@ -37,6 +38,7 @@ use IPS\Node\Model;
|
||||
use IPS\Node\Permissions;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecord;
|
||||
use IPS\Platform\Bridge;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget;
|
||||
@@ -242,6 +244,20 @@ class Block extends Model implements Permissions
|
||||
if ( ! isset( Store::i()->$functionName ) )
|
||||
{
|
||||
$content = $block->content;
|
||||
|
||||
if( $block->getConfig('editor') == 'php' )
|
||||
{
|
||||
/* If PHP blocks are disabled, stop here */
|
||||
if( !Bridge::i()->featureIsEnabled( 'phpblocks' ) )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
ob_start();
|
||||
eval( $content );
|
||||
$content = ob_get_clean();
|
||||
}
|
||||
|
||||
Store::i()->$functionName = Theme::compileTemplate( $content, $functionName );
|
||||
}
|
||||
|
||||
@@ -515,6 +531,12 @@ EOF;
|
||||
$block_editor = ( isset( Request::i()->block_editor ) ) ? Request::i()->block_editor : ( $this->id ? $this->getConfig('editor') : null );
|
||||
$block_plugin = ( isset( Request::i()->block_plugin ) ) ? Request::i()->block_plugin : ( $this->id ? $this->plugin : null );
|
||||
|
||||
/* Double check that we didn't force the PHP blocks */
|
||||
if( $block_editor == 'php' and !Bridge::i()->featureIsEnabled( 'phpblocks' ) )
|
||||
{
|
||||
$block_editor = 'html';
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form->addTab( 'content_block_form_tab__details' );
|
||||
$form->add( new Translatable( 'block_name', NULL, TRUE, array(
|
||||
@@ -692,7 +714,21 @@ EOF;
|
||||
}
|
||||
else
|
||||
{
|
||||
$form->add( new Codemirror( 'block_content', htmlentities( (string) $this->content, ENT_DISALLOWED, 'UTF-8' ), FALSE, array( 'tagSource' => Url::internal( "app=cms&module=pages&controller=blocks&do=loadTags" ), "codeModeAllowedLanguages" => ["ipsphtml"]), function($val ) {
|
||||
$form->add( new Codemirror( 'block_content', htmlentities( (string) $this->content, ENT_DISALLOWED, 'UTF-8' ), FALSE, array( 'tagSource' => Url::internal( "app=cms&module=pages&controller=blocks&do=loadTags" ), "codeModeAllowedLanguages" => ( $block_editor == 'php' ) ? [ "php"] : ["ipsphtml"] ), function( $val ) use( $block_editor ) {
|
||||
if( $block_editor == 'php' )
|
||||
{
|
||||
try
|
||||
{
|
||||
ob_start();
|
||||
@eval( $val );
|
||||
ob_get_clean();
|
||||
}
|
||||
catch ( ParseError|Exception $e )
|
||||
{
|
||||
throw new DomainException( $e->getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( mb_strpos( $val, '{block="' . Request::i()->block_key . '"}' ) !== FALSE )
|
||||
{
|
||||
throw new DomainException('block_content_recursive_error');
|
||||
|
||||
Reference in new issue
Block a user