source: extensions/PWG_Stuffs/trunk/modules/MostVisited/main.inc.php @ 12450

Last change on this file since 12450 was 12450, checked in by patdenice, 13 years ago

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

File size: 1.7 KB
Line 
1<?php
2
3if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
4
5global $page, $user, $conf, $template;
6
7$page_save = $page;
8$tpl_save = $template->get_template_vars('THUMBNAILS');
9
10if (script_basename() == 'picture'
11  or ($datas['cat_display'] == 'wo_thumb' and !empty($page['items']))
12  or ($datas['cat_display'] == 'w_thumb' and empty($page['items']) and isset($page['category']))
13  or ($datas['cat_display'] == 'selected_cats' and isset($page['category']) and !in_array($page['category']['id'], $datas['cat_selection'])))
14{
15  return false;
16}
17
18$forbidden = get_sql_condition_FandF
19  (
20    array
21      (
22        'forbidden_categories' => 'ic.category_id',
23        'visible_categories' => 'ic.category_id',
24        'visible_images' => 'i.id'
25      ),
26    'AND'
27  );
28
29$query = '
30  SELECT DISTINCT (i.id)
31    FROM '.IMAGES_TABLE.' as i
32      INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
33      INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
34    WHERE i.hit > 0';
35
36if (isset($page['category']))
37{
38  $query .= '
39        AND ( c.uppercats LIKE \''.$page['category']['uppercats'].',%\' OR c.id = '.$page['category']['id'].' )
40  ';
41}
42
43$query .= '
44      '.$forbidden.'
45      ORDER BY i.hit DESC, i.file ASC
46    LIMIT 0, '.$datas['nb_images'].'
47  ;';
48
49$page['items'] = array_from_query($query, 'id');
50$page['start'] = 0;
51$page['nb_image_page'] = $datas['nb_images'];
52$page['section'] = 'most_visited';
53
54include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
55
56if (!empty($tpl_thumbnails_var))
57{
58  $block['thumbnails'] = $tpl_thumbnails_var;
59  $block['TEMPLATE'] = 'stuffs_thumbnails.tpl';
60}
61
62$page = $page_save;
63$template->assign('THUMBNAILS', $tpl_save);
64
65?>
Note: See TracBrowser for help on using the repository browser.