Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Dynamic Chart Helper
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @since 27 Aug 2013
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -219,7 +219,10 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
$this->end = new \IPS\DateTime( \IPS\Request::i()->end[ $this->identifier ], new \DateTimeZone( \IPS\Member::loggedIn()->timezone ) );
|
||||
}
|
||||
|
||||
|
||||
/* The end date should include items to the end of the day */
|
||||
$this->end->setTime( 23, 59, 59 );
|
||||
|
||||
$url = $url->setQueryString( 'end', array( $this->identifier => $this->end->getTimestamp() ) );
|
||||
}
|
||||
catch ( \Exception $e ) {}
|
||||
@@ -318,39 +321,41 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$data[ $date->format( 'j n Y' ) ] = array();
|
||||
$data[ $date->format( 'Y-n-j' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'j n Y' ) ][ $key ] = 0;
|
||||
$data[ $date->format( 'Y-n-j' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1D' ) );
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$data[ $date->format( 'W Y' ) ] = array();
|
||||
/* o is the ISO year number, which we need when years roll over.
|
||||
@see http://php.net/manual/en/function.date.php#106974 */
|
||||
$data[ $date->format( 'o-W' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'W Y' ) ][ $key ] = 0;
|
||||
$data[ $date->format( 'o-W' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P7D' ) );
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$data[ $date->format( 'n Y' ) ] = array();
|
||||
$data[ $date->format( 'Y-n' ) ] = array();
|
||||
|
||||
if( $this->groupBy )
|
||||
{
|
||||
foreach( $this->groupByKeys as $key )
|
||||
{
|
||||
$data[ $date->format( 'n Y' ) ][ $key ] = 0;
|
||||
$data[ $date->format( 'Y-n' ) ][ $key ] = 0;
|
||||
}
|
||||
}
|
||||
$date->add( new \DateInterval( 'P1M' ) );
|
||||
@@ -365,6 +370,7 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
/* Work out where clause */
|
||||
$where = $this->where;
|
||||
$where[] = array( "{$this->dateField}>?", 0 );
|
||||
if ( $this->start )
|
||||
{
|
||||
$where[] = array( "{$this->dateField}>?", $this->start->getTimestamp() );
|
||||
@@ -378,15 +384,15 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$timescale = '%e %c %Y';
|
||||
$timescale = '%Y-%c-%e';
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$timescale = '%u %Y';
|
||||
$timescale = '%Y-%u';
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$timescale = '%c %Y';
|
||||
$timescale = '%Y-%c';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -410,7 +416,7 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
"{$key}" . ( $this->groupBy ? ", {$this->groupBy}" : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
"{$this->dateField} ASC",
|
||||
NULL,
|
||||
NULL,
|
||||
$this->groupBy
|
||||
)->setKeyField( $this->groupBy )->setValueField( $key );
|
||||
@@ -435,7 +441,7 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
"DATE_FORMAT( FROM_UNIXTIME( IFNULL( {$this->dateField}, 0 ) ), '{$timescale}' ) AS time, " . implode( ', ', array_unique( $this->series ) ) . ( $this->groupBy ? ", " . $this->groupBy : '' ),
|
||||
$this->table,
|
||||
$where,
|
||||
"{$this->dateField} ASC",
|
||||
'time ASC',
|
||||
NULL,
|
||||
$this->groupBy ? array( 'time', $this->groupBy ) : 'time'
|
||||
);
|
||||
@@ -474,6 +480,8 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
|
||||
$data[ $row['time'] ] = $result;
|
||||
}
|
||||
|
||||
ksort( $data, SORT_NATURAL );
|
||||
|
||||
/* Add to graph */
|
||||
$min = NULL;
|
||||
@@ -496,21 +504,21 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
}
|
||||
|
||||
$datetime->setTime( 0, 0, 0 );
|
||||
$exploded = explode( ' ', $time );
|
||||
$exploded = explode( '-', $time );
|
||||
switch ( $this->timescale )
|
||||
{
|
||||
case 'daily':
|
||||
$datetime->setDate( $exploded[2], $exploded[1], $exploded[0] );
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], $exploded[2] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'weekly':
|
||||
$datetime->setISODate( $exploded[1], $exploded[0] );
|
||||
$datetime->setISODate( (float) $exploded[0], $exploded[1] );
|
||||
//$datetime = $datetime->localeDate();
|
||||
break;
|
||||
|
||||
case 'monthly':
|
||||
$datetime->setDate( $exploded[1], $exploded[0], 1 );
|
||||
$datetime->setDate( (float) $exploded[0], $exploded[1], 1 );
|
||||
//$datetime = $datetime->format( 'F Y' );
|
||||
break;
|
||||
}
|
||||
@@ -579,6 +587,10 @@ class _Dynamic extends \IPS\Helpers\Chart
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
catch ( \Throwable $e )
|
||||
{
|
||||
\IPS\IPS::exceptionHandler( $e );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user