source: extensions/PWG_Stuffs/trunk/modules/BestRated/main.inc.php @ 16690

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