You are here

function _mandrill_parse_regions in Mandrill 7.2

Same name and namespace in other branches
  1. 7 modules/mandrill_template/mandrill_template.admin.inc \_mandrill_parse_regions()

Parse a Mandrill template to extract its regions.

The Mandrill API does not provide an elegant data structure containing the mc:edit tags for a given template, but rather a big pile of ugly HTML containing the tags. We need to parse through it.

1 call to _mandrill_parse_regions()
mandrill_template_map_form in modules/mandrill_template/mandrill_template.admin.inc
Return a form for adding/editing a Mandrill template map.

File

modules/mandrill_template/mandrill_template.admin.inc, line 195
Administrative forms for Mandrill Template module.

Code

function _mandrill_parse_regions($html, $tag = 'mc:edit') {
  $instances = array();
  $offset = 0;
  $inst = NULL;
  while ($offset = strpos($html, $tag, $offset)) {
    $start = 1 + strpos($html, '"', $offset);
    $length = strpos($html, '"', $start) - $start;
    $inst = substr($html, $start, $length);
    $instances[$inst] = $inst;
    $offset = $start + $length;
  }
  return $instances;
}