[4545] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | global $lang; |
---|
| 4 | load_language('lang', dirname(__FILE__).'/../'); |
---|
| 5 | $admin_url = PHPWG_ROOT_PATH.'admin.php'; |
---|
| 6 | |
---|
[8501] | 7 | if ( !isset($_GET['cat']) ) $_GET['cat'] = 'caddie'; |
---|
| 8 | $_GET['mode'] = 'map'; |
---|
| 9 | include (PHPWG_ROOT_PATH.'admin/element_set.php'); |
---|
| 10 | $template->concat('TABSHEET_TITLE', ' '.l10n_dec('%d image', '%d images', count($page['cat_elements_id'])).' - '.$page['title']); |
---|
| 11 | if ( isset($_POST['submit']) and !is_adviser() ) |
---|
| 12 | { |
---|
| 13 | $collection = array(); |
---|
| 14 | if( !isset ($_POST['target'])) |
---|
| 15 | { |
---|
| 16 | $_POST['submit'] == l10n('Submit') ; |
---|
| 17 | $_POST['target']='selection'; |
---|
| 18 | $collection = $_POST['selection']; |
---|
| 19 | |
---|
| 20 | } |
---|
| 21 | |
---|
| 22 | switch ($_POST['target']) |
---|
| 23 | { |
---|
| 24 | case 'all' : |
---|
| 25 | $collection = $page['cat_elements_id']; |
---|
| 26 | break; |
---|
| 27 | case 'selection' : |
---|
| 28 | if (!isset($_POST['selection']) or count($_POST['selection']) == 0) |
---|
| 29 | array_push($page['errors'], l10n('Select at least one picture')); |
---|
| 30 | else |
---|
| 31 | $collection = $_POST['selection']; |
---|
| 32 | break; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | // test si mise à jour (valider) |
---|
| 37 | if ( isset($_POST['submit']) and $_POST['submit'] == l10n('Submit') ) |
---|
| 38 | { |
---|
| 39 | if ( count($collection)>0 ) |
---|
| 40 | { |
---|
| 41 | $lat = trim($_POST['lat']); |
---|
| 42 | $lon = trim($_POST['lon']); |
---|
| 43 | |
---|
| 44 | if ( strlen($lat)>0 and strlen($lon)>0 ) |
---|
| 45 | { |
---|
| 46 | if ( (double)$lat<=90 and (double)$lat>=-90 |
---|
| 47 | and (double)$lon<=180 and (double)$lat>=-180 ) |
---|
| 48 | $update_query = 'lat='.$lat.', lon='.$lon; |
---|
| 49 | else |
---|
| 50 | $page['errors'][] = 'Invalid lat or lon value'; |
---|
| 51 | } |
---|
| 52 | elseif ( strlen($lat)==0 and strlen($lon)==0 ) |
---|
| 53 | $update_query = 'lat=NULL, lon=NULL'; |
---|
| 54 | else |
---|
| 55 | $page['errors'][] = 'Both lat/lon must be empty or not empty'; |
---|
| 56 | |
---|
| 57 | if (isset($update_query)) |
---|
| 58 | { |
---|
| 59 | $update_query = ' |
---|
| 60 | UPDATE '.IMAGES_TABLE.' SET '.$update_query.' |
---|
| 61 | WHERE id IN ('.implode(',',$collection).')'; |
---|
| 62 | pwg_query($update_query); |
---|
| 63 | rvm_invalidate_cache(); |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | $template->append( |
---|
| 71 | 'specials', |
---|
| 72 | array( |
---|
| 73 | $admin_url.get_query_string_diff(array('start','cat')).'&cat=caddie' => l10n('Caddie') |
---|
| 74 | ), |
---|
| 75 | true |
---|
| 76 | ); |
---|
| 77 | |
---|
| 78 | $query = ' |
---|
| 79 | SELECT id,name,uppercats,global_rank |
---|
| 80 | FROM '.CATEGORIES_TABLE.' |
---|
| 81 | ;'; |
---|
| 82 | $result = pwg_query($query); |
---|
| 83 | $categories = array(); |
---|
| 84 | $selecteds = array(); |
---|
| 85 | if (!empty($result)) |
---|
| 86 | { |
---|
| 87 | while ($row = mysql_fetch_assoc($result)) |
---|
| 88 | { |
---|
| 89 | $url = $admin_url.get_query_string_diff(array('start','cat')).'&cat='.$row['id']; |
---|
| 90 | if ( $row['id']==$_GET['cat'] ) $selecteds[] = $url; |
---|
| 91 | $row['id']=$url; |
---|
| 92 | array_push($categories, $row); |
---|
| 93 | } |
---|
| 94 | } |
---|
| 95 | usort($categories, 'global_rank_compare'); |
---|
| 96 | display_select_categories($categories, $selecteds, 'categories', false); |
---|
| 97 | |
---|
| 98 | if (!empty($_GET['display'])) |
---|
| 99 | { |
---|
| 100 | if ('all' == $_GET['display']) |
---|
| 101 | $page['nb_images'] = count($page['cat_elements_id']); |
---|
| 102 | else |
---|
| 103 | $page['nb_images'] = intval($_GET['display']); |
---|
| 104 | } |
---|
| 105 | else |
---|
| 106 | $page['nb_images'] = 20; |
---|
| 107 | |
---|
| 108 | if ( !empty($page['cat_elements_id']) ) |
---|
| 109 | { |
---|
| 110 | $nav_bar = create_navigation_bar( |
---|
| 111 | $admin_url.get_query_string_diff(array('start')), |
---|
| 112 | count($page['cat_elements_id']), |
---|
| 113 | $page['start'], |
---|
| 114 | $page['nb_images'] |
---|
| 115 | ); |
---|
| 116 | $template->assign('navbar', $nav_bar); |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | $images=array(); |
---|
| 120 | if ( !empty($page['cat_elements_id']) ) |
---|
| 121 | { |
---|
| 122 | $query=' |
---|
| 123 | SELECT id,tn_ext,name,path,file,lat,lon FROM '.IMAGES_TABLE.' |
---|
| 124 | WHERE id IN ('.implode(',',$page['cat_elements_id']).') |
---|
| 125 | '.$conf['order_by'].' |
---|
| 126 | LIMIT '.$page['start'].', '.$page['nb_images'].' |
---|
| 127 | ;'; |
---|
| 128 | $result = pwg_query($query); |
---|
| 129 | while ( $row=mysql_fetch_assoc($result) ) |
---|
| 130 | $images[] = $row; |
---|
| 131 | } |
---|
| 132 | |
---|
| 133 | foreach ($images as $image) |
---|
| 134 | { |
---|
| 135 | $tpl_var = array_merge( $image, |
---|
| 136 | array( |
---|
| 137 | 'U_TN' => get_thumbnail_url($image), |
---|
| 138 | 'TITLE' => get_thumbnail_title($image) |
---|
| 139 | ) |
---|
| 140 | ); |
---|
| 141 | if ( isset($image['lat']) ) |
---|
[8586] | 142 | $tpl_var['U_MAP'] = cl_make_map_picture_url( array('image_id'=>$image['id'], 'image_file'=>$image['file']) ); |
---|
[8501] | 143 | $template->append('thumbnails', $tpl_var); |
---|
| 144 | } |
---|
| 145 | |
---|
| 146 | $template->assign( |
---|
| 147 | array( |
---|
| 148 | 'U_DISPLAY'=> $admin_url.get_query_string_diff(array('display')) |
---|
| 149 | ) |
---|
| 150 | ); |
---|
[4545] | 151 | |
---|
[8501] | 152 | //========================================================== |
---|
| 153 | if (!defined('EDIT_RV_ROOT')) define( 'EDIT_RV_ROOT', PHPWG_PLUGINS_PATH.'edit_gmaps/admin/' ); |
---|
| 154 | $path = EDIT_RV_PATH; |
---|
| 155 | $plg_data = implode( '', file($path.'main.inc.php') ); |
---|
| 156 | if (preg_match("|Version: (.*)|", $plg_data, $val)) |
---|
| 157 | { $edit_rv_plugin['version'] = trim($val[1]); } |
---|
| 158 | $edit_rv_plugin = array_map('htmlspecialchars', $edit_rv_plugin); |
---|
| 159 | $version= $edit_rv_plugin['version'] ; |
---|
| 160 | $icon_path = 'themes/default/icon/help.png'; |
---|
| 161 | $path_js= 'themes/default/js/' ; |
---|
[4545] | 162 | |
---|
[8501] | 163 | //================================================================================== |
---|
| 164 | $match=""; |
---|
[4545] | 165 | if ( isset($_POST['submit']) and !is_adviser() ) |
---|
[8501] | 166 | { |
---|
[4545] | 167 | |
---|
[8501] | 168 | if ($_POST['submit']==l10n('Submit') ) |
---|
| 169 | { |
---|
| 170 | $_POST['selection']=array(); |
---|
| 171 | $collection =array(); |
---|
| 172 | unset($collection); |
---|
[4545] | 173 | } |
---|
[8501] | 174 | |
---|
[4545] | 175 | |
---|
[8501] | 176 | if ($_POST['submit']==l10n('reset' ) ) |
---|
| 177 | { |
---|
| 178 | $_POST['selection']=array(); |
---|
| 179 | unset($collection); |
---|
| 180 | } |
---|
[4545] | 181 | |
---|
[8456] | 182 | |
---|
[4545] | 183 | } |
---|
[8501] | 184 | //================================================================================= |
---|
| 185 | $src=""; |
---|
| 186 | $template->assign( |
---|
| 187 | array( 'EDIT_RV_ROOT' => EDIT_RV_ROOT, |
---|
| 188 | 'path_js' => $path_js, |
---|
| 189 | 'VERSION'=> $version, |
---|
| 190 | ) |
---|
[4545] | 191 | ); |
---|
[8501] | 192 | global $lang_info; |
---|
| 193 | if (date_default_timezone_get()) { $adresse = date_default_timezone_get() ;} |
---|
| 194 | else{ |
---|
[4545] | 195 | |
---|
| 196 | } |
---|
[8501] | 197 | $adresse = $lang_info['country']; ; |
---|
| 198 | $adresse=str_replace("/",", ",$adresse); |
---|
| 199 | $template->assign( 'coordinates', |
---|
| 200 | array('LAT' => '100', |
---|
| 201 | 'LON' => '100', |
---|
| 202 | 'ADRESSE' => $adresse, |
---|
| 203 | 'ZOOM' => 18, |
---|
| 204 | ) |
---|
| 205 | ); |
---|
| 206 | if (isset($_POST['submit']) and $_POST['submit']==l10n('selection' )) |
---|
[4545] | 207 | { |
---|
| 208 | |
---|
| 209 | if (isset($collection)) |
---|
| 210 | { |
---|
| 211 | $lat =1000; |
---|
| 212 | foreach ($collection as $id_0) { |
---|
| 213 | foreach ($images as $image) { |
---|
[8501] | 214 | if (array_search($id_0,$image)) { |
---|
| 215 | $_POST['selection'] = $collection ; |
---|
[4545] | 216 | |
---|
[8501] | 217 | if ($lat==1000) { |
---|
| 218 | $lat1= ($image['lat'] <> '') ? $image['lat'] : '100' ; |
---|
| 219 | $lon1= ($image['lon'] <> '') ? $image['lon'] : '3.0' ; |
---|
| 220 | if($lat1 != '100') $lat=$image['lat']; |
---|
| 221 | |
---|
[8456] | 222 | $template->assign( 'coordinates', |
---|
[8501] | 223 | array('LAT' => $lat1 , |
---|
| 224 | 'LON' => $lon1 , |
---|
| 225 | 'ADRESSE' => $adresse , |
---|
| 226 | 'ZOOM' => 4, |
---|
[8456] | 227 | ) |
---|
| 228 | ); |
---|
| 229 | |
---|
| 230 | } |
---|
[8501] | 231 | |
---|
[4545] | 232 | $tpl_var = array_merge( |
---|
| 233 | $image, |
---|
| 234 | array( |
---|
[8501] | 235 | 'lat' => $image['lat'] , |
---|
| 236 | 'lon' => $image['lon'] , |
---|
| 237 | 'adresse' => $adresse , |
---|
[4545] | 238 | 'U_TN' => get_thumbnail_url($image), |
---|
| 239 | 'TITLE' => get_thumbnail_title($image), |
---|
[8586] | 240 | 'U_MAP' => cl_make_map_picture_url( |
---|
[4545] | 241 | array( |
---|
| 242 | 'image_id'=>$image['id'], |
---|
| 243 | 'image_file'=>$image['file'], |
---|
| 244 | ) |
---|
| 245 | |
---|
| 246 | ), |
---|
| 247 | ) |
---|
| 248 | ); |
---|
[8501] | 249 | |
---|
| 250 | $template->append('Selectthumbnails', $tpl_var); |
---|
| 251 | } |
---|
| 252 | } |
---|
| 253 | } |
---|
| 254 | } |
---|
[4545] | 255 | } |
---|
| 256 | |
---|
| 257 | //======================================================================= |
---|
[8586] | 258 | function cl_make_map_picture_url($params) |
---|
| 259 | { |
---|
| 260 | global $conf; |
---|
| 261 | /*if ( empty($conf['gmaps_api_key']) and $_SERVER['SERVER_ADDR']!='127.0.0.1' ) |
---|
| 262 | return "";*/ |
---|
| 263 | $map_url = make_picture_url($params); |
---|
| 264 | return add_url_params($map_url, array('map'=>null) ); |
---|
| 265 | } |
---|
[4545] | 266 | ?> |
---|