diff -urpN trackhead/INSTALL.txt track/INSTALL.txt
--- trackhead/INSTALL.txt	2009-02-16 06:39:47.000000000 -0600
+++ track/INSTALL.txt	2009-02-16 10:02:57.000000000 -0600
@@ -1,5 +1,11 @@
-// $Id: INSTALL.txt,v 1.3 2006/10/24 17:15:06 gaby Exp $
+// $Id: INSTALL.txt,v 1.4 2008/01/29 13:47:30 gaby Exp $
 
 - Install the GMAP module
 - Put all files inside your module directory
 - Activate the module and change create tracks auth.
+
+Note:  
+- Does not work correctly with Drupal caching for the
+  main track list.  For now be sure to disable caching until
+  somebody figures out a better way to turn off caching of links
+  under http://mysite/track/...
Binary files trackhead/.INSTALL.txt.swp and track/.INSTALL.txt.swp differ
diff -urpN trackhead/misc/map.inc.js track/misc/map.inc.js
--- trackhead/misc/map.inc.js	2009-02-16 06:42:14.000000000 -0600
+++ track/misc/map.inc.js	2009-02-16 10:00:26.000000000 -0600
@@ -1,4 +1,4 @@
-// $Id: map.inc.js,v 1.4 2006/11/10 22:04:55 gaby Exp $
+// $Id: map.inc.js,v 1.5 2008/01/29 13:47:30 gaby Exp $
 
 function MapClass()
 {
@@ -71,7 +71,7 @@ function MapClass()
  function processXMLnode(marker) {
 
      if (marker.getAttribute("type") == "alert") {
-        alert(marker.getAttribute("alert"));
+   //     alert(marker.getAttribute("alert"));
      }
      if (marker.getAttribute("type") == "point") {
      	addMarker(marker);
@@ -94,8 +94,9 @@ function MapClass()
          map.clearOverlays();
      }
      if (marker.getAttribute("type") == "clearlasttrace") {
-//         FIXME Causes NULL reference
-//         map.removeOverlay(lasttrace);
+         if (lasttrace != null) {
+            map.removeOverlay(lasttrace);
+         }
      }
      if (marker.getAttribute("type") == "move") {
          map.setCenter(new GLatLng(parseFloat(marker.getAttribute("y")), parseFloat(marker.getAttribute("x"))), 17 - parseFloat(marker.getAttribute("zl")));
@@ -106,11 +107,15 @@ function MapClass()
  }
 
  function processxmlDoc(xmlDoc) {
-      var markers = xmlDoc.documentElement.getElementsByTagName("data");
-      markerstoadd = [];
-
-      for (var i = 0; i < markers.length; i++) { // er"<"erg<>
-        processXMLnode(markers[i]);
+      if (xmlDoc.documentElement != null) {
+       var markers = xmlDoc.documentElement.getElementsByTagName("data");
+       markerstoadd = [];
+
+       //alert("ok!");
+
+       for (var i = 0; i < markers.length; i++) { // er"<"erg<>
+         processXMLnode(markers[i]);
+       }
       }
  }
 
diff -urpN trackhead/track.gpx.inc track/track.gpx.inc
--- trackhead/track.gpx.inc	2009-02-16 06:44:25.000000000 -0600
+++ track/track.gpx.inc	2009-02-16 09:55:48.000000000 -0600
@@ -331,31 +331,31 @@ class GPX_file {
      for ($i=0; $i<10; $i++) {
         $tot += $datay[$i];
      }
-     echo "<set name='".t("Grosse descente")."' value='".$tot."' />";   //<-10%
+     echo "<set name='".t("Steep descent")."' value='".$tot."' />";   //<-10%
 
      $tot = 0;
      for ($i=10; $i<19; $i++) {
         $tot += $datay[$i];
      }
-     echo "<set name='".t("Descente")."' value='".$tot."' />"; //(entre -10% et -2%)
+     echo "<set name='".t("Descent")."' value='".$tot."' />"; //(entre -10% et -2%)
 
      $tot = 0;
      for ($i=19; $i<22; $i++) {
         $tot += $datay[$i];
      }
-     echo "<set name='".t("Plat")."' value='".$tot."' />"; // (entre -2% et 2%)
+     echo "<set name='".t("Flat")."' value='".$tot."' />"; // (entre -2% et 2%)
 
      $tot = 0;
      for ($i=22; $i<31; $i++) {
         $tot += $datay[$i];
      }
-     echo "<set name='".t("Montée")."' value='".$tot."' />"; //(entre 2% et 10%)
+     echo "<set name='".t("Ascent")."' value='".$tot."' />"; //(entre 2% et 10%)
 
      $tot = 0;
      for ($i=31; $i<41; $i++) {
         $tot += $datay[$i];
      }
-     echo "<set name='".t("Grosse montée")."' value='".$tot."' />"; //(>10%)
+     echo "<set name='".t("Steep ascent")."' value='".$tot."' />"; //(>10%)
 
      echo "</graph>";
   }
@@ -555,7 +555,7 @@ H  LATITUDE    LONGITUDE    DATE      TI
     xml_set_element_handler($xml_parser, array(&$this,"debutElement"), array(&$this,"finElement"));
     xml_set_character_data_handler($xml_parser, array(&$this,"characterData"));
     if (!($fp = fopen($filename, "r"))) {
-       die("Impossible d'ouvrir le fichier.");
+       die("Can't open file: ".$filename);
     }
 
     while ($data = fread($fp, 4096)) {
diff -urpN trackhead/track.info track/track.info
--- trackhead/track.info	2009-02-16 06:44:54.000000000 -0600
+++ track/track.info	2009-02-16 09:58:03.000000000 -0600
@@ -1,5 +1,7 @@
-; $Id$
+; $Id: track.info,v 1.1 2008/01/29 13:47:30 gaby Exp $
 name = Track
 description = The track module can display GPS tracklogs inside a node. Users submit tracklogs in GPX format, the system renders those tracklogs on Google Maps and dynamically generates elevation profiles
-dependencies = gmap
+dependencies[] = gmap
 package = "Location"
+
+core = 6.x
\ No newline at end of file
diff -urpN trackhead/track.install track/track.install
--- trackhead/track.install	2006-11-10 16:04:55.000000000 -0600
+++ track/track.install	2009-02-16 09:52:23.000000000 -0600
@@ -1,41 +1,41 @@
-<?
+<?php
+// $Id$
 
+/**
+ * Implementation of hook_install().
+ */
 function track_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      db_query("CREATE TABLE {track} (".
-      	"nid int(10) unsigned NOT NULL default '0',".
-      	"filename varchar(255) not null,".
-      	"filepath varchar(255) not null,".
-      	"latstart float NOT NULL default '0',".
-      	"lonstart float NOT NULL default '0',".
-      	"latmin float NOT NULL default '0',".
-      	"latmax float NOT NULL default '0',".
-      	"lonmin float NOT NULL default '0',".
-      	"lonmax float NOT NULL default '0',".
-      	"length float NOT NULL default '0',".
-      	"dzminu float NOT NULL default '0',".
-      	"dzplus float NOT NULL default '0',".
-      	"zmin float NOT NULL default '0',".
-      	"zmax float NOT NULL default '0') /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-    case 'pgsql':
-      db_query("CREATE TABLE {track} (".
-      	"nid int(10) unsigned NOT NULL default '0',".
-      	"filename varchar(255) not null,".
-      	"filepath varchar(255) not null,".
-      	"latstart float NOT NULL default '0',".
-      	"lonstart float NOT NULL default '0',".
-      	"latmin float NOT NULL default '0',".
-      	"latmax float NOT NULL default '0',".
-      	"lonmin float NOT NULL default '0',".
-      	"lonmax float NOT NULL default '0',".
-      	"length float NOT NULL default '0',".
-      	"dzminu float NOT NULL default '0',".
-      	"dzplus float NOT NULL default '0',".
-      	"zmin float NOT NULL default '0',".
-      	"zmax float NOT NULL default '0')");
-      break;
-  }
-}
\ No newline at end of file
+  drupal_install_schema('track');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function track_uninstall() {
+  drupal_uninstall_schema('track');
+}
+
+/**
+ * Implementation of hook_schema().
+ */
+function track_schema() {
+  $schema['track'] = array(
+    'fields' => array(
+      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'disp-width' => '10'),
+      'filename' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'filepath' => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'latstart' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'lonstart' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'latmin' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'latmax' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'lonmin' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'lonmax' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'length' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'dzminu' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'dzplus' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'zmin' => array('type' => 'float', 'not null' => TRUE, 'default' => '0'),
+      'zmax' => array('type' => 'float', 'not null' => TRUE, 'default' => '0')),
+  );
+
+  return $schema;
+}
diff -urpN trackhead/track.module track/track.module
--- trackhead/track.module	2009-02-16 06:46:11.000000000 -0600
+++ track/track.module	2009-02-16 17:36:59.000000000 -0600
@@ -1,13 +1,14 @@
 <?
-// $Id: track.module,v 1.6 2006/11/10 22:04:55 gaby Exp $
+// $Id: track.module,v 1.7 2008/01/29 13:47:30 gaby Exp $
 
 /**
  * @file
  * GPX-handling and displaying.
  */
 
-include_once("modules/track/track.gpx.inc");
-include_once("modules/track/track.tile.inc");
+include_once(drupal_get_path('module', 'track') ."/track.gpx.inc");
+include_once(drupal_get_path('module', 'track') ."/track.tile.inc");
+include_once(drupal_get_path('module', 'track') ."/track.google.map.inc");
 
 $phptrackback = "";
 
@@ -22,64 +23,67 @@ function track_add() {
 }
 
 /**
- * Implementation of hook_menu.
+ * Implementation of hook_menu().
  */
-function track_menu($may_cache) {
+function track_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'track', 'callback' => 'list_trk', 'title' =>  t('Track list'), 'access' => true);
-    $items[] = array('path' => 'track/add', 'callback' => 'track_add', 'title' =>  t('Track upload'), 'access' => user_access('Create tracks'));
-  }
 
-  $items[] = array(
-   'path' => 'track/trk',
-   'callback' => 'download_trk',
-   'access' => true,
+  $items['track'] = array(
+   'title' => 'Track list',
+   'page callback' => 'list_trk',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-  $items[] = array(
-   'path' => 'track/kml',
-   'callback' => 'download_kml',
-   'access' => true,
+//  $items['track/add'] = array(
+//    'title' => 'Track upload',
+//    'page callback' => 'track_add',
+//    'access' => user_access('Create tracks'),
+//    'type' => MENU_CALLBACK);
+  $items['track/trk'] = array(
+   'page callback' => 'download_trk',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-  $items[] = array(
-   'path' => 'track/gpx',
-   'callback' => 'download_gpx',
-   'access' => true,
+  $items['track/kml'] = array(
+   'page callback' => 'download_kml',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-
-  $items[] = array(
-   'path' => 'track/icon',
-   'callback' => 'get_icon',
-   'access' => true,
+  $items['track/gpx'] = array(
+//   'title' => 'Track GPX',
+   'page callback' => 'download_gpx',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-
-  $items[] = array(
-   'path' => 'track/ajax/all',
-   'callback' => 'trackback_all',
-   'access' => true,
+  $items['track/icon'] = array(
+   'page callback' => 'get_icon',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-
-  $items[] = array(
-   'path' => 'track/ajax/detail',
-   'callback' => 'trackback_detail',
-   'access' => true,
+  $items['track/ajax/all'] = array(
+   'page callback' => 'trackback_all',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-
-  $items[] = array(
-   'path' => 'track/profile',
-   'callback' => 'trackback_profile',
-   'access' => true,
+  $items['track/ajax/detail'] = array(
+   'page callback' => 'trackback_detail',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-  $items[] = array(
-   'path' => 'track/repartition',
-   'callback' => 'trackback_repartition',
-   'access' => true,
+  $items['track/profile'] = array(
+   'page callback' => 'trackback_profile',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
-   
-  $items[] = array(
-   'path' => 'track/boundslist',
-   'callback' => 'track_boundslist',
-   'access' => true,
+  $items['track/repartition'] = array(
+   'page callback' => 'trackback_repartition',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
+   'type' => MENU_CALLBACK);
+  $items['track/boundslist'] = array(
+   'page callback' => 'track_boundslist',
+   'access callback' => 'user_access',
+   'access arguments' => array('access content'),
    'type' => MENU_CALLBACK);
 
   return $items;
@@ -110,13 +114,13 @@ function get_icon($diff) {
  header("Content-type: image/png");
 
  if ($diff == "S") {
-  $image_name = "modules/track/misc/pushpins/058.png";
+  $image_name = drupal_get_path('module', 'track') ."/misc/pushpins/058.png";
  } elseif ($diff == "M") {
-  $image_name = "modules/track/misc/pushpins/150.png";
+  $image_name = drupal_get_path('module', 'track') ."/misc/pushpins/150.png";
  } elseif ($diff == "L") {
-  $image_name = "modules/track/misc/pushpins/011.png";
+  $image_name = drupal_get_path('module', 'track') ."/misc/pushpins/011.png";
  } else {
-  $image_name = "modules/track/misc/pushpins/007.png";
+  $image_name = drupal_get_path('module', 'track') ."/misc/pushpins/007.png";
  }
 
  $im = imagecreatefrompng($image_name);
@@ -145,7 +149,6 @@ function get_icon($diff) {
 }
 
 function trackback_detail($nid) {
-  include_once("modules/track/track.google.map.inc");
   // create interface object with map
   $aMap = new GoogleMap();
   // init all values
@@ -170,8 +173,8 @@ function trackback_detail($nid) {
     $zoomlevellon = 17;
     while ($angle>$varlon)
     {
-	$angle = $angle / 2;
-	$zoomlevellon--;
+  $angle = $angle / 2;
+  $zoomlevellon--;
     }
 
     $varlat = max(1e-5, $latmax - $latmin);
@@ -179,8 +182,8 @@ function trackback_detail($nid) {
     $zoomlevellat = 17;
     while ($angle>$varlat)
     {
-	$angle = $angle / 2;
-	$zoomlevellat--;
+  $angle = $angle / 2;
+  $zoomlevellat--;
     }
 
     $zoomlevel = max(0, max($zoomlevellat, $zoomlevellon));
@@ -200,10 +203,10 @@ function trackback_detail($nid) {
     $track = node_load($nid);
     $desc = theme('info_window_html', $track);
     $aMap->AddTrace($points, "#ff0000", 3, 0.8);
-    
+
     $intensite = $track->file->dzplus / ($track->file->length / 4);
     $intensite = ($intensite - 30) * (100 / 40);
-    
+
     if ($intensite < 30) {
       $mapicon = base_path()."track/icon/S";
     }
@@ -226,7 +229,6 @@ function trackback_detail($nid) {
 }
 
 function trackback_all() {
-  include_once("modules/track/track.google.map.inc");
   // create interface object with map
   $aMap = new GoogleMap();
   // init all values
@@ -253,8 +255,8 @@ function trackback_all() {
     $zoomlevellon = 17;
     while ($angle>$varlon)
     {
-	$angle = $angle / 2;
-	$zoomlevellon--;
+  $angle = $angle / 2;
+  $zoomlevellon--;
     }
 
     $varlat = max(1e-5, $latmax - $latmin);
@@ -262,8 +264,8 @@ function trackback_all() {
     $zoomlevellat = 17;
     while ($angle>$varlat)
     {
-	$angle = $angle / 2;
-	$zoomlevellat--;
+  $angle = $angle / 2;
+  $zoomlevellat--;
     }
 
     $zoomlevel = max(0, max($zoomlevellat, $zoomlevellon));
@@ -281,7 +283,7 @@ function trackback_all() {
     if ($result) {
      while ($track = db_fetch_object($result)) {
       $desc = theme('info_window_html', $track);
-      
+
       $intensite = $track->dzplus / ($track->length / 4);
       $intensite = ($intensite - 30) * (100 / 40);
 
@@ -336,7 +338,7 @@ function theme_info_details($track) {
 function prepare_google_maps() {
   $key = variable_get('googlemap_api_key', 'AAAAAAAAAAA');
   $basepath = $GLOBALS['base_path'];
-  drupal_add_js('modules/track/misc/map.inc.js');
+  drupal_add_js(drupal_get_path('module', 'track') .'/misc/map.inc.js');
   $GLOBALS['base_path'] = "";
   drupal_set_html_head('<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key='.$key.'"type="text/javascript"></script>');
   $GLOBALS['base_path'] = $basepath;
@@ -387,9 +389,13 @@ function track_page_last() {
     $row[] = sprintf('%2.2f', $track->file->dzplus)." m";
     $row[] = sprintf('%2.2f', $track->file->dzminu)." m";
 
-    $intensite = $track->file->dzplus / ($track->file->length / 4);
-    $intensite = ($intensite - 30) * (100 / 40);
-    
+    if ($track->file->length != 0) {
+      $intensite = $track->file->dzplus / ($track->file->length / 4);
+      $intensite = ($intensite - 30) * (100 / 40);
+    } else {
+      $intensite = 0.0;
+    }
+
     if ($intensite < 30) {
       $sint = "S";
     }
@@ -430,7 +436,7 @@ function list_trk() {
   $content .= '   </td></tr><tr><td>';
   $content .= '   <div id="info" style="height: 100px">'.t("Loading").'...'.'</div>';
   $content .= '   </td></tr></table>';
-  
+
   $content .= track_page_last();
 
   return $content;
@@ -461,10 +467,10 @@ function track_perm() {
 }
 
 /**
- * Implementation of hook_help.
+ * Implementation of hook_help().
  */
-function track_help($section) {
-  switch ($section) {
+function track_help($path, $arg) {
+  switch ($path) {
     case 'node/add#track':
       return t('Upload new track.');
   }
@@ -505,9 +511,9 @@ function track_flash_chart($width, $heig
   $output .= '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
   $output .= 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
   $output .= 'WIDTH="'.$width.'" HEIGHT="'.$height.'" id="FC2Area3D" ALIGN="">';
-  $output .= '<PARAM NAME=movie VALUE="'.base_path().'modules/track/misc/'.$swf.'?dataUrl=/track/'.$type.'/'.$nid.'">';
+  $output .= '<PARAM NAME=movie VALUE="'.drupal_get_path('module', 'track').'/misc/'.$swf.'?dataUrl=/track/'.$type.'/'.$nid.'">';
   $output .= '<PARAM NAME=quality VALUE=high><PARAM NAME=bgcolor VALUE=#FFFFFF>';
-  $output .= '<EMBED src="'.base_path().'modules/track/misc/'.$swf.'?dataUrl=/track/'.$type.'/'.$nid.'" quality=high ';
+  $output .= '<EMBED src="'.drupal_get_path('module', 'track').'/misc/'.$swf.'?dataUrl=/track/'.$type.'/'.$nid.'" quality=high ';
   $output .= 'bgcolor=#FFFFFF WIDTH="'.$width.'" HEIGHT="'.$height.'" NAME="FC2Area3D" ';
   $output .= 'ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>';
   $output .= '</OBJECT>';
@@ -530,6 +536,30 @@ function track_view(&$node, $teaser = FA
   return $node;
 }
 
+//function track_theme() {
+//  return array(
+//    'track' => array(
+//      'function' => 'theme_track_files',
+//      'arguments' => array('track' => NULL),
+//    ),
+//  );
+//}
+
+/**
+ * Implementation of hook_theme().
+ */
+function track_theme() {
+  return array(
+    'track' => array('arguments' => array('element')),
+    'track_files' => array('arguments' => array('element')),
+    'item_list' => array('arguments' => array('element')),
+  );
+}
+
+function theme_track($node) {
+  return theme_track_files($node);
+}
+
 function theme_track_files($node) {
   //theme_node_example_order_info
   $output = "";
@@ -630,15 +660,16 @@ function track_form(&$node) {
      '#title' => t('File').'<span class="form-required" title="This field is required.">*</span>',
      '#size' => 40,
      '#default_value' => '',
-     '#weight' => -3
+     '#weight' => -3,
+     '#description' => t('GPX file'),
    );
   }
 
   $form['body_filter']['body'] = array(
-   '#type' => 'textarea', 
+   '#type' => 'textarea',
    '#title' => t('Body'),
    '#default_value' => $node->body,
-   '#rows' => 10, 
+   '#rows' => 10,
    '#weight' => -2,
    '#required' => TRUE);
   $form['body_filter']['filter'] = filter_form($node->format);
@@ -658,17 +689,16 @@ function file_check_local($source) {
 }
 
 function track_validate_file(&$node) {
+  $validators = array(
+    'file_validate_extensions' => array('gpx'),
+  );
+
   // Check for a new file upload.
-  if ($file = file_check_upload('file')) {
-    $ext = strtolower(ereg_replace("^.+\\.([^.]+)$", "\\1", $file->filename));
-    if ($ext != "gpx") {
-     form_set_error('file', t('A <b>GPX</b> file must be provided.'));
-    }
-    else
-    {
-     $node->file = file_save_upload($file, file_directory_path(), false);
-     $node->current_file = $node->file->filepath;
-    }
+  if ($file = file_save_upload('file', $validators, file_directory_path())) {
+    file_set_status($file, FILE_STATUS_PERMANENT);
+
+    $node->file = $file;
+    $node->current_file = $node->file->filepath;
   }
   else
   {
@@ -676,6 +706,7 @@ function track_validate_file(&$node) {
    if (file_exists($current_file)) {
      $node->file = file_check_local($current_file);
      $node->current_file = $node->file->filepath;
+     $file = $node->file;
    }
   }
   return $file;
@@ -729,7 +760,7 @@ function track_load($node) {
 function track_insert($node) {
   track_validate($node);
   $file = $node->file;
-  
+
   $aGPXfile = new GPX_file();
   $aGPXfile->LoadFromFile($file->filepath);
   $aGPXfile->getInfos($latstart,$lonstart,$latmin,$latmax,$lonmin,$lonmax,$length,$dzminu,$dzplus,$zmin,$zmax);
@@ -764,3 +795,4 @@ function track_settings() {
 
   return $form;
 }
+
