BxBaseModTextConfig.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_merge($this->CNF, [
  27. // database tables
  28. 'TABLE_LINKS' => $aModule['db_prefix'] . 'links',
  29. 'TABLE_LINKS2CONTENT' => $aModule['db_prefix'] . 'links2content',
  30. // database fields
  31. 'FIELD_ATTACH_LINK_CONTENT_ID' => 'content_id',
  32. 'FIELD_ATTACH_LINK_URL' => 'url',
  33. 'FIELD_ATTACH_LINK_CONTROLS' => 'controls',
  34. // some params
  35. 'PARAM_MULTICAT_ENABLED' => false,
  36. 'PARAM_LINKS_ENABLED' => false,
  37. 'PARAM_LINKS_LIMIT' => 'sys_attach_links_max',
  38. // objects
  39. 'OBJECT_FORM_ATTACH_LINK' => $this->_sName . '_attach_link',
  40. 'OBJECT_FORM_ATTACH_LINK_DISPLAY_ADD' => $this->_sName . '_attach_link_add',
  41. ]);
  42. $sPrefix = str_replace('_', '-', $this->_sName);
  43. $this->_aPrefixes = [
  44. 'style' => $sPrefix,
  45. ];
  46. $this->_aJsClasses = array_merge($this->_aJsClasses, [
  47. 'links' => $this->_sClassPrefix . 'Links',
  48. 'categories' => $this->_sClassPrefix . 'Categories'
  49. ]);
  50. $this->_aJsObjects = $this->_aJsObjects = array_merge($this->_aJsObjects, [
  51. 'links' => 'o' . $this->_sClassPrefix . 'Links',
  52. 'categories' => 'o' . $this->_sClassPrefix . 'Categories'
  53. ]);
  54. $this->_aHtmlIds = array_merge($this->_aHtmlIds, $this->_aHtmlIdsPoll, [
  55. 'attach_link_popup' => $sPrefix . '-attach-link-popup',
  56. 'attach_link_form_field' => $sPrefix . '-attach-link-form-field-',
  57. 'attach_link_item' => $sPrefix . '-attach-link-item-',
  58. ]);
  59. $this->_aPregPatterns = array(
  60. "meta_title" => "/<title>(.*)<\/title>/",
  61. "meta_description" => "/<meta[\s]+[^>]*?name[\s]?=[\s\"\']+description[\s\"\']+content[\s]?=[\s\"\']+(.*?)[\"\']+.*?>/",
  62. "url" => "/(([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%#\/\.\w\-_!\(\)]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?/"
  63. );
  64. $this->_bAttachmentsInTimeline = false;
  65. }
  66. public function isAttachLinks()
  67. {
  68. return !empty($this->CNF['TABLE_LINKS']) && $this->CNF['PARAM_LINKS_ENABLED'] == true;
  69. }
  70. public function isAttachmentsInTimeline()
  71. {
  72. return $this->_bAttachmentsInTimeline;
  73. }
  74. public function getPregPattern($sType)
  75. {
  76. return $this->_aPregPatterns[$sType];
  77. }
  78. public function getHtmlIds($sKey = '')
  79. {
  80. if(empty($sKey))
  81. return $this->_aHtmlIds;
  82. return isset($this->_aHtmlIds[$sKey]) ? $this->_aHtmlIds[$sKey] : '';
  83. }
  84. }
  85. /** @} */