Changeset 17705 for extensions
- Timestamp:
- Sep 3, 2012, 12:33:45 PM (12 years ago)
- Location:
- extensions/rv_gmaps/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/admin/admin_boot.php
r17286 r17705 53 53 $template->append('element_set_global_plugins_actions', 54 54 array('ID' => 'geotag', 'NAME'=>l10n('Geotag'), 'CONTENT' => ' 55 <label> Latitude(-90=S to 90=N)55 <label>{\'Latitude\'|@translate} (-90=S to 90=N) 56 56 <input type="text" size="8" name="lat"> 57 57 </label> 58 <label> Longitude(-180=E to 180=W)58 <label>{\'Longitude\'|@translate} (-180=E to 180=W) 59 59 <input type="text" size="9" name="lon"> 60 60 </label> (Empty values will erase coordinates) … … 73 73 { 74 74 if ( (double)$lat<=90 and (double)$lat>=-90 75 and (double)$lon<=180 and (double)$l at>=-180 )75 and (double)$lon<=180 and (double)$lon>=-180 ) 76 76 $update_query = 'lat='.$lat.', lon='.$lon; 77 77 else … … 92 92 } 93 93 } 94 95 add_event_handler('loc_begin_element_set_unit', 'rvm_loc_begin_element_set_unit'); 96 function rvm_loc_begin_element_set_unit() 97 { 98 global $page; 99 100 if (isset($_POST['submit'])) 101 { 102 $collection = explode(',', $_POST['element_ids']); 103 104 $datas = array(); 105 $errors = array(); 106 107 $query = ' 108 SELECT id, name 109 FROM '.IMAGES_TABLE.' 110 WHERE id IN ('.implode(',', $collection).') 111 ;'; 112 $result = pwg_query($query); 113 114 while ($row = pwg_db_fetch_assoc($result)) 115 { 116 $data = array(); 117 $error = false; 118 $data['id'] = $row['id']; 119 $data['lat'] = trim($_POST['lat-'.$row['id']]); 120 $data['lon'] = trim($_POST['lon-'.$row['id']]); 121 122 if ( strlen($data['lat'])>0 and strlen($data['lon'])>0 ) 123 { 124 if ( (double)$data['lat']>90 or (double)$data['lat']<-90 125 or (double)$data['lon']>180 or (double)$data['lon']<-180 ) 126 $error = true; 127 } 128 elseif ( strlen($data['lat'])==0 and strlen($data['lon'])==0 ) 129 { 130 // nothing 131 } 132 else 133 { 134 $error = true; 135 } 136 137 if ($error) 138 array_push($errors, $row['name']); 139 else 140 array_push($datas, $data); 141 } 142 143 mass_updates( 144 IMAGES_TABLE, 145 array( 146 'primary' => array('id'), 147 'update' => array('lat', 'lon') 148 ), 149 $datas 150 ); 151 152 if (count($errors)>0) 153 { 154 array_push($page['errors'], 'Invalid lat or lon value for files: '.implode(', ', $errors)); 155 } 156 } 157 } 158 159 add_event_handler('loc_end_element_set_unit', 'rvm_loc_end_element_set_unit'); 160 function rvm_loc_end_element_set_unit() 161 { 162 global $template, $conf, $page, $is_category, $category_info; 163 164 $query = ' 165 SELECT id,lat,lon 166 FROM '.IMAGES_TABLE; 167 168 if ($is_category) 169 { 170 $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']); 171 172 $conf['order_by'] = $conf['order_by_inside_category']; 173 if (!empty($category_info['image_order'])) 174 { 175 $conf['order_by'] = ' ORDER BY '.$category_info['image_order']; 176 } 177 178 $query.= ' 179 JOIN '.IMAGE_CATEGORY_TABLE.' ON id = image_id'; 180 } 181 182 $query.= ' 183 WHERE id IN ('.implode(',', $page['cat_elements_id']).')'; 184 185 if ($is_category) 186 { 187 $query.= ' 188 AND category_id = '.$_SESSION['bulk_manager_filter']['category']; 189 } 190 191 $query.= ' 192 '.$conf['order_by'].' 193 LIMIT '.$page['nb_images'].' OFFSET '.$page['start'].' 194 ;'; 195 $result = pwg_query($query); 196 197 $tpl_vars = array(); 198 while ($row = pwg_db_fetch_assoc($result)) 199 { 200 // remove last zeros for better display 201 $row['lat'] = preg_replace('#\.([0-9]*?)([0]+)$#', '.$1', $row['lat']); 202 $row['lon'] = preg_replace('#\.([0-9]*?)([0]+)$#', '.$1', $row['lon']); 203 204 $tpl_vars[ $row['id'] ] = array( 205 'LAT' => rtrim($row['lat'], '.'), 206 'LON' => rtrim($row['lon'], '.'), 207 ); 208 } 209 210 $template->assign('GEOTAG', $tpl_vars); 211 212 $template->set_prefilter('batch_manager_unit', 'rvm_prefilter_batch_manager_unit'); 213 } 214 215 function rvm_prefilter_batch_manager_unit($content, &$smarty) 216 { 217 $search = '<td><strong>{\'Who can see this photo?\'|@translate}</strong></td>'; 218 $add = '<td><strong>{\'Geotag\'|@translate}</strong></td> 219 <td> 220 <label>{\'Latitude\'|@translate} 221 <input type="text" size="8" name="lat-{$element.ID}" value="{$GEOTAG[$element.ID].LAT}"> 222 </label> 223 <label>{\'Longitude\'|@translate} 224 <input type="text" size="9" name="lon-{$element.ID}" value="{$GEOTAG[$element.ID].LON}"> 225 </label> 226 </td> 227 </tr> 228 229 <tr> 230 '; 231 return str_replace($search, $add.$search, $content); 232 } 94 233 ?> -
extensions/rv_gmaps/trunk/language/en_UK/lang.php
r17286 r17705 26 26 $lang['Not geotagged']='Not geotagged'; 27 27 $lang['Geotag']='Geotag'; 28 $lang['Latitude'] = 'Latitude'; 29 $lang['Longitude'] = 'Longitude'; 28 30 ?>
Note: See TracChangeset
for help on using the changeset viewer.