ProductRepository: kopiowanie custom fields uwzględnia pola type i is_required. product-custom-fields.php: ochrona XSS, obsługa pola image, fallback typu na text. SonarQube 0.343: nowe issues dodane do TODO.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
1019 B
PHP
26 lines
1019 B
PHP
<? if ( $this -> custom_fields ) : ?>
|
|
<? foreach ( $this -> custom_fields as $key => $val ) : ?>
|
|
<? $custom_field = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->findCustomFieldCached( $key ); ?>
|
|
<? $field_type = !empty( $custom_field['type'] ) ? $custom_field['type'] : 'text'; ?>
|
|
|
|
<? if ( $field_type == 'text' ) : ?>
|
|
<div class="custom-field">
|
|
<div class="_name">
|
|
<?= htmlspecialchars( $custom_field['name'] ) . ':'; ?>
|
|
</div>
|
|
<div class="_text">
|
|
<?= nl2br( htmlspecialchars( $val ) );?>
|
|
</div>
|
|
</div>
|
|
<? elseif ( $field_type == 'image' && !empty( $val ) ) : ?>
|
|
<div class="custom-field">
|
|
<div class="_name">
|
|
<?= htmlspecialchars( $custom_field['name'] ) . ':'; ?>
|
|
</div>
|
|
<div class="_image">
|
|
<img src="<?= htmlspecialchars( $val );?>" alt="<?= htmlspecialchars( $custom_field['name'] );?>">
|
|
</div>
|
|
</div>
|
|
<? endif; ?>
|
|
<? endforeach; ?>
|
|
<? endif;?>
|