/** * Merge information of 2 xml element (was converted to array) * * @param array &$element1 Array element * @param array &$element2 Array element * * @return array Merged array */ public static function merge_info(&$element1, &$element2) { for ($i = 0, $n = count($element1['children']); $i < $n; $i++) { $child1 = $element1['children'][$i]; $name = $child1['name']; if ($name == 'blocks') { $child2 = T3Common::arr_find_child($element2, 'blocks', 'name', $child1['attributes']['name']); if (!$child2) { //Add child1 into element2 $element2['children'][] = $child1; } } else { $child2 = null; if (isset($child1['attributes']['name'])) { $child2 = T3Common::arr_find_child($element2, $name, 'name', $child1['attributes']['name']); } else { $child2 = T3Common::arr_find_child($element2, $name); } if (!count($child1['children']) || !$child2) { //$element2->{$name} = array(); //Add child1 into element2 $element2['children'][] = $child1; } else { $element2['children'][isset($child2['index']) ? $child2['index'] : 0] = T3Common::merge_info($child1, $child2); } } } return $element2; }
/** * Get blocks by name * * @param $name string * Block name * * @return array List block */ function &getBlocksXML($name) { $null = null; $layout =& $this->getLayoutXML(); if (!$layout) { return $null; } $blocks =& T3Common::arr_find_child($layout, 'blocks', 'name', $name); return $blocks; }