├── context_omniture.info ├── context_omniture.module └── plugins └── context_omniture_reaction.inc /context_omniture.info: -------------------------------------------------------------------------------- 1 | name = Omniture Context Intergation 2 | core = 7.x 3 | file[] = plugins/context_omniture_reaction.inc 4 | dependancies[] = context 5 | dependancies[] = omniture 6 | -------------------------------------------------------------------------------- /context_omniture.module: -------------------------------------------------------------------------------- 1 | array( 11 | 'path' => drupal_get_path('module', 'context_omniture') .'/plugins', 12 | 'file' => 'context_omniture_reaction.inc', 13 | 'class' => 'context_omniture_reaction', 14 | 'parent' => 'context_reaction', 15 | ), 16 | ); 17 | return $plugins; 18 | } 19 | 20 | /** 21 | * Implements hook_context_registry(). 22 | */ 23 | function context_omniture_context_registry() { 24 | $reg = array( 25 | 'reactions' => array( 26 | 'context_omniture_reaction' => array( 27 | 'title' => t('Omniture'), 28 | 'plugin' => 'context_omniture_reaction', 29 | ), 30 | ), 31 | ); 32 | return $reg; 33 | } 34 | 35 | /** 36 | * Implements hook_omniture_variables(). 37 | */ 38 | function context_omniture_omniture_variables() { 39 | 40 | //get variables from context 41 | if ($plugin = context_get_plugin('reaction', 'context_omniture_reaction')) { 42 | $variables = $plugin->execute($vars); 43 | dpm($variables); 44 | return array("variables" => $variables); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /plugins/context_omniture_reaction.inc: -------------------------------------------------------------------------------- 1 | fetch_from_context($context); 11 | $form = array( 12 | '#title' => 'Omniture Variables', 13 | '#type' => 'fieldset' 14 | ); 15 | $form['variables'] = array( 16 | '#title' => 'Name', 17 | '#type' => 'textarea', 18 | '#description' => t('A list of variables to set for omniture each line should be of the form VARIABLE = VALUE. tokens can be used for the value. variables examples are s.eVar10 or s.prop5'), 19 | '#default_value' => isset($settings['variables'])? $settings['variables'] : 0, 20 | ); 21 | $form['token_help'] = array( 22 | '#theme' => 'token_tree', 23 | '#token_types' => array('node'), 24 | 25 | ); 26 | return $form; 27 | } 28 | 29 | /* 30 | * implements context_reaction::execute() 31 | * 32 | * go through all active context and covert the 33 | * stored text in to variables. making sure we replace tokens 34 | * before for sending it out 35 | */ 36 | function execute(&$vars) { 37 | $settings = array(); 38 | //grab the node object so we can use node tokens 39 | $node = menu_get_object(); 40 | foreach ($this->get_contexts() as $context) { 41 | if (isset($context->reactions[$this->plugin])) { 42 | $settings = $context->reactions[$this->plugin]['variables']; 43 | $settings = token_replace($settings, array("node" => $node)); 44 | $lines = explode("\n", $settings); 45 | foreach($lines as $line) { 46 | if(preg_match("/^ *(.*?) *= *(.*?) *$/", $line, $match)) { 47 | $variables[$match[1]] = $match[2]; 48 | 49 | } 50 | } 51 | } 52 | } 53 | return $variables; 54 | } 55 | 56 | } 57 | --------------------------------------------------------------------------------