BxAdsConfig.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 Ads Ads
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxDolInformer');
  12. class BxAdsConfig extends BxBaseModTextConfig
  13. {
  14. protected $_oDb;
  15. protected $_aCurrency;
  16. protected $_bAuction;
  17. function __construct($aModule)
  18. {
  19. parent::__construct($aModule);
  20. $aMenuItems2Methods = array (
  21. 'edit-ad' => 'checkAllowedEdit',
  22. 'delete-ad' => 'checkAllowedDelete',
  23. );
  24. $this->CNF = array_merge($this->CNF, array (
  25. // module icon
  26. 'ICON' => 'ad col-green2',
  27. // database tables
  28. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'entries',
  29. 'TABLE_ENTRIES_FULLTEXT' => 'title_text',
  30. 'TABLE_CATEGORIES' => $aModule['db_prefix'] . 'categories',
  31. 'TABLE_CATEGORIES_TYPES' => $aModule['db_prefix'] . 'categories_types',
  32. 'TABLE_INTERESTED_TRACK' => $aModule['db_prefix'] . 'interested_track',
  33. 'TABLE_LICENSES' => $aModule['db_prefix'] . 'licenses',
  34. 'TABLE_LICENSES_DELETED' => $aModule['db_prefix'] . 'licenses_deleted',
  35. 'TABLE_OFFERS' => $aModule['db_prefix'] . 'offers',
  36. // database fields
  37. 'FIELD_ID' => 'id',
  38. 'FIELD_AUTHOR' => 'author',
  39. 'FIELD_ADDED' => 'added',
  40. 'FIELD_CHANGED' => 'changed',
  41. 'FIELD_DELIVERED' => 'delivered',
  42. 'FIELD_RECEIVED' => 'received',
  43. 'FIELD_TITLE' => 'title',
  44. 'FIELD_NAME' => 'name',
  45. 'FIELD_TEXT' => 'text',
  46. 'FIELD_TEXT_ID' => 'ad-text',
  47. 'FIELD_CATEGORY' => 'category',
  48. 'FIELD_CATEGORY_VIEW' => 'category_view',
  49. 'FIELD_CATEGORY_SELECT' => 'category_select',
  50. 'FIELD_PRICE' => 'price',
  51. 'FIELD_AUCTION' => 'auction',
  52. 'FIELD_QUANTITY' => 'quantity',
  53. 'FIELD_YEAR' => 'year',
  54. 'FIELD_NOTES_PURCHASED' => 'notes_purchased',
  55. 'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
  56. 'FIELD_COVER' => 'covers',
  57. 'FIELD_PHOTO' => 'pictures',
  58. 'FIELD_VIDEO' => 'videos',
  59. 'FIELD_FILE' => 'files',
  60. 'FIELD_POLL' => 'polls',
  61. 'FIELD_THUMB' => 'thumb',
  62. 'FIELD_ATTACHMENTS' => 'attachments',
  63. 'FIELD_VIEWS' => 'views',
  64. 'FIELD_COMMENTS' => 'comments',
  65. 'FIELD_STATUS' => 'status',
  66. 'FIELD_STATUS_ADMIN' => 'status_admin',
  67. 'FIELD_LOCATION' => 'location',
  68. 'FIELD_LOCATION_PREFIX' => 'location',
  69. 'FIELD_LABELS' => 'labels',
  70. 'FIELD_ANONYMOUS' => 'anonymous',
  71. 'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
  72. 'FIELDS_DELAYED_PROCESSING' => 'videos', // can be array of fields or comma separated string of field names
  73. 'FIELD_OFR_ID' => 'id',
  74. 'FIELD_OFR_CONTENT' => 'content_id',
  75. 'FIELD_OFR_AUTHOR' => 'author_id',
  76. 'FIELD_OFR_ADDED' => 'added',
  77. 'FIELD_OFR_CHANGED' => 'changed',
  78. 'FIELD_OFR_AMOUNT' => 'amount',
  79. 'FIELD_OFR_QUANTITY' => 'quantity',
  80. 'FIELD_OFR_STATUS' => 'status',
  81. // page URIs
  82. 'URI_VIEW_ENTRY' => 'view-ad',
  83. 'URI_VIEW_ENTRY_OFFERS' => 'view-ad-offers',
  84. 'URI_AUTHOR_ENTRIES' => 'ads-author',
  85. 'URI_ENTRIES_BY_CONTEXT' => 'ads-context',
  86. 'URI_ADD_ENTRY' => 'create-ad',
  87. 'URI_EDIT_ENTRY' => 'edit-ad',
  88. 'URI_MANAGE_COMMON' => 'ads-manage',
  89. 'URL_HOME' => 'page.php?i=ads-home',
  90. 'URL_POPULAR' => 'page.php?i=ads-popular',
  91. 'URL_UPDATED' => 'page.php?i=ads-updated',
  92. 'URL_CATEGORIES' => 'page.php?i=ads-categories',
  93. 'URL_MANAGE_COMMON' => 'page.php?i=ads-manage',
  94. 'URL_MANAGE_ADMINISTRATION' => 'page.php?i=ads-administration',
  95. 'URL_LICENSES_COMMON' => 'page.php?i=ads-licenses',
  96. 'URL_LICENSES_ADMINISTRATION' => 'page.php?i=ads-licenses-administration',
  97. 'GET_PARAM_CATEGORY' => 'category',
  98. // some params
  99. 'PARAM_AUTO_APPROVE' => 'bx_ads_enable_auto_approve',
  100. 'PARAM_CHARS_SUMMARY' => 'bx_ads_summary_chars',
  101. 'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_ads_plain_summary_chars',
  102. 'PARAM_NUM_RSS' => 'bx_ads_rss_num',
  103. 'PARAM_SEARCHABLE_FIELDS' => 'bx_ads_searchable_fields',
  104. 'PARAM_PER_PAGE_BROWSE_SHOWCASE' => 'bx_ads_per_page_browse_showcase',
  105. 'PARAM_LIFETIME' => 'bx_ads_lifetime',
  106. 'PARAM_USE_IIN' => 'bx_ads_internal_interested_notification',
  107. 'PARAM_CATEGORY_LEVEL_MAX' => 1,
  108. 'PARAM_USE_AUCTION' => 'bx_ads_enable_auction',
  109. // objects
  110. 'OBJECT_STORAGE' => 'bx_ads_covers',
  111. 'OBJECT_STORAGE_FILES' => 'bx_ads_files',
  112. 'OBJECT_STORAGE_PHOTOS' => 'bx_ads_photos',
  113. 'OBJECT_STORAGE_VIDEOS' => 'bx_ads_videos',
  114. 'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_ads_preview',
  115. 'OBJECT_IMAGES_TRANSCODER_GALLERY' => 'bx_ads_gallery',
  116. 'OBJECT_IMAGES_TRANSCODER_COVER' => 'bx_ads_cover',
  117. 'OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES' => 'bx_ads_preview_files',
  118. 'OBJECT_IMAGES_TRANSCODER_GALLERY_FILES' => 'bx_ads_gallery_files',
  119. 'OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS' => 'bx_ads_preview_photos',
  120. 'OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS' => 'bx_ads_gallery_photos',
  121. 'OBJECT_VIDEOS_TRANSCODERS' => array(
  122. 'poster' => 'bx_ads_videos_poster',
  123. 'poster_preview' => 'bx_ads_videos_poster_preview',
  124. 'mp4' => 'bx_ads_videos_mp4',
  125. 'mp4_hd' => 'bx_ads_videos_mp4_hd'
  126. ),
  127. 'OBJECT_VIDEO_TRANSCODER_HEIGHT' => '480px',
  128. 'OBJECT_REPORTS' => 'bx_ads',
  129. 'OBJECT_VIEWS' => 'bx_ads',
  130. 'OBJECT_VOTES' => 'bx_ads',
  131. 'OBJECT_REACTIONS' => 'bx_ads_reactions',
  132. 'OBJECT_SCORES' => 'bx_ads',
  133. 'OBJECT_FAVORITES' => 'bx_ads',
  134. 'OBJECT_FEATURED' => 'bx_ads',
  135. 'OBJECT_METATAGS' => 'bx_ads',
  136. 'OBJECT_COMMENTS' => 'bx_ads',
  137. 'OBJECT_NOTES' => 'bx_ads_notes',
  138. 'OBJECT_REVIEWS' => 'bx_ads_reviews',
  139. 'OBJECT_CATEGORY' => '',
  140. 'OBJECT_PRIVACY_VIEW' => 'bx_ads_allow_view_to',
  141. 'OBJECT_FORM_CATEGORY' => 'bx_ads_category',
  142. 'OBJECT_FORM_CATEGORY_DISPLAY_ADD' => 'bx_ads_category_add',
  143. 'OBJECT_FORM_CATEGORY_DISPLAY_EDIT' => 'bx_ads_category_edit',
  144. 'OBJECT_FORM_CATEGORY_DISPLAY_DELETE' => 'bx_ads_category_delete',
  145. 'OBJECT_FORM_ENTRY' => 'bx_ads',
  146. 'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => '',
  147. 'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_ads_entry_add',
  148. 'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => '',
  149. 'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_ads_entry_delete',
  150. 'OBJECT_FORM_POLL' => 'bx_ads_poll',
  151. 'OBJECT_FORM_POLL_DISPLAY_ADD' => 'bx_ads_poll_add',
  152. 'OBJECT_FORM_OFFER' => 'bx_ads_offer',
  153. 'OBJECT_FORM_OFFER_DISPLAY_ADD' => 'bx_ads_offer_add',
  154. 'OBJECT_MENU_ENTRY_ATTACHMENTS' => 'bx_ads_entry_attachments', // attachments menu in create/edit forms
  155. 'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_ads_view', // actions menu on view entry page
  156. 'OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL' => 'bx_ads_view_actions', // all actions menu on view entry page
  157. 'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_ads_my', // actions menu on my entries page
  158. 'OBJECT_MENU_SUBMENU' => 'bx_ads_submenu', // main module submenu
  159. 'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_ads_view_submenu', // view entry submenu
  160. 'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'ads-home', // first item in view entry submenu from main module submenu
  161. 'OBJECT_MENU_SNIPPET_META' => 'bx_ads_snippet_meta', // menu for snippet meta info
  162. 'OBJECT_MENU_MANAGE_TOOLS' => 'bx_ads_menu_manage_tools', //manage menu in content administration tools
  163. 'OBJECT_MENU_LICENSES' => 'bx_ads_licenses_submenu',
  164. 'OBJECT_GRID_CATEGORIES' => 'bx_ads_categories',
  165. 'OBJECT_GRID_ADMINISTRATION' => 'bx_ads_administration',
  166. 'OBJECT_GRID_COMMON' => 'bx_ads_common',
  167. 'OBJECT_GRID_LICENSES_ADMINISTRATION' => 'bx_ads_licenses_administration',
  168. 'OBJECT_GRID_LICENSES' => 'bx_ads_licenses',
  169. 'OBJECT_GRID_OFFERS' => 'bx_ads_offers',
  170. 'OBJECT_GRID_OFFERS_ALL' => 'bx_ads_offers_all',
  171. 'OBJECT_UPLOADERS' => array('bx_ads_simple', 'bx_ads_html5'),
  172. // menu items which visibility depends on custom visibility checking
  173. 'MENU_ITEM_TO_METHOD' => array (
  174. 'bx_ads_my' => array (
  175. 'create-ad' => 'checkAllowedAdd',
  176. ),
  177. 'bx_ads_view' => $aMenuItems2Methods,
  178. ),
  179. // informer messages
  180. 'INFORMERS' => array (
  181. 'approving' => array (
  182. 'name' => 'bx-ads-approving',
  183. 'map' => array (
  184. 'pending' => array('msg' => '_bx_ads_txt_msg_status_pending', 'type' => BX_INFORMER_ALERT),
  185. 'hidden' => array('msg' => '_bx_ads_txt_msg_status_hidden', 'type' => BX_INFORMER_ERROR),
  186. ),
  187. ),
  188. 'processing' => array (
  189. 'name' => 'bx-ads-processing',
  190. 'map' => array (
  191. 'awaiting' => array('msg' => '_bx_ads_txt_processing_awaiting', 'type' => BX_INFORMER_ALERT),
  192. 'failed' => array('msg' => '_bx_ads_txt_processing_failed', 'type' => BX_INFORMER_ERROR)
  193. ),
  194. )
  195. ),
  196. // email templates
  197. 'ETEMPLATE_INTERESTED' => 'bx_ads_interested',
  198. 'ETEMPLATE_PURCHASED' => 'bx_ads_purchased',
  199. 'ETEMPLATE_OFFER_ADDED' => 'bx_ads_offer_added',
  200. 'ETEMPLATE_OFFER_ACCEPTED' => 'bx_ads_offer_accepted',
  201. 'ETEMPLATE_OFFER_DECLINED' => 'bx_ads_offer_declined',
  202. // some language keys
  203. 'T' => array (
  204. 'txt_sample_single' => '_bx_ads_txt_sample_single',
  205. 'txt_sample_single_with_article' => '_bx_ads_txt_sample_single_with_article',
  206. 'txt_sample_comment_single' => '_bx_ads_txt_sample_comment_single',
  207. 'txt_sample_vote_single' => '_bx_ads_txt_sample_vote_single',
  208. 'txt_sample_reaction_single' => '_bx_ads_txt_sample_reaction_single',
  209. 'txt_sample_score_up_single' => '_bx_ads_txt_sample_score_up_single',
  210. 'txt_sample_score_down_single' => '_bx_ads_txt_sample_score_down_single',
  211. 'txt_sample_interest_single' => '_bx_ads_txt_sample_interest_single',
  212. 'form_field_author' => '_bx_ads_form_entry_input_author',
  213. 'grid_action_err_delete' => '_bx_ads_grid_action_err_delete',
  214. 'grid_txt_account_manager' => '_bx_ads_grid_txt_account_manager',
  215. 'filter_item_active' => '_bx_ads_grid_filter_item_title_adm_active',
  216. 'filter_item_hidden' => '_bx_ads_grid_filter_item_title_adm_hidden',
  217. 'filter_item_pending' => '_bx_ads_grid_filter_item_title_adm_pending',
  218. 'filter_item_select_one_filter1' => '_bx_ads_grid_filter_item_title_adm_select_one_filter1',
  219. 'menu_item_manage_my' => '_bx_ads_menu_item_title_manage_my',
  220. 'menu_item_manage_all' => '_bx_ads_menu_item_title_manage_all',
  221. 'txt_all_entries_by' => '_bx_ads_txt_all_entries_by',
  222. 'txt_all_entries_in' => '_bx_ads_txt_all_entries_in',
  223. 'txt_all_entries_by_author' => '_bx_ads_page_title_browse_by_author',
  224. 'txt_all_entries_by_context' => '_bx_ads_page_title_browse_by_context',
  225. 'txt_err_cannot_perform_action' => '_bx_ads_txt_err_cannot_perform_action',
  226. 'txt_poll_form_answers_add' => '_bx_ads_form_poll_input_answers_add',
  227. 'txt_poll_menu_view_answers' => '_bx_ads_txt_poll_view_answers',
  228. 'txt_poll_menu_view_results' => '_bx_ads_txt_poll_view_results',
  229. 'txt_poll_answer_vote_do_by' => '_bx_ads_txt_poll_answer_vote_do_by',
  230. 'txt_poll_answer_vote_counter' => '_bx_ads_txt_poll_answer_vote_counter',
  231. 'txt_poll_answer_vote_percent' => '_bx_ads_txt_poll_answer_vote_percent',
  232. 'txt_display_add' => '_bx_ads_txt_display_title_add',
  233. 'txt_display_edit' => '_bx_ads_txt_display_title_edit',
  234. 'txt_display_view' => '_bx_ads_txt_display_title_view',
  235. ),
  236. ));
  237. $this->_aJsClasses = array_merge($this->_aJsClasses, array(
  238. 'manage_tools' => 'BxAdsManageTools',
  239. 'studio' => 'BxAdsStudio',
  240. 'entry' => 'BxAdsEntry',
  241. 'form' => 'BxAdsForm',
  242. ));
  243. $this->_aJsObjects = array_merge($this->_aJsObjects, array(
  244. 'manage_tools' => 'oBxAdsManageTools',
  245. 'studio' => 'oBxAdsStudio',
  246. 'entry' => 'oBxAdsEntry',
  247. 'form' => 'oBxAdsForm',
  248. ));
  249. $this->_aGridObjects = array(
  250. 'categories' => $this->CNF['OBJECT_GRID_CATEGORIES'],
  251. 'common' => $this->CNF['OBJECT_GRID_COMMON'],
  252. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'],
  253. );
  254. $sPrefix = str_replace('_', '-', $this->_sName);
  255. $this->_aHtmlIds = array(
  256. 'offer_popup' => $sPrefix . '-offer-popup',
  257. );
  258. $oPayments = BxDolPayments::getInstance();
  259. $this->_aCurrency = array(
  260. 'code' => $oPayments->getOption('default_currency_code'),
  261. 'sign' => $oPayments->getOption('default_currency_sign')
  262. );
  263. $this->_bAttachmentsInTimeline = true;
  264. }
  265. public function init(&$oDb)
  266. {
  267. $this->_oDb = &$oDb;
  268. $this->_bAuction = getParam($this->CNF['PARAM_USE_AUCTION']) == 'on';
  269. }
  270. public function isAuction()
  271. {
  272. return $this->_bAuction;
  273. }
  274. public function getCurrency()
  275. {
  276. return $this->_aCurrency;
  277. }
  278. public function getEntryName($sName)
  279. {
  280. return uriGenerate($sName, $this->CNF['TABLE_ENTRIES'], $this->CNF['FIELD_NAME']);
  281. }
  282. }
  283. /** @} */