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 abstract class Mage_Catalog_Model_Layer_Filter_Abstract extends Varien_Object
00035 {
00036
00037
00038
00039
00040
00041 protected $_requestVar;
00042
00043
00044
00045
00046
00047
00048 protected $_items;
00049
00050
00051
00052
00053
00054
00055
00056 public function setRequestVar($varName)
00057 {
00058 $this->_requestVar = $varName;
00059 return $this;
00060 }
00061
00062
00063
00064
00065
00066
00067 public function getRequestVar()
00068 {
00069 return $this->_requestVar;
00070 }
00071
00072
00073
00074
00075
00076
00077 public function getResetValue()
00078 {
00079 return null;
00080 }
00081
00082
00083
00084
00085
00086
00087 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
00088 {
00089 return $this;
00090 }
00091
00092
00093
00094
00095
00096
00097 public function getItemsCount()
00098 {
00099 return count($this->getItems());
00100 }
00101
00102
00103
00104
00105
00106
00107 public function getItems()
00108 {
00109 if (is_null($this->_items)) {
00110 $this->_initItems();
00111 }
00112 return $this->_items;
00113 }
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 protected function _getItemsData()
00130 {
00131 return array();
00132 }
00133
00134
00135
00136
00137
00138
00139 protected function _initItems()
00140 {
00141 $data = $this->_getItemsData();
00142 $items=array();
00143 foreach ($data as $itemData) {
00144 $items[] = $this->_createItem(
00145 $itemData['label'],
00146 $itemData['value'],
00147 $itemData['count']
00148 );
00149 }
00150 $this->_items = $items;
00151 return $this;
00152 }
00153
00154
00155
00156
00157
00158
00159
00160 public function getLayer()
00161 {
00162 $layer = $this->_getData('layer');
00163 if (is_null($layer)) {
00164 $layer = Mage::getSingleton('catalog/layer');
00165 $this->setData('layer', $layer);
00166 }
00167 return $layer;
00168 }
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178 protected function _createItem($label, $value, $count=0)
00179 {
00180 return Mage::getModel('catalog/layer_filter_item')
00181 ->setFilter($this)
00182 ->setLabel($label)
00183 ->setValue($value)
00184 ->setCount($count);
00185 }
00186
00187
00188
00189
00190
00191
00192 protected function _getFilterEntityIds()
00193 {
00194 return $this->getLayer()->getProductCollection()->getAllIdsCache();
00195 }
00196
00197
00198
00199
00200
00201
00202 protected function _getBaseCollectionSql()
00203 {
00204 return $this->getLayer()->getProductCollection()->getSelect();
00205 }
00206
00207
00208
00209
00210
00211
00212
00213 public function setAttributeModel($attribute)
00214 {
00215 $this->setRequestVar($attribute->getAttributeCode());
00216 $this->setData('attribute_model', $attribute);
00217 return $this;
00218 }
00219
00220
00221
00222
00223
00224
00225 public function getAttributeModel()
00226 {
00227 $attribute = $this->getData('attribute_model');
00228 if (is_null($attribute)) {
00229 Mage::throwException(Mage::helper('catalog')->__('Attribute model not defined'));
00230 }
00231 return $attribute;
00232 }
00233
00234
00235
00236
00237
00238
00239 public function getName()
00240 {
00241 return $this->getAttributeModel()->getFrontendLabel();
00242 }
00243 }