[16937] | 1 | <?php |
---|
[26298] | 2 | defined('HEADER_MANAGER_PATH') or die ("Hacking attempt!"); |
---|
[16937] | 3 | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Basic checks | |
---|
| 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | |
---|
| 8 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 9 | |
---|
[24010] | 10 | check_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&cat_id='.$_GET['cat_id']; |
---|
| 14 | |
---|
| 15 | $query = ' |
---|
| 16 | SELECT * |
---|
| 17 | FROM '.CATEGORIES_TABLE.' |
---|
| 18 | WHERE id = '.$_GET['cat_id'].' |
---|
| 19 | ;'; |
---|
| 20 | $category = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 21 | |
---|
| 22 | if (!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 | |
---|
| 34 | include_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 | // +-----------------------------------------------------------------------+ |
---|
| 46 | if (isset($_POST['save_banner'])) |
---|
| 47 | { |
---|
[26298] | 48 | if (!isset($_POST['image']) or $_POST['image'] == 'default') |
---|
[16937] | 49 | { |
---|
| 50 | $query = ' |
---|
| 51 | DELETE FROM '.HEADER_MANAGER_TABLE.' |
---|
| 52 | WHERE category_id = '.$cat_id.' |
---|
| 53 | ;'; |
---|
| 54 | pwg_query($query); |
---|
| 55 | } |
---|
| 56 | else |
---|
| 57 | { |
---|
| 58 | $query = ' |
---|
| 59 | INSERT 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 = ' |
---|
| 82 | SELECT * |
---|
| 83 | FROM '.HEADER_MANAGER_TABLE.' |
---|
| 84 | WHERE category_id = '.$cat_id.' |
---|
| 85 | ;'; |
---|
| 86 | $result = pwg_query($query); |
---|
| 87 | |
---|
| 88 | if (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 | } |
---|
| 97 | else |
---|
| 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&cat_id=' |
---|
| 113 | ), |
---|
| 114 | )); |
---|
| 115 | |
---|
[26298] | 116 | $template->set_filename('header_manager', realpath(HEADER_MANAGER_PATH . 'admin/template/album.tpl')); |
---|