diff --git a/app/appadmin/modules/Config/block/base/Manager.php b/app/appadmin/modules/Config/block/base/Manager.php index 6b008c7d5..8e6286aad 100644 --- a/app/appadmin/modules/Config/block/base/Manager.php +++ b/app/appadmin/modules/Config/block/base/Manager.php @@ -31,9 +31,9 @@ class Manager extends AppadminbaseBlockEdit implements AppadminbaseBlockEditInte 'default_currency', 'base_currency', 'image_domain', - + ]; - + public function init() { // 需要配置 @@ -48,32 +48,33 @@ 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) { @@ -81,19 +82,19 @@ public function getEditArr() } } // 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, @@ -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 { @@ -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. */ @@ -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 ''; } -} \ No newline at end of file +} diff --git a/models/mysqldb/AdminUser.php b/models/mysqldb/AdminUser.php index 01986e810..a02ef18f7 100644 --- a/models/mysqldb/AdminUser.php +++ b/models/mysqldb/AdminUser.php @@ -32,6 +32,7 @@ * @property string $created_at_datetime * @property string $updated_at_datetime * @property string $birth_date + * * @author Terry Zhao <2358269014@qq.com> * @since 1.0 */ diff --git a/services/Store.php b/services/Store.php index 8b4d5b4a3..11a6aac1c 100644 --- a/services/Store.php +++ b/services/Store.php @@ -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() { @@ -82,7 +82,7 @@ public function isApiStore() return false; } } - + public function isAppserver() { $appServerArr = ['appserver']; @@ -90,7 +90,7 @@ public function isAppserver() if (in_array($currentAppName, $appServerArr)) { return true; } - + return false; } @@ -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)) { @@ -166,7 +166,7 @@ public function initCurrentStoreConfig() } } } - + return true; } // 如果入口是appserver,那么通过这个函数初始化 @@ -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) { @@ -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']; @@ -281,7 +281,7 @@ protected function actionBootstrap($app) } } } - + } //if (isset($headers['fecshop-currency']) && $headers['fecshop-currency']) { // $currentC = Yii::$service->page->currency->getCurrentCurrency(); @@ -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'); } @@ -395,7 +395,7 @@ public function isAppServerMobile() } } } - + return false; } diff --git a/services/cms/StaticBlock.php b/services/cms/StaticBlock.php index d1742424d..c8a9377a5 100644 --- a/services/cms/StaticBlock.php +++ b/services/cms/StaticBlock.php @@ -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(); diff --git a/services/page/Widget.php b/services/page/Widget.php index a60163f25..527ebef1d 100644 --- a/services/page/Widget.php +++ b/services/page/Widget.php @@ -60,7 +60,7 @@ protected function actionRender($configKey, $parentThis = '') $configKey = ''; } else if ($configKey){ $configArr = explode('/', $configKey); - + if (count($configArr) < 2 ) { throw new InvalidValueException(" config key: '$configKey', format: `xxxx/xxxx`, you must config it with correct format"); } @@ -102,15 +102,15 @@ protected function actionDiRender($configKey, $diConfig = []) if (!is_array($diConfig)) { throw new InvalidValueException(" configParent: '$diConfig' must be array"); } - // - + // + $config = ''; if (is_array($configKey)) { $config = $configKey; $configKey = ''; } else if ($configKey){ $configArr = explode('/', $configKey); - + if (count($configArr) < 2 ) { throw new InvalidValueException(" config key: '$configKey', format: `xxxx/xxxx`, you must config it with correct format"); } @@ -126,7 +126,7 @@ protected function actionDiRender($configKey, $diConfig = []) foreach ($diConfig as $k=>$v) { $config [$k] = $v; } - + return $this->renderContent($configKey, $config); } @@ -167,14 +167,14 @@ protected function actionRenderContentHtml($configKey, $config, $parentThis = '' return Yii::$app->view->renderFile($viewFile, $params); } - + public $_cache_arr = [ 'head' => 'headBlockCache', 'header' => 'headerBlockCache', 'menu' => 'menuBlockCache', 'footer' => 'footerBlockCache', ]; - + /** * @param $configKey | string , 标记,以及报错排查时使用的key。 * @param $config,就是上面actionRender()方法中的参数,格式一样。 @@ -185,13 +185,13 @@ protected function actionRenderContent($configKey, $config, $parentThis = '') { // 从配置中读取cache的enable状态 $cacheEnable = false; - $cacheConfigKey = $this->_cache_arr[$configKey]; + $cacheConfigKey = isset($this->_cache_arr[$configKey]) ? $this->_cache_arr[$configKey] : null; $appName = Yii::$service->helper->getAppName(); $cacheConfig = Yii::$app->store->get($appName.'_cache'); if ($cacheConfigKey && isset($cacheConfig[$cacheConfigKey]) && $cacheConfig[$cacheConfigKey] == Yii::$app->store->enable) { $cacheEnable = true; } - if ($cacheEnable) { + if ($cacheEnable) { if (!isset($config['class']) || !$config['class']) { throw new InvalidConfigException('in widget ['.$configKey.'],you enable cache ,you must config widget class .'); } elseif ($ob = new $config['class']()) { diff --git a/services/url/rewrite/RewriteMysqldb.php b/services/url/rewrite/RewriteMysqldb.php index eeae5652d..b3a80d11c 100644 --- a/services/url/rewrite/RewriteMysqldb.php +++ b/services/url/rewrite/RewriteMysqldb.php @@ -29,11 +29,11 @@ class RewriteMysqldb extends Service implements RewriteInterface protected $_lang_attr = [ ]; - + protected $_urlRewriteModelName = '\fecshop\models\mysqldb\url\UrlRewrite'; protected $_urlRewriteModel; - + public function init() { parent::init(); @@ -49,7 +49,7 @@ public function getOriginUrl($urlKey) $UrlData = $this->_urlRewriteModel->find()->where([ 'custom_url_key' => $urlKey, ])->asArray()->one(); - if ($UrlData['custom_url_key']) { + if ($UrlData) { return $UrlData['origin_url']; } }