source: extensions/header_manager/admin/album.php @ 17734

Last change on this file since 17734 was 16937, checked in by mistic100, 12 years ago

ability to define a specific banner for an album + apply to sub-cats
(needs Piwigo 2.4.2 for tabs)

File size: 4.5 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if(!defined("PHPWG_ROOT_PATH")) die ("Hacking attempt!");
25
26// +-----------------------------------------------------------------------+
27// | Basic checks                                                          |
28// +-----------------------------------------------------------------------+
29
30check_status(ACCESS_ADMINISTRATOR);
31
32check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
33
34$admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id'];
35$self_url = HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'];
36
37$query = '
38SELECT *
39  FROM '.CATEGORIES_TABLE.'
40  WHERE id = '.$_GET['cat_id'].'
41;';
42$category = pwg_db_fetch_assoc(pwg_query($query));
43
44if (!isset($category['id']))
45{
46  die("unknown album");
47}
48
49// +-----------------------------------------------------------------------+
50// | Tabs                                                                  |
51// +-----------------------------------------------------------------------+
52
53include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
54$tabsheet = new tabsheet();
55$tabsheet->set_id('album');
56$tabsheet->select('headermanager');
57$tabsheet->assign();
58
59
60$cat_id = $_GET['cat_id'];
61
62
63// +-----------------------------------------------------------------------+
64// | Save Form                                                             |
65// +-----------------------------------------------------------------------+
66if (isset($_POST['save_banner']))
67{
68  if ($_POST['image'] == 'default')
69  {
70    $query = '
71DELETE FROM '.HEADER_MANAGER_TABLE.'
72  WHERE category_id = '.$cat_id.'
73;';
74    pwg_query($query);
75  }
76  else
77  {
78    $query = '
79INSERT INTO '.HEADER_MANAGER_TABLE.'(
80    category_id,
81    image,
82    deep
83  )
84  VALUES (
85    '.$cat_id.',
86    "'.$_POST['image'].'",
87    '.(int)isset($_POST['deep']).'
88  )
89  ON DUPLICATE KEY UPDATE
90    image = "'.$_POST['image'].'",
91    deep = '.(int)isset($_POST['deep']).'
92;';
93    pwg_query($query);
94  }
95}
96
97
98// +-----------------------------------------------------------------------+
99// | Display page                                                          |
100// +-----------------------------------------------------------------------+
101$query = '
102SELECT *
103  FROM '.HEADER_MANAGER_TABLE.'
104  WHERE category_id = '.$cat_id.'
105;';
106$result = pwg_query($query);
107
108if (pwg_db_num_rows($result))
109{
110  $cat_banner = pwg_db_fetch_assoc($result);
111  $banner = get_banner($cat_banner['image']);
112  if ($banner === false)
113  {
114    $cat_banner['image'] = 'default';
115  }
116}
117else
118{
119  $cat_banner = array(
120    'image' => 'default',
121    'deep' => 1,
122    );
123}
124
125$template->assign(array(
126  'banners' => list_banners(true),
127  'BANNER_IMAGE' => $cat_banner['image'],
128  'BANNER_DEEP' => $cat_banner['deep'],
129  'F_ACTION' => $self_url,
130  'CATEGORIES_NAV' => get_cat_display_name_cache(
131    $category['uppercats'],
132    HEADER_MANAGER_ADMIN.'-album&amp;cat_id='
133    ),
134));
135
136$template->set_filename('header_manager', dirname(__FILE__).'/template/album.tpl');
137
138?>
Note: See TracBrowser for help on using the repository browser.