Index: SiteCatalyst(20.3).example.txt
===================================================================
RCS file: SiteCatalyst(20.3).example.txt
diff -N SiteCatalyst(20.3).example.txt
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ SiteCatalyst(20.3).example.txt	5 Jan 2010 16:33:08 -0000
@@ -0,0 +1,33 @@
+<!-- SiteCatalyst code version: H.20.3.
+Copyright 1997-2007 Omniture, Inc. More info available at
+http://www.omniture.com -->
+<script type="text/javascript" language="JavaScript" src="/sites/all/themes/devportal/s_code.js"></script>
+<script type="text/javascript" language="JavaScript"><!--
+
+s.pageName="DevPortal: home";
+s.channel="DevPortal: Home";
+s.hier1="DevPortal: home";
+s.prop2="Pasqualle";
+s.prop3="";
+s.prop4="DevPortal";
+s.prop5="";
+s.prop6="";
+s.prop7="live";
+s.prop9="en";
+s.prop10="";
+s.prop11="0.41193";
+s.prop15="";
+s.prop37="";
+s.evar37="";
+s.events="";
+// Begin "omniture" module custom code
+var omniture_rsid='omniture.devportal';
+if (s && s.sa && (typeof s.sa == 'function')) s.sa(omniture_rsid);
+s.prop29=omniture_rsid;
+// End "omniture" module custom code;
+/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
+var s_code=s.t();if(s_code)document.write(s_code)//--></script>
+<script language="JavaScript" type="text/javascript"><!--
+if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')
+//--></script><!--/DO NOT REMOVE/-->
+<!-- End SiteCatalyst code version: H.20.3. -->
Index: omniture.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/omniture/omniture.info,v
retrieving revision 1.4.4.1
diff -u -p -r1.4.4.1 omniture.info
--- omniture.info	7 Oct 2008 21:11:16 -0000	1.4.4.1
+++ omniture.info	8 Jan 2010 00:31:05 -0000
@@ -1,4 +1,6 @@
 ; $Id: omniture.info,v 1.4.4.1 2008/10/07 21:11:16 ultimateboy Exp $
 name = Omniture
-description = Adds Omniture SiteCatalyst javascript tracking code to all your site's pages.
-core = 6.x
\ No newline at end of file
+description = Adds Omniture SiteCatalyst javascript tracking code to your site's pages.
+core = 7.x
+files[] = omniture.module
+files[] = omniture.install
Index: omniture.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/omniture/omniture.install,v
retrieving revision 1.4
diff -u -p -r1.4 omniture.install
--- omniture.install	6 Oct 2008 22:22:52 -0000	1.4
+++ omniture.install	8 Jan 2010 00:49:37 -0000
@@ -1,21 +1,49 @@
 <?php
 // $Id: omniture.install,v 1.4 2008/10/06 22:22:52 ultimateboy Exp $
