Explorar o código

#52 - Get rid of duplicates in code (Studio -> Base)

AntonLV %!s(int64=12) %!d(string=hai) anos
pai
achega
2d69ed1b35

+ 1 - 2
modules/boonex/english/data/langs/system.xml

@@ -771,7 +771,6 @@
 	<string name="_adm_form_txt_select_display"><![CDATA[Select Display...]]></string>
 	<string name="_adm_form_txt_select_display"><![CDATA[Select Display...]]></string>
 	<string name="_adm_form_txt_select_form"><![CDATA[Select Form...]]></string>
 	<string name="_adm_form_txt_select_form"><![CDATA[Select Form...]]></string>
 	<string name="_adm_form_txt_select_list"><![CDATA[Select List...]]></string>
 	<string name="_adm_form_txt_select_list"><![CDATA[Select List...]]></string>
-	<string name="_adm_form_txt_select_module"><![CDATA[Select Module...]]></string>
 	<string name="_adm_from_err_field_delete"><![CDATA[Cannot delete field]]></string>
 	<string name="_adm_from_err_field_delete"><![CDATA[Cannot delete field]]></string>
 	<string name="_adm_from_err_pre_lists_delete"><![CDATA[Cannot delete list]]></string>
 	<string name="_adm_from_err_pre_lists_delete"><![CDATA[Cannot delete list]]></string>
 	<string name="_adm_ipbl_Date_of_finish"><![CDATA[Expiration date]]></string>
 	<string name="_adm_ipbl_Date_of_finish"><![CDATA[Expiration date]]></string>
@@ -923,7 +922,6 @@
 	<string name="_adm_nav_txt_menus_style_select"><![CDATA[Select Style...]]></string>
 	<string name="_adm_nav_txt_menus_style_select"><![CDATA[Select Style...]]></string>
 	<string name="_adm_nav_txt_menus_title"><![CDATA[System Name]]></string>
 	<string name="_adm_nav_txt_menus_title"><![CDATA[System Name]]></string>
 	<string name="_adm_nav_txt_n_items"><![CDATA[{0} items]]></string>
 	<string name="_adm_nav_txt_n_items"><![CDATA[{0} items]]></string>
-	<string name="_adm_nav_txt_select_module"><![CDATA[Select Module...]]></string>
 	<string name="_adm_nav_txt_select_set"><![CDATA[Select Set...]]></string>
 	<string name="_adm_nav_txt_select_set"><![CDATA[Select Set...]]></string>
 	<string name="_adm_nav_txt_sets_create_popup"><![CDATA[Add New Set]]></string>
 	<string name="_adm_nav_txt_sets_create_popup"><![CDATA[Add New Set]]></string>
 	<string name="_adm_nav_txt_sets_edit_popup"><![CDATA[Edit "{0}" Set]]></string>
 	<string name="_adm_nav_txt_sets_edit_popup"><![CDATA[Edit "{0}" Set]]></string>
@@ -1255,6 +1253,7 @@
 	<string name="_adm_txt_pca_active"><![CDATA[Active]]></string>
 	<string name="_adm_txt_pca_active"><![CDATA[Active]]></string>
 	<string name="_adm_txt_pca_favorite"><![CDATA[Favorite]]></string>
 	<string name="_adm_txt_pca_favorite"><![CDATA[Favorite]]></string>
 	<string name="_adm_txt_remember_me"><![CDATA[Remember me]]></string>
 	<string name="_adm_txt_remember_me"><![CDATA[Remember me]]></string>
+	<string name="_adm_txt_select_module"><![CDATA[Select Module...]]></string>
 	<string name="_adm_txt_show_help"><![CDATA[Help]]></string>
 	<string name="_adm_txt_show_help"><![CDATA[Help]]></string>
 	<string name="_adm_txt_show_help_content_empty"><![CDATA[Help is not available]]></string>
 	<string name="_adm_txt_show_help_content_empty"><![CDATA[Help is not available]]></string>
 	<string name="_adm_wgt_cpt_builder_forms"><![CDATA[Forms]]></string>
 	<string name="_adm_wgt_cpt_builder_forms"><![CDATA[Forms]]></string>

+ 1 - 0
modules/boonex/russian/data/langs/system.xml

