|
|
@@ -351,44 +351,61 @@ class BxMarketTemplate extends BxBaseModTextTemplate
|
|
|
|
|
|
protected function getAttachments($sStorage, $aData, $aParams = array())
|
|
|
{
|
|
|
- $aFiles = $this->_oDb->getFile(array('type' => 'content_id_key_file_id', 'content_id' => $aData['id']));
|
|
|
+ $aFiles = $this->_oDb->getFile(array('type' => 'content_id_key_file_id', 'content_id' => $aData['id']));
|
|
|
|
|
|
- $aAttachments = parent::getAttachments($sStorage, $aData, $aParams);
|
|
|
- if(empty($aAttachments) || !is_array($aAttachments))
|
|
|
- return $aAttachments;
|
|
|
+ $aAttachments_ = parent::getAttachments($sStorage, $aData, $aParams);
|
|
|
+ $aAttachments = array();
|
|
|
+ foreach($aAttachments_ as $aAttachment) {
|
|
|
+ $aAttachments[(int)$aAttachment['id']] = $aAttachment;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($aAttachments) || !is_array($aAttachments))
|
|
|
+ return $aAttachments;
|
|
|
|
|
|
$aResults = array();
|
|
|
- foreach($aAttachments as $iIndex => $aAttachment) {
|
|
|
- $iAttachmentId = (int)$aAttachment['id'];
|
|
|
-
|
|
|
- $aAttachments[$iIndex]['class'] = (int)$aData['package'] == $iAttachmentId ? ' bx-market-attachment-main' : '';
|
|
|
- $aAttachments[$iIndex]['bx_if:main'] = array(
|
|
|
- 'condition' => (int)$aData['package'] == $iAttachmentId,
|
|
|
- 'content' => array()
|
|
|
- );
|
|
|
-
|
|
|
- $bAttachment = !empty($aFiles[$iAttachmentId]);
|
|
|
- $aAttachments[$iIndex]['bx_if:not_image']['content'] = array_merge($aAttachments[$iIndex]['bx_if:not_image']['content'], array(
|
|
|
- 'file_type' => $bAttachment ? _t('_bx_market_form_entry_input_files_type_' . $aFiles[$iAttachmentId]['type']) : '',
|
|
|
- 'bx_if:show_version' => array(
|
|
|
- 'condition' => $bAttachment && $aFiles[$iAttachmentId]['type'] == BX_MARKET_FILE_TYPE_VERSION,
|
|
|
- 'content' => array(
|
|
|
- 'file_version' => $bAttachment ? $aFiles[$iAttachmentId]['version'] : ''
|
|
|
- )
|
|
|
- ),
|
|
|
- 'bx_if:show_update' => array(
|
|
|
- 'condition' => $bAttachment && $aFiles[$iAttachmentId]['type'] == BX_MARKET_FILE_TYPE_UPDATE,
|
|
|
- 'content' => array(
|
|
|
- 'file_version_from_to' => $bAttachment ? _t('_bx_market_form_entry_input_files_version_from_x_to_y', $aFiles[$iAttachmentId]['version'], $aFiles[$iAttachmentId]['version_to']) : ''
|
|
|
- )
|
|
|
- )
|
|
|
- ));
|
|
|
-
|
|
|
- $aFiles[$iAttachmentId] = $aAttachments[$iIndex];
|
|
|
- $aResults[$iAttachmentId] = $aAttachments[$iIndex];
|
|
|
- }
|
|
|
+ $sCaptionType = "";
|
|
|
+ foreach($aFiles as $iAttachmentId => $aFile) {
|
|
|
+ $aAttachments[$iAttachmentId]['class'] = (int)$aData['package'] == $iAttachmentId ? ' bx-market-attachment-main' : '';
|
|
|
+ $aAttachments[$iAttachmentId]['bx_if:main'] = array(
|
|
|
+ 'condition' => (int)$aData['package'] == $iAttachmentId,
|
|
|
+ 'content' => array()
|
|
|
+ );
|
|
|
+
|
|
|
+ $bSeparatorNeeded = false;
|
|
|
+ if ($aFiles[$iAttachmentId]['type'] != $sCaptionType){
|
|
|
+ $bSeparatorNeeded = true;
|
|
|
+ $sCaptionType = $aFiles[$iAttachmentId]['type'];
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ if ((int)$aData['package'] == $iAttachmentId){
|
|
|
+ $bSeparatorNeeded = true;
|
|
|
+ $sCaptionType = 'latest';
|
|
|
+ }
|
|
|
+
|
|
|
+ $bAttachment = !empty($aFiles[$iAttachmentId]);
|
|
|
+ $aAttachments[$iAttachmentId]['bx_if:not_image']['content'] = array_merge($aAttachments[$iAttachmentId]['bx_if:not_image']['content'], array(
|
|
|
+ 'file_type' => $bAttachment ? _t('_bx_market_form_entry_input_files_type_' . $aFiles[$iAttachmentId]['type']) : '',
|
|
|
+ 'bx_if:show_version' => array(
|
|
|
+ 'condition' => $bAttachment && $aFiles[$iAttachmentId]['type'] == BX_MARKET_FILE_TYPE_VERSION,
|
|
|
+ 'content' => array(
|
|
|
+ 'file_version' => $bAttachment ? $aFiles[$iAttachmentId]['version'] : ''
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ 'bx_if:show_update' => array(
|
|
|
+ 'condition' => $bAttachment && $aFiles[$iAttachmentId]['type'] == BX_MARKET_FILE_TYPE_UPDATE,
|
|
|
+ 'content' => array(
|
|
|
+ 'file_version_from_to' => $bAttachment ? _t('_bx_market_form_entry_input_files_version_from_x_to_y', $aFiles[$iAttachmentId]['version'], $aFiles[$iAttachmentId]['version_to']) : ''
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ));
|
|
|
+ $aAttachments[$iAttachmentId]['bx_if:show_separator'] = array('condition' => $bSeparatorNeeded, 'content' => array('type' => _t('_bx_market_form_entry_input_files_version_caption_' . $sCaptionType)));
|
|
|
+
|
|
|
+ $aFiles[$iAttachmentId] = $aAttachments[$iAttachmentId];
|
|
|
+ $aResults[$iAttachmentId] = $aAttachments[$iAttachmentId];
|
|
|
+ }
|
|
|
|
|
|
- return array_intersect_key($aFiles, $aResults);
|
|
|
+ return array_intersect_key($aFiles, $aResults);
|
|
|
}
|
|
|
|
|
|
protected function getAttachmentsImagesTranscoders ($sStorage = '')
|