Skip to content

Commit

Permalink
修复获取第三方登录时,未定义时取值问题
Browse files Browse the repository at this point in the history
修复url重写查找失败时,值判断错误
修复一个缓存读取Key错误
  • Loading branch information
yanlong-li committed Jan 20, 2020
1 parent d6c95be commit 2875548
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 74 deletions.
87 changes: 43 additions & 44 deletions app/appadmin/modules/Config/block/base/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class Manager extends AppadminbaseBlockEdit implements AppadminbaseBlockEditInte
'default_currency',
'base_currency',
'image_domain',

];

public function init()
{
// 需要配置
Expand All @@ -48,52 +48,53 @@ public function init()
$this->_one['value'] = unserialize($this->_one['value']);
}
}





// 传递给前端的数据 显示编辑form
public function getLastData()
{
$id = '';
$id = '';
if (isset($this->_one['id'])) {
$id = $this->_one['id'];
}
$id = $this->_one['id'];
}
return [
'id' => $id,
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
'id' => $id,
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
}

public function setService()
{
$this->_service = Yii::$service->storeBaseConfig;
}

public function getEditArr()
{
// language
$langArr = [];
$langArr = [];
$mutilLangs = Yii::$app->store->get('mutil_lang');
if (is_array($mutilLangs)) {
foreach ($mutilLangs as $lang) {
$langArr[$lang['lang_code']] = $lang['lang_name'];
}
}
// currency
$currencyArr = [];
$currencyArr = [];
$currencys = Yii::$app->store->get('currency');
if (is_array($currencys)) {
foreach ($currencys as $currency) {
$currencyArr[$currency['currency_code']] = $currency['currency_code'];
}
}

return [
// 需要配置
[
'label' => Yii::$service->page->translate->__('Default Base Lang'),
'name' => 'default_lang',
'name' => 'default_lang',
'display' => [
'type' => 'select',
'data' => $langArr,
Expand All @@ -102,45 +103,43 @@ public function getEditArr()
],
[
'label' => Yii::$service->page->translate->__('Base Currency'),
'name' => 'base_currency',
'name' => 'base_currency',
'display' => [
'type' => 'select',
'data' => $currencyArr,
],
'remark' => '基础货币,产品数据后台编辑的货币'
],

[
'label' => Yii::$service->page->translate->__('Default Currency'),
'name' => 'default_currency',
'name' => 'default_currency',
'display' => [
'type' => 'select',
'data' => $currencyArr,
],
'remark' => '默认的货币,如果store中没有设置货币,那么将使用默认货币'
],



[
[
'label' => Yii::$service->page->translate->__('Image Domain'),
'name' => 'image_domain',
'name' => 'image_domain',
'display' => [
'type' => 'inputString',
],
'require' => 1,
'remark' => '图片的域名'
'remark' => '图片的域名,指向 appimage/ 目录的地址,或 OSS 的地址'
],

];
}

public function getArrParam(){

public function getArrParam()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
$param = [];
$attrVals = [];
foreach($this->_param as $attr => $val) {
foreach ($this->_param as $attr => $val) {
if (in_array($attr, $this->_attrArr)) {
$attrVals[$attr] = $val;
} else {
Expand All @@ -149,10 +148,10 @@ public function getArrParam(){
}
$param['value'] = $attrVals;
$param['key'] = $this->_key;

return $param;
}

/**
* save article data, get rewrite url and save to article url key.
*/
Expand All @@ -166,33 +165,33 @@ public function save()
$this->_service->saveConfig($this->getArrParam());
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} else {
echo json_encode([
echo json_encode([
'statusCode' => '300',
'message' => $errors,
'message' => $errors,
]);
exit;
}
}

public function getVal($name, $column){


public function getVal($name, $column)
{
if (is_object($this->_one) && property_exists($this->_one, $name) && $this->_one[$name]) {

return $this->_one[$name];
}
$content = $this->_one['value'];
if (is_array($content) && !empty($content) && isset($content[$name])) {

return $content[$name];
}

return '';
}
}
}
1 change: 1 addition & 0 deletions models/mysqldb/AdminUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @property string $created_at_datetime
* @property string $updated_at_datetime
* @property string $birth_date
*
* @author Terry Zhao <[email protected]>
* @since 1.0
*/
Expand Down
34 changes: 17 additions & 17 deletions services/Store.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,18 @@ class Store extends Service
public $thirdLogin;

//public $https;

public $serverLangs;

public $apiAppNameArr = ['appserver','appapi'];

public function init()
{
parent::init();

$this->initCurrentStoreConfig();
}

// 是否是api入口
public function isApiStore()
{
Expand All @@ -82,15 +82,15 @@ public function isApiStore()
return false;
}
}

public function isAppserver()
{
$appServerArr = ['appserver'];
$currentAppName = $this->getCurrentAppName();
if (in_array($currentAppName, $appServerArr)) {
return true;
}

return false;
}

Expand All @@ -107,7 +107,7 @@ public function initCurrentStoreConfig()
{
$currentAppName = $this->getCurrentAppName();
if ($this->isAppserver()) {
return $this->initAppserverCurrentStoreConfig();
return $this->initAppserverCurrentStoreConfig();
}
$coll = Yii::$service->storeDomain->getCollByAppName($currentAppName);
if (is_array($coll)) {
Expand Down Expand Up @@ -166,7 +166,7 @@ public function initCurrentStoreConfig()
}
}
}

return true;
}
// 如果入口是appserver,那么通过这个函数初始化
Expand Down Expand Up @@ -208,16 +208,16 @@ public function initAppserverCurrentStoreConfig()
$this->stores[$storeKey]['serverLangs'] = Yii::$app->store->get('appserver_store_lang');
// 通过该方法,初始化货币services,直接从headers中取出来currency。进行set,这样currency就不会从session中读取(fecshop-2版本对于appserver已经抛弃session servcies)
Yii::$service->page->currency->appserverSetCurrentCurrency();

return true;
}

