Dotclear

Changeset 1266:f18660c2ca33


Ignore:
Timestamp:
08/05/13 12:44:48 (10 years ago)
Author:
akewea
Branch:
ticket1084
Message:

ticket#1084 : add a boolean parameter to getPostMedia to choose the return type : resultSet (for LoopPosition? to work) or Array (default).

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.media.php

    r1220 r1266  
    497497     @param    post_id   <b>integer</b>      Post ID 
    498498     @param    media_id  <b>integer</b>      Optionnal media ID 
     499     @param    rs   <b>boolean</b>      Whether to return a resultset (true) or an array (false, default value). 
    499500     @return   <b>array</b> Array of fileItems 
    500501     */ 
    501      public function getPostMedia($post_id,$media_id=null) 
     502     public function getPostMedia($post_id,$media_id=null,$rs=false) 
    502503     { 
    503504          $params = array( 
     
    515516               $f = $this->fileRecord($rs); 
    516517               if ($f !== null) { 
    517                     $res[] = new ArrayObject($f); 
    518                } 
    519           } 
    520            
    521           return $res; 
     518                    $res[] = $rs ? new ArrayObject($f) : $f; 
     519               } 
     520          } 
     521           
     522          return $rs ? staticRecord::newFromArray($res) : $res; 
    522523     } 
    523524      
  • plugins/attachments/_public.php

    r1221 r1266  
    4040          "<?php\n". 
    4141          'if ($_ctx->posts !== null && $core->media) {'."\n". 
    42           '$_ctx->attachments = staticRecord::newFromArray($core->media->getPostMedia($_ctx->posts->post_id));'."\n". 
     42          '$_ctx->attachments = $core->media->getPostMedia($_ctx->posts->post_id, null, true);'."\n". 
    4343          "?>\n". 
    4444           
     
    4646          '<?php while ($_ctx->attachments->fetch()) : ?>'. 
    4747           
    48           '<?php $GLOBALS[\'attach_i\'] = $attach_i; $attach_f = $_ctx->attachments->row(); $GLOBALS[\'attach_f\'] = $attach_f;'. // LEGACY 
     48          '<?php $GLOBALS[\'attach_i\'] = $attach_i; $attach_f = $_ctx->attachments; $GLOBALS[\'attach_f\'] = $attach_f;'. // LEGACY 
    4949          '$_ctx->file_url = $attach_f->file_url; ?>'. // LEGACY 
    5050          $content. 
Note: See TracChangeset for help on using the changeset viewer.

Sites map