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

Revision 26298, 3.2 KB checked in by mistic100, 6 years ago (diff)

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

Line 
1<?php
2defined('HEADER_MANAGER_PATH') or die('Hacking attempt!');
3
4// change banner to last uploaded
5if (pwg_get_session_var('added_banner')!==null and $conf['header_manager']['image']!='random')
6{
7  $conf['header_manager']['image'] = pwg_get_session_var('added_banner');
8  conf_update_param('header_manager', serialize($conf['header_manager']));
9  pwg_unset_session_var('added_banner');
10}
11
12
13// save config
14if (isset($_POST['save_config']))
15{
16  if ($_POST['display'] == 'with_text')
17  {
18    $conf['page_banner'] = $_POST['conf_page_banner'];
19    conf_update_param('page_banner', $conf['page_banner']);
20  }
21 
22  $conf['header_manager'] = array(
23    'width' => $conf['header_manager']['width'],
24    'height' => $conf['header_manager']['height'],
25    'image' => @$_POST['image'],
26    'display' => $_POST['display'],
27    'banner_on_picture' => isset($_POST['banner_on_picture']),
28    );
29  conf_update_param('header_manager', serialize($conf['header_manager']));
30 
31  $page['infos'][] = l10n('Information data registered in database');
32}
33
34
35// delete banner
36if (isset($_GET['delete_banner']))
37{
38  $banner = get_banner($_GET['delete_banner']);
39  if ($banner !== false or @unlink($banner['PATH']))
40  {
41    @unlink($banner['THUMB']);
42   
43    if ($conf['header_manager']['image'] == $_GET['delete_banner'])
44    {
45      $conf['header_manager']['image'] = 'random';
46      conf_update_param('header_manager', serialize($conf['header_manager']));
47    }
48   
49    $query = '
50DELETE FROM '.HEADER_MANAGER_TABLE.'
51  WHERE image = "'.$_GET['delete_banner'].'"
52;';
53    pwg_query($query);
54   
55    $page['infos'][] = l10n('Banner deleted');
56  }
57  else
58  {
59    $page['warnings'][] = l10n('File/directory read error').' : ' . HEADER_MANAGER_DIR . $_GET['delete_banner'];
60  }
61}
62
63if (isset($_GET['delete_cat_banner']))
64{
65  $query = '
66DELETE FROM '.HEADER_MANAGER_TABLE.'
67  WHERE category_id = "'.$_GET['delete_cat_banner'].'"
68;';
69  pwg_query($query);
70}
71
72
73// album banners
74$query = '
75SELECT
76    id,
77    name,
78    permalink,
79    dir,
80    image,
81    deep
82  FROM '.HEADER_MANAGER_TABLE.' AS h
83    INNER JOIN '.CATEGORIES_TABLE.' AS c
84    ON h.category_id = c.id
85  ORDER BY global_rank ASC
86;';
87$categories = query2array($query, 'id');
88
89foreach ($categories as $category)
90{
91  $tpl_cat =
92    array(
93      'NAME'     => get_cat_display_name_from_id($category['id'], HEADER_MANAGER_ADMIN.'-album&amp;cat_id='),
94      'ID'       => $category['id'],
95      'IMAGE'    => get_filename_wo_extension($category['image']),
96      'DEEP'     => $category['deep'],
97      'U_DELETE' => HEADER_MANAGER_ADMIN.'-config&amp;delete_cat_banner='.$category['id'],
98    );
99 
100  $template->append('categories', $tpl_cat);
101}
102
103
104// config template
105if (empty($conf['header_manager']['image']) or get_banner($conf['header_manager']['image']) === false)
106{
107  $conf['header_manager']['image'] = 'random';
108}
109
110$template->assign(array(
111  'banners' => list_banners(true),
112  'CONF_PAGE_BANNER' => stripslashes(htmlspecialchars($conf['page_banner'])),
113  'BANNER_IMAGE' => $conf['header_manager']['image'],
114  'BANNER_DISPLAY' => $conf['header_manager']['display'],
115  'BANNER_ON_PICTURE' => $conf['header_manager']['banner_on_picture']
116  ));
117
118$template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/config.tpl'));
Note: See TracBrowser for help on using the repository browser.