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,83 @@
|
||||
namespace IPS\Content;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Member as FormMember;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Rating;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\IPS;
|
||||
use IPS\Member;
|
||||
use IPS\Widget\Customizable;
|
||||
use IPS\Widget\PermissionCache;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use function is_array;
|
||||
use const IPS\UPGRADE_LARGE_TABLE_SIZE;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Content Comment Feed Widget
|
||||
*/
|
||||
abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
abstract class WidgetComment extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Class
|
||||
*/
|
||||
protected static $class;
|
||||
protected static string $class;
|
||||
|
||||
/**
|
||||
* @brief Moderator permission to generate caches on [optional]
|
||||
*/
|
||||
protected $moderatorPermissions = array();
|
||||
protected array $moderatorPermissions = array();
|
||||
|
||||
/**
|
||||
* Skip the getItemsWithPermission check?
|
||||
*/
|
||||
protected static $permissionCheck = 'read';
|
||||
protected static string $permissionCheck = 'read';
|
||||
|
||||
/**
|
||||
* Skip the getItemsWithPermission check?
|
||||
*/
|
||||
protected static $skipPermissions = FALSE;
|
||||
protected static bool $skipPermissions = FALSE;
|
||||
|
||||
/**
|
||||
* 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 );
|
||||
|
||||
if( \count( $this->moderatorPermissions ) )
|
||||
if( count( $this->moderatorPermissions ) )
|
||||
{
|
||||
$cacheKeyChecks = array();
|
||||
|
||||
foreach( $this->moderatorPermissions as $permission )
|
||||
{
|
||||
$cacheKeyChecks[] = \IPS\Member::loggedIn()->modPermission( $permission );
|
||||
$cacheKeyChecks[] = Member::loggedIn()->modPermission( $permission );
|
||||
}
|
||||
|
||||
$this->cacheKey .= '_' . implode( '_', $cacheKeyChecks );
|
||||
@@ -72,13 +98,13 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \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 );
|
||||
|
||||
|
||||
foreach( $this->formElements() as $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
@@ -92,36 +118,37 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function formElements()
|
||||
protected function formElements(): array
|
||||
{
|
||||
/* @var Comment $class */
|
||||
/* Init */
|
||||
$class = static::$class;
|
||||
$itemClass = $class::$itemClass;
|
||||
$return = array();
|
||||
|
||||
/* Block title */
|
||||
$return['title'] = new \IPS\Helpers\Form\Text( 'widget_feed_title', isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) );
|
||||
$return['title'] = new Text( 'widget_feed_title', $this->configuration['widget_feed_title'] ?? Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) );
|
||||
|
||||
/* Container */
|
||||
if ( isset( $itemClass::$containerNodeClass ) )
|
||||
{
|
||||
$return['container'] = new \IPS\Helpers\Form\Node( 'widget_feed_container_' . $itemClass::$title, isset( $this->configuration['widget_feed_container'] ) ? $this->configuration['widget_feed_container'] : 0, FALSE, array(
|
||||
$return['container'] = new Node( 'widget_feed_container_' . $itemClass::$title, $this->configuration['widget_feed_container'] ?? 0, FALSE, array(
|
||||
'class' => $itemClass::$containerNodeClass,
|
||||
'zeroVal' => 'all',
|
||||
'permissionCheck' => 'view',
|
||||
'multiple' => TRUE,
|
||||
'clubs' => TRUE
|
||||
) );
|
||||
}
|
||||
|
||||
/* Use permissions? */
|
||||
if ( \in_array( 'IPS\Content\Permissions', class_implements( $itemClass ) ) )
|
||||
{
|
||||
$return['permissions'] = new \IPS\Helpers\Form\YesNo( 'widget_feed_use_perms', isset( $this->configuration['widget_feed_use_perms'] ) ? $this->configuration['widget_feed_use_perms'] : TRUE, FALSE );
|
||||
|
||||
/* Use permissions? */
|
||||
if( in_array( 'IPS\Node\Permissions', class_implements( $itemClass::$containerNodeClass ) ) )
|
||||
{
|
||||
$return['permissions'] = new YesNo( 'widget_feed_use_perms', $this->configuration['widget_feed_use_perms'] ?? TRUE, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
/* Types */
|
||||
if ( \in_array( 'IPS\Content\Lockable', class_implements( $itemClass ) ) )
|
||||
if ( IPS::classUsesTrait( $itemClass, 'IPS\Content\Lockable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -129,9 +156,9 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
'closed' => 'mod_confirm_lock'
|
||||
);
|
||||
|
||||
$return['locked'] = new \IPS\Helpers\Form\Radio( 'widget_feed_item_status_locked', isset( $this->configuration['widget_feed_item_status_locked'] ) ? $this->configuration['widget_feed_item_status_locked'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['locked'] = new Radio( 'widget_feed_item_status_locked', $this->configuration['widget_feed_item_status_locked'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $itemClass ) ) )
|
||||
if ( IPS::classUsesTrait( $itemClass, 'IPS\Content\Pinnable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -139,9 +166,9 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
'notpinned' => 'mod_confirm_unpin'
|
||||
);
|
||||
|
||||
$return['pinned'] = new \IPS\Helpers\Form\Radio( 'widget_feed_item_status_pinned', isset( $this->configuration['widget_feed_item_status_pinned'] ) ? $this->configuration['widget_feed_item_status_pinned'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['pinned'] = new Radio( 'widget_feed_item_status_pinned', $this->configuration['widget_feed_item_status_pinned'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $itemClass ) ) )
|
||||
if ( IPS::classUsesTrait( $itemClass, 'IPS\Content\Featurable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -149,9 +176,9 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
'notfeatured' => 'mod_confirm_unfeature'
|
||||
);
|
||||
|
||||
$return['featured'] = new \IPS\Helpers\Form\Radio( 'widget_feed_item_status_featured', isset( $this->configuration['widget_feed_item_status_featured'] ) ? $this->configuration['widget_feed_item_status_featured'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['featured'] = new Radio( 'widget_feed_item_status_featured', $this->configuration['widget_feed_item_status_featured'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Hideable', class_implements( $class ) ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Hideable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -159,9 +186,9 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
'hidden' => 'mod_confirm_hidden'
|
||||
);
|
||||
|
||||
$return['hidden'] = new \IPS\Helpers\Form\Radio( 'widget_feed_comment_status_visible', isset( $this->configuration['widget_feed_comment_status_visible'] ) ? $this->configuration['widget_feed_comment_status_visible'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['hidden'] = new Radio( 'widget_feed_comment_status_visible', $this->configuration['widget_feed_comment_status_visible'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \IPS\IPS::classUsesTrait( $itemClass, 'IPS\Content\Solvable' ) )
|
||||
if ( IPS::classUsesTrait( $itemClass, 'IPS\Content\Solvable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'solved_either',
|
||||
@@ -169,51 +196,51 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
'unsolved' => 'solved_unsolved'
|
||||
);
|
||||
|
||||
$return['solved'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_solved', isset( $this->configuration['widget_feed_status_solved'] ) ? $this->configuration['widget_feed_status_solved'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['solved'] = new Radio( 'widget_feed_status_solved', $this->configuration['widget_feed_status_solved'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
/* Author */
|
||||
$author = NULL;
|
||||
try
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_item_author'] ) and \is_array( $this->configuration['widget_feed_item_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_author'] ) and is_array( $this->configuration['widget_feed_item_author'] ) )
|
||||
{
|
||||
foreach( $this->configuration['widget_feed_item_author'] as $id )
|
||||
{
|
||||
$author[ $id ] = \IPS\Member::load( $id );
|
||||
$author[ $id ] = Member::load( $id );
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( \OutOfRangeException $ex ) { }
|
||||
$return['author'] = new \IPS\Helpers\Form\Member( 'widget_feed_item_author', $author, FALSE, array( 'multiple' => true ) );
|
||||
catch( OutOfRangeException $ex ) { }
|
||||
$return['author'] = new FormMember( 'widget_feed_item_author', $author, FALSE, array( 'multiple' => true ) );
|
||||
|
||||
/* Minimum comments/reviews */
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
if ( $class::$firstCommentRequired )
|
||||
{
|
||||
$return['min_posts'] = new \IPS\Helpers\Form\Number( 'widget_feed_item_min_posts', isset( $this->configuration['widget_feed_item_min_posts'] ) ? $this->configuration['widget_feed_item_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_posts'] = new Number( 'widget_feed_item_min_posts', $this->configuration['widget_feed_item_min_posts'] ?? 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['min_comments'] = new \IPS\Helpers\Form\Number( 'widget_feed_item_min_comments', isset( $this->configuration['widget_feed_item_min_comments'] ) ? $this->configuration['widget_feed_item_min_comments'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_comments'] = new Number( 'widget_feed_item_min_comments', $this->configuration['widget_feed_item_min_comments'] ?? 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
}
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$return['min_reviews'] = new \IPS\Helpers\Form\Number( 'widget_feed_item_min_reviews', isset( $this->configuration['widget_feed_item_min_reviews'] ) ? $this->configuration['widget_feed_item_min_reviews'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_reviews'] = new Number( 'widget_feed_item_min_reviews', $this->configuration['widget_feed_item_min_reviews'] ?? 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
|
||||
/* Rating */
|
||||
if ( \in_array( 'IPS\Content\Ratings', class_implements( $class ) ) and isset( $class::$databaseColumnMap['rating_average'] ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Ratings' ) and isset( $class::$databaseColumnMap['rating_average'] ) )
|
||||
{
|
||||
$return['rating'] = new \IPS\Helpers\Form\Rating( 'widget_feed_item_min_rating', isset( $this->configuration['widget_feed_item_min_rating'] ) ? $this->configuration['widget_feed_item_min_rating'] : 0, FALSE, array() );
|
||||
$return['rating'] = new Rating( 'widget_feed_item_min_rating', $this->configuration['widget_feed_item_min_rating'] ?? 0, FALSE, array() );
|
||||
}
|
||||
|
||||
if ( isset( $class::$databaseColumnMap['date'] ) )
|
||||
{
|
||||
$return['date_restrict'] = new \IPS\Helpers\Form\Select( 'widget_feed_comment_date', isset( $this->configuration['widget_feed_comment_date'] ) ? (int) $this->configuration['widget_feed_comment_date'] : 0, FALSE, array(
|
||||
$return['date_restrict'] = new Select( 'widget_feed_comment_date', isset( $this->configuration['widget_feed_comment_date'] ) ? (int) $this->configuration['widget_feed_comment_date'] : 0, FALSE, array(
|
||||
'options' => array(
|
||||
0 => $class::databaseTableCount( TRUE ) > \IPS\UPGRADE_LARGE_TABLE_SIZE ? 'search_year' : 'show_all',
|
||||
0 => $class::databaseTableCount( TRUE ) > UPGRADE_LARGE_TABLE_SIZE ? 'search_year' : 'show_all',
|
||||
1 => 'today',
|
||||
5 => 'last_5_days',
|
||||
7 => 'last_7_days',
|
||||
@@ -229,10 +256,10 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Number to show */
|
||||
$return['show'] = new \IPS\Helpers\Form\Number( 'widget_feed_show', isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, TRUE );
|
||||
$return['show'] = new Number( 'widget_feed_show', $this->configuration['widget_feed_show'] ?? 5, TRUE );
|
||||
|
||||
/* Sort */
|
||||
$return['sort'] = new \IPS\Helpers\Form\Select( 'widget_feed_sort_dir', isset( $this->configuration['widget_feed_sort_dir'] ) ? $this->configuration['widget_feed_sort_dir'] : 'desc', FALSE, array(
|
||||
$return['sort'] = new Select( 'widget_feed_sort_dir', $this->configuration['widget_feed_sort_dir'] ?? 'desc', FALSE, array(
|
||||
'options' => array(
|
||||
'desc' => 'descending',
|
||||
'asc' => 'ascending'
|
||||
@@ -241,11 +268,11 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
|
||||
/* Fix up some language strings */
|
||||
$langs = array( 'widget_feed_item_status_locked', 'widget_feed_item_status_pinned', 'widget_feed_item_status_featured', 'widget_feed_comment_status_visible', 'widget_feed_item_author', 'widget_feed_item_min_posts', 'widget_feed_item_min_comments', 'widget_feed_item_min_reviews', 'widget_feed_item_min_rating' );
|
||||
$words = \IPS\Member::loggedIn()->language()->get( $langs );
|
||||
$words = Member::loggedIn()->language()->get( $langs );
|
||||
|
||||
foreach( $langs as $lang )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words[ $lang ] = sprintf( $words[ $lang ], \IPS\Member::loggedIn()->language()->addToStack( $itemClass::$title ) );
|
||||
Member::loggedIn()->language()->words[ $lang ] = sprintf( $words[ $lang ], Member::loggedIn()->language()->addToStack( $itemClass::$title ) );
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -257,18 +284,19 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
/* @var Comment $class */
|
||||
$class = static::$class;
|
||||
$itemClass = $class::$itemClass;
|
||||
|
||||
if ( \is_array( $values[ 'widget_feed_container_' . $itemClass::$title ] ) )
|
||||
if ( is_array( $values[ 'widget_feed_container_' . $itemClass::$title ] ) )
|
||||
{
|
||||
$values['widget_feed_container'] = array_keys( $values[ 'widget_feed_container_' . $itemClass::$title ] );
|
||||
unset( $values[ 'widget_feed_container_' . $class::$title ] );
|
||||
unset( $values[ 'widget_feed_container_' . $itemClass::$title ] );
|
||||
}
|
||||
|
||||
if ( \is_array( $values['widget_feed_item_author'] ) )
|
||||
if ( is_array( $values['widget_feed_item_author'] ) )
|
||||
{
|
||||
$members = array();
|
||||
foreach( $values['widget_feed_item_author'] as $member )
|
||||
@@ -287,8 +315,10 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function buildWhere()
|
||||
protected function buildWhere(): array
|
||||
{
|
||||
/* @var array $databaseColumnMap */
|
||||
/* @var Comment $class */
|
||||
$class = static::$class;
|
||||
$itemClass = $class::$itemClass;
|
||||
$where = array();
|
||||
@@ -322,17 +352,17 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
$nodeIds[] = $id;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$where['item'][] = array( \IPS\Db::i()->in( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['container'], $nodeIds ) );
|
||||
$where['item'][] = array( Db::i()->in( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['container'], $nodeIds ) );
|
||||
}
|
||||
|
||||
/* Locked or open status */
|
||||
if ( isset( $this->configuration['widget_feed_item_status_locked'] ) and \in_array( 'IPS\Content\Lockable', class_implements( $itemClass ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_status_locked'] ) and IPS::classUsesTrait( $itemClass, 'IPS\Content\Lockable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_item_status_locked'] == 'closed' )
|
||||
{
|
||||
@@ -345,7 +375,7 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Featured or unfeatured */
|
||||
if ( isset( $this->configuration['widget_feed_item_status_featured'] ) and \in_array( 'IPS\Content\Featurable', class_implements( $itemClass ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_status_featured'] ) and IPS::classUsesTrait( $itemClass, 'IPS\Content\Featurable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_item_status_featured'] == 'notfeatured' )
|
||||
{
|
||||
@@ -368,7 +398,7 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Pinned or unpinned */
|
||||
if ( isset( $this->configuration['widget_feed_item_status_pinned'] ) and \in_array( 'IPS\Content\Pinnable', class_implements( $itemClass ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_status_pinned'] ) and IPS::classUsesTrait( $itemClass, 'IPS\Content\Pinnable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_item_status_pinned'] == 'notpinned' )
|
||||
{
|
||||
@@ -381,45 +411,45 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Author */
|
||||
if ( isset( $this->configuration['widget_feed_item_author'] ) and \is_array( $this->configuration['widget_feed_item_author'] ) and \count( $this->configuration['widget_feed_item_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_author'] ) and is_array( $this->configuration['widget_feed_item_author'] ) and count( $this->configuration['widget_feed_item_author'] ) )
|
||||
{
|
||||
$where['item'][] = array( \IPS\Db::i()->in( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['author'], $this->configuration['widget_feed_item_author'] ) );
|
||||
$where['item'][] = array( Db::i()->in( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['author'], $this->configuration['widget_feed_item_author'] ) );
|
||||
}
|
||||
|
||||
/* Min posts/comments/reviews */
|
||||
if ( isset( $this->configuration['widget_feed_item_min_posts'] ) and isset( $this->configuration['widget_feed_item_min_posts'] ) and isset( $this->configuration['widget_feed_item_min_posts'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_item_min_posts'] ) and $this->configuration['widget_feed_item_min_posts'] )
|
||||
{
|
||||
$where['item'][] = array( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] . '>?', (int) $this->configuration['widget_feed_item_min_posts'] );
|
||||
}
|
||||
if ( isset( $this->configuration['widget_feed_item_min_comments'] ) and isset( $this->configuration['widget_feed_item_min_comments'] ) and $this->configuration['widget_feed_item_min_comments'] )
|
||||
if ( isset( $this->configuration['widget_feed_item_min_comments'] ) and $this->configuration['widget_feed_item_min_comments'] )
|
||||
{
|
||||
$where['item'][] = array( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_comments'] . '>?', (int) $this->configuration['widget_feed_item_min_comments'] );
|
||||
}
|
||||
if ( isset( $this->configuration['widget_feed_item_min_reviews'] ) and isset( $this->configuration['widget_feed_item_min_reviews'] ) and $this->configuration['widget_feed_item_min_reviews'] )
|
||||
if ( isset( $this->configuration['widget_feed_item_min_reviews'] ) and $this->configuration['widget_feed_item_min_reviews'] )
|
||||
{
|
||||
$where['item'][] = array( $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['num_reviews'] . '>?', (int) $this->configuration['widget_feed_item_min_reviews'] );
|
||||
}
|
||||
|
||||
/* Rating */
|
||||
if ( isset( $this->configuration['widget_feed_item_min_rating'] ) and isset( $this->configuration['widget_feed_item_min_rating'] ) and $this->configuration['widget_feed_item_min_rating'] )
|
||||
if ( isset( $this->configuration['widget_feed_item_min_rating'] ) and $this->configuration['widget_feed_item_min_rating'] )
|
||||
{
|
||||
$where['item'][] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['rating_average'] . '>?', (int) $this->configuration['widget_feed_item_min_rating'] );
|
||||
}
|
||||
|
||||
/* Future */
|
||||
if ( \in_array( 'IPS\Content\FuturePublishing', class_implements( $itemClass ) ) )
|
||||
if ( IPS::classUsesTrait( $itemClass, 'IPS\Content\FuturePublishing' ) )
|
||||
{
|
||||
$where['item'][] = array( $itemClass::$databasePrefix . $itemClass::$databaseColumnMap['is_future_entry'] . '=0' );
|
||||
}
|
||||
|
||||
/* Start date */
|
||||
if ( isset( $this->configuration['widget_feed_comment_date'] ) and isset( $this->configuration['widget_feed_comment_date'] ) and $this->configuration['widget_feed_comment_date'] > 0 )
|
||||
if ( isset( $this->configuration['widget_feed_comment_date'] ) and $this->configuration['widget_feed_comment_date'] > 0 )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_comment_date'] . 'D' ) )->getTimestamp() );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', DateTime::create()->sub( new DateInterval( 'P' . $this->configuration['widget_feed_comment_date'] . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
else if ( $class::databaseTableCount( TRUE ) > \IPS\UPGRADE_LARGE_TABLE_SIZE )
|
||||
else if ( $class::databaseTableCount( TRUE ) > UPGRADE_LARGE_TABLE_SIZE )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P1Y' ) )->getTimestamp() );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', DateTime::create()->sub( new DateInterval( 'P1Y' ) )->getTimestamp() );
|
||||
}
|
||||
|
||||
return $where;
|
||||
@@ -430,23 +460,25 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
/* @var array $databaseColumnMap */
|
||||
/* @var Comment $class */
|
||||
$class = static::$class;
|
||||
|
||||
/* What visible status are we checking? */
|
||||
$hidden = \IPS\Content\Hideable::FILTER_AUTOMATIC;
|
||||
$hidden = Filter::FILTER_AUTOMATIC;
|
||||
|
||||
if( isset( $this->configuration['widget_feed_comment_status_visible'] ) )
|
||||
{
|
||||
switch( $this->configuration['widget_feed_comment_status_visible'] )
|
||||
{
|
||||
case 'visible':
|
||||
$hidden = \IPS\Content\Hideable::FILTER_PUBLIC_ONLY;
|
||||
$hidden = Filter::FILTER_PUBLIC_ONLY;
|
||||
break;
|
||||
|
||||
case 'hidden':
|
||||
$hidden = \IPS\Content\Hideable::FILTER_ONLY_HIDDEN;
|
||||
$hidden = Filter::FILTER_ONLY_HIDDEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -459,9 +491,9 @@ abstract class _WidgetComment extends \IPS\Widget\PermissionCache
|
||||
$hidden
|
||||
);
|
||||
|
||||
if ( \count( $items ) )
|
||||
if ( count( $items ) )
|
||||
{
|
||||
return $this->output( $items, isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) );
|
||||
return $this->output( $items, $this->configuration['widget_feed_title'] ?? Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user