BxBaseFunctions.php 22 KB

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