Ver Fonte

#31 - Minor fixes and improvements.

AntonLV há 12 anos atrás
pai
commit
d10d6481e8

+ 1 - 0
studio/builder_forms.php

@@ -20,6 +20,7 @@ $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 
 
 bx_import('BxTemplStudioForms');
 bx_import('BxTemplStudioForms');
 $oPage = new BxTemplStudioForms($sPage);
 $oPage = new BxTemplStudioForms($sPage);
+$oPage->init();
 
 
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate = BxDolStudioTemplate::getInstance();

+ 1 - 0
studio/builder_menu.php

@@ -20,6 +20,7 @@ $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 
 
 bx_import('BxTemplStudioNavigation');
 bx_import('BxTemplStudioNavigation');
 $oPage = new BxTemplStudioNavigation($sPage);
 $oPage = new BxTemplStudioNavigation($sPage);
+$oPage->init();
 
 
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate = BxDolStudioTemplate::getInstance();

+ 1 - 0
studio/builder_permissions.php

@@ -20,6 +20,7 @@ $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 
 
 bx_import('BxTemplStudioPermissions');
 bx_import('BxTemplStudioPermissions');
 $oPage = new BxTemplStudioPermissions($sPage);
 $oPage = new BxTemplStudioPermissions($sPage);
+$oPage->init();
 
 
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate = BxDolStudioTemplate::getInstance();

+ 33 - 33
studio/classes/BxDolStudioBuilderPage.php

@@ -56,39 +56,39 @@ class BxDolStudioBuilderPage extends BxTemplStudioPage
 
 
     function init()
     function init()
     {
     {
-        //--- Check actions ---//
-        if(($sAction = bx_get('bp_action')) !== false) {
-            $sAction = bx_process_input($sAction);
-
-            $aResult = array('code' => 1, 'message' => _t('_adm_bp_err_cannot_process_action'));
-            switch($sAction) {
-                case 'reorder':
-                    if(empty($this->aPageRebuild) || !is_array($this->aPageRebuild))
-                        break;
-
-                    $bResult = false;
-                    for($i = 1; $i <= $this->aPageRebuild['layout_cells_number']; $i++) {
-                        $aItems = bx_get('bp_items_' . $i);
-                        $iItems = count($aItems);
-
-                        for($j = 0; $j < $iItems; $j++)
-                            $bResult |= $this->oDb->updateBlock((int)$aItems[$j], array(
-                                'cell_id' => $i,
-                                'order' => $j
-                            ));
-                    }
-                    $aResult = $bResult ? array('code' => 0, 'message' => _t('_adm_bp_scs_save')) : array('code' => 1, 'message' => _t('_adm_bp_err_nothing_changed'));
-                    break;
-
-                default:
-                    $sMethod = 'action' . $this->getClassName($sAction);
-                    if(method_exists($this, $sMethod))
-                        $aResult = $this->$sMethod();
-            }
-
-            echo json_encode($aResult);
-            exit;
-        }
+        if(($sAction = bx_get('bp_action')) === false) 
+        	return;
+
+		$sAction = bx_process_input($sAction);
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_bp_err_cannot_process_action'));
+		switch($sAction) {
+			case 'reorder':
+				if(empty($this->aPageRebuild) || !is_array($this->aPageRebuild))
+					break;
+
+				$bResult = false;
+				for($i = 1; $i <= $this->aPageRebuild['layout_cells_number']; $i++) {
+					$aItems = bx_get('bp_items_' . $i);
+					$iItems = count($aItems);
+
+					for($j = 0; $j < $iItems; $j++)
+					$bResult |= $this->oDb->updateBlock((int)$aItems[$j], array(
+						'cell_id' => $i,
+						'order' => $j
+					));
+				}
+				$aResult = $bResult ? array('code' => 0, 'message' => _t('_adm_bp_scs_save')) : array('code' => 1, 'message' => _t('_adm_bp_err_nothing_changed'));
+				break;
+
+			default:
+				$sMethod = 'action' . $this->getClassName($sAction);
+				if(method_exists($this, $sMethod))
+			    	$aResult = $this->$sMethod();
+		}
+
+		echo json_encode($aResult);
+		exit;
     }
     }
 
 
     protected function onSaveBlock(&$oForm, &$aBlock)
     protected function onSaveBlock(&$oForm, &$aBlock)

