1
0

BxBaseModTextConfig.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /**
  15. * Determine whether Timeline post will use common content (header image + text)
  16. * or content received from attachments (header image + text + images + videos + polls).
  17. * By default the first variant is used.
  18. * Note. The variable can be removed in future, when all Text Based modules
  19. * implement 'attachments' related parameters.
  20. */
  21. protected $_bAttachmentsInTimeline;
  22. protected $_aPregPatterns;
  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. 'TABLE_LINKS' => $aModule['db_prefix'] . 'links',
  36. 'TABLE_LINKS2CONTENT' => $aModule['db_prefix'] . 'links2content',
  37. // database fields
  38. 'FIELD_POLL_ID' => 'id',
  39. 'FIELD_POLL_AUTHOR_ID' => 'author_id',
  40. 'FIELD_POLL_CONTENT_ID' => 'content_id',
  41. 'FIELD_POLL_TEXT' => 'text',
  42. 'FIELD_POLL_ANSWERS' => 'answers',
  43. 'FIELD_ATTACH_LINK_CONTROLS' => 'controls',
  44. // some params
  45. 'PARAM_POLL_ENABLED' => true,
  46. 'PARAM_POLL_HIDDEN_RESULTS' => false,
  47. 'PARAM_POLL_ANONYMOUS_VOTING' => true,
  48. 'PARAM_MULTICAT_ENABLED' => false,
  49. 'PARAM_LINKS_ENABLED' => false,
  50. 'PARAM_LINKS_LIMIT' => 'sys_attach_links_max',
  51. // objects
  52. 'OBJECT_VOTES_POLL_ANSWERS' => $this->_sName . '_poll_answers',
  53. 'OBJECT_FORM_ATTACH_LINK' => $this->_sName . '_attach_link',
  54. 'OBJECT_FORM_DISPLAY_ATTACH_LINK_ADD' => $this->_sName . '_attach_link_add',
  55. // styles
  56. 'STYLES_POLLS_EMBED_CLASS' => 'body.bx-page-iframe.bx-def-color-bg-page',
  57. 'STYLES_POLLS_EMBED_CONTENT' => array(
  58. 'background-color' => '#ffffff'
  59. ),
  60. );
  61. $this->_aJsClasses = array(
  62. 'poll' => $this->_sClassPrefix . 'Polls',
  63. 'links' => $this->_sClassPrefix . 'Links',
  64. 'categories' => $this->_sClassPrefix . 'Categories'
  65. );
  66. $this->_aJsObjects = array(
  67. 'poll' => 'o' . $this->_sClassPrefix . 'Polls',
  68. 'links' => 'o' . $this->_sClassPrefix . 'Links',
  69. 'categories' => 'o' . $this->_sClassPrefix . 'Categories'
  70. );
  71. $sPrefix = str_replace('_', '-', $this->_sName);
  72. $this->_aHtmlIds = array(
  73. 'add_poll_popup' => $sPrefix . '-add-poll-popup',
  74. 'add_poll_form_field' => $sPrefix . '-add-poll-form-field',
  75. 'polls_showcase' => $sPrefix . '-polls-showcase-',
  76. 'poll' => $sPrefix . '-poll-',
  77. 'poll_content' => $sPrefix . '-poll-content-',
  78. 'poll_view_menu' => $sPrefix . '-poll-view-menu',
  79. 'poll_view_link_answers' => $sPrefix . '-poll-view-answers-',
  80. 'poll_view_link_results' => $sPrefix . '-poll-view-results-',
  81. 'attach_link_popup' => $sPrefix . '-attach-link-popup',
  82. 'attach_link_form_field' => $sPrefix . '-attach-link-form-field-',
  83. 'attach_link_item' => $sPrefix . '-attach-link-item-',
  84. );
  85. $this->_aPregPatterns = array(
  86. "meta_title" => "/<title>(.*)<\/title>/",
  87. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  88. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%#\/\.\w\-_!\(\)]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  89. );
  90. $this->_bAttachmentsInTimeline = false;
  91. }
  92. public function isAttachmentsInTimeline()
  93. {
  94. return $this->_bAttachmentsInTimeline;
  95. }
  96. public function getPregPattern($sType)
  97. {
  98. return $this->_aPregPatterns[$sType];
  99. }
  100. public function getHtmlIds($sKey = '')
  101. {
  102. if(empty($sKey))
  103. return $this->_aHtmlIds;
  104. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  105. }
  106. }
  107. /** @} */