function patterns_xmlparser_rearrange_data in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_xmlparser/patterns_xmlparser.module \patterns_xmlparser_rearrange_data()
2 calls to patterns_xmlparser_rearrange_data()
- patterns_xmlparser_parse in patterns_xmlparser/
patterns_xmlparser.module - Creates a pattern from an XML data source.
- _patterns_xmlparser_process_action in patterns_xmlparser/
patterns_xmlparser.module
File
- patterns_xmlparser/
patterns_xmlparser.module, line 119
Code
function patterns_xmlparser_rearrange_data($pattern) {
foreach ($pattern as $key => $value) {
if (is_string($key)) {
unset($pattern[$key]);
}
else {
if ($value['xml_tag'] == PATTERNS_SECTION_INFO) {
$pattern[PATTERNS_SECTION_INFO] = _patterns_xmlparser_rearrange_data($value);
unset($pattern[PATTERNS_SECTION_INFO]['xml_tag']);
unset($pattern[$key]);
// TODO: unset in _patterns_xmlparser_rearrange_data
}
elseif ($value['xml_tag'] == PATTERNS_SECTION_MODULES) {
$pattern[PATTERNS_SECTION_MODULES] = _patterns_xmlparser_rearrange_data($value);
unset($pattern[PATTERNS_SECTION_MODULES]['xml_tag']);
unset($pattern[$key]);
// TODO: unset in _patterns_xmlparser_rearrange_data
}
else {
// There is no section, just actions
if (isset($value['tag'])) {
$pattern[] = _patterns_xmlparser_process_action($value);
unset($pattern[$key]);
continue;
}
// Process the section
$section = $value['xml_tag'];
$pattern[$section] = array();
unset($value['xml_tag']);
// Build actions
foreach ($value as $action) {
$pattern[$section][] = _patterns_xmlparser_process_action($action);
}
unset($pattern[$key]);
}
}
}
return $pattern;
}