+ 28 - 25
studio/classes/BxDolStudioForms.php

@@ -31,33 +31,36 @@ class BxDolStudioForms extends BxTemplStudioPage
         $this->sPage = BX_DOL_STUDIO_FORM_TYPE_DEFAULT;
         $this->sPage = BX_DOL_STUDIO_FORM_TYPE_DEFAULT;
         if(is_string($sPage) && !empty($sPage))
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
             $this->sPage = $sPage;
-
-        //--- Check actions ---//
-        if(($sAction = bx_get('form_action')) !== false) {
-            $sAction = bx_process_input($sAction);
-
-            $aResult = array('code' => 1, 'message' => _t('_adm_form_err_cannot_process_action'));
-            switch($sAction) {
-                case 'get-page-by-type':
-                    $sValue = bx_process_input(bx_get('form_value'));
-                    if(empty($sValue))
-                        break;
-
-                    $this->sPage = $sValue;
-                    $aResult = array('code' => 0, 'content' => $this->getPageCode());
-                    break;
-
-                default:
-                    $sMethod = 'action' . $this->getClassName($sAction);
-                    if(method_exists($this, $sMethod))
-                        $aResult = $this->$sMethod();
-            }
-
-            echo json_encode($aResult);
-            exit;
-        }
     }
     }
 
 
+	public function init()
+	{
+        if(($sAction = bx_get('form_action')) === false) 
+        	return;
+
+		$sAction = bx_process_input($sAction);
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_form_err_cannot_process_action'));
+        switch($sAction) {
+        	case 'get-page-by-type':
+            	$sValue = bx_process_input(bx_get('form_value'));
+                if(empty($sValue))
+                	break;
+
+				$this->sPage = $sValue;
+				$aResult = array('code' => 0, 'content' => $this->getPageCode());
+				break;
+
+			default:
+				$sMethod = 'action' . $this->getClassName($sAction);
+				if(method_exists($this, $sMethod))
+					$aResult = $this->$sMethod();
+		}
+
+		echo json_encode($aResult);
+		exit;
+	}
+
     protected function getSystemName($sValue)
     protected function getSystemName($sValue)
     {
     {
         return str_replace(' ', '_', strtolower($sValue));
         return str_replace(' ', '_', strtolower($sValue));

+ 28 - 25
studio/classes/BxDolStudioNavigation.php

@@ -29,32 +29,35 @@ class BxDolStudioNavigation extends BxTemplStudioPage
         $this->sPage = BX_DOL_STUDIO_NAV_TYPE_DEFAULT;
         $this->sPage = BX_DOL_STUDIO_NAV_TYPE_DEFAULT;
         if(is_string($sPage) && !empty($sPage))
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
             $this->sPage = $sPage;
-
-        //--- Check actions ---//
-        if(($sAction = bx_get('nav_action')) !== false) {
-            $sAction = bx_process_input($sAction);
-
-            $aResult = array('code' => 1, 'message' => _t('_adm_nav_err_cannot_process_action'));
-            switch($sAction) {
-                case 'get-page-by-type':
-                    $sValue = bx_process_input(bx_get('nav_value'));
-                    if(empty($sValue))
-                        break;
-
-                    $this->sPage = $sValue;
-                    $aResult = array('code' => 0, 'content' => $this->getPageCode());
-                    break;
-
-                default:
-                    $sMethod = 'action' . $this->getClassName($sAction);
-                    if(method_exists($this, $sMethod))
-                        $aResult = $this->$sMethod();
-            }
-
-            echo json_encode($aResult);
-            exit;
-        }
     }
     }
