Mage_CatalogSearch_Block_Advanced_Form Class Reference

Inheritance diagram for Mage_CatalogSearch_Block_Advanced_Form:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 _prepareLayout ()
 getSearchableAttributes ()
 getAttributeLabel ($attribute)
 getAttributeValidationClass ($attribute)
 getAttributeValue ($attribute, $part=null)
 getAvailableCurrencies ()
 getCurrencyCount ()
 getCurrency ($attribute)
 getAttributeInputType ($attribute)
 getAttributeSelectElement ($attribute)
 getAttributeYesNoElement ($attribute)
 getModel ()
 getSearchPostUrl ()
 getDateInput ($attribute, $part= 'from')

Protected Member Functions

 _getSelectBlock ()
 _getDateBlock ()


Detailed Description

Definition at line 34 of file Form.php.


Member Function Documentation

_getDateBlock (  )  [protected]

Definition at line 234 of file Form.php.

00235     {
00236         $block = $this->getData('_date_block');
00237         if (is_null($block)) {
00238             $block = $this->getLayout()->createBlock('core/html_date');
00239             $this->setData('_date_block', $block);
00240         }
00241         return $block;
00242     }

_getSelectBlock (  )  [protected]

Definition at line 224 of file Form.php.

00225     {
00226         $block = $this->getData('_select_block');
00227         if (is_null($block)) {
00228             $block = $this->getLayout()->createBlock('core/html_select');
00229             $this->setData('_select_block', $block);
00230         }
00231         return $block;
00232     }

_prepareLayout (  ) 

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 36 of file Form.php.

00037     {
00038         if ($headBlock = $this->getLayout()->getBlock('head')) {
00039             $headBlock->setTitle(Mage::helper('catalogsearch')->__('Catalog Advanced Search'));
00040         }
00041 
00042         // add Home breadcrumb
00043         if ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs')) {
00044             $breadcrumbs->addCrumb('home', array(
00045                 'label'=>Mage::helper('catalogsearch')->__('Home'),
00046                 'title'=>Mage::helper('catalogsearch')->__('Go to Home Page'),
00047                 'link'=>Mage::getBaseUrl()
00048             ))->addCrumb('search', array(
00049                 'label'=>Mage::helper('catalogsearch')->__('Catalog Advanced Search')
00050             ));
00051         }
00052         return parent::_prepareLayout();
00053     }

getAttributeInputType ( attribute  ) 

Retrieve attribute input type

Parameters:
$attribute 
Returns:
string

Definition at line 149 of file Form.php.

00150     {
00151         $dataType   = $attribute->getBackend()->getType();
00152         $imputType  = $attribute->getFrontend()->getInputType();
00153         if ($imputType == 'select' || $imputType == 'multiselect') {
00154             return 'select';
00155         }
00156 
00157         if ($imputType == 'boolean') {
00158             return 'yesno';
00159         }
00160 
00161         if ($imputType == 'price') {
00162             return 'price';
00163         }
00164 
00165         if ($dataType == 'int' || $dataType == 'decimal') {
00166             return 'number';
00167         }
00168 
00169         if ($dataType == 'datetime') {
00170             return 'date';
00171         }
00172 
00173         return 'string';
00174     }

getAttributeLabel ( attribute  ) 

Retrieve attribute label

Parameters:
$attribute 
Returns:
string

Definition at line 72 of file Form.php.

00073     {
00074         return Mage::helper('catalog')->__($attribute->getFrontend()->getLabel());
00075     }

getAttributeSelectElement ( attribute  ) 

Definition at line 176 of file Form.php.

00177     {
00178         $extra = '';
00179         $options = $attribute->getSource()->getAllOptions(false);
00180 
00181         $name = $attribute->getAttributeCode();
00182 
00183         // 2 - avoid yes/no selects to be multiselects
00184         if (is_array($options) && count($options)>2) {
00185             $extra = 'multiple="multiple" size="4"';
00186             $name.= '[]';
00187         }
00188         else {
00189             array_unshift($options, array('value'=>'', 'label'=>Mage::helper('catalogsearch')->__('All')));
00190         }
00191 
00192 
00193 
00194         return $this->_getSelectBlock()
00195             ->setName($name)
00196             ->setId($attribute->getAttributeCode())
00197             ->setTitle($this->getAttributeLabel($attribute))
00198             ->setExtraParams($extra)
00199             ->setValue($this->getAttributeValue($attribute))
00200             ->setOptions($options)
00201             ->setClass('multiselect')
00202             ->getHtml();
00203     }

