[17882] | 1 | <?php |
---|
| 2 | if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $template, $page, $conf; |
---|
| 5 | |
---|
| 6 | if (strpos($_GET['tab'], 'album-') !== false) |
---|
| 7 | { |
---|
| 8 | $_GET['cat_id'] = substr($_GET['tab'], 6); |
---|
| 9 | } |
---|
| 10 | else |
---|
| 11 | { |
---|
| 12 | die('Hacking attempt!'); |
---|
| 13 | } |
---|
| 14 | |
---|
| 15 | // +-----------------------------------------------------------------------+ |
---|
| 16 | // | Basic checks | |
---|
| 17 | // +-----------------------------------------------------------------------+ |
---|
| 18 | check_status(ACCESS_ADMINISTRATOR); |
---|
| 19 | |
---|
| 20 | check_input_parameter('cat_id', $_GET, false, PATTERN_ID); |
---|
| 21 | |
---|
| 22 | $admin_album_base_url = get_root_url().'admin.php?page=album-'.$_GET['cat_id']; |
---|
| 23 | $self_url = LINKEDPAGES_ADMIN.'-album-'.$_GET['cat_id']; |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | // +-----------------------------------------------------------------------+ |
---|
| 27 | // | Init | |
---|
| 28 | // +-----------------------------------------------------------------------+ |
---|
| 29 | $query = ' |
---|
| 30 | SELECT * |
---|
| 31 | FROM '.CATEGORIES_TABLE.' |
---|
| 32 | WHERE id = '.$_GET['cat_id'].' |
---|
| 33 | ;'; |
---|
| 34 | $category = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 35 | |
---|
| 36 | if (!isset($category['id'])) |
---|
| 37 | { |
---|
| 38 | die("unknown album"); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); |
---|
| 42 | $tabsheet = new tabsheet(); |
---|
| 43 | $tabsheet->set_id('album'); |
---|
| 44 | $tabsheet->select('linked_pages'); |
---|
| 45 | $tabsheet->assign(); |
---|
| 46 | |
---|
[22866] | 47 | $page['active_menu'] = get_active_menu('album'); |
---|
| 48 | |
---|
[17882] | 49 | load_language('plugin.lang', AP_PATH); |
---|
| 50 | $languages = get_languages(); |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | // +-----------------------------------------------------------------------+ |
---|
| 54 | // | Save pages | |
---|
| 55 | // +-----------------------------------------------------------------------+ |
---|
| 56 | if (isset($_POST['save_pages'])) |
---|
| 57 | { |
---|
| 58 | $query = ' |
---|
| 59 | DELETE FROM '.LINKEDPAGES_TABLE.' |
---|
| 60 | WHERE category_id = '.$_GET['cat_id'].' |
---|
| 61 | ;'; |
---|
| 62 | pwg_query($query); |
---|
| 63 | |
---|
| 64 | if (isset($_POST['position'])) |
---|
| 65 | { |
---|
| 66 | $inserts = array(); |
---|
| 67 | foreach ($_POST['position'] as $page_id => $pos) |
---|
| 68 | { |
---|
| 69 | array_push($inserts, array( |
---|
| 70 | 'category_id' => $_GET['cat_id'], |
---|
| 71 | 'page_id' => $page_id, |
---|
| 72 | 'pos' => $pos, |
---|
| 73 | )); |
---|
| 74 | } |
---|
| 75 | |
---|
[17888] | 76 | mass_inserts( |
---|
[17882] | 77 | LINKEDPAGES_TABLE, |
---|
| 78 | array('category_id','page_id','pos'), |
---|
| 79 | $inserts |
---|
| 80 | ); |
---|
| 81 | } |
---|
[17926] | 82 | |
---|
| 83 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
[17882] | 84 | } |
---|
| 85 | |
---|
| 86 | // +-----------------------------------------------------------------------+ |
---|
| 87 | // | Get pages | |
---|
| 88 | // +-----------------------------------------------------------------------+ |
---|
| 89 | $query = ' |
---|
| 90 | SELECT |
---|
| 91 | lp.*, |
---|
| 92 | ap.lang, |
---|
| 93 | ap.title, |
---|
| 94 | ap.standalone, |
---|
| 95 | ap.permalink |
---|
| 96 | FROM '.LINKEDPAGES_TABLE.' AS lp |
---|
| 97 | INNER JOIN '.ADD_PAGES_TABLE.' AS ap |
---|
| 98 | ON lp.page_id = ap.id |
---|
| 99 | WHERE category_id = '.$_GET['cat_id'].' |
---|
| 100 | ORDER BY lp.pos |
---|
| 101 | '; |
---|
| 102 | $result = pwg_query($query); |
---|
| 103 | |
---|
| 104 | $cat_pages = array(); |
---|
| 105 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 106 | { |
---|
| 107 | $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['page_id']); |
---|
| 108 | $row['title'] = trigger_event('AP_render_title', $row['title']); |
---|
| 109 | $row['language'] = @$languages[$row['lang']]; |
---|
| 110 | $cat_pages[$row['page_id']] = $row; |
---|
| 111 | } |
---|
| 112 | $template->assign('cat_pages', $cat_pages); |
---|
| 113 | |
---|
| 114 | $query = ' |
---|
| 115 | SELECT |
---|
| 116 | id, |
---|
| 117 | lang, |
---|
| 118 | title, |
---|
| 119 | standalone, |
---|
| 120 | permalink |
---|
| 121 | FROM '.ADD_PAGES_TABLE.' |
---|
| 122 | '.(!empty($conf['AP']['homepage']) ? 'WHERE id != '.$conf['AP']['homepage'] : null).' |
---|
| 123 | ORDER BY title ASC |
---|
| 124 | ;'; |
---|
| 125 | $result = pwg_query($query); |
---|
| 126 | |
---|
| 127 | while ($row = pwg_db_fetch_assoc($result)) |
---|
| 128 | { |
---|
| 129 | if (array_key_exists($row['id'], $cat_pages)) |
---|
| 130 | { |
---|
| 131 | $row['disabled'] = 'disabled="disabled"'; |
---|
| 132 | } |
---|
| 133 | $row['U_PAGE'] = make_index_url(array('section'=>'page')).'/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']); |
---|
| 134 | $row['title'] = trigger_event('AP_render_title', $row['title']); |
---|
| 135 | $row['language'] = @$languages[$row['lang']]; |
---|
| 136 | $template->append('pages', $row); |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | // +-----------------------------------------------------------------------+ |
---|
| 141 | // | Template | |
---|
| 142 | // +-----------------------------------------------------------------------+ |
---|
| 143 | $template->assign(array( |
---|
| 144 | 'F_ACTION' => $self_url, |
---|
| 145 | 'CATEGORIES_NAV' => get_cat_display_name_cache( |
---|
| 146 | $category['uppercats'], |
---|
| 147 | LINKEDPAGES_ADMIN.'-album-' |
---|
| 148 | ), |
---|
| 149 | 'LINKEDPAGES_PATH'=> get_root_url() . LINKEDPAGES_PATH, |
---|
[23218] | 150 | 'AP_ADMIN' => get_root_url() . 'admin.php?page=plugin-' . AP_DIR |
---|
[17882] | 151 | )); |
---|
| 152 | |
---|
| 153 | $template->set_filename('linked_pages_content', realpath(LINKEDPAGES_PATH . 'template/admin_album.tpl')); |
---|
| 154 | $template->assign_var_from_handle('ADMIN_CONTENT', 'linked_pages_content'); |
---|
| 155 | |
---|
| 156 | ?> |
---|