AntonLV 10 лет назад
Родитель
Сommit
8ac2d9af9a
3 измененных файлов с 51 добавлено и 17 удалено
  1. 49 15
      studio/classes/BxDolStudioLanguage.php
  2. 1 1
      studio/language.php
  3. 1 1
      studio/template/scripts/BxBaseStudioLanguage.php

+ 49 - 15
studio/classes/BxDolStudioLanguage.php

@@ -17,6 +17,8 @@ class BxDolStudioLanguage extends BxTemplStudioPage
     protected $sLanguage;
     protected $sLanguage;
     protected $aLanguage;
     protected $aLanguage;
 
 
+    protected $sManageUrl;
+    
     function __construct($sLanguage, $sPage)
     function __construct($sLanguage, $sPage)
     {
     {
         parent::__construct($sLanguage);
         parent::__construct($sLanguage);
@@ -31,24 +33,33 @@ class BxDolStudioLanguage extends BxTemplStudioPage
         if(is_string($sPage) && !empty($sPage))
         if(is_string($sPage) && !empty($sPage))
             $this->sPage = $sPage;
             $this->sPage = $sPage;
 
 
-        //--- Check actions ---//
-        if(($sAction = bx_get('lang_action')) !== false) {
-            $sAction = bx_process_input($sAction);
+        $this->sManageUrl = BX_DOL_URL_STUDIO . 'language.php?name=' . $this->sLanguage;
+    }
 
 
-            $aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
-            switch($sAction) {
-                case 'activate':
-                    $sValue = bx_process_input(bx_get('lang_value'));
-                    if(empty($sValue))
-                        break;
+    public static function getObjectInstance($sModule = "", $sPage = "", $bInit = true)
+	{
+	    $oModuleDb = BxDolModuleQuery::getInstance();
 
 
-                    $aResult = $this->activate($sValue);
-                    break;
-            }
+        $sClass = 'BxTemplStudioLanguage';
+	    if($sModule != '' && $oModuleDb->isModuleByName($sModule)) {
+	        $aModule = $oModuleDb->getModuleByName($sModule);
+
+	        if(file_exists(BX_DIRECTORY_PATH_MODULES . $aModule['path'] . 'classes/' . $aModule['class_prefix'] . 'StudioPage.php')) {
+	            bx_import('StudioPage', $aModule);
+	            $sClass = $aModule['class_prefix'] . 'StudioPage';
+	        }
+	    }
+
+	    $oObject = new $sClass($sModule, $sPage);
+	    if($bInit)
+	    	$oObject->init();
 
 
-            echo json_encode($aResult);
-            exit;
-        }
+	    return $oObject;
+	}
+
+    public function init()
+    {
+    	$this->checkAction();
 
 
         $this->aLanguage = BxDolModuleQuery::getInstance()->getModuleByName($this->sLanguage);
         $this->aLanguage = BxDolModuleQuery::getInstance()->getModuleByName($this->sLanguage);
         if(empty($this->aLanguage) || !is_array($this->aLanguage))
         if(empty($this->aLanguage) || !is_array($this->aLanguage))
@@ -66,6 +77,29 @@ class BxDolStudioLanguage extends BxTemplStudioPage
         ), false);
         ), false);
     }
     }
 
 
+	public function checkAction()
+    {
+    	$sAction = bx_get('lang_action');
+    	if($sAction === false)
+    		return;
+
+		$sAction = bx_process_input($sAction);
+
+		$aResult = array('code' => 1, 'message' => _t('_adm_pgt_err_cannot_process_action'));
+		switch($sAction) {
+		    case 'activate':
+                $sValue = bx_process_input(bx_get('lang_value'));
+                if(empty($sValue))
+                    break;
+
+                $aResult = $this->activate($sValue);
+                break;
+		}
+
+        echoJson($aResult);
+		exit;
+    }
+
     function activate($sLanguage)
     function activate($sLanguage)
     {
     {
         $aLanguage = BxDolModuleQuery::getInstance()->getModuleByName($sLanguage);
         $aLanguage = BxDolModuleQuery::getInstance()->getModuleByName($sLanguage);

+ 1 - 1
studio/language.php

@@ -23,7 +23,7 @@ $sName = $sName !== false ? bx_process_input($sName) : '';
 $sPage = bx_get('page');
 $sPage = bx_get('page');
 $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 $sPage = $sPage !== false ? bx_process_input($sPage) : '';
 
 
-$oPage = new BxTemplStudioLanguage($sName, $sPage);
+$oPage = BxDolStudioLanguage::getObjectInstance($sName, $sPage);
 
 
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate = BxDolStudioTemplate::getInstance();
 $oTemplate->setPageNameIndex($oPage->getPageIndex());
 $oTemplate->setPageNameIndex($oPage->getPageIndex());

+ 1 - 1
studio/template/scripts/BxBaseStudioLanguage.php

@@ -57,7 +57,7 @@ class BxBaseStudioLanguage extends BxDolStudioLanguage
             $aMenu[] = array(
             $aMenu[] = array(
                 'name' => $sName,
                 'name' => $sName,
                 'icon' => $aItem['icon'],
                 'icon' => $aItem['icon'],
-                'link' => BX_DOL_URL_STUDIO . 'languages.php?name=' . $this->sLanguage . '&page=' . $sName,
+                'link' => bx_append_url_params($this->sManageUrl, array('page' => $sName)),
                 'title' => _t($aItem['caption']),
                 'title' => _t($aItem['caption']),
                 'selected' => $sName == $this->sPage
                 'selected' => $sName == $this->sPage
             );
             );