AntonLV 8 лет назад
Родитель
Сommit
54a3fdc0cb

+ 3 - 3
inc/classes/BxDolTemplate.php

@@ -1303,13 +1303,13 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
                 if(isset($this->aPage['header_text']))
                     $sRet = bx_process_output($this->aPage['header_text']);
                 break;
-            case 'injection_head':
+            case 'system_injection_head':
                 $sRet = $this->_oTemplateFunctions->getInjectionHead();
                 break;
-            case 'injection_header':
+            case 'system_injection_header':
                 $sRet = $this->_oTemplateFunctions->getInjectionHeader();
                 break;
-            case 'injection_footer':
+            case 'system_injection_footer':
                 $sRet = $this->_oTemplateFunctions->getInjectionFooter();
                 break;
             case 'lang':

+ 0 - 10
install/sql/system.sql

@@ -1208,12 +1208,7 @@ CREATE TABLE `sys_injections` (
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
 INSERT INTO `sys_injections`(`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES
-('sys_popup_alert', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"add_popup_alert";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
-('sys_popup_confirm', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:17:"add_popup_confirm";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
-('sys_popup_prompt', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:16:"add_popup_prompt";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
-('sys_push_init', 0, 'injection_header', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:13:"add_push_init";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
 ('update_cache', 150, 'injection_head', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:17:"get_cache_updater";s:6:"params";a:0:{}s:5:"class";s:19:"TemplStudioLauncher";}', 0, 1),
-('live_updates', 0, 'injection_head', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:4:"init";s:6:"params";a:0:{}s:5:"class";s:24:"TemplLiveUpdatesServices";}', 0, 1),
 ('sys_head', 0, 'injection_head', 'text', '', 0, 1),
 ('sys_body', 0, 'injection_footer', 'text', '', 0, 1);
 
@@ -1232,11 +1227,6 @@ CREATE TABLE `sys_injections_admin` (
   PRIMARY KEY (`id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
-INSERT INTO `sys_injections_admin`(`name`, `page_index`, `key`, `type`, `data`, `replace`, `active`) VALUES
-('sys_popup_alert', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:15:"add_popup_alert";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
-('sys_popup_confirm', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:17:"add_popup_confirm";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1),
-('sys_popup_prompt', 0, 'injection_footer', 'service', 'a:4:{s:6:"module";s:6:"system";s:6:"method";s:16:"add_popup_prompt";s:6:"params";a:0:{}s:5:"class";s:13:"TemplServices";}', 0, 1);
-
 -- --------------------------------------------------------
 
 

+ 91 - 0
template/scripts/BxBaseFunctions.php

@@ -416,6 +416,35 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         return $this->getInjection('getInjFooter');
     }
 
+    public function getPopupAlert()
+    {
+        return $this->transBox('bx-popup-alert', $this->_oTemplate->parseHtmlByName('popup_trans_alert_cnt.html', array()), true);
+    }
+
+    public function getPopupConfirm()
+    {
+        return $this->transBox('bx-popup-confirm', $this->_oTemplate->parseHtmlByName('popup_trans_confirm_cnt.html', array()), true);
+    }
+
+    public function getPopupPrompt()
+    {
+        $sInputText = 'bx-popup-prompt-value';
+        $aInputText = array(
+            'type' => 'text',
+            'name' => $sInputText,
+            'attrs' => array(
+                'id' => $sInputText,
+            ),
+            'value' => '',
+            'caption' => ''
+        );
+
+        $oForm = new BxTemplFormView(array(), $this->_oTemplate);
+        return $this->transBox('bx-popup-prompt', $this->_oTemplate->parseHtmlByName('popup_trans_prompt_cnt.html', array(
+            'input' => $oForm->genRow($aInputText)
+        )), true);
+    }
+
     /**
      * Output time wrapped in <time> tag in HTML.
      * Then time is autoformatted using JS upon page load, this is aumatically converted to user's timezone and
@@ -493,6 +522,57 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
         return $sContent;
     }
 
+    protected function getInjHeadLiveUpdates() 
+    {
+        return BxDolLiveUpdates::getInstance()->init();
+    }
+
+    protected function getInjHeaderPushNotifications() 
+    {
+        $iProfileId = bx_get_logged_profile_id();
+        if(empty($iProfileId))
+            return '';
+
+        $sAppId = getParam('sys_push_app_id');
+        if(empty($sAppId))
+            return '';
+
+        $sShortName = getParam('sys_push_short_name');
+        $sSafariWebId = getParam('sys_push_safari_id');
+
+        $sSubfolder = '/plugins_public/onesignal/';
+        $aUrl = parse_url(BX_DOL_URL_ROOT);
+        if(!empty($aUrl['path'])) {
+            $sPath = trim($aUrl['path'], '/');
+            if(!empty($sPath))
+                $sSubfolder = '/' . $sPath . $sSubfolder;
+        }
+
+        $this->_oTemplate->addJs(array(
+            'https://cdn.onesignal.com/sdks/OneSignalSDK.js',
+            'BxDolPush.js',
+        ));
+
+        $sJsClass = 'BxDolPush';
+        $sJsObject = 'oBxDolPush';
+
+        $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode(array(
+            'sObjName' => $sJsObject,
+            'sSiteName' => getParam('site_title'),
+            'iProfileId' => $iProfileId,
+            'sAppId' => $sAppId,
+            'sShortName' => $sShortName,
+            'sSafariWebId' => $sSafariWebId,
+            'sSubfolder' => $sSubfolder,
+            'sNotificationUrl' => BX_DOL_URL_ROOT,
+            'sTxtNotificationRequest' => bx_js_string(_t('_sys_push_notification_request', getParam('site_title'))),
+            'sTxtNotificationRequestYes' => bx_js_string(_t('_sys_push_notification_request_yes')),
+            'sTxtNotificationRequestNo' => bx_js_string(_t('_sys_push_notification_request_no')),
+        )) . ");";
+
+        return $this->_oTemplate->_wrapInTagJsCode($sContent);
+    }
+
     protected function getInjFooterPopupLoading() 
     {
         return $this->transBox('bx-popup-loading', $this->_oTemplate->parsePageByName('popup_loading.html', array()), true);  
@@ -517,6 +597,17 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
 
         return $sContent;
     }
+
+    protected function getInjFooterPopups() 
+    {
+        $sContent = '';
+
+        $sContent .= $this->getPopupAlert();
+        $sContent .= $this->getPopupConfirm();
+        $sContent .= $this->getPopupPrompt();
+
+        return $sContent;
+    }
 }
 
 /** @} */

+ 0 - 79
template/scripts/BxBaseServices.php

@@ -140,85 +140,6 @@ class BxBaseServices extends BxDol implements iBxDolProfileService
         BxDolTemplate::getInstance()->addCss(BX_DIRECTORY_PATH_PLUGINS_PUBLIC . 'cubiq-add-to-homescreen/style/|addtohomescreen.css');
         return "<script>addToHomescreen();</script>";
     }
-
-    public function serviceAddPopupAlert()
-    {
-        return BxTemplFunctions::getInstance()->transBox('bx-popup-alert', BxDolTemplate::getInstance()->parseHtmlByName('popup_trans_alert_cnt.html', array()), true);
-    }
-
-    public function serviceAddPopupConfirm()
-    {
-        return BxTemplFunctions::getInstance()->transBox('bx-popup-confirm', BxDolTemplate::getInstance()->parseHtmlByName('popup_trans_confirm_cnt.html', array()), true);
-    }
-
-    public function serviceAddPopupPrompt()
-    {
-        $oTemplate = BxDolTemplate::getInstance();
-
-        $sInputText = 'bx-popup-prompt-value';
-        $aInputText = array(
-            'type' => 'text',
-            'name' => $sInputText,
-            'attrs' => array(
-                'id' => $sInputText,
-            ),
-            'value' => '',
-            'caption' => ''
-        );
-
-        $oForm = new BxTemplFormView(array(), $oTemplate);
-        return BxTemplFunctions::getInstance()->transBox('bx-popup-prompt', $oTemplate->parseHtmlByName('popup_trans_prompt_cnt.html', array(
-            'input' => $oForm->genRow($aInputText)
-        )), true);
-    }
-
-    public function serviceAddPushInit($iProfileId = 0)
-    {
-        $iProfileId = !empty($iProfileId) ? $iProfileId : bx_get_logged_profile_id();
-        if(empty($iProfileId))
-            return '';
-
-        $sAppId = getParam('sys_push_app_id');
-        if(empty($sAppId))
-            return '';
-
-        $oTemplate = BxDolTemplate::getInstance();
-
-        $sShortName = getParam('sys_push_short_name');
-        $sSafariWebId = getParam('sys_push_safari_id');
-
-        $sSubfolder = '/plugins_public/onesignal/';
-        $aUrl = parse_url(BX_DOL_URL_ROOT);
-        if(!empty($aUrl['path'])) {
-            $sPath = trim($aUrl['path'], '/');
-            if(!empty($sPath))
-                $sSubfolder = '/' . $sPath . $sSubfolder;
-        }
-
-        $oTemplate->addJs(array(
-            'https://cdn.onesignal.com/sdks/OneSignalSDK.js',
-            'BxDolPush.js',
-        ));
-
-        $sJsClass = 'BxDolPush';
-        $sJsObject = 'oBxDolPush';
-
-        $sContent = "var " . $sJsObject . " = new " . $sJsClass . "(" . json_encode(array(
-            'sObjName' => $sJsObject,
-            'sSiteName' => getParam('site_title'),
-            'iProfileId' => $iProfileId,
-            'sAppId' => $sAppId,
-            'sShortName' => $sShortName,
-            'sSafariWebId' => $sSafariWebId,
-            'sSubfolder' => $sSubfolder,
-            'sNotificationUrl' => BX_DOL_URL_ROOT,
-            'sTxtNotificationRequest' => bx_js_string(_t('_sys_push_notification_request', getParam('site_title'))),
-            'sTxtNotificationRequestYes' => bx_js_string(_t('_sys_push_notification_request_yes')),
-            'sTxtNotificationRequestNo' => bx_js_string(_t('_sys_push_notification_request_no')),
-        )) . ");";
-
-        return $oTemplate->_wrapInTagJsCode($sContent);
-    }
 }
 
 /** @} */