BxGlsrModule.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Glossary Glossary
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Glossary module
  13. */
  14. class BxGlsrModule extends BxBaseModTextModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. /**
  21. * Display terms by Alphabetical index
  22. * @return HTML string
  23. */
  24. public function serviceBrowseAlphabetical ($sUnitView = false, $bEmptyMessage = true, $bAjaxPaginate = true)
  25. {
  26. $aTmp = $this->_serviceBrowse('alphabetical', $sUnitView ? array('unit_view' => $sUnitView) : false, BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
  27. $iPerPage = getParam('bx_glossary_per_page_browse');
  28. $aLetterData = $this->_oDb->getAlphabeticalIndex();
  29. $iStartPage = bx_get('start') ? bx_get('start') : 0;
  30. foreach ($aLetterData as $key => $aLetter){
  31. $iStart = floor($aLetter['row_number'] / $iPerPage) * $iPerPage;
  32. if ($iStartPage == $iStart){
  33. $aLetterData[$key]['url'] = "javascript:BxGlsrAlphabeticalList_goAnchor('" . $aLetter['letter'] . "')";
  34. }
  35. else{
  36. $aBaseLink = bx_get('dynamic') ? parse_url($_SERVER['HTTP_REFERER']) : parse_url($_SERVER['REQUEST_URI']);
  37. $aLetterData[$key]['url'] = $aBaseLink['path'] . ($iStart>0 ? '?start=' . $iStart . '&per_page=' . $iPerPage . '&letter=' . $aLetter['letter'] : '?letter=' . $aLetter['letter']);
  38. }
  39. }
  40. $sRv = $this->_oTemplate->getAlphabeticalList($aLetterData, $aTmp['content']);
  41. $aTmp['content'] = $sRv;
  42. return $aTmp;
  43. }
  44. }
  45. /** @} */