Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/thumbnails.php,v $
15
  $Revision: 1.6 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
define('IN_COPPERMINE', true);
21
define('THUMBNAILS_PHP', true);
22
define('INDEX_PHP', true);
23
 
24
require('include/init.inc.php');
25
if ($CONFIG['enable_smilies']) include("include/smilies.inc.php");
26
 
27
function get_subcat_data($parent, &$album_set_array, $level)
28
{
29
    global $CONFIG;
30
 
31
    $result = db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent'");
32
    if (mysql_num_rows($result) > 0) {
33
        $rowset = db_fetch_rowset($result);
34
        foreach ($rowset as $subcat) {
35
            $result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']}");
36
            $album_count = mysql_num_rows($result);
37
            while ($row = mysql_fetch_array($result)) {
38
                $album_set_array[] = $row['aid'];
39
            } // while
40
        }
41
        if ($level > 1) get_subcat_data($subcat['cid'], $album_set_array, $level -1);
42
    }
43
}
44
 
45
/**
46
 * Main code
47
 */
48
 
49
if (isset($HTTP_GET_VARS['sort'])) $USER['sort'] = $HTTP_GET_VARS['sort'];
50
if (isset($HTTP_GET_VARS['cat'])) $cat = (int)$HTTP_GET_VARS['cat'];
51
if (isset($HTTP_GET_VARS['uid'])) $USER['uid'] = (int)$HTTP_GET_VARS['uid'];
52
if (isset($HTTP_GET_VARS['search'])) {
53
    $USER['search'] = $HTTP_GET_VARS['search'];
54
    if (isset($HTTP_GET_VARS['type']) && $HTTP_GET_VARS['type'] == 'full') {
55
        $USER['search'] = '###' . $USER['search'];
56
    }
57
}
58
 
59
$album = $HTTP_GET_VARS['album'];
60
 
61
if (isset($HTTP_GET_VARS['page'])) {
62
    $page = max((int)$HTTP_GET_VARS['page'], 1);
63
} else {
64
    $page = 1;
65
}
66
 
67
$breadcrumb = '';
68
$breadcrumb_text = '';
69
$cat_data = array();
70
$lang_meta_album_names['lastupby'] = $lang_meta_album_names['lastup'];
71
$lang_meta_album_names['lastcomby'] = $lang_meta_album_names['lastcom'];
72
 
73
if (is_numeric($album)) {
74
    $result = db_query("SELECT category, title, aid, keyword, description FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='$album'");
75
    if (mysql_num_rows($result) > 0) {
76
        $CURRENT_ALBUM_DATA = mysql_fetch_array($result);
77
        $actual_cat = $CURRENT_ALBUM_DATA['category'];
78
        $CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];
79
        breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
80
        $cat = - $album;
81
    }
82
} elseif (isset($cat) && $cat) { // Meta albums, we need to restrict the albums to the current category
83
    if ($cat < 0) {
84
        $result = db_query("SELECT category, title, aid, keyword,description FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='" . (- $cat) . "'");
85
        if (mysql_num_rows($result) > 0) {
86
            $CURRENT_ALBUM_DATA = mysql_fetch_array($result);
87
            $actual_cat = $CURRENT_ALBUM_DATA['category'];
88
                $CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];
89
        }
90
 
91
        $ALBUM_SET .= 'AND aid IN (' . (- $cat) . ') ';
92
        breadcrumb($actual_cat, $breadcrumb, $breadcrumb_text);
93
        $CURRENT_CAT_NAME = $CURRENT_ALBUM_DATA['title'];
94
            $CURRENT_ALBUM_KEYWORD = $CURRENT_ALBUM_DATA['keyword'];
95
    } else {
96
        $album_set_array = array();
97
        if ($cat == USER_GAL_CAT)
98
            $where = 'category > ' . FIRST_USER_CAT;
99
        else
100
            $where = "category = '$cat'";
101
 
102
        $result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE $where");
103
        while ($row = mysql_fetch_array($result)) {
104
            $album_set_array[] = $row['aid'];
105
        } // while
106
        if ($cat >= FIRST_USER_CAT) {
107
            $user_name = get_username($cat - FIRST_USER_CAT);
108
            $CURRENT_CAT_NAME = sprintf($lang_list_categories['xx_s_gallery'], $user_name);
109
        } else {
110
            $result = db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
111
            if (mysql_num_rows($result) == 0) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
112
            $row = mysql_fetch_array($result);
113
            $CURRENT_CAT_NAME = $row['name'];
114
        }
115
        get_subcat_data($cat, $album_set_array, $CONFIG['subcat_level']);
116
        // Treat the album set
117
        if (count($album_set_array)) {
118
            $set = '';
119
            foreach ($album_set_array as $album_id) $set .= ($set == '') ? $album_id : ',' . $album_id;
120
            $ALBUM_SET .= "AND aid IN ($set) ";
121
        }
122
 
123
        breadcrumb($cat, $breadcrumb, $breadcrumb_text);
124
    }
125
}
126
 
127
pageheader(isset($CURRENT_ALBUM_DATA) ? $CURRENT_ALBUM_DATA['title'] : $lang_meta_album_names[$album]);
128
if ($breadcrumb) {
129
  if(!(strpos($CONFIG['main_page_layout'],"breadcrumb")===false)){
130
            theme_display_breadcrumb($breadcrumb, $cat_data);
131
        }
132
    theme_display_cat_list($breadcrumb, $cat_data, '');
133
}
134
 
135
display_thumbnails($album, (isset($cat) ? $cat : 0), $page, $CONFIG['thumbcols'], $CONFIG['thumbrows'], true);
136
pagefooter();
137
ob_end_flush();
138
?>