Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+25 -20
View File
@@ -11,46 +11,51 @@
namespace IPS\cms\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use IPS\Helpers\Form;
use IPS\Http\Url;
use IPS\Text\Parser;
use IPS\Widget\Builder;
use IPS\Widget\StaticCache;
use UnexpectedValueException;
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;
}
/**
* oembed Widget
*/
class _pagebuilderoembed extends \IPS\Widget\StaticCache implements \IPS\Widget\Builder
class pagebuilderoembed extends StaticCache implements Builder
{
/**
* @brief Widget Key
*/
public $key = 'pagebuilderoembed';
public string $key = 'pagebuilderoembed';
/**
* @brief App
*/
public $app = 'cms';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'cms';
/**
* Specify widget configuration
*
* @param null|\IPS\Helpers\Form $form Form object
* @return null|\IPS\Helpers\Form
* @param null|Form $form Form object
* @return Form
*/
public function configuration( &$form=null )
public function configuration( Form &$form=null ): Form
{
$form = parent::configuration( $form );
$form->add( new \IPS\Helpers\Form\Url( 'video_url', ( isset( $this->configuration['video_url'] ) )? $this->configuration['video_url'] : NULL, TRUE, array(), function( $url ) {
if ( \IPS\Text\Parser::embeddableMedia( \IPS\Http\Url::external( $url ) ) === NULL )
$form->add( new Form\Url( 'video_url', ( isset( $this->configuration['video_url'] ) )? $this->configuration['video_url'] : NULL, TRUE, array(), function( $url ) {
if ( Parser::embeddableMedia( Url::external( $url ) ) === NULL )
{
throw new \DomainException('video_cannot_embed');
throw new DomainException('video_cannot_embed');
}
} ) );
return $form;
@@ -62,7 +67,7 @@ class _pagebuilderoembed extends \IPS\Widget\StaticCache implements \IPS\Widget\
* @param array $values Values from form
* @return array
*/
public function preConfig( $values )
public function preConfig( array $values ): array
{
$values['video_url'] = (string) $values['video_url'];
return $values;
@@ -73,16 +78,16 @@ class _pagebuilderoembed extends \IPS\Widget\StaticCache implements \IPS\Widget\
*
* @return string
*/
public function render()
public function render(): string
{
try
{
if ( isset( $this->configuration['video_url'] ) AND $embed = \IPS\Text\Parser::embeddableMedia( \IPS\Http\Url::external( $this->configuration['video_url'] ) ) )
if ( isset( $this->configuration['video_url'] ) AND $embed = Parser::embeddableMedia( Url::external( $this->configuration['video_url'] ) ) )
{
return $this->output( $embed );
}
}
catch( \UnexpectedValueException $e ){}
catch( UnexpectedValueException $e ){}
return '';
}