You are here

function heartbeat_decode_message_variables in Heartbeat 7

Same name and namespace in other branches
  1. 6.4 heartbeat.common.inc \heartbeat_decode_message_variables()
  2. 6.2 heartbeat.module \heartbeat_decode_message_variables()
  3. 6.3 heartbeat.common.inc \heartbeat_decode_message_variables()

Decode heartbeat message variables

4 calls to heartbeat_decode_message_variables()
HeartbeatActivity::set_variables in includes/heartbeatactivity.inc
Sets the variables array Data variables are stored in an array to use them to build real variables. this means that when activity message objects get merged, the variables will be filled with variables components from all instances.
HeartbeatMessageTemplate::setArguments in includes/heartbeatmessagetemplate.inc
Sets the concatenation arguments
HeartbeatMessageTemplate::setVariables in includes/heartbeatmessagetemplate.inc
Sets the variables array Data variables are stored in an array to use them to build real variables. this means that when activity message objects get merged, the variables will be filled with variables components from all instances.
views_handler_field_heartbeat_message::render in views/views_handler_field_heartbeat_message.inc
Render the field.

File

./heartbeat.module, line 1628
Module file for heartbeat activity. Basic hook implementations and helper functions will be found here.

Code

function heartbeat_decode_message_variables($string, $object = FALSE) {
  if (!is_string($string)) {
    return array();
  }

  // Variable string need to be cleared from spaces to decode properly
  $array = explode("-|-", $string);
  $variables = array();
  if (!empty($array)) {
    foreach ($array as $varvalue) {
      $parts = explode("=|=", $varvalue);
      if (isset($parts[0]) && !empty($parts[0])) {
        if (preg_match("/\\*\\*\\*/", $parts[1])) {
          $parts[1] = explode("***", $parts[1]);
        }
        $variables[$parts[0]] = !is_array($parts[1]) ? (string) $parts[1] : $parts[1];
      }
    }
  }
  return $object ? (object) $variables : (array) $variables;
}