BxAdsConfig.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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 $_bAuction;
  16. protected $_bSources;
  17. protected $_bPromotion;
  18. protected $_fPromotionCpm;
  19. protected $_sCacheEngineShopify;
  20. protected $_iCacheLifetimeShopify;
  21. public function __construct($aModule)
  22. {
  23. parent::__construct($aModule);
  24. $aMenuItems2Methods = array (
  25. 'approve' => 'checkAllowedApprove',
  26. 'view-ad-promotion' => 'checkAllowedEdit',
  27. 'edit-ad' => 'checkAllowedEdit',
  28. 'edit-ad-budget' => 'checkAllowedEdit',
  29. 'delete-ad' => 'checkAllowedDelete',
  30. );
  31. $this->CNF = array_merge($this->CNF, array (
  32. // module icon
  33. 'ICON' => 'ad',
  34. // database tables
  35. 'TABLE_SOURCES' => $aModule['db_prefix'] . 'sources',
  36. 'TABLE_SOURCES_OPTIONS' => $aModule['db_prefix'] . 'sources_options',
  37. 'TABLE_SOURCES_OPTIONS_VALUES' => $aModule['db_prefix'] . 'sources_options_values',
  38. 'TABLE_ENTRIES' => $aModule['db_prefix'] . 'entries',
  39. 'TABLE_ENTRIES_FULLTEXT' => 'title_text',
  40. 'TABLE_CATEGORIES' => $aModule['db_prefix'] . 'categories',
  41. 'TABLE_CATEGORIES_TYPES' => $aModule['db_prefix'] . 'categories_types',
  42. 'TABLE_INTERESTED_TRACK' => $aModule['db_prefix'] . 'interested_track',
  43. 'TABLE_COMMODITIES' => $aModule['db_prefix'] . 'commodities',
  44. 'TABLE_LICENSES' => $aModule['db_prefix'] . 'licenses',
  45. 'TABLE_LICENSES_DELETED' => $aModule['db_prefix'] . 'licenses_deleted',
  46. 'TABLE_PROMO_LICENSES' => $aModule['db_prefix'] . 'promo_licenses',
  47. 'TABLE_PROMO_LICENSES_DELETED' => $aModule['db_prefix'] . 'promo_licenses_deleted',
  48. 'TABLE_PROMO_TRACKER' => $aModule['db_prefix'] . 'promo_tracker',
  49. 'TABLE_OFFERS' => $aModule['db_prefix'] . 'offers',
  50. // database fields
  51. 'FIELD_ID' => 'id',
  52. 'FIELD_AUTHOR' => 'author',
  53. 'FIELD_ADDED' => 'added',
  54. 'FIELD_CHANGED' => 'changed',
  55. 'FIELD_SOLD' => 'sold',
  56. 'FIELD_SHIPPED' => 'shipped',
  57. 'FIELD_RECEIVED' => 'received',
  58. 'FIELD_SOURCE_TYPE' => 'source_type',
  59. 'FIELD_SOURCE' => 'source',
  60. 'FIELD_TITLE' => 'title',
  61. 'FIELD_URL' => 'url',
  62. 'FIELD_NAME' => 'name',
  63. 'FIELD_TEXT' => 'text',
  64. 'FIELD_TEXT_ID' => 'ad-text',
  65. 'FIELD_CATEGORY' => 'category',
  66. 'FIELD_CATEGORY_VIEW' => 'category_view',
  67. 'FIELD_CATEGORY_SELECT' => 'category_select',
  68. 'FIELD_TAGS' => 'tags',
  69. 'FIELD_PRICE' => 'price',
  70. 'FIELD_PRICE_SINGLE' => 'price',
  71. 'FIELD_AUCTION' => 'auction',
  72. 'FIELD_QUANTITY' => 'quantity',
  73. 'FIELD_SINGLE' => 'single',
  74. 'FIELD_YEAR' => 'year',
  75. 'FIELD_NOTES_PURCHASED' => 'notes_purchased',
  76. 'FIELD_ALLOW_VIEW_TO' => 'allow_view_to',
  77. 'FIELD_CF' => 'cf',
  78. 'FIELD_COVER' => 'covers',
  79. 'FIELD_PHOTO' => 'pictures',
  80. 'FIELD_VIDEO' => 'videos',
  81. 'FIELD_FILE' => 'files',
  82. 'FIELD_POLL' => 'polls',
  83. 'FIELD_THUMB' => 'thumb',
  84. 'FIELD_LINK' => 'link',
  85. 'FIELD_ATTACHMENTS' => 'attachments',
  86. 'FIELD_BUDGET_TOTAL' => 'budget_total',
  87. 'FIELD_BUDGET_DAILY' => 'budget_daily',
  88. 'FIELD_VIEWS' => 'views',
  89. 'FIELD_COMMENTS' => 'comments',
  90. 'FIELD_SEG' => 'seg',
  91. 'FIELD_SEG_GENDER' => 'seg_gender',
  92. 'FIELD_SEG_AGE' => 'seg_age',
  93. 'FIELD_SEG_AGE_MIN' => 'seg_age_min',
  94. 'FIELD_SEG_AGE_MAX' => 'seg_age_max',
  95. 'FIELD_SEG_COUNTRY' => 'seg_country',
  96. 'FIELD_STATUS' => 'status',
  97. 'FIELD_STATUS_ADMIN' => 'status_admin',
  98. 'FIELD_LOCATION' => 'location',
  99. 'FIELD_LOCATION_PREFIX' => 'location',
  100. 'FIELD_LABELS' => 'labels',
  101. 'FIELD_ANONYMOUS' => 'anonymous',
  102. 'FIELDS_WITH_KEYWORDS' => 'auto', // can be 'auto', array of fields or comma separated string of field names, works only when OBJECT_METATAGS is specified
  103. 'FIELDS_DELAYED_PROCESSING' => 'videos', // can be array of fields or comma separated string of field names
  104. 'FIELD_OFR_ID' => 'id',
  105. 'FIELD_OFR_CONTENT' => 'content_id',
  106. 'FIELD_OFR_AUTHOR' => 'author_id',
  107. 'FIELD_OFR_ADDED' => 'added',
  108. 'FIELD_OFR_CHANGED' => 'changed',
  109. 'FIELD_OFR_AMOUNT' => 'amount',
  110. 'FIELD_OFR_QUANTITY' => 'quantity',
  111. 'FIELD_OFR_TOTAL' => 'total', // form field only
  112. 'FIELD_OFR_STATUS' => 'status',
  113. // page URIs
  114. 'URI_VIEW_ENTRY' => 'view-ad',
  115. 'URI_VIEW_ENTRY_OFFERS' => 'view-ad-offers',
  116. 'URI_VIEW_ENTRY_PROMOTION' => 'view-ad-promotion',
  117. 'URI_AUTHOR_ENTRIES' => 'ads-author',
  118. 'URI_ENTRIES_BY_CONTEXT' => 'ads-context',
  119. 'URI_ADD_ENTRY' => 'create-ad',
  120. 'URI_EDIT_ENTRY' => 'edit-ad',
  121. 'URI_EDIT_ENTRY_BUDGET' => 'edit-ad-budget',
  122. 'URI_MANAGE_COMMON' => 'ads-manage',
  123. 'URL_HOME' => 'page.php?i=ads-home',
  124. 'URL_POPULAR' => 'page.php?i=ads-popular',
  125. 'URL_UPDATED' => 'page.php?i=ads-updated',
  126. 'URL_CATEGORIES' => 'page.php?i=ads-categories',
  127. 'URL_MANAGE_COMMON' => 'page.php?i=ads-manage',
  128. 'URL_MANAGE_ADMINISTRATION' => 'page.php?i=ads-administration',
  129. 'URL_SOURCES' => 'page.php?i=ads-sources',
  130. 'URI_FAVORITES_LIST' => 'ads-favorites',
  131. 'URL_LICENSES_COMMON' => 'page.php?i=ads-licenses',
  132. 'URL_LICENSES_ADMINISTRATION' => 'page.php?i=ads-licenses-administration',
  133. 'GET_PARAM_CATEGORY' => 'category',
  134. // some params
  135. 'PARAM_AUTO_APPROVE' => 'bx_ads_enable_auto_approve',
  136. 'PARAM_CHARS_SUMMARY' => 'bx_ads_summary_chars',
  137. 'PARAM_CHARS_SUMMARY_PLAIN' => 'bx_ads_plain_summary_chars',
  138. 'PARAM_NUM_RSS' => 'bx_ads_rss_num',
  139. 'PARAM_SEARCHABLE_FIELDS' => 'bx_ads_searchable_fields',
  140. 'PARAM_PER_PAGE_FOR_FAVORITES_LISTS' => 'bx_ads_per_page_for_favorites_lists',
  141. 'PARAM_PER_PAGE_BROWSE_SHOWCASE' => 'bx_ads_per_page_browse_showcase',
  142. 'PARAM_LIFETIME' => 'bx_ads_lifetime',
  143. 'PARAM_LIFETIME_OFFERS' => 'bx_ads_offer_lifetime',
  144. 'PARAM_USE_IIN' => 'bx_ads_internal_interested_notification',
  145. 'PARAM_CATEGORY_LEVEL_MAX' => 1,
  146. 'PARAM_USE_AUCTION' => 'bx_ads_enable_auction',
  147. 'PARAM_USE_SOURCES' => 'bx_ads_enable_sources',
  148. 'PARAM_USE_PROMOTION' => 'bx_ads_enable_promotion',
  149. 'PARAM_PROMOTION_CPM' => 'bx_ads_promotion_cpm',
  150. 'PARAM_LINKS_ENABLED' => true,
  151. // objects
  152. 'OBJECT_STORAGE' => 'bx_ads_covers',
  153. 'OBJECT_STORAGE_FILES' => 'bx_ads_files',
  154. 'OBJECT_STORAGE_PHOTOS' => 'bx_ads_photos',
  155. 'OBJECT_STORAGE_VIDEOS' => 'bx_ads_videos',
  156. 'OBJECT_IMAGES_TRANSCODER_PREVIEW' => 'bx_ads_preview',
  157. 'OBJECT_IMAGES_TRANSCODER_GALLERY' => 'bx_ads_gallery',
  158. 'OBJECT_IMAGES_TRANSCODER_COVER' => 'bx_ads_cover',
  159. 'OBJECT_IMAGES_TRANSCODER_PREVIEW_FILES' => 'bx_ads_preview_files',
  160. 'OBJECT_IMAGES_TRANSCODER_GALLERY_FILES' => 'bx_ads_gallery_files',
  161. 'OBJECT_IMAGES_TRANSCODER_PREVIEW_PHOTOS' => 'bx_ads_preview_photos',
  162. 'OBJECT_IMAGES_TRANSCODER_GALLERY_PHOTOS' => 'bx_ads_gallery_photos',
  163. 'OBJECT_IMAGES_TRANSCODER_VIEW_PHOTOS' => 'bx_ads_view_photos',
  164. 'OBJECT_VIDEOS_TRANSCODERS' => array(
  165. 'poster' => 'bx_ads_videos_poster',
  166. 'poster_preview' => 'bx_ads_videos_poster_preview',
  167. 'mp4' => 'bx_ads_videos_mp4',
  168. 'mp4_hd' => 'bx_ads_videos_mp4_hd'
  169. ),
  170. 'OBJECT_VIDEO_TRANSCODER_HEIGHT' => '480px',
  171. 'OBJECT_REPORTS' => 'bx_ads',
  172. 'OBJECT_VIEWS' => 'bx_ads',
  173. 'OBJECT_VOTES' => 'bx_ads',
  174. 'OBJECT_REACTIONS' => 'bx_ads_reactions',
  175. 'OBJECT_SCORES' => 'bx_ads',
  176. 'OBJECT_FAVORITES' => 'bx_ads',
  177. 'OBJECT_FEATURED' => 'bx_ads',
  178. 'OBJECT_METATAGS' => 'bx_ads',
  179. 'OBJECT_COMMENTS' => 'bx_ads',
  180. 'OBJECT_NOTES' => 'bx_ads_notes',
  181. 'OBJECT_REVIEWS' => 'bx_ads_reviews',
  182. 'OBJECT_CATEGORY' => '',
  183. 'OBJECT_PRIVACY_VIEW' => 'bx_ads_allow_view_to',
  184. 'OBJECT_PRIVACY_LIST_VIEW' => 'bx_ads_allow_view_favorite_list',
  185. 'OBJECT_FORM_SOURCES_DETAILS' => 'bx_ads_form_sources_details',
  186. 'OBJECT_FORM_SOURCES_DETAILS_DISPLAY_EDIT' => 'bx_ads_form_sources_details_edit',
  187. 'OBJECT_FORM_CATEGORY' => 'bx_ads_category',
  188. 'OBJECT_FORM_CATEGORY_DISPLAY_ADD' => 'bx_ads_category_add',
  189. 'OBJECT_FORM_CATEGORY_DISPLAY_EDIT' => 'bx_ads_category_edit',
  190. 'OBJECT_FORM_CATEGORY_DISPLAY_DELETE' => 'bx_ads_category_delete',
  191. 'OBJECT_FORM_ENTRY' => 'bx_ads',
  192. 'OBJECT_FORM_ENTRY_DISPLAY_VIEW' => '',
  193. 'OBJECT_FORM_ENTRY_DISPLAY_ADD' => 'bx_ads_entry_add',
  194. 'OBJECT_FORM_ENTRY_DISPLAY_EDIT' => '',
  195. 'OBJECT_FORM_ENTRY_DISPLAY_EDIT_BUDGET' => 'bx_ads_entry_edit_budget',
  196. 'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_ads_entry_delete',
  197. 'OBJECT_FORM_POLL' => 'bx_ads_poll',
  198. 'OBJECT_FORM_POLL_DISPLAY_ADD' => 'bx_ads_poll_add',
  199. 'OBJECT_FORM_OFFER' => 'bx_ads_offer',
  200. 'OBJECT_FORM_OFFER_DISPLAY_ADD' => 'bx_ads_offer_add',
  201. 'OBJECT_FORM_OFFER_DISPLAY_VIEW' => 'bx_ads_offer_view',
  202. 'OBJECT_MENU_ENTRY_ATTACHMENTS' => 'bx_ads_entry_attachments', // attachments menu in create/edit forms
  203. 'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_ads_view', // actions menu on view entry page
  204. 'OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL' => 'bx_ads_view_actions', // all actions menu on view entry page
  205. 'OBJECT_MENU_ACTIONS_MY_ENTRIES' => 'bx_ads_my', // actions menu on my entries page
  206. 'OBJECT_MENU_SUBMENU' => 'bx_ads_submenu', // main module submenu
  207. 'OBJECT_MENU_SUBMENU_VIEW_ENTRY' => 'bx_ads_view_submenu', // view entry submenu
  208. 'OBJECT_MENU_SUBMENU_VIEW_ENTRY_MAIN_SELECTION' => 'ads-home', // first item in view entry submenu from main module submenu
  209. 'OBJECT_MENU_SNIPPET_META' => 'bx_ads_snippet_meta', // menu for snippet meta info
  210. 'OBJECT_MENU_MANAGE_TOOLS' => 'bx_ads_menu_manage_tools', //manage menu in content administration tools
  211. 'OBJECT_MENU_LICENSES' => 'bx_ads_licenses_submenu',
  212. 'OBJECT_GRID_CATEGORIES' => 'bx_ads_categories',
  213. 'OBJECT_GRID_ADMINISTRATION' => 'bx_ads_administration',
  214. 'OBJECT_GRID_COMMON' => 'bx_ads_common',
  215. 'OBJECT_GRID_LICENSES_ADMINISTRATION' => 'bx_ads_licenses_administration',
  216. 'OBJECT_GRID_LICENSES' => 'bx_ads_licenses',
  217. 'OBJECT_GRID_OFFERS' => 'bx_ads_offers',
  218. 'OBJECT_GRID_OFFERS_ALL' => 'bx_ads_offers_all',
  219. 'OBJECT_UPLOADERS' => array('bx_ads_simple', 'bx_ads_html5'),
  220. 'OBJECT_PROMOTION_CHARTS' => ['bx_ads_promotion_growth', 'bx_ads_promotion_growth_speed'],
  221. 'BADGES_AVALIABLE' => true,
  222. // menu items which visibility depends on custom visibility checking
  223. 'MENU_ITEM_TO_METHOD' => array (
  224. 'bx_ads_my' => array (
  225. 'create-ad' => 'checkAllowedAdd',
  226. ),
  227. 'bx_ads_view' => $aMenuItems2Methods,
  228. 'bx_ads_view_submenu' => $aMenuItems2Methods
  229. ),
  230. // informer messages
  231. 'INFORMERS' => array (
  232. 'approving' => array (
  233. 'name' => 'bx-ads-approving',
  234. 'map' => array (
  235. 'pending' => array('msg' => '_bx_ads_txt_msg_status_pending', 'type' => BX_INFORMER_ALERT),
  236. 'hidden' => array('msg' => '_bx_ads_txt_msg_status_hidden', 'type' => BX_INFORMER_ERROR),
  237. ),
  238. ),
  239. 'processing' => array (
  240. 'name' => 'bx-ads-processing',
  241. 'map' => array (
  242. 'awaiting' => array('msg' => '_bx_ads_txt_processing_awaiting', 'type' => BX_INFORMER_ALERT),
  243. 'failed' => array('msg' => '_bx_ads_txt_processing_failed', 'type' => BX_INFORMER_ERROR)
  244. ),
  245. ),
  246. 'auction' => array (
  247. 'name' => 'bx-ads-auction',
  248. 'map' => array (
  249. 'offer' => array('msg' => '_bx_ads_txt_msg_auction_offer', 'type' => BX_INFORMER_INFO),
  250. 'sold' => array('msg' => '_bx_ads_txt_msg_auction_sold', 'type' => BX_INFORMER_INFO)
  251. ),
  252. ),
  253. 'promotion' => [
  254. 'name' => 'bx-ads-promotion',
  255. 'map' => [
  256. 'unpaid' => ['msg' => '_bx_ads_txt_msg_promotion_unpaid', 'type' => BX_INFORMER_ALERT],
  257. ],
  258. ]
  259. ),
  260. // email templates
  261. 'ETEMPLATE_INTERESTED' => 'bx_ads_interested',
  262. 'ETEMPLATE_PURCHASED' => 'bx_ads_purchased',
  263. 'ETEMPLATE_SHIPPED' => 'bx_ads_shipped',
  264. 'ETEMPLATE_RECEIVED' => 'bx_ads_received',
  265. 'ETEMPLATE_OFFER_ADDED' => 'bx_ads_offer_added',
  266. 'ETEMPLATE_OFFER_ACCEPTED' => 'bx_ads_offer_accepted',
  267. 'ETEMPLATE_OFFER_DECLINED' => 'bx_ads_offer_declined',
  268. 'ETEMPLATE_OFFER_CANCELED' => 'bx_ads_offer_canceled',
  269. // some language keys
  270. 'T' => array (
  271. 'txt_sample_single' => '_bx_ads_txt_sample_single',
  272. 'txt_sample_single_with_article' => '_bx_ads_txt_sample_single_with_article',
  273. 'txt_sample_comment_single' => '_bx_ads_txt_sample_comment_single',
  274. 'txt_sample_vote_single' => '_bx_ads_txt_sample_vote_single',
  275. 'txt_sample_reaction_single' => '_bx_ads_txt_sample_reaction_single',
  276. 'txt_sample_score_up_single' => '_bx_ads_txt_sample_score_up_single',
  277. 'txt_sample_score_down_single' => '_bx_ads_txt_sample_score_down_single',
  278. 'txt_sample_interest_single' => '_bx_ads_txt_sample_interest_single',
  279. 'txt_status_offer' => '_bx_ads_txt_status_offer',
  280. 'txt_status_sold' => '_bx_ads_txt_status_sold',
  281. 'form_field_author' => '_bx_ads_form_entry_input_author',
  282. 'form_field_covers_uploader_simple' => '_bx_ads_form_entry_input_covers_uploader_simple_title',
  283. 'form_field_covers_uploader_html5' => '_bx_ads_form_entry_input_covers_uploader_html5_title',
  284. 'grid_action_err_delete' => '_bx_ads_grid_action_err_delete',
  285. 'grid_txt_account_manager' => '_bx_ads_grid_txt_account_manager',
  286. 'filter_item_active' => '_bx_ads_grid_filter_item_title_adm_active',
  287. 'filter_item_hidden' => '_bx_ads_grid_filter_item_title_adm_hidden',
  288. 'filter_item_pending' => '_bx_ads_grid_filter_item_title_adm_pending',
  289. 'filter_item_unpaid' => '_bx_ads_grid_filter_item_title_adm_unpaid',
  290. 'filter_item_select_one_filter1' => '_bx_ads_grid_filter_item_title_adm_select_one_filter1',
  291. 'filter_item_select_one_filter2' => '_bx_ads_grid_filter_item_title_adm_select_one_filter2',
  292. 'menu_item_manage_my' => '_bx_ads_menu_item_title_manage_my',
  293. 'menu_item_manage_all' => '_bx_ads_menu_item_title_manage_all',
  294. 'txt_all_entries_by' => '_bx_ads_txt_all_entries_by',
  295. 'txt_all_entries_in' => '_bx_ads_txt_all_entries_in',
  296. 'txt_all_entries_by_author' => '_bx_ads_page_title_browse_by_author',
  297. 'txt_all_entries_by_context' => '_bx_ads_page_title_browse_by_context',
  298. 'txt_err_cannot_perform_action' => '_bx_ads_txt_err_cannot_perform_action',
  299. 'txt_poll_form_answers_add' => '_bx_ads_form_poll_input_answers_add',
  300. 'txt_poll_menu_view_answers' => '_bx_ads_txt_poll_view_answers',
  301. 'txt_poll_menu_view_results' => '_bx_ads_txt_poll_view_results',
  302. 'txt_poll_answer_vote_do_by' => '_bx_ads_txt_poll_answer_vote_do_by',
  303. 'txt_poll_answer_vote_counter' => '_bx_ads_txt_poll_answer_vote_counter',
  304. 'txt_poll_answer_vote_percent' => '_bx_ads_txt_poll_answer_vote_percent',
  305. 'txt_link_form_err_delete' => '_bx_ads_form_entry_input_link_err_delete',
  306. 'txt_display_add' => '_bx_ads_txt_display_title_add',
  307. 'txt_display_edit' => '_bx_ads_txt_display_title_edit',
  308. 'txt_display_view' => '_bx_ads_txt_display_title_view',
  309. 'txt_cd_ct_product' => '_bx_ads_txt_cd_ct_product',
  310. 'txt_cd_ct_promotion' => '_bx_ads_txt_cd_ct_promotion',
  311. 'chart_label_impressions' => '_bx_ads_chart_label_impressions',
  312. 'chart_label_clicks' => '_bx_ads_chart_label_clicks',
  313. 'chart_label_roi_local' => '_bx_ads_chart_label_roi_local',
  314. 'chart_label_roi_source' => '_bx_ads_chart_label_roi_source',
  315. 'chart_label_roi_investment' => '_bx_ads_chart_label_roi_investment',
  316. ),
  317. ));
  318. $this->_aJsClasses = array_merge($this->_aJsClasses, [
  319. 'main' => 'BxAdsMain',
  320. 'manage_tools' => 'BxAdsManageTools',
  321. 'studio' => 'BxAdsStudio',
  322. 'entry' => 'BxAdsEntry',
  323. 'form' => 'BxAdsForm',
  324. 'form_offer' => 'BxAdsFormOffer',
  325. ]);
  326. $this->_aJsObjects = array_merge($this->_aJsObjects, [
  327. 'main' => 'oBxAdsMain',
  328. 'manage_tools' => 'oBxAdsManageTools',
  329. 'studio' => 'oBxAdsStudio',
  330. 'entry' => 'oBxAdsEntry',
  331. 'form' => 'oBxAdsForm',
  332. 'form_offer' => 'oBxAdsFormOffer',
  333. ]);
  334. $this->_aGridObjects = [
  335. 'categories' => $this->CNF['OBJECT_GRID_CATEGORIES'],
  336. 'common' => $this->CNF['OBJECT_GRID_COMMON'],
  337. 'administration' => $this->CNF['OBJECT_GRID_ADMINISTRATION'],
  338. ];
  339. $sPrefix = str_replace('_', '-', $this->_sName);
  340. $this->_aHtmlIds = array_merge($this->_aHtmlIds, [
  341. 'unit' => $sPrefix . '-unit-',
  342. 'offer_popup' => $sPrefix . '-offer-popup',
  343. ]);
  344. $this->_bAttachmentsInTimeline = true;
  345. $this->_bPromotion = false;
  346. $this->_fPromotionCpm = 0;
  347. $this->_sCacheEngineShopify = 'File';
  348. $this->_iCacheLifetimeShopify = 2419200; //1 month
  349. }
  350. public function init(&$oDb)
  351. {
  352. $this->_oDb = &$oDb;
  353. $this->_bSources = getParam($this->CNF['PARAM_USE_SOURCES']) == 'on';
  354. $this->_bAuction = getParam($this->CNF['PARAM_USE_AUCTION']) == 'on';
  355. $this->_bPromotion = getParam($this->CNF['PARAM_USE_PROMOTION']) == 'on';
  356. if($this->_bPromotion) {
  357. $this->_fPromotionCpm = (float)getParam($this->CNF['PARAM_PROMOTION_CPM']);
  358. }
  359. }
  360. public function getActiveStatus()
  361. {
  362. return [BX_BASE_MOD_TEXT_STATUS_ACTIVE];
  363. }
  364. public function getActiveStatusAdmin()
  365. {
  366. return [BX_BASE_MOD_TEXT_STATUS_ACTIVE];
  367. }
  368. public function isSources()
  369. {
  370. return $this->_bSources;
  371. }
  372. public function isAuction()
  373. {
  374. return $this->_bAuction;
  375. }
  376. public function isPromotion()
  377. {
  378. return $this->_bPromotion;
  379. }
  380. public function getEntryName($sName)
  381. {
  382. return uriGenerate($sName, $this->CNF['TABLE_ENTRIES'], $this->CNF['FIELD_NAME'], ['lowercase' => false]);
  383. }
  384. public function getDay($iTimestamp = null)
  385. {
  386. return mktime(0, 0, 0, date("m", $iTimestamp), date("d", $iTimestamp), date("Y", $iTimestamp));
  387. }
  388. public function getPromotionCpm()
  389. {
  390. return $this->_fPromotionCpm;
  391. }
  392. public function getCacheEngineShopify()
  393. {
  394. return $this->_sCacheEngineShopify;
  395. }
  396. public function getCacheLifetimeShopify()
  397. {
  398. return $this->_iCacheLifetimeShopify;
  399. }
  400. public function getCacheKeyShopify()
  401. {
  402. return 'bx_ads_shopify_' . bx_site_hash() . '.php';
  403. }
  404. public function getRandomWeightedItem($aWeightedValues)
  405. {
  406. $iRand = mt_rand(1, (int)array_sum($aWeightedValues));
  407. foreach($aWeightedValues as $iKey => $iValue)
  408. if(($iRand -= $iValue) <= 0)
  409. return $iKey;
  410. }
  411. }
  412. /** @} */