Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+53 -1
View File
@@ -15,14 +15,18 @@ namespace IPS\downloads;
use IPS\Application;
use IPS\CustomField;
use IPS\Data\Store;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\TextArea;
use IPS\Helpers\Form\YesNo;
use IPS\Lang;
use IPS\Log;
use IPS\Member;
use IPS\Node\Permissions;
use IPS\Settings;
use IPS\Theme;
use ParseError;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
@@ -226,6 +230,7 @@ class Field extends CustomField implements Permissions
* @apiresponse string name Name
* @apiresponse string description Description
* @apiresponse string value Current value for this file
* @apiresponse string|int|array|boolean displayValue Parsed Field value with all field data
*/
public function apiOutput( ?Member $authorizedMember = NULL, array $fieldValues=array() ): array
{
@@ -234,7 +239,54 @@ class Field extends CustomField implements Permissions
'id' => $this->id,
'name' => $lang->addToStack( 'downloads_field_' . $this->id ),
'description' => $lang->addToStack( 'downloads_field_' . $this->id . '_desc' ),
'value' => $fieldValues[ 'field_' . $this->id ] ?? null
'value' => $fieldValues[ 'field_' . $this->id ] ?? null,
'displayValue' => $this->apiValue( $fieldValues[ 'field_' . $this->id ] )
];
}
/**
* Parse the HTML logic to format the field
*
* @param string $rawValue Raw value
* @param File $file
* @return string
*/
public function formatValue( string $rawValue, File $file ) : string
{
/* If we are using the "default" formatting, set that up now */
$template = $this->format ?: "<strong><span data-ips-font-size=\"90\">{title} </span></strong> {content}";
$template = str_replace( [ '{title}', '{content}' ], [ "{\$title}", "{\$content}" ], $template );
try
{
$functionName = 'downloadsfields_cc_' . md5( $template );
if ( ! isset( Store::i()->$functionName ) )
{
/* We need the "raw" content because HTML is typically used to format the value */
$template = str_replace( '{$processedContent}', '{$processedContent|raw}', $template );
/* If this an editor, we can safely use the |raw value as it is clean, otherwise the escaped value will display which is not what the user expects */
if ( $this->type == 'Editor' )
{
$template = str_replace( '{$content}', '{$content|raw}', $template );
$template = Theme::i()->getTemplate('global', 'core', 'global')->richText( $template );
}
/* $content is the raw content from the database, $processedContent is the parsed content ready for display */
Store::i()->$functionName = Theme::compileTemplate( $template, $functionName, '$title, $content, $processedContent, $file' );
}
Theme::runProcessFunction( Store::i()->$functionName, $functionName );
$themeFunction = 'IPS\\Theme\\'. $functionName;
return $themeFunction( Member::loggedIn()->language()->addToStack( static::$langKey . '_' . $this->id ), $rawValue, $this->displayValue( $rawValue ), $file );
}
catch ( ParseError $e )
{
@ob_end_clean();
Log::log( $e, 'pfield_error' );
return (string) $this->displayValue( $rawValue );
}
}
}
+17 -19
View File
@@ -933,20 +933,12 @@ Filter
if( $topic === TRUE )
{
$thisField = Field::constructFromData( $this->_fieldData[ $fieldId ] );
if( isset( $this->_fieldData[ $fieldId ] ) )
{
$v = str_replace( '{content}', htmlspecialchars( $v, ENT_DISALLOWED, 'UTF-8', FALSE ), $thisField->displayValue( $v ) );
$v = str_replace( '{member_id}', Member::loggedIn()->member_id, $v );
$v = str_replace( '{title}', Member::loggedIn()->language()->addToStack( 'downloads_field_' . $fieldId ), $v );
}
else
{
$v = htmlspecialchars( $v, ENT_DISALLOWED, 'UTF-8', FALSE );
}
$return[ $k ] = $thisField->formatValue( $v, $this );
}
else
{
$return[ $k ] = $v;
}
$return[ $k ] = $v;
}
}
}
@@ -2482,6 +2474,7 @@ Filter
* @apiresponse \IPS\Member author Author
* @apiresponse datetime date When the file was created
* @apiresponse datetime updated When the file was last updated
* @apiresponse datetime published When the file was published
* @apiresponse string description Description
* @apiresponse string version Current version number
* @apiresponse string changelog Description of what changed between this version and the previous one
@@ -2541,6 +2534,7 @@ Filter
'author' => $this->author()->apiOutput( $authorizedMember ),
'date' => DateTime::ts( $backup ? $backup['b_backup'] : $this->submitted )->rfc3339(),
'updated' => DateTime::ts( $this->updated )->rfc3339(),
'published' => DateTime::ts( $this->published )->rfc3339(),
'description' => $backup ? $backup['b_filedesc'] : $this->content(),
'version' => $backup ? $backup['b_version'] : $this->version,
'changelog' => $backup ? $backup['b_changelog'] : $this->changelog,
@@ -2723,7 +2717,7 @@ Filter
/* Due to an older bug in 5.0.0 B9, attachment files can match the exact filename of a downloads record, so we won't want to delete if there's a match there */
$existsAlready = Db::i()->select( '*', 'downloads_files_records', [ 'record_location=? or record_thumb=?', $row['attach_location'], $row['attach_location'] ] )->first();
}
catch( \UnderflowException )
catch( UnderflowException )
{
$existsAlready = false;
}
@@ -2754,7 +2748,8 @@ Filter
{
/* Copy the screenshot and generate an attachment */
/* @var SystemFile $screenshot */
$copy = $screenshot->duplicate();
$uploadSettings = json_decode( Settings::i()->upload_settings, true );
$copy = $screenshot->copy( $uploadSettings['filestorage__core_Attachment'] );
$attachment = $copy->makeAttachment( md5( uniqid() ), $topic->author() );
@@ -2773,7 +2768,10 @@ Filter
}
catch( RuntimeException ){}
$topic->firstComment()->post = $content;
$firstComment = $topic->firstComment();
$contentField = $firstComment::$databaseColumnMap['content'];
$topic->firstComment()->$contentField = $content;
$topic->firstComment()->save();
}
}
@@ -2924,17 +2922,17 @@ Filter
if( !$this->hasPendingVersion() AND $this->canEdit( $member ) )
{
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'newVersion' ) ), languageString: Member::loggedIn()->language()->addToStack( 'upload_new_version') ) );
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'newVersion' ) ), languageString: Member::loggedIn()->language()->addToStack( 'upload_new_version'), icon: "fa-solid fa-upload" ) );
}
if( $this->isPurchasable() AND $this->canDisablePurchases( $member ) )
{
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'purchaseStatus' , 'value' => 0 ) )->csrf(), languageString: Member::loggedIn()->language()->addToStack( 'disable_purchases') ) );
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'purchaseStatus' , 'value' => 0 ) )->csrf(), languageString: Member::loggedIn()->language()->addToStack( 'disable_purchases'), icon: "fa-solid fa-circle-xmark" ) );
}
if( !$this->isPurchasable() AND $this->canEnablePurchases() )
{
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'purchaseStatus' , 'value' => 1 ) )->csrf(), languageString: Member::loggedIn()->language()->addToStack( 'enable_purchases') ) );
$menu->add( new Menu\Link( url: $this->url()->setQueryString( array( 'do' => 'purchaseStatus' , 'value' => 1 ) )->csrf(), languageString: Member::loggedIn()->language()->addToStack( 'enable_purchases'), icon: "fa-solid fa-circle-check" ) );
}
return $menu;