BxPollsModule.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Polls Polls
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Polls module
  13. */
  14. class BxPollsModule extends BxBaseModTextModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. /**
  21. * ACTION METHODS
  22. */
  23. public function actionGetBlock()
  24. {
  25. $iContentId = (int)bx_get('content_id');
  26. $sBlock = bx_process_input(bx_get('block'));
  27. $sMethod = 'serviceGetBlock' . bx_gen_method_name($sBlock);
  28. if(!method_exists($this, $sMethod))
  29. return echoJson(array());
  30. $aBlock = $this->$sMethod($iContentId);
  31. if(empty($aBlock) || !is_array($aBlock))
  32. return echoJson(array());
  33. return echoJson(array(
  34. 'content' => $aBlock['content']
  35. ));
  36. }
  37. /**
  38. * SERVICE METHODS
  39. */
  40. public function serviceGetBlockSubentries($iContentId = 0)
  41. {
  42. return $this->_serviceTemplateFunc('entrySubentries', $iContentId);
  43. }
  44. public function serviceGetBlockResults($iContentId = 0)
  45. {
  46. return $this->_serviceTemplateFunc('entryResults', $iContentId);
  47. }
  48. }
  49. /** @} */