8 require_once(CH_DIRECTORY_PATH_CLASSES .
'ChWsbCategories.php');
18 parent::__construct();
20 $this->_sCategTmplName =
'view_categ.html';
21 $this->_sCategTmplContent =
'';
22 $this->_aOrderValues = array(
'none' =>
_t(
'_categ_order_none'),
'popular' =>
_t(
'_categ_order_popular'),
'recent' =>
_t(
'_categ_order_recent'));
29 if (
empty($aTotalCategories))
35 $iCount = count($aTotalCategories);
36 $iRowCount = floor($iCount / $iColumns) + (($iCount % $iColumns) ? 1 : 0);
37 $iWidthPr = floor(100 / $iColumns);
39 $sCode =
'<div class="categories_wrapper ch-def-bc-margin ch-def-font-large">';
41 foreach( $aTotalCategories
as $sCategory => $iCatCount ) {
42 if (!($i % $iRowCount)) {
45 $sCode .=
'<div class="categories_col" style="width: ' . $iWidthPr .
'%">';
48 $aUnit[
'catHref'] = str_replace(
'{tag}', rawurlencode(
title2uri($sCategory)), $sHrefTempl);
50 $aUnit[
'count'] = $iCatCount;
52 if ($this->_sCategTmplContent)
70 foreach ($this->aTagObjects
as $sKey => $aTagUnit) {
74 if (isset($aParam[
'filter']) && $aParam[
'filter']) {
75 $aParamTmp[
'type'] = $sKey;
77 $sHref .=
'&filter=' . $aParam[
'filter'];
80 if (isset($aParam[
'date']) && $aParam[
'date'])
81 $sHref .=
'&year=' . $aParam[
'date'][
'year'] .
82 '&month=' . $aParam[
'date'][
'month'] .
83 '&day=' . $aParam[
'date'][
'day'];
85 $aTopMenu[
$sName] = array(
'href' => $sHref,
'dynamic' =>
true,
'active' => ( $sKey == $aParam[
'type']));
96 foreach ($aTopMenu
as $sName => $aItem) {
99 'active' => $aItem[
'active'],
100 'href' => $aItem[
'href']
108 if (!isset($aParam[
'type']) || !$aParam[
'type'])
114 $sPageUrl .=
'?tags_mode=' . $aParam[
'type'];
116 if (!isset($aParam[
'orderby']) && isset(
$_REQUEST[
'orderby']) &&
$_REQUEST[
'orderby'] && isset($this->_aOrderValues[
$_REQUEST[
'orderby']]))
117 $aParam[
'orderby'] =
$_REQUEST[
'orderby'];
119 if (isset($aParam[
'filter']) && $aParam[
'filter'])
120 $sPageUrl .=
'&filter=' . $aParam[
'filter'];
121 if (isset($aParam[
'orderby']) && $aParam[
'orderby'])
122 $sPageUrl .=
'&orderby=' . $aParam[
'orderby'];
125 if (isset($aParam[
'date']) && $aParam[
'date']) {
126 $sPageUrl .=
'&year=' . $aParam[
'date'][
'year'] .
127 '&month=' . $aParam[
'date'][
'month'] .
128 '&day=' . $aParam[
'date'][
'day'];
131 if (isset($aParam[
'pagination']) && $aParam[
'pagination']) {
135 'page_url' => $sPageUrl .
'&page={page}&per_page={per_page}',
137 'page_links' =>
true,
138 'on_change_page' =>
"!loadDynamicBlock($iBoxId, this.href)"
141 $aParam[
'limit'] = $aPaginate[
'per_page'] = $aParam[
'pagination'];
144 $aParam[
'start'] = $aParam[
'limit'] * ($aPaginate[
'page'] - 1);
145 if ($aParam[
'start'] <=0)
146 $aParam[
'start'] = 0;
149 $sPaginate =
'<div class="clear_both"></div>'.$oPaginate->getPaginate();
167 $this->_sCategTmplName = $sTmplName;
172 $this->_sCategTmplContent = $sTmplContent;
180 'block_id' => $iBoxId,
181 'page_url' => $sPageUrl,
182 'ch_repeat:options' => array()
185 foreach ($this->_aOrderValues
as $sKey => $sVal)
186 $aTmplVars[
'ch_repeat:options'][] = array(
188 'ch_if:show_selected' => array(
189 'condition' => $sKey == $aParam[
'orderby'],
194 $sTopControls =
$oSysTemplate->parseHtmlByName(
'categories_top_controls.html', $aTmplVars);
196 return $oSysTemplate->parseHtmlByName(
'designbox_top_controls.html', array(
'top_controls' => $sTopControls));