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,55 +12,65 @@
|
||||
namespace IPS\nexus\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\nexus\Package\Review;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\PermissionCache;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* recentCommerceReviews Widget
|
||||
*/
|
||||
class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
class recentCommerceReviews extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'recentCommerceReviews';
|
||||
public string $key = 'recentCommerceReviews';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'nexus';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
public string $app = 'nexus';
|
||||
|
||||
/**
|
||||
* Init widget
|
||||
*
|
||||
* @return null
|
||||
* @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', 'front' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'nexus', 'front' ) );
|
||||
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 );
|
||||
|
||||
/* Container */
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'widget_group', isset( $this->configuration['widget_group'] ) ? $this->configuration['widget_group'] : 0, FALSE, array(
|
||||
$form->add( new Node( 'widget_group', $this->configuration['widget_group'] ?? 0, FALSE, array(
|
||||
'class' => '\IPS\nexus\Package\Group',
|
||||
'zeroVal' => 'all',
|
||||
'permissionCheck' => 'view',
|
||||
@@ -68,7 +78,7 @@ class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
'subnodes' => false,
|
||||
) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'review_count', isset( $this->configuration['review_count'] ) ? $this->configuration['review_count'] : 5, TRUE ) );
|
||||
$form->add( new Number( 'review_count', $this->configuration['review_count'] ?? 5, TRUE ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -79,9 +89,9 @@ class _recentCommerceReviews 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['widget_group'] ) )
|
||||
if ( is_array( $values['widget_group'] ) )
|
||||
{
|
||||
$values['widget_group'] = array_keys( $values['widget_group'] );
|
||||
}
|
||||
@@ -94,18 +104,18 @@ class _recentCommerceReviews extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( ! empty( $this->configuration['widget_group'] ) )
|
||||
{
|
||||
$where['item'][] = array( \IPS\Db::i()->in( 'p_group', $this->configuration['widget_group'] ) );
|
||||
$where['item'][] = array( Db::i()->in( 'p_group', $this->configuration['widget_group'] ) );
|
||||
}
|
||||
|
||||
$reviews = \IPS\nexus\Package\Review::getItemsWithPermission( $where, NULL, ( isset( $this->configuration['review_count'] ) AND $this->configuration['review_count'] > 0 ) ? $this->configuration['review_count'] : 5, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY );
|
||||
$reviews = Review::getItemsWithPermission( $where, null, ( isset( $this->configuration['review_count'] ) and $this->configuration['review_count'] > 0 ) ? $this->configuration['review_count'] : 5, 'read', Filter::FILTER_PUBLIC_ONLY );
|
||||
|
||||
if ( !\count( $reviews ) )
|
||||
if ( !count( $reviews ) )
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user