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

+35 -25
View File
@@ -11,39 +11,49 @@
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\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Stack;
use IPS\Helpers\Form\Upload;
use IPS\Helpers\Form\YesNo;
use IPS\Widget\Builder;
use IPS\Widget\StaticCache;
use function count;
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;
}
/**
* pagebuilderupload Widget
*/
class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\Builder
class pagebuilderupload extends StaticCache implements Builder
{
/**
* @brief Widget Key
*/
public $key = 'pagebuilderupload';
public string $key = 'pagebuilderupload';
/**
* @brief App
*/
public $app = 'cms';
public string $app = 'cms';
/**
* @brief Plugin
*/
public $plugin = '';
/**
* 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 );
@@ -55,7 +65,7 @@ class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\
{
foreach( explode( ',', $this->configuration['pagebuilderupload_upload'] ) as $img )
{
$images[] = \IPS\File::get( 'core_Attachment', $img );
$images[] = File::get( 'core_Attachment', $img );
}
}
@@ -75,12 +85,12 @@ class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\
}
}
$form->add( new \IPS\Helpers\Form\Upload( 'pagebuilderupload_upload', $images, FALSE, array( 'multiple' => true, 'storageExtension' => 'core_Attachment', 'allowStockPhotos' => TRUE, 'image' => true ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'pagebuilderupload_slideshow', ( isset( $this->configuration['pagebuilderupload_slideshow'] ) ? $this->configuration['pagebuilderupload_slideshow'] : FALSE ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'pagebuilderupload_captions', $captions, FALSE, array( 'stackFieldType' => 'Text' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'pagebuilderupload_urls', $urls, FALSE, array( 'stackFieldType' => 'Url' ) ) );
$form->add( new Upload( 'pagebuilderupload_upload', $images, FALSE, array( 'multiple' => true, 'storageExtension' => 'core_Attachment', 'allowStockPhotos' => TRUE, 'image' => true ) ) );
$form->add( new YesNo( 'pagebuilderupload_slideshow', ( $this->configuration['pagebuilderupload_slideshow'] ?? FALSE ) ) );
$form->add( new Stack( 'pagebuilderupload_captions', $captions, FALSE, array( 'stackFieldType' => 'Text' ) ) );
$form->add( new Stack( 'pagebuilderupload_urls', $urls, FALSE, array( 'stackFieldType' => 'Url' ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'pagebuilderupload_height', ( isset( $this->configuration['pagebuilderupload_height'] ) ? $this->configuration['pagebuilderupload_height'] : 300 ), FALSE, array( 'unlimited' => 0 ) ) );
$form->add( new Number( 'pagebuilderupload_height', ( $this->configuration['pagebuilderupload_height'] ?? 300 ), FALSE, array( 'unlimited' => 0 ) ) );
return $form;
}
@@ -89,15 +99,15 @@ class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\
*
* @return void
*/
public function delete()
public function delete() : void
{
foreach( explode( ',', $this->configuration['pagebuilderupload_upload'] ) as $img )
{
try
{
\IPS\File::get( 'core_Attachment', $img )->delete();
File::get( 'core_Attachment', $img )->delete();
}
catch( \Exception $e ) { }
catch( Exception $e ) { }
}
}
@@ -107,7 +117,7 @@ class _pagebuilderupload 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
{
$images = array();
$urls = array();
@@ -132,7 +142,7 @@ class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\
*
* @return string
*/
public function render()
public function render() : string
{
$images = array();
$captions = ( isset( $this->configuration['pagebuilderupload_captions'] ) ) ? $this->configuration['pagebuilderupload_captions'] : array();
@@ -144,10 +154,10 @@ class _pagebuilderupload extends \IPS\Widget\StaticCache implements \IPS\Widget\
{
foreach( explode( ',', $this->configuration['pagebuilderupload_upload'] ) as $img )
{
$images[] = (string) \IPS\File::get( 'core_Attachment', $img )->url;
$images[] = (string) File::get( 'core_Attachment', $img )->url;
}
return $this->output( ( \count( $images ) === 1 ? $images[0] : $images ), $captions, $urls, $autoPlay, $maxHeight );
return $this->output( ( count( $images ) === 1 ? $images[0] : $images ), $captions, $urls, $autoPlay, $maxHeight );
}
return '';