@@ -2583,6 +2583,7 @@ Without doing that you won't be submitted to our database.</p>
 	<string name="_adm_btn_login_submit"><![CDATA[Enter Studio]]></string>
 	<string name="_adm_btn_login_submit"><![CDATA[Enter Studio]]></string>
 	<string name="_adm_txt_forgot_password"><![CDATA[Forgot password?]]></string>
 	<string name="_adm_txt_forgot_password"><![CDATA[Forgot password?]]></string>
 	<string name="_adm_txt_remember_me"><![CDATA[Remember me]]></string>
 	<string name="_adm_txt_remember_me"><![CDATA[Remember me]]></string>
+	<string name="_adm_txt_select_module"><![CDATA[Select Module...]]></string>
 	<string name="_adm_txt_settings_logo_header"><![CDATA[Upload]]></string>
 	<string name="_adm_txt_settings_logo_header"><![CDATA[Upload]]></string>
 	<string name="_adm_txt_settings_logo_upload"><![CDATA[Browse]]></string>
 	<string name="_adm_txt_settings_logo_upload"><![CDATA[Browse]]></string>
 	<string name="_adm_txt_settings_resize_header"><![CDATA[Resize]]></string>
 	<string name="_adm_txt_settings_resize_header"><![CDATA[Resize]]></string>

+ 19 - 0
modules/boonex/uni/data/template/studio/scripts/BxTemplStudioGridNavigation.php

@@ -0,0 +1,19 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinView Dolphin Studio Representation classes
+ * @ingroup     DolphinStudio
+ * @{
+ */
+defined('BX_DOL') or die('hack attempt');
+
+bx_import('BxBaseStudioGridNavigation');
+
+class BxTemplStudioGridNavigation extends BxBaseStudioGridNavigation { 
+    function __construct($aOptions, $oTemplate = false) {
+        parent::__construct($aOptions, $oTemplate);
+    }
+}
+/** @} */

+ 9 - 0
studio/classes/BxDolStudioForm.php

@@ -49,6 +49,15 @@ class BxDolStudioForm extends BxBaseFormView {
         return $mixedResult;
         return $mixedResult;
     }
     }
 
 
