You are here

function patterns_feed_rearrange_data in Patterns 7.2

Same name and namespace in other branches
  1. 6.2 patterns.module \patterns_feed_rearrange_data()
  2. 6 patterns.module \patterns_feed_rearrange_data()
  3. 7 includes/feed.inc \patterns_feed_rearrange_data()

File

includes/feed.inc, line 59
Patterns feed functions.

Code

function patterns_feed_rearrange_data($feed) {
  unset($feed['tag']);
  foreach ($feed as $key => $section) {
    $tag = $section['tag'];
    if ($tag == 'pattern') {
      unset($section['tag']);
      if (!isset($section['value'])) {
        foreach ($section as $t) {
          if ($t['tag'] == 'pid') {
            $pid = $t['value'];
            break;
          }
        }
        $result[$pid] = patterns_feed_rearrange_data($section);
      }
      else {
        $result[$tag] = $section['value'];
      }
    }
    else {
      unset($section['tag']);
      if (!isset($section['value'])) {
        $result[$tag] = patterns_feed_rearrange_data($section);
      }
      else {
        $result[$tag] = $section['value'];
      }
    }
  }
  return $result;
}