+
+    public function init()
+	{
+        if(($sAction = bx_get('nav_action')) === false) 
+        	return;
+
+		$sAction = bx_process_input($sAction);
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_nav_err_cannot_process_action'));
+		switch($sAction) {
+			case 'get-page-by-type':
+				$sValue = bx_process_input(bx_get('nav_value'));
+				if(empty($sValue))
+					break;
+
+				$this->sPage = $sValue;
+				$aResult = array('code' => 0, 'content' => $this->getPageCode());
+				break;
+
+			default:
+				$sMethod = 'action' . $this->getClassName($sAction);
+				if(method_exists($this, $sMethod))
+					$aResult = $this->$sMethod();
+		}
+
+		echo json_encode($aResult);
+		exit;
+	}
 }
 }
 
 
 /** @} */
 /** @} */

+ 23 - 20
studio/classes/BxDolStudioPermissions.php

@@ -28,27 +28,30 @@ class BxDolStudioPermissions extends BxTemplStudioPage
         $this->sPage = BX_DOL_STUDIO_PRM_TYPE_DEFAULT;
         $this->sPage = BX_DOL_STUDIO_PRM_TYPE_DEFAULT;
         if(is_string($sPage) && !empty($sPage))
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
             $this->sPage = $sPage;
-
-        //--- Check actions ---//
-        if(($sAction = bx_get('pgt_action')) !== false) {
-            $sAction = bx_process_input($sAction);
-
-            $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
-            switch($sAction) {
-                case 'get-page-by-type':
-                    $sValue = bx_process_input(bx_get('pgt_value'));
-                    if(empty($sValue))
-                        break;
-
-                    $this->sPage = $sValue;
-                    $aResult = array('code' => 0, 'content' => $this->getPageCode());
-                    break;
-            }
-
-            echo json_encode($aResult);
-            exit;
-        }
     }
     }
+
+    public function init()
+	{
+		if(($sAction = bx_get('pgt_action')) === false)
+			return;
+
+		$sAction = bx_process_input($sAction);
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
+		switch($sAction) {
+			case 'get-page-by-type':
+				$sValue = bx_process_input(bx_get('pgt_value'));
+				if(empty($sValue))
+					break;
+
+				$this->sPage = $sValue;
+				$aResult = array('code' => 0, 'content' => $this->getPageCode());
+				break;
+		}
+
+		echo json_encode($aResult);
+		exit;
+	}
 }
 }
 
 
 /** @} */
 /** @} */

+ 55 - 52
studio/classes/BxDolStudioPolyglot.php

@@ -29,59 +29,62 @@ class BxDolStudioPolyglot extends BxTemplStudioPage
         $this->sPage = BX_DOL_STUDIO_PGT_TYPE_DEFAULT;
         $this->sPage = BX_DOL_STUDIO_PGT_TYPE_DEFAULT;
         if(is_string($sPage) && !empty($sPage))
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
             $this->sPage = $sPage;
