Mage_CatalogSearch_Helper_Data Class Reference

Inheritance diagram for Mage_CatalogSearch_Helper_Data:

Mage_Core_Helper_Abstract

List of all members.

Public Member Functions

 getQueryParamName ()
 getQuery ()
 isMinQueryLength ()
 getQueryText ()
 getEscapedQueryText ()
 getSuggestCollection ()
 getResultUrl ($query=null)
 getSuggestUrl ()
 getSearchTermUrl ()
 getAdvancedSearchUrl ()
 getMinQueryLength ($store=null)
 getMaxQueryLength ($store=null)
 getMaxQueryWords ($store=null)
 addNoteMessage ($message)
 setNoteMessages (array $messages)
 getNoteMessages ()
 checkNotes ($store=null)

Public Attributes

const QUERY_VAR_NAME = 'q'
const MAX_QUERY_LEN = 200

Protected Attributes

 $_query
 $_queryText
 $_messages = array()
 $_isMaxLength = false


Detailed Description

Catalog search helper

Author:
Magento Core Team <core@magentocommerce.com>

Definition at line 32 of file Data.php.


Member Function Documentation

addNoteMessage ( message  ) 

Add Note message

Parameters:
string $message
Returns:
Mage_CatalogSearch_Helper_Data

Definition at line 234 of file Data.php.

00235     {
00236         $this->_messages[] = $message;
00237         return $this;
00238     }

checkNotes ( store = null  ) 

Check query of a warnings

Parameters:
mixed $store
Returns:
Mage_CatalogSearch_Helper_Data

Definition at line 268 of file Data.php.

00269     {
00270         if ($this->_isMaxLength) {
00271             $this->addNoteMessage($this->__('Maximum Search query  length is %s. Your query was cut.', $this->getMaxQueryLength()));
00272         }
00273 
00274         $stringHelper = Mage::helper('core/string');
00275         /* @var $stringHelper Mage_Core_Helper_String */
00276 
00277         $searchType = Mage::getStoreConfig(Mage_CatalogSearch_Model_Fulltext::XML_PATH_CATALOG_SEARCH_TYPE);
00278         if ($searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_COMBINE ||
00279             $searchType == Mage_CatalogSearch_Model_Fulltext::SEARCH_TYPE_LIKE) {
00280 
00281             $wordsFull = $stringHelper->splitWords($this->getQueryText(), true);
00282             $wordsLike = $stringHelper->splitWords($this->getQueryText(), true, $this->getMaxQueryWords());
00283 
00284             if (count($wordsFull) > count($wordsLike)) {
00285                 $wordsCut = array_diff($wordsFull, $wordsLike);
00286 
00287                 $this->addNoteMessage(
00288                     $this->__('Maximum words count is %1$s. In your search query was cut next part: %2$s.',
00289                         $this->getMaxQueryWords(),
00290                         join(' ', $wordsCut)
00291                     )
00292                 );
00293             }
00294         }
00295     }

getAdvancedSearchUrl (  ) 

Retrieve advanced search URL

Returns:
string

Definition at line 190 of file Data.php.

00191     {
00192         return $this->_getUrl('catalogsearch/advanced');
00193     }

getEscapedQueryText (  ) 

Retrieve HTML escaped search query

Returns:
string

Definition at line 137 of file Data.php.

00138     {
00139         return $this->htmlEscape($this->getQueryText());
00140     }

getMaxQueryLength ( store = null  ) 

Retrieve maximum query length

Parameters:
mixed $store
Returns:
int

Definition at line 212 of file Data.php.

getMaxQueryWords ( store = null  ) 

Retrieve maximum query words count for like search

Parameters:
mixed $store
Returns:
int

Definition at line 223 of file Data.php.

getMinQueryLength ( store = null  ) 

Retrieve minimum query length

Parameters:
mixed $store
Returns:
int

Definition at line 201 of file Data.php.

getNoteMessages (  ) 

Retrieve Current Note messages

Returns:
array

Definition at line 257 of file Data.php.

00258     {
00259         return $this->_messages;
00260     }

getQuery (  ) 

Retrieve query model object

Returns:
Mage_CatalogSearch_Model_Query

Definition at line 80 of file Data.php.

00081     {
00082         if (!$this->_query) {
00083             $this->_query = Mage::getModel('catalogsearch/query')
00084                 ->loadByQuery($this->getQueryText())
00085                 ->setQueryText($this->getQueryText());
00086         }
00087         return $this->_query;
00088     }

getQueryParamName (  ) 

Retrieve search query parameter name

Returns:
string

Definition at line 70 of file Data.php.

00071     {
00072         return self::QUERY_VAR_NAME;
00073     }

getQueryText (  ) 

Retrieve search query text

Returns:
string

Definition at line 108 of file Data.php.

00109     {
00110         if (is_null($this->_queryText)) {
00111             $this->_queryText = $this->_getRequest()->getParam($this->getQueryParamName());
00112             if ($this->_queryText === null) {
00113                 $this->_queryText = '';
00114             } else {
00115                 if (is_array($this->_queryText)) {
00116                     $this->_queryText = null;
00117                 }
00118                 $this->_queryText = trim($this->_queryText);
00119                 if (Mage::helper('core/string')->strlen($this->_queryText) > $this->getMaxQueryLength()) {
00120                     $this->_queryText = Mage::helper('core/string')->substr(
00121                         $this->_queryText,
00122                         0,
00123                         $this->getMaxQueryLength()
00124                     );
00125                     $this->_isMaxLength = true;
00126                 }
00127             }
00128         }
00129         return $this->_queryText;
00130     }

getResultUrl ( query = null  ) 

Retrieve result page url

Parameters:
string $query
Returns:
string

Definition at line 158 of file Data.php.

00159     {
00160         return $this->_getUrl('catalogsearch/result', array('_query' => array(
00161             self::QUERY_VAR_NAME => $query
00162         )));
00163     }

getSearchTermUrl (  ) 

Retrieve search term url

Returns:
string

Definition at line 180 of file Data.php.

00181     {
00182         return $this->_getUrl('catalogsearch/term/popular');
00183     }

getSuggestCollection (  ) 

Retrieve suggest collection for query

Returns:
Mage_CatalogSearch_Model_Mysql4_Query_Collection

Definition at line 147 of file Data.php.

00148     {
00149         return $this->getQuery()->getSuggestCollection();
00150     }

getSuggestUrl (  ) 

Retrieve suggest url

Returns:
string

Definition at line 170 of file Data.php.

00171     {
00172         return $this->_getUrl('catalogsearch/ajax/suggest');
00173     }

isMinQueryLength (  ) 

Is a minimum query length

Returns:
bool

Definition at line 95 of file Data.php.

00096     {
00097         if (Mage::helper('core/string')->strlen($this->getQueryText()) < $this->getMinQueryLength()) {
00098             return true;
00099         }
00100         return false;
00101     }

setNoteMessages ( array messages  ) 

Set Note messages

Parameters:
array $messages
Returns:
Mage_CatalogSearch_Helper_Data

Definition at line 246 of file Data.php.

00247     {
00248         $this->_messages = $messages;
00249         return $this;
00250     }


Member Data Documentation

$_isMaxLength = false [protected]

Definition at line 63 of file Data.php.

$_messages = array() [protected]

Definition at line 56 of file Data.php.

$_query [protected]

Definition at line 42 of file Data.php.

$_queryText [protected]

Definition at line 49 of file Data.php.

const MAX_QUERY_LEN = 200

Definition at line 35 of file Data.php.

const QUERY_VAR_NAME = 'q'

Definition at line 34 of file Data.php.


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