/**
* Bootstrap:init website, class property $currentLang ,$currentTheme and $currentStore.
* if you not config this ,default class property will be set.
* if current store_code is not config , InvalidValueException will be throw.
* class property $currentStore will be set value $store_code.
* @param $app
* @param \yii\web\Application $app
*/
protected function actionBootstrap($app)
{
Expand Down Expand Up @@ -260,9 +260,9 @@ protected function actionBootstrap($app)
* current domain is config is store config.
*/
$init_complete = 1;
$this->thirdLogin = $store['thirdLogin'];
$this->thirdLogin = isset($store['thirdLogin']) ? $store['thirdLogin'] : [];
/**
* appserver 部分
* appserver 部分
*/
if (isset($store['serverLangs']) && !empty($store['serverLangs'])) {
$this->serverLangs = $store['serverLangs'];
Expand All @@ -281,7 +281,7 @@ protected function actionBootstrap($app)
}
}
}

}
//if (isset($headers['fecshop-currency']) && $headers['fecshop-currency']) {
// $currentC = Yii::$service->page->currency->getCurrentCurrency();
Expand All @@ -293,7 +293,7 @@ protected function actionBootstrap($app)
}
}
}

if (!$init_complete) {
throw new InvalidValueException('this domain is not config in store service, you must config it in admin store config');
}
Expand Down Expand Up @@ -395,7 +395,7 @@ public function isAppServerMobile()
}
}
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion services/cms/StaticBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function init()
protected function actionGetStoreContentByIdentify($identify, $app = 'common')
{
$staticBlock = $this->_static_block->getByIdentify($identify);
$content = $staticBlock['content'];
$content = isset($staticBlock['content'])?$staticBlock['content']:'';
$storeContent = Yii::$service->store->getStoreAttrVal($content, 'content');
$_params_ = $this->getStaticBlockVariableArr($app);
ob_start();
Expand Down
Loading

0 comments on commit 2875548

Please sign in to comment.