Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

+131 -28
View File
@@ -128,6 +128,47 @@ class _File extends \IPS\Content\Item implements
* @brief [Content] Key for hide reasons
*/
public static $hideLogKey = 'downloads-file';
/**
* Columns needed to query for search result / stream view
*
* @return array
*/
public static function basicDataColumns()
{
$return = parent::basicDataColumns();
$return[] = 'file_primary_screenshot';
$return[] = 'file_version';
$return[] = 'file_downloads';
$return[] = 'file_cost';
$return[] = 'file_nexus';
return $return;
}
/**
* Query to get additional data for search result / stream view
*
* @param array $items Item data (will be an array containing values from basicDataColumns())
* @return array
*/
public static function searchResultExtraData( $items )
{
$screenshotIds = array();
foreach ( $items as $itemData )
{
if ( $itemData['file_primary_screenshot'] )
{
$screenshotIds[] = $itemData['file_primary_screenshot'];
}
}
if ( count( $screenshotIds ) )
{
return iterator_to_array( \IPS\Db::i()->select( array( 'record_file_id', 'record_location', 'record_thumb' ), 'downloads_files_records', \IPS\Db::i()->in( 'record_id', $screenshotIds ) )->setKeyField( 'record_file_id' ) );
}
return array();
}
/**
* Set name
@@ -171,29 +212,21 @@ class _File extends \IPS\Content\Item implements
* @brief Cached URLs
*/
protected $_url = array();
/**
* Get URL
*
* @param string|NULL $action Action
* @return \IPS\Http\Url
*/
public function url( $action=NULL )
{
$_key = md5( $action );
if( !isset( $this->_url[ $_key ] ) )
{
$this->_url[ $_key ] = \IPS\Http\Url::internal( "app=downloads&module=downloads&controller=view&id={$this->id}", 'front', 'downloads_file', $this->name_furl );
if ( $action )
{
$this->_url[ $_key ] = $this->_url[ $_key ]->setQueryString( 'do', $action );
}
}
return $this->_url[ $_key ];
}
/**
* @brief URL Base
*/
public static $urlBase = 'app=downloads&module=downloads&controller=view&id=';
/**
* @brief URL Base
*/
public static $urlTemplate = 'downloads_file';
/**
* @brief SEO Title Column
*/
public static $seoTitleColumn = 'name_furl';
/**
* Get URL for last comment page
@@ -225,6 +258,16 @@ class _File extends \IPS\Content\Item implements
return array( \IPS\Theme::i()->getTemplate( 'browse', 'downloads' ), 'rows' );
}
/**
* HTML to manage an item's follows
*
* @return callable
*/
public static function manageFollowRows()
{
return array( \IPS\Theme::i()->getTemplate( 'global', 'downloads', 'front' ), 'manageFollowRow' );
}
/**
* Files
*/
@@ -288,17 +331,29 @@ class _File extends \IPS\Content\Item implements
* @return \IPS\nexus\Money|NULL
*/
public function price()
{
return static::_price( $this->cost, $this->nexus );
}
/**
* Get Price
*
* @param float $cost The cost
* @param string $nexusPackageIds Comma-delimited list of associated package IDs
* @return \IPS\nexus\Money|NULL
*/
public static function _price( $cost, $nexusPackageIds )
{
if ( \IPS\Application::appIsEnabled( 'nexus' ) and \IPS\Settings::i()->idm_nexus_on )
{
if ( $this->nexus )
if ( $nexusPackageIds )
{
$packages = explode( ',', $this->nexus );
$packages = explode( ',', $nexusPackageIds );
try
{
if ( count( $packages ) === 1 )
{
return \IPS\nexus\Package::load( $this->nexus )->priceToDisplay();
return \IPS\nexus\Package::load( $nexusPackageIds )->priceToDisplay();
}
else
{
@@ -310,10 +365,10 @@ class _File extends \IPS\Content\Item implements
return NULL;
}
if ( $this->cost )
if ( $cost )
{
$currency = isset( $_SESSION['currency'] ) ? $_SESSION['currency'] : \IPS\nexus\Customer::loggedIn()->defaultCurrency();
if ( $costs = json_decode( $this->cost, TRUE ) and isset( $costs[ $currency ]['amount'] ) )
if ( $costs = json_decode( $cost, TRUE ) and isset( $costs[ $currency ]['amount'] ) )
{
if ( $costs[ $currency ]['amount'] )
{
@@ -322,7 +377,7 @@ class _File extends \IPS\Content\Item implements
}
else
{
return new \IPS\nexus\Money( $this->cost, $currency );
return new \IPS\nexus\Money( $cost, $currency );
}
}
}
@@ -1364,6 +1419,28 @@ class _File extends \IPS\Content\Item implements
}
}
}
/**
* Are comments supported by this class?
*
* @param \IPS\Member\NULL $member The member to check for or NULL fto not check permission
* @return int
*/
public static function supportsComments( \IPS\Member $member = NULL )
{
return parent::supportsComments() and ( !$member or \IPS\downloads\Category::countWhere( 'read', $member, array( 'cbitoptions & 4' ) ) );
}
/**
* Are reviews supported by this class?
*
* @param \IPS\Member\NULL $member The member to check for or NULL to not check permission
* @return int
*/
public static function supportsReviews( \IPS\Member $member = NULL )
{
return parent::supportsReviews() and ( !$member or \IPS\downloads\Category::countWhere( 'read', $member, array( 'cbitoptions & 256' ) ) );
}
/* !Tags */
@@ -1865,6 +1942,32 @@ class _File extends \IPS\Content\Item implements
return $this->primary_screenshot_thumb ? \IPS\File::get( 'downloads_Screenshots', $this->primary_screenshot_thumb ) : NULL;
}
/**
* Get snippet HTML for search result display
*
* @param array $indexData Data from the search index
* @param array $authorData Basic data about the author. Only includes columns returned by \IPS\Member::columnsForPhoto()
* @param array $itemData Basic data about the item. Only includes columns returned by item::basicDataColumns()
* @param array|NULL $containerData Basic data about the author. Only includes columns returned by container::basicDataColumns()
* @param array $reputationData Array of people who have given reputation and the reputation they gave
* @param int|NULL $reviewRating If this is a review, the rating
* @param string $view 'expanded' or 'condensed'
* @return callable
*/
public static function searchResultSnippet( array $indexData, array $authorData, array $itemData, array $containerData = NULL, array $reputationData, $reviewRating, $view )
{
$screenshot = NULL;
if ( isset( $itemData['extra'] ) )
{
$screenshot = isset( $itemData['extra']['record_thumb'] ) ? $itemData['extra']['record_thumb'] : $itemData['extra']['record_location'];
}
$url = \IPS\Http\Url::internal( static::$urlBase . $indexData['index_item_id'], 'front', static::$urlTemplate, \IPS\Http\Url::seoTitle( $indexData['index_title'] ?: $itemData[ static::$databasePrefix . static::$databaseColumnMap['title'] ] ) );
$price = static::_price( $itemData['file_cost'], $itemData['file_nexus'] );
return \IPS\Theme::i()->getTemplate( 'global', 'downloads', 'front' )->searchResultFileSnippet( $indexData, $itemData, $screenshot, $url, $price, $view == 'condensed' );
}
/**
* If, when making a post, we should merge with an existing comment, this method returns the comment to merge with
*