Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief Categories
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 27 Sep 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\downloads;
@@ -1,13 +1,12 @@
<?php
/**
* @brief fields
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 03 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\downloads;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 09 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\downloads;
@@ -32,25 +31,19 @@ class _settings extends \IPS\Dispatcher\Controller
protected function manage()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
$form = $this->getForm();
if ( $values = $form->values( TRUE ) )
{
/* We can't store '' for idm_nexus_display as it will fall back to the default */
if ( ! $values['idm_nexus_display'] )
{
$values['idm_nexus_display'] = 'none';
}
$form->saveAsSettings( $values );
$this->saveSettingsForm( $form, $values );
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
\IPS\Session::i()->log( 'acplogs__downloads_settings' );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
\IPS\Output::i()->output = $form;
}
@@ -64,13 +57,40 @@ class _settings extends \IPS\Dispatcher\Controller
protected function getForm()
{
$form = new \IPS\Helpers\Form;
$form->addTab('basic_settings');
$form->addTab( 'idm_landing_page' );
$form->addHeader( 'featured_downloads' );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_featured', \IPS\Settings::i()->idm_show_featured, FALSE, array( 'togglesOn' => array( 'idm_featured_count' ) ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'idm_featured_count', \IPS\Settings::i()->idm_featured_count, FALSE, array(), NULL, NULL, NULL, 'idm_featured_count' ) );
$form->addHeader('browse_whats_new');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_newest', \IPS\Settings::i()->idm_show_newest, FALSE, array('togglesOn' => array( 'idm_newest_categories') ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_newest_categories', ( \IPS\Settings::i()->idm_newest_categories AND \IPS\Settings::i()->idm_newest_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_newest_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_newest_categories') );
$form->addHeader('browse_highest_rated');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_highest_rated', \IPS\Settings::i()->idm_show_highest_rated, FALSE, array( 'togglesOn' => array( 'idm_highest_rated_categories' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_highest_rated_categories', ( \IPS\Settings::i()->idm_highest_rated_categories AND \IPS\Settings::i()->idm_highest_rated_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_highest_rated_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_highest_rated_categories') );
$form->addHeader('browse_most_downloaded');
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_show_most_downloaded', \IPS\Settings::i()->idm_show_most_downloaded, FALSE, array( 'togglesOn' => array( 'idm_show_most_downloaded_categories' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'idm_show_most_downloaded_categories', ( \IPS\Settings::i()->idm_show_most_downloaded_categories AND \IPS\Settings::i()->idm_show_most_downloaded_categories != 0 ) ? explode( ',', \IPS\Settings::i()->idm_show_most_downloaded_categories ) : 0, FALSE, array(
'class' => 'IPS\downloads\Category',
'zeroVal' => 'any',
'multiple' => TRUE ), NULL, NULL, NULL, 'idm_show_most_downloaded_categories') );
$form->addTab( 'basic_settings' );
$form->add( new \IPS\Helpers\Form\Upload( 'idm_watermarkpath', \IPS\Settings::i()->idm_watermarkpath ? \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'idm_link_blacklist', explode( ',', \IPS\Settings::i()->idm_link_blacklist ), FALSE, array( 'placeholder' => 'example.com' ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_antileech', \IPS\Settings::i()->idm_antileech ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'idm_rss', \IPS\Settings::i()->idm_rss ) );
if ( \IPS\Application::appIsEnabled( 'nexus' ) )
{
$form->addTab( 'paid_file_settings' );
@@ -84,7 +104,24 @@ class _settings extends \IPS\Dispatcher\Controller
return $form;
}
/**
* Save the settings form
*
* @param \IPS\Helpers\Form $form The Form Object
* @param array $values Values
*/
protected function saveSettingsForm( \IPS\Helpers\Form $form, array $values )
{
/* We can't store '' for idm_nexus_display as it will fall back to the default */
if ( ! $values['idm_nexus_display'] )
{
$values['idm_nexus_display'] = 'none';
}
$form->saveAsSettings( $values );
}
/**
* Rebuild Watermarks
*
@@ -94,7 +131,7 @@ class _settings extends \IPS\Dispatcher\Controller
{
$perGo = 1;
$watermark = \IPS\Settings::i()->idm_watermarkpath ? \IPS\Image::create( \IPS\File::get( 'core_Theme', \IPS\Settings::i()->idm_watermarkpath )->contents() ) : NULL;
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=settings&do=rebuildWatermarks' ), function( $doneSoFar ) use( $watermark, $perGo )
{
$doneSoFar = intval( $doneSoFar );
@@ -104,13 +141,13 @@ class _settings extends \IPS\Dispatcher\Controller
{
$where[] = array( 'record_no_watermark<>?', '' );
}
$select = \IPS\Db::i()->select( '*', 'downloads_files_records', $where, 'record_id', array( $doneSoFar, $perGo ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
if ( !$select->count() )
{
return NULL;
}
foreach ( $select as $row )
{
try
@@ -118,13 +155,13 @@ class _settings extends \IPS\Dispatcher\Controller
if ( $row['record_no_watermark'] )
{
$original = \IPS\File::get( 'downloads_Screenshots', $row['record_no_watermark'] );
try
{
\IPS\File::get( 'downloads_Screenshots', $row['record_location'] )->delete();
}
catch ( \Exception $e ) { }
if ( !$watermark )
{
\IPS\Db::i()->update( 'downloads_files_records', array(
@@ -132,7 +169,7 @@ class _settings extends \IPS\Dispatcher\Controller
'record_thumb' => (string) $original->thumbnail( 'downloads_Screenshots' ),
'record_no_watermark' => NULL
), array( 'record_id=?', $row['record_id'] ) );
continue;
}
}
@@ -140,12 +177,12 @@ class _settings extends \IPS\Dispatcher\Controller
{
$original = \IPS\File::get( 'downloads_Screenshots', $row['record_location'] );
}
$image = \IPS\Image::create( $original->contents() );
$image->watermark( $watermark );
$newFile = \IPS\File::create( 'downloads_Screenshots', $original->originalFilename, $image );
\IPS\Db::i()->update( 'downloads_files_records', array(
'record_location' => (string) $newFile,
'record_thumb' => (string) $newFile->thumbnail( 'downloads_Screenshots' ),
@@ -154,10 +191,10 @@ class _settings extends \IPS\Dispatcher\Controller
}
catch ( \Exception $e ) {}
}
$doneSoFar += $perGo;
return array( $doneSoFar, \IPS\Member::loggedIn()->language()->addToStack('rebuilding'), 100 / $select->count( TRUE ) * $doneSoFar );
return array( $doneSoFar, \IPS\Member::loggedIn()->language()->addToStack('rebuilding'), 100 / $select->count( TRUE ) * $doneSoFar );
}, function()
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=settings' ), 'completed' );
@@ -1,13 +1,12 @@
<?php
/**
* @brief Top Downloaders
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 17 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\stats;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Downloads Statistics
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 16 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\stats;
@@ -42,10 +41,16 @@ class _downloads extends \IPS\Dispatcher\Controller
*/
protected function manage()
{
$chart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=downloads" ), 'downloads_downloads', 'dtime', '', array(), 'ColumnChart', 'monthly', array( 'start' => 0, 'end' => 0 ), array( 'dmid', 'dfid', 'dtime', 'dsize', 'dua', 'dip' ) );
$chart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=downloads" ), 'downloads_downloads', 'dtime', '', array(
'backgroundColor' => '#ffffff',
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
'lineWidth' => 1,
'areaOpacity' => 0.4,
), 'AreaChart', 'monthly', array( 'start' => 0, 'end' => 0 ), array( 'dmid', 'dfid', 'dtime', 'dsize', 'dua', 'dip' ) );
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('downloads'), 'number', 'COUNT(*)', FALSE );
$chart->availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart' );
$chart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart' );
$chart->tableParsers = array(
'dmid' => function( $val )
@@ -1,13 +1,12 @@
<?php
/**
* @brief Member Stats
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 13 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\stats;
@@ -87,9 +86,15 @@ class _member extends \IPS\Dispatcher\Controller
break;
case 'downloads':
$downloadsChart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=member&do=downloads&id={$member->member_id}&tab=downloads&_graph=1" ), 'downloads_downloads', 'dtime', '', array(), 'ColumnChart', 'monthly', array( 'start' => 0, 'end' => 0 ), array( 'dfid', 'dtime', 'dsize', 'dua', 'dip' ) );
$downloadsChart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=member&do=downloads&id={$member->member_id}&tab=downloads&_graph=1" ), 'downloads_downloads', 'dtime', '', array(
'backgroundColor' => '#ffffff',
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
'lineWidth' => 1,
'areaOpacity' => 0.4
), 'ColumnChart', 'monthly', array( 'start' => 0, 'end' => 0 ), array( 'dfid', 'dtime', 'dsize', 'dua', 'dip' ) );
$downloadsChart->where[] = array( 'dmid=?', $member->member_id );
$downloadsChart->availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart', 'Table' );
$downloadsChart->availableTypes = array( 'AreaChart', 'ColumnChart', 'BarChart', 'Table' );
$downloadsChart->tableParsers = array(
'dfid' => function( $val )
{
@@ -126,7 +131,14 @@ class _member extends \IPS\Dispatcher\Controller
break;
case 'bandwidth_use':
$bandwidthChart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=member&do=downloads&id={$member->member_id}&tab=bandwidth_use&_graph=1" ), 'downloads_downloads', 'dtime', '', array( 'vAxis' => array( 'title' => '(' . \IPS\Member::loggedIn()->language()->addToStack( 'filesize_raw_k' ) . ')' ) ) );
$bandwidthChart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=downloads&module=stats&controller=member&do=downloads&id={$member->member_id}&tab=bandwidth_use&_graph=1" ), 'downloads_downloads', 'dtime', '', array(
'vAxis' => array( 'title' => '(' . \IPS\Member::loggedIn()->language()->addToStack( 'filesize_raw_k' ) . ')' ),
'backgroundColor' => '#ffffff',
'colors' => array( '#10967e', '#ea7963', '#de6470', '#6b9dde', '#b09be4', '#eec766', '#9fc973', '#e291bf', '#55c1a6', '#5fb9da' ),
'hAxis' => array( 'gridlines' => array( 'color' => '#f5f5f5' ) ),
'lineWidth' => 1,
'areaOpacity' => 0.4
) );
$bandwidthChart->where[] = array( 'dmid=?', $member->member_id );
$bandwidthChart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('bandwidth_use'), 'number', 'ROUND((SUM(dsize)/1024),2)', FALSE );
$activeTabContents = ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->_graph ) ) ? (string) $bandwidthChart : \IPS\Theme::i()->getTemplate( 'stats' )->graphs( (string) $bandwidthChart );
@@ -1,13 +1,12 @@
<?php
/**
* @brief Top Submitters
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 17 Dec 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\admin\stats;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Browse Files Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 08 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -67,10 +66,40 @@ class _browse extends \IPS\Dispatcher\Controller
}
/* Get stuff */
$featured = iterator_to_array( \IPS\downloads\File::featured( 4, '_rand' ) );
$new = \IPS\downloads\File::getItemsWithPermission( array(), NULL, 14 );
$highestRated = \IPS\downloads\File::getItemsWithPermission( array( array( 'file_rating > ?', 0 ) ), 'file_rating DESC, file_reviews DESC', 14 );
$mostDownloaded = \IPS\downloads\File::getItemsWithPermission( array( array( 'file_downloads > ?', 0 ) ), 'file_downloads DESC', 14 );
$featured = (\IPS\Settings::i()->idm_show_featured) ? iterator_to_array(\IPS\downloads\File::featured(\IPS\Settings::i()->idm_featured_count, '_rand')) : array();
if ( \IPS\Settings::i()->idm_newest_categories )
{
$newestWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_newest_categories ) ) ) );
}
else
{
$newestWhere = array( array( 'downloads_categories.copen=1' ) );
}
$new = ( \IPS\Settings::i()->idm_show_newest) ? \IPS\downloads\File::getItemsWithPermission( $newestWhere, NULL, 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if (\IPS\Settings::i()->idm_highest_rated_categories )
{
$highestWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_highest_rated_categories ) ) ) );
}
else
{
$highestWhere = array( array( 'downloads_categories.copen=1' ) );
}
$highestWhere[] = array( 'file_rating > ?', 0 );
$highestRated = ( \IPS\Settings::i()->idm_show_highest_rated ) ? \IPS\downloads\File::getItemsWithPermission( $highestWhere, 'file_rating DESC, file_reviews DESC', 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
if (\IPS\Settings::i()->idm_show_most_downloaded_categories )
{
$mostDownloadedWhere = array( array( 'downloads_categories.copen=1 and ' . \IPS\Db::i()->in('file_cat', explode( ',', \IPS\Settings::i()->idm_show_most_downloaded_categories ) ) ) );
}
else
{
$mostDownloadedWhere = array( array( 'downloads_categories.copen=1' ) );
}
$mostDownloadedWhere[] = array( 'downloads_categories.copen=1 and file_downloads > ?', 0 );
$mostDownloaded = ( \IPS\Settings::i()->idm_show_most_downloaded ) ? \IPS\downloads\File::getItemsWithPermission( $mostDownloadedWhere, 'file_downloads DESC', 14, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE ) : array();
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=downloads', 'front', 'downloads' ), array(), 'loc_downloads_browsing' );
@@ -89,16 +118,34 @@ class _browse extends \IPS\Dispatcher\Controller
*/
protected function _category( $category )
{
\IPS\Output::i()->sidebar['contextual'] = '';
$_count = \IPS\downloads\File::getItemsWithPermission( array( array( \IPS\downloads\File::$databasePrefix . \IPS\downloads\File::$databaseColumnMap['container'] . '=?', $category->_id ) ), NULL, 1, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
if( !$_count )
{
/* Set breadcrumb */
foreach ( $category->parents() as $parent )
if ( $club = $category->club() )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $category, 'sidebar' );
}
}
else
{
foreach ( $category->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
}
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
/* Show a 'no files' template if there's nothing to display */
$table = \IPS\Theme::i()->getTemplate( 'browse' )->noFiles( $category );
@@ -110,6 +157,17 @@ class _browse extends \IPS\Dispatcher\Controller
$table->classes = array( 'ipsDataList_large' );
$table->sortOptions = array_merge( $table->sortOptions, array( 'file_downloads' => 'file_downloads' ) );
if ( !$category->bitoptions['reviews_download'] )
{
unset( $table->sortOptions['num_reviews'] );
}
if ( !$category->bitoptions['comments'] )
{
unset( $table->sortOptions['last_comment'] );
unset( $table->sortOptions['num_comments'] );
}
if ( $table->sortBy === 'file_name' )
{
$table->sortDirection = 'asc';
@@ -133,7 +191,7 @@ class _browse extends \IPS\Dispatcher\Controller
\IPS\Output::i()->title = $category->_title;
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_downloads_categories' ) ] = array( 'type' => 'downloads_file', 'nodes' => $category->_id );
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'browse' )->indexSidebar( \IPS\downloads\Category::canOnAny('add'), $category );
\IPS\Output::i()->sidebar['contextual'] .= \IPS\Theme::i()->getTemplate( 'browse' )->indexSidebar( \IPS\downloads\Category::canOnAny('add'), $category );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->category( $category, (string) $table );
}
@@ -147,7 +205,7 @@ class _browse extends \IPS\Dispatcher\Controller
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse&do=categories', 'front', 'downloads_categories' ), array(), 'loc_downloads_browsing_categories' );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('__app_downloads');
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('downloads_categories_pagetitle');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories();
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Submit File Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 08 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -35,8 +34,6 @@ class _submit extends \IPS\Dispatcher\Controller
\IPS\downloads\File::canCreate( \IPS\Member::loggedIn(), NULL, TRUE );
\IPS\Output::i()->sidebar['enabled'] = FALSE;
parent::execute();
}
@@ -343,6 +340,24 @@ class _submit extends \IPS\Dispatcher\Controller
\IPS\File::get( $file['record_type'] === 'upload' ? 'downloads_Files' : 'downloads_Screenshots', $location )->delete();
}
catch ( \Exception $e ) { }
if( $file['record_thumb'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_thumb'] )->delete();
}
catch ( \Exception $e ) { }
}
if( $file['record_no_watermark'] )
{
try
{
\IPS\File::get( 'downloads_Screenshots', $file['record_no_watermark'] )->delete();
}
catch ( \Exception $e ) { }
}
\IPS\Db::i()->delete( 'downloads_files_records', array( 'record_id=?', $file['record_id'] ) );
}
@@ -592,6 +607,29 @@ class _submit extends \IPS\Dispatcher\Controller
$wizard = \IPS\Theme::i()->getTemplate( 'forms', 'core' )->modQueueMessage( \IPS\Member::loggedIn()->warnings( 5, NULL, 'mq' ), \IPS\Member::loggedIn()->mod_posts ) . $wizard;
}
\IPS\Output::i()->output = $wizard;
if ( isset( \IPS\Request::i()->category ) )
{
try
{
$category = \IPS\downloads\Category::loadAndCheckPerms( \IPS\Request::i()->category );
if ( $club = $category->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $category, 'sidebar' );
}
}
}
catch ( \OutOfRangeException $e ) { }
}
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'submit_a_file' ) );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief View File Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @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 Downloads
* @since 10 Oct 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\downloads\modules\front\downloads;
@@ -40,8 +39,7 @@ class _view extends \IPS\Content\Controller
{
$this->file = \IPS\downloads\File::load( \IPS\Request::i()->id );
/* Downloading does not check 'view' permission, as there is a separate download permission already.
@see https://invisionpower.com/4bugtrack/archived-reports/4092-cant-download-files-when-files-disallowed-to-view-by-any-group-r6975/ */
/* Downloading does not check 'view' permission, as there is a separate download permission already */
if ( !$this->file->canView( \IPS\Member::loggedIn() ) and \IPS\Request::i()->do != 'download' )
{
\IPS\Output::i()->error( $this->file->container()->message('npv') ?: 'node_error', '2D161/2', 403, '' );
@@ -119,7 +117,119 @@ class _view extends \IPS\Content\Controller
}
}
}
/* Add JSON-ld */
\IPS\Output::i()->jsonLd['download'] = array(
'@context' => "http://schema.org",
'@type' => "SoftwareApplication",
'url' => (string) $this->file->url(),
'name' => htmlspecialchars( $this->file->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'description' => strip_tags( $this->file->truncated() ),
'applicationCategory' => $this->file->container()->_title,
'downloadUrl' => (string) $this->file->url( 'download' ),
'dateCreated' => \IPS\DateTime::ts( $this->file->submitted )->format( \IPS\DateTime::ISO8601 ),
'fileSize' => \IPS\Output\Plugin\Filesize::humanReadableFilesize( $this->file->filesize() ),
'softwareVersion' => htmlspecialchars( $this->file->version, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->file->submitter )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->file->submitter )->url(),
'image' => \IPS\Member::load( $this->file->submitter )->get_photo()
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $this->file->views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/DownloadAction",
'userInteractionCount' => $this->file->downloads
)
)
);
if( $this->file->updated != $this->file->submitted )
{
\IPS\Output::i()->jsonLd['download']['dateModified'] = \IPS\DateTime::ts( $this->file->updated )->format( \IPS\DateTime::ISO8601 );
}
if( $this->file->container()->bitoptions['reviews'] )
{
\IPS\Output::i()->jsonLd['download']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $this->file->averageReviewRating(),
'reviewCount' => $this->file->reviews,
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
);
}
if( $this->file->screenshots()->getInnerIterator()->count( true ) )
{
\IPS\Output::i()->jsonLd['download']['screenshot'] = array();
$thumbnails = iterator_to_array( $this->file->screenshots( 1 ) );
foreach( $this->file->screenshots() as $id => $screenshot )
{
\IPS\Output::i()->jsonLd['download']['screenshot'][] = array(
'@type' => 'ImageObject',
'url' => (string) $screenshot->url,
'thumbnail' => array(
'@type' => 'ImageObject',
'url' => (string) $thumbnails[ $id ]->url
)
);
}
}
if( $versionData['b_changelog'] )
{
\IPS\Output::i()->jsonLd['download']['releaseNotes'] = $versionData['b_changelog'];
}
if( $this->file->topic() )
{
\IPS\Output::i()->jsonLd['download']['sameAs'] = (string) $this->file->topic()->url();
}
if( $this->file->isPaid() )
{
\IPS\Output::i()->jsonLd['download']['potentialAction'] = array(
'@type' => 'BuyAction',
'target' => (string) $this->file->url( 'buy' ),
);
\IPS\Output::i()->jsonLd['download']['offers'] = array(
'@type' => 'Offer',
'url' => (string) $this->file->url( 'buy' ),
'price' => $this->file->price(),
'priceCurrency' => \IPS\nexus\Customer::loggedIn()->defaultCurrency(),
'availability' => "http://schema.org/InStock"
);
}
if( $this->file->container()->bitoptions['comments'] )
{
\IPS\Output::i()->jsonLd['download']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $this->file->mapped('num_comments')
);
\IPS\Output::i()->jsonLd['download']['commentCount'] = $this->file->mapped('num_comments');
}
if( $this->file->container()->bitoptions['reviews'] )
{
\IPS\Output::i()->jsonLd['download']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ReviewAction",
'userInteractionCount' => $this->file->mapped('num_reviews')
);
}
/* Display */
\IPS\Output::i()->sidebar['sticky'] = TRUE;
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->file, $commentsAndReviews, $versionData, $previousVersions, $this->file->nextItem(), $this->file->prevItem(), $cfields );
@@ -355,7 +465,7 @@ class _view extends \IPS\Content\Controller
'dmid' => (int) \IPS\Member::loggedIn()->member_id,
'dsize' => $data['record_size'],
'dua' => \IPS\Session::i()->userAgent->useragent,
'dbrowsers' => \IPS\Session::i()->userAgent->useragentKey,
'dbrowsers' => \IPS\Session::i()->userAgent->browser,
'dos' => ''
) );
}
@@ -671,9 +781,15 @@ class _view extends \IPS\Content\Controller
$form->addHeader( 'upload_files' );
$form->add( new \IPS\Helpers\Form\Upload( 'files', iterator_to_array( $this->file->files( NULL, FALSE ) ), ( !\IPS\Member::loggedIn()->group['idm_linked_files'] and !\IPS\Member::loggedIn()->group['idm_import_files'] ), array( 'storageExtension' => 'downloads_Files', 'allowedFileTypes' => $category->types, 'maxFileSize' => $category->maxfile ? ( $category->maxfile / 1024 ) : NULL, 'multiple' => TRUE, 'retainDeleted' => TRUE ) ) );
$linkedFiles = iterator_to_array( \IPS\Db::i()->select( 'record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $this->file->id, 'link' ) ) );
if ( \IPS\Member::loggedIn()->group['idm_linked_files'] )
{
$form->add( new \IPS\Helpers\Form\Stack( 'url_files', iterator_to_array( \IPS\Db::i()->select( 'record_location', 'downloads_files_records', array( 'record_file_id=? AND record_type=? AND record_backup=0', $this->file->id, 'link' ) ) ), FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
$form->add( new \IPS\Helpers\Form\Stack( 'url_files', $linkedFiles, FALSE, array( 'stackFieldType' => 'Url' ), array( 'IPS\downloads\File', 'blacklistCheck' ) ) );
}
else if ( count( $linkedFiles ) > 0 )
{
$form->addMessage( 'url_files_no_perm' );
}
if ( \IPS\Member::loggedIn()->group['idm_import_files'] )
@@ -851,6 +967,7 @@ class _view extends \IPS\Content\Controller
else
{
$noWatermark = NULL;
$watermarked = FALSE;
if ( \IPS\Settings::i()->idm_watermarkpath )
{
try
@@ -860,15 +977,31 @@ class _view extends \IPS\Content\Controller
$image = \IPS\Image::create( $file->contents() );
$image->watermark( $watermark );
$file = \IPS\File::create( 'downloads_Screenshots', $file->originalFilename, $image );
$watermarked = TRUE;
}
catch ( \Exception $e ) { }
}
/**
* We only need to generate a new thumbnail if we are using watermarking.
* If we are not, then we can simply use the previous thumbnail, if this existed previously, rather than generating a new one every time we upload a new version, which is unnecessary extra processing as well as disk usage.
* If we are, then it is impossible to know if the watermark has since changed, so we need to go ahead and do it anyway.
*/
$existing = NULL;
if ( $watermarked !== TRUE )
{
try
{
$existing = \IPS\Db::i()->select( '*', 'downloads_files_records', array( "record_location=? AND record_file_id=?", (string) $file, $this->file->id ) )->first();
}
catch( \UnderflowException $e ) {}
}
\IPS\Db::i()->insert( 'downloads_files_records', array(
'record_file_id' => $this->file->id,
'record_type' => 'ssupload',
'record_location' => (string) $file,
'record_thumb' => (string) $file->thumbnail( 'downloads_Screenshots' ),
'record_thumb' => ( $watermarked OR !$existing ) ? (string) $file->thumbnail( 'downloads_Screenshots' ) : $existing['record_thumb'],
'record_realname' => $file->originalFilename,
'record_size' => $file->filesize(),
'record_time' => time(),