Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,48 +12,54 @@
|
||||
namespace IPS\cms\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\cms\Blocks\Block;
|
||||
use IPS\cms\Blocks\Container;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Widget\PermissionCache;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom block Widget
|
||||
*/
|
||||
class _Blocks extends \IPS\Widget\PermissionCache
|
||||
class Blocks extends PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'Blocks';
|
||||
public string $key = 'Blocks';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'cms';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'cms';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $uniqueKey Unique key for this specific instance
|
||||
* @param String $uniqueKey Unique key for this specific instance
|
||||
* @param array $configuration Widget custom configuration
|
||||
* @param null|string|array $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param null|string $orientation Orientation (top, bottom, right, left)
|
||||
* @param array|string|null $access Array/JSON string of executable apps (core=sidebar only, content=IP.Content only, etc)
|
||||
* @param string|null $orientation Orientation (top, bottom, right, left)
|
||||
* @param string $layout
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( $uniqueKey, array $configuration, $access=null, $orientation=null )
|
||||
public function __construct(string $uniqueKey, array $configuration, array|string $access=null, string $orientation=null, string $layout='table' )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( isset( $configuration['cms_widget_custom_block'] ) )
|
||||
{
|
||||
$block = \IPS\cms\Blocks\Block::load( $configuration['cms_widget_custom_block'], 'block_key' );
|
||||
$block = Block::load( $configuration['cms_widget_custom_block'], 'block_key' );
|
||||
if ( $block->type === 'custom' AND ! $block->cache )
|
||||
{
|
||||
$this->neverCache = TRUE;
|
||||
@@ -66,22 +72,22 @@ class _Blocks extends \IPS\Widget\PermissionCache
|
||||
$block->orientation = $orientation;
|
||||
$block->widget()->init();
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
catch( Exception $e ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
catch( Exception $e ) { }
|
||||
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation );
|
||||
parent::__construct( $uniqueKey, $configuration, $access, $orientation, $layout );
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form Form Object
|
||||
* @return null|\IPS\Helpers\Form
|
||||
* @param Form|null $form Form Object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
@@ -91,17 +97,17 @@ class _Blocks extends \IPS\Widget\PermissionCache
|
||||
{
|
||||
if ( isset( $this->configuration['cms_widget_custom_block'] ) )
|
||||
{
|
||||
$block = \IPS\cms\Blocks\Block::load( $this->configuration['cms_widget_custom_block'], 'block_key' );
|
||||
$block = Block::load( $this->configuration['cms_widget_custom_block'], 'block_key' );
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $e ) { }
|
||||
catch( OutOfRangeException $e ) { }
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'cms_widget_custom_block', $block, FALSE, array(
|
||||
$form->add( new Node( 'cms_widget_custom_block', $block, FALSE, array(
|
||||
'class' => '\IPS\cms\Blocks\Container',
|
||||
'showAllNodes' => TRUE,
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
if ( $node instanceof \IPS\cms\Blocks\Container )
|
||||
if ( $node instanceof Container )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -119,7 +125,7 @@ class _Blocks extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Form values
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
$newValues = $values;
|
||||
|
||||
@@ -136,11 +142,11 @@ class _Blocks extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
if ( isset( $this->configuration['cms_widget_custom_block'] ) )
|
||||
{
|
||||
return (string) \IPS\cms\Blocks\Block::display( $this->configuration['cms_widget_custom_block'], $this->orientation );
|
||||
return (string) Block::display( $this->configuration['cms_widget_custom_block'], $this->orientation );
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
Reference in new issue
Block a user