Ignore:
Timestamp:
10/15/11 17:16:32 (8 years ago)
Author:
patdenice
Message:

Use category_default.inc.php to generate template output for thumbnalis blocks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/PWG_Stuffs/trunk/modules/Recent/main.inc.php

    r12414 r12450  
    44 
    55global $page, $user, $conf, $template; 
     6 
     7$page_save = $page; 
     8$tpl_save = $template->get_template_vars('THUMBNAILS'); 
    69 
    710if (script_basename() == 'picture' 
     
    4447    LIMIT 0, '.$datas['nb_images'].' 
    4548  ;'; 
     49  
     50$page['items'] = array_from_query($query, 'id'); 
     51$page['start'] = 0; 
     52$page['nb_image_page'] = $datas['nb_images']; 
     53$page['section'] = 'best_rated'; 
    4654 
    47 $pictures = array(); 
    48 $selection = array_from_query($query, 'id'); 
    49   
    50 if (count($selection) > 0) 
     55include(PHPWG_ROOT_PATH.'include/category_default.inc.php'); 
     56 
     57if (!empty($tpl_thumbnails_var)) 
    5158{ 
    52   $query = ' 
    53 SELECT * 
    54   FROM '.IMAGES_TABLE.' 
    55   WHERE id IN ('.implode(',', $selection).') 
    56   ORDER BY  date_available DESC, id DESC 
    57 ;'; 
    58   $result = pwg_query($query); 
    59   while ($row = mysql_fetch_assoc($result)) 
    60   { 
    61     array_push($pictures, $row); 
    62   } 
    63 } 
    64  
    65 if (count($pictures) > 0) 
    66 { 
    67   if ($user['show_nb_comments']) 
    68   { 
    69     $query = ' 
    70 SELECT image_id, COUNT(*) AS nb_comments 
    71   FROM '.COMMENTS_TABLE.' 
    72   WHERE validated = \'true\' 
    73     AND image_id IN ('.implode(',', $selection).') 
    74   GROUP BY image_id 
    75 ;'; 
    76     $nb_comments_of = simple_hash_from_query($query, 'image_id', 'nb_comments'); 
    77   } 
    78  
    79   // template thumbnail initialization 
    80   trigger_action('loc_begin_index_thumbnails', $pictures); 
    81   $block['thumbnails'] = array(); 
    82  
    83   foreach ($pictures as $row) 
    84   { 
    85     // link on picture.php page 
    86     $url = duplicate_picture_url( 
    87           array( 
    88             'image_id' => $row['id'], 
    89             'image_file' => $row['file'] 
    90           ), 
    91           array('start') 
    92         ); 
    93     $url = add_url_params($url, array('pwgs_re' => implode(',',$selection))); 
    94  
    95     $tpl_var = 
    96       array( 
    97         'ID'        => $row['id'], 
    98         'TN_SRC'    => get_thumbnail_url($row), 
    99         'TN_ALT'    => $row['file'], 
    100         'TN_TITLE'  => get_thumbnail_title($row), 
    101         'ICON_TS'   => get_icon($row['date_available']), 
    102         'URL'       => $url, 
    103  
    104      /* Fields for template-extension usage */ 
    105         'FILE_PATH' => $row['path'], 
    106         'FILE_POSTED' => $row['date_available'], 
    107         'FILE_CREATED' => $row['date_creation'], 
    108         'FILE_DESC' => $row['comment'], 
    109         'FILE_AUTHOR' => $row['author'], 
    110         'FILE_HIT' => $row['hit'], 
    111         'FILE_SIZE' => $row['filesize'], 
    112         'FILE_WIDTH' => $row['width'], 
    113         'FILE_HEIGHT' => $row['height'], 
    114         'FILE_METADATE' => $row['date_metadata_update'], 
    115         'FILE_HAS_HD' => ($row['has_high'] and $user['enabled_high']=='true') ? 
    116                   true:false, /* lack of include/functions_picture.inc.php */ 
    117       ); 
    118  
    119     if ($user['show_nb_hits']) 
    120     { 
    121       $tpl_var['NB_HITS'] = $row['hit']; 
    122     } 
    123  
    124     if (isset($row['name']) and $row['name'] != '') 
    125     { 
    126       $name = $row['name']; 
    127     } 
    128     else 
    129     { 
    130       $name = str_replace('_', ' ', get_filename_wo_extension($row['file'])); 
    131     } 
    132  
    133     $tpl_var['NAME'] = $name; 
    134  
    135     if ( isset($nb_comments_of) ) 
    136     { 
    137       $tpl_var['NB_COMMENTS'] = (int)@$nb_comments_of[$row['id']]; 
    138     } 
    139  
    140     $block['thumbnails'][] = $tpl_var; 
    141   } 
    142  
    143   $block['thumbnails'] = trigger_event('loc_end_index_thumbnails', $block['thumbnails'], $pictures); 
    144  
     59  $block['thumbnails'] = $tpl_thumbnails_var; 
    14560  $block['TEMPLATE'] = 'stuffs_thumbnails.tpl'; 
    14661} 
    14762 
     63$page = $page_save; 
     64$template->assign('THUMBNAILS', $tpl_save); 
     65 
    14866?> 
Note: See TracChangeset for help on using the changeset viewer.