00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class Mage_Core_Model_Layout_Element extends Varien_Simplexml_Element
00029 {
00030 public function prepare($args)
00031 {
00032 switch ($this->getName()) {
00033 case 'layoutUpdate':
00034 break;
00035
00036 case 'layout':
00037 break;
00038
00039 case 'update':
00040 break;
00041
00042 case 'remove':
00043 break;
00044
00045 case 'block':
00046 $this->prepareBlock($args);
00047 break;
00048
00049 case 'reference':
00050 $this->prepareReference($args);
00051 break;
00052
00053 case 'action':
00054 $this->prepareAction($args);
00055 break;
00056
00057 default:
00058 $this->prepareActionArgument($args);
00059 break;
00060 }
00061 $children = $this->children();
00062 foreach ($this as $child) {
00063 $child->prepare($args);
00064 }
00065 return $this;
00066 }
00067
00068 public function getBlockName()
00069 {
00070 $tagName = (string)$this->getName();
00071 if ('block'!==$tagName && 'reference'!==$tagName || empty($this['name'])) {
00072 return false;
00073 }
00074 return (string)$this['name'];
00075 }
00076
00077 public function prepareBlock($args)
00078 {
00079 $type = (string)$this['type'];
00080 $name = (string)$this['name'];
00081
00082 $className = (string)$this['class'];
00083 if (!$className) {
00084 $className = Mage::getConfig()->getBlockClassName($type);
00085 $this->addAttribute('class', $className);
00086 }
00087
00088 $parent = $this->getParent();
00089 if (isset($parent['name']) && !isset($this['parent'])) {
00090 $this->addAttribute('parent', (string)$parent['name']);
00091 }
00092
00093 return $this;
00094 }
00095
00096 public function prepareReference($args)
00097 {
00098 return $this;
00099 }
00100
00101 public function prepareAction($args)
00102 {
00103 $parent = $this->getParent();
00104 $this->addAttribute('block', (string)$parent['name']);
00105
00106 return $this;
00107 }
00108
00109 public function prepareActionArgument($args)
00110 {
00111 return $this;
00112 }
00113
00114 }