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

Last change on this file since 22857 was 22857, checked in by mistic100, 11 years ago

rename personal get_crop_display function to avoid conflicts

File size: 4.6 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$page['active_menu'] = get_active_menu('album');
60
61
62$cat_id = $_GET['cat_id'];
63
64
65// +-----------------------------------------------------------------------+
66// | Save Form                                                             |
67// +-----------------------------------------------------------------------+
68if (isset($_POST['save_banner']))
69{
70  if ( !isset($_POST['image']) or $_POST['image'] == 'default')
71  {
72    $query = '
73DELETE FROM '.HEADER_MANAGER_TABLE.'
74  WHERE category_id = '.$cat_id.'
75;';
76    pwg_query($query);
77  }
78  else
79  {
80    $query = '
81INSERT INTO '.HEADER_MANAGER_TABLE.'(
82    category_id,
83    image,
84    deep
85  )
86  VALUES (
87    '.$cat_id.',
88    "'.$_POST['image'].'",
89    '.(int)isset($_POST['deep']).'
90  )
91  ON DUPLICATE KEY UPDATE
92    image = "'.$_POST['image'].'",
93    deep = '.(int)isset($_POST['deep']).'
94;';
95    pwg_query($query);
96  }
97}
98
99
100// +-----------------------------------------------------------------------+
101// | Display page                                                          |
102// +-----------------------------------------------------------------------+
103$query = '
104SELECT *
105  FROM '.HEADER_MANAGER_TABLE.'
106  WHERE category_id = '.$cat_id.'
107;';
108$result = pwg_query($query);
109
110if (pwg_db_num_rows($result))
111{
112  $cat_banner = pwg_db_fetch_assoc($result);
113  $banner = get_banner($cat_banner['image']);
114  if ($banner === false)
115  {
116    $cat_banner['image'] = 'default';
117  }
118}
119else
120{
121  $cat_banner = array(
122    'image' => 'default',
123    'deep' => 1,
124    );
125}
126
127$template->assign(array(
128  'banners' => list_banners(true),
129  'BANNER_IMAGE' => $cat_banner['image'],
130  'BANNER_DEEP' => $cat_banner['deep'],
131  'F_ACTION' => $self_url,
132  'CATEGORIES_NAV' => get_cat_display_name_cache(
133    $category['uppercats'],
134    HEADER_MANAGER_ADMIN.'-album&amp;cat_id='
135    ),
136));
137
138$template->set_filename('header_manager', dirname(__FILE__).'/template/album.tpl');
139
140?>
Note: See TracBrowser for help on using the repository browser.