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,10 +2,10 @@
|
||||
/**
|
||||
* @brief topDownloads Widget
|
||||
* @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
|
||||
* @subpackage downloads
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Downloads
|
||||
* @since 09 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -45,6 +45,18 @@ class _topDownloads extends \IPS\Widget\PermissionCache
|
||||
*/
|
||||
public $cacheExpiration = 172800;
|
||||
|
||||
/**
|
||||
* Init the widget
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'widgets.css', 'downloads', 'front' ) );
|
||||
|
||||
parent::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify widget configuration
|
||||
*
|
||||
@@ -89,19 +101,31 @@ class _topDownloads extends \IPS\Widget\PermissionCache
|
||||
$where[] = array( 'dtime>?', \IPS\DateTime::create()->sub( new \DateInterval( $interval ) )->getTimestamp() );
|
||||
}
|
||||
|
||||
|
||||
$$time = new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select(
|
||||
'*, COUNT(*) AS downloads',
|
||||
'downloads_files',
|
||||
$where,
|
||||
'downloads DESC',
|
||||
isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5,
|
||||
'file_id'
|
||||
)
|
||||
->join( 'downloads_downloads', 'dfid=file_id' ),
|
||||
'IPS\downloads\File'
|
||||
);
|
||||
$ids = array();
|
||||
$cases = array();
|
||||
|
||||
foreach( \IPS\Db::i()->select( 'dfid, COUNT(*) AS downloads', 'downloads_downloads', $where, 'downloads DESC', isset( $this->configuration['number_to_show'] ) ? $this->configuration['number_to_show'] : 5, array( 'dfid' ) )->join( 'downloads_files', 'dfid=file_id' ) as $download )
|
||||
{
|
||||
$ids[] = $download['dfid'];
|
||||
$cases[] = "WHEN file_id={$download['dfid']} THEN {$download['downloads']}";
|
||||
}
|
||||
|
||||
if( count( $ids ) )
|
||||
{
|
||||
$$time = new \IPS\Patterns\ActiveRecordIterator(
|
||||
\IPS\Db::i()->select(
|
||||
'*, CASE ' . implode( ' ', $cases ) . ' END AS file_downloads',
|
||||
'downloads_files',
|
||||
'file_id IN(' . implode( ',', $ids ) . ')',
|
||||
'file_downloads DESC'
|
||||
),
|
||||
'IPS\downloads\File'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$$time = array();
|
||||
}
|
||||
}
|
||||
|
||||
return $this->output( $week, $month, $year, $all );
|
||||
|
||||
Reference in new issue
Block a user