Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+12 -13
View File
@@ -12,48 +12,47 @@
namespace IPS\blog\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Content\WidgetComment;
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;
}
/**
* blogCommentFeed Widget
*/
class _blogCommentFeed extends \IPS\Content\WidgetComment
class blogCommentFeed extends WidgetComment
{
/**
* @brief Widget Key
*/
public $key = 'blogCommentFeed';
public string $key = 'blogCommentFeed';
/**
* @brief App
*/
public $app = 'blog';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'blog';
/**
* Class
*/
protected static $class = 'IPS\blog\Entry\Comment';
protected static string $class = 'IPS\blog\Entry\Comment';
/**
* @brief Moderator permission to generate caches on [optional]
*/
protected $moderatorPermissions = array( 'can_view_hidden_content', 'can_view_hidden_blog_entry_comment' );
protected array $moderatorPermissions = array( 'can_view_hidden_content', 'can_view_hidden_blog_entry_comment' );
/**
* Get where clause
*
* @return array
*/
protected function buildWhere()
protected function buildWhere(): array
{
$where = parent::buildWhere();
$where['item'][] = array( 'entry_status!=?', 'draft' );
+13 -13
View File
@@ -12,43 +12,43 @@
namespace IPS\blog\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Widget\StaticCache;
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;
}
/**
* blogStatistics Widget
*/
class _blogStatistics extends \IPS\Widget\StaticCache
class blogStatistics extends StaticCache
{
/**
* @brief Widget Key
*/
public $key = 'blogStatistics';
public string $key = 'blogStatistics';
/**
* @brief App
*/
public $app = 'blog';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'blog';
/**
* Render a widget
*
* @return string
*/
public function render()
public function render(): string
{
$stats = array();
$stats['total_blogs'] = \IPS\Db::i()->select( "COUNT(*)", 'blog_blogs' )->first();
$stats['total_entries'] = \IPS\Db::i()->select( "COUNT(*)", 'blog_entries', array( 'entry_status=? AND entry_hidden=?', 'published', 1 ) )->first();
$stats['total_blogs'] = Db::i()->select( "COUNT(*)", 'blog_blogs' )->first();
$stats['total_entries'] = Db::i()->select( "COUNT(*)", 'blog_entries', array( 'entry_status=? AND entry_hidden=?', 'published', 1 ) )->first();
return $this->output( $stats );
}
+47 -35
View File
@@ -12,40 +12,52 @@
namespace IPS\blog\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Blog;
use IPS\Db;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Text;
use IPS\Member;
use IPS\Output;
use IPS\Theme;
use IPS\Widget\Customizable;
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;
}
/**
* blogs Widget
*/
class _blogs extends \IPS\Widget\PermissionCache
class blogs extends PermissionCache implements Customizable
{
/**
* @brief Widget Key
*/
public $key = 'blogs';
public string $key = 'blogs';
/**
* @brief App
*/
public $app = 'blog';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'blog';
/**
* Initialize 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( 'blog.css', 'blog' ) );
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'blog.css', 'blog' ) );
parent::init();
}
@@ -53,34 +65,34 @@ class _blogs extends \IPS\Widget\PermissionCache
/**
* 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 );
/* Block title */
$form->add( new \IPS\Helpers\Form\Text( 'widget_feed_title', isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( 'blogs' ) ) );
$form->add( new Text( 'widget_feed_title', $this->configuration['widget_feed_title'] ?? Member::loggedIn()->language()->addToStack('blogs')) );
/* 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 ) { }
$form->add( new \IPS\Helpers\Form\Member( 'widget_feed_author', $author, FALSE, array( 'multiple' => null ) ) );
catch( OutOfRangeException ) { }
$form->add( new Form\Member( 'widget_feed_author', $author, FALSE, array( 'multiple' => null ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'widget_blog_last_date', isset( $this->configuration['widget_blog_last_date'] ) ? $this->configuration['widget_blog_last_date'] : '0', FALSE, array(
$form->add( new Select( 'widget_blog_last_date', $this->configuration['widget_blog_last_date'] ?? '0', FALSE, array(
'options' => array(
0 => 'show_all',
1 => 'today',
@@ -98,15 +110,15 @@ class _blogs extends \IPS\Widget\PermissionCache
/* Number to show */
$form->add( new \IPS\Helpers\Form\Number( 'widget_feed_show', isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5, TRUE ) );
$form->add( new Number( 'widget_feed_show', $this->configuration['widget_feed_show'] ?? 5, TRUE ) );
$form->add( new \IPS\Helpers\Form\Select( 'widget_feed_sort_on', isset( $this->configuration['widget_feed_sort_on'] ) ? $this->configuration['widget_feed_sort_on'] : 'blog_last_edate', FALSE, array( 'options' => array(
$form->add( new Select( 'widget_feed_sort_on', $this->configuration['widget_feed_sort_on'] ?? 'blog_last_edate', FALSE, array( 'options' => array(
'blog_last_edate' => 'widget__blog_edate',
'blog_count_entries' => 'widget__blog_count_entries',
'blog_count_comments' => 'widget__blog_count_comments'
) ), NULL, NULL, NULL, 'widget_feed_sort_on' ) );
$form->add( 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(
$form->add( new Select( 'widget_feed_sort_dir', $this->configuration['widget_feed_sort_dir'] ?? 'desc', FALSE, array(
'options' => array(
'desc' => 'descending',
'asc' => 'ascending'
@@ -118,12 +130,12 @@ class _blogs extends \IPS\Widget\PermissionCache
/**
* Ran before saving widget configuration
*
* @param array $values Values from form
* @param array $values Values from form
* @return array
*/
public function preConfig( $values )
public function preConfig( array $values ): array
{
if ( \is_array( $values['widget_feed_author'] ) )
if ( is_array( $values['widget_feed_author'] ) )
{
$members = array();
foreach( $values['widget_feed_author'] as $member )
@@ -142,30 +154,30 @@ class _blogs extends \IPS\Widget\PermissionCache
*
* @return string
*/
public function render()
public function render(): string
{
$where = array( array( 'blog_disabled=0 AND blog_social_group IS NULL AND blog_club_id IS NULL' ) );
$sortBy = ( isset( $this->configuration['widget_feed_sort_on'] ) and isset( $this->configuration['widget_feed_sort_dir'] ) ) ? ( $this->configuration['widget_feed_sort_on'] . ' ' . $this->configuration['widget_feed_sort_dir'] ) : NULL;
$limit = isset( $this->configuration['widget_feed_show'] ) ? $this->configuration['widget_feed_show'] : 5;
$limit = $this->configuration['widget_feed_show'] ?? 5;
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( 'blog_member_id', $this->configuration['widget_feed_author'] ) );
$where[] = array( Db::i()->in( 'blog_member_id', $this->configuration['widget_feed_author'] ) );
}
/* Get results */
$blogs = array();
foreach( \IPS\Db::i()->select( '*', 'blog_blogs', $where, $sortBy, array( 0, $limit ) ) as $row )
foreach( Db::i()->select( '*', 'blog_blogs', $where, $sortBy, array( 0, $limit ) ) as $row )
{
$blog = \IPS\blog\Blog::constructFromData( $row );
$blog = Blog::constructFromData( $row );
$blog->coverPhoto()->editable = false;
$blogs[] = $blog;
}
if ( \count( $blogs ) )
if ( count( $blogs ) )
{
return $this->output( $blogs, isset( $this->configuration['widget_feed_title'] ) ? $this->configuration['widget_feed_title'] : \IPS\Member::loggedIn()->language()->addToStack( 'blogs' ) );
return $this->output( $blogs, $this->configuration['widget_feed_title'] ?? Member::loggedIn()->language()->addToStack('blogs'));
}
else
{
+11 -12
View File
@@ -12,43 +12,42 @@
namespace IPS\blog\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Content\Widget;
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;
}
/**
* Blog Entry Feed Widget
*/
class _entryFeed extends \IPS\Content\Widget
class entryFeed extends Widget
{
/**
* @brief Widget Key
*/
public $key = 'entryFeed';
public string $key = 'entryFeed';
/**
* @brief App
*/
public $app = 'blog';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'blog';
/**
* Class
*/
protected static $class = 'IPS\blog\Entry';
protected static string $class = 'IPS\blog\Entry';
/**
* Get where clause
*
* @return array
*/
protected function buildWhere()
protected function buildWhere(): array
{
$where = parent::buildWhere();
$where[] = array( 'entry_status!=?', 'draft' );
+22 -17
View File
@@ -12,43 +12,48 @@
namespace IPS\blog\widgets;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Entry;
use IPS\Content\Filter;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Number;
use IPS\Widget\Customizable;
use IPS\Widget\PermissionCache;
use function count;
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;
}
/**
* recentEntries Widget
*/
class _recentEntries extends \IPS\Widget\PermissionCache
class recentEntries extends PermissionCache implements Customizable
{
/**
* @brief Widget Key
*/
public $key = 'recentEntries';
public string $key = 'recentEntries';
/**
* @brief App
*/
public $app = 'blog';
/**
* @brief Plugin
*/
public $plugin = '';
public string $app = 'blog';
/**
* 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 );
$form->add( new \IPS\Helpers\Form\Number( 'number_to_show', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, TRUE ) );
$form->add( new Number( 'number_to_show', $this->configuration['number_to_show'] ?? 5, TRUE ) );
return $form;
}
@@ -57,10 +62,10 @@ class _recentEntries extends \IPS\Widget\PermissionCache
*
* @return string
*/
public function render()
public function render(): string
{
$entries = \IPS\blog\Entry::getItemsWithPermission( array( array( 'entry_status!=?', 'draft' ) ), NULL, isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY );
if ( \count( $entries ) )
$entries = Entry::getItemsWithPermission( array( array( 'entry_status!=?', 'draft' ) ), NULL, $this->configuration['number_to_show'] ?? 5, 'read', Filter::FILTER_PUBLIC_ONLY );
if ( count( $entries ) )
{
return $this->output( $entries );
}