[3447] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | $admin_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
| 5 | |
---|
| 6 | if ( !isset($_GET['cat']) ) |
---|
| 7 | $_GET['cat'] = 'caddie'; |
---|
| 8 | $_GET['mode'] = 'map'; |
---|
| 9 | include (PHPWG_ROOT_PATH.'admin/element_set.php'); |
---|
| 10 | |
---|
| 11 | $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d element', '%d elements', count($page['cat_elements_id'])).' - '.$page['title']); |
---|
| 12 | |
---|
| 13 | if ( isset($_POST['submit']) and !is_adviser() ) |
---|
| 14 | { |
---|
| 15 | $collection = array(); |
---|
| 16 | |
---|
| 17 | switch ($_POST['target']) |
---|
| 18 | { |
---|
| 19 | case 'all' : |
---|
| 20 | $collection = $page['cat_elements_id']; |
---|
| 21 | break; |
---|
| 22 | case 'selection' : |
---|
| 23 | if (!isset($_POST['selection']) or count($_POST['selection']) == 0) |
---|
| 24 | array_push($page['errors'], l10n('Select at least one picture')); |
---|
| 25 | else |
---|
| 26 | $collection = $_POST['selection']; |
---|
| 27 | break; |
---|
| 28 | } |
---|
| 29 | if ( count($collection)>0 ) |
---|
| 30 | { |
---|
| 31 | $lat = trim($_POST['lat']); |
---|
| 32 | $lon = trim($_POST['lon']); |
---|
| 33 | |
---|
| 34 | if ( strlen($lat)>0 and strlen($lon)>0 ) |
---|
| 35 | { |
---|
| 36 | if ( (double)$lat<=90 and (double)$lat>=-90 |
---|
| 37 | and (double)$lon<=180 and (double)$lat>=-180 ) |
---|
| 38 | $update_query = 'lat='.$lat.', lon='.$lon; |
---|
| 39 | else |
---|
| 40 | $page['errors'][] = 'Invalid lat or lon value'; |
---|
| 41 | } |
---|
| 42 | elseif ( strlen($lat)==0 and strlen($lon)==0 ) |
---|
| 43 | $update_query = 'lat=NULL, lon=NULL'; |
---|
| 44 | else |
---|
| 45 | $page['errors'][] = 'Both lat/lon must be empty or not empty'; |
---|
| 46 | |
---|
| 47 | if (isset($update_query)) |
---|
| 48 | { |
---|
| 49 | $update_query = ' |
---|
| 50 | UPDATE '.IMAGES_TABLE.' SET '.$update_query.' |
---|
| 51 | WHERE id IN ('.implode(',',$collection).')'; |
---|
| 52 | pwg_query($update_query); |
---|
| 53 | rvm_invalidate_cache(); |
---|
| 54 | } |
---|
| 55 | } |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | |
---|
| 59 | $template->append( |
---|
| 60 | 'specials', |
---|
| 61 | array( |
---|
| 62 | $admin_url.get_query_string_diff(array('start','cat')).'&cat=caddie' => l10n('Caddie') |
---|
| 63 | ), |
---|
| 64 | true |
---|
| 65 | ); |
---|
| 66 | |
---|
| 67 | $query = ' |
---|
| 68 | SELECT id,name,uppercats,global_rank |
---|
| 69 | FROM '.CATEGORIES_TABLE.' |
---|
| 70 | ;'; |
---|
| 71 | $result = pwg_query($query); |
---|
| 72 | $categories = array(); |
---|
| 73 | $selecteds = array(); |
---|
| 74 | if (!empty($result)) |
---|
| 75 | { |
---|
| 76 | while ($row = mysql_fetch_assoc($result)) |
---|
| 77 | { |
---|
| 78 | $url = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$row['id']; |
---|
| 79 | if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url; |
---|
| 80 | $row['id']=$url; |
---|
| 81 | array_push($categories, $row); |
---|
| 82 | } |
---|
| 83 | } |
---|
| 84 | usort($categories, 'global_rank_compare'); |
---|
| 85 | display_select_categories($categories, $selecteds, 'categories', false); |
---|
| 86 | |
---|
| 87 | if (!empty($_GET['display'])) |
---|
| 88 | { |
---|
| 89 | if ('all' == $_GET['display']) |
---|
| 90 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
| 91 | else |
---|
| 92 | $page['nb_images'] = intval($_GET['display']); |
---|
| 93 | } |
---|
| 94 | else |
---|
| 95 | $page['nb_images'] = 20; |
---|
| 96 | |
---|
| 97 | if ( !empty($page['cat_elements_id']) ) |
---|
| 98 | { |
---|
| 99 | $nav_bar = create_navigation_bar( |
---|
| 100 | $admin_url.get_query_string_diff(array('start')), |
---|
| 101 | count($page['cat_elements_id']), |
---|
| 102 | $page['start'], |
---|
| 103 | $page['nb_images'] |
---|
| 104 | ); |
---|
| 105 | $template->assign('NAV_BAR', $nav_bar); |
---|
| 106 | } |
---|
| 107 | |
---|
| 108 | $images=array(); |
---|
| 109 | if ( !empty($page['cat_elements_id']) ) |
---|
| 110 | { |
---|
| 111 | $query=' |
---|
| 112 | SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.' |
---|
| 113 | WHERE id IN ('.implode(',',$page['cat_elements_id']).') |
---|
| 114 | '.$conf['order_by'].' |
---|
| 115 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
| 116 | ;'; |
---|
| 117 | $result = pwg_query($query); |
---|
| 118 | while ( $row=mysql_fetch_assoc($result) ) |
---|
| 119 | $images[] = $row; |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | foreach ($images as $image) |
---|
| 123 | { |
---|
| 124 | $tpl_var = array_merge( $image, |
---|
| 125 | array( |
---|
| 126 | 'U_TN' => get_thumbnail_url($image), |
---|
| 127 | 'TITLE' => get_thumbnail_title($image) |
---|
| 128 | ) |
---|
| 129 | ); |
---|
| 130 | if ( isset($image['lat']) ) |
---|
| 131 | $tpl_var['U_MAP'] = rvm_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) ); |
---|
| 132 | $template->append('thumbnails', $tpl_var); |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | $template->assign( |
---|
| 136 | array( |
---|
| 137 | 'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display')) |
---|
| 138 | ) |
---|
| 139 | ); |
---|
| 140 | |
---|
| 141 | ?> |
---|