Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+35 -22
View File
@@ -11,7 +11,7 @@
namespace IPS\Helpers\Chart;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -46,7 +46,7 @@ class _Callback extends \IPS\Helpers\Chart\Dynamic
*/
public function __construct( \IPS\Http\Url $url, $callback=NULL, $title='', $options=array(), $defaultType='AreaChart', $defaultTimescale='monthly', $defaultTimes=array( 'start' => 0, 'end' => 0 ), $identifier='', $minimumDate=NULL )
{
$this->identifier = \substr( md5( (string) $url ), 0, 6 ) . $identifier;
$this->identifier = \substr( md5( (string) $url ), 0, 6 ) . $identifier . ( \IPS\Request::i()->chartId ?: '_default' );
$this->callback = $callback;
parent::__construct( $url, $title, $options, $defaultType, $defaultTimescale, $defaultTimes, $identifier, $minimumDate );
@@ -71,7 +71,7 @@ class _Callback extends \IPS\Helpers\Chart\Dynamic
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $name );
$filterKey = $name;
if ( !$filterable or !isset( \IPS\Request::i()->filters[ $this->identifier ] ) or in_array( $filterKey, \IPS\Request::i()->filters[ $this->identifier ] ) )
if ( !$filterable or !isset( \IPS\Request::i()->filters[ $this->identifier ] ) or \in_array( $filterKey, \IPS\Request::i()->filters[ $this->identifier ] ) )
{
if ( $this->type !== 'PieChart' and $this->type !== 'GeoChart' )
{
@@ -96,40 +96,39 @@ class _Callback extends \IPS\Helpers\Chart\Dynamic
$this->availableFilters[ $filterKey ] = $name;
}
}
/**
* Get the chart output
* Compile Data for Output
*
* @return string
* @param array $data The data
* @return void
*/
public function getOutput()
public function compileForOutput(): void
{
/* Init data */
$data = $this->initData();
/* Get rows */
$callbackFunction = $this->callback;
$rows = $callbackFunction( $this );
/* Pie Chart */
if ( $this->type === 'PieChart' or $this->type === 'GeoChart' )
{
$rows = call_user_func( $this->callback, $this );
{
foreach ( $rows as $k => $v )
{
if( count( $this->availableFilters ) and !in_array( $k, $this->currentFilters ) )
if( \count( $this->availableFilters ) and !\in_array( $k, $this->currentFilters ) )
{
continue;
}
$this->addRow( array( 'key' => $this->availableFilters[ $k ], 'value' => $v ) );
}
$output = $this->render( $this->type, $this->options, $this->format );
}
/* Graph */
else
{
$rows = call_user_func( $this->callback, $this );
foreach ( $rows as $row )
{
$result = array();
@@ -205,14 +204,14 @@ class _Callback extends \IPS\Helpers\Chart\Dynamic
}
else
{
$this->addRow( array_merge( array( $datetime ), array_fill( 0, count( $this->series ), 0 ) ) );
$this->addRow( array_merge( array( $datetime ), array_fill( 0, \count( $this->series ), 0 ) ) );
}
}
else
{
if( count($d) < count($this->series) )
if( \count($d) < \count($this->series) )
{
$this->addRow( array_merge( array( $datetime ), $d, array_fill( 0, count($this->series) - count($d), 0 ) ) );
$this->addRow( array_merge( array( $datetime ), $d, array_fill( 0, \count($this->series) - \count($d), 0 ) ) );
}
else
{
@@ -221,14 +220,28 @@ class _Callback extends \IPS\Helpers\Chart\Dynamic
}
}
if ( count( $data ) === 1 )
if ( \count( $data ) === 1 )
{
$this->options['domainAxis']['type'] = 'category';
}
$output = $this->render( $this->type, $this->options, $this->format );
}
}
return $output;
/**
* Get the chart output
*
* @return string
*/
public function getOutput()
{
$this->compileForOutput();
if ( isset( \IPS\Request::i()->download ) )
{
return $this->download();
}
else
{
return $this->render( $this->type, $this->options, $this->format );
}
}
}