+    }
 
 
-        //--- Check actions ---//
-        if(($sAction = bx_get('pgt_action')) !== false) {
-            $sAction = bx_process_input($sAction);
-
-            bx_import('BxDolStudioLanguagesUtils');
-            $oLanguages = BxDolStudioLanguagesUtils::getInstance();
-
-            $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
-            switch($sAction) {
-                case 'get-page-by-type':
-                    $sValue = bx_process_input(bx_get('pgt_value'));
-                    if(empty($sValue))
-                        break;
-
-                    $this->sPage = $sValue;
-                    $aResult = array('code' => 0, 'content' => $this->getPageCode());
-                    break;
-
-                /*
-                 * Available URL params:
-                 * pgt_action = recompile - action name
-                 * pgt_language - ID or name(en, ru, etc) of language.
-                 */
-                case 'recompile':
-                    $sLanguage = bx_process_input(bx_get('pgt_language'));
-
-                    if($oLanguages->compileLanguage($sLanguage))
-                        $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
-                    else
-                        $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
-                    break;
-
-                /*
-                 * Available URL params:
-                 * pgt_action = restore - action name
-                 * pgt_language - ID or name(en, ru, etc) of language.
-                 * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
-                 */
-                case 'restore':
-                    $sLanguage = bx_process_input(bx_get('pgt_language'));
-                    $sModule = bx_process_input(bx_get('pgt_module'));
-
-                    if($oLanguages->restoreLanguage($sLanguage, $sModule))
-                        $aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
-                    else
-                        $aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
-                    break;
-            }
-
-            echo json_encode($aResult);
-            exit;
-        }
+    public function init()
+    {
+        if(($sAction = bx_get('pgt_action')) === false) 
+        	return;
+
+		$sAction = bx_process_input($sAction);
+
+		bx_import('BxDolStudioLanguagesUtils');
+		$oLanguages = BxDolStudioLanguagesUtils::getInstance();
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
+		switch($sAction) {
+			case 'get-page-by-type':
+				$sValue = bx_process_input(bx_get('pgt_value'));
+				if(empty($sValue))
+					break;
+
+				$this->sPage = $sValue;
+				$aResult = array('code' => 0, 'content' => $this->getPageCode());
+				break;
+
+			/*
+			 * Available URL params:
+			 * pgt_action = recompile - action name
+			 * pgt_language - ID or name(en, ru, etc) of language.
+			 */
+			case 'recompile':
+				$sLanguage = bx_process_input(bx_get('pgt_language'));
+
+				if($oLanguages->compileLanguage($sLanguage))
+					$aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_recompiled'));
+				else
+					$aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_recompile_lang'));
+				break;
+
+			/*
+			 * Available URL params:
+			 * pgt_action = restore - action name
+			 * pgt_language - ID or name(en, ru, etc) of language.
+			 * pgt_module - ID or Module Uri (@see sys_modules table). Leave empty for 'System' language file.
+			 */
+			case 'restore':
+				$sLanguage = bx_process_input(bx_get('pgt_language'));
+				$sModule = bx_process_input(bx_get('pgt_module'));
+
+				if($oLanguages->restoreLanguage($sLanguage, $sModule))
+					$aResult = array('code' => 0, 'content' => _t('_adm_pgt_scs_restored'));
+				else
+					$aResult = array('code' => 2, 'content' => _t('_adm_pgt_err_cannot_restore_lang'));
+				break;
+		}
+
+		echo json_encode($aResult);
+		exit;
     }
     }
 }
 }
 
 

+ 1 - 0
studio/polyglot.php

@@ -20,6 +20,7 @@ $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 
 
 bx_import('BxTemplStudioPolyglot');
 bx_import('BxTemplStudioPolyglot');
 $oPage = new BxTemplStudioPolyglot($sPage);
 $oPage = new BxTemplStudioPolyglot($sPage);
+$oPage->init();
 
 
 bx_import('BxDolStudioTemplate');
 bx_import('BxDolStudioTemplate');
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate = BxDolStudioTemplate::getInstance();

+ 9 - 7
studio/template/scripts/BxBaseStudioForms.php

