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
@@ -11,54 +11,64 @@
|
||||
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\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* newsletter Widget
|
||||
*/
|
||||
class _newsletter extends \IPS\Widget
|
||||
class newsletter extends Widget
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'newsletter';
|
||||
public string $key = 'newsletter';
|
||||
|
||||
/**
|
||||
* @brief Language String Key used to store the editor content
|
||||
*/
|
||||
public static $editorKey = 'block_newsletter_signup';
|
||||
public static string $editorKey = 'block_newsletter_signup';
|
||||
|
||||
/**
|
||||
* @brief Language Key used to save the content
|
||||
*/
|
||||
public static $editorLangKey = 'block_newsletter_signup';
|
||||
public static string $editorLangKey = 'block_newsletter_signup';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'core';
|
||||
public string $app = 'core';
|
||||
|
||||
/**
|
||||
* @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 );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Translatable( 'block_newsletter_signup_text', NULL, TRUE, array(
|
||||
$form->add( new Translatable( 'block_newsletter_signup_text', NULL, TRUE, array(
|
||||
'app' => 'core',
|
||||
'key' => static::$editorLangKey,
|
||||
'editor' => array(
|
||||
@@ -76,27 +86,27 @@ class _newsletter extends \IPS\Widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete() : void
|
||||
{
|
||||
\IPS\Lang::deleteCustom( 'core', static::$editorLangKey );
|
||||
Lang::deleteCustom( 'core', static::$editorLangKey );
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_Newsletterwidget' ) ) ) as $map )
|
||||
foreach( Db::i()->select( '*', 'core_attachments_map', array( array( 'location_key=?', 'core_Newsletterwidget' ) ) ) 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 ) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +116,10 @@ class _newsletter 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, 'block_newsletter_signup' );
|
||||
\IPS\Lang::saveCustom( 'core', 'block_newsletter_signup', $values[ 'block_newsletter_signup_text' ] );
|
||||
File::claimAttachments( 'widget-' . $this->uniqueKey, 0, 0, 'block_newsletter_signup' );
|
||||
Lang::saveCustom( 'core', 'block_newsletter_signup', $values[ 'block_newsletter_signup_text' ] );
|
||||
return $values;
|
||||
}
|
||||
|
||||
@@ -118,21 +128,21 @@ class _newsletter extends \IPS\Widget
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
if( \IPS\Member::loggedIn()->allow_admin_mails )
|
||||
if( Member::loggedIn()->allow_admin_mails )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
// If we have just dropped the block, the ref will be the URL for that block drop, which will show a WSOD if we click the sign up button before reloading the page
|
||||
if ( isset( \IPS\Request::i()->blockID ) )
|
||||
if ( isset( Request::i()->blockID ) )
|
||||
{
|
||||
$url = \IPS\Settings::i()->base_url;
|
||||
$url = Settings::i()->base_url;
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = (string) \IPS\Request::i()->url();
|
||||
$url = (string) Request::i()->url();
|
||||
}
|
||||
|
||||
return $this->output( $url );
|
||||
|
||||
Reference in new issue
Block a user