diff --git a/app/appadmin/modules/Catalog/block/category/Index.php b/app/appadmin/modules/Catalog/block/category/Index.php index 8b72dc5f72986a3cc911e6796cd78ae9e7ffd561..486d3e9c26d8373b6b51ae8e3b5047f00f053096 100644 --- a/app/appadmin/modules/Catalog/block/category/Index.php +++ b/app/appadmin/modules/Catalog/block/category/Index.php @@ -252,6 +252,20 @@ class Index extends AppadminbaseBlockEdit implements AppadminbaseBlockEditInterf 'require' => 1, 'default' => 1, ], + + [ + 'label'=>'Menu是否显示', + 'name'=>'menu_show', + 'display'=>[ + 'type' => 'select', + 'data' => [ + 1 => '菜单中显示', + 2 => '菜单中不显示', + ], + ], + 'require' => 1, + 'default' => 1, + ], [ 'label'=>'Url Key', diff --git a/app/appfront/modules/Catalog/block/category/Index.php b/app/appfront/modules/Catalog/block/category/Index.php index 46e132cad5e040e0cdfbd700f646c51979c594b3..6de4102c75269c7bb5cf8e863617ae99e812075c 100644 --- a/app/appfront/modules/Catalog/block/category/Index.php +++ b/app/appfront/modules/Catalog/block/category/Index.php @@ -53,8 +53,11 @@ class Index // 这样是为了防止恶意攻击,也就是发送很多不同的页面个数的链接,绕开缓存。 $this->getNumPerPage(); //echo Yii::$service->page->translate->__('fecshop,{username}', ['username' => 'terry']); - $this->initCategory(); - + if(!$this->initCategory()){ + Yii::$service->url->redirect404(); + return; + } + // change current layout File. //Yii::$service->page->theme->layoutFile = 'home.php'; @@ -471,6 +474,16 @@ class Index $primaryVal = Yii::$app->request->get($primaryKey); $this->_primaryVal = $primaryVal; $category = Yii::$service->category->getByPrimaryKey($primaryVal); + if ($category) { + $enableStatus = Yii::$service->category->getCategoryEnableStatus(); + if ($category['status'] != $enableStatus){ + + return false; + } + } else { + + return false; + } $this->_category = $category; Yii::$app->view->registerMetaTag([ 'name' => 'keywords', @@ -486,6 +499,7 @@ class Index $this->_title = $this->_title ? $this->_title : $name; Yii::$app->view->title = $this->_title; $this->_where = $this->initWhere(); + return true; } // 面包屑导航 diff --git a/app/appfront/modules/Catalog/controllers/CategoryController.php b/app/appfront/modules/Catalog/controllers/CategoryController.php index 67c69415dd3c91208fcc74b6e0b676feb887d686..1e1969762b8896f940b6531b43b8e1e6f0e7fc55 100644 --- a/app/appfront/modules/Catalog/controllers/CategoryController.php +++ b/app/appfront/modules/Catalog/controllers/CategoryController.php @@ -24,12 +24,13 @@ class CategoryController extends AppfrontController Yii::$service->page->theme->layoutFile = 'category_view.php'; } - // 网站信息管理 + // 分类页面。 public function actionIndex() { $data = $this->getBlock()->getLastData(); - - return $this->render($this->action->id, $data); + if(is_array($data)){ + return $this->render($this->action->id, $data); + } } /** * Yii2 behaviors 可以参看地址:http://www.yiichina.com/doc/guide/2.0/concept-behaviors diff --git a/app/apphtml5/modules/Catalog/block/category/Index.php b/app/apphtml5/modules/Catalog/block/category/Index.php index 2495d314f246cda60c2db7b18f4fda3d6a297eab..4deff79feee03f7d1106a2366804f56266fef320 100644 --- a/app/apphtml5/modules/Catalog/block/category/Index.php +++ b/app/apphtml5/modules/Catalog/block/category/Index.php @@ -54,7 +54,10 @@ class Index // 这样是为了防止恶意攻击,也就是发送很多不同的页面个数的链接,绕开缓存。 $this->getNumPerPage(); //echo Yii::$service->page->translate->__('fecshop,{username}', ['username' => 'terry']); - $this->initCategory(); + if(!$this->initCategory()){ + Yii::$service->url->redirect404(); + return; + } // change current layout File. //Yii::$service->page->theme->layoutFile = 'home.php'; @@ -483,6 +486,16 @@ class Index $primaryVal = Yii::$app->request->get($primaryKey); $this->_primaryVal = $primaryVal; $category = Yii::$service->category->getByPrimaryKey($primaryVal); + if ($category) { + $enableStatus = Yii::$service->category->getCategoryEnableStatus(); + if ($category['status'] != $enableStatus){ + + return false; + } + } else { + + return false; + } $this->_category = $category; Yii::$app->view->registerMetaTag([ 'name' => 'keywords', @@ -498,6 +511,7 @@ class Index $this->_title = $this->_title ? $this->_title : $name; Yii::$app->view->title = $this->_title; $this->_where = $this->initWhere(); + return true; } // 面包屑导航 diff --git a/app/apphtml5/modules/Catalog/controllers/CategoryController.php b/app/apphtml5/modules/Catalog/controllers/CategoryController.php index b3fb53550226a843c201d4d0fad5bc9678a597a9..3bcb6e25ea40bf07e6d177bad21b51ca036fe7f3 100644 --- a/app/apphtml5/modules/Catalog/controllers/CategoryController.php +++ b/app/apphtml5/modules/Catalog/controllers/CategoryController.php @@ -24,12 +24,13 @@ class CategoryController extends AppfrontController Yii::$service->page->theme->layoutFile = 'category_view.php'; } - // 网站信息管理 + // 分类页面。 public function actionIndex() { $data = $this->getBlock()->getLastData(); - - return $this->render($this->action->id, $data); + if(is_array($data)){ + return $this->render($this->action->id, $data); + } } public function behaviors() diff --git a/models/mongodb/Category.php b/models/mongodb/Category.php index b2589c175d6a7297409be725165461b52fe25567..f1eb014ae456086fc0dc57d68cc8040181b89bc1 100644 --- a/models/mongodb/Category.php +++ b/models/mongodb/Category.php @@ -17,6 +17,14 @@ use yii\mongodb\ActiveRecord; */ class Category extends ActiveRecord { + + + const MENU_SHOW = 1; + const MENU_NOT_SHOW = 2; + const STATUS_ENABLE = 1; + const STATUS_DISABLE = 2; + + /** * mongodb collection 的名字,相当于mysql的table name */ @@ -35,6 +43,7 @@ class Category extends ActiveRecord 'parent_id', 'name', 'status', + 'menu_show', 'url_key', 'level', 'thumbnail_image', diff --git a/services/Category.php b/services/Category.php index 3dbbbb5e6c78ccb66e74ae875345de35433d77ac..334e2080d3ce8e67b8ddcb7de952c0f6e90e7e1f 100644 --- a/services/Category.php +++ b/services/Category.php @@ -35,6 +35,18 @@ class Category extends Service //$this->_category = new CategoryMysqldb; } } + + + + protected function actionGetCategoryEnableStatus() + { + return $this->_category->getCategoryEnableStatus(); + } + + protected function actionGetCategoryMenuShowStatus() + { + return $this->_category->getCategoryMenuShowStatus(); + } /** * 得到当前的category service 对应的主键名称,譬如如果是mongo,返回的是 _id. diff --git a/services/Url.php b/services/Url.php index a8af3c17522864a93a337de2a8cb8f42e768e22d..360d7227dd4ec989aef18441004e1aebc5a47778 100644 --- a/services/Url.php +++ b/services/Url.php @@ -423,4 +423,13 @@ class Url extends Service //header("Location: $homeUrl"); } } + + protected function actionRedirect404() + { + $error404UrlKey = Yii::$app->errorHandler->errorAction; + $error404Url = $this->getUrl($error404UrlKey); + if ($error404Url) { + Yii::$app->getResponse()->redirect($error404Url)->send(); + } + } } diff --git a/services/category/CategoryMongodb.php b/services/category/CategoryMongodb.php index cb376ac7ab8e7bf58a8738b662719600af78f612..42dc2e0a95160d414bc0803b63667f41e03de380 100644 --- a/services/category/CategoryMongodb.php +++ b/services/category/CategoryMongodb.php @@ -27,7 +27,18 @@ class CategoryMongodb implements CategoryInterface { return '_id'; } - + /** + * 得到分类激活状态的值 + */ + public function getCategoryEnableStatus(){ + return Category::STATUS_ENABLE; + } + /** + * 得到分类在menu中显示的状态值 + */ + public function getCategoryMenuShowStatus(){ + return Category::MENU_SHOW; + } /** * 通过主键,得到Category对象。 */ @@ -112,7 +123,8 @@ class CategoryMongodb implements CategoryInterface } $model->updated_at = time(); unset($one['_id']); - + $one['status'] = (int)$one['status']; + $one['menu_show'] = (int)$one['menu_show']; $saveStatus = Yii::$service->helper->ar->save($model, $one); $originUrl = $originUrlKey.'?'.$this->getPrimaryKey() .'='. $primaryVal; $originUrlKey = isset($one['url_key']) ? $one['url_key'] : ''; diff --git a/services/category/Menu.php b/services/category/Menu.php index acd99827baf3b7ae24755472b9b0b92785fa2df6..fe1c09e0ce88e61e26e5a0816e3d0165370a61e3 100644 --- a/services/category/Menu.php +++ b/services/category/Menu.php @@ -26,6 +26,7 @@ class Menu extends Service */ protected function actionGetCategoryMenuArr($parentId = '') { + $arr = []; if (!$parentId) { $parentId = $this->rootCategoryId; @@ -34,6 +35,8 @@ class Menu extends Service '_id', 'parent_id', 'name', 'url_key', 'menu_custom', ])->where([ 'parent_id' => $parentId, + 'status' => Category::STATUS_ENABLE, + 'menu_show' => Category::MENU_SHOW, ])->all(); if (is_array($data) && !empty($data)) { foreach ($data as $category) { diff --git a/services/email/views/order/create/guest/body_en.php b/services/email/views/order/create/guest/body_en.php index 5dcb1c824c7c86bd50b3cb42bc627b2f44df57ba..c92d9dabc0898e7a2c5d29583533a9cb65d3008f 100644 --- a/services/email/views/order/create/guest/body_en.php +++ b/services/email/views/order/create/guest/body_en.php @@ -55,7 +55,7 @@ use fecshop\app\appfront\helper\Format;   -

PayPal -

+

diff --git a/services/email/views/order/create/logined/body_en.php b/services/email/views/order/create/logined/body_en.php index 700089e04a0fcbcbb6a954b545af07b1da13e7b6..ff67e504755f9e676dc54b4adb997f88e1db8517 100644 --- a/services/email/views/order/create/logined/body_en.php +++ b/services/email/views/order/create/logined/body_en.php @@ -55,7 +55,7 @@ use fecshop\app\appfront\helper\Format;   -

PayPal -

+