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,57 +12,66 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\nexus\Package;
|
||||
use IPS\Output;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\PermissionCache;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function is_array;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* featuredProduct Widget
|
||||
*/
|
||||
class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
class featuredProduct extends PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'featuredProduct';
|
||||
public string $key = 'featuredProduct';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Initialise this widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'nexus' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus' ) );
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
|
||||
$value = 0;
|
||||
if ( isset( $this->configuration['package'] ) )
|
||||
{
|
||||
if ( \is_array( $this->configuration['package'] ) )
|
||||
if ( is_array( $this->configuration['package'] ) )
|
||||
{
|
||||
$value = $this->configuration['package'];
|
||||
}
|
||||
@@ -72,7 +81,7 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'package', $value, FALSE, array(
|
||||
$form->add( new Node( 'package', $value, FALSE, array(
|
||||
'class' => '\IPS\nexus\Package',
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
@@ -95,9 +104,9 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
if ( \is_array( $values['package'] ) )
|
||||
if ( is_array( $values['package'] ) )
|
||||
{
|
||||
$save = array();
|
||||
foreach( $values['package'] AS $pkg )
|
||||
@@ -119,27 +128,27 @@ class _featuredProduct extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
//Load the product
|
||||
$packages = array();
|
||||
if( isset( $this->configuration['package'] ) )
|
||||
{
|
||||
if ( \is_array( $this->configuration['package'] ) )
|
||||
if ( is_array( $this->configuration['package'] ) )
|
||||
{
|
||||
$packages = new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'nexus_packages', array( array( 'p_store=1' ), array( \IPS\Db::i()->in( 'p_id', $this->configuration['package'] ) ) ) ), 'IPS\nexus\Package' );
|
||||
$packages = new ActiveRecordIterator( Db::i()->select( '*', 'nexus_packages', array( array( 'p_store=1' ), array( Db::i()->in( 'p_id', $this->configuration['package'] ) ) ) ), 'IPS\nexus\Package' );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
$packages = array( \IPS\nexus\Package::load( $this->configuration['package'] ) );
|
||||
$packages = array( Package::load( $this->configuration['package'] ) );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ){}
|
||||
catch ( OutOfRangeException ){}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !\count( $packages ) )
|
||||
if ( !count( $packages ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user