Kaynağa Gözat

#3392 Nexus: main menu selector

Alex Trofimov 5 yıl önce
ebeveyn
işleme
81bdd74065

+ 7 - 0
inc/classes/BxDolMenuQuery.php

@@ -34,6 +34,13 @@ class BxDolMenuQuery extends BxDolDb
         return $aObject;
     }
 
+    static public function getMenuObjects($bActive = true, $bFromCache = true)
+    {
+        $oDb = BxDolDb::getInstance();
+        $sSql = $oDb->prepare("SELECT `sys_objects_menu`.`title`, `object`, `module`, `uri` FROM `sys_objects_menu` INNER JOIN `sys_modules` ON (`sys_modules`.`name` = `sys_objects_menu`.`module`) WHERE `active` = ? ORDER BY FIELD(`module`, 'system') DESC, `module` ASC, `object` ASC", $bActive ? 1 : 0);
+        return $bFromCache ? $oDb->fromMemory('sys_menus', 'getAll', $sSql) : $oDb->getAll($sSql);
+    }
+
     static public function getMenuTriggers($sTriggerName)
     {
         $oDb = BxDolDb::getInstance();

+ 2 - 2
inc/classes/BxDolModule.php

@@ -111,13 +111,13 @@ class BxDolModule extends BxDol
     }
 
     public static function getTitle($sUri)
-    {
+    {   
         return _t(self::getTitleKey($sUri));
     }
 
     public static function getTitleKey($sUri)
     {
-        return '_sys_module_' . strtolower(str_replace(' ', '_', $sUri));
+        return 'system' == $sUri ? '_adm_txt_module_system' : '_sys_module_' . strtolower(str_replace(' ', '_', $sUri));
     }
 
 	/**

+ 12 - 0
modules/boonex/nexus/classes/BxNexusModule.php

@@ -64,6 +64,7 @@ class BxNexusModule extends BxDolModule
             'txt_pull_to_refresh' => bx_js_string(_t('_bx_nexus_pull_to_refresh')),
             'txt_release_to_refresh' => bx_js_string(_t('_bx_nexus_release_to_refresh')),
             'txt_refreshing' => bx_js_string(_t('_bx_nexus_refreshing')),
+            'main_menu' => getParam('bx_nexus_option_main_menu'),
         ));
 
         //  TODO: enable it back when it will work correctly on Android
@@ -76,6 +77,17 @@ class BxNexusModule extends BxDolModule
         return $s;
     }
 
+    public function serviceGetMenusList()
+    {
+        $a = BxDolMenuQuery::getMenuObjects();
+        array_unshift($a, array('object' => 'default', 'title' => '_sys_page_type_default', 'module' => '', 'uri' => ''));
+        $aRes = array();
+        foreach($a as $r) {
+            $aRes[] = array('key' => $r['object'], 'value' => $r['uri'] ? _t('_bx_nexus_option_main_menu_value', BxDolModule::getTitle($r['uri']), _t($r['title'])) : _t($r['title']));
+        }
+        return $aRes;
+    }
+
     protected function redirects()
     {
         $bLoggedIn = isLogged() ? 1 : 0;

+ 2 - 0
modules/boonex/nexus/install/langs/en.xml

@@ -9,6 +9,8 @@
     <string name="_bx_nexus_option_styles"><![CDATA[Custom CSS styles for mobile apps]]></string>
     <string name="_bx_nexus_option_guest_pages"><![CDATA[Comma separated list of pages URIs, which are avalilable for guests]]></string>
     <string name="_bx_nexus_option_custom_homepage"><![CDATA[Display custom homepage with login form only]]></string>
+    <string name="_bx_nexus_option_main_menu"><![CDATA[Main menu]]></string>
+    <string name="_bx_nexus_option_main_menu_value"><![CDATA[{0}: {1}]]></string>
 
 	<string name="_bx_nexus_information"><![CDATA[Information]]></string>
     <string name="_bx_nexus_information_block"><![CDATA[This module adds neccesary styles and functionalty for proper functionality of UNA Nexus apps. Installing this module isn't enough, you need to get source code of mobile apps then modify them for your needs then publish in Google and Apple stores.]]></string>

+ 2 - 1
modules/boonex/nexus/install/sql/enable.sql

@@ -13,7 +13,8 @@ SET @iCategId = LAST_INSERT_ID();
 INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `extra`, `check`, `check_error`, `order`) VALUES
 ('bx_nexus_option_styles', '', @iCategId, '_bx_nexus_option_styles', 'text', '', '', '', 10),
 ('bx_nexus_option_guest_pages', 'forgot-password,create-account,terms,privacy,contact,about,home', @iCategId, '_bx_nexus_option_guest_pages', 'text', '', '', '', 20),
-('bx_nexus_option_custom_homepage', 'on', @iCategId, '_bx_nexus_option_custom_homepage', 'checkbox', '', '', '', 30);
+('bx_nexus_option_custom_homepage', 'on', @iCategId, '_bx_nexus_option_custom_homepage', 'checkbox', '', '', '', 30),
+('bx_nexus_option_main_menu', 'default', @iCategId, '_bx_nexus_option_main_menu', 'select', 'a:3:{s:6:"module";s:8:"bx_nexus";s:6:"method";s:14:"get_menus_list";s:6:"params";a:0:{}}', '', '', 40);
 
 -- Injections
 

+ 11 - 6
modules/boonex/nexus/template/js.html

@@ -1,11 +1,16 @@
 <script>
     function bx_mobile_apps_show_main_menu () {
-        if ($('.cd-dropdown-trigger').size())
-            $('.cd-dropdown-trigger').click();
-        else if ($('.cd-side-nav').size())
-            $([$('.cd-side-nav'), $('.cd-nav-trigger')]).toggleClass('nav-is-visible');
-        else
-            bx_menu_slide_inline('#bx-sliding-menu-sys_site', null, 'site');
+        if ('__main_menu__' == 'default') {
+            if ($('.cd-dropdown-trigger').size())
+                $('.cd-dropdown-trigger').click();
+            else if ($('.cd-side-nav').size())
+                $([$('.cd-side-nav'), $('.cd-nav-trigger')]).toggleClass('nav-is-visible');
+            else
+                bx_menu_slide_inline('#bx-sliding-menu-sys_site', null, 'site');
+        }
+        else {
+            bx_menu_popup('__main_menu__');
+        }
     }
 
     function bx_mobile_apps_show_profile_menu () {