1
0

BxBaseModTextConfig.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 BaseText Base classes for text modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolInformer');
  12. class BxBaseModTextConfig extends BxBaseModGeneralConfig
  13. {
  14. protected $_aHtmlIds;
  15. /**
  16. * Determine whether Timeline post will use common content (header image + text)
  17. * or content received from attachments (header image + text + images + videos + polls).
  18. * By default the first variant is used.
  19. * Note. The variable can be removed in future, when all Text Based modules
  20. * implement 'attachments' related parameters.
  21. */
  22. protected $_bAttachmentsInTimeline;
  23. function __construct($aModule)
  24. {
  25. parent::__construct($aModule);
  26. $this->CNF = array(
  27. // modules icon
  28. 'ICON_POLLS_ANSWERS' => 'vote-yea',
  29. 'ICON_POLLS_RESULTS' => 'poll-h',
  30. // database tables
  31. 'TABLE_POLLS' => $aModule['db_prefix'] . 'polls',
  32. 'TABLE_POLLS_ANSWERS' => $aModule['db_prefix'] . 'polls_answers',
  33. 'TABLE_POLLS_ANSWERS_VOTES' => $aModule['db_prefix'] . 'polls_answers_votes',
  34. 'TABLE_POLLS_ANSWERS_VOTES_TRACK' => $aModule['db_prefix'] . 'polls_answers_votes_track',
  35. // database fields
  36. 'FIELD_POLL_ID' => 'id',
  37. 'FIELD_POLL_AUTHOR_ID' => 'author_id',
  38. 'FIELD_POLL_CONTENT_ID' => 'content_id',
  39. 'FIELD_POLL_TEXT' => 'text',
  40. 'FIELD_POLL_ANSWERS' => 'answers',
  41. // some params
  42. 'PARAM_POLL_ENABLED' => true,
  43. 'PARAM_POLL_HIDDEN_RESULTS' => false,
  44. 'PARAM_POLL_ANONYMOUS_VOTING' => true,
  45. 'PARAM_MULTICAT_ENABLED' => false,
  46. // objects
  47. 'OBJECT_VOTES_POLL_ANSWERS' => $this->_sName . '_poll_answers',
  48. // styles
  49. 'STYLES_POLLS_EMBED_CLASS' => 'body.bx-page-iframe.bx-def-color-bg-page',
  50. 'STYLES_POLLS_EMBED_CONTENT' => array(
  51. 'background-color' => '#ffffff'
  52. ),
  53. );
  54. $this->_aJsClasses = array(
  55. 'poll' => $this->_sClassPrefix . 'Polls',
  56. 'categories' => $this->_sClassPrefix . 'Categories'
  57. );
  58. $this->_aJsObjects = array(
  59. 'poll' => 'o' . $this->_sClassPrefix . 'Polls',
  60. 'categories' => 'o' . $this->_sClassPrefix . 'Categories'
  61. );
  62. $sPrefix = str_replace('_', '-', $this->_sName);
  63. $this->_aHtmlIds = array(
  64. 'add_poll_popup' => $sPrefix . '-add-poll-popup',
  65. 'add_poll_form_field' => $sPrefix . '-add-poll-form-field',
  66. 'polls_showcase' => $sPrefix . '-polls-showcase-',
  67. 'poll' => $sPrefix . '-poll-',
  68. 'poll_content' => $sPrefix . '-poll-content-',
  69. 'poll_view_menu' => $sPrefix . '-poll-view-menu',
  70. 'poll_view_link_answers' => $sPrefix . '-poll-view-answers-',
  71. 'poll_view_link_results' => $sPrefix . '-poll-view-results-',
  72. );
  73. $this->_bAttachmentsInTimeline = false;
  74. }
  75. public function isAttachmentsInTimeline()
  76. {
  77. return $this->_bAttachmentsInTimeline;
  78. }
  79. /**
  80. * Is Auto Approve mode is available.
  81. */
  82. public function isAutoApprove()
  83. {
  84. return !empty($this->CNF['FIELD_STATUS_ADMIN']) && !empty($this->CNF['PARAM_AUTO_APPROVE']);
  85. }
  86. public function isAutoApproveEnabled()
  87. {
  88. return !$this->isAutoApprove() || getParam($this->CNF['PARAM_AUTO_APPROVE']) == 'on';
  89. }
  90. public function getHtmlIds($sKey = '')
  91. {
  92. if(empty($sKey))
  93. return $this->_aHtmlIds;
  94. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  95. }
  96. }
  97. /** @} */