function update_modified() { global $error, $messages; $data = prepare_export(); if (!is_array($data)) { $error = sprintf(_('Error preparing data: %s.'), $data); return; } $update = array('node' => array(), 'way' => array(), 'relation' => array()); $count = 0; foreach ($data as $obj) { if (isset($obj['action']) && $obj['id'] > 0) { $update[$obj['type']][] = $obj['id']; $count++; } } if (!$count) { $error = _('Nothing is modified, not going to update everything'); return; } elseif ($count > MAX_REQUEST_OBJECTS) { $messages = sprintf(ngettext('%d object was modified, can update only %d of them (repeat for more).', '%d objects were modified, can update only %d of them (repeat for more).', $count), $count, MAX_REQUEST_OBJECTS); $count = MAX_REQUEST_OBJECTS; foreach (array('relation', 'way', 'node') as $type) { if (count($update[$type]) > $count) { array_splice($update[$type], $count); } $count = max(0, $count - count($update[$type])); } } $urls = array(); foreach ($update as $type => $ids) { if (count($ids)) { $urls[] = OSM_API_URL . $type . 's?' . $type . 's=' . implode(',', $ids); } } update_data_array($urls); }
$error = _('Please enter changeset comment.'); } else { if (oauth_upload(trim(isset($_REQUEST['comment']) ? $_REQUEST['comment'] : ''), $e)) { clear_data(); $text = ''; $validation = array(); $_REQUEST['comment'] = ''; } $loggedin = isset($_SESSION['osm_token']); } } elseif (isset($_REQUEST['check'])) { update_modified(); } $osccontent = ''; if (isset($_REQUEST['showosc']) && strlen($_REQUEST['showosc']) > 0) { $e = prepare_export(); if (is_array($e)) { $osccontent = create_osc($e, 1234); } else { $osccontent = sprintf(_('Error preparing data: %s.'), $e); } } // Restore map parameters $center = calculate_center(); $center_r = false; if (!$center && isset($_REQUEST['center']) && preg_match('/^-?\\d{1,2}(?:\\.\\d+)?,-?\\d{1,3}(?:\\.\\d+)?$/', $_REQUEST['center'])) { $center = explode(',', $_REQUEST['center']); $center_r = true; } $zoom = $center ? 17 : ($center_r ? 15 : 2); if (!$center) {
function get_export_csv($fields, $records, $type) { $filename = prepare_export($type, 'csv'); $file = fopen($filename, 'w+'); fputcsv($file, $fields); foreach ($records as $record) { fputcsv($file, $record); } fclose($file); return array('filepath' => $filename, 'contents' => file_get_contents($filename)); }