AntonLV 12 лет назад
Родитель
Сommit
0196fba09b

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

@@ -407,6 +407,7 @@
 	<string name="_adm_block_cpt_downloaded_modules"><![CDATA[Modules]]></string>
 	<string name="_adm_block_cpt_downloaded_updates"><![CDATA[Updates]]></string>
 	<string name="_adm_block_cpt_featured"><![CDATA[Featured]]></string>
+	<string name="_adm_block_cpt_goodies"><![CDATA[Storefront]]></string>
 	<string name="_adm_block_cpt_languages"><![CDATA[Languages]]></string>
 	<string name="_adm_block_cpt_last_featured"><![CDATA[Latest Featured]]></string>
 	<string name="_adm_block_cpt_last_languages"><![CDATA[Latest Languages]]></string>

+ 8 - 8
studio/classes/BxDolStudioInstallerUtils.php

@@ -65,6 +65,14 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
     	return $this->perform($sDirectory, $sOperation, array_merge($aParams, array('transient' => true)));
     }
 
+    public function getAccessObject($bAuthorizedAccess)
+    {
+    	$sClass = $bAuthorizedAccess ? $this->sAuthorizedAccessClass : 'BxDolStudioJson';
+
+		bx_import($sClass);
+		return $sClass::getInstance();
+    }
+
     public function getModules($bTitleAsKey = true)
     {
         $aModules = array();
@@ -514,14 +522,6 @@ class BxDolStudioInstallerUtils extends BxDolInstallerUtils implements iBxDolSin
 			'conclusion' => strip_tags($sMessage),
 		));
     }
-
-    private function getAccessObject($bAuthorizedAccess)
-    {
-    	$sClass = $bAuthorizedAccess ? $this->sAuthorizedAccessClass : 'BxDolStudioJson';
-
-		bx_import($sClass);
-		return $sClass::getInstance();
-    }
 }
 
 /** @} */

+ 9 - 0
studio/classes/BxDolStudioOAuth.php

@@ -68,6 +68,15 @@ class BxDolStudioOAuth extends BxDol
         return $aItems;
     }
 
+    public function doAuthorize()
+    {
+    	if(empty($this->sKey) || empty($this->sSecret))
+            return _t('_adm_err_oauth_empty_key_secret');
+
+        return $this->authorize($this->sKey, $this->sSecret);
+    }
+    
+
     protected function isAuthorized()
     {
         return self::isAuthorizedClient();

+ 50 - 35
studio/template/scripts/BxBaseStudioStore.php

@@ -97,27 +97,37 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $aProducts = $this->loadGoodies();
-
-        $aTmplVars = array(
+		$aTmplVars = array(
             'js_object' => $sJsObject,
             'bx_repeat:blocks' => array()
         );
 
-        $sActions = "";
-        foreach($aProducts as $aBlock) {
-            $sItems = $oTemplate->parseHtmlByName('str_products.html', array(
-                'list' => $this->displayProducts($aBlock['items']),
-                'paginate' => ''
-            ));
-
-            $aTmplVars['bx_repeat:blocks'][] = array(
-                'caption' => $this->getBlockCaption($aBlock),
+        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        if($mixedResult === true) {
+	        $aProducts = $this->loadGoodies();
+
+	        $sActions = "";
+	        foreach($aProducts as $aBlock) {
+	            $sItems = $oTemplate->parseHtmlByName('str_products.html', array(
+	                'list' => $this->displayProducts($aBlock['items']),
+	                'paginate' => ''
+	            ));
+
+	            $aTmplVars['bx_repeat:blocks'][] = array(
+	                'caption' => $this->getBlockCaption($aBlock),
+	                'panel_top' => '',
+	                'items' => $sItems,
+	                'panel_bottom' => ''
+	            );
+	        }
+        }
+        else 
+        	$aTmplVars['bx_repeat:blocks'][] = array(
+                'caption' => $this->getBlockCaption(array('caption' => _t('_adm_block_cpt_goodies'), 'actions' => array())),
                 'panel_top' => '',
-                'items' => $sItems,
+                'items' => $mixedResult,
                 'panel_bottom' => ''
             );
-        }
 
         return $oTemplate->parseHtmlByName('store.html', $aTmplVars);
     }
@@ -127,28 +137,33 @@ class BxBaseStudioStore extends BxDolStudioStore
         $sJsObject = $this->getPageJsObject();
         $oTemplate = BxDolStudioTemplate::getInstance();
 
-        $iStart = (int)bx_get('str_start');
-        $iPerPage = (int)bx_get('str_per_page');
-        if(empty($iPerPage))
-            $iPerPage = $this->iPerPageDefault;
-
-        $aProducts = $this->loadFeatured($iStart, $iPerPage + 1);
-
-        bx_import('BxTemplPaginate');
-        $oPaginate = new BxTemplPaginate(array(
-            'start' => $iStart,
-            'per_page' => $iPerPage,
-            'on_change_page' => $sJsObject . ".changePagePaginate(this, 'featured', {start}, {per_page})"
-        ));
-        $oPaginate->setNumFromDataArray($aProducts);
-
-        $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
-            'list' => $this->displayProducts($aProducts),
-            'paginate' => $oPaginate->getSimplePaginate()
-        ));
+        $mixedResult = BxDolStudioInstallerUtils::getInstance()->getAccessObject(true)->doAuthorize();
+        if($mixedResult === true) {
+	        $iStart = (int)bx_get('str_start');
+	        $iPerPage = (int)bx_get('str_per_page');
+	        if(empty($iPerPage))
+	            $iPerPage = $this->iPerPageDefault;
+
+	        $aProducts = $this->loadFeatured($iStart, $iPerPage + 1);
+
+	        bx_import('BxTemplPaginate');
+	        $oPaginate = new BxTemplPaginate(array(
+	            'start' => $iStart,
+	            'per_page' => $iPerPage,
+	            'on_change_page' => $sJsObject . ".changePagePaginate(this, 'featured', {start}, {per_page})"
+	        ));
+	        $oPaginate->setNumFromDataArray($aProducts);
+
+	        $sContent = $oTemplate->parseHtmlByName('str_products.html', array(
+	            'list' => $this->displayProducts($aProducts),
+	            'paginate' => $oPaginate->getSimplePaginate()
+	        ));
+        }
+        else 
+        	$sContent = $mixedResult;
 
-        if(!$bWrapInBlock)
-            return $sContent;
+		if(!$bWrapInBlock)
+			return $sContent;
 
         return $oTemplate->parseHtmlByName('store.html', array(
             'js_object' => $sJsObject,