All right. I finally figured out how to add coordinate info to a file via upload.php. It's been stumping me since v1 of this mod.
If you as admin are the only one uploading files and you use batch uploading only, you do NOT need to make this modification. This applies to people who allow non-admin users to upload via the upload form, or use the form as admin.
Open include/picmgmt.php
FIND:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
REPLACE with:
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $latitude = '', $longitude = '', $category = 0, $raw_ip = '', $hdr_ip = '', $iwidth = 0, $iheight = 0)
FIND:
$CURRENT_PIC_DATA['user4'] = $user4;
AFTER it, ADD:
$CURRENT_PIC_DATA['latitude'] = $latitude;
$CURRENT_PIC_DATA['longitude'] = $longitude;
FIND:
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";
REPLACE with:
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, latitude, longitude, pic_raw_ip, pic_hdr_ip, position) VALUES ('{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['latitude']}', '{$CURRENT_PIC_DATA['longitude']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";
-----
Open upload.php
FIND:
define('ADMIN_PHP', true);
AFTER it, ADD:
define('GMAP_PHP', true);
FIND:
// The file input function. Takes the label, field name, and number of iterations as arguments.
BEFORE it, ADD:
function text_box_input_gmap($text, $name, $max_length, $latitude, $longitude) {
global $CONFIG;
global $coordinates, $latitude, $longitude;
// Create a text box.
echo <<<EOT
<tr>
<td width="40%" class="tableb">
$text
</td>
<td width="60%" class="tableb" valign="top">
<input type="text" style="width: 100%" name="$name" maxlength="$max_length" value="$default" class="textinput" id="$name" />
</td>
</tr>
EOT;
//show map if configured
if ($CONFIG['gmap_editOnePic_map'] == 1) {
echo <<<EOT
<tr>
<td class="tableb" valign="top" style="white-space: nowrap;">
{$lang_register_php['location']}
</td>
<td width="100%" class="tableb" valign="top" colspan="2">
<noscript>
{$lang_gmap_php['no_javascript']}
</noscript>
<!--{$lang_gmap_php['coord_instructions']}-->
<div id="small_map"></div>
</td>
</tr>
EOT;
}
} //end text_box_input_gmap()
FIND:
case 4 :
// Call the hidden input funtion.
hidden_input($element[0], $element[1]);
break;
AFTER it, ADD:
// If the type is a coordinate text box input
case 10 :
//Call the form input function.
text_box_input_gmap($element[0], $element[1], $element[3], $element[4], $element[5]);
break;
FIND:
<form method="post" action="$path" enctype="multipart/form-data">
REPLACE with:
<form method="post" action="$path" enctype="multipart/form-data" name="uploadform">
FIND:
array($lang_upload_php['pic_title'], 'title', 0, 255, 1),
AFTER it, ADD:
array($lang_gmap_php['coordinates'], 'coordinates', 10, 255, 'latitude', 'longitude'),
FIND:
$user4 = addslashes($_POST['user4']);
AFTER it, ADD:
$coordinates = addslashes($_POST['coordinates']);
$coordinates = explode(',',$_POST['coordinates']);
$latitude = $coordinates[0];
$longitude = $coordinates[1];
FIND:
$result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);
REPLACE with:
$result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $user1, $user2, $user3, $user4, $latitude, $longitude, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);
FIND:
array('unique_ID', $_POST['unique_ID'], 4),
AFTER it, ADD:
array($lang_gmap_php['coordinates'], 'coordinates', 10, 255, $latitude, $longitude),
FIND:
// Close the table, create footers, and flush the output buffer.
endtable();
pagefooter();
(be careful because there are 5 pagefooter() in the file)
AFTER it, ADD:
//if config set, show map
if ($CONFIG['gmap_editOnePic_map'] == 1) {
$map_key = $CONFIG['gmap_api_key'];
$use_dev_version = $CONFIG['gmap_version'];
// if version config is set not to use development version, use 2 (geocodedPoint stable), otherwise, use 2.x (latest development)
if ($use_dev_version == 1) {
$version = '2.x';
} else {
$version = '2';
}
$default_zoom_level = $CONFIG['gmap_default_zoom'];
if ($CONFIG['gmap_default_center'] != NULL) { //if the picture doesn't have lat/long info, use the default value
$def_coordinates = explode(',',$CONFIG['gmap_default_center']);
$default_center_coord = $def_coordinates[0] . ',' . $def_coordinates[1];
} else { //if there is no default center, use Google, Inc address
$default_center_coord = '37.42225327545478,-122.0855712890625';
}
//This variable gets fed into master template
$gmap_code = <<<EOT
<script src="http://maps.google.com/maps?file=api&v=$version&key=$map_key" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("small_map"));
map.setCenter(new GLatLng({$default_center_coord}), {$default_zoom_level});
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
// "tiny" marker icon
var icon = new GIcon();
icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
icon.iconSize = new GSize(12, 20);
icon.shadowSize = new GSize(22, 20);
icon.iconAnchor = new GPoint(6, 20);
icon.infoWindowAnchor = new GPoint(5, 1);
/////Draggable markers
var point = new GLatLng({$default_center_coord});
var markerD = new GMarker(point, {icon:icon, draggable: true});
map.addOverlay(markerD);
markerD.enableDragging();
//gets coordinate values by dragging marker around
GEvent.addListener(markerD, "drag", function(){
document.getElementById("coordinates").value=markerD.getPoint().toUrlValue();
});
//gets coordinate values by double-clicking or moving the map
GEvent.addListener(map, 'moveend', function() {
var center = map.getCenter();
var latLngStr = center.y + ', ' + center.x ;
document.uploadform.coordinates.value = latLngStr;
});
} else {
alert("Sorry, the Google Maps API is not compatible with this browser");
}
//]]>
</script>
EOT;
} //end if show map
Repeat the above step except:
FIND:
// Close the table, create footers, and flush the output buffer.
endtable();
echo "</form>";
pagefooter();
Please let me know if you have trouble with your particular setup. There are 5 pagefooters under 5 conditions and I saw 2 places where the map code needed to be placed. If the map doesn't show up, please let me know what the Group setting is with regards to the Upload Method.