BxForumCategory.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup Forum Forum
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxForumCategory extends BxTemplCategory
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_aCategories;
  16. public function __construct($aObject, $oTemplate = null)
  17. {
  18. $this->_sModule = 'bx_forum';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. parent::__construct($aObject, $oTemplate);
  21. $CNF = $this->_oModule->_oConfig->CNF;
  22. $this->_sBrowseUrl = bx_append_url_params(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_CATEGORY_ENTRIES']), array(
  23. 'category' => '{keyword}'
  24. ), true, ['{keyword}']);
  25. $this->_aCategories = $this->_oModule->_oDb->getCategories(['type' => 'all_with_key']);
  26. }
  27. public function getCategoryIcon($sValue)
  28. {
  29. $aCategoryData = $this->_oModule->_oDb->getCategories(['type' => 'by_category', 'category' => $sValue]);
  30. return isset($aCategoryData['icon']) ? $aCategoryData['icon'] : '';
  31. }
  32. protected function _getCategoryData($aCategory)
  33. {
  34. $iCategory = (int)$aCategory['Value'];
  35. if(!isset($this->_aCategories[$iCategory]))
  36. return [];
  37. return [
  38. 'use' => 'icon',
  39. 'icon' => $this->_aCategories[$iCategory]['icon']
  40. ];
  41. }
  42. }
  43. /** @} */