+    function updateWithVisibility($iId)
+    {
+		$iVisibleFor = BxDolStudioUtils::getVisibilityValue($this->getCleanValue('visible_for'), $this->getCleanValue('visible_for_levels'));
+		BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $this->aFormAttrs['method']);
+		unset($this->aInputs['visible_for']);
+
+		return $this->update($iId);
+    }
+
     function processImageUploaderSave($sName, $iId = 0) {
     function processImageUploaderSave($sName, $iId = 0) {
         if($this->aInputs[$sName]['type'] != 'image_uploader')
         if($this->aInputs[$sName]['type'] != 'image_uploader')
             return $iId;
             return $iId;

+ 2 - 2
studio/classes/BxDolStudioNavigationImport.php

@@ -8,11 +8,11 @@
  */
  */
 defined('BX_DOL') or die('hack attempt');
 defined('BX_DOL') or die('hack attempt');
 
 
-bx_import('BxTemplStudioGrid');
+bx_import('BxTemplStudioGridNavigation');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioNavigationQuery');
 bx_import('BxDolStudioNavigationQuery');
 
 
-class BxDolStudioNavigationImport extends BxTemplStudioGrid {
+class BxDolStudioNavigationImport extends BxTemplStudioGridNavigation {
     protected $sSet;
     protected $sSet;
 
 
     public function __construct ($aOptions, $oTemplate = false) {
     public function __construct ($aOptions, $oTemplate = false) {

+ 2 - 2
studio/classes/BxDolStudioNavigationMenus.php

@@ -8,11 +8,11 @@
  */
  */
 defined('BX_DOL') or die('hack attempt');
 defined('BX_DOL') or die('hack attempt');
 
 
-bx_import('BxTemplStudioGrid');
+bx_import('BxTemplStudioGridNavigation');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioNavigationQuery');
 bx_import('BxDolStudioNavigationQuery');
 
 
-class BxDolStudioNavigationMenus extends BxTemplStudioGrid {
+class BxDolStudioNavigationMenus extends BxTemplStudioGridNavigation {
     public function __construct ($aOptions, $oTemplate = false) {
     public function __construct ($aOptions, $oTemplate = false) {
         parent::__construct ($aOptions, $oTemplate);
         parent::__construct ($aOptions, $oTemplate);
 
 

+ 2 - 2
studio/classes/BxDolStudioNavigationSets.php

@@ -8,11 +8,11 @@
  */
  */
 defined('BX_DOL') or die('hack attempt');
 defined('BX_DOL') or die('hack attempt');
 
 
-bx_import('BxTemplStudioGrid');
+bx_import('BxTemplStudioGridNavigation');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioNavigationQuery');
 bx_import('BxDolStudioNavigationQuery');
 
 
-class BxDolStudioNavigationSets extends BxTemplStudioGrid {
+class BxDolStudioNavigationSets extends BxTemplStudioGridNavigation {
     public function __construct ($aOptions, $oTemplate = false) {
     public function __construct ($aOptions, $oTemplate = false) {
         parent::__construct ($aOptions, $oTemplate);
         parent::__construct ($aOptions, $oTemplate);
 
 

+ 1 - 22
studio/template/scripts/BxBaseStudioFormsDisplays.php

@@ -212,32 +212,11 @@ class BxBaseStudioFormsDisplays extends BxDolStudioFormsDisplays {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
+        $sContent = $this->getModulesSelectOne('getDisplays', false) . $this->getFormsSelector($this->sModule);
 
 
         bx_import('BxTemplStudioFormView');
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
         $oForm = new BxTemplStudioFormView(array());
 
 
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
-            ),
-            'value' => $this->sModule,
-            'values' => $this->getModules(false)
-        );
-
-        $aCounter = array();
-        $this->oDb->getDisplays(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-            $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_form_txt_select_module')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-        $sContent .= $this->getFormsSelector($this->sModule);
-
         $aInputSearch = array(
         $aInputSearch = array(
             'type' => 'text',
             'type' => 'text',
             'name' => 'keyword',
             'name' => 'keyword',

+ 43 - 76
studio/template/scripts/BxBaseStudioFormsField.php

@@ -114,44 +114,7 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField {
             $sName = $this->getFieldName($sInputObject, $sCaption);
             $sName = $this->getFieldName($sInputObject, $sCaption);
             BxDolForm::setSubmittedValue('name', $sName, $oForm->aFormAttrs['method']);
             BxDolForm::setSubmittedValue('name', $sName, $oForm->aFormAttrs['method']);
 
 
-            //--- Process field values.
-            if(isset($oForm->aInputs['values'])) {
-                $sValues = $oForm->getCleanValue('values');
-                if(is_string($sValues) && strpos($sValues, BX_DATA_LISTS_KEY_PREFIX) === false)
-                    BxDolForm::setSubmittedValue('values', serialize(explode("\n", $sValues)), $oForm->aFormAttrs['method']);
-            }
-
-            //--- Process field 'html' flag.
-            if(isset($oForm->aInputs['html'])) {
-                $iHtml = (int)$oForm->getCleanValue('html');
-                BxDolForm::setSubmittedValue('db_pass', $iHtml == 0 ? 'Xss' : 'XssHtml', $oForm->aFormAttrs['method']);
-            }
-
-            //--- Process field checker.
-            $aCheckerParams = array();
-            if(isset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'])) {
-                $aCheckerParams['min'] = $oForm->getCleanValue('checker_params_length_min');
-                $aCheckerParams['max'] = $oForm->getCleanValue('checker_params_length_max');
-            }
-            if(isset($oForm->aInputs['checker_params_preg']))
-                $aCheckerParams['preg'] = $oForm->getCleanValue('checker_params_preg');
-
-            unset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'], $oForm->aInputs['checker_params_preg']);
-            BxDolForm::setSubmittedValue('checker_params', !empty($aCheckerParams) ? serialize($aCheckerParams) : '', $oForm->aFormAttrs['method']);
-
-            //--- Process field attrs.
-            $aAttrs = array();
-            if(isset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'])) {
-                $aAttrs['min'] = $oForm->getCleanValue('attrs_min');
-                $aAttrs['max'] = $oForm->getCleanValue('attrs_max');
-                $aAttrs['step'] = $oForm->getCleanValue('attrs_step');
-            }
-            else if(isset($oForm->aInputs['attrs_src']))
-                $aAttrs['src'] = $oForm->getCleanValue('attrs_src');
-
-            unset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'], $oForm->aInputs['attrs_src']);
-            BxDolForm::setSubmittedValue('attrs', serialize($aAttrs), $oForm->aFormAttrs['method']);
-
+            $this->onSubmitField($oForm);
             if(($iId = $oForm->insert()) === false) 
             if(($iId = $oForm->insert()) === false) 
                 return false;
                 return false;
 
 
@@ -179,44 +142,7 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField {
             $sInputObject = $oForm->getCleanValue('object');
             $sInputObject = $oForm->getCleanValue('object');
             $sInputName = $oForm->getCleanValue('name');
             $sInputName = $oForm->getCleanValue('name');
 
 
-            //--- Process field values.
-            if(isset($oForm->aInputs['values']['db'])) {
-                $sValues = $oForm->getCleanValue('values');
-                if(is_string($sValues) && strpos($sValues, BX_DATA_LISTS_KEY_PREFIX) === false)
-                    BxDolForm::setSubmittedValue('values', serialize(explode("\n", $sValues)), $oForm->aFormAttrs['method']);
-            }
-
-            //--- Process field 'html' flag.
-            if(isset($oForm->aInputs['html'])) {
-                $iHtml = (int)$oForm->getCleanValue('html');
-                BxDolForm::setSubmittedValue('db_pass', $iHtml == 0 ? 'Xss' : 'XssHtml', $oForm->aFormAttrs['method']);
-            }
-
-            //--- Process field checker,
-            $aCheckerParams = array();
-            if(isset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'])) {
-                $aCheckerParams['min'] = $oForm->getCleanValue('checker_params_length_min');
-                $aCheckerParams['max'] = $oForm->getCleanValue('checker_params_length_max');
-            }
-            if(isset($oForm->aInputs['checker_params_preg']))
-                $aCheckerParams['preg'] = $oForm->getCleanValue('checker_params_preg');
-
-            unset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'], $oForm->aInputs['checker_params_preg']);
-            BxDolForm::setSubmittedValue('checker_params', !empty($aCheckerParams) ? serialize($aCheckerParams) : '', $oForm->aFormAttrs['method']);
-
-            //--- Process field attrs
-            $aAttrs = array();
-            if(isset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'])) {
-                $aAttrs['min'] = $oForm->getCleanValue('attrs_min');
-                $aAttrs['max'] = $oForm->getCleanValue('attrs_max');
-                $aAttrs['step'] = $oForm->getCleanValue('attrs_step');
-            }
-            else if(isset($oForm->aInputs['attrs_src']))
-                $aAttrs['src'] = $oForm->getCleanValue('attrs_src');
-
-            unset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'], $oForm->aInputs['attrs_src']);
-            BxDolForm::setSubmittedValue('attrs', serialize($aAttrs), $oForm->aFormAttrs['method']);
-
+            $this->onSubmitField($oForm);
             if($oForm->update((int)$this->aField['id']) === false) 
             if($oForm->update((int)$this->aField['id']) === false) 
                 return false;
                 return false;
 
 
@@ -616,6 +542,47 @@ class BxBaseStudioFormsField extends BxDolStudioFormsField {
 
 
         return $sPrefix . $iIndex;
         return $sPrefix . $iIndex;
     }
     }
+
+	protected function onSubmitField(&$oForm)
+    {
+		//--- Process field values.
+		if(isset($oForm->aInputs['values']['db'])) {
+			$sValues = $oForm->getCleanValue('values');
+		    if(is_string($sValues) && strpos($sValues, BX_DATA_LISTS_KEY_PREFIX) === false)
+		    	BxDolForm::setSubmittedValue('values', serialize(explode("\n", $sValues)), $oForm->aFormAttrs['method']);
+		}
+		
+		//--- Process field 'html' flag.
+		if(isset($oForm->aInputs['html'])) {
+			$iHtml = (int)$oForm->getCleanValue('html');
+			BxDolForm::setSubmittedValue('db_pass', $iHtml == 0 ? 'Xss' : 'XssHtml', $oForm->aFormAttrs['method']);
+		}
+		
+		//--- Process field checker.
+		$aCheckerParams = array();
+		if(isset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'])) {
+			$aCheckerParams['min'] = $oForm->getCleanValue('checker_params_length_min');
+			$aCheckerParams['max'] = $oForm->getCleanValue('checker_params_length_max');
+		}
+		if(isset($oForm->aInputs['checker_params_preg']))
+			$aCheckerParams['preg'] = $oForm->getCleanValue('checker_params_preg');
+		
+		unset($oForm->aInputs['checker_params_length_min'], $oForm->aInputs['checker_params_length_max'], $oForm->aInputs['checker_params_preg']);
+		BxDolForm::setSubmittedValue('checker_params', !empty($aCheckerParams) ? serialize($aCheckerParams) : '', $oForm->aFormAttrs['method']);
+		
+		//--- Process field attrs.
+		$aAttrs = array();
+		if(isset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'])) {
+			$aAttrs['min'] = $oForm->getCleanValue('attrs_min');
+			$aAttrs['max'] = $oForm->getCleanValue('attrs_max');
+			$aAttrs['step'] = $oForm->getCleanValue('attrs_step');
+		}
+		else if(isset($oForm->aInputs['attrs_src']))
+			$aAttrs['src'] = $oForm->getCleanValue('attrs_src');
+		
+		unset($oForm->aInputs['attrs_min'], $oForm->aInputs['attrs_max'], $oForm->aInputs['attrs_step'], $oForm->aInputs['attrs_src']);
+		BxDolForm::setSubmittedValue('attrs', serialize($aAttrs), $oForm->aFormAttrs['method']);
+    }
 }
 }
 
 
 class BxBaseStudioFormsFieldBlockHeader extends BxBaseStudioFormsField {
 class BxBaseStudioFormsFieldBlockHeader extends BxBaseStudioFormsField {

+ 2 - 27
studio/template/scripts/BxBaseStudioFormsFields.php

@@ -247,11 +247,7 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields {
         $oForm->initChecker();
         $oForm->initChecker();
 
 
         if($oForm->isSubmittedAndValid()) {
         if($oForm->isSubmittedAndValid()) {
-            $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
-            BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']);
-            unset($oForm->aInputs['visible_for']);
-
-            if($oForm->update($iId) !== false)
+            if($oForm->updateWithVisibility($iId) !== false)
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
             else
             else
                 $aRes = array('msg' => _t('_adm_form_err_field_show_to'));
                 $aRes = array('msg' => _t('_adm_form_err_field_show_to'));
@@ -411,32 +407,11 @@ class BxBaseStudioFormsFields extends BxDolStudioFormsFields {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
+        $sContent = $this->getModulesSelectOne('getInputs') . $this->getDisplaysSelector($this->sModule);
 
 
         bx_import('BxTemplStudioFormView');
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
         $oForm = new BxTemplStudioFormView(array());
 
 
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
-            ),
-            'value' => $this->sModule,
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getInputs(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_form_txt_select_module')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-        $sContent .= $this->getDisplaysSelector($this->sModule);
-
         $aInputSearch = array(
         $aInputSearch = array(
             'type' => 'text',
             'type' => 'text',
             'name' => 'keyword',
             'name' => 'keyword',

+ 1 - 22
studio/template/scripts/BxBaseStudioFormsPreValues.php

@@ -394,32 +394,11 @@ class BxBaseStudioFormsPreValues extends BxDolStudioFormsPreValues {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
+        $sContent = $this->getModulesSelectOne('getValues') . $this->getListsSelector($this->sModule);
 
 
         bx_import('BxTemplStudioFormView');
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
         $oForm = new BxTemplStudioFormView(array());
 
 
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
-            ),
-            'value' => $this->sModule,
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getValues(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_form_txt_select_module')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-        $sContent .= $this->getListsSelector($this->sModule);
-
         $aInputSearch = array(
         $aInputSearch = array(
             'type' => 'text',
             'type' => 'text',
             'name' => 'keyword',
             'name' => 'keyword',

+ 28 - 0
studio/template/scripts/BxBaseStudioGrid.php

@@ -20,6 +20,34 @@ class BxBaseStudioGrid extends BxDolStudioGrid {
         return '';
         return '';
     }
     }
 
 
+    public function getModulesSelectOne($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
+    {
+    	if(empty($sGetItemsMethod))
+    		return '';
+
+    	bx_import('BxTemplStudioFormView');
+        $oForm = new BxTemplStudioFormView(array());
+
+        $aInputModules = array(
+            'type' => 'select',
+            'name' => 'module',
+            'attrs' => array(
+                'id' => 'bx-grid-module-' . $this->_sObject,
+            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
+            ),
+            'value' => $this->sModule,
+            'values' => $this->getModules($bShowCustom, $bShowSystem)
+        );
+
+        $aCounter = array();
+        $this->oDb->$sGetItemsMethod(array('type' => 'counter_by_modules'), $aCounter, false);
+        foreach($aInputModules['values'] as $sKey => $sValue)
+                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
+
+        $aInputModules['values'] = array_merge(array('' => _t('_adm_txt_select_module')), $aInputModules['values']);
+
+        return $oForm->genRow($aInputModules);
+    }
 	protected function _getItem($sDbMethod = '')
 	protected function _getItem($sDbMethod = '')
     {
     {
     	$aIds = bx_get('ids');
     	$aIds = bx_get('ids');

+ 64 - 0
studio/template/scripts/BxBaseStudioGridNavigation.php

@@ -0,0 +1,64 @@
+<?php
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinView Dolphin Studio Representation classes
+ * @ingroup     DolphinStudio
+ * @{
+ */
+defined('BX_DOL') or die('hack attempt');
+
+bx_import('BxTemplStudioGrid');
+
+class BxBaseStudioGridNavigation extends BxTemplStudioGrid {
+    function __construct($aOptions, $oTemplate = false) {
+        parent::__construct($aOptions, $oTemplate);
+    }
+
+    public function getModulesSelectAll($sGetItemsMethod, $bShowCustom = true, $bShowSystem = true)
+    {
+    	if(empty($sGetItemsMethod))
+    		return '';
+
+    	bx_import('BxTemplStudioFormView');
+        $oForm = new BxTemplStudioFormView(array());
+
+    	$aInputModules = array(
+            'type' => 'select',
+            'name' => 'module',
+            'attrs' => array(
+                'id' => 'bx-grid-module-' . $this->_sObject,
+            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeFilter()'
+            ),
+            'value' => '',
+            'values' => $this->getModules($bShowCustom, $bShowSystem)
+        );
+
+        $aCounter = array();
+        $this->oDb->$sGetItemsMethod(array('type' => 'counter_by_modules'), $aCounter, false);
+        foreach($aInputModules['values'] as $sKey => $sValue)
+                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
+
+        $aInputModules['values'] = array_merge(array('' => _t('_adm_nav_txt_all_modules')), $aInputModules['values']);
+
+        return $oForm->genRow($aInputModules);
+    }
+
+    public function getSearchInput()
+    {
+    	bx_import('BxTemplStudioFormView');
+        $oForm = new BxTemplStudioFormView(array());
+
+    	$aInputSearch = array(
+            'type' => 'text',
+            'name' => 'keyword',
+            'attrs' => array(
+                'id' => 'bx-grid-search-' . $this->_sObject,
+                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->getJsObject() . '.onChangeFilter()' 
+            )
+        );
+        return $oForm->genRow($aInputSearch);
+    }
+}
+/** @} */

+ 1 - 35
studio/template/scripts/BxBaseStudioNavigationImport.php

@@ -113,8 +113,6 @@ class BxBaseStudioNavigationImport extends BxDolStudioNavigationImport {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
-
         bx_import('BxTemplStudioFormView');
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
         $oForm = new BxTemplStudioFormView(array());
 
 
@@ -138,39 +136,7 @@ class BxBaseStudioNavigationImport extends BxDolStudioNavigationImport {
         asort($aInputSets['values']);
         asort($aInputSets['values']);
         $aInputSets['values'] = array_merge(array('' => _t('_adm_nav_txt_select_set')), $aInputSets['values']);
         $aInputSets['values'] = array_merge(array('' => _t('_adm_nav_txt_select_set')), $aInputSets['values']);
 
 
-        $sContent .= $oForm->genRow($aInputSets);
-
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeFilter()'
-            ),
-            'value' => '',
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getItems(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_nav_txt_all_modules')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-
-        $aInputSearch = array(
-            'type' => 'text',
-            'name' => 'keyword',
-            'attrs' => array(
-                'id' => 'bx-grid-search-' . $this->_sObject,
-                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->getJsObject() . '.onChangeFilter()' 
-            )
-        );
-        $sContent .= $oForm->genRow($aInputSearch);
-
-        return  $sContent;
+        return $oForm->genRow($aInputSets) . $this->getModulesSelectAll('getItems') . $this->getSearchInput();
     }
     }
 }
 }
 /** @} */
 /** @} */

+ 2 - 27
studio/template/scripts/BxBaseStudioNavigationItems.php

@@ -698,11 +698,7 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
         $oForm->initChecker();
         $oForm->initChecker();
 
 
         if($oForm->isSubmittedAndValid()) {
         if($oForm->isSubmittedAndValid()) {
-            $iVisibleFor = BxDolStudioUtils::getVisibilityValue($oForm->getCleanValue('visible_for'), $oForm->getCleanValue('visible_for_levels'));
-            BxDolForm::setSubmittedValue('visible_for_levels', $iVisibleFor, $aForm['form_attrs']['method']);
-            unset($oForm->aInputs['visible_for']);
-
-            if($oForm->update($iId) !== false)
+            if($oForm->updateWithVisibility($iId) !== false)
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
                 $aRes = array('grid' => $this->getCode(false), 'blink' => $iId);
             else
             else
                 $aRes = array('msg' => _t('_adm_nav_err_items_show_to'));
                 $aRes = array('msg' => _t('_adm_nav_err_items_show_to'));
@@ -896,32 +892,11 @@ class BxBaseStudioNavigationItems extends BxDolStudioNavigationItems {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
+        $sContent = $this->getModulesSelectOne('getItems') . $this->getSetsSelector($this->sModule);
 
 
         bx_import('BxTemplStudioFormView');
         bx_import('BxTemplStudioFormView');
         $oForm = new BxTemplStudioFormView(array());
         $oForm = new BxTemplStudioFormView(array());
 
 
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeModule()'
-            ),
-            'value' => $this->sModule,
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getItems(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_nav_txt_select_module')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-        $sContent .= $this->getSetsSelector($this->sModule);
-
         $aInputSearch = array(
         $aInputSearch = array(
             'type' => 'text',
             'type' => 'text',
             'name' => 'keyword',
             'name' => 'keyword',

+ 1 - 36
studio/template/scripts/BxBaseStudioNavigationMenus.php

@@ -495,42 +495,7 @@ class BxBaseStudioNavigationMenus extends BxDolStudioNavigationMenus {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
-
-        bx_import('BxTemplStudioFormView');
-        $oForm = new BxTemplStudioFormView(array());
-
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeFilter()'
-            ),
-            'value' => '',
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getMenus(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-                $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_nav_txt_all_modules')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-
-        $aInputSearch = array(
-            'type' => 'text',
-            'name' => 'keyword',
-            'attrs' => array(
-                'id' => 'bx-grid-search-' . $this->_sObject,
-                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->getJsObject() . '.onChangeFilter()' 
-            )
-        );
-        $sContent .= $oForm->genRow($aInputSearch);
-
-        return  $sContent;
+        return  $this->getModulesSelectAll('getMenus') . $this->getSearchInput();
     }
     }
 
 
     protected function updateSetFields(&$oForm) {
     protected function updateSetFields(&$oForm) {

+ 1 - 36
studio/template/scripts/BxBaseStudioNavigationSets.php

@@ -327,42 +327,7 @@ class BxBaseStudioNavigationSets extends BxDolStudioNavigationSets {
     protected function _getFilterControls () {
     protected function _getFilterControls () {
         parent::_getFilterControls();
         parent::_getFilterControls();
 
 
-        $sContent = "";
-
-        bx_import('BxTemplStudioFormView');
-        $oForm = new BxTemplStudioFormView(array());
-
-        $aInputModules = array(
-            'type' => 'select',
-            'name' => 'module',
-            'attrs' => array(
-                'id' => 'bx-grid-module-' . $this->_sObject,
-            	'onChange' => 'javascript:' . $this->getJsObject() . '.onChangeFilter()'
-            ),
-            'value' => '',
-            'values' => $this->getModules()
-        );
-
-        $aCounter = array();
-        $this->oDb->getSets(array('type' => 'counter_by_modules'), $aCounter, false);
-        foreach($aInputModules['values'] as $sKey => $sValue)
-            $aInputModules['values'][$sKey] = $aInputModules['values'][$sKey] . " (" . (isset($aCounter[$sKey]) ? $aCounter[$sKey] : "0") . ")";
-
-        $aInputModules['values'] = array_merge(array('' => _t('_adm_nav_txt_all_modules')), $aInputModules['values']);
-
-        $sContent .= $oForm->genRow($aInputModules);
-
-        $aInputSearch = array(
-            'type' => 'text',
-            'name' => 'keyword',
-            'attrs' => array(
-                'id' => 'bx-grid-search-' . $this->_sObject,
-                'onKeyup' => 'javascript:$(this).off(\'keyup\'); ' . $this->getJsObject() . '.onChangeFilter()' 
-            )
-        );
-        $sContent .= $oForm->genRow($aInputSearch);
-
-        return  $sContent;
+        return  $this->getModulesSelectAll('getSets') . $this->getSearchInput();
     }
     }
 }
 }
 /** @} */
 /** @} */