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
+123
-87
@@ -12,34 +12,61 @@
|
||||
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\Select;
|
||||
use IPS\Helpers\Form\Text;
|
||||
use IPS\Helpers\Form\Translatable;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\IPS;
|
||||
use IPS\Lang;
|
||||
use IPS\Member;
|
||||
use IPS\Settings;
|
||||
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 Item Feed Widget
|
||||
*/
|
||||
abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
abstract class Widget extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* Class
|
||||
*/
|
||||
protected static $class;
|
||||
protected static string $class;
|
||||
|
||||
/**
|
||||
* Skip the getItemsWithPermission check?
|
||||
*/
|
||||
protected static $skipPermissions = FALSE;
|
||||
|
||||
protected static bool $skipPermissions = FALSE;
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
* @param null|\IPS\Helpers\Form $form Form object
|
||||
* @return \IPS\Helpers\Form
|
||||
* @param Form|null $form Form object
|
||||
* @return Form
|
||||
*/
|
||||
public function configuration( &$form=null )
|
||||
public function configuration( Form &$form=null ): Form
|
||||
{
|
||||
$form = parent::configuration( $form );
|
||||
|
||||
@@ -56,19 +83,21 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function formElements()
|
||||
protected function formElements(): array
|
||||
{
|
||||
/* Init */
|
||||
/* @var array $databaseColumnMap */
|
||||
/* @var Item $class */
|
||||
$class = static::$class;
|
||||
$return = array();
|
||||
|
||||
/* Block title */
|
||||
$return['title'] = new \IPS\Helpers\Form\Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ), FALSE, array( 'app' => 'core', 'key' => ( isset( $this->configuration['language_key'] ) ? $this->configuration['language_key'] : NULL ) ) );
|
||||
$return['title'] = new Translatable( 'widget_feed_title', isset( $this->configuration['language_key'] ) ? NULL : Member::loggedIn()->language()->addToStack( $class::$title . '_pl' ), FALSE, array( 'app' => 'core', 'key' => ( $this->configuration['language_key'] ?? NULL ) ) );
|
||||
|
||||
/* Container */
|
||||
if ( isset( $class::$containerNodeClass ) )
|
||||
{
|
||||
$return['container'] = new \IPS\Helpers\Form\Node( 'widget_feed_container_' . $class::$title, isset( $this->configuration['widget_feed_container'] ) ? $this->configuration['widget_feed_container'] : 0, FALSE, array(
|
||||
$return['container'] = new Node( 'widget_feed_container_' . $class::$title, $this->configuration['widget_feed_container'] ?? 0, FALSE, array(
|
||||
'class' => $class::$containerNodeClass,
|
||||
'zeroVal' => 'all',
|
||||
'permissionCheck' => 'view',
|
||||
@@ -76,16 +105,16 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'forceOwner' => false,
|
||||
'clubs' => TRUE
|
||||
) );
|
||||
}
|
||||
|
||||
/* Use permissions? */
|
||||
if ( \in_array( 'IPS\Content\Permissions', class_implements( $class ) ) )
|
||||
{
|
||||
$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( $class::$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( $class ) ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Lockable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -93,9 +122,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'closed' => 'mod_confirm_lock'
|
||||
);
|
||||
|
||||
$return['locked'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_locked', isset( $this->configuration['widget_feed_status_locked'] ) ? $this->configuration['widget_feed_status_locked'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['locked'] = new Radio( 'widget_feed_status_locked', $this->configuration['widget_feed_status_locked'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Pinnable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -103,9 +132,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'notpinned' => 'mod_confirm_unpin'
|
||||
);
|
||||
|
||||
$return['pinned'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_pinned', isset( $this->configuration['widget_feed_status_pinned'] ) ? $this->configuration['widget_feed_status_pinned'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['pinned'] = new Radio( 'widget_feed_status_pinned', $this->configuration['widget_feed_status_pinned'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
if ( \in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Featurable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -113,9 +142,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'notfeatured' => 'mod_confirm_unfeature'
|
||||
);
|
||||
|
||||
$return['featured'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_featured', isset( $this->configuration['widget_feed_status_featured'] ) ? $this->configuration['widget_feed_status_featured'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['featured'] = new Radio( 'widget_feed_status_featured', $this->configuration['widget_feed_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',
|
||||
@@ -123,9 +152,9 @@ abstract class _Widget 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( $class, 'IPS\Content\Solvable' ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\Solvable' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'solved_either',
|
||||
@@ -133,10 +162,10 @@ abstract class _Widget 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 ) );
|
||||
}
|
||||
|
||||
if ( \in_array( 'IPS\Content\FuturePublishing', class_implements( $class ) ) )
|
||||
if ( IPS::classUsesTrait( $class, 'IPS\Content\FuturePublishing' ) )
|
||||
{
|
||||
$types = array(
|
||||
'any' => 'mod_confirm_either',
|
||||
@@ -144,77 +173,77 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
'unpublished' => 'mod_confirm_unpublish'
|
||||
);
|
||||
|
||||
$return['published'] = new \IPS\Helpers\Form\Radio( 'widget_feed_status_published', isset( $this->configuration['widget_feed_status_published'] ) ? $this->configuration['widget_feed_status_published'] : 'any', FALSE, array( 'options' => $types ) );
|
||||
$return['published'] = new Radio( 'widget_feed_status_published', $this->configuration['widget_feed_status_published'] ?? 'any', FALSE, array( 'options' => $types ) );
|
||||
}
|
||||
|
||||
/* Author */
|
||||
$author = NULL;
|
||||
try
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and \is_array( $this->configuration['widget_feed_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and is_array( $this->configuration['widget_feed_author'] ) )
|
||||
{
|
||||
foreach( $this->configuration['widget_feed_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_author', $author, FALSE, array( 'multiple' => NULL ) );
|
||||
catch( OutOfRangeException $ex ) { }
|
||||
$return['author'] = new FormMember( 'widget_feed_author', $author, FALSE, array( 'multiple' => NULL ) );
|
||||
|
||||
/* Minimum comments/reviews */
|
||||
if ( isset( $class::$commentClass ) )
|
||||
{
|
||||
if ( $class::$firstCommentRequired )
|
||||
{
|
||||
$return['min_posts'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_posts', isset( $this->configuration['widget_feed_min_posts'] ) ? $this->configuration['widget_feed_min_posts'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_posts'] = new Number( 'widget_feed_min_posts', $this->configuration['widget_feed_min_posts'] ?? 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['min_comments'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_comments', isset( $this->configuration['widget_feed_min_comments'] ) ? $this->configuration['widget_feed_min_comments'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_comments'] = new Number( 'widget_feed_min_comments', $this->configuration['widget_feed_min_comments'] ?? 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
}
|
||||
}
|
||||
if ( isset( $class::$reviewClass ) )
|
||||
{
|
||||
$return['min_reviews'] = new \IPS\Helpers\Form\Number( 'widget_feed_min_reviews', isset( $this->configuration['widget_feed_min_reviews'] ) ? $this->configuration['widget_feed_min_reviews'] : 0, FALSE, array( 'unlimitedLang' => 'any', 'unlimited' => 0 ) );
|
||||
$return['min_reviews'] = new Number( 'widget_feed_min_reviews', $this->configuration['widget_feed_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'] ) )
|
||||
{
|
||||
$ratingOptions = array(
|
||||
0 => 'any'
|
||||
);
|
||||
for( $i=1; $i<=\IPS\Settings::i()->reviews_rating_out_of; $i++ )
|
||||
for($i=1; $i<= Settings::i()->reviews_rating_out_of; $i++ )
|
||||
{
|
||||
$ratingOptions[$i] = $i;
|
||||
}
|
||||
|
||||
$return['rating'] = new \IPS\Helpers\Form\Select( 'widget_feed_min_rating', isset( $this->configuration['widget_feed_min_rating'] ) ? $this->configuration['widget_feed_min_rating'] : 0, FALSE, array(
|
||||
$return['rating'] = new Select( 'widget_feed_min_rating', $this->configuration['widget_feed_min_rating'] ?? 0, FALSE, array(
|
||||
'options' => $ratingOptions
|
||||
) );
|
||||
}
|
||||
|
||||
/* 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 );
|
||||
|
||||
/* Date restrict */
|
||||
$options = array( 'unlimited' => -1 );
|
||||
|
||||
if ( $class::databaseTableCount( TRUE ) > \IPS\UPGRADE_LARGE_TABLE_SIZE )
|
||||
if ( $class::databaseTableCount( TRUE ) > UPGRADE_LARGE_TABLE_SIZE )
|
||||
{
|
||||
$options['unlimitedLang'] = 'search_year';
|
||||
}
|
||||
|
||||
$return['date_restrict'] = new \IPS\Helpers\Form\Number( 'widget_feed_restrict_days', isset( $this->configuration['widget_feed_restrict_days'] ) ? $this->configuration['widget_feed_restrict_days'] : -1, FALSE, $options, NULL, NULL, \IPS\Member::loggedIn()->language()->addToStack('widget_feed_restrict_days_suffix') );
|
||||
$return['date_restrict'] = new Number( 'widget_feed_restrict_days', $this->configuration['widget_feed_restrict_days'] ?? -1, FALSE, $options, NULL, NULL, Member::loggedIn()->language()->addToStack('widget_feed_restrict_days_suffix') );
|
||||
|
||||
/* Sort */
|
||||
$sortOptions = $class::getWidgetSortOptions();
|
||||
|
||||
$dateColumn = $class::$databasePrefix . ( isset( $class::$databaseColumnMap['updated'] ) ? $class::$databaseColumnMap['updated'] : $class::$databaseColumnMap['date'] );
|
||||
$return['sort'] = new \IPS\Helpers\Form\Select( 'widget_feed_sort_on', $this->configuration['widget_feed_sort_on'] ?? $dateColumn, FALSE, array( 'options' => $sortOptions ), NULL, NULL, NULL, 'widget_feed_sort_on' );
|
||||
$dateColumn = $class::$databasePrefix . ( $class::$databaseColumnMap['updated'] ?? $class::$databaseColumnMap['date'] );
|
||||
$return['sort'] = new Select( 'widget_feed_sort_on', $this->configuration['widget_feed_sort_on'] ?? $dateColumn, FALSE, array( 'options' => $sortOptions ), NULL, NULL, NULL, 'widget_feed_sort_on' );
|
||||
|
||||
$return['direction'] = 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['direction'] = new Select( 'widget_feed_sort_dir', $this->configuration['widget_feed_sort_dir'] ?? 'desc', FALSE, array(
|
||||
'options' => array(
|
||||
'desc' => 'descending',
|
||||
'asc' => 'ascending'
|
||||
@@ -222,22 +251,17 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
) );
|
||||
|
||||
/* Tags */
|
||||
if( \in_array( 'IPS\Content\Tags', class_implements( $class ) ) and \IPS\Settings::i()->tags_enabled )
|
||||
if( Settings::i()->tags_enabled AND IPS::classUsesTrait( $class, \IPS\Content\Taggable::class ) )
|
||||
{
|
||||
if ( \IPS\Settings::i()->tags_force_lower )
|
||||
if ( Settings::i()->tags_force_lower )
|
||||
{
|
||||
$options['autocomplete']['forceLower'] = TRUE;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->tags_clean )
|
||||
{
|
||||
$options['autocomplete']['filterProfanity'] = TRUE;
|
||||
}
|
||||
|
||||
$options['autocomplete']['prefix'] = FALSE;
|
||||
$options['autocomplete']['minimized'] = FALSE;
|
||||
|
||||
$return['tags'] = new \IPS\Helpers\Form\Text( 'widget_feed_tags', ( isset( $this->configuration['widget_feed_tags'] ) ? $this->configuration['widget_feed_tags'] : array( 'tags' => NULL ) ), FALSE, $options );
|
||||
$return['tags'] = new Text( 'widget_feed_tags', ( $this->configuration['widget_feed_tags'] ?? array( 'tags' => NULL ) ), FALSE, $options );
|
||||
|
||||
}
|
||||
|
||||
@@ -250,17 +274,18 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
* @param array $values Values from form
|
||||
* @return array
|
||||
*/
|
||||
public function preConfig( $values )
|
||||
public function preConfig( array $values ): array
|
||||
{
|
||||
/* @var Item $class */
|
||||
$class = static::$class;
|
||||
|
||||
if ( isset( $class::$containerNodeClass ) and \is_array( $values[ 'widget_feed_container_' . $class::$title ] ) )
|
||||
|
||||
if ( isset( $values[ 'widget_feed_container_' . $class::$title ] ) and is_array( $values[ 'widget_feed_container_' . $class::$title ] ) )
|
||||
{
|
||||
$values['widget_feed_container'] = array_keys( $values[ 'widget_feed_container_' . $class::$title ] );
|
||||
unset( $values[ 'widget_feed_container_' . $class::$title ] );
|
||||
}
|
||||
|
||||
if ( \is_array( $values['widget_feed_author'] ) )
|
||||
if ( is_array( $values['widget_feed_author'] ) )
|
||||
{
|
||||
$members = array();
|
||||
foreach( $values['widget_feed_author'] as $member )
|
||||
@@ -277,7 +302,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
$values['language_key'] = $this->configuration['language_key'];
|
||||
|
||||
\IPS\Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
Lang::saveCustom( 'core', $this->configuration['language_key'], $values['widget_feed_title'] );
|
||||
unset( $values['widget_feed_title'] );
|
||||
|
||||
return $values;
|
||||
@@ -288,8 +313,10 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function buildWhere()
|
||||
protected function buildWhere(): array
|
||||
{
|
||||
/* @var array $databaseColumnMap */
|
||||
/* @var Item $class */
|
||||
$class = static::$class;
|
||||
$where = array();
|
||||
|
||||
@@ -322,17 +349,17 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$nodeIds[] = $id;
|
||||
}
|
||||
}
|
||||
catch( \Exception $e )
|
||||
catch( Exception $e )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], $nodeIds ) );
|
||||
|
||||
$where[] = array( Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['container'], $nodeIds ) );
|
||||
}
|
||||
|
||||
/* Status */
|
||||
if ( isset( $this->configuration['widget_feed_status_locked'] ) and \in_array( 'IPS\Content\Lockable', class_implements( $class ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_status_locked'] ) and IPS::classUsesTrait( $class, 'IPS\Content\Lockable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_locked'] == 'closed' )
|
||||
{
|
||||
@@ -344,7 +371,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_featured'] ) and \in_array( 'IPS\Content\Featurable', class_implements( $class ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_status_featured'] ) and IPS::classUsesTrait( $class, 'IPS\Content\Featurable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_featured'] == 'notfeatured' )
|
||||
{
|
||||
@@ -361,7 +388,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$where['item'][] = $this->configuration['widget_feed_status_solved'] == 'solved' ? array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['solved_comment_id'] . '>0' ) : array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['solved_comment_id'] . '=0' );
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['widget_feed_status_pinned'] ) and \in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) )
|
||||
if ( isset( $this->configuration['widget_feed_status_pinned'] ) and IPS::classUsesTrait( $class, 'IPS\Content\Pinnable' ) )
|
||||
{
|
||||
if ( $this->configuration['widget_feed_status_pinned'] == 'notpinned' )
|
||||
{
|
||||
@@ -386,9 +413,9 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Author */
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and \is_array( $this->configuration['widget_feed_author'] ) and \count( $this->configuration['widget_feed_author'] ) )
|
||||
if ( isset( $this->configuration['widget_feed_author'] ) and is_array( $this->configuration['widget_feed_author'] ) and count( $this->configuration['widget_feed_author'] ) )
|
||||
{
|
||||
$where[] = array( \IPS\Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'], $this->configuration['widget_feed_author'] ) );
|
||||
$where[] = array( Db::i()->in( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['author'], $this->configuration['widget_feed_author'] ) );
|
||||
}
|
||||
|
||||
/* Min comments/reviews */
|
||||
@@ -412,22 +439,22 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
|
||||
/* Limit to days */
|
||||
if ( $class::databaseTableCount( TRUE ) > \IPS\UPGRADE_LARGE_TABLE_SIZE )
|
||||
if ( $class::databaseTableCount( TRUE ) > UPGRADE_LARGE_TABLE_SIZE )
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_restrict_days'] ) and $this->configuration['widget_feed_restrict_days'] > 0 and $this->configuration['widget_feed_restrict_days'] <= 365 )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', DateTime::create()->sub( new DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
else
|
||||
{
|
||||
$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() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( isset( $this->configuration['widget_feed_restrict_days'] ) and $this->configuration['widget_feed_restrict_days'] > 0 )
|
||||
{
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['date'] . '>?', DateTime::create()->sub( new DateInterval( 'P' . $this->configuration['widget_feed_restrict_days'] . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -439,12 +466,14 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
/* @var array $databaseColumnMap */
|
||||
/* @var Item $class */
|
||||
$class = static::$class;
|
||||
$where = $this->buildWhere();
|
||||
|
||||
if ( \IPS\Settings::i()->tags_enabled and isset( $this->configuration['widget_feed_tags'] ) and \is_array( $this->configuration['widget_feed_tags'] ) and \count( $this->configuration['widget_feed_tags'] ) )
|
||||
if ( Settings::i()->tags_enabled and isset( $this->configuration['widget_feed_tags'] ) and is_array( $this->configuration['widget_feed_tags'] ) and count( $this->configuration['widget_feed_tags'] ) )
|
||||
{
|
||||
$tagWhere = array();
|
||||
$binds = array( $class::$application, $class::$module );
|
||||
@@ -454,22 +483,22 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$binds[] = $tag;
|
||||
}
|
||||
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId . ' IN (?)', \IPS\Db::i()->select( 'tag_meta_id', 'core_tags', array( array_merge( array( 'tag_meta_app=? AND tag_meta_area=? AND (' . implode( ' OR ', $tagWhere ) . ')' ), $binds ) ) ) );
|
||||
$where[] = array( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnId . ' IN (?)', Db::i()->select( 'tag_meta_id', 'core_tags', array( array_merge( array( 'tag_meta_app=? AND tag_meta_area=? AND (' . implode( ' OR ', $tagWhere ) . ')' ), $binds ) ) ) );
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
@@ -481,12 +510,19 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( ( $this->configuration['widget_feed_sort_on'] == '_rand' ) ? $this->configuration['widget_feed_sort_on'] : ( $class::$databaseTable . '.' . $class::$databasePrefix . $this->configuration['widget_feed_sort_on'] . ' ' . $this->configuration['widget_feed_sort_dir'] ) ) : ( $class::$databaseTable . '.' . $class::$databasePrefix . $class::$databaseColumnMap['updated'] . ' DESC' ), /* Order */
|
||||
|
||||
( isset( $this->configuration['widget_feed_show'] ) AND $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, /* Limit */
|
||||
( $skipPerms ) ? NULL : 'read', /* Permission key to check against */
|
||||
'read', /* Permission key to check against */
|
||||
$hidden, /* Whether or not to include hidden items */
|
||||
$class::SELECT_IDS_FIRST
|
||||
$class::SELECT_IDS_FIRST,
|
||||
NULL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
FALSE,
|
||||
NULL,
|
||||
$skipPerms
|
||||
) );
|
||||
|
||||
if ( \count( $items ) )
|
||||
if ( count( $items ) )
|
||||
{
|
||||
$memberIds = array();
|
||||
$members = array();
|
||||
@@ -503,22 +539,22 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
$memberIds = array_unique( $memberIds );
|
||||
}
|
||||
|
||||
if ( \count( $memberIds ) )
|
||||
if ( count( $memberIds ) )
|
||||
{
|
||||
$members = \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ) )->setKeyField('member_id');
|
||||
$members = Db::i()->select( '*', 'core_members', array( Db::i()->in( 'member_id', $memberIds ) ) )->setKeyField('member_id');
|
||||
|
||||
if ( \count( $members ) )
|
||||
if ( count( $members ) )
|
||||
{
|
||||
foreach( $members as $member )
|
||||
{
|
||||
\IPS\Member::constructFromData( $member, FALSE );
|
||||
Member::constructFromData( $member, FALSE );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $this->configuration['language_key'] ) )
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) );
|
||||
$title = Member::loggedIn()->language()->addToStack( $this->configuration['language_key'], FALSE, array( 'escape' => TRUE ) );
|
||||
}
|
||||
elseif ( isset( $this->configuration['widget_feed_title'] ) )
|
||||
{
|
||||
@@ -526,7 +562,7 @@ abstract class _Widget extends \IPS\Widget\PermissionCache
|
||||
}
|
||||
else
|
||||
{
|
||||
$title = \IPS\Member::loggedIn()->language()->addToStack( $class::$title . '_pl' );
|
||||
$title = Member::loggedIn()->language()->addToStack( $class::$title . '_pl' );
|
||||
}
|
||||
|
||||
return $this->output( $items, $title );
|
||||
|
||||
Reference in new issue
Block a user