You are here

private function HeartbeatActivity::rebuild_arguments in Heartbeat 6.4

Same name and namespace in other branches
  1. 6.3 includes/heartbeatactivity.inc \HeartbeatActivity::rebuild_arguments()
  2. 7 includes/heartbeatactivity.inc \HeartbeatActivity::rebuild_arguments()

Rebuild the arguments for variables to share within this object

Parameters

array $raw_input of arguments:

2 calls to HeartbeatActivity::rebuild_arguments()
HeartbeatActivity::save_locale in includes/heartbeatactivity.inc
Save activity log with multilingual content and multilingual parts to pre-translate
HeartbeatActivity::_save in includes/heartbeatactivity.inc
Save activity log

File

includes/heartbeatactivity.inc, line 456
HeartbeatActivity object Defines one heartbeat activity object.

Class

HeartbeatActivity
Class defines an activity message object

Code

private function rebuild_arguments($raw_input, $locale = FALSE) {
  $args = array();
  if ($locale) {

    // Variables that need to be pre-translated go here
    $args['locale'] = array();
  }
  $tags = heartbeat_allowed_tags();

  // Rebuild arguments with language tokens
  foreach ($this->variables as $key => $value) {
    $value = filter_xss($value, $tags);

    // Leave $key[0] == "!"  asis
    if ($key[0] != "@" && $key[0] != "#") {

      //continue; // bad argument
    }
    $oldkey = $key;

    // Reset the key of the arguments to ! to parse the next
    // tokenization asis.
    if ($key[0] == "@") {
      $key[0] = "!";
    }

    // # and @ token replacement prefixes are kept,
    // but set a flag for it in the raw_arguments
    if ($key[0] == "#") {

      // if it has to be translated ...
      if ($locale) {
        $args['locale'][$key] = $value;
      }

      // Now reset the key
      $key[0] = "!";
    }

    // if argument is prefilled, override
    if (isset($raw_input[$oldkey])) {
      $args[$key] = $raw_input[$oldkey];
      continue;
    }

    // Argument gets the value as in variables
    $args[$key] = $value;
  }
  return $args;
}