_oTemplate = $oTemplate; else $this->_oTemplate = BxDolTemplate::getInstance(); $this->_sBrowseUrl = bx_append_url_params('searchKeyword.php', array( 'cat' => '{category}', 'keyword' => '{keyword}' )) . '{sections}'; } public function getCategoryTitle($sValue) { $a = BxDolForm::getDataItems($this->_aObject['list_name']); if (!$a || !isset($a[$sValue])) return ''; return $a[$sValue]; } public function getCategoryUrl($sValue) { return BX_DOL_URL_ROOT . bx_replace_markers($this->_sBrowseUrl, array( 'category' => rawurlencode($this->getObjectName()), 'keyword' => rawurlencode($sValue), 'sections' => $this->_aObject['search_object'] ? '§ion[]=' . rawurlencode($this->_aObject['search_object']) : '' )); } /** * Get link to list all items with the same category * @param $sName category title * @param $sValue category value * @return category name wrapped with A tag */ public function getCategoryLink($sName, $sValue) { $sUrl = $this->getCategoryUrl($sValue); return '' . $sName . ''; } /** * Get all categories list * @param $bDisplayEmptyCats display categories with no items, true by default * @return categories list html */ public function getCategoriesList($bDisplayEmptyCats = true, $bAsArray = false) { $a = BxDolForm::getDataItems($this->_aObject['list_name']); if (!$a) return $bAsArray ? array() : ''; $aVars = array('bx_repeat:cats' => array()); foreach ($a as $sValue => $sName) { if (!is_numeric($sValue) && !$sValue) continue; $iNum = $this->getItemsNum($sValue); if (!$bDisplayEmptyCats && !$iNum) continue; $aVars['bx_repeat:cats'][] = array( 'url' => $this->getCategoryUrl($sValue), 'name' => $sName, 'value' => $sValue, 'num' => $iNum, ); } if ($bAsArray) return $aVars; if (!$aVars['bx_repeat:cats']) return ''; return $this->_oTemplate->parseHtmlByName('category_list.html', $aVars); } } /** @} */