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_Filter_Store extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
00036 {
00037
00038 public function getHtml()
00039 {
00040 $storeModel = Mage::getSingleton('adminhtml/system_store');
00041
00042 $websiteCollection = $storeModel->getWebsiteCollection();
00043 $groupCollection = $storeModel->getGroupCollection();
00044 $storeCollection = $storeModel->getStoreCollection();
00045
00046 $allShow = $this->getColumn()->getStoreAll();
00047
00048 $html = '<select name="' . ($this->getColumn()->getName() ? $this->getColumn()->getName() : $this->getColumn()->getId()) . '" ' . $this->getColumn()->getValidateClass() . '>';
00049 $value = $this->getColumn()->getValue();
00050 if ($allShow) {
00051 $html .= '<option value="0"' . ($value == 0 ? ' selected="selected"' : '') . '>' . Mage::helper('adminhtml')->__('All Store Views') . '</option>';
00052 } else {
00053 $html .= '<option value=""' . (!$value ? ' selected="selected"' : '') . '></option>';
00054 }
00055 foreach ($websiteCollection as $website) {
00056 $websiteShow = false;
00057 foreach ($groupCollection as $group) {
00058 if ($group->getWebsiteId() != $website->getId()) {
00059 continue;
00060 }
00061 $groupShow = false;
00062 foreach ($storeCollection as $store) {
00063 if ($store->getGroupId() != $group->getId()) {
00064 continue;
00065 }
00066 if (!$websiteShow) {
00067 $websiteShow = true;
00068 $html .= '<optgroup label="' . $website->getName() . '"></optgroup>';
00069 }
00070 if (!$groupShow) {
00071 $groupShow = true;
00072 $html .= '<optgroup label=" ' . $group->getName() . '">';
00073 }
00074 $value = $this->getValue();
00075 $html .= '<option value="' . $store->getId() . '"' . ($value == $store->getId() ? ' selected="selected"' : '') . '> ' . $store->getName() . '</option>';
00076 }
00077 if ($groupShow) {
00078 $html .= '</optgroup>';
00079 }
00080 }
00081 }
00082 if ($this->getColumn()->getDisplayDeleted()) {
00083 $selected = ($this->getValue() == '_deleted_') ? ' selected' : '';
00084 $html.= '<option value="_deleted_"'.$selected.'>'.$this->__('[ deleted ]').'</option>';
00085 }
00086 $html .= '</select>';
00087 return $html;
00088 }
00089
00090 public function getCondition()
00091 {
00092 if (is_null($this->getValue())) {
00093 return null;
00094 }
00095 if ($this->getValue() == '_deleted_') {
00096 return array('null' => true);
00097 }
00098 else {
00099 return array('eq' => $this->getValue());
00100 }
00101 }
00102
00103 }