getAttributeValidationClass ( attribute  ) 

Retrieve attribute input validation class

Parameters:
$attribute 
Returns:
string

Definition at line 83 of file Form.php.

00084     {
00085         return $attribute->getFrontendClass();
00086     }

getAttributeValue ( attribute,
part = null 
)

Definition at line 88 of file Form.php.

00089     {
00090         $value = $this->getRequest()->getQuery($attribute->getAttributeCode());
00091         if ($part && $value) {
00092             if (isset($value[$part])) {
00093                 $value = $value[$part];
00094             }
00095             else {
00096                 $value = '';
00097             }
00098         }
00099 
00100         if (!is_array($value)) {
00101             $value = htmlspecialchars($value);
00102         }
00103         return $value;
00104     }

getAttributeYesNoElement ( attribute  ) 

Definition at line 205 of file Form.php.

00206     {
00207         $options = array(
00208             array('value' => '',  'label' => Mage::helper('catalogsearch')->__('All')),
00209             array('value' => '1', 'label' => Mage::helper('catalogsearch')->__('Yes')),
00210             array('value' => '0', 'label' => Mage::helper('catalogsearch')->__('No'))
00211         );
00212 
00213         $name = $attribute->getAttributeCode();
00214         return $this->_getSelectBlock()
00215             ->setName($name)
00216             ->setId($attribute->getAttributeCode())
00217             ->setTitle($this->getAttributeLabel($attribute))
00218             ->setExtraParams("")
00219             ->setValue($this->getAttributeValue($attribute))
00220             ->setOptions($options)
00221             ->getHtml();
00222     }

getAvailableCurrencies (  ) 

Definition at line 106 of file Form.php.

00107     {
00108         $currencies = $this->getData('_currencies');
00109         if (is_null($currencies)) {
00110             $currencies = array();
00111             $codes = Mage::app()->getStore()->getAvailableCurrencyCodes(true);
00112             if (is_array($codes) && count($codes)) {
00113                 $rates = Mage::getModel('directory/currency')->getCurrencyRates(
00114                     Mage::app()->getStore()->getBaseCurrency(),
00115                     $codes
00116                 );
00117 
00118                 foreach ($codes as $code) {
00119                     if (isset($rates[$code])) {
00120                         $currencies[$code] = $code;
00121                     }
00122                 }
00123             }
00124 
00125             $this->setData('currencies', $currencies);
00126         }
00127         return $currencies;
00128     }

getCurrency ( attribute  ) 

Definition at line 135 of file Form.php.

00136     {
00137         return Mage::app()->getStore()->getCurrentCurrencyCode();
00138 
00139         $baseCurrency = Mage::app()->getStore()->getBaseCurrency()->getCurrencyCode();
00140         return $this->getAttributeValue($attribute, 'currency') ? $this->getAttributeValue($attribute, 'currency') : $baseCurrency;
00141     }

getCurrencyCount (  ) 

Definition at line 130 of file Form.php.

00131     {
00132         return count($this->getAvailableCurrencies());
00133     }

getDateInput ( attribute,
part = 'from' 
)

Definition at line 258 of file Form.php.

00259     {
00260         $name = $attribute->getAttributeCode() . '[' . $part . ']';
00261         $value = $this->getAttributeValue($attribute, $part);
00262 
00263         return $this->_getDateBlock()
00264             ->setName($name)
00265             ->setId($attribute->getAttributeCode() . '_' . $part)
00266             ->setTitle($this->getAttributeLabel($attribute))
00267             ->setValue($value)
00268             ->setImage($this->getSkinUrl('images/calendar.gif'))
00269             ->setFormat('%m/%d/%y')
00270             ->setClass('input-text')
00271             ->getHtml();
00272     }

getModel (  ) 

Retrieve advanced search model object

Returns:
Mage_CatalogSearch_Model_Advanced

Definition at line 248 of file Form.php.

00249     {
00250         return Mage::getSingleton('catalogsearch/advanced');
00251     }

getSearchableAttributes (  ) 

Retrieve collection of product searchable attributes

Returns:
Varien_Data_Collection_Db

Definition at line 60 of file Form.php.

00061     {
00062         $attributes = $this->getModel()->getAttributes();
00063         return $attributes;
00064     }

getSearchPostUrl (  ) 

Definition at line 253 of file Form.php.

00254     {
00255         return $this->getUrl('*/*/result');
00256     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:49 2009 for Magento by  doxygen 1.5.8