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

+53 -42
View File
@@ -11,70 +11,81 @@
namespace IPS\core\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Db;
use IPS\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Translatable;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Login;
use IPS\Member;
use IPS\Widget;
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;
}
/**
* guestSignUp Widget
*/
class _guestSignUp extends \IPS\Widget
class guestSignUp extends Widget
{
/**
* @brief Widget Key
*/
public $key = 'guestSignUp';
public string $key = 'guestSignUp';
/**
* @brief Language String Key used to store the editor content
*/
public static $editorKey = 'block_guestsignup_message';
public static string $editorKey = 'block_guestsignup_message';
/**
* @brief Language Key used to save the content
*/
public static $editorLangKey = 'widget_guestsignup_text';
public static string $editorLangKey = 'widget_guestsignup_text';
/**
* @brief App
*/
public $app = 'core';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'core';
/**
* 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' )
{
parent::__construct($uniqueKey, $configuration, $access, $orientation);
parent::__construct($uniqueKey, $configuration, $access, $orientation, $layout);
$this->errorMessage = 'guest_signup_admin_message';
}
/**
* 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\Translatable( 'block_guestsignup_title', NULL, TRUE, array( 'app'=>'core', 'key' =>'widget_guestsignup_title' ) ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'block_guestsignup_message', NULL, TRUE, array(
$form->add( new Translatable( 'block_guestsignup_title', NULL, TRUE, array( 'app'=>'core', 'key' =>'widget_guestsignup_title' ) ) );
$form->add( new Translatable( 'block_guestsignup_message', NULL, TRUE, array(
'app' => 'core',
'key' => static::$editorLangKey,
'editor' => array(
@@ -92,28 +103,28 @@ class _guestSignUp extends \IPS\Widget
*
* @return void
*/
public function delete()
public function delete() : void
{
\IPS\Lang::deleteCustom( 'core', 'widget_guestsignup_title' );
\IPS\Lang::deleteCustom( 'core', 'widget_guestsignup_text' );
Lang::deleteCustom( 'core', 'widget_guestsignup_title' );
Lang::deleteCustom( 'core', 'widget_guestsignup_text' );
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_GuestSignupWidget' ) ) ) as $map )
foreach( Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_GuestSignupWidget' ) ) ) as $map )
{
try
{
$attachment = \IPS\Db::i()->select( '*', 'core_attachments', array( 'attach_id=?', $map['attachment_id'] ) )->first();
$attachment = Db::i()->select( '*', 'core_attachments', array( 'attach_id=?', $map['attachment_id'] ) )->first();
\IPS\Db::i()->delete( 'core_attachments_map', array( array( 'attachment_id=?', $attachment['attach_id'] ) ) );
\IPS\Db::i()->delete( 'core_attachments', array( 'attach_id=?', $attachment['attach_id'] ) );
Db::i()->delete( 'core_attachments_map', array( array( 'attachment_id=?', $attachment['attach_id'] ) ) );
Db::i()->delete( 'core_attachments', array( 'attach_id=?', $attachment['attach_id'] ) );
\IPS\File::get( 'core_Attachment', $attachment['attach_location'] )->delete();
File::get( 'core_Attachment', $attachment['attach_location'] )->delete();
if ( $attachment['attach_thumb_location'] )
{
\IPS\File::get( 'core_Attachment', $attachment['attach_thumb_location'] )->delete();
File::get( 'core_Attachment', $attachment['attach_thumb_location'] )->delete();
}
}
catch ( \Exception $e ) { }
catch ( Exception $e ) { }
}
}
@@ -123,11 +134,11 @@ class _guestSignUp extends \IPS\Widget
* @param array $values Values from form
* @return array
*/
public function preConfig( $values )
public function preConfig( array $values ): array
{
\IPS\File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, 'widget_guestsignup_text' );
\IPS\Lang::saveCustom( 'core', static::$editorLangKey, $values[ 'block_guestsignup_message' ] );
\IPS\Lang::saveCustom( 'core', 'widget_guestsignup_title', $values[ 'block_guestsignup_title' ] );
File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, 'widget_guestsignup_text' );
Lang::saveCustom( 'core', static::$editorLangKey, $values[ 'block_guestsignup_message' ] );
Lang::saveCustom( 'core', 'widget_guestsignup_title', $values[ 'block_guestsignup_title' ] );
return $values;
}
@@ -136,23 +147,23 @@ class _guestSignUp extends \IPS\Widget
*
* @return string
*/
public function render()
public function render(): string
{
/* Show this only to guests */
if ( \IPS\Member::loggedIn()->member_id )
if ( Member::loggedIn()->member_id )
{
return '';
}
else
{
$title = \IPS\Member::loggedIn()->language()->addToStack( 'widget_guestsignup_title' );
$text = \IPS\Member::loggedIn()->language()->addToStack( 'widget_guestsignup_text' );
if ( !\IPS\Member::loggedIn()->language()->checkKeyExists( 'widget_guestsignup_title' ) )
$title = Member::loggedIn()->language()->addToStack( 'widget_guestsignup_title' );
$text = Member::loggedIn()->language()->addToStack( 'widget_guestsignup_text' );
if ( !Member::loggedIn()->language()->checkKeyExists( 'widget_guestsignup_title' ) )
{
return '';
}
$login = new \IPS\Login( \IPS\Http\Url::internal( 'app=core&module=system&controller=login', 'front', 'login' ) );
$login = new Login( Url::internal( 'app=core&module=system&controller=login', 'front', 'login' ) );
return $this->output( $login, $text, $title );
}
}