AntonLV 1 год назад
Родитель
Сommit
51bbbf469b

+ 51 - 0
modules/boonex/developer/updates/14.0.5_14.0.6/install/config.php

@@ -0,0 +1,51 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'title' => 'Developer',
+    'version_from' => '14.0.5',
+    'version_to' => '14.0.6',
+    'vendor' => 'BoonEx',
+
+    'compatible_with' => array(
+        '14.0.0-RC5'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/developer/updates/update_14.0.5_14.0.6/',
+    'home_uri' => 'developer_update_1405_1406',
+
+    'module_dir' => 'boonex/developer/',
+    'module_uri' => 'developer',
+
+    'db_prefix' => 'bx_dev_',
+    'class_prefix' => 'BxDev',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 0,
+        'update_files' => 1,
+        'update_languages' => 0,
+        'clear_db_cache' => 0,
+    ),
+
+    /**
+     * Category for language keys.
+     */
+    'language_category' => 'BoonEx Developer',
+
+    /**
+     * Files Section
+     */
+    'delete_files' => array(),
+);

+ 13 - 0
modules/boonex/developer/updates/14.0.5_14.0.6/install/installer.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ */
+
+class BxDevUpdater extends BxDolStudioUpdater
+{
+    function __construct($aConfig)
+    {
+        parent::__construct($aConfig);
+    }
+}

+ 183 - 0
modules/boonex/developer/updates/14.0.5_14.0.6/source/classes/BxDevNavigationItems.php

