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
00033
00034
00035 class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Store extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
00036 {
00037 protected $_skipAllStoresLabel = false;
00038
00039
00040
00041
00042
00043
00044 protected function _getStoreModel()
00045 {
00046 return Mage::getSingleton('adminhtml/system_store');
00047 }
00048
00049 protected function _getShowAllStoresLabelFlag()
00050 {
00051 return $this->getColumn()->getData('skipAllStoresLabel')?$this->getColumn()->getData('skipAllStoresLabel'):$this->_skipAllStoresLabel;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060 public function render(Varien_Object $row)
00061 {
00062 $skipAllStoresLabel = $this->_getShowAllStoresLabelFlag();
00063 $origStores = $row->getData($this->getColumn()->getIndex());
00064 $showNumericStores = (bool)$this->getColumn()->getShowNumericStores();
00065 $stores = array();
00066 if (!is_array($origStores)) {
00067 $origStores = array($origStores);
00068 }
00069 foreach ($origStores as $origStore) {
00070 if (is_numeric($origStore)) {
00071 if (0 == $origStore) {
00072 if (!$skipAllStoresLabel) {
00073 $stores[] = Mage::helper('adminhtml')->__('All Store Views');
00074 }
00075 }
00076 elseif ($storeName = $this->_getStoreModel()->getStoreName($origStore)) {
00077 if ($this->getColumn()->getStoreView()) {
00078 $store = $this->_getStoreModel()->getStoreNameWithWebsite($origStore);
00079 } else {
00080 $store = $this->_getStoreModel()->getStoreNamePath($origStore);
00081 }
00082 $layers = array();
00083 foreach (explode('/', $store) as $key => $value) {
00084 $layers[] = str_repeat(" ", $key * 3) . $value;
00085 }
00086 $stores[] = implode('<br/>', $layers);
00087 }
00088 elseif ($showNumericStores) {
00089 $stores[] = $origStore;
00090 }
00091 }
00092 elseif (is_null($origStore) && $row->getStoreName()) {
00093 $stores[] = $row->getStoreName() . ' ' . $this->__('[deleted]');
00094 }
00095 else {
00096 $stores[] = $origStore;
00097 }
00098 }
00099 return $stores ? join('<br/> ', $stores) : ' ';
00100 }
00101
00102 }