BxBaseFunctions.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  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. class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
  10. {
  11. protected $_oTemplate;
  12. protected $_sDesignBoxIcon = 'chevron';
  13. protected function __construct($oTemplate)
  14. {
  15. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  16. trigger_error ('Multiple instances are not allowed for the class: ' . get_class($this), E_USER_ERROR);
  17. parent::__construct();
  18. $this->_oTemplate = $oTemplate ? $oTemplate : BxDolTemplate::getInstance();
  19. }
  20. /**
  21. * Prevent cloning the instance
  22. */
  23. public function __clone()
  24. {
  25. if (isset($GLOBALS['bxDolClasses'][get_class($this)]))
  26. trigger_error('Clone is not allowed for the class: ' . get_class($this), E_USER_ERROR);
  27. }
  28. public static function getInstance($oTemplate = null)
  29. {
  30. if(!isset($GLOBALS['bxDolClasses']['BxTemplFunctions']))
  31. $GLOBALS['bxDolClasses']['BxTemplFunctions'] = new BxTemplFunctions($oTemplate);
  32. return $GLOBALS['bxDolClasses']['BxTemplFunctions'];
  33. }
  34. function TemplPageAddComponent($sKey)
  35. {
  36. switch( $sKey ) {
  37. case 'something':
  38. return false; // return here additional components
  39. default:
  40. return false; // if you have not such component, return false!
  41. }
  42. }
  43. function msgBox($sText, $iTimer = 0, $sOnClose = "")
  44. {
  45. $iId = time() . mt_rand(1, 1000);
  46. if($iTimer > 0)
  47. BxDolTemplate::getInstance()->addJs(array('jquery.anim.js'));
  48. return $this->_oTemplate->parseHtmlByName('messageBox.html', array(
  49. 'id' => $iId,
  50. 'msgText' => $sText,
  51. 'bx_if:timer' => array(
  52. 'condition' => $iTimer > 0,
  53. 'content' => array(
  54. 'id' => $iId,
  55. 'time' => 1000 * $iTimer,
  56. 'on_close' => $sOnClose,
  57. )
  58. )
  59. ));
  60. }
  61. /**
  62. * Get standard popup box with title.
  63. *
  64. * @param string $sName - unique name
  65. * @param string $sTitle - translated title
  66. * @param string $sContent - content of the box
  67. * @return HTML string
  68. */
  69. function popupBox($sName, $sTitle, $sContent, $isHiddenByDefault = false)
  70. {
  71. $iId = !empty($sName) ? $sName : time();
  72. return $this->_oTemplate->parseHtmlByName('popup_box.html', array(
  73. 'id' => $iId,
  74. 'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '',
  75. 'title' => $sTitle,
  76. 'content' => $sContent
  77. ));
  78. }
  79. /**
  80. * Get popup box without title.
  81. *
  82. * @param string $sName - unique name
  83. * @param string $sContent - content of the box
  84. * @return HTML string
  85. */
  86. function transBox($sName, $sContent, $isHiddenByDefault = false, $isPlaceInCenter = false)
  87. {
  88. return $this->simpleBox($sName, $sContent, $isHiddenByDefault, $isPlaceInCenter, 'popup_trans.html');
  89. }
  90. function slideBox($sName, $sContent, $isHiddenByDefault = false)
  91. {
  92. return $this->simpleBox($sName, $sContent, $isHiddenByDefault, false, 'popup_slide.html');
  93. }
  94. function inlineBox($sName, $sContent, $isHiddenByDefault = false)
  95. {
  96. return $this->simpleBox($sName, $sContent, $isHiddenByDefault, false, 'popup_inline.html');
  97. }
  98. protected function simpleBox($sName, $sContent, $isHiddenByDefault, $isPlaceInCenter, $sTemplate) {
  99. $iId = !empty($sName) ? $sName : time();
  100. $sContent = $this->_oTemplate->parseHtmlByName($sTemplate, array(
  101. 'id' => $iId,
  102. 'wrapper_style' => $isHiddenByDefault ? 'display:none;' : '',
  103. 'content' => $sContent
  104. ));
  105. if($isPlaceInCenter)
  106. $sContent = '<div class="login_ajax_wrap">' . $sContent . '</div>';
  107. return $sContent;
  108. }
  109. function getTemplateIcon($sName)
  110. {
  111. $sUrl = $this->_oTemplate->getIconUrl($sName);
  112. return !empty($sUrl) ? $sUrl : $this->_oTemplate->getIconUrl('spacer.gif');
  113. }
  114. function getTemplateImage($sName)
  115. {
  116. $sUrl = $this->_oTemplate->getImageUrl($sName);
  117. return !empty($sUrl) ? $sUrl : $this->_oTemplate->getImageUrl('spacer.gif');
  118. }
  119. function sysIcon ($sIcon, $sName, $sUrl = '', $iWidth = 0)
  120. {
  121. return '<div class="sys_icon">' . ($sUrl ? '<a title="'.$sName.'" href="'.$sUrl.'">' : '') . '<img alt="'.$sName.'" src="'.$sIcon.'" '.($iWidth ? 'width='.$iWidth : '').' />' . ($sUrl ? '</a>' : '') . '</div>';
  122. }
  123. /**
  124. * functions for limiting maximal string length
  125. */
  126. function getStringWithLimitedLength($sString, $iWidth = 45, $isPopupOnOverflow = false, $bReturnString = true)
  127. {
  128. if (empty($sString) || mb_strlen($sString, 'UTF-8') <= $iWidth)
  129. return $bReturnString ? $sString : array($sString);
  130. $sResult = '';
  131. $aWords = mb_split("[\s\r\n]", $sString);
  132. $iPosition = 0;
  133. $iWidthReal = $iWidth - 3;
  134. $iWidthMin = $iWidth - 15;
  135. foreach($aWords as $sWord) {
  136. $sWord = trim($sWord);
  137. $iWord = mb_strlen($sWord, 'UTF-8');
  138. if ($iPosition + $iWord > $iWidthReal)
  139. break;
  140. // add word and continue
  141. $sResult .= ' ' . $sWord;
  142. $iPosition += 1 + $iWord;
  143. }
  144. // last word is too long, cut it
  145. if(!$iPosition || $iPosition < $iWidthMin)
  146. $sResult .= ' ' . mb_substr($sWord, 0, $iWidthReal - $iPosition - $iWord, 'UTF-8');
  147. $sResult = trim($sResult);
  148. // add tripple dot
  149. if(!$isPopupOnOverflow) {
  150. $sResult .= '...';
  151. return $bReturnString ? $sResult : array($sResult);
  152. }
  153. // add button width popup
  154. $sId = 'bx-str-limit-' . rand(1, PHP_INT_MAX);
  155. $sPopup = '<img class="bx-str-limit" onclick="$(\'#' . $sId . '\').dolPopup({pointer:{el:$(this), offset:\'10 1\'}})" src="' . $this->getTemplateImage('str-limit.png') . '"/>';
  156. $sPopup .= '<div id="' . $sId . '" style="display:none;">' . BxTemplFunctions::getInstance()->transBox('', '<div class="bx-def-padding bx-def-color-bg-block">'.$sString.'</div>') . '</div>';
  157. return $bReturnString ? $sResult . $sPopup : array($sResult, $sPopup);
  158. }
  159. /**
  160. * Display design box with specified title, template, content and menu.
  161. * @param $sTitle - design box title, please note that some templates don't use title.
  162. * @param $sContent - design box content.
  163. * @param $iTemplateNum - number of design box template, use predefined contants only, default is BX_DB_DEF.
  164. * @param $mixedMenu - design box menu, it can be:
  165. * - object: instance of BxTemplMenu class
  166. * - string: menu object identifier
  167. * - array: array of menu links to create menu from
  168. * @return string
  169. *
  170. * @see BX_DB_CONTENT_ONLY
  171. * @see BX_DB_DEF
  172. * @see BX_DB_EMPTY
  173. * @see BX_DB_NO_CAPTION
  174. * @see BX_DB_PADDING_CONTENT_ONLY
  175. * @see BX_DB_PADDING_DEF
  176. * @see BX_DB_PADDING_NO_CAPTION
  177. */
  178. function designBoxContent ($sTitle, $sContent, $iTemplateNum = BX_DB_DEF, $mixedMenu = false)
  179. {
  180. return $this->_oTemplate->parseHtmlByName('designbox_' . (int)$iTemplateNum . '.html', array(
  181. 'title' => $sTitle,
  182. 'designbox_content' => $sContent,
  183. 'caption_item' => $this->designBoxMenu ($mixedMenu, array (array('menu' => 1))),
  184. ));
  185. }
  186. function designBoxMenu ($mixedMenu, $aButtons = array ())
  187. {
  188. $sCode = '';
  189. $aButtonMenu = false;
  190. if ($mixedMenu) {
  191. $sMenu = '';
  192. if (is_string($mixedMenu)) {
  193. $oMenu = BxTemplMenu::getObjectInstance($mixedMenu);
  194. $sMenu = $oMenu ? $oMenu->getCode () : $mixedMenu;
  195. } elseif (is_object($mixedMenu) && is_a($mixedMenu, 'BxTemplMenu')) {
  196. $sMenu = $mixedMenu->getCode();
  197. } elseif (is_array($mixedMenu)) {
  198. if (isset($mixedMenu['template']) && isset($mixedMenu['menu_items']))
  199. $aMenu = $mixedMenu;
  200. else
  201. $aMenu = array ('template' => 'menu_vertical.html', 'menu_items' => $mixedMenu);
  202. $oMenu = new BxTemplMenu($aMenu, $this->_oTemplate);
  203. $sMenu = $oMenu->getCode ();
  204. }
  205. if ($sMenu) {
  206. $sId = 'bx-menu-db-' . time() . rand(0, PHP_INT_MAX);
  207. $sCode .= $this->slideBox($sId, $sMenu, true);
  208. $aButtonMenu = array ('icon-a' => $this->_sDesignBoxIcon, 'onclick' => "bx_menu_slide('#" . $sId . "', this)");
  209. }
  210. }
  211. if ($aButtons) {
  212. $sCode .= '<div class="bx-db-menu"><div class="bx-db-menu-tab bx-db-menu-tab-btn">';
  213. foreach ($aButtons as $aButton) {
  214. if (isset($aButton['menu']) && $aButton['menu']) {
  215. if (!$aButtonMenu)
  216. continue;
  217. $aButton = $aButtonMenu;
  218. }
  219. $aAttrs = array ();
  220. if (!empty($aButton['onclick']))
  221. $aAttrs['onclick'] = $aButton['onclick'];
  222. if (!empty($aButton['class']))
  223. $aAttrs['class'] = $aButton['class'];
  224. $sAttrs = bx_convert_array2attrs ($aAttrs, 'bx-def-margin-sec-left');
  225. $sCode .= '<a href="javascript:void(0);" ' . $sAttrs . '>';
  226. $sCode .= !empty($aButton['icon']) ? '<i class="sys-icon ' . $aButton['icon'] . ' bx-def-font-h2"></i>' : '';
  227. $sCode .= !empty($aButton['icon-a']) ? '<i class="sys-icon-a" data-rotate="down" data-icon="' . $aButton['icon-a'] . '"></i>' : '';
  228. $sCode .= !empty($aButton['title']) ? $aButton['title'] : '';
  229. $sCode .= '</a>';
  230. }
  231. $sCode .= '</div></div>';
  232. }
  233. return $sCode;
  234. }
  235. /**
  236. * Get logo URL.
  237. * @return string
  238. */
  239. function getMainLogoUrl()
  240. {
  241. $oDesigns = BxDolDesigns::getInstance();
  242. $iFileId = (int)$oDesigns->getSiteLogo();
  243. if (!$iFileId)
  244. return false;
  245. $oStorage = BxDolTranscoder::getObjectInstance('sys_custom_images');
  246. $sFileUrl = $oStorage->getFileUrl($iFileId);
  247. if (!$sFileUrl)
  248. return false;
  249. $iLogoWidth = (int)$oDesigns->getSiteLogoWidth();
  250. if($iLogoWidth > 0)
  251. $sFileUrl = bx_append_url_params($sFileUrl, array('x' => $iLogoWidth));
  252. $iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
  253. if($iLogoHeight > 0)
  254. $sFileUrl = bx_append_url_params($sFileUrl, array('y' => $iLogoHeight));
  255. return $sFileUrl;
  256. }
  257. /**
  258. * Get logo HTML.
  259. * @return string
  260. */
  261. function getMainLogo()
  262. {
  263. $oDesigns = BxDolDesigns::getInstance();
  264. $sAlt = $oDesigns->getSiteLogoAlt();
  265. if(empty($sAlt))
  266. $sAlt = getParam('site_title');
  267. $sLogo = '<span>' . $sAlt . '</span>';
  268. $sFileUrl = $this->getMainLogoUrl();
  269. if (!empty($sFileUrl)) {
  270. $iLogoWidth = (int)$oDesigns->getSiteLogoWidth();
  271. $sMaxWidth = $iLogoWidth > 0 ? 'max-width:' . round($iLogoWidth/16, 3) . 'rem;' : '';
  272. $iLogoHeight = (int)$oDesigns->getSiteLogoHeight();
  273. $sMaxHeight = $iLogoHeight > 0 ? 'max-height:' . round($iLogoHeight/16, 3) . 'rem;' : '';
  274. $sLogo = '<img style="' . $sMaxWidth . $sMaxHeight . '" src="' . $sFileUrl . '" id="bx-logo" alt="' . bx_html_attribute($sAlt, BX_ESCAPE_STR_QUOTE) . '" />';
  275. }
  276. return '<a class="bx-def-font-contrasted" href="' . BX_DOL_URL_ROOT . '" title="' . bx_html_attribute($sAlt, BX_ESCAPE_STR_QUOTE) . '">' . $sLogo . '</a>';
  277. }
  278. /**
  279. * Get HTML code for manifests.
  280. * @return HTML string to insert into HEAD section
  281. */
  282. function getManifests()
  283. {
  284. $sRet = '';
  285. $bLogged = isLogged();
  286. /*
  287. * OneSignal manifest must appear before any other <link rel="manifest" ...> in <head>
  288. */
  289. $sPushAppId = getParam('sys_push_app_id');
  290. if($bLogged && !empty($sPushAppId)) {
  291. $aUrlRoot = parse_url(BX_DOL_URL_ROOT);
  292. $sUrl = BX_DOL_URL_PLUGINS_PUBLIC . 'onesignal/manifest.json.php';
  293. $sUrl = bx_append_url_params($sUrl, array('bx_name' => $aUrlRoot['host']));
  294. $sRet .= '<link rel="manifest" href="' . $sUrl . '" />';
  295. }
  296. return $sRet;
  297. }
  298. /**
  299. * Get HTML code for meta icons.
  300. * @return HTML string to insert into HEAD section
  301. */
  302. function getMetaIcons()
  303. {
  304. $iId = (int)getParam('sys_site_icon');
  305. $sImageUrlFav = $sImageUrlFcb = $sImageUrlApl = '';
  306. if(!empty($iId)) {
  307. // favicon icon
  308. $oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_FAVICON);
  309. $sImageUrlFav = $oTranscoder->getFileUrl($iId);
  310. // facebook icon
  311. $oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_FACEBOOK);
  312. $sImageUrlFcb = $oTranscoder->getFileUrl($iId);
  313. // apple touch icon
  314. $oTranscoder = BxDolTranscoderImage::getObjectInstance(BX_DOL_TRANSCODER_OBJ_ICON_APPLE);
  315. $sImageUrlApl = $oTranscoder->getFileUrl($iId);
  316. }
  317. if(empty($sImageUrlFav))
  318. $sImageUrlFav = $this->_oTemplate->getIconUrl('favicon.png');
  319. if(empty($sImageUrlFcb))
  320. $sImageUrlFcb = $this->_oTemplate->getIconUrl('facebook-icon.png');
  321. if(empty($sImageUrlApl))
  322. $sImageUrlApl = $this->_oTemplate->getIconUrl('apple-touch-icon.png');
  323. $sRet = '';
  324. $sRet .= '<link rel="shortcut icon" type="image/x-icon" href="' . $sImageUrlFav . '" />';
  325. $sRet .= '<link rel="image_src" sizes="100x100" href="' . $sImageUrlFcb . '" />';
  326. $sRet .= '<link rel="apple-touch-icon" sizes="152x152" href="' . $sImageUrlApl . '" />';
  327. return $sRet;
  328. }
  329. function getInjectionHead()
  330. {
  331. return $this->getInjection('getInjHead');
  332. }
  333. function getInjectionHeader()
  334. {
  335. return $this->getInjection('getInjHeader');
  336. }
  337. function getInjectionFooter()
  338. {
  339. return $this->getInjection('getInjFooter');
  340. }
  341. public function getPopupAlert()
  342. {
  343. return $this->transBox('bx-popup-alert', $this->_oTemplate->parseHtmlByName('popup_trans_alert_cnt.html', array()), true);
  344. }
  345. public function getPopupConfirm()
  346. {
  347. return $this->transBox('bx-popup-confirm', $this->_oTemplate->parseHtmlByName('popup_trans_confirm_cnt.html', array()), true);
  348. }
  349. public function getPopupPrompt()
  350. {
  351. $sInputText = 'bx-popup-prompt-value';
  352. $aInputText = array(
  353. 'type' => 'text',
  354. 'name' => $sInputText,
  355. 'attrs' => array(
  356. 'id' => $sInputText,
  357. ),
  358. 'value' => '',
  359. 'caption' => ''
  360. );
  361. $oForm = new BxTemplFormView(array(), $this->_oTemplate);
  362. return $this->transBox('bx-popup-prompt', $this->_oTemplate->parseHtmlByName('popup_trans_prompt_cnt.html', array(
  363. 'input' => $oForm->genRow($aInputText)
  364. )), true);
  365. }
  366. /**
  367. * Output time wrapped in <time> tag in HTML.
  368. * Then time is autoformatted using JS upon page load, this is aumatically converted to user's timezone and
  369. * updated in realtime in case of short periods of 'from now' time format.
  370. *
  371. * Short version of this function:
  372. * @see bx_time_js
  373. *
  374. * @param $iUnixTimestamp time as unixtimestamp
  375. * @param $sFormatIdentifier output format identifier
  376. * @see BX_FORMAT_DATE
  377. * @see BX_FORMAT_TIME
  378. * @see BX_FORMAT_DATE_TIME
  379. * @param $bForceFormat force provided format and don't use "from now" time autoformat.
  380. */
  381. function timeForJs ($iUnixTimestamp, $sFormatIdentifier = BX_FORMAT_DATE, $bForceFormat = false)
  382. {
  383. $sDateUTC = bx_time_utc ($iUnixTimestamp);
  384. return $this->timeForJsFullDate ($sDateUTC, $sFormatIdentifier, $bForceFormat);
  385. }
  386. /**
  387. * Same as @see timeForJs but instead of unxtimestamp full date format is used (ex: 2005-08-15T15:52:01) as passec date param
  388. */
  389. function timeForJsFullDate ($sDateUTC, $sFormatIdentifier = BX_FORMAT_DATE, $bForceFormat = false)
  390. {
  391. return '<time datetime="' . $sDateUTC . '" data-bx-format="' . getParam($sFormatIdentifier) . '" data-bx-autoformat="' . ($bForceFormat ? 0 : getParam('sys_format_timeago')) . '">' . $sDateUTC . '</time>';
  392. }
  393. function statusOnOff ($mixed, $isMsg = false)
  394. {
  395. if ((is_bool($mixed) && !$mixed) || (is_string($mixed) && 'fail' == $mixed))
  396. return '<i class="sys-icon circle col-red2"></i> ' . ($isMsg ? _t('_sys_off') : '');
  397. elseif (is_string($mixed) && 'warn' == $mixed)
  398. return '<i class="sys-icon circle col-red3"></i> ' . ($isMsg ? _t('_sys_warn') : '');
  399. elseif (is_string($mixed) && 'undef' == $mixed)
  400. return '<i class="sys-icon circle col-gray"></i> ' . ($isMsg ? _t('_undefined') : '');
  401. else
  402. return '<i class="sys-icon circle col-green1"></i> ' . ($isMsg ? _t('_sys_on') : '');
  403. }
  404. /**
  405. * Ouputs HTML5 video player.
  406. * @param $sUrlPoster video poster image
  407. * @param $sUrlMP4 .mp4 video
  408. * @param $sUrlWebM .webm video
  409. * @param $aAttrs custom attributes, defaults are: controls="" preload="none" autobuffer=""
  410. * @param $sStyles custom styles, defaults are: width:100%; height:auto;
  411. */
  412. function videoPlayer ($sUrlPoster, $sUrlMP4, $sUrlWebM = '', $aAttrs = false, $sStyles = 'width:100%; height:auto;')
  413. {
  414. $aAttrsDefaults = array(
  415. 'controls' => '',
  416. 'preload' => 'none',
  417. 'autobuffer' => '',
  418. );
  419. $aAttrs = array_merge($aAttrsDefaults, is_array($aAttrs) ? $aAttrs : array());
  420. $sAttrs = bx_convert_array2attrs($aAttrs, '', $sStyles);
  421. return '<video ' . $sAttrs . ' poster="' . $sUrlPoster . '">
  422. ' . ($sUrlWebM ? '<source type="video/webm; codecs="vp8, vorbis" src="' . $sUrlWebM . '" />' : '') . '
  423. ' . ($sUrlMP4 ? '<source type="video/mp4" src="' . $sUrlMP4 . '" />' : '') . '
  424. </video>';
  425. }
  426. protected function getInjection($sPrefix)
  427. {
  428. $sContent = '';
  429. $aMethods = get_class_methods($this);
  430. foreach($aMethods as $sMethod)
  431. if(substr($sMethod, 0, strlen($sPrefix)) == $sPrefix)
  432. $sContent .= $this->$sMethod();
  433. return $sContent;
  434. }
  435. protected function getInjHeadLiveUpdates()
  436. {
  437. return BxDolLiveUpdates::getInstance()->init();
  438. }
  439. protected function getInjHeaderPushNotifications()
  440. {
  441. $iProfileId = bx_get_logged_profile_id();
  442. if(empty($iProfileId))
  443. return '';
  444. $sAppId = getParam('sys_push_app_id');
  445. if(empty($sAppId))
  446. return '';
  447. $sShortName = getParam('sys_push_short_name');
  448. $sSafariWebId = getParam('sys_push_safari_id');
  449. $sSubfolder = '/plugins_public/onesignal/';
  450. $aUrl = parse_url(BX_DOL_URL_ROOT);
  451. if(!empty($aUrl['path'])) {
  452. $sPath = trim($aUrl['path'], '/');
  453. if(!empty($sPath))
  454. $sSubfolder = '/' . $sPath . $sSubfolder;
  455. }
  456. $this->_oTemplate->addJs(array(
  457. 'https://cdn.onesignal.com/sdks/OneSignalSDK.js',
  458. 'BxDolPush.js',
  459. ));
  460. $sJsClass = 'BxDolPush';
  461. $sJsObject = 'oBxDolPush';
  462. $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode(array(
  463. 'sObjName' => $sJsObject,
  464. 'sSiteName' => getParam('site_title'),
  465. 'iProfileId' => $iProfileId,
  466. 'sAppId' => $sAppId,
  467. 'sShortName' => $sShortName,
  468. 'sSafariWebId' => $sSafariWebId,
  469. 'sSubfolder' => $sSubfolder,
  470. 'sNotificationUrl' => BX_DOL_URL_ROOT,
  471. 'sTxtNotificationRequest' => bx_js_string(_t('_sys_push_notification_request', getParam('site_title'))),
  472. 'sTxtNotificationRequestYes' => bx_js_string(_t('_sys_push_notification_request_yes')),
  473. 'sTxtNotificationRequestNo' => bx_js_string(_t('_sys_push_notification_request_no')),
  474. )) . ");";
  475. return $this->_oTemplate->_wrapInTagJsCode($sContent);
  476. }
  477. protected function getInjFooterPopupLoading()
  478. {
  479. return $this->transBox('bx-popup-loading', $this->_oTemplate->parsePageByName('popup_loading.html', array()), true);
  480. }
  481. protected function getInjFooterPopupMenus()
  482. {
  483. $sContent = '';
  484. $oSearch = new BxTemplSearch();
  485. $oSearch->setLiveSearch(true);
  486. $sContent .= $this->_oTemplate->parsePageByName('search.html', array(
  487. 'search_form' => $oSearch->getForm(BX_DB_CONTENT_ONLY),
  488. 'results' => $oSearch->getResultsContainer(),
  489. ));
  490. $sContent .= $this->_oTemplate->getMenu ('sys_site');
  491. if(isLogged()) {
  492. $sContent .= $this->_oTemplate->getMenu ('sys_add_content');
  493. $sContent .= $this->_oTemplate->getMenu ('sys_account_popup');
  494. }
  495. return $sContent;
  496. }
  497. protected function getInjFooterPopups()
  498. {
  499. $sContent = '';
  500. $sContent .= $this->getPopupAlert();
  501. $sContent .= $this->getPopupConfirm();
  502. $sContent .= $this->getPopupPrompt();
  503. return $sContent;
  504. }
  505. protected function getInjFooterEmbed()
  506. {
  507. // Load embed files
  508. $oEmbed = BxDolEmbed::getObjectInstance(false);
  509. if ($oEmbed)
  510. return $oEmbed->addJsCss();
  511. return '';
  512. }
  513. }
  514. /** @} */