@@ -0,0 +1,183 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Developer Developer
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDevNavigationItems extends BxTemplStudioNavigationItems
+{
+    protected $oModule;
+
+    function __construct($aOptions, $oTemplate = false)
+    {
+        parent::__construct($aOptions, $oTemplate);
+
+        $this->oModule = BxDolModule::getInstance('bx_developer');
+        $this->sUrlPage = BX_DOL_URL_STUDIO . 'module.php?name=' . $this->oModule->_oConfig->getName() . '&page=navigation&nav_page=items';
+        $this->sUrlViewItems = $this->sUrlPage . '&nav_module=%s&nav_set=%s';
+
+        $sModule = bx_get('nav_module');
+        if(!empty($sModule)) {
+            $this->sModule = bx_process_input($sModule);
+            $this->_aQueryAppend['module'] = $this->sModule;
+        }
+
+        $sSet = bx_get('nav_set');
+        if(!empty($sSet)) {
+            $this->sSet = bx_process_input($sSet);
+            $this->_aQueryAppend['set'] = $this->sSet;
+        }
+    }
+
+    public function performActionAdd()
+    {
+        $sAction = 'add';
+        $sFormObject = $this->oModule->_oConfig->getObject('form_nav_item');
+        $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_item_add');
+
+        $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&set=' . $this->sSet;
+        $this->fillInSelects($oForm->aInputs);
+
+        $oForm->initChecker();
+        if($oForm->isSubmittedAndValid()) {
+            $aValsToAdd = [];
+            $this->onSave($oForm, $aValsToAdd);
+
+            if(($iId = (int)$oForm->insert($aValsToAdd)) != 0)
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
+            else
+                $aRes = array('msg' => _t('_bx_dev_nav_err_items_create'));
+
+            echoJson($aRes);
+        } else {
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-item-create-popup', _t('_bx_dev_nav_txt_items_create_popup'), $this->_oTemplate->parseHtmlByName('nav_add_item.html', array(
+                'form_id' => $oForm->aFormAttrs['id'],
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+
+            echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
+        }
+    }
+
+    public function performActionEdit($bUpdateGrid = false)
+    {
+        $sAction = 'edit';
+        $sFormObject = $this->oModule->_oConfig->getObject('form_nav_item');
+        $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_item_edit');
+
+        $aItem = $this->_getItem('getItems');
+        if($aItem === false) {
+            echoJson(array());
+            exit;
+        }
+
+        $this->_prepareServiceEdit('addon', $aItem);
+        $this->_prepareServiceEdit('visibility_custom', $aItem);
+
+        $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction . '&set=' . $this->sSet;
+        $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_nav_btn_items_save');
+        $this->fillInSelects($oForm->aInputs);
+
+        $oForm->initChecker($aItem);
+        if($oForm->isSubmittedAndValid()) {
+            $this->_prepareServiceSave('addon', $oForm);
+            $this->_prepareServiceSave('visibility_custom', $oForm);
+
+            $this->onSave($oForm, $aItem);
+
+            if($oForm->update($aItem['id']) !== false)
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $aItem['id']);
+            else
+                $aRes = array('msg' => _t('_bx_dev_nav_err_items_edit'));
+
+            echoJson($aRes);
+        } else {
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-item-edit-popup', _t('_bx_dev_nav_txt_items_edit_popup', _t($aItem['title_system'])), $this->oModule->_oTemplate->parseHtmlByName('nav_add_item.html', array(
+                'form_id' => $oForm->aFormAttrs['id'],
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+
+            echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
+        }
+    }
+
+    protected function _prepareServiceEdit($sField, &$aItem)
+    {
+        if(empty($aItem[$sField]))
+            return;
+
+        $aItem[$sField] = BxDevFunctions::unserializeString($aItem[$sField]);
+    }
+
+    protected function _prepareServiceSave($sField, &$oForm)
+    {
+        $sValue = $oForm->getCleanValue($sField);
+        $sValue = BxDevFunctions::serializeString($sValue);
+        BxDolForm::setSubmittedValue($sField, $sValue, $oForm->aFormAttrs['method']);
+    }
+
+    protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
+    {
+        return  parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
+    }
+
+    protected function _isEditable(&$aRow)
+    {
+    	return true;
+    }
+
+    protected function _isDeletable(&$aRow)
+    {
+    	return true;
+    }
+
+    protected function onSave(&$oForm, &$aItem) 
+    {
+        if(($sConfigApi = $oForm->getCleanValue('config_api')) && !$this->oModule->isValidJson($sConfigApi))
+            BxDolForm::setSubmittedValue('config_api', '', $oForm->aFormAttrs['method']);
+    }
+
+    private function fillInSelects(&$aInputs)
+    {
+        $aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_nav_txt_select_module')), BxDolStudioUtils::getModules());
+        $aInputs['module']['value'] = $this->sModule;
+
+        $aInputs['set_name']['value'] = $this->sSet;
+
+        $aInputs['hidden_on']['values'] = array(
+            BX_DB_HIDDEN_PHONE => _t('_bx_dev_nav_txt_sys_items_hidden_on_phone'),
+            BX_DB_HIDDEN_TABLET => _t('_bx_dev_nav_txt_sys_items_hidden_on_tablet'),
+            BX_DB_HIDDEN_DESKTOP => _t('_bx_dev_nav_txt_sys_items_hidden_on_desktop'),
+            BX_DB_HIDDEN_MOBILE => _t('_bx_dev_nav_txt_sys_items_hidden_on_mobile')
+        );
+
+        $aInputs['hidden_on_pt']['values'] = [];
+        $aPageTypes = BxDolPageQuery::getPageTypes();
+        foreach($aPageTypes as $aPageType) {
+            $iPageType = (int)$aPageType['id'];
+            if($iPageType == 1)
+                continue;
+
+            $aInputs['hidden_on_pt']['values'][$iPageType - 1] = _t($aPageType['title']);
+        }
+
+        $aInputs['hidden_on_col']['values'] = [
+            1 => _t('_adm_nav_txt_block_hidden_on_col_thin'),
+            2 => _t('_adm_nav_txt_block_hidden_on_col_half'),
+            3 => _t('_adm_nav_txt_block_hidden_on_col_wide'),
+            4 => _t('_adm_nav_txt_block_hidden_on_col_full')
+        ];
+    }
+}
+/** @} */

+ 258 - 0
modules/boonex/developer/updates/14.0.5_14.0.6/source/classes/BxDevNavigationMenus.php

