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,45 +12,50 @@
|
||||
namespace IPS\gallery\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\gallery\Album\Item;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\PermissionCache;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery statistics widget
|
||||
*/
|
||||
class _galleryStats extends \IPS\Widget\PermissionCache
|
||||
class galleryStats extends PermissionCache
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'galleryStats';
|
||||
public string $key = 'galleryStats';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
public string $app = 'gallery';
|
||||
|
||||
/**
|
||||
* @brief Cache Expiration - 24h
|
||||
*/
|
||||
public $cacheExpiration = 86400;
|
||||
public int $cacheExpiration = 86400;
|
||||
|
||||
/**
|
||||
* Initialize 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', 'gallery', 'front' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'gallery', 'front' ) );
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@@ -60,26 +65,26 @@ class _galleryStats extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$stats = [];
|
||||
|
||||
$approxRows = \IPS\gallery\Image::databaseTableCount( TRUE );
|
||||
$approxRows = Image::databaseTableCount( TRUE );
|
||||
|
||||
if ( $approxRows > 1000000 )
|
||||
{
|
||||
$stats['totalImages'] = $approxRows;
|
||||
$stats['totalComments'] = (int) \IPS\Db::i()->query( "SHOW TABLE STATUS LIKE '" . \IPS\Db::i()->prefix . "gallery_comments';" )->fetch_assoc()['Rows'];
|
||||
$stats['totalComments'] = (int) Db::i()->query( "SHOW TABLE STATUS LIKE '" . Db::i()->prefix . "gallery_comments';" )->fetch_assoc()['Rows'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$stats = \IPS\Db::i()->select( 'COUNT(*) AS totalImages, SUM(image_comments) AS totalComments', 'gallery_images', [ "image_approved=?", 1 ] )->first();
|
||||
$stats = Db::i()->select( 'COUNT(*) AS totalImages, SUM(image_comments) AS totalComments', 'gallery_images', [ "image_approved=?", 1 ] )->first();
|
||||
}
|
||||
|
||||
$stats['totalAlbums'] = \IPS\gallery\Album\Item::databaseTableCount( TRUE );
|
||||
$stats['totalAlbums'] = Item::databaseTableCount( TRUE );
|
||||
|
||||
$latestImage = NULL;
|
||||
foreach ( \IPS\gallery\Image::getItemsWithPermission( [], NULL, 1, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY ) as $latestImage )
|
||||
foreach ( Image::getItemsWithPermission( [], NULL, 1, 'read', Filter::FILTER_PUBLIC_ONLY ) as $latestImage )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user