Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user