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
00029
00030
00031
00032 class Mage_Core_Model_App_Area
00033 {
00034 const AREA_GLOBAL = 'global';
00035 const AREA_FRONTEND = 'frontend';
00036 const AREA_ADMIN = 'admin';
00037
00038 const PART_CONFIG = 'config';
00039 const PART_EVENTS = 'events';
00040 const PART_TRANSLATE= 'translate';
00041 const PART_DESIGN = 'design';
00042
00043
00044
00045
00046
00047
00048 protected $_loadedParts;
00049
00050
00051
00052
00053
00054
00055 protected $_code;
00056
00057
00058
00059
00060
00061
00062 protected $_application;
00063
00064 public function __construct($areaCode, $application)
00065 {
00066 $this->_code = $areaCode;
00067 $this->_application = $application;
00068 }
00069
00070
00071
00072
00073
00074
00075 public function getApplication()
00076 {
00077 return $this->_application;
00078 }
00079
00080
00081
00082
00083
00084
00085
00086 public function load($part=null)
00087 {
00088 if (is_null($part)) {
00089 $this->_loadPart(self::PART_CONFIG)
00090 ->_loadPart(self::PART_EVENTS)
00091 ->_loadPart(self::PART_DESIGN)
00092 ->_loadPart(self::PART_TRANSLATE);
00093 }
00094 else {
00095 $this->_loadPart($part);
00096 }
00097 return $this;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 protected function _loadPart($part)
00107 {
00108 if (isset($this->_loadedParts[$part])) {
00109 return $this;
00110 }
00111 Varien_Profiler::start('mage::dispatch::controller::action::predispatch::load_area::'.$this->_code.'::'.$part);
00112 switch ($part) {
00113 case self::PART_CONFIG:
00114 $this->_initConfig();
00115 break;
00116 case self::PART_EVENTS:
00117 $this->_initEvents();
00118 break;
00119 case self::PART_TRANSLATE:
00120 $this->_initTranslate();
00121 break;
00122 case self::PART_DESIGN:
00123 $this->_initDesign();
00124 break;
00125 }
00126 $this->_loadedParts[$part] = true;
00127 Varien_Profiler::stop('mage::dispatch::controller::action::predispatch::load_area::'.$this->_code.'::'.$part);
00128 return $this;
00129 }
00130
00131 protected function _initConfig()
00132 {
00133
00134 }
00135
00136 protected function _initEvents()
00137 {
00138 Mage::app()->addEventArea($this->_code);
00139 #Mage::app()->getConfig()->loadEventObservers($this->_code);
00140 return $this;
00141 }
00142
00143 protected function _initTranslate()
00144 {
00145 Mage::app()->getTranslator()->init($this->_code);
00146 return $this;
00147 }
00148
00149 protected function _initDesign()
00150 {
00151 $designPackage = Mage::getSingleton('core/design_package');
00152 if ($designPackage->getArea() != self::AREA_FRONTEND)
00153 return;
00154
00155 $currentStore = Mage::app()->getStore()->getStoreId();
00156
00157 $designChange = Mage::getSingleton('core/design')
00158 ->loadChange($currentStore);
00159
00160 if ($designChange->getData()) {
00161 $designPackage->setPackageName($designChange->getPackage())
00162 ->setTheme($designChange->getTheme());
00163 }
00164 }
00165 }