Changeset 17780
- Timestamp:
- Sep 6, 2012, 10:24:41 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/rv_gmaps/trunk/admin/admin_boot.php
r17705 r17780 53 53 $template->append('element_set_global_plugins_actions', 54 54 array('ID' => 'geotag', 'NAME'=>l10n('Geotag'), 'CONTENT' => ' 55 <label> {\'Latitude\'|@translate}(-90=S to 90=N)55 <label>'.l10n('Latitude').' (-90=S to 90=N) 56 56 <input type="text" size="8" name="lat"> 57 57 </label> 58 <label> {\'Longitude\'|@translate}(-180=E to 180=W)58 <label>'.l10n('Longitude').' (-180=E to 180=W) 59 59 <input type="text" size="9" name="lon"> 60 60 </label> (Empty values will erase coordinates) … … 97 97 { 98 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 = ' 99 100 if (!isset($_POST['submit'])) 101 return; 102 103 $collection = explode(',', $_POST['element_ids']); 104 105 $datas = array(); 106 $errors = array(); 107 $form_errors = 0; 108 109 $query = ' 108 110 SELECT id, name 109 111 FROM '.IMAGES_TABLE.' 110 112 WHERE id IN ('.implode(',', $collection).') 111 113 ;'; 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 { 114 $result = pwg_query($query); 115 116 while ($row = pwg_db_fetch_assoc($result)) 117 { 118 if (!isset($_POST['lat-'.$row['id']])) 119 { 120 $form_errors++; 121 continue; 122 } 123 $error = false; 124 $data = array( 125 'id' => $row['id'], 126 'lat' => trim($_POST['lat-'.$row['id']]), 127 'lon' => trim($_POST['lon-'.$row['id']]) 128 ); 129 130 if ( strlen($data['lat'])>0 and strlen($data['lon'])>0 ) 131 { 132 if ( (double)$data['lat']>90 or (double)$data['lat']<-90 133 or (double)$data['lon']>180 or (double)$data['lon']<-180 ) 134 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 } 135 } 136 elseif ( strlen($data['lat'])==0 and strlen($data['lon'])==0 ) 137 { 138 // nothing 139 } 140 else 141 { 142 $error = true; 143 } 144 145 if ($error) 146 $errors[] = $row['name']; 147 else 148 $datas[] = $data; 149 } 150 151 mass_updates( 152 IMAGES_TABLE, 153 array( 154 'primary' => array('id'), 155 'update' => array('lat', 'lon') 156 ), 157 $datas 158 ); 159 160 if (count($errors)>0) 161 { 162 $page['errors'][] = 'Invalid lat or lon value for files: '.implode(', ', $errors); 163 } 164 if ($form_errors) 165 $page['errors'][] = 'Maps & Earth: Invalid form submission for '.$form_errors.' photos'; 157 166 } 158 167 … … 161 170 { 162 171 global $template, $conf, $page, $is_category, $category_info; 163 172 173 $template->set_prefilter('batch_manager_unit', 'rvm_prefilter_batch_manager_unit'); 174 164 175 $query = ' 165 176 SELECT id,lat,lon 166 177 FROM '.IMAGES_TABLE; 167 178 168 179 if ($is_category) 169 180 { 170 181 $category_info = get_cat_info($_SESSION['bulk_manager_filter']['category']); 171 182 172 183 $conf['order_by'] = $conf['order_by_inside_category']; 173 184 if (!empty($category_info['image_order'])) … … 201 212 $row['lat'] = preg_replace('#\.([0-9]*?)([0]+)$#', '.$1', $row['lat']); 202 213 $row['lon'] = preg_replace('#\.([0-9]*?)([0]+)$#', '.$1', $row['lon']); 203 214 204 215 $tpl_vars[ $row['id'] ] = array( 205 216 'LAT' => rtrim($row['lat'], '.'), … … 207 218 ); 208 219 } 209 220 210 221 $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> 222 } 223 224 function rvm_prefilter_batch_manager_unit($content) 225 { 226 $needle = '</table>'; 227 $pos = strpos($content, $needle); 228 if ($pos!==false) 229 { 230 $add = '<tr><td><strong>{\'Geotag\'|@translate}</strong></td> 219 231 <td> 220 232 <label>{\'Latitude\'|@translate} … … 225 237 </label> 226 238 </td> 227 </tr> 228 229 <tr> 230 '; 231 return str_replace($search, $add.$search, $content); 239 </tr>'; 240 $content = substr_replace($content, $add, $pos, 0); 241 } 242 return $content; 232 243 } 233 244 ?>
Note: See TracChangeset
for help on using the changeset viewer.