1
0

BxBaseServices.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  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. * System services.
  11. */
  12. class BxBaseServices extends BxDol implements iBxDolProfileService
  13. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. public function serviceIsPublicService($s)
  19. {
  20. $sService = bx_gen_method_name($s);
  21. $aServices = $this->serviceGetPublicServices();
  22. return isset($aServices[$sService]);
  23. }
  24. public function serviceGetPublicServices()
  25. {
  26. return array (
  27. 'GetProductsNames' => 'BxBaseServices',
  28. );
  29. }
  30. public function serviceIsSafeService($s)
  31. {
  32. $sService = bx_gen_method_name($s);
  33. $aSafeServices = $this->serviceGetSafeServices();
  34. return isset($aSafeServices[$sService]);
  35. }
  36. public function serviceGetSafeServices()
  37. {
  38. return array(
  39. 'GetCreatePostForm' => 'BxBaseServices',
  40. 'GetProductsNames' => 'BxBaseServices',
  41. 'KeywordSearch' => 'BxBaseServices',
  42. 'Cmts' => 'BxBaseServices',
  43. 'CreateAccountForm' => 'BxBaseServiceAccount',
  44. 'ForgotPassword' => 'BxBaseServiceAccount',
  45. 'SwitchProfile' => 'BxBaseServiceAccount',
  46. 'CategoriesList' => 'BxBaseServiceCategory',
  47. 'Test' => 'BxBaseServiceLogin',
  48. 'MemberAuthCode' => 'BxBaseServiceLogin',
  49. 'LoginForm' => 'BxBaseServiceLogin',
  50. 'KeywordsCloud' => 'BxBaseServiceMetatags',
  51. 'ProfileMembership' => 'BxBaseServiceProfiles',
  52. 'ProfileNotifications' => 'BxBaseServiceProfiles',
  53. 'GetCountOnlineProfiles' => 'BxBaseServiceProfiles',
  54. 'GetChartGrowth' => 'BxBaseChartServices',
  55. 'GetChartStats' => 'BxBaseChartServices',
  56. 'GetCartItemsCount' => 'BxBasePaymentsServices',
  57. 'GetOrdersCount' => 'BxBasePaymentsServices',
  58. );
  59. }
  60. public function serviceProfileUnit ($iContentId, $aParams = array())
  61. {
  62. return $this->_serviceProfileFunc('getUnit', $iContentId, $aParams);
  63. }
  64. public function serviceHasImage ($iContentId)
  65. {
  66. return false;
  67. }
  68. public function serviceProfilePicture ($iContentId)
  69. {
  70. return BxDolTemplate::getInstance()->getImageUrl('account-picture.png');
  71. }
  72. public function serviceProfileAvatar ($iContentId)
  73. {
  74. return BxDolTemplate::getInstance()->getImageUrl('account-avatar.png');
  75. }
  76. public function serviceProfileCover ($iContentId)
  77. {
  78. return '';
  79. }
  80. public function serviceProfileEditUrl ($iContentId)
  81. {
  82. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=account-settings-info');
  83. }
  84. public function serviceProfileThumb ($iContentId)
  85. {
  86. return $this->_serviceProfileFunc('getThumb', $iContentId);
  87. }
  88. public function serviceProfileIcon ($iContentId)
  89. {
  90. return $this->_serviceProfileFunc('getIcon', $iContentId);
  91. }
  92. public function serviceProfileName ($iContentId)
  93. {
  94. return $this->_serviceProfileFunc('getDisplayName', $iContentId);
  95. }
  96. public function serviceProfileUrl ($iContentId)
  97. {
  98. return $this->_serviceProfileFunc('getUrl', $iContentId);
  99. }
  100. /**
  101. * @see iBxDolProfileService::serviceCheckAllowedProfileView
  102. */
  103. public function serviceCheckAllowedProfileView($iContentId)
  104. {
  105. return _t('_Access denied');
  106. }
  107. /**
  108. * @see iBxDolProfileService::serviceCheckAllowedProfileContact
  109. */
  110. public function serviceCheckAllowedProfileContact($iContentId)
  111. {
  112. return _t('_Access denied');
  113. }
  114. /**
  115. * @see iBxDolProfileService::serviceCheckAllowedPostInProfile
  116. */
  117. public function serviceCheckAllowedPostInProfile($iContentId)
  118. {
  119. return _t('_Access denied');
  120. }
  121. /**
  122. * @see iBxDolProfileService::serviceGetSpaceTitle
  123. */
  124. public function serviceGetSpaceTitle()
  125. {
  126. return '';
  127. }
  128. /**
  129. * @see iBxDolProfileService::serviceGetParticipatingProfiles
  130. */
  131. public function serviceGetParticipatingProfiles($iProfileId, $aConnectionObject = false)
  132. {
  133. return array();
  134. }
  135. /**
  136. * @page service Service Calls
  137. * @section bx_system_general System Services
  138. * @subsection bx_system_general-general General
  139. * @subsubsection bx_system_general-get_create_post_form get_create_post_form
  140. *
  141. * @code bx_srv('system', 'get_create_post_form', [false, "bx_posts"], 'TemplServices'); @endcode
  142. * @code {{~system:get_create_post_form:TemplServices[false,"bx_posts"]~}} @endcode
  143. *
  144. * Get United Create Post form.
  145. * @param $mixedContextId - context which the post will be created in:
  146. * - false = 'Public' post form;
  147. * - 0 = 'Profile' post form, which allows to post in your own profile and connections;
  148. * - n = 'Context' post form, which allows to post in context (3d party profile, group, event, etc).
  149. * @param $sDefault - tab selected by default.
  150. * @param $aCustom - an array with custom paramaters.
  151. * @return string with form content
  152. *
  153. * @see BxBaseServices::serviceGetCreatePostForm
  154. */
  155. /**
  156. * @ref bx_system_general-get_create_post_form "get_create_post_form"
  157. */
  158. public function serviceGetCreatePostForm($mixedContextId = false, $sDefault = '', $aCustom = array())
  159. {
  160. if(!isLogged() || ($mixedContextId !== false && !is_numeric($mixedContextId)))
  161. return '';
  162. $oProfile = BxDolProfile::getInstance();
  163. if(!$oProfile)
  164. return '';
  165. if($mixedContextId !== false)
  166. $mixedContextId = (int)(!empty($mixedContextId) ? -$mixedContextId : $oProfile->id());
  167. $bContext = $mixedContextId !== false;
  168. if($bContext && ($oContextProfile = BxDolProfile::getInstance(abs($mixedContextId))) !== false)
  169. if($oContextProfile->checkAllowedPostInProfile() !== CHECK_ACTION_RESULT_ALLOWED)
  170. return '';
  171. $sTitle = _t('_sys_page_block_title_create_post' . (!$bContext ? '_public' : ($mixedContextId < 0 ? '_context' : '')));
  172. $sPlaceholder = _t('_sys_txt_create_post_placeholder', $oProfile->getDisplayName());
  173. $oMenu = BxDolMenu::getObjectInstance('sys_create_post');
  174. if(!$oMenu)
  175. return '';
  176. $aMenuItems = $oMenu->getMenuItems();
  177. if(empty($aMenuItems) || !is_array($aMenuItems))
  178. return '';
  179. if(empty($sDefault)) {
  180. $aDefault = array_shift($aMenuItems);
  181. $sDefault = !empty($aDefault['module']) ? $aDefault['module'] : $aDefault['name'];
  182. }
  183. $oMenu->setSelected($sDefault, $sDefault);
  184. $oTemplate = BxDolTemplate::getInstance();
  185. $oTemplate->addJs(array('BxDolCreatePost.js'));
  186. $sJsObject = 'oBxDolCreatePost';
  187. $sJsContent = $oTemplate->_wrapInTagJsCode("var " . $sJsObject . " = new BxDolCreatePost(" . json_encode(array(
  188. 'sObjName' => $sJsObject,
  189. 'sRootUrl' => BX_DOL_URL_ROOT,
  190. 'sDefault' => $sDefault,
  191. 'iContextId' => $bContext ? $mixedContextId : 0,
  192. 'oCustom' => $aCustom
  193. )) . ");");
  194. return array(
  195. 'title' => $sTitle,
  196. 'content' => BxDolTemplate::getInstance()->parseHtmlByName('create_post_form.html', array(
  197. 'default' => $sDefault,
  198. 'placeholder' => $sPlaceholder,
  199. 'user_thumb' => $oProfile->getUnit(0, array('template' => 'unit_wo_info')),
  200. 'form' => BxDolService::call($sDefault, 'get_create_post_form', array(array('context_id' => $mixedContextId, 'ajax_mode' => true, 'absolute_action_url' => true, 'custom' => $aCustom))),
  201. 'js_object' => $sJsObject,
  202. 'js_content' => $sJsContent
  203. )),
  204. 'menu' => $oMenu
  205. );
  206. }
  207. /**
  208. * @page service Service Calls
  209. * @section bx_system_general System Services
  210. * @subsection bx_system_general-general General
  211. * @subsubsection bx_system_general-get_products_names get_products_names
  212. *
  213. * @code bx_srv('system', 'get_products_names', [], 'TemplServices');
  214. *
  215. * @code http://example.com/m/oauth2/com/get_products_names?module=system&class=BaseServices @endcode
  216. * @code http://hihi.una.io/modules/?r=oauth2/com/get_products_names&module=system&class=BaseServices @endcode
  217. *
  218. * Get an array of products names from all modules with payments functionality.
  219. * @param $iVendorId filter products by vendor ID.
  220. * @param $iLimit limit number of records from one module.
  221. * @return array of products where key id product name and value is module name
  222. *
  223. * @see BxBaseServices::serviceGetProductsNames
  224. */
  225. /**
  226. * @ref bx_system_general-get_products_names "get_products_names"
  227. */
  228. public function serviceGetProductsNames($iVendorId = 0, $iLimit = 1000)
  229. {
  230. $o = BxDolPayments::getInstance();
  231. if (!$o)
  232. return array();
  233. return $o->getProductsNames($iVendorId, $iLimit);
  234. }
  235. /**
  236. * @see iBxDolProfileService::serviceCheckSpacePrivacy
  237. */
  238. public function serviceCheckSpacePrivacy($iContentId)
  239. {
  240. return _t('_Access denied');
  241. }
  242. public function serviceFormsHelper ()
  243. {
  244. return new BxTemplAccountForms();
  245. }
  246. public function serviceActAsProfile ()
  247. {
  248. return false;
  249. }
  250. public function servicePrepareFields ($aFieldsProfile)
  251. {
  252. return $aFieldsProfile;
  253. }
  254. public function serviceProfilesSearch ($sTerm, $iLimit)
  255. {
  256. $oDb = BxDolAccountQuery::getInstance();
  257. $aRet = array();
  258. $a = $oDb->searchByTerm($sTerm, $iLimit);
  259. foreach ($a as $r)
  260. $aRet[] = array ('label' => $this->serviceProfileName($r['content_id']), 'value' => $r['profile_id']);
  261. return $aRet;
  262. }
  263. /**
  264. * @page service Service Calls
  265. * @section bx_system_general System Services
  266. * @subsection bx_system_general-general General
  267. * @subsubsection bx_system_general-keyword_search keyword_search
  268. *
  269. * @code bx_srv('system', 'keyword_search', ["bx_posts", ["keyword" => "test"}], 'TemplServices'); @endcode
  270. *
  271. * @code {{~system:keyword_search:TemplServices["bx_posts", {"keyword":"test"}]~}} @endcode
  272. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country", "keyword": "AU"}, "unit.html"]~}} @endcode
  273. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_state", "state":"NSW", "keyword": "AU"}, "unit.html"]~}} @endcode
  274. * @code {{~system:keyword_search:TemplServices["bx_albums", {"meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"}, "unit.html"]~}} @endcode
  275. * @code {{~system:keyword_search:TemplServices["bx_posts", {"meta_type": "mention", "keyword": 2}, "unit_gallery.html"]~}} @endcode
  276. * @code {{~system:keyword_search:TemplServices["bx_posts", {"cat": "bx_posts_cats", "keyword": 3}, "unit_gallery.html"]~}} @endcode
  277. *
  278. * Search by keyword
  279. * @param $sSection - search object to search in, usually module name, for example: bx_posts
  280. * @param $aCondition - condition for search, supported conditions:
  281. * - search by keyword: ["keyword" => "test"]
  282. * - search by country: ["meta_type" => "location_country", "keyword" => "AU"]
  283. * - search by country and state: ["meta_type": "location_country_state", "state":"NSW", "keyword": "AU"]
  284. * - search by country, state and city: ["meta_type": "location_country_city", "state":"NSW", "city":"Manly", "keyword": "AU"]
  285. * - search for mentions: ["meta_type" => "mention", "keyword" => 2]
  286. * - search in category: ["cat": "bx_posts_cats", "keyword": 3]
  287. * @param $sTemplate - template for displaying search results, for example: unit.html
  288. * @param $iStart - paginate, display records starting from this number
  289. * @param $iPerPage - paginate, display this number of records per page
  290. * @param $bLiveSearch - search results like in live search
  291. *
  292. * @see BxBaseServices::serviceKeywordSearch
  293. */
  294. /**
  295. * @ref bx_system_general-keyword_search "keyword_search"
  296. */
  297. public function serviceKeywordSearch ($sSection, $aCondition, $sTemplate = '', $iStart = 0, $iPerPage = 0, $bLiveSearch = 0, $bPaginate = false)
  298. {
  299. if (!$sSection || !isset($aCondition['keyword']))
  300. return '';
  301. $sClass = 'BxTemplSearch';
  302. $sElsName = 'bx_elasticsearch';
  303. $sElsMethod = 'is_configured';
  304. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod)) {
  305. $oModule = BxDolModule::getInstance($sElsName);
  306. bx_import('Search', $oModule->_aModule);
  307. $sClass = 'BxElsSearch';
  308. }
  309. $oSearch = new $sClass(array($sSection));
  310. $oSearch->setLiveSearch($bLiveSearch);
  311. $oSearch->setMetaType(isset($aCondition['meta_type']) ? $aCondition['meta_type'] : '');
  312. $oSearch->setCategoryObject(isset($aCondition['cat']) ? $aCondition['cat'] : '');
  313. $oSearch->setCustomSearchCondition($aCondition);
  314. if (!$bPaginate)
  315. $oSearch->setRawProcessing(true);
  316. $oSearch->setCustomCurrentCondition(array(
  317. 'paginate' => array (
  318. 'start' => $iStart,
  319. 'perPage' => $iPerPage ? $iPerPage : BX_DOL_SEARCH_RESULTS_PER_PAGE_DEFAULT,
  320. )));
  321. if ($sTemplate)
  322. $oSearch->setUnitTemplate($sTemplate);
  323. return $oSearch->response();
  324. }
  325. /**
  326. * @page service Service Calls
  327. * @section bx_system_general System Services
  328. * @subsection bx_system_general-general General
  329. * @subsubsection bx_system_general-keyword_search keyword_search
  330. *
  331. * @code bx_srv('system', 'search_keyword_form', 'TemplServices'); @endcode
  332. *
  333. * Block with Search by Keywords Form
  334. *
  335. * @see BxBaseServices::serviceSearchKeywordForm
  336. */
  337. /**
  338. * @ref bx_system_general-keyword_search "keyword_search"
  339. */
  340. public function serviceSearchKeywordForm ()
  341. {
  342. return $this->_getSearchObject()->getForm(BX_DB_PADDING_DEF, false, true);
  343. }
  344. /**
  345. * @page service Service Calls
  346. * @section bx_system_general System Services
  347. * @subsection bx_system_general-general General
  348. * @subsubsection bx_system_general-keyword_search keyword_search
  349. *
  350. * @code bx_srv('system', 'search_keyword_result', 'TemplServices'); @endcode
  351. *
  352. * Block with Search by Keywords Results
  353. *
  354. * @see BxBaseServices::serviceSearchKeywordResult
  355. */
  356. /**
  357. * @ref bx_system_general-keyword_search "keyword_search"
  358. */
  359. public function serviceSearchKeywordResult ()
  360. {
  361. $oSearch = $this->_getSearchObject();
  362. $sCode = '';
  363. if (bx_get('keyword') !== false) {
  364. $sCode = $oSearch->response();
  365. if (!$sCode)
  366. $sCode = $oSearch->getEmptyResult();
  367. }
  368. return $sCode;
  369. }
  370. /**
  371. * @page service Service Calls
  372. * @section bx_system_general System Services
  373. * @subsection bx_system_general-general General
  374. * @subsubsection bx_system_general-cmts cmts
  375. *
  376. * @code bx_srv('system', 'cmts', ["sys_blocks", 1], 'TemplServices'); @endcode
  377. *
  378. * @code {{~system:cmts:TemplServices["sys_blocks", 1]~}} @endcode
  379. *
  380. * Comments block
  381. * @param $sObject - comments object name
  382. * @param $sId - content id assiciated tith the comments
  383. *
  384. * @see BxBaseServices::serviceCmts
  385. */
  386. /**
  387. * @ref bx_system_general-cmts "cmts"
  388. */
  389. public function serviceCmts ($sObject, $sId)
  390. {
  391. $o = BxDolCmts::getObjectInstance($sObject, $sId);
  392. if (!$o || !$o->isEnabled())
  393. return '';
  394. return $o->getCommentsBlock(array(), array('in_designbox' => false, 'show_empty' => true));
  395. }
  396. public function _serviceProfileFunc ($sFunc, $iContentId, $aParams = array())
  397. {
  398. if (!$iContentId)
  399. return false;
  400. if (!($oAccount = BxDolAccount::getInstance($iContentId)))
  401. return false;
  402. return $oAccount->$sFunc(false, $aParams);
  403. }
  404. public function serviceAlertResponseProcessInstalled()
  405. {
  406. BxDolTranscoderImage::registerHandlersSystem();
  407. }
  408. public function serviceAlertResponseProcessStorageChange ($oAlert)
  409. {
  410. if ('sys_storage_default' != $oAlert->aExtras['option'])
  411. return;
  412. $aStorages = BxDolStorageQuery::getStorageObjects();
  413. foreach ($aStorages as $r) {
  414. if (0 == $r['current_size'] && 0 == $r['current_number'] && ($oStorage = BxDolStorage::getObjectInstance($r['object'])))
  415. $oStorage->changeStorageEngine($oAlert->aExtras['value']);
  416. }
  417. }
  418. public function serviceGetOptionsProfileBot()
  419. {
  420. $aResult = array(
  421. array('key' => '', 'value' => _t('_Select_one'))
  422. );
  423. $aAccountsIds = BxDolAccountQuery::getInstance()->getOperators();
  424. foreach($aAccountsIds as $iAccountId) {
  425. $aProfilesIds = BxDolAccount::getInstance($iAccountId)->getProfilesIds(true, false);
  426. foreach($aProfilesIds as $iProfileId) {
  427. $oProfile = BxDolProfile::getInstance($iProfileId);
  428. $aResult[] = array(
  429. 'key' => $iProfileId,
  430. 'value' => _t('_sys_profile_with_type', $oProfile->getDisplayName(), $oProfile->getModule()),
  431. );
  432. }
  433. }
  434. return $aResult;
  435. }
  436. public function serviceGetOptionsModuleListForPrivacySelector()
  437. {
  438. $aResult = array();
  439. $BxDolModuleQuery = BxDolModuleQuery::getInstance();
  440. $aModules = $BxDolModuleQuery->getModulesBy(array('type' => 'modules', 'active' => 1));
  441. foreach($aModules as $aModule){
  442. $oModule = BxDolModule::getInstance($aModule['name']);
  443. if($oModule instanceof iBxDolContentInfoService){
  444. if (!BxDolRequest::serviceExists($aModule['name'], 'act_as_profile'))
  445. continue;
  446. $aResult[$aModule['name']] = $aModule['title'];
  447. }
  448. }
  449. return $aResult;
  450. }
  451. public function serviceGetOptionsEmbedDefault()
  452. {
  453. $aResults = array(
  454. '' => _t('_None')
  455. );
  456. $aObjects = BxDolEmbedQuery::getObjects();
  457. foreach($aObjects as $aObject)
  458. $aResults[$aObject['object']] = $aObject['title'];
  459. return $aResults;
  460. }
  461. public function serviceGetOptionsLocationFieldDefault()
  462. {
  463. $aResults = array();
  464. $aObjects = BxDolLocationFieldQuery::getObjects();
  465. foreach($aObjects as $aObject)
  466. $aResults[$aObject['object']] = _t($aObject['title']);
  467. return $aResults;
  468. }
  469. public function serviceGetOptionsLocationMapDefault()
  470. {
  471. $aResults = array();
  472. $aObjects = BxDolLocationMapQuery::getObjects();
  473. foreach($aObjects as $aObject)
  474. $aResults[$aObject['object']] = _t($aObject['title']);
  475. return $aResults;
  476. }
  477. public function serviceGetOptionsLocationLeafletGetProviders()
  478. {
  479. return BxDolLocationMapLeaflet::getProviders();
  480. }
  481. public function serviceGetOptionsRelations()
  482. {
  483. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  484. $aProfiles = array();
  485. foreach($aModules as $aModule) {
  486. $sMethod = 'act_as_profile';
  487. if(!BxDolRequest::serviceExists($aModule['name'], $sMethod) || !BxDolService::call($aModule['name'], $sMethod))
  488. continue;
  489. $aProfiles[$aModule['name']] = _t('_' . $aModule['name']);
  490. }
  491. $aResults = array();
  492. foreach($aProfiles as $sName1 => $sTitle1)
  493. foreach($aProfiles as $sName2 => $sTitle2)
  494. $aResults[$sName1 . '_' . $sName2] = $sTitle1 . ' - ' . $sTitle2;
  495. return $aResults;
  496. }
  497. public function serviceGetBadge($aBadge, $bIsCompact = false)
  498. {
  499. $sClass = '';
  500. $sStyleFont = '';
  501. $sStyleBg = '';
  502. if ($aBadge['color'] == '')
  503. $aBadge['color'] = '#ff0000';
  504. if ($aBadge['fontcolor'] == '')
  505. $aBadge['fontcolor'] = '#ffffff';
  506. if ($bIsCompact){
  507. $aBadge['is_icon_only'] = 1;
  508. $sClass .= ' bx-badge-compact-to';
  509. $sStyleFont = 'color: ' . $aBadge['color'];
  510. }
  511. else{
  512. $sStyleBg = 'background-color: ' . $aBadge['color'] . '; color: ' . $aBadge['fontcolor'];
  513. }
  514. if ($aBadge['is_icon_only'] == 1){
  515. $sClass .= ' bx-badge-compact';
  516. }
  517. return BxDolTemplate::getInstance()->parseHtmlByName('badge.html', array(
  518. 'bx_if:content' => array(
  519. 'condition' => $aBadge['is_icon_only'] != '1',
  520. 'content' => array('content' => _t($aBadge['text'])),
  521. ),
  522. 'bx_if:icon' => array(
  523. 'condition' => $aBadge['icon'] != '',
  524. 'content' => array('content' => BxDolTemplate::getInstance()->getIcon($aBadge['icon'], array('class' => 'bx-badge-icon sys-colored', 'style' => $sStyleFont))),
  525. ),
  526. 'title' => $aBadge['text'],
  527. 'style_font' => $sStyleFont,
  528. 'style_bg' => $sStyleBg,
  529. 'class' => $sClass,
  530. )
  531. );
  532. }
  533. private function _getSearchObject()
  534. {
  535. $sClass = 'BxTemplSearch';
  536. $sElsName = 'bx_elasticsearch';
  537. $sElsMethod = 'is_configured';
  538. if(BxDolRequest::serviceExists($sElsName, $sElsMethod) && BxDolService::call($sElsName, $sElsMethod) && !bx_get('cat') && !bx_get('type')) {
  539. $oModule = BxDolModule::getInstance($sElsName);
  540. bx_import('Search', $oModule->_aModule);
  541. $sClass = 'BxElsSearch';
  542. }
  543. bx_alert('system', 'search_keyword', 0, 0, array('class' => &$sClass));
  544. $oSearch = new $sClass(bx_get('section'));
  545. $oSearch->setLiveSearch(bx_get('live_search') ? 1 : 0);
  546. $oSearch->setMetaType(bx_process_input(bx_get('type')));
  547. $oSearch->setCategoryObject(bx_process_input(bx_get('cat')));
  548. return $oSearch;
  549. }
  550. }
  551. /** @} */