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,41 +12,55 @@
|
||||
namespace IPS\core;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\Url as FormUrl;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Referral Banner Node
|
||||
*/
|
||||
class _ReferralBanner extends \IPS\Node\Model
|
||||
class ReferralBanner extends Model
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_referral_banners';
|
||||
public static ?string $databaseTable = 'core_referral_banners';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'rb_';
|
||||
public static string $databasePrefix = 'rb_';
|
||||
|
||||
/**
|
||||
* @brief [Node] Order Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'order';
|
||||
public static ?string $databaseColumnOrder = 'order';
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'referral_banners';
|
||||
public static string $nodeTitle = 'referral_banners';
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
@@ -64,7 +78,7 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
|
||||
* @endcode
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
protected static ?array $restrictions = array(
|
||||
'app' => 'core',
|
||||
'module' => 'membersettings',
|
||||
'all' => 'referrals_banners'
|
||||
@@ -75,9 +89,9 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get__title()
|
||||
public function get__title(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->referralBanner( $this->url );
|
||||
return Theme::i()->getTemplate( 'global', 'core', 'global' )->referralBanner( $this->url );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +99,7 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canCopy()
|
||||
public function canCopy(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -93,12 +107,12 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @param Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
public function form( Form &$form ) : void
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'rb_upload', $this->id ? $this->upload : 1, TRUE, array(
|
||||
$form->add( new Radio( 'rb_upload', $this->id ? $this->upload : 1, TRUE, array(
|
||||
'options' => array(
|
||||
1 => 'rb_upload_yes',
|
||||
0 => 'rb_upload_no'
|
||||
@@ -109,19 +123,19 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
)
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'rb_url_upload', $this->upload ? \IPS\File::get( 'core_ReferralBanners', $this->url ) : NULL, NULL, array( 'storageExtension' => 'core_ReferralBanners' ), function( $val )
|
||||
$form->add( new Upload( 'rb_url_upload', $this->upload ? File::get( 'core_ReferralBanners', $this->url ) : NULL, NULL, array( 'storageExtension' => 'core_ReferralBanners' ), function( $val )
|
||||
{
|
||||
if ( \IPS\Request::i()->rb_upload and !$val )
|
||||
if ( Request::i()->rb_upload and !$val )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'rb_url_upload' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Url( 'rb_url_url', !$this->upload ? $this->url : NULL, NULL, array( 'allowedMimes' => 'image/*' ), function( $val )
|
||||
$form->add( new FormUrl( 'rb_url_url', !$this->upload ? $this->url : NULL, NULL, array( 'allowedMimes' => 'image/*' ), function( $val )
|
||||
{
|
||||
if ( !\IPS\Request::i()->rb_upload and !$val )
|
||||
if ( !Request::i()->rb_upload and !$val )
|
||||
{
|
||||
throw new \DomainException('form_required');
|
||||
throw new DomainException('form_required');
|
||||
}
|
||||
}, NULL, NULL, 'rb_url_url' ) );
|
||||
}
|
||||
@@ -132,7 +146,7 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
public function formatFormValues( array $values ): array
|
||||
{
|
||||
if( isset( $values['rb_url_upload'] ) or isset( $values['rb_url_url'] ) )
|
||||
{
|
||||
@@ -154,17 +168,17 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
/**
|
||||
* [ActiveRecord] Delete Record
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
if ( $this->upload )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\File::get( 'core_ReferralBanners', $this->url )->delete();
|
||||
File::get( 'core_ReferralBanners', $this->url )->delete();
|
||||
}
|
||||
catch( \Exception $e ) { }
|
||||
catch( Exception $e ) { }
|
||||
}
|
||||
|
||||
parent::delete();
|
||||
@@ -173,18 +187,18 @@ class _ReferralBanner extends \IPS\Node\Model
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url|string|null
|
||||
* @note Any nodes that have URLs (e.g. forums, gallery categories) should override this
|
||||
*/
|
||||
public function url()
|
||||
function url(): Url|string|null
|
||||
{
|
||||
if ( mb_substr( $this->url, 0, 4 ) == 'http')
|
||||
{
|
||||
return \IPS\Http\Url::external( $this->url );
|
||||
return Url::external( $this->url );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\Http\Url::internal( $this->url, 'none', NULL );
|
||||
return Url::internal( $this->url, 'none' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user