Procházet zdrojové kódy

#4148 - Build-in API support (attachments in comments)

roman.lesnikov@gmail.com před 3 roky
rodič
revize
0cc12cd0a0
2 změnil soubory, kde provedl 30 přidání a 11 odebrání
  1. 1 0
      inc/classes/BxDolCmts.php
  2. 29 11
      template/scripts/BxBaseCmts.php

+ 1 - 0
inc/classes/BxDolCmts.php

@@ -2199,6 +2199,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
                 'id' => $mixedItem['cmt_id'], 
                 'order' => isset($mixedItem['cmt_order']) ? $mixedItem['cmt_order'] : 0, 
                 'data' => $this->getCommentSimple((int)$mixedItem['cmt_id']),
+                'files' => $this->_getAttachments($mixedItem),
                 'items' => array(),
             );
             $aStructure[$iI]['data']['author_data'] = BxDolProfile::getData($aStructure[$iI]['data']['cmt_author_id']);

+ 29 - 11
template/scripts/BxBaseCmts.php

@@ -1480,19 +1480,37 @@ class BxBaseCmts extends BxDolCmts
                     'h' => $iHeight
                 );
 
-                $aTmplImages[] = array(
-                    'style_prefix' => $this->_sStylePrefix,
-                    'bx_if:show_image' => array(
-                        'condition' => $bImage,
-                        'content' => $aTmplVarsFile
-                    ),
-                    'bx_if:show_file' => array(
-                        'condition' => !$bImage,
-                        'content' => $aTmplVarsFile
-                    ),
-                );
+                if (bx_is_api()){
+                    $aTmplImages[] = array(
+                        'is_image' => $bImage,
+                        'file' => $aTmplVarsFile['file'],
+                        'file_id' => $aTmplVarsFile['file_id'],
+                        'file_name' => $aTmplVarsFile['file_name'],
+                        'file_icon' => $aTmplVarsFile['file_icon'],
+                        'file_size' => $aTmplVarsFile['file_size'],
+                        'width' => $aTmplVarsFile['w'],
+                        'height' => $aTmplVarsFile['h'],
+                    );
+                }
+                else{
+                    $aTmplImages[] = array(
+                        'style_prefix' => $this->_sStylePrefix,
+                        'bx_if:show_image' => array(
+                            'condition' => $bImage,
+                            'content' => $aTmplVarsFile
+                        ),
+                        'bx_if:show_file' => array(
+                            'condition' => !$bImage,
+                            'content' => $aTmplVarsFile
+                        ),
+                    );
+                }
             }
         }
+        
+        if (bx_is_api()){
+            return $aTmplImages;
+        }
 
         return $this->_oTemplate->parseHtmlByName('comment_attachments.html', array(
             'bx_repeat:attached' => $aTmplImages