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

Last change on this file since 26298 was 26298, checked in by mistic100, 10 years ago

update for 2.6 + better calculation + option to force ratio
TODO: issue with PNG (unable to generate thumbnail with IM)

File size: 3.0 KB
RevLine 
[16937]1<?php
[26298]2defined('HEADER_MANAGER_PATH') or die ("Hacking attempt!");
[16937]3
4// +-----------------------------------------------------------------------+
5// | Basic checks                                                          |
6// +-----------------------------------------------------------------------+
7
8check_status(ACCESS_ADMINISTRATOR);
9
[24010]10check_input_parameter('cat_id', $_GET, false, PATTERN_ID, true);
[16937]11
12$admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id'];
13$self_url = HEADER_MANAGER_ADMIN.'-album&amp;cat_id='.$_GET['cat_id'];
14
15$query = '
16SELECT *
17  FROM '.CATEGORIES_TABLE.'
18  WHERE id = '.$_GET['cat_id'].'
19;';
20$category = pwg_db_fetch_assoc(pwg_query($query));
21
22if (!isset($category['id']))
23{
24  die("unknown album");
25}
26
[26298]27$cat_id = $_GET['cat_id'];
28
29
[16937]30// +-----------------------------------------------------------------------+
31// | Tabs                                                                  |
32// +-----------------------------------------------------------------------+
33
34include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
35$tabsheet = new tabsheet();
36$tabsheet->set_id('album');
37$tabsheet->select('headermanager');
38$tabsheet->assign();
39
[22857]40$page['active_menu'] = get_active_menu('album');
[16937]41
[22857]42
[16937]43// +-----------------------------------------------------------------------+
44// | Save Form                                                             |
45// +-----------------------------------------------------------------------+
46if (isset($_POST['save_banner']))
47{
[26298]48  if (!isset($_POST['image']) or $_POST['image'] == 'default')
[16937]49  {
50    $query = '
51DELETE FROM '.HEADER_MANAGER_TABLE.'
52  WHERE category_id = '.$cat_id.'
53;';
54    pwg_query($query);
55  }
56  else
57  {
58    $query = '
59INSERT INTO '.HEADER_MANAGER_TABLE.'(
60    category_id,
61    image,
62    deep
63  )
64  VALUES (
65    '.$cat_id.',
66    "'.$_POST['image'].'",
67    '.(int)isset($_POST['deep']).'
68  )
69  ON DUPLICATE KEY UPDATE
70    image = "'.$_POST['image'].'",
71    deep = '.(int)isset($_POST['deep']).'
72;';
73    pwg_query($query);
74  }
75}
76
77
78// +-----------------------------------------------------------------------+
79// | Display page                                                          |
80// +-----------------------------------------------------------------------+
81$query = '
82SELECT *
83  FROM '.HEADER_MANAGER_TABLE.'
84  WHERE category_id = '.$cat_id.'
85;';
86$result = pwg_query($query);
87
88if (pwg_db_num_rows($result))
89{
90  $cat_banner = pwg_db_fetch_assoc($result);
91  $banner = get_banner($cat_banner['image']);
92  if ($banner === false)
93  {
94    $cat_banner['image'] = 'default';
95  }
96}
97else
98{
99  $cat_banner = array(
100    'image' => 'default',
101    'deep' => 1,
102    );
103}
104
105$template->assign(array(
106  'banners' => list_banners(true),
107  'BANNER_IMAGE' => $cat_banner['image'],
108  'BANNER_DEEP' => $cat_banner['deep'],
109  'F_ACTION' => $self_url,
110  'CATEGORIES_NAV' => get_cat_display_name_cache(
111    $category['uppercats'],
112    HEADER_MANAGER_ADMIN.'-album&amp;cat_id='
113    ),
114));
115
[26298]116$template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/album.tpl'));
Note: See TracBrowser for help on using the repository browser.