@@ -0,0 +1,258 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Developer Developer
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+class BxDevNavigationMenus extends BxTemplStudioNavigationMenus
+{
+    protected $oModule;
+
+    function __construct($aOptions, $oTemplate = false)
+    {
+        parent::__construct($aOptions, $oTemplate);
+
+        $this->_aOptions['actions_single']['export']['attr']['title'] = _t('_bx_dev_nav_btn_menus_gl_export');
+
+        $this->oModule = BxDolModule::getInstance('bx_developer');
+        $this->sUrlViewItems = BX_DOL_URL_STUDIO . 'module.php?name=' . $this->oModule->_oConfig->getName() . '&page=navigation&nav_page=items&nav_module=%s&nav_set=%s';
+    }
+
+    public function getCode($isDisplayHeader = true)
+    {
+        return $this->oModule->_oTemplate->getJsCode('main') . parent::getCode($isDisplayHeader);
+    }
+
+    public function performActionAdd()
+    {
+        $sAction = 'add';
+        $sFormObject = $this->oModule->_oConfig->getObject('form_nav_menu');
+        $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_menu_add');
+
+        $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
+        $this->fillInSelects($oForm->aInputs);
+
+        $oForm->initChecker();
+        if($oForm->isSubmittedAndValid()) {
+            $sObject = uriGenerate($oForm->getCleanValue('object'), 'sys_objects_menu', 'object', ['empty' => 'object']);
+            BxDolForm::setSubmittedValue('object', $sObject, $oForm->aFormAttrs['method']);
+
+            $aValsToAdd = [];
+            $this->onSave($oForm, $aValsToAdd);
+
+            if(($iId = (int)$oForm->insert($aValsToAdd)) != 0)
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
+            else
+                $aRes = array('msg' => _t('_bx_dev_nav_err_menus_create'));
+
+            echoJson($aRes);
+        } else {
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-menu-create-popup', _t('_bx_dev_nav_txt_menus_create_popup'), $this->oModule->_oTemplate->parseHtmlByName('nav_add_menu.html', array(
+                'form_id' => $oForm->aFormAttrs['id'],
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+
+            echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
+        }
+    }
+
+    public function performActionEdit()
+    {
+        $sAction = 'edit';
+        $sFormObject = $this->oModule->_oConfig->getObject('form_nav_menu');
+        $sFormDisplay = $this->oModule->_oConfig->getObject('form_display_nav_menu_edit');
+
+        $aMenu = $this->_getItem('getMenus');
+        if($aMenu === false) {
+            echoJson(array());
+            exit;
+        }
+
+        $oForm = BxDolForm::getObjectInstance($sFormObject, $sFormDisplay, $this->oModule->_oTemplate);
+        $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction;
+        $oForm->aInputs['controls'][0]['value'] = _t('_bx_dev_nav_btn_menus_save');
+        $this->fillInSelects($oForm->aInputs);
+
+        $oForm->initChecker($aMenu);
+        if($oForm->isSubmittedAndValid()) {
+            $this->onSave($oForm, $aMenu);
+
+            if($oForm->update($aMenu['id']) !== false)
+                $aRes = array('grid' => $this->getCode(false), 'blink' => $aMenu['id']);
+            else
+                $aRes = array('msg' => _t('_bx_dev_nav_err_menus_edit'));
+
+            echoJson($aRes);
+        } else {
+            $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-menu-edit-popup', _t('_bx_dev_nav_txt_menus_edit_popup', _t($aMenu['title'])), $this->oModule->_oTemplate->parseHtmlByName('nav_add_menu.html', array(
+                'form_id' => $oForm->aFormAttrs['id'],
+                'form' => $oForm->getCode(true),
+                'object' => $this->_sObject,
+                'action' => $sAction
+            )));
+
+            echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false))));
+        }
+    }
+
+    public function performActionExport()
+    {
+        $sContentInsert = $sContentDelete = "";
+
+        $aMenu = $this->_getItem('getMenus');
+        if($aMenu === false) {
+            echoJson(array());
+            exit;
+        }
+
+        $sContentInsert .= $this->oModule->_oDb->getQueryInsert('sys_objects_menu', array($aMenu), "Dumping data for '" . $aMenu['object'] . "' menu");
+        $sContentDelete .= $this->oModule->_oDb->getQueryDelete('sys_objects_menu', 'object', array($aMenu), "Deleting data for '" . $aMenu['object'] . "' menu");
+
+        $aSet = array();
+        $this->oDb->getSets(array('type' => 'dump_by_name', 'value' => $aMenu['set_name']), $aSet, false);
+        $sContentInsert .= $this->oModule->_oDb->getQueryInsert('sys_menu_sets', array($aSet), false, array('name'));
+        $sContentDelete .= $this->oModule->_oDb->getQueryDelete('sys_menu_sets', 'set_name', array($aSet), false);
+
+        $aItems = array();
+        $this->oDb->getItems(array('type' => 'by_set_name', 'value' => $aMenu['set_name']), $aItems, false);
+        $sContentInsert .= $this->oModule->_oDb->getQueryInsert('sys_menu_items', $aItems);
+        $sContentDelete .= $this->oModule->_oDb->getQueryDelete('sys_menu_items', 'set_name', array($aSet), false);
+
+        $aFormStructure = array(
+            'form_attrs' => array(),
+            'inputs' => array (
+                'insert' => array(
+                    'type' => 'textarea',
+                    'name' => 'insert',
+                    'caption' => _t('_bx_dev_nav_txt_menus_export_insert'),
+                    'value' => $sContentInsert,
+                ),
+                'delete' => array(
+                    'type' => 'textarea',
+                    'name' => 'delete',
+                    'caption' => _t('_bx_dev_nav_txt_menus_export_delete'),
+                    'value' => $sContentDelete,
+                ),
+                'done' => array (
+                    'type' => 'button',
+                    'name' => 'done',
+                    'value' => _t('_bx_dev_nav_btn_menus_done'),
+                    'attrs' => array(
+                        'onclick' => "$('.bx-popup-applied:visible').dolPopupHide()",
+                    ),
+                )
+            )
+        );
+        $oForm = new BxTemplStudioFormView($aFormStructure);
+
+        $sContent = BxTemplStudioFunctions::getInstance()->popupBox('bx-dev-nav-menu-export-popup', _t('_bx_dev_nav_txt_menus_export_popup', _t($aMenu['title'])), $this->oModule->_oTemplate->parseHtmlByName('nav_export.html', array(
+            'content' => $oForm->getCode()
+        )));
+
+        echoJson(array('popup' => $sContent));
+    }
+
+    public function performActionExportFull()
+    {
+        echoJson([
+            'url' => BX_DOL_URL_ROOT . bx_append_url_params($this->oModule->_oConfig->getBaseUri() . 'download', [
+                'type' => 'menus',
+            ]),
+            'eval' => $this->oModule->_oConfig->getJsObject('main') . '.onExport(oData);'
+        ]);
+    }
+    
+    public function performActionImportFull()
+    {
+        $sAction = 'import_full';
+
+        $aResult = $this->oModule->getPopupCodeImport('menus', [
+            'form_name' => 'bx-dev-menus-import-full',
+            'form_action' => BX_DOL_URL_ROOT . 'grid.php?o=' . $this->_sObject . '&a=' . $sAction
+        ]);
+        
+        if(!isset($aResult['code']) || (int)$aResult['code'] != 0)
+            return echoJson($aResult);
+
+        $aContent = $aResult['content'];
+        $bModeFull = isset($aContent['meta']['full']) && (bool)$aContent['meta']['full'] === true;
+
+        $aMfMenu = $aMfSet = $aMfItem = false;
+        foreach($aContent['meta']['masks'] as $sMask => $aMask)
+            ${'aMf' . bx_gen_method_name($sMask)} = array_flip($aMask);
+
+        if($aResult['disable'] != 0) {
+            $this->oDb->updateMenus(['active' => 0]);
+            $this->oDb->updateItems(['active' => 0, 'active_api' => 0]);
+        }
+            
+        $iData = 0;
+        foreach($aContent['data'] as $aData) {
+            $iData += 1;
+
+            $sObject = $aData['menu']['object'];
+            if($bModeFull && !$this->oDb->isMenuExists($sObject))
+                $this->oDb->addMenu($aData['menu']);
+            else
+                $this->oDb->updateMenuByObject($sObject, $aData['menu']);
+
+            $aSet = $aData['set'];
+            if(empty($aSet) || !is_array($aSet))
+                continue;
+
+            $sSetName = $aSet['set_name'];
+            if($bModeFull && !$this->oDb->isSetExists($sSetName))
+                $this->oDb->addSet($aSet);
+
+            foreach($aData['items'] as $aItem)
+                if($bModeFull && !$this->oDb->isItemExists($sSetName,  $aItem['name']))
+                    $this->oDb->addItem($aItem);
+                else
+                    $this->oDb->updateItemBySetAndName($sSetName, $aItem['name'], $aItem);
+        }
+
+        BxDolCacheUtilities::getInstance()->clear('db');
+
+        echoJson([
+            'msg' => _t('_bx_dev_msg_imported', $iData), 
+            'eval' => $this->oModule->_oConfig->getJsObject('main') . '.onImport(oData);'
+        ]);
+    }
+
+    protected function onSave(&$oForm, &$aMenu) 
+    {
+        if(($sConfigApi = $oForm->getCleanValue('config_api')) && !$this->oModule->isValidJson($sConfigApi))
+            BxDolForm::setSubmittedValue('config_api', '', $oForm->aFormAttrs['method']);
+    }
+
+    private function fillInSelects(&$aInputs)
+    {
+        $aInputs['module']['values'] = array_merge(array('' => _t('_bx_dev_nav_txt_select_module')), BxDolStudioUtils::getModules());
+        $aInputs['set_name']['values'] = array(
+            array('key' => '', 'value' => _t('_bx_dev_nav_txt_menus_set_name_select'))
+        );
+
+        $aSets = array();
+        $this->oDb->getSets(array('type' => 'all'), $aSets, false);
+        foreach($aSets as $sSet)
+            $aInputs['set_name']['values'][] = array('key' => $sSet['name'], 'value' => _t($sSet['title']));
+
+        $aInputs['template_id']['values'] = array(
+            array('key' => '', 'value' => _t('_bx_dev_nav_txt_menus_template_id_select'))
+        );
+
+        $aTemplates = array();
+        $this->oDb->getTemplates(array('type' => 'all'), $aTemplates, false);
+        foreach($aTemplates as $aTemplate)
+            $aInputs['template_id']['values'][] = array('key' => $aTemplate['id'], 'value' => _t($aTemplate['title']));
+    }
+}
+/** @} */

