[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'; |
---|
[9069] | 9 | include (PHPWG_ROOT_PATH.'admin/batch_manager.php'); |
---|
[3447] | 10 | |
---|
[9069] | 11 | $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d photo', '%d photos', count($page['cat_elements_id']))); |
---|
[3447] | 12 | |
---|
[8367] | 13 | if ( isset($_POST['submit']) ) |
---|
[3447] | 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) |
---|
[8683] | 24 | array_push($page['errors'], l10n('Select at least one photo')); |
---|
[3447] | 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 | |
---|
[9069] | 58 | $specials_selected = null; |
---|
| 59 | foreach( array('caddie'=>'Caddie', 'recent'=>'Recent photos') as $k => $v) |
---|
| 60 | { |
---|
| 61 | $link = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$k; |
---|
| 62 | $template->append( |
---|
| 63 | 'specials', |
---|
| 64 | array( |
---|
| 65 | $link => l10n($v), |
---|
| 66 | ), |
---|
| 67 | true |
---|
| 68 | ); |
---|
| 69 | if ($k == $_GET['cat']) $specials_selected = $link; |
---|
| 70 | } |
---|
| 71 | $template->assign('specials_selected', $specials_selected); |
---|
[3447] | 72 | |
---|
| 73 | $query = ' |
---|
| 74 | SELECT id,name,uppercats,global_rank |
---|
| 75 | FROM '.CATEGORIES_TABLE.' |
---|
| 76 | ;'; |
---|
| 77 | $result = pwg_query($query); |
---|
| 78 | $categories = array(); |
---|
| 79 | $selecteds = array(); |
---|
| 80 | if (!empty($result)) |
---|
| 81 | { |
---|
[9069] | 82 | while ($row = mysql_fetch_assoc($result)) |
---|
| 83 | { |
---|
| 84 | $url = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$row['id']; |
---|
| 85 | if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url; |
---|
| 86 | $row['id']=$url; |
---|
| 87 | array_push($categories, $row); |
---|
| 88 | } |
---|
[3447] | 89 | } |
---|
| 90 | usort($categories, 'global_rank_compare'); |
---|
| 91 | display_select_categories($categories, $selecteds, 'categories', false); |
---|
| 92 | |
---|
| 93 | if (!empty($_GET['display'])) |
---|
| 94 | { |
---|
| 95 | if ('all' == $_GET['display']) |
---|
| 96 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
| 97 | else |
---|
| 98 | $page['nb_images'] = intval($_GET['display']); |
---|
| 99 | } |
---|
| 100 | else |
---|
| 101 | $page['nb_images'] = 20; |
---|
| 102 | |
---|
| 103 | if ( !empty($page['cat_elements_id']) ) |
---|
| 104 | { |
---|
| 105 | $nav_bar = create_navigation_bar( |
---|
| 106 | $admin_url.get_query_string_diff(array('start')), |
---|
| 107 | count($page['cat_elements_id']), |
---|
| 108 | $page['start'], |
---|
| 109 | $page['nb_images'] |
---|
| 110 | ); |
---|
[6472] | 111 | $template->assign('navbar', $nav_bar); |
---|
[3447] | 112 | } |
---|
| 113 | |
---|
| 114 | $images=array(); |
---|
| 115 | if ( !empty($page['cat_elements_id']) ) |
---|
| 116 | { |
---|
| 117 | $query=' |
---|
| 118 | SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.' |
---|
| 119 | WHERE id IN ('.implode(',',$page['cat_elements_id']).') |
---|
| 120 | '.$conf['order_by'].' |
---|
| 121 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
| 122 | ;'; |
---|
| 123 | $result = pwg_query($query); |
---|
| 124 | while ( $row=mysql_fetch_assoc($result) ) |
---|
| 125 | $images[] = $row; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | foreach ($images as $image) |
---|
| 129 | { |
---|
| 130 | $tpl_var = array_merge( $image, |
---|
| 131 | array( |
---|
| 132 | 'U_TN' => get_thumbnail_url($image), |
---|
| 133 | 'TITLE' => get_thumbnail_title($image) |
---|
| 134 | ) |
---|
| 135 | ); |
---|
| 136 | if ( isset($image['lat']) ) |
---|
| 137 | $tpl_var['U_MAP'] = rvm_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) ); |
---|
| 138 | $template->append('thumbnails', $tpl_var); |
---|
| 139 | } |
---|
| 140 | |
---|
| 141 | $template->assign( |
---|
| 142 | array( |
---|
| 143 | 'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display')) |
---|
| 144 | ) |
---|
| 145 | ); |
---|
| 146 | |
---|
| 147 | ?> |
---|