-/*
+/**
  * @file
  * Installs the module, Omniture.
- * 
+ */
+
+/**
+ * Implements hook_install().
  */
 function omniture_install() {
-  $result = db_query('SELECT * FROM {role} ORDER BY name');
+  $result = db_select('role', 'r')
+    ->fields('r')
+    ->orderBy('name', 'ASC')
+    ->execute();
 
-  while ($role = db_fetch_object($result)) {
-    $role_varname = $string = str_replace(" ", "_", $role->name);
+  foreach ($result as $role) {
+    $role_varname = str_replace(" ", "_", $role->name);
     $omniture_role = "omniture_track_{$role_varname}";
 
-    //check if variable is not already set from a previous install
+    // Check if variable is not already set from a previous install.
     if (strpos(variable_get($omniture_role, 'new'), 'new') !== FALSE) {
       variable_set($omniture_role, TRUE);
-      drupal_set_message(t('Role %rolename is now being tracked by SiteCatalyst', array('%rolename' => $role->name)));
+      drupal_set_message(t('Role %rolename is now being tracked by SiteCatalyst.', array('%rolename' => $role->name)));
     }
   }
 }
+
+/**
+ * Implements hook_uninstall().
+ */
+function omniture_uninstall() {
+  $result = db_select('variable', 'v')
+    ->fields('v')
+    ->condition('v.name', 'omniture_%', 'LIKE')
+    ->execute();
+
+  foreach ($result as $variable) {
+    variable_del($variable->name);
+  }
+}
+
+/**
+ * Update to Drupal 7. Set the version number for new installs.
+ */
+function omniture_update_7000() {
+  $ret = array();
+  return $ret;
+}
Index: omniture.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/omniture/omniture.module,v
retrieving revision 1.6.4.3
diff -u -p -r1.6.4.3 omniture.module
--- omniture.module	23 Sep 2009 23:18:18 -0000	1.6.4.3
+++ omniture.module	8 Jan 2010 19:32:04 -0000
@@ -1,6 +1,6 @@
 <?php
 // $Id: omniture.module,v 1.6.4.3 2009/09/23 23:18:18 greggles Exp $
-/*
+/**
  * @file
  * Drupal Module: Omniture SiteCatalyst Stats
  * Adds the required Javascript to the bottom of all your Drupal pages
@@ -12,6 +12,9 @@
  *
  */
 
+/**
+ * Implements hook_help().
+ */
 function omniture_help($path, $arg) {
   switch ($path) {
     case 'admin/help#omniture':
@@ -19,19 +22,24 @@ function omniture_help($path, $arg) {
   }
 }
 
-function omniture_perm() {
-  return array('administer SiteCatalyst configuration');
+/**
+ * Implements hook_permission().
+ */
+function omniture_permission() {
+  return array(
+    'administer SiteCatalyst configuration' => array(
+      'title' => t('Administer SiteCatalyst configuration'),
+    )
+  );
 }
 
 /**
- * Implementation of hook_menu
+ * Implements hook_menu().
  */
 function omniture_menu() {
-  $items = array();
-
-  $items['admin/settings/omniture'] = array(
+  $items['admin/config/system/omniture'] = array(
     'title' => 'SiteCatalyst',
-    'description' => 'Configure the settings used to integrate Omniture\'s SiteCatalyst.',
+    'description' => "Configure the settings used to integrate Omniture's SiteCatalyst.",
     'page callback' => 'drupal_get_form',
     'page arguments' => array('omniture_admin_settings'),
     'access arguments' => array('administer SiteCatalyst configuration'),
@@ -42,205 +50,179 @@ function omniture_menu() {
 }
 
 /**
- * Implementation of hook_footer()  to insert Javascript at the end of the page
+ * Implements hook_page_alter().
  */
-function omniture_footer($main = 0) {
-
+function omniture_page_alter(&$page) {
   global $user;
 
-  // Check if we should track the currently active user's role
+  // Check if we should track the currently active user's role.
   $track = 0;
   foreach ($user->roles as $role) {
     $role = str_replace(' ', '_', $role);
     $track += variable_get("omniture_track_{$role}", FALSE);
   }
 
-  // Don't track page views in the admin sections, or for certain roles
-  if (arg(0) != 'admin' && $track > 0) {
+  // Don't track page views in the admin sections, or for certain roles.
+  if (arg(0) == 'admin' || $track <= 0) {
+    return;
+  }
+
+  // Add any custom code snippets if specified.
+  $codesnippet = variable_get('omniture_codesnippet', '');
+
+  // Format and combine variables in the "right" order
+  // Right order is the code file (least likely to be maintained)
+  // Then admin settings with codesnippet first and finally taxonomy->vars
+  $extra_variables_formatted = $codesnippet;
+
+  $header = "<!-- SiteCatalyst code version: ";
+  $header .=  check_plain(variable_get("omniture_version", 'H.20.3.'));
+  $header .= "\nCopyright 1997-2009 Omniture, Inc. More info available at http://www.omniture.com -->\n";
+  $header .= "<script type=\"text/javascript\" language=\"JavaScript\" src=\"";
+  $header .=  check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js'));
+  $header .= "\"></script>\n";
+  $header .= "<script type=\"text/javascript\" language=\"JavaScript\"><!--\n";
+
+  $footer = '/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/'."\n";
+  $footer .= 'var s_code=s.t();if(s_code)document.write(s_code)//--></script>'."\n";
+  $footer .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
+  $footer .= "if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')"."\n";
+  $footer .= '//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img src="';
+  $footer .= check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.20.3--NS/0')) .'"'."\n";
+  $footer .= 'height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->'."\n";
+  $footer .= '<!-- End SiteCatalyst code version: ';
+  $footer .=  check_plain(variable_get("omniture_version", 'H.20.3.'));
+  $footer .= ' -->'."\n";
+
+  if ($omniture_hooked_vars = module_invoke_all('omniture_variables')) {
+    if (isset($omniture_hooked_vars['header'])) {
+      $header = $omniture_hooked_vars['header'];
+    }
+    if (isset($omniture_hooked_vars['variables'])) {
+      $extra_variables_formatted .= _omniture_format_variables($omniture_hooked_vars['variables']);
+    }
+    if (isset($omniture_hooked_vars['footer'])) {
+      $footer = $omniture_hooked_vars['footer'];
+    }
+  }
 
-    // Add any custom code snippets if specified
-    $codesnippet = variable_get('omniture_codesnippet', '');
+  $page['page_bottom']['omniture'] = array(
+    'header'=> array(
+      '#type' => 'markup',
+      '#markup' => $header,
+    ),
+    'variables'=> array(
+      '#type' => 'markup',
+      '#markup' => $extra_variables_formatted,
+    ),
+    'footer'=> array(
+      '#type' => 'markup',
+      '#markup' => $footer,
+    ),
+  );
+}
 
-    // Taxonomy specific stuff - only for nodes
-    if (module_exists('taxonomy') && $node = menu_get_object()) {
-      $tax = $node->taxonomy;
-
-      $vocabularies = taxonomy_get_vocabularies();
-      foreach ($vocabularies as $vid => $vocab) {
-        if ($vocab->tags == 0) {
-          if ($variable_name = variable_get("omniture_vocabvidvar_{$vocab->vid}", FALSE)) {
-            $terms_for_omniture = "";
-            foreach ($node->taxonomy as $tid => $taxonomy) {
-              if ($taxonomy->vid == $vid) {
-                if (strlen($terms_for_omniture) > 0) {
-                  $terms_for_omniture .= ','. $taxonomy->name;
-                }
-                else {
-                  $terms_for_omniture .= $taxonomy->name;
-                }
-              }
-            }
-            if (isset($terms_for_omniture)) {
-              $omniture_vocab_vars[$variable_name] = $terms_for_omniture;
-            }
-          }
-        }
-      }
-    }
+/**
+ * Helper function to format Omniture variables.
+ */
+function _omniture_format_variables(array $variables = array()) {
+  $extra_variables = omniture_get_variables();
 
-    // Format and combine variables in the "right" order
-    // Right order is the code file (least likely to be maintained)
-    // Then admin settings with codesnippet first and finally taxonomy->vars
-    $extra_variables_formatted = $codesnippet;
-
-    if (isset($omniture_vocab_vars)) {
-      foreach ($omniture_vocab_vars as $variable => $value) {
-        $extra_variables_formatted .= "\n". $variable .'="'. $value .'";';
-      }
+  $variables_formatted = '';
+  foreach ($variables as $key => $value) {
+    if (is_array($value)) {
+      // Use the last element.
+      $value = end($value);
     }
 
-    $header = "<!-- SiteCatalyst code version: ";
-    $header .=  check_plain(variable_get("omniture_version", 'H.13.'));
-    $header .= " Copyright 1997-2009 Omniture, Inc. More info available at http://www.omniture.com -->\n";
-    $header .= "<script type=\"text/javascript\" language=\"JavaScript\" src=\"";
-    $header .=  check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js'));
-    $header .= "\"></script>\n";
-    $header .= "<script type=\"text/javascript\" language=\"JavaScript\"><!--\n";
-
-    $footer = '/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/'."\n";
-    $footer .= 'var s_code=s.t();if(s_code)document.write(s_code)//--></script>'."\n";
-    $footer .= '<script language="JavaScript" type="text/javascript"><!--'."\n";
-    $footer .= "if(navigator.appVersion.indexOf('MSIE')>=0)document.write(unescape('%3C')+'\!-'+'-')"."\n";
-    $footer .= '//--></script><noscript><a href="http://www.omniture.com" title="Web Analytics"><img src="';
-    $footer .= check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.13--NS/0')) .'"'."\n";
-    $footer .= 'height="1" width="1" border="0" alt="" /></a></noscript><!--/DO NOT REMOVE/-->'."\n";
-    $footer .= '<!-- End SiteCatalyst code version: ';
-    $footer .=  check_plain(variable_get("omniture_version", 'H.13.'));
-    $footer .= ' -->'."\n";
-
-    // Get variables other modules have set.
-    $extra_variables = omniture_get_variables();
-
-    if ($omniture_hooked_vars = module_invoke_all('omniture_variables', $main)) {
-      if (isset($omniture_hooked_vars['header'])) {
-        $header = $omniture_hooked_vars['header'];
-      }
-      if (isset($omniture_hooked_vars['variables'])) {
-        // We need to merge some variables here.
-        foreach ($omniture_hooked_vars['variables'] as $k => $v) {
-          if (is_array($v)) {
-            $v = $v[count($v)-1];
-          }
-          if (isset($extra_variables[$k])) {
-            $v = $extra_variables[$k];
-          }
-          $extra_variables_formatted .= "$k=\"$v\";\n";
-        }
-      }
-      if (isset($omniture_hooked_vars['footer'])) {
-        $footer = $omniture_hooked_vars['footer'];
-      }
+    if (isset($extra_variables[$key])) {
+      $value = $extra_variables[$key];
     }
 
-    $script  = $header;
-    $script .= $extra_variables_formatted;
-    $script .= $footer;
-
-    return $script;
+    $key = check_plain($key);
+    $value = check_plain($value);
+    $variables_formatted .= "{$key}=\"{$value}\";\n";
   }
+  return $variables_formatted;
 }
 
 /**
- * Implementation of hook_admin_settings() for configuring the module
+ * Menu callback; Omniture settings.
  */
 function omniture_admin_settings() {
   $form['general'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('General Settings'),
-        '#collapsible' => TRUE,
-        '#description' => t('General settings')
+    '#type' => 'fieldset',
+    '#title' => t('General settings'),
+    '#collapsible' => TRUE,
+    '#weight' => '-10',
   );
 
   $form['general']['omniture_js_file_location'] = array(
-      '#type' => 'textfield',
-      '#title' => t("Complete path to SiteCatalyst Javascript file"),
-      '#default_value' => check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js')),
+    '#type' => 'textfield',
+    '#title' => t("Complete path to SiteCatalyst Javascript file"),
+    '#default_value' => check_plain(variable_get("omniture_js_file_location", 'http://www.example.com/js/s_code_remote_h.js')),
   );
 
   $form['general']['omniture_image_file_location'] = array(
-      '#type' => 'textfield',
-      '#title' => t("Complete path to SiteCatalyst Image file"),
-      '#default_value' => check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.13--NS/0')),
+    '#type' => 'textfield',
+    '#title' => t("Complete path to SiteCatalyst Image file"),
+    '#default_value' => check_plain(variable_get("omniture_image_file_location", 'http://examplecom.112.2O7.net/b/ss/examplecom/1/H.20.3--NS/0')),
   );
 
   $form['general']['omniture_version'] = array(
-      '#type' => 'textfield',
-      '#title' => t("SiteCatalyst version (used by omniture for debugging)"),
-      '#default_value' => check_plain(variable_get("omniture_version", 'H.13')),
+    '#type' => 'textfield',
+    '#title' => t("SiteCatalyst version (used by omniture for debugging)"),
+    '#default_value' => check_plain(variable_get("omniture_version", 'H.20.3.')),
   );
 
-  // Render the role overview.
-  $result = db_query('SELECT * FROM {role} ORDER BY name');
-
   $form['roles'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('User Role Tracking'),
-        '#collapsible' => TRUE,
-        '#description' => t('Define what user roles should be tracked by SiteCatalyst.')
-  );
-
-  while ($role = db_fetch_object($result)) {
-     // can't use empty spaces in varname
-    $role_varname = $string = str_replace(' ', '_', $role->name);
+    '#type' => 'fieldset',
+    '#title' => t('User role tracking'),
+    '#collapsible' => TRUE,
+    '#description' => t('Define what user roles should be tracked by SiteCatalyst.'),
+    '#weight' => '-6',
+  );
+
+  $result = db_select('role', 'r')
+    ->fields('r')
+    ->orderBy('name', 'ASC')
+    ->execute();
+
+  foreach ($result as $role) {
+    // Can't use empty spaces in varname.
+    $role_varname = str_replace(' ', '_', $role->name);
+    // Only the basic roles are translated.
+    $role_name = in_array($role->rid, array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID)) ? t($role->name) : $role->name;
     $form['roles']["omniture_track_{$role_varname}"] = array(
       '#type' => 'checkbox',
-      '#title' => t($role->name),
+      '#title' => $role_name,
       '#default_value' => variable_get("omniture_track_{$role_varname}", FALSE),
     );
   }
 
-  $form['vocabs'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Vocabulary Variables'),
-        '#collapsible' => TRUE,
-        '#description' => t('Define which vocabularies should should be tracked by which SiteCatalyst variables.  Only applies to the full node view (e.g. node/1 or the aliased version of a node). Leave blank to disable for a vocabulary.  Multiple terms from a "Multiple select" vocabulary will be placed into a comma separated list.  Not available for "Free tagging" vocabularies.')
-  );
-
-  // Allow setting a vocabulary into a variable
-  if (module_exists('taxonomy')) {
-    $vocabularies = taxonomy_get_vocabularies();
-    foreach ($vocabularies as $vid => $vocab) {
-      if ($vocab->tags == 0) {
-        $form['vocabs']["omniture_vocabvidvar_{$vocab->vid}"] = array(
-          '#type' => 'textfield',
-          '#title' => t('Variable for %vocab', array('%vocab' => $vocab->name)),
-          '#default_value' => variable_get("omniture_vocabvidvar_{$vocab->vid}", FALSE),
-        );
-      }
-    }
-  }
-
   $form['advanced'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Advanced'),
-        '#collapsible' => TRUE,
-        '#collapsed' => TRUE,
-        '#description' => t('You can add custom SiteCatalyst code here.')
+    '#type' => 'fieldset',
+    '#title' => t('Advanced'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('You can add custom SiteCatalyst code here.'),
+    '#weight' => '-2',
   );
 
   $form['advanced']['omniture_codesnippet'] = array(
-      '#type' => 'textarea',
-      '#title' => t('JavaScript Code'),
-      '#default_value' => variable_get('omniture_codesnippet', ''),
-      '#rows' => 15,
-      '#description' => t('Paste <a href="@snippets">custom code snippets here</a>. These will be added to every page that SiteCatalyst appears on. For help with this feature see the <a href="@blog">cutroni.com blog</a>. <strong>Do not include the &lt;script&gt; tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/39282', '@blog' => 'http://cutroni.com/blog/') )
+    '#type' => 'textarea',
+    '#title' => t('JavaScript Code'),
+    '#default_value' => variable_get('omniture_codesnippet', ''),
+    '#rows' => 15,
+    '#description' => t('Paste <a href="@snippets">custom code snippets here</a>. These will be added to every page that SiteCatalyst appears on. For help with this feature see the <a href="@blog">cutroni.com blog</a>. <strong>Do not include the &lt;script&gt; tags</strong>, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/39282', '@blog' => 'http://cutroni.com/blog/')),
   );
 
   return system_settings_form($form);
 }
 
 /**
- * Builds up a set of properties and values ot add to the JS of the page.
+ * Used to replace the value of omniture variables. The variables need to be
+ * defined with hook_omniture_variables().
  *
  * @param string $name
  *  The property.
@@ -248,7 +230,8 @@ function omniture_admin_settings() {
  *  The value for the property.
  */
 function omniture_set_variable($name = NULL, $value = NULL) {
-  static $variables;
+  $variables = &drupal_static(__FUNCTION__, array());
+
   if (empty($name)) {
     return $variables;
   }
@@ -260,103 +243,3 @@ function omniture_set_variable($name = N
 function omniture_get_variables() {
   return omniture_set_variable();
 }
-
-/**
- * Example output from the omniture.com site itself.
- * Some of the paths may not be applicable for your site but at least it provides an example.
- */
-
-/*
-
-<!-- SITECATALYST CODE -->
-<script language="javascript" src="/js/s_code_remote_h.js" type="text/javascript"></script>
-<script language="javascript" type="text/javascript">
-<!--
-// Copyright 1997-2004 Omniture, Inc.
-
-// PAGE SPECIFIC VIA ISOL G & H
-
-var s_pageName='Omniture: Homepage';
-var s_channel='Home';
-var s_prop7='English';
-s.pageName='Omniture: Homepage';
-s.channel='Home';
-s.prop6='English';
-
-// END PAGE SPECIFIC VIA ISOL
-
-// SiteCatalyst code version: G.7.
-var s_server="www.omniture.com"
-  var s_campaign=""
-  var s_events=""
-  var s_products=""
-  var s_prop1="Non-Customer"
-  var s_prop15=""
-  var s_prop16=""
-  var s_eVar3 = ""
-  var s_eVar4 = ""
-  var s_eVar5 = ""
-  var s_eVar6 = ""
-  var s_eVar7 = ""
-  var s_eVar8 = ""
-  var s_eVar9 = ""
-  var s_eVar10 = ""
-  var s_eVar11 = ""
-  var s_eVar13 = ""
-  var s_eVar14 = ""
-  var s_eVar15 = ""
-  // END G.7 CODE IMPLEMENTATION
-
-  // H.1 CODE BEGIN
-  s.server="www.omniture.com"
-  s.campaign=""
-  s.events=""
-  s.products=""
-  s.prop1="Non-Customer"
-  s.prop3="Natural Search (All Other Engines)|"+s.pageName
-  s.prop5="Untracked"
-  s.prop14=""
-  s.prop15=""
-  s.prop16=""
-  s.prop17=""
-  s.prop18=""
-  s.prop19=""
-  s.prop20="Non-Customer"
-  s.prop21=""
-  s.prop22=""
-  s.prop23=""
-  s.prop24=""
-  s.prop25=""
-  s.prop26=""
-  s.prop27=""
-  s.prop28=""
-  s.prop30=""
-  s.prop32="67.41.129.163"
-  s.prop33=""
-  s.prop34=""
-  s.prop35=""
-  s.eVar7=""
-  s.eVar8=""
-  s.eVar9=""
-  s.eVar10=""
-  s.eVar11=""
-  s.eVar13=""
-  s.eVar28=""
-  s.eVar33=""
-  // H.1 CODE END
-
-  var s_code=s.t();if(s_code)document.write(s_code)
-         //-->
-         </script>
-         <script language="javascript" src="/js/s_code_remote_g.js" type="text/javascript"></script>
-         <noscript>
-         <img src="http://omniturecom.112.2O7.net/b/ss/omniturecom/1/H.7--NS/0" height="1" width="1" border="0" alt="" />
-         </noscript>
-
-
-         <!-- BANNER TRACKING IF ANY -->
-         <script language="javascript" src="/js/functions.js"></script>
-         <script language="javascript" src="/js/banner_track.js"></script>
-         <!-- END SITECATALYST CODE -->
-
-*/
Index: omniture_basic.info
===================================================================
RCS file: omniture_basic.info
diff -N omniture_basic.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ omniture_basic.info	8 Jan 2010 19:36:56 -0000
@@ -0,0 +1,7 @@
+; $Id$
+name = Omniture basic variables
+description = Adds basic variables (taxonomy terms, page title, user name) to Omniture SiteCatalyst.
+core = 7.x
+files[] = omniture_basic.module
+files[] = omniture_basic.install
+dependencies[] = omniture
Index: omniture_basic.install
===================================================================
RCS file: omniture_basic.install
diff -N omniture_basic.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ omniture_basic.install	8 Jan 2010 18:16:18 -0000
@@ -0,0 +1,32 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Installs the module.
+ */
+
+/**
+ * Implements hook_uninstall().
+ */
+function omniture_basic_uninstall() {
+  $or = db_or()
+    ->condition('v.name', 'omniture_vocabvidvar_%', 'LIKE')
+    ->condition('v.name', 'omniture_var_%', 'LIKE');
+
+  $result = db_select('variable', 'v')
+    ->fields('v')
+    ->condition($or)
+    ->execute();
+
+  foreach ($result as $variable) {
+    variable_del($variable);
+  }
+}
+
+/**
+ * Update to Drupal 7. Set the version number for new installs.
+ */
+function omniture_basic_update_7000() {
+  $ret = array();
+  return $ret;
+}
Index: omniture_basic.module
===================================================================
RCS file: omniture_basic.module
diff -N omniture_basic.module
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ omniture_basic.module	8 Jan 2010 19:48:44 -0000
@@ -0,0 +1,94 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * This module is a basic example how to add variabled to Omniture SiteCatalyst.
+ * Creates variables from taxonomy terms, page title and user name.
+ */
+
+/**
+ * Implements hook_omniture_variables().
+ */
+function omniture_basic_omniture_variables() {
+  if ($variable_name = variable_get('omniture_var_pagename', FALSE)) {
+    $variables[$variable_name] = strip_tags(drupal_get_title());
+  }
+  if ($variable_name = variable_get('omniture_var_username', FALSE)) {
+    global $user;
+    $variables[$variable_name] = format_username($user);
+  }
+
+  // Taxonomy specific stuff - only for nodes.
+  if (module_exists('taxonomy') && $node = menu_get_object()) {
+    $omniture_taxonomy = array();
+
+    $fields = field_info_instances('node', $node->type);
+    foreach ($fields as $field) {
+      if ($field['widget']['module'] != 'taxonomy') {
+        // Not a taxonomy field.
+        continue;
+      }
+      // @todo: what to do with multilingual terms?
+      if (isset($node->{$field['field_name']}['und'][0]['taxonomy_term'])) {
+        foreach ($node->{$field['field_name']}['und'] as $term) {
+          if ($variable_name = variable_get("omniture_vocabvidvar_{$term['taxonomy_term']->vid}", FALSE)) {
+            $omniture_taxonomy[$variable_name][] = $term['taxonomy_term']->name;
+          }
+        }
+      }
+    }
+
+    foreach ($omniture_taxonomy as $variable_name => $terms_for_omniture) {
+      $variables[$variable_name] = implode(',', $terms_for_omniture);
+    }
+  }
+
+  return array('variables' => $variables);
+}
+
+/**
+ * Implements hook_form_FORM_ID_alter().
+ */
+function omniture_basic_form_omniture_admin_settings_alter(&$form, &$form_state) {
+  // Allow setting a vocabulary into a variable.
+  if (module_exists('taxonomy')) {
+    $form['vocabs'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Vocabulary variables'),
+      '#collapsible' => TRUE,
+      '#collapsed' => TRUE,
+      '#description' => t('Define which vocabularies should be tracked by which SiteCatalyst variables. Only applies to the full node view (e.g. node/1 or the aliased version of a node). Leave blank to disable for a vocabulary. Multiple terms from a "Multiple select" vocabulary will be placed into a comma separated list.'),
+      '#weight' => '-4',
+    );
+
+    $vocabularies = taxonomy_get_vocabularies();
+    foreach ($vocabularies as $vid => $vocab) {
+      $form['vocabs']["omniture_vocabvidvar_{$vocab->vid}"] = array(
+        '#type' => 'textfield',
+        '#title' => t('Variable for %vocab', array('%vocab' => $vocab->name)),
+        '#default_value' => variable_get("omniture_vocabvidvar_{$vocab->vid}", FALSE),
+      );
+    }
+  }
+
+  $form['vars'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Variables'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('Define some SiteCatalyst variables. Leave blank to not track certain variables.'),
+    '#weight' => '-5',
+  );
+
+  $form['vars']['omniture_var_pagename'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Variable for page title'),
+    '#default_value' => variable_get('omniture_var_pagename', FALSE),
+  );
+  $form['vars']['omniture_var_username'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Variable for user name'),
+    '#default_value' => variable_get('omniture_var_username', FALSE),
+  );
+}
