Dotclear

Changeset 1220:4358ca8a7184


Ignore:
Timestamp:
07/18/13 13:52:55 (12 years ago)
Author:
akewea
Branch:
ticket1084
Message:

ticket #1084 : passage des attachments en staticRecord pour permettre l'utilisation de <tpl:LoopPosition>.

Files:
2 edited

Legend:

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

    r1179 r1220  
    515515               $f = $this->fileRecord($rs); 
    516516               if ($f !== null) { 
    517                     $res[] = $f; 
     517                    $res[] = new ArrayObject($f); 
    518518               } 
    519519          } 
  • plugins/attachments/_public.php

    r1179 r1220  
    4040          "<?php\n". 
    4141          'if ($_ctx->posts !== null && $core->media) {'."\n". 
    42                '$_ctx->attachments = new ArrayObject($core->media->getPostMedia($_ctx->posts->post_id));'."\n". 
     42          '$_ctx->attachments = staticRecord::newFromArray($core->media->getPostMedia($_ctx->posts->post_id));'."\n". 
    4343          "?>\n". 
    4444           
    45           '<?php foreach ($_ctx->attachments as $attach_i => $attach_f) : '. 
    46           '$GLOBALS[\'attach_i\'] = $attach_i; $GLOBALS[\'attach_f\'] = $attach_f;'. 
    47           '$_ctx->file_url = $attach_f->file_url; ?>'. 
    48           $content. 
    49           '<?php endforeach; $_ctx->attachments = null; unset($attach_i,$attach_f,$_ctx->file_url); ?>'. 
     45          '<?php $attach_i = 0; ?>'. // LEGACY 
     46          '<?php while ($_ctx->attachments->fetch()) : ?>'. 
     47           
     48          '<?php $GLOBALS[\'attach_i\'] = $attach_i++; $GLOBALS[\'attach_f\'] = $_ctx->attachments->row();'. // LEGACY 
     49          '$_ctx->file_url = $_ctx->attachments->file_url; ?>'. // LEGACY 
     50           
     51          $content.'<?php endwhile; '. 
     52          '$_ctx->attachments = null; ?>'. 
    5053           
    5154          "<?php } ?>\n"; 
     
    6063     { 
    6164          return 
    62           "<?php if (\$attach_i == 0) : ?>". 
     65          "<?php if (\$_ctx->attachments->isStart()) : ?>". 
    6366          $content. 
    6467          "<?php endif; ?>"; 
     
    7174     { 
    7275          return 
    73           "<?php if (\$attach_i+1 == count(\$_ctx->attachments)) : ?>". 
     76          "<?php if (\$_ctx->attachments->isEnd()) : ?>". 
    7477          $content. 
    7578          "<?php endif; ?>"; 
     
    9396          if (isset($attr['is_image'])) { 
    9497               $sign = (boolean) $attr['is_image'] ? '' : '!'; 
    95                $if[] = $sign.'$attach_f->media_image'; 
     98               $if[] = $sign.'$_ctx->attachments->media_image'; 
    9699          } 
    97100           
    98101          if (isset($attr['has_thumb'])) { 
    99102               $sign = (boolean) $attr['has_thumb'] ? '' : '!'; 
    100                $if[] = $sign.'isset($attach_f->media_thumb[\'sq\'])'; 
     103               $if[] = $sign.'isset($_ctx->attachments->media_thumb[\'sq\'])'; 
    101104          } 
    102105           
    103106          if (isset($attr['is_mp3'])) { 
    104107               $sign = (boolean) $attr['is_mp3'] ? '==' : '!='; 
    105                $if[] = '$attach_f->type '.$sign.' "audio/mpeg3"'; 
     108               $if[] = '$_ctx->attachments->type '.$sign.' "audio/mpeg3"'; 
    106109          } 
    107110           
     
    109112               $sign = (boolean) $attr['is_flv'] ? '' : '!'; 
    110113               $if[] = $sign. 
    111                     '($attach_f->type == "video/x-flv" || '. 
    112                     '$attach_f->type == "video/mp4" || '. 
    113                     '$attach_f->type == "video/x-m4v")'; 
     114                    '($_ctx->attachments->type == "video/x-flv" || '. 
     115                    '$_ctx->attachments->type == "video/mp4" || '. 
     116                    '$_ctx->attachments->type == "video/x-m4v")'; 
    114117          } 
    115118           
     
    127130     { 
    128131          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    129           return '<?php echo '.sprintf($f,'$attach_f->type').'; ?>'; 
     132          return '<?php echo '.sprintf($f,'$_ctx->attachments->type').'; ?>'; 
    130133     } 
    131134      
     
    136139     { 
    137140          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    138           return '<?php echo '.sprintf($f,'$attach_f->media_type').'; ?>'; 
     141          return '<?php echo '.sprintf($f,'$_ctx->attachments->media_type').'; ?>'; 
    139142     } 
    140143      
     
    145148     { 
    146149          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    147           return '<?php echo '.sprintf($f,'$attach_f->basename').'; ?>'; 
     150          return '<?php echo '.sprintf($f,'$_ctx->attachments->basename').'; ?>'; 
    148151     } 
    149152      
     
    158161          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    159162          if (!empty($attr['full'])) { 
    160                return '<?php echo '.sprintf($f,'$attach_f->size').'; ?>'; 
    161           } 
    162           return '<?php echo '.sprintf($f,'files::size($attach_f->size)').'; ?>'; 
     163               return '<?php echo '.sprintf($f,'$_ctx->attachments->size').'; ?>'; 
     164          } 
     165          return '<?php echo '.sprintf($f,'files::size($_ctx->attachments->size)').'; ?>'; 
    163166     } 
    164167      
     
    169172     { 
    170173          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    171           return '<?php echo '.sprintf($f,'$attach_f->media_title').'; ?>'; 
     174          return '<?php echo '.sprintf($f,'$_ctx->attachments->media_title').'; ?>'; 
    172175     } 
    173176      
     
    180183          return 
    181184          '<?php '. 
    182           'if (isset($attach_f->media_thumb[\'sq\'])) {'. 
    183                'echo '.sprintf($f,'$attach_f->media_thumb[\'sq\']').';'. 
     185          'if (isset($_ctx->attachments->media_thumb[\'sq\'])) {'. 
     186               'echo '.sprintf($f,'$_ctx->attachments->media_thumb[\'sq\']').';'. 
    184187          '}'. 
    185188          '?>'; 
     
    192195     { 
    193196          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    194           return '<?php echo '.sprintf($f,'$attach_f->file_url').'; ?>'; 
     197          return '<?php echo '.sprintf($f,'$_ctx->attachments->file_url').'; ?>'; 
    195198     } 
    196199      
Note: See TracChangeset for help on using the changeset viewer.

Sites map