root/trunk/inc/album.inc.php

Revision 15, 3.8 KB (checked in by alexx, 7 years ago)
  • fix last bug in communities (see [14])
  • execute a "conversion smarty style" script ;) : for i in find . -type f | grep "\.php$" | grep -v "\.svn"; do perl -pi -e "s/\\\$smarty->assign\((.*),(.*)\);/\\\$_SMARTY\[\$1\] = \$2;/" $i; done
Line 
1<?php
2/****************************************************** Open .node ***
3 * Description:   
4 * Status:        Stable.
5 * Author:        Alexandre Dath <alexandre@dotnode.com>
6 * $Id$
7 *
8 * Copyright (C) 2005 Alexandre Dath <alexandre@dotnode.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ******************** http://opensource.ikse.net/projects/dotnode ***/
24
25$_SMARTY['Title'] = 'Album';
26
27if($token[1] != 'view' || !is_numeric($token[2]) )
28{
29    $user['info'] = get_cache_user_info($url_id);
30
31    $user['photo'] = build_image_url($url_id);
32
33    /** Pagination ***************/
34    $pagination['nb_elements'] = $db->getOne('SELECT COUNT(id_image) FROM album WHERE id=?', array($url_id) );
35    $pagination['elmt_by_page'] = 12;
36    if($pagination['nb_elements'] > 0)
37        $pagination['nb_pages'] = ceil($pagination['nb_elements']/$pagination['elmt_by_page']);
38    else
39        $pagination['nb_pages'] = 1;
40
41    if(is_numeric($token[2]) &&
42            $token[2] <= $pagination['nb_pages'] &&
43            $token[2] > 0 )
44    {
45        $pagination['current_page'] = $token[2];
46        $pagination['last_page'] = $token[2]-1;
47    }
48    else
49    {
50        header('Location: /album/'.$url_id.'/page/1');
51        exit();
52    }
53
54    $pagination['pages'] = @array_fill(1,$pagination['nb_pages'], NULL);
55
56    $_SMARTY['pagination'] =  $pagination;
57    /******************************/
58
59
60    // *********** recuperation des infos generals ******************
61    $images = $db->query('SELECT id_image, width, height, format, caption FROM album WHERE id=? ORDER BY date DESC LIMIT !,!', array($url_id, ($pagination['current_page']-1)*$pagination['elmt_by_page'], $pagination['elmt_by_page']) );
62    while($image = $images->fetchRow())
63    {
64        $album['image'][$image['id_image']] = $image;
65
66        $album['image'][$image['id_image']]['path'] = build_album_url($url_id, $image['id_image'], $image['format']);
67        $album['image'][$image['id_image']]['thumb_path'] = build_album_thumb_url($url_id, $image['id_image']);
68
69        $wh_ratio = $image['width']/$image['height'];
70        if($wh_ratio>(160/160))
71        {
72            $thumb_width = 160;
73            $thumb_height = floor($image['height']*160/$image['width']);
74        }
75        else
76        {
77            $thumb_width = floor($image['width']*160/$image['height']);
78            $thumb_height = 160;
79        }
80
81        $album['image'][$image['id_image']]['thumb_width'] = $thumb_width;
82        $album['image'][$image['id_image']]['thumb_height'] = $thumb_height;
83    }
84}
85elseif(is_numeric($token[2]) )
86{
87    $_SMARTY['Title'] = 'Photo';
88
89        $image = $db->getRow('SELECT id_image, width, height, format, caption FROM album WHERE id=? ORDER BY date DESC LIMIT !,1', array($url_id, $token[2]-1) );
90    if(DB::isError($image))
91        error_log($image->getUserInfo());
92        $album['image'] = $image;
93        $album['image']['path'] = build_album_url($url_id, $image['id_image'], $image['format']);
94}
95
96/************* menu *******************/
97$leftmenu["/profile/$url_id"] = 'Profile';
98
99if($user['info']['nb_photos'] > 0)
100        $leftmenu["/album/$url_id"] = 'Album';
101
102if($user['info']['nb_blogs'] > 0)
103        $leftmenu["/blog/$url_id"] = 'Blog';
104
105if($user['info']['nb_bookmarks'] > 0)
106        $leftmenu["/bookmarks/$url_id"] = 'Bookmarks';
107
108$_SMARTY['leftmenu'] = $leftmenu;
109
110
111/************************************/
112
113$_SMARTY['user'] = $user;
114$_SMARTY['album'] = $album;
115
116
117?>
Note: See TracBrowser for help on using the browser.