Index: omniture.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/omniture/omniture.module,v
retrieving revision 1.6.4.2
diff -u -p -r1.6.4.2 omniture.module
--- omniture.module 19 Aug 2009 09:23:16 -0000 1.6.4.2
+++ omniture.module 23 Sep 2009 21:12:41 -0000
@@ -9,7 +9,7 @@
*
* @author: Greg Knaddison
* @co-maintainer: Matthew Tucker
- *
+ *
*/
function omniture_help($path, $arg) {
@@ -57,7 +57,7 @@ function omniture_footer($main = 0) {
// Don't track page views in the admin sections, or for certain roles
if (arg(0) != 'admin' && $track > 0) {
-
+
// Add any custom code snippets if specified
$codesnippet = variable_get('omniture_codesnippet', '');
@@ -117,14 +117,23 @@ function omniture_footer($main = 0) {
$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";
}
}
@@ -218,18 +227,39 @@ function omniture_admin_settings() {
'#collapsed' => TRUE,
'#description' => t('You can add custom SiteCatalyst code here.')
);
-
+
$form['advanced']['omniture_codesnippet'] = array(
'#type' => 'textarea',
'#title' => t('JavaScript Code'),
'#default_value' => variable_get('omniture_codesnippet', ''),
'#rows' => 15,
- '#description' => t('Paste custom code snippets here. These will be added to every page that SiteCatalyst appears on. For help with this feature see the cutroni.com blog. Do not include the <script> tags, and always end your code with a semicolon (;).', array('@snippets' => 'http://drupal.org/node/39282', '@blog' => 'http://cutroni.com/blog/') )
+ '#description' => t('Paste custom code snippets here. These will be added to every page that SiteCatalyst appears on. For help with this feature see the cutroni.com blog. Do not include the <script> tags, 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.
+ *
+ * @param string $name
+ * The property.
+ * @param string $value
+ * The value for the property.
+ */
+function omniture_set_variable($name = NULL, $value = NULL) {
+ static $variables;
+ if (empty($name)) {
+ return $variables;
+ }
+ else {
+ $variables[$name] = $value;
+ }
+}
+
+function omniture_get_variables() {
+ return omniture_set_variable();
+}
/**
* Example output from the omniture.com site itself.
@@ -241,10 +271,10 @@ function omniture_admin_settings() {
@@ -323,7 +353,7 @@ var s_server="www.omniture.com"
-
+