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,40 +12,46 @@
|
||||
namespace IPS\downloads\widgets;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\downloads\File;
|
||||
use IPS\Output;
|
||||
use IPS\Theme;
|
||||
use IPS\Widget\Customizable;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* downloadStats Widget
|
||||
*/
|
||||
class _downloadStats extends \IPS\Widget\PermissionCache
|
||||
class downloadStats extends PermissionCache implements Customizable
|
||||
{
|
||||
/**
|
||||
* @brief Widget Key
|
||||
*/
|
||||
public $key = 'downloadStats';
|
||||
public string $key = 'downloadStats';
|
||||
|
||||
/**
|
||||
* @brief App
|
||||
*/
|
||||
public $app = 'downloads';
|
||||
public string $app = 'downloads';
|
||||
|
||||
/**
|
||||
* @brief Plugin
|
||||
*/
|
||||
public $plugin = '';
|
||||
|
||||
|
||||
/**
|
||||
* Init the widget
|
||||
*
|
||||
* @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', 'downloads', 'front' ) );
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'widgets.css', 'downloads', 'front' ) );
|
||||
|
||||
parent::init();
|
||||
}
|
||||
@@ -55,13 +61,13 @@ class _downloadStats extends \IPS\Widget\PermissionCache
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
public function render(): string
|
||||
{
|
||||
$stats = \IPS\Db::i()->select( 'COUNT(*) AS totalFiles, SUM(file_comments) AS totalComments, SUM(file_reviews) AS totalReviews', 'downloads_files', array( "file_open=?", 1 ) )->first();
|
||||
$stats['totalAuthors'] = \IPS\Db::i()->select( 'COUNT(DISTINCT file_submitter)', 'downloads_files' )->first();
|
||||
$stats = Db::i()->select( 'COUNT(*) AS totalFiles, SUM(file_comments) AS totalComments, SUM(file_reviews) AS totalReviews', 'downloads_files', array( "file_open=?", 1 ) )->first();
|
||||
$stats['totalAuthors'] = Db::i()->select( 'COUNT(DISTINCT file_submitter)', 'downloads_files' )->first();
|
||||
|
||||
$latestFile = NULL;
|
||||
foreach ( \IPS\downloads\File::getItemsWithPermission( array(), NULL, 1 ) as $latestFile )
|
||||
foreach ( File::getItemsWithPermission( array(), NULL, 1 ) as $latestFile )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user