@@ -13,19 +13,21 @@ bx_import('BxDolStudioForms');
 class BxBaseStudioForms extends BxDolStudioForms
 class BxBaseStudioForms extends BxDolStudioForms
 {
 {
     protected $sSubpageUrl;
     protected $sSubpageUrl;
-    protected $aGridObjects = array(
-        'forms' => 'sys_studio_forms',
-        'displays' => 'sys_studio_forms_displays',
-        'fields' => 'sys_studio_forms_fields',
-        'pre_lists' => 'sys_studio_forms_pre_lists',
-        'pre_values' => 'sys_studio_forms_pre_values'
-    );
+    protected $aGridObjects;
 
 
     function __construct($sPage = '')
     function __construct($sPage = '')
     {
     {
         parent::__construct($sPage);
         parent::__construct($sPage);
 
 
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_forms.php?page=';
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_forms.php?page=';
+
+        $this->aGridObjects = array(
+	        'forms' => 'sys_studio_forms',
+	        'displays' => 'sys_studio_forms_displays',
+	        'fields' => 'sys_studio_forms_fields',
+	        'pre_lists' => 'sys_studio_forms_pre_lists',
+	        'pre_values' => 'sys_studio_forms_pre_values'
+    	);
     }
     }
     function getPageCss()
     function getPageCss()
     {
     {

+ 7 - 5
studio/template/scripts/BxBaseStudioNavigation.php

@@ -13,17 +13,19 @@ bx_import('BxDolStudioNavigation');
 class BxBaseStudioNavigation extends BxDolStudioNavigation
 class BxBaseStudioNavigation extends BxDolStudioNavigation
 {
 {
     protected $sSubpageUrl;
     protected $sSubpageUrl;
-    protected $aGridObjects = array(
-        'menus' => 'sys_studio_nav_menus',
-        'sets' => 'sys_studio_nav_sets',
-        'items' => 'sys_studio_nav_items'
-    );
+    protected $aGridObjects;
 
 
     function __construct($sPage = '')
     function __construct($sPage = '')
     {
     {
         parent::__construct($sPage);
         parent::__construct($sPage);
 
 
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_menu.php?page=';
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'builder_menu.php?page=';
+
+        $this->aGridObjects = array(
+	        'menus' => 'sys_studio_nav_menus',
+	        'sets' => 'sys_studio_nav_sets',
+	        'items' => 'sys_studio_nav_items'
+	    );
     }
     }
     function getPageCss()
     function getPageCss()
     {
     {

+ 13 - 9
studio/template/scripts/BxBaseStudioPolyglot.php

@@ -13,21 +13,25 @@ bx_import('BxDolStudioPolyglot');
 class BxBaseStudioPolyglot extends BxDolStudioPolyglot
 class BxBaseStudioPolyglot extends BxDolStudioPolyglot
 {
 {
     protected $sSubpageUrl;
     protected $sSubpageUrl;
-    protected $aMenuItems = array(
-        BX_DOL_STUDIO_PGT_TYPE_SETTINGS => array('icon' => 'cogs'),
-        BX_DOL_STUDIO_PGT_TYPE_KEYS => array('icon' => 'key'),
-        BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES => array('icon' => 'envelope-o')
-    );
-    protected $aGridObjects = array(
-        'keys' => 'sys_studio_lang_keys',
-        'etemplates' => 'sys_studio_lang_etemplates',
-    );
+    protected $aMenuItems;
+    protected $aGridObjects;
 
 
     function __construct($sPage = '')
     function __construct($sPage = '')
     {
     {
         parent::__construct($sPage);
         parent::__construct($sPage);
 
 
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'polyglot.php?page=';
         $this->sSubpageUrl = BX_DOL_URL_STUDIO . 'polyglot.php?page=';
+
+		$this->aMenuItems = array(
+	        BX_DOL_STUDIO_PGT_TYPE_SETTINGS => array('icon' => 'cogs'),
+	        BX_DOL_STUDIO_PGT_TYPE_KEYS => array('icon' => 'key'),
+	        BX_DOL_STUDIO_PGT_TYPE_ETEMPLATES => array('icon' => 'envelope-o')
+	    );
+
+		$this->aGridObjects = array(
+        	'keys' => 'sys_studio_lang_keys',
+        	'etemplates' => 'sys_studio_lang_etemplates',
+    );
     }
     }
     function getPageCss()
     function getPageCss()
     {
     {