+ 69 - 0
modules/boonex/developer/updates/14.0.5_14.0.6/source/install/config.php

@@ -0,0 +1,69 @@
+<?php
+/**
+ * Copyright (c) UNA, Inc - https://una.io
+ * MIT License - https://opensource.org/licenses/MIT
+ *
+ * @defgroup    Developer Developer
+ * @ingroup     UnaModules
+ *
+ * @{
+ */
+
+$aConfig = array(
+    /**
+     * Main Section.
+     */
+    'type' => BX_DOL_MODULE_TYPE_MODULE,
+    'name' => 'bx_developer',
+    'title' => 'Developer',
+    'note' => 'Developer tools...',
+    'version' => '14.0.6',
+    'vendor' => 'UNA INC',
+    'help_url' => 'http://feed.una.io/?section={module_name}',
+
+    'compatible_with' => array(
+        '14.0.0-RC5'
+    ),
+
+    /**
+     * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars.
+     */
+    'home_dir' => 'boonex/developer/',
+    'home_uri' => 'developer',
+
+    'db_prefix' => 'bx_dev_',
+    'class_prefix' => 'BxDev',
+
+	/**
+     * Category for language keys.
+     */
+    'language_category' => 'BoonEx Developer',
+
+    /**
+     * Installation/Uninstallation Section.
+     */
+    'install' => array(
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1
+    ),
+    'uninstall' => array (
+        'execute_sql' => 1,
+        'update_languages' => 1,
+        'clear_db_cache' => 1
+    ),
+    'enable' => array(
+        'execute_sql' => 1,
+    ),
+    'disable' => array(
+        'execute_sql' => 1,
+    ),
+
+    /**
+     * Dependencies Section
+     */
+    'dependencies' => array(),
+
+);
+
+/** @} */