| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup Ads Ads
- * @ingroup UnaModules
- *
- * @{
- */
- /*
- * Module representation.
- */
- class BxAdsTemplate extends BxBaseModTextTemplate
- {
- function __construct(&$oConfig, &$oDb)
- {
- $this->MODULE = 'bx_ads';
- parent::__construct($oConfig, $oDb);
- $this->aMethodsToCallAddJsCss[] = 'categories';
- }
- public function entryBreadcrumb($aContentInfo, $aTmplVarsItems = array())
- {
- $CNF = &$this->_oConfig->CNF;
- $oPermalink = BxDolPermalinks::getInstance();
- $aTmplVarsItems = array();
- $this->_entryBreadcrumb($aContentInfo[$CNF['FIELD_CATEGORY']], $oPermalink, $aTmplVarsItems);
- $aTmplVarsItems = array_reverse($aTmplVarsItems);
-
- $aTmplVarsItems[] = array(
- 'url' => BX_DOL_URL_ROOT . $oPermalink->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aContentInfo[$CNF['FIELD_ID']]),
- 'title' => bx_process_output($aContentInfo[$CNF['FIELD_TITLE']])
- );
- return parent::entryBreadcrumb($aContentInfo, $aTmplVarsItems);
- }
- public function categoriesList($aParams = array())
- {
- $CNF = &$this->_oConfig->CNF;
- $sResult = $this->_categoriesList(0, array(
- 'url' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink($CNF['URL_CATEGORIES'], array('category' => ''))
- ));
- if(empty($sResult) && isset($aParams['show_empty']) && $aParams['show_empty'] === true)
- $sResult = MsgBox(_t('_Empty'));
- return $sResult;
- }
- /**
- * Use Gallery image for both because currently there is no Unit types with small thumbnails.
- */
- protected function getUnitThumbAndGallery ($aData)
- {
- list($sPhotoThumb, $sPhotoGallery) = parent::getUnitThumbAndGallery($aData);
- return array($sPhotoGallery, $sPhotoGallery);
- }
- protected function _categoriesList($iParentId, $aParams = array())
- {
- $aCategories = $this->_oDb->getCategories(array('type' => 'parent_id', 'parent_id' => $iParentId));
- $aTmplVars = array();
- foreach($aCategories as $aCategory) {
- $iItems = (int)$aCategory['items'];
- $sSibcategories = $this->_categoriesList($aCategory['id'], $aParams);
- if($iItems == 0 && empty($sSibcategories))
- continue;
- $aTmplVars[] = array(
- 'url' => $aParams['url'] . $aCategory['id'],
- 'title' => _t($aCategory['title']),
- 'bx_if:show_icon' => array(
- 'condition' => !empty($aCategory['icon']),
- 'content' => array(
- 'icon' => $aCategory['icon'],
- )
- ),
- 'bx_if:show_counter' => array(
- 'condition' => $iItems != 0,
- 'content' => array(
- 'items' => $iItems,
- )
- ),
- 'bx_if:show_subcategories' => array(
- 'condition' => !empty($sSibcategories),
- 'content' => array(
- 'subcategories' => $sSibcategories
- )
- )
- );
- }
- if(empty($aTmplVars))
- return '';
- return $this->parseHtmlByName('categories.html', array(
- 'bx_repeat:categories' => $aTmplVars
- ));
- }
- protected function _entryBreadcrumb($iCategory, &$oPermalink, &$aTmplVarsItems)
- {
- $CNF = &$this->_oConfig->CNF;
- $aCategory = $this->_oDb->getCategories(array('type' => 'id', 'id' => $iCategory));
- if(empty($aCategory) || !is_array($aCategory))
- return;
- $aTmplVarsItems[] = array(
- 'url' => BX_DOL_URL_ROOT . $oPermalink->permalink($CNF['URL_CATEGORIES'], array($CNF['GET_PARAM_CATEGORY'] => $aCategory['id'])),
- 'title' => bx_process_output(_t($aCategory['title']))
- );
- if(empty($aCategory['parent_id']))
- return;
- $this->_entryBreadcrumb((int)$aCategory['parent_id'], $oPermalink, $aTmplVarsItems);
- }
- }
- /** @} */
|