Dotclear


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • plugins/attachments/_public.php

    r1179 r1266  
    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 = $core->media->getPostMedia($_ctx->posts->post_id, null, true);'."\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; ?>'. 
     45          '<?php $attach_i = 0; ?>'. // LEGACY 
     46          '<?php while ($_ctx->attachments->fetch()) : ?>'. 
     47           
     48          '<?php $GLOBALS[\'attach_i\'] = $attach_i; $attach_f = $_ctx->attachments; $GLOBALS[\'attach_f\'] = $attach_f;'. // LEGACY 
     49          '$_ctx->file_url = $attach_f->file_url; ?>'. // LEGACY 
    4850          $content. 
    49           '<?php endforeach; $_ctx->attachments = null; unset($attach_i,$attach_f,$_ctx->file_url); ?>'. 
     51          '<?php $attach_i++; ?>'. // LEGACY 
     52          '<?php endwhile; '. 
     53          '$_ctx->attachments = null; ?>'. 
    5054           
    5155          "<?php } ?>\n"; 
     
    6064     { 
    6165          return 
    62           "<?php if (\$attach_i == 0) : ?>". 
     66          "<?php if (\$_ctx->attachments->isStart()) : ?>". 
    6367          $content. 
    6468          "<?php endif; ?>"; 
     
    7175     { 
    7276          return 
    73           "<?php if (\$attach_i+1 == count(\$_ctx->attachments)) : ?>". 
     77          "<?php if (\$_ctx->attachments->isEnd()) : ?>". 
    7478          $content. 
    7579          "<?php endif; ?>"; 
     
    9397          if (isset($attr['is_image'])) { 
    9498               $sign = (boolean) $attr['is_image'] ? '' : '!'; 
    95                $if[] = $sign.'$attach_f->media_image'; 
     99               $if[] = $sign.'$_ctx->attachments->media_image'; 
    96100          } 
    97101           
    98102          if (isset($attr['has_thumb'])) { 
    99103               $sign = (boolean) $attr['has_thumb'] ? '' : '!'; 
    100                $if[] = $sign.'isset($attach_f->media_thumb[\'sq\'])'; 
     104               $if[] = $sign.'isset($_ctx->attachments->media_thumb[\'sq\'])'; 
    101105          } 
    102106           
    103107          if (isset($attr['is_mp3'])) { 
    104108               $sign = (boolean) $attr['is_mp3'] ? '==' : '!='; 
    105                $if[] = '$attach_f->type '.$sign.' "audio/mpeg3"'; 
     109               $if[] = '$_ctx->attachments->type '.$sign.' "audio/mpeg3"'; 
    106110          } 
    107111           
     
    109113               $sign = (boolean) $attr['is_flv'] ? '' : '!'; 
    110114               $if[] = $sign. 
    111                     '($attach_f->type == "video/x-flv" || '. 
    112                     '$attach_f->type == "video/mp4" || '. 
    113                     '$attach_f->type == "video/x-m4v")'; 
     115                    '($_ctx->attachments->type == "video/x-flv" || '. 
     116                    '$_ctx->attachments->type == "video/mp4" || '. 
     117                    '$_ctx->attachments->type == "video/x-m4v")'; 
    114118          } 
    115119           
     
    127131     { 
    128132          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    129           return '<?php echo '.sprintf($f,'$attach_f->type').'; ?>'; 
     133          return '<?php echo '.sprintf($f,'$_ctx->attachments->type').'; ?>'; 
    130134     } 
    131135      
     
    136140     { 
    137141          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    138           return '<?php echo '.sprintf($f,'$attach_f->media_type').'; ?>'; 
     142          return '<?php echo '.sprintf($f,'$_ctx->attachments->media_type').'; ?>'; 
    139143     } 
    140144      
     
    145149     { 
    146150          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    147           return '<?php echo '.sprintf($f,'$attach_f->basename').'; ?>'; 
     151          return '<?php echo '.sprintf($f,'$_ctx->attachments->basename').'; ?>'; 
    148152     } 
    149153      
     
    158162          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    159163          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)').'; ?>'; 
     164               return '<?php echo '.sprintf($f,'$_ctx->attachments->size').'; ?>'; 
     165          } 
     166          return '<?php echo '.sprintf($f,'files::size($_ctx->attachments->size)').'; ?>'; 
    163167     } 
    164168      
     
    169173     { 
    170174          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    171           return '<?php echo '.sprintf($f,'$attach_f->media_title').'; ?>'; 
     175          return '<?php echo '.sprintf($f,'$_ctx->attachments->media_title').'; ?>'; 
    172176     } 
    173177      
     
    180184          return 
    181185          '<?php '. 
    182           'if (isset($attach_f->media_thumb[\'sq\'])) {'. 
    183                'echo '.sprintf($f,'$attach_f->media_thumb[\'sq\']').';'. 
     186          'if (isset($_ctx->attachments->media_thumb[\'sq\'])) {'. 
     187               'echo '.sprintf($f,'$_ctx->attachments->media_thumb[\'sq\']').';'. 
    184188          '}'. 
    185189          '?>'; 
     
    192196     { 
    193197          $f = $GLOBALS['core']->tpl->getFilters($attr); 
    194           return '<?php echo '.sprintf($f,'$attach_f->file_url').'; ?>'; 
     198          return '<?php echo '.sprintf($f,'$_ctx->attachments->file_url').'; ?>'; 
    195199     } 
    196200      
Note: See TracChangeset for help on using the changeset viewer.

Sites map