1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Core
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: class Mage_Core_Model_Layout_Element extends Varien_Simplexml_Element
29: {
30: public function prepare($args)
31: {
32: switch ($this->getName()) {
33: case 'layoutUpdate':
34: break;
35:
36: case 'layout':
37: break;
38:
39: case 'update':
40: break;
41:
42: case 'remove':
43: break;
44:
45: case 'block':
46: $this->prepareBlock($args);
47: break;
48:
49: case 'reference':
50: $this->prepareReference($args);
51: break;
52:
53: case 'action':
54: $this->prepareAction($args);
55: break;
56:
57: default:
58: $this->prepareActionArgument($args);
59: break;
60: }
61: $children = $this->children();
62: foreach ($this as $child) {
63: $child->prepare($args);
64: }
65: return $this;
66: }
67:
68: public function getBlockName()
69: {
70: $tagName = (string)$this->getName();
71: if ('block'!==$tagName && 'reference'!==$tagName || empty($this['name'])) {
72: return false;
73: }
74: return (string)$this['name'];
75: }
76:
77: public function prepareBlock($args)
78: {
79: $type = (string)$this['type'];
80: $name = (string)$this['name'];
81:
82: $className = (string)$this['class'];
83: if (!$className) {
84: $className = Mage::getConfig()->getBlockClassName($type);
85: $this->addAttribute('class', $className);
86: }
87:
88: $parent = $this->getParent();
89: if (isset($parent['name']) && !isset($this['parent'])) {
90: $this->addAttribute('parent', (string)$parent['name']);
91: }
92:
93: return $this;
94: }
95:
96: public function prepareReference($args)
97: {
98: return $this;
99: }
100:
101: public function prepareAction($args)
102: {
103: $parent = $this->getParent();
104: $this->addAttribute('block', (string)$parent['name']);
105:
106: return $this;
107: }
108:
109: public function prepareActionArgument($args)
110: {
111: return $this;
112: }
113:
114: }
115: