Files
2025-12-19 19:04:57 -08:00

91 lines
3.2 KiB
Plaintext

<?php
/**
* @brief Overview statistics extension: {class}
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
{subpackage}
* @since {date}
*/
namespace IPS\{app}\extensions\core\OverviewStatistics;
use IPS\Extensions\OverviewStatisticsAbstract;
use function defined;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief Overview statistics extension: {class}
*/
class {class} extends OverviewStatisticsAbstract
{
/**
* @brief Which statistics page (activity or user)
*/
public string $page = '{statisticsPage}';
/**
* Return the sub-block keys
*
* @note This is designed to allow one class to support multiple blocks, for instance using the ContentRouter to generate blocks.
* @return array
*/
public function getBlocks(): array
{
return array( 'subblockKey' );
}
/**
* Return block details (title and description)
*
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
* @return array
*/
public function getBlockDetails( ?string $subBlock = NULL ): array
{
/* Description can be null and will not be shown if so */
return array( 'app' => '{app}', 'title' => '...', 'description' => null, 'refresh' => 60 );
}
/**
* Return the block HTML to show
*
* @param array|string|null $dateRange String for a fixed time period in days, NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
* @return string
*/
public function getBlock( array|string|null $dateRange = NULL, ?string $subBlock = NULL ): string
{
/* @todo replace this with appropriate logic for this block. It is recommended to use the numbers from the getBlockNumbers() method for consistency */
$numbers = $this->getBlockNumbers( $dateRange, $subBlock );
if ( isset( $numbers['statsreports_current_count'] ) )
{
return Theme::i()->getTemplate( 'stats', 'core', 'admin' )->overviewComparisonCount( $numbers['statsreports_current_count'], $numbers['statsreports_previous_count'] );
}
return '';
}
/**
* Return the numbers for this block/subblock. These numbers are added to CSV downloads
*
* @param array|string|null $dateRange String for a fixed time period in days, NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
* @return ((null|number)[])|((number|null)[][]) returns an associative array mapping columns to a number or an array of numbers. Null can be used to indicate a missing or indeterminate value
*/
public function getBlockNumbers( array|string|null $dateRange = NULL, ?string $subBlock = NULL ): array
{
/* Replace with relevant columns */
return array(
"statsreports_current_count" => NULL,
"statsreports_previous_count" => NULL,
);
}
}