BxBaseConnection.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  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 UnaBaseView UNA Base Representation Classes
  7. * @{
  8. */
  9. /**
  10. * @see BxBaseConnection
  11. */
  12. class BxBaseConnection extends BxDolConnection
  13. {
  14. protected $_oTemplate;
  15. protected $_oFunctions;
  16. protected $_sStylePrefix;
  17. protected $_sJsObjName;
  18. protected $_sHp;
  19. protected $_aHtmlIds;
  20. protected $_aT;
  21. protected $_sTmplContentElement;
  22. protected $_sTmplContentCounter;
  23. protected $_aElementDefaults;
  24. public function __construct($aObject)
  25. {
  26. parent::__construct($aObject);
  27. $this->_oTemplate = BxDolTemplate::getInstance();
  28. $this->_oFunctions = BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate);
  29. $this->_sStylePrefix = 'bx-conn';
  30. $this->_sJsObjName = 'oConn' . bx_gen_method_name($this->_sObject, ['_' , '-']) . '';
  31. $this->_sHp = str_replace('_', '-', $this->_sObject);
  32. $this->_aHtmlIds = [
  33. 'main' => 'bx-conn-' . $this->_sHp . '-',
  34. 'do_popup' => 'bx-conn-do-popup-' . $this->_sHp . '-',
  35. 'do_menu' => 'bx-conn-do-menu-' . $this->_sHp . '-',
  36. 'counter' => 'bx-conn-counter-' . $this->_sHp . '-',
  37. 'by_popup' => 'bx-conn-by-popup-' . $this->_sHp . '-',
  38. ];
  39. $this->_aT = [
  40. 'do_by' => '_sys_conn_do_by'
  41. ];
  42. $this->_sTmplContentElement = $this->_oTemplate->getHtml('connection_element.html');
  43. $this->_sTmplContentCounter = $this->_oTemplate->getHtml('connection_counter.html');
  44. $this->_aElementDefaults = [
  45. 'uniq_id' => '',
  46. 'dynamic_mode' => true,
  47. 'show_do_as_button_small' => false,
  48. 'show_do_as_button' => false,
  49. 'show_do_icon' => true,
  50. 'show_do_label' => true,
  51. 'show_counter' => false,
  52. 'show_counter_label_with_profiles' => true,
  53. 'show_script' => true
  54. ];
  55. }
  56. public function actionGetConnected ($iStart = 0, $iPerPage = 0)
  57. {
  58. $sContentType = bx_process_input(bx_get('content_type'));
  59. $iProfileId = (int)bx_get('id');
  60. $bIsMutual = (bool)bx_get('mutual');
  61. $aRequestParamsData = $this->_getRequestParamsData();
  62. return $this->_getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage, $aRequestParamsData);
  63. }
  64. public function actionGetUsers ($iStart = 0, $iPerPage = 0)
  65. {
  66. $sContentType = bx_process_input(bx_get('content_type'));
  67. $iProfileId = (int)bx_get('id');
  68. $bIsMutual = (bool)bx_get('mutual');
  69. $iStart = (int)bx_get('start');
  70. $iPerPage = (int)bx_get('per_page');
  71. $aRequestParamsData = $this->_getRequestParamsData();
  72. return [
  73. 'content' => $this->_getConnected($sContentType, $iProfileId, $bIsMutual, $iStart, $iPerPage, $aRequestParamsData),
  74. 'eval' => $this->getJsObjectName($iProfileId, $aRequestParamsData) . '.onGetUsers(oData)'
  75. ];
  76. }
  77. public function getJsObjectName($iProfileId, $aParams = [])
  78. {
  79. return $this->_sJsObjName . (!empty($aParams['uniq_id']) ? $aParams['uniq_id'] : '') . $iProfileId;
  80. }
  81. public function getElement($iContent, $iInitiator = false, $aParams = [])
  82. {
  83. $aParams = $this->_prepareParamsData($aParams);
  84. $bDynamicMode = isset($aParams['dynamic_mode']) && (bool)$aParams['dynamic_mode'] === true;
  85. $bShowDo = !isset($aParams['show_do']) || (bool)$aParams['show_do'] === true;
  86. $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && (bool)$aParams['show_do_as_button_small'] === true;
  87. $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && (bool)$aParams['show_do_as_button'] === true;
  88. $bShowDoLabel = isset($aParams['show_do_label']) && (bool)$aParams['show_do_label'] === true;
  89. $bShowCounter = isset($aParams['show_counter']) && (bool)$aParams['show_counter'] === true;
  90. if(!$iInitiator)
  91. $iInitiator = bx_get_logged_profile_id();
  92. if($iInitiator && $iInitiator == $iContent)
  93. return '';
  94. $aActions = $this->_getActions($iInitiator, $iContent, $aParams);
  95. $iCount = $this->_getCounterCount($iContent, $this->_bMutual, $aParams);
  96. if((empty($aActions['items']) || !is_array($aActions['items'])) && (!$bShowCounter || !$iCount))
  97. return '';
  98. $sJsObject = $this->getJsObjectName($iContent, $aParams);
  99. $sClassDo = '';
  100. if($bShowDoAsButton)
  101. $sClassDo = ' bx-btn';
  102. else if ($bShowDoAsButtonSmall)
  103. $sClassDo = ' bx-btn bx-btn-small';
  104. $aTmplVarsAction = $aTmplVarsActions = [];
  105. if(count($aActions['items']) == 1) {
  106. $aAction = reset($aActions['items']);
  107. $aTmplVarsAction = array_merge([
  108. 'style_prefix' => $this->_sStylePrefix,
  109. 'js_object' => $sJsObject,
  110. 'class' => $sClassDo,
  111. 'action' => $aAction['name'],
  112. 'profile_id' => $iContent,
  113. 'title' => $bShowDoLabel && !empty($aAction['title']) ? _t($aAction['title']) : ''
  114. ], $this->_getTmplVarsAction($aAction, $aParams));
  115. }
  116. else {
  117. $sHtmlIdDoPopup = $this->_aHtmlIds['do_popup'] . $iContent;
  118. $sHtmlIdDoMenu = $this->_aHtmlIds['do_menu'] . $iContent;
  119. $aMenuItems = [];
  120. foreach($aActions['items'] as $aItem)
  121. if(!empty($aItem) && is_array($aItem)) {
  122. if(!isset($aItem['link'], $aItem['onclick']))
  123. $aMenuItems[] = [
  124. 'id' => $aItem['name'],
  125. 'name' => $aItem['name'],
  126. 'icon' => $this->_getActionIcon($aItem, $aParams),
  127. 'link' => 'javascript:void(0)',
  128. 'onclick' => "javascript:" . $sJsObject . ".connect(this, '" . $aItem['name'] . "', " . $iContent . ")",
  129. 'target' => '_self',
  130. 'title' => !empty($aItem['title']) ? _t($aItem['title']) : '',
  131. 'active' => 1
  132. ];
  133. else
  134. $aMenuItems[] = $aItem;
  135. }
  136. $oMenu = new BxTemplMenu(['template' => 'menu_vertical.html', 'menu_id'=> $sHtmlIdDoMenu, 'menu_items' => $aMenuItems]);
  137. $aTmplVarsActions = array_merge([
  138. 'style_prefix' => $this->_sStylePrefix,
  139. 'js_object' => $sJsObject,
  140. 'class' => $sClassDo,
  141. 'profile_id' => $iContent,
  142. 'do_popup' => $this->_oFunctions->transBox($sHtmlIdDoPopup, $oMenu->getCode(), true),
  143. ], $this->_getTmplVarsAction([
  144. 'name' => $aActions['name'],
  145. 'title' => $bShowDoLabel && !empty($aActions['title']) ? $aActions['title'] : ''
  146. ], $aParams));
  147. }
  148. $bTmplVarsAction = !empty($aTmplVarsAction) && is_array($aTmplVarsAction);
  149. $bTmplVarsActions = !empty($aTmplVarsActions) && is_array($aTmplVarsActions);
  150. return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentElement(), [
  151. 'style_prefix' => $this->_sStylePrefix,
  152. 'html_id' => $this->_aHtmlIds['main'] . $iContent,
  153. 'class' => $this->_sStylePrefix . ($bShowDoAsButton ? '-button' : '-link') . ($bShowDoAsButtonSmall ? '-button-small' : ''),
  154. 'bx_if:show_do' => [
  155. 'condition' => $bShowDo && ($bTmplVarsAction || $bTmplVarsActions),
  156. 'content' => [
  157. 'style_prefix' => $this->_sStylePrefix,
  158. 'bx_if:show_action' => [
  159. 'condition' => $bTmplVarsAction,
  160. 'content' => $aTmplVarsAction
  161. ],
  162. 'bx_if:show_actions' => [
  163. 'condition' => $bTmplVarsActions,
  164. 'content' => $aTmplVarsActions
  165. ],
  166. ]
  167. ],
  168. 'bx_if:show_counter' => [
  169. 'condition' => $bShowCounter && $iCount,
  170. 'content' => [
  171. 'style_prefix' => $this->_sStylePrefix,
  172. 'counter' => $this->getCounter($iContent, $this->_bMutual, array_merge($aParams, ['count' => $iCount]))
  173. ]
  174. ],
  175. 'script' => $this->_getJsScript($iContent, $this->_bMutual, $aParams)
  176. ]);
  177. }
  178. public function getCounter($iProfileId, $bIsMutual = false, $aParams = [])
  179. {
  180. $aParams = $this->_prepareParamsData($aParams);
  181. if(!$iProfileId)
  182. $iProfileId = bx_get_logged_profile_id();
  183. if($this->_aObject['type'] != 'mutual')
  184. $bIsMutual = false;
  185. $iCount = !empty($aParams['count']) ? $aParams['count'] : $this->_getCounterCount($iProfileId, $bIsMutual, $aParams);
  186. if(!$iCount)
  187. return '';
  188. $bDynamicMode = isset($aParams['dynamic_mode']) && (bool)$aParams['dynamic_mode'] === true;
  189. $bShowDoAsButtonSmall = isset($aParams['show_do_as_button_small']) && (bool)$aParams['show_do_as_button_small'] === true;
  190. $bShowDoAsButton = !$bShowDoAsButtonSmall && isset($aParams['show_do_as_button']) && (bool)$aParams['show_do_as_button'] === true;
  191. $bShowScript = !isset($aParams['show_script']) || (bool)$aParams['show_script'] === true;
  192. $sJsObject = $this->getJsObjectName($iProfileId, $aParams);
  193. $sClass = $this->_sStylePrefix . '-counter';
  194. if($bShowDoAsButtonSmall)
  195. $sClass .= ' bx-btn-small-height';
  196. if($bShowDoAsButton)
  197. $sClass .= ' bx-btn-height';
  198. $sHtmlIdCounter = $this->_aHtmlIds['counter'] . $iProfileId;
  199. $sContent = $this->_getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams);
  200. $this->_oTemplate->addCss(['connection.css']);
  201. return $this->_oTemplate->parseHtmlByContent($this->_getTmplContentCounter(), [
  202. 'html_id' => $sHtmlIdCounter,
  203. 'style_prefix' => $this->_sStylePrefix,
  204. 'bx_if:show_text' => [
  205. 'condition' => false,
  206. 'content' => [
  207. 'class' => $sClass,
  208. 'bx_repeat:attrs' => [
  209. ['key' => 'id', 'value' => $sHtmlIdCounter],
  210. ],
  211. 'content' => $sContent
  212. ]
  213. ],
  214. 'bx_if:show_link' => [
  215. 'condition' => true,
  216. 'content' => [
  217. 'class' => $sClass,
  218. 'bx_repeat:attrs' => [
  219. ['key' => 'id', 'value' => $sHtmlIdCounter],
  220. ['key' => 'href', 'value' => 'javascript:void(0)'],
  221. ['key' => 'onclick', 'value' => 'javascript:' . $sJsObject . '.toggleByPopup(this)'],
  222. ['key' => 'title', 'value' => _t('_sys_conn_do_by')]
  223. ],
  224. 'content' => $sContent
  225. ]
  226. ],
  227. 'script' => $bShowScript ? $this->_getJsScript($iProfileId, $bIsMutual, $aParams) : ''
  228. ]);
  229. }
  230. public function getCounterAPI($iProfileId, $bIsMutual = false, $aParams = [])
  231. {
  232. $sContentType = ($sKey = 'content_type') && isset($aParams[$sKey]) ? $aParams[$sKey] : BX_CONNECTIONS_CONTENT_TYPE_INITIATORS;
  233. $iCount = $this->{'getConnected' . ($sContentType == BX_CONNECTIONS_CONTENT_TYPE_INITIATORS ? 'Initiators' : 'Content') . 'Count'}($iProfileId, $bIsMutual);
  234. return [
  235. 'count' => $iCount,
  236. 'countf' => _t(isset($aParams['caption']) ? $aParams['caption'] : $this->_aT['counter'], $iCount)
  237. ];
  238. }
  239. public function getConnectedListAPI($iProfileId, $bIsMutual, $sContentType, $iCount = BX_CONNECTIONS_LIST_COUNTER)
  240. {
  241. $aProfiles = [];
  242. $aIds = $this->{BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'getConnectedInitiators' : 'getConnectedContent'}($iProfileId, $bIsMutual, 0, $iCount);
  243. foreach($aIds as $iId)
  244. if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
  245. $aProfiles[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);
  246. return $aProfiles;
  247. }
  248. public function getCommonListAPI($iProfileId1, $iProfileId2, $bIsMutual, $iCount = BX_CONNECTIONS_LIST_COUNTER)
  249. {
  250. $aProfiles = [];
  251. $aIds = $this->getCommonContent($iProfileId1, $iProfileId2, $bIsMutual, 0, $iCount);
  252. foreach($aIds as $iId)
  253. if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
  254. $aProfiles[] = $oProfile->getUnitAPI(0, ['template' => 'unit_wo_info']);
  255. return $aProfiles;
  256. }
  257. protected function _action($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual = false, $isInvert = false)
  258. {
  259. $aResult = parent::_action($iInitiator, $iContent, $sMethod, $sErrorKey, $isMutual, $isInvert);
  260. if(!$aResult['err'] && ($sOut = bx_get('out')) !== false && $sOut == 'eval') {
  261. $aRequestParamsData = $this->_getRequestParamsData();
  262. $aResult = array_merge($aResult, [
  263. 'data' => $this->getElement($this->_iContent, $this->_iInitiator, $aRequestParamsData),
  264. 'eval' => $this->getJsObjectName($this->_iContent, $aRequestParamsData) . '.onConnect(oData)',
  265. ]);
  266. }
  267. return $aResult;
  268. }
  269. protected function _getJsScript($iContentId, $bIsMutual = false, $aParams = [])
  270. {
  271. $sJsObject = $this->getJsObjectName($iContentId, $aParams);
  272. $aParamsJs = [
  273. 'sSystem' => $this->_sObject,
  274. 'iContentId' => $iContentId,
  275. 'bIsMutual' => $bIsMutual ? 1 : 0,
  276. 'sObjName' => $sJsObject,
  277. 'sRootUrl' => BX_DOL_URL_ROOT,
  278. 'sStylePrefix' => $this->_sStylePrefix,
  279. 'aHtmlIds' => $this->_aHtmlIds,
  280. 'aRequestParams' => $this->_prepareRequestParamsData($aParams)
  281. ];
  282. if(($sKey = 'content_type') && !empty($aParams[$sKey]))
  283. $aParamsJs['sContentType'] = $aParams[$sKey];
  284. $sCode = "if(window['" . $sJsObject . "'] == undefined) var " . $sJsObject . " = new BxDolConnection(" . json_encode($aParamsJs) . ");";
  285. return $this->_oTemplate->_wrapInTagJsCode($sCode);
  286. }
  287. protected function _getCounterCount($iProfileId, $bIsMutual, $aParams = [])
  288. {
  289. $sContentType = ($sKey = 'content_type') && isset($aParams[$sKey]) ? $aParams[$sKey] : BX_CONNECTIONS_CONTENT_TYPE_INITIATORS;
  290. return $this->{'getConnected' . ($sContentType == BX_CONNECTIONS_CONTENT_TYPE_INITIATORS ? 'Initiators' : 'Content') . 'Count'}($iProfileId, $bIsMutual);
  291. }
  292. protected function _getCounterLabel($iCount, $iProfileId, $bIsMutual, $aParams)
  293. {
  294. if ('mutual' != $this->_aObject['type'])
  295. $bIsMutual = false;
  296. $sContentType = ($sKey = 'content_type') && isset($aParams[$sKey]) ? $aParams[$sKey] : BX_CONNECTIONS_CONTENT_TYPE_INITIATORS;
  297. $bShowWithProfiles = isset($aParams['show_counter_label_with_profiles']) && $aParams['show_counter_label_with_profiles'] === true;
  298. $bShowWithIcon = (!isset($aParams['show_counter_label_icon']) || $aParams['show_counter_label_icon'] === true) && !$bShowWithProfiles;
  299. $aTmplVarsWithProfiles = [];
  300. if($bShowWithProfiles) {
  301. $aTmplVarsWithProfiles = [
  302. 'style_prefix' => $this->_sStylePrefix,
  303. 'bx_repeat:profiles' => []
  304. ];
  305. $aIds = $this->{'getConnected' . (BX_CONNECTIONS_CONTENT_TYPE_INITIATORS == $sContentType ? 'Initiators' : 'Content')}($iProfileId, $bIsMutual, 0, BX_CONNECTIONS_LIST_COUNTER);
  306. foreach($aIds as $iId)
  307. if(($oProfile = BxDolProfile::getInstanceMagic($iId)) !== false)
  308. $aTmplVarsWithProfiles['bx_repeat:profiles'][] = [
  309. 'style_prefix' => $this->_sStylePrefix,
  310. 'unit' => $oProfile->getUnit(0, ['template' => ['name' => 'unit_wo_info_links', 'size' => 'icon']])
  311. ];
  312. }
  313. return $this->_oTemplate->parseHtmlByName('connection_counter_label.html', array(
  314. 'style_prefix' => $this->_sStylePrefix,
  315. 'bx_if:show_icon' => array(
  316. 'condition' => $bShowWithIcon,
  317. 'content' => array(
  318. 'style_prefix' => $this->_sStylePrefix,
  319. 'name' => isset($aParams['custom_icon']) && $aParams['custom_icon'] != '' ? $aParams['custom_icon'] : $this->_oFunctions->getFontIconAsHtml($this->_getIconDo())
  320. )
  321. ),
  322. 'bx_if:show_profiles' => array(
  323. 'condition' => $bShowWithProfiles,
  324. 'content' => $aTmplVarsWithProfiles
  325. ),
  326. 'bx_if:show_text' => array(
  327. 'condition' => !isset($aParams['show_counter_label_text']) || $aParams['show_counter_label_text'] === true,
  328. 'content' => array(
  329. 'style_prefix' => $this->_sStylePrefix,
  330. 'text' => _t(isset($aParams['caption']) ? $aParams['caption'] : $this->_aT['counter'], $iCount)
  331. )
  332. )
  333. ));
  334. }
  335. protected function _getIconDo()
  336. {
  337. if ($this->_sObject == 'sys_profiles_subscriptions')
  338. return 'user-friends';
  339. if (strpos($this->_sObject, 'fan'))
  340. return 'users';
  341. }
  342. public function _getConnected ($sContentType, $iProfileId, $bIsMutual, $iStart = 0, $iPerPage = 0, $aParams = [])
  343. {
  344. if ('mutual' != $this->_aObject['type'])
  345. $bIsMutual = false;
  346. if(empty($iPerPage))
  347. $iPerPage = $this->_aObject['per_page_default'];
  348. $aUsers = $this->getConnectionsAsArray($sContentType, $iProfileId, null, $bIsMutual, $iStart, $iPerPage + 1);
  349. $oPaginate = new BxTemplPaginate([
  350. 'on_change_page' => $this->getJsObjectName($iProfileId, $aParams) . '.getUsers(this, {start}, {per_page})',
  351. 'start' => $iStart,
  352. 'per_page' => $iPerPage,
  353. ]);
  354. $oPaginate->setNumFromDataArray($aUsers);
  355. foreach($aUsers as $iProfile) {
  356. $oProfile = BxDolProfile::getInstanceMagic($iProfile);
  357. $aTmplUsers[] = [
  358. 'style_prefix' => $this->_sStylePrefix,
  359. 'user_unit' => $oProfile->getUnit(0, ['template' => 'unit_wo_info']),
  360. 'user_url' => $oProfile->getUrl(),
  361. 'user_title' => bx_html_attribute($oProfile->getDisplayName()),
  362. 'user_name' => $oProfile->getDisplayName()
  363. ];
  364. }
  365. if(empty($aTmplUsers))
  366. $aTmplUsers = MsgBox(_t('_Empty'));
  367. return $this->_oTemplate->parseHtmlByName('connected_by_list.html', [
  368. 'style_prefix' => $this->_sStylePrefix,
  369. 'bx_repeat:list' => $aTmplUsers,
  370. 'paginate' => $oPaginate->getSimplePaginate()
  371. ]);
  372. }
  373. protected function _getAuthorInfo($iAuthorId = 0)
  374. {
  375. $oProfile = $this->_getAuthorObject($iAuthorId);
  376. return array(
  377. $oProfile->getDisplayName(),
  378. $oProfile->getUrl(),
  379. $oProfile->getThumb(),
  380. $oProfile->getUnit(),
  381. $oProfile->getUnit(0, array('template' => 'unit_wo_info'))
  382. );
  383. }
  384. protected function _getActions($iInitiator, $iContent, $aParams = [])
  385. {
  386. return [];
  387. }
  388. protected function _getActionIcon($aAction, $aParams = [])
  389. {
  390. return !empty($aAction['name']) ? $this->{'_getActionIconAs' . bx_gen_method_name($this->_useIconAs($aParams))}($aAction['name']) : '';
  391. }
  392. protected function _useIconAs($aParams = [])
  393. {
  394. if(!empty($aParams['use_icon_as']) && in_array($aParams['use_icon_as'], ['icon', 'emoji', 'image']))
  395. return $aParams['use_icon_as'];
  396. return 'image';
  397. }
  398. protected function _getTmplContentElement()
  399. {
  400. return $this->_sTmplContentElement;
  401. }
  402. protected function _getTmplContentCounter()
  403. {
  404. return $this->_sTmplContentCounter;
  405. }
  406. protected function _getTmplVarsAction($aAction, $aParams = [])
  407. {
  408. $sIcon = $this->_getActionIcon($aAction, $aParams);
  409. return [
  410. 'bx_if:show_icon' => [
  411. 'condition' => !empty($sIcon),
  412. 'content' => [
  413. 'style_prefix' => $this->_sStylePrefix,
  414. 'icon' => $this->_oTemplate->getImageAuto($sIcon)
  415. ]
  416. ],
  417. 'bx_if:show_text' => [
  418. 'condition' => !empty($aAction['title']),
  419. 'content' => [
  420. 'style_prefix' => $this->_sStylePrefix,
  421. 'text' => _t($aAction['title'])
  422. ]
  423. ]
  424. ];
  425. }
  426. protected function _prepareParamsData($aParams)
  427. {
  428. $aResult = $this->_aElementDefaults;
  429. if(!empty($aParams) && is_array($aParams))
  430. $aResult = array_merge($aResult, $aParams);
  431. return $aResult;
  432. }
  433. protected function _getRequestParamsData($aKeys = [])
  434. {
  435. $sParams = bx_get('params');
  436. if($sParams === false)
  437. return [];
  438. $aParams = [];
  439. parse_str(bx_process_input($sParams), $aParams);
  440. return $aParams;
  441. }
  442. protected function _prepareRequestParamsData($aParams, $aParamsAdd = [])
  443. {
  444. $aRequestParams = array_intersect_key($aParams, $this->_aElementDefaults);
  445. $aRequestParams = array_merge($aRequestParams, $aParamsAdd);
  446. foreach($aRequestParams as $sKey => $mixedValue)
  447. if(is_bool($mixedValue))
  448. $aRequestParams[$sKey] = (int)$mixedValue;
  449. return $aRequestParams;
  450. }
  451. }