Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
7038e3e0
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
18
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7038e3e0
编写于
7月 21, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
进一步优化重写机制:block层和models层
上级
1971354a
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
276 addition
and
70 deletion
+276
-70
app/appadmin/modules/AppadminController.php
app/appadmin/modules/AppadminController.php
+29
-0
app/appadmin/modules/Catalog/block/productinfo/Index.php
app/appadmin/modules/Catalog/block/productinfo/Index.php
+16
-5
app/appadmin/modules/Catalog/block/productinfo/Manageredit.php
...ppadmin/modules/Catalog/block/productinfo/Manageredit.php
+12
-2
app/appadmin/modules/Catalog/block/productinfo/index/Attr.php
...appadmin/modules/Catalog/block/productinfo/index/Attr.php
+13
-3
app/appapi/modules/AppapiController.php
app/appapi/modules/AppapiController.php
+3
-1
app/appfront/modules/AppfrontController.php
app/appfront/modules/AppfrontController.php
+3
-1
app/appfront/modules/Catalog/block/product/Index.php
app/appfront/modules/Catalog/block/product/Index.php
+19
-4
app/appfront/modules/Catalog/block/product/Review.php
app/appfront/modules/Catalog/block/product/Review.php
+13
-2
app/appfront/modules/Catalog/block/reviewproduct/Add.php
app/appfront/modules/Catalog/block/reviewproduct/Add.php
+12
-2
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
+13
-4
app/apphtml5/modules/AppfrontController.php
app/apphtml5/modules/AppfrontController.php
+3
-1
app/apphtml5/modules/Catalog/block/product/Index.php
app/apphtml5/modules/Catalog/block/product/Index.php
+17
-4
app/apphtml5/modules/Catalog/block/product/Review.php
app/apphtml5/modules/Catalog/block/product/Review.php
+13
-3
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
+13
-3
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
+12
-3
app/appserver/modules/AppserverController.php
app/appserver/modules/AppserverController.php
+3
-1
app/console/modules/ConsoleController.php
app/console/modules/ConsoleController.php
+3
-1
services/category/CategoryMongodb.php
services/category/CategoryMongodb.php
+40
-30
yii/Yii.php
yii/Yii.php
+39
-0
未找到文件。
app/appadmin/modules/AppadminController.php
浏览文件 @
7038e3e0
...
...
@@ -86,4 +86,33 @@ class AppadminController extends FecadminbaseController
}
throw
new
InvalidValueException
(
'layout file is not exist!'
);
}
public
function
getBlock
(
$blockname
=
''
){
$_currentNameSpace
=
\
fec\helpers\CModule
::
param
(
"_currentNameSpace"
);
//echo $_currentNameSpace;exit;
if
(
empty
(
$_currentNameSpace
)){
$message
=
"Modules Param '_currentNameSpace' is not set , you can set like fecadmin
\\
Module"
;
throw
new
\
yii\web\HttpException
(
406
,
$message
);
}
$modulesDir
=
"
\\
"
.
$_currentNameSpace
.
"
\\
block
\\
"
;
$url_key
=
\
fec\helpers\CUrl
::
getUrlKey
();
$url_key
=
trim
(
$url_key
,
"/"
);
$url_key
=
substr
(
$url_key
,
strpos
(
$url_key
,
"/"
)
+
1
);
$url_key_arr
=
explode
(
"/"
,
$url_key
);
if
(
!
isset
(
$url_key_arr
[
1
]))
$url_key_arr
[
1
]
=
'index'
;
if
(
$blockname
){
$url_key_arr
[
count
(
$url_key_arr
)
-
1
]
=
ucfirst
(
$blockname
);
}
else
{
$url_key_arr
[
count
(
$url_key_arr
)
-
1
]
=
ucfirst
(
$url_key_arr
[
count
(
$url_key_arr
)
-
1
]);
}
$block_space
=
implode
(
"
\\
"
,
$url_key_arr
);
$blockFile
=
$modulesDir
.
$block_space
;
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
//echo $blockFile;exit;
return
new
$blockFile
;
}
}
app/appadmin/modules/Catalog/block/productinfo/Index.php
浏览文件 @
7038e3e0
...
...
@@ -12,7 +12,7 @@ namespace fecshop\app\appadmin\modules\Catalog\block\productinfo;
use
fec\helpers\CUrl
;
use
fecshop\app\appadmin\interfaces\base\AppadminbaseBlockInterface
;
use
fecshop\app\appadmin\modules\AppadminbaseBlock
;
use
fecshop\app\appadmin\modules\Catalog\helper\Product
as
ProductHelper
;
//
use fecshop\app\appadmin\modules\Catalog\helper\Product as ProductHelper;
use
Yii
;
/**
...
...
@@ -23,12 +23,23 @@ use Yii;
class
Index
extends
AppadminbaseBlock
implements
AppadminbaseBlockInterface
{
protected
$_copyUrl
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_productHelperName
=
'\fecshop\app\appadmin\modules\Catalog\helper\Product'
;
protected
$_productHelper
;
/**
* init param function ,execute in construct.
*/
public
function
init
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_productHelperName
,
$this
->
_productHelper
)
=
Yii
::
mapGet
(
$this
->
_productHelperName
);
/*
* edit data url
*/
...
...
@@ -82,14 +93,14 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
'title'
=>
'状态'
,
'name'
=>
'status'
,
'columns_type'
=>
'int'
,
// int使用标准匹配, string使用模糊查询
'value'
=>
P
roductHelper
::
getStatusArr
(),
'value'
=>
$this
->
_p
roductHelper
::
getStatusArr
(),
],
[
// selecit的Int 类型
'type'
=>
'select'
,
'title'
=>
'库存状态'
,
'name'
=>
'is_in_stock'
,
'columns_type'
=>
'int'
,
// int使用标准匹配, string使用模糊查询
'value'
=>
P
roductHelper
::
getInStockArr
(),
'value'
=>
$this
->
_p
roductHelper
::
getInStockArr
(),
],
[
// 字符串类型
'type'
=>
'inputtext'
,
...
...
@@ -191,7 +202,7 @@ class Index extends AppadminbaseBlock implements AppadminbaseBlockInterface
'label'
=>
'状态'
,
'width'
=>
'50'
,
'align'
=>
'center'
,
'display'
=>
P
roductHelper
::
getStatusArr
(),
'display'
=>
$this
->
_p
roductHelper
::
getStatusArr
(),
],
[
...
...
app/appadmin/modules/Catalog/block/productinfo/Manageredit.php
浏览文件 @
7038e3e0
...
...
@@ -13,7 +13,7 @@ use fec\helpers\CRequest;
use
fec\helpers\CUrl
;
use
fecshop\app\appadmin\interfaces\base\AppadminbaseBlockEditInterface
;
use
fecshop\app\appadmin\modules\AppadminbaseBlockEdit
;
use
fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr
;
//
use fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr;
use
Yii
;
/**
...
...
@@ -26,9 +26,19 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit
public
$_saveUrl
;
protected
$_attr
;
protected
$_custom_option_list_str
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_attrBlockName
=
'\fecshop\app\appadmin\modules\Catalog\block\productinfo\index\Attr'
;
protected
$_attrBlock
;
public
function
init
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
$this
->
_attrBlockName
=
Yii
::
mapGetName
(
$this
->
_attrBlockName
);
$this
->
_saveUrl
=
CUrl
::
getUrl
(
'catalog/productinfo/managereditsave'
);
parent
::
init
();
$product_id
=
$this
->
_param
[
$this
->
_primaryKey
];
...
...
@@ -38,7 +48,7 @@ class Manageredit extends AppadminbaseBlockEdit implements AppadminbaseBlockEdit
$this
->
_one
[
'qty'
]
=
$qty
;
}
$this
->
_attr
=
new
Attr
(
$this
->
_one
);
$this
->
_attr
=
new
$this
->
_attrBlockName
(
$this
->
_one
);
//$this->_param = $request_param[$this->_editFormData];
}
...
...
app/appadmin/modules/Catalog/block/productinfo/index/Attr.php
浏览文件 @
7038e3e0
...
...
@@ -10,7 +10,7 @@
namespace
fecshop\app\appadmin\modules\Catalog\block\productinfo\index
;
use
fec\helpers\CRequest
;
use
fecshop\app\appadmin\modules\Catalog\helper\Product
as
ProductHelper
;
//
use fecshop\app\appadmin\modules\Catalog\helper\Product as ProductHelper;
use
Yii
;
/**
...
...
@@ -22,9 +22,19 @@ class Attr
{
protected
$_currentAttrGroup
;
protected
$_attrInfo
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_productHelperName
=
'\fecshop\app\appadmin\modules\Catalog\helper\Product'
;
protected
$_productHelper
;
public
function
__construct
(
$one
)
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_productHelperName
,
$this
->
_productHelper
)
=
Yii
::
mapGet
(
$this
->
_productHelperName
);
$currentAttrGroup
=
CRequest
::
param
(
'attr_group'
);
if
(
$currentAttrGroup
)
{
$this
->
_currentAttrGroup
=
$currentAttrGroup
;
...
...
@@ -165,7 +175,7 @@ class Attr
'name'
=>
'status'
,
'display'
=>
[
'type'
=>
'select'
,
'data'
=>
P
roductHelper
::
getStatusArr
(),
'data'
=>
$this
->
_p
roductHelper
::
getStatusArr
(),
],
'require'
=>
1
,
'default'
=>
1
,
...
...
@@ -212,7 +222,7 @@ class Attr
'name'
=>
'is_in_stock'
,
'display'
=>
[
'type'
=>
'select'
,
'data'
=>
P
roductHelper
::
getInStockArr
(),
'data'
=>
$this
->
_p
roductHelper
::
getInStockArr
(),
],
'require'
=>
1
,
'default'
=>
1
,
...
...
app/appapi/modules/AppapiController.php
浏览文件 @
7038e3e0
...
...
@@ -77,7 +77,9 @@ class AppapiController extends ActiveController
$relativeFile
=
'\\'
.
$this
->
blockNamespace
;
$relativeFile
.
=
'\\'
.
$this
->
id
.
'\\'
.
ucfirst
(
$blockName
);
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
return
new
$relativeFile
();
}
}
app/appfront/modules/AppfrontController.php
浏览文件 @
7038e3e0
...
...
@@ -75,7 +75,9 @@ class AppfrontController extends FecController
$viewId
=
str_replace
(
'/'
,
'\\'
,
$viewId
);
$relativeFile
=
'\\'
.
$this
->
blockNamespace
;
$relativeFile
.
=
'\\'
.
$viewId
.
'\\'
.
ucfirst
(
$blockName
);
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
return
new
$relativeFile
();
}
...
...
app/appfront/modules/Catalog/block/product/Index.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\appfront\modules\Catalog\block\product
;
use
fecshop\app\appfront\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\appfront\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -32,7 +32,22 @@ class Index
protected
$_image_thumbnails
;
// 在产品详细页面,在产品描述部分显示的产品图片列表
protected
$_image_detail
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\appfront\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
}
public
function
getLastData
()
{
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
...
...
@@ -41,8 +56,8 @@ class Index
Yii
::
$service
->
url
->
redirect404
();
return
;
}
R
eviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
R
eviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
$this
->
_r
eviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
$this
->
_r
eviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
$this
->
filterProductImg
(
$this
->
_product
[
'image'
]);
$groupAttr
=
Yii
::
$service
->
product
->
getGroupAttr
(
$this
->
_product
[
'attr_group'
]);
...
...
app/appfront/modules/Catalog/block/product/Review.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\appfront\modules\Catalog\block\product
;
use
fecshop\app\appfront\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\appfront\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -22,11 +22,22 @@ class Review
public
$spu
;
public
$filterBySpu
=
true
;
public
$filterOrderBy
=
'review_date'
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\appfront\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
// 初始化当前appfront的设置,覆盖service的初始设置。
R
eviewHelper
::
initReviewConfig
();
$this
->
_r
eviewHelper
::
initReviewConfig
();
}
/**
* 得到当前spu下面的所有评论信息。
...
...
app/appfront/modules/Catalog/block/reviewproduct/Add.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\appfront\modules\Catalog\block\reviewproduct
;
use
fecshop\app\appfront\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\appfront\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -19,10 +19,20 @@ use Yii;
class
Add
{
protected
$_add_captcha
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\appfront\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
ReviewHelper
::
initReviewConfig
();
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
$this
->
_reviewHelper
::
initReviewConfig
();
}
/**
* @return boolean , review页面是否开启验证码验证。
...
...
app/appfront/modules/Catalog/block/reviewproduct/Lists.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\appfront\modules\Catalog\block\reviewproduct
;
use
fecshop\app\appfront\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\appfront\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -25,11 +25,20 @@ class Lists
public
$_page
=
'p'
;
public
$numPerPage
=
20
;
public
$pageNum
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\appfront\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
// 初始化服务
ReviewHelper
::
initReviewConfig
();
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
$this
->
_reviewHelper
::
initReviewConfig
();
}
/**
* @property $countTotal | Int
...
...
@@ -88,7 +97,7 @@ class Lists
$pageToolBar
=
$this
->
getProductPage
(
$count
);
$coll
=
$data
[
'coll'
];
$ReviewAndStarCount
=
R
eviewHelper
::
getReviewAndStarCount
(
$product
);
$ReviewAndStarCount
=
$this
->
_r
eviewHelper
::
getReviewAndStarCount
(
$product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
return
[
...
...
app/apphtml5/modules/AppfrontController.php
浏览文件 @
7038e3e0
...
...
@@ -75,7 +75,9 @@ class AppfrontController extends FecController
$viewId
=
str_replace
(
'/'
,
'\\'
,
$viewId
);
$relativeFile
=
'\\'
.
$this
->
blockNamespace
;
$relativeFile
.
=
'\\'
.
$viewId
.
'\\'
.
ucfirst
(
$blockName
);
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
return
new
$relativeFile
();
}
...
...
app/apphtml5/modules/Catalog/block/product/Index.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\apphtml5\modules\Catalog\block\product
;
use
fecshop\app\apphtml5\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\apphtml5\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -32,7 +32,20 @@ class Index
protected
$_image_thumbnails
;
// 在产品详细页面,在产品描述部分显示的产品图片列表
protected
$_image_detail
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\apphtml5\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
}
public
function
getLastData
()
{
$productImgSize
=
Yii
::
$app
->
controller
->
module
->
params
[
'productImgSize'
];
...
...
@@ -41,8 +54,8 @@ class Index
Yii
::
$service
->
url
->
redirect404
();
return
;
}
R
eviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
R
eviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
$this
->
_r
eviewHelper
::
initReviewConfig
();
$ReviewAndStarCount
=
$this
->
_r
eviewHelper
::
getReviewAndStarCount
(
$this
->
_product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
$this
->
filterProductImg
(
$this
->
_product
[
'image'
]);
$groupAttr
=
Yii
::
$service
->
product
->
getGroupAttr
(
$this
->
_product
[
'attr_group'
]);
...
...
app/apphtml5/modules/Catalog/block/product/Review.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\apphtml5\modules\Catalog\block\product
;
use
fecshop\app\apphtml5\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\apphtml5\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -22,12 +22,22 @@ class Review
public
$spu
;
public
$filterBySpu
=
true
;
public
$filterOrderBy
=
'review_date'
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\apphtml5\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
// 初始化当前apphtml5的设置,覆盖service的初始设置。
R
eviewHelper
::
initReviewConfig
();
$this
->
_r
eviewHelper
::
initReviewConfig
();
}
/**
* 得到当前spu下面的所有评论信息。
*/
...
...
app/apphtml5/modules/Catalog/block/reviewproduct/Add.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\apphtml5\modules\Catalog\block\reviewproduct
;
use
fecshop\app\apphtml5\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\apphtml5\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -19,11 +19,21 @@ use Yii;
class
Add
{
protected
$_add_captcha
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\apphtml5\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
ReviewHelper
::
initReviewConfig
();
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
$this
->
_reviewHelper
::
initReviewConfig
();
}
/**
* @return boolean , review页面是否开启验证码验证。
*/
...
...
app/apphtml5/modules/Catalog/block/reviewproduct/Lists.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\app\apphtml5\modules\Catalog\block\reviewproduct
;
use
fecshop\app\apphtml5\modules\Catalog\helpers\Review
as
ReviewHelper
;
//
use fecshop\app\apphtml5\modules\Catalog\helpers\Review as ReviewHelper;
use
Yii
;
/**
...
...
@@ -25,11 +25,20 @@ class Lists
public
$_page
=
'p'
;
public
$numPerPage
=
20
;
public
$pageNum
;
/**
* 为了可以使用rewriteMap,use 引入的文件统一采用下面的方式,通过Yii::mapGet()得到className和Object
*/
protected
$_reviewHelperName
=
'\fecshop\app\apphtml5\modules\Catalog\helpers\Review'
;
protected
$_reviewHelper
;
public
function
__construct
()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list
(
$this
->
_reviewHelperName
,
$this
->
_reviewHelper
)
=
Yii
::
mapGet
(
$this
->
_reviewHelperName
);
// 初始化服务
R
eviewHelper
::
initReviewConfig
();
$this
->
_r
eviewHelper
::
initReviewConfig
();
}
/**
* @property $countTotal | Int
...
...
@@ -88,7 +97,7 @@ class Lists
$pageToolBar
=
$this
->
getProductPage
(
$count
);
$coll
=
$data
[
'coll'
];
$ReviewAndStarCount
=
R
eviewHelper
::
getReviewAndStarCount
(
$product
);
$ReviewAndStarCount
=
$this
->
_r
eviewHelper
::
getReviewAndStarCount
(
$product
);
list
(
$review_count
,
$reviw_rate_star_average
)
=
$ReviewAndStarCount
;
return
[
...
...
app/appserver/modules/AppserverController.php
浏览文件 @
7038e3e0
...
...
@@ -63,7 +63,9 @@ class AppserverController extends FecController
$viewId
=
str_replace
(
'/'
,
'\\'
,
$viewId
);
$relativeFile
=
'\\'
.
$this
->
blockNamespace
;
$relativeFile
.
=
'\\'
.
$viewId
.
'\\'
.
ucfirst
(
$blockName
);
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
return
new
$relativeFile
();
}
...
...
app/console/modules/ConsoleController.php
浏览文件 @
7038e3e0
...
...
@@ -39,7 +39,9 @@ class ConsoleController extends FecController
$relativeFile
=
'\\'
.
$this
->
blockNamespace
;
$relativeFile
.
=
'\\'
.
$this
->
id
.
'\\'
.
ucfirst
(
$blockName
);
//查找是否在rewriteMap中存在重写
$relativeFile
=
Yii
::
mapGetName
(
$relativeFile
);
return
new
$relativeFile
();
}
}
services/category/CategoryMongodb.php
浏览文件 @
7038e3e0
...
...
@@ -9,7 +9,7 @@
namespace
fecshop\services\category
;
use
fecshop\models\mongodb\Category
;
//
use fecshop\models\mongodb\Category;
use
Yii
;
/**
...
...
@@ -19,7 +19,26 @@ use Yii;
class
CategoryMongodb
implements
CategoryInterface
{
public
$numPerPage
=
20
;
protected
$_categoryModelName
=
'\fecshop\models\mongodb\Category'
;
protected
$_categoryModel
;
public
function
__construct
(){
list
(
$this
->
_categoryModelName
,
$this
->
_categoryModel
)
=
Yii
::
mapGet
(
$this
->
_categoryModelName
);
}
/**
* 通过主键,得到Category对象。
*/
public
function
getByPrimaryKey
(
$primaryKey
)
{
if
(
$primaryKey
)
{
return
$this
->
_categoryModel
::
findOne
(
$primaryKey
);
}
else
{
return
new
$this
->
_categoryModelName
;
}
}
/**
* 返回主键。
*/
...
...
@@ -31,25 +50,16 @@ class CategoryMongodb implements CategoryInterface
* 得到分类激活状态的值
*/
public
function
getCategoryEnableStatus
(){
return
Category
::
STATUS_ENABLE
;
return
$this
->
_categoryModel
::
STATUS_ENABLE
;
}
/**
* 得到分类在menu中显示的状态值
*/
public
function
getCategoryMenuShowStatus
(){
return
Category
::
MENU_SHOW
;
}
/**
* 通过主键,得到Category对象。
*/
public
function
getByPrimaryKey
(
$primaryKey
)
{
if
(
$primaryKey
)
{
return
Category
::
findOne
(
$primaryKey
);
}
else
{
return
new
Category
();
}
return
$this
->
_categoryModel
::
MENU_SHOW
;
}
/*
* example filter:
...
...
@@ -67,7 +77,7 @@ class CategoryMongodb implements CategoryInterface
*/
public
function
coll
(
$filter
=
''
)
{
$query
=
Category
::
find
();
$query
=
$this
->
_categoryModel
::
find
();
$query
=
Yii
::
$service
->
helper
->
ar
->
getCollByFilter
(
$query
,
$filter
);
return
[
...
...
@@ -81,7 +91,7 @@ class CategoryMongodb implements CategoryInterface
*/
public
function
collCount
(
$filter
=
''
)
{
$query
=
Category
::
find
();
$query
=
$this
->
_categoryModel
::
find
();
$query
=
Yii
::
$service
->
helper
->
ar
->
getCollByFilter
(
$query
,
$filter
);
return
$query
->
count
();
...
...
@@ -97,7 +107,7 @@ class CategoryMongodb implements CategoryInterface
$currentDateTime
=
\
fec\helpers\CDate
::
getCurrentDateTime
();
$primaryVal
=
isset
(
$one
[
$this
->
getPrimaryKey
()])
?
$one
[
$this
->
getPrimaryKey
()]
:
''
;
if
(
$primaryVal
)
{
$model
=
Category
::
findOne
(
$primaryVal
);
$model
=
$this
->
_categoryModel
::
findOne
(
$primaryVal
);
if
(
!
$model
)
{
Yii
::
$service
->
helper
->
errors
->
add
(
'Category '
.
$this
->
getPrimaryKey
()
.
' is not exist'
);
...
...
@@ -105,7 +115,7 @@ class CategoryMongodb implements CategoryInterface
}
$parent_id
=
$model
[
'parent_id'
];
}
else
{
$model
=
new
Category
()
;
$model
=
new
$this
->
_categoryModelName
;
$model
->
created_at
=
time
();
$model
->
created_user_id
=
\
fec\helpers\CUser
::
getCurrentUserId
();
$primaryVal
=
new
\
MongoDB\BSON\ObjectId
();
...
...
@@ -116,7 +126,7 @@ class CategoryMongodb implements CategoryInterface
if
(
$parent_id
===
'0'
)
{
$model
[
'level'
]
=
1
;
}
else
{
$parent_model
=
Category
::
findOne
(
$parent_id
);
$parent_model
=
$this
->
_categoryModel
::
findOne
(
$parent_id
);
if
(
$parent_level
=
$parent_model
[
'level'
])
{
$model
[
'level'
]
=
$parent_level
+
1
;
}
...
...
@@ -149,7 +159,7 @@ class CategoryMongodb implements CategoryInterface
return
false
;
}
$model
=
Category
::
findOne
(
$id
);
$model
=
$this
->
_categoryModel
::
findOne
(
$id
);
if
(
isset
(
$model
[
$this
->
getPrimaryKey
()])
&&
!
empty
(
$model
[
$this
->
getPrimaryKey
()]))
{
$url_key
=
$model
[
'url_key'
];
Yii
::
$service
->
url
->
removeRewriteUrlKey
(
$url_key
);
...
...
@@ -166,7 +176,7 @@ class CategoryMongodb implements CategoryInterface
protected
function
removeChildCate
(
$id
)
{
$data
=
Category
::
find
()
->
where
([
'parent_id'
=>
$id
])
->
all
();
$data
=
$this
->
_categoryModel
::
find
()
->
where
([
'parent_id'
=>
$id
])
->
all
();
if
(
!
empty
(
$data
))
{
foreach
(
$data
as
$one
)
{
$idVal
=
(
string
)
$one
[
'_id'
];
...
...
@@ -196,7 +206,7 @@ class CategoryMongodb implements CategoryInterface
}
else
{
$where
=
[
'parent_id'
=>
$rootCategoryId
];
}
$categorys
=
Category
::
find
()
->
asArray
()
->
where
(
$where
)
->
all
();
$categorys
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
(
$where
)
->
all
();
//var_dump($categorys);exit;
$idKey
=
$this
->
getPrimaryKey
();
if
(
!
empty
(
$categorys
))
{
...
...
@@ -219,7 +229,7 @@ class CategoryMongodb implements CategoryInterface
protected
function
hasChildCategory
(
$idVal
)
{
$one
=
Category
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$idVal
])
->
one
();
$one
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$idVal
])
->
one
();
if
(
!
empty
(
$one
))
{
return
true
;
}
...
...
@@ -237,7 +247,7 @@ class CategoryMongodb implements CategoryInterface
public
function
getAllParentInfo
(
$parent_id
)
{
if
(
$parent_id
)
{
$parentModel
=
Category
::
findOne
(
$parent_id
);
$parentModel
=
$this
->
_categoryModel
::
findOne
(
$parent_id
);
$parent_parent_id
=
$parentModel
[
'parent_id'
];
$parent_category
=
[];
if
(
$parent_parent_id
!==
'0'
)
{
...
...
@@ -262,7 +272,7 @@ class CategoryMongodb implements CategoryInterface
if
(
$parent_id
===
'0'
)
{
return
[];
}
$category
=
Category
::
find
()
->
asArray
()
->
where
([
'_id'
=>
new
\
MongoDB\BSON\ObjectId
(
$parent_id
)])
->
one
();
$category
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
([
'_id'
=>
new
\
MongoDB\BSON\ObjectId
(
$parent_id
)])
->
one
();
if
(
isset
(
$category
[
'_id'
])
&&
!
empty
(
$category
[
'_id'
]))
{
$currentUrlKey
=
$category
[
'url_key'
];
$currentName
=
$category
[
'name'
];
...
...
@@ -296,7 +306,7 @@ class CategoryMongodb implements CategoryInterface
{
$returnData
=
[];
$primaryKey
=
$this
->
getPrimaryKey
();
$currentCategory
=
Category
::
findOne
(
$category_id
);
$currentCategory
=
$this
->
_categoryModel
::
findOne
(
$category_id
);
$currentUrlKey
=
$currentCategory
[
'url_key'
];
$currentName
=
$currentCategory
[
'name'
];
$currentId
=
(
string
)
$currentCategory
[
'_id'
];
...
...
@@ -327,7 +337,7 @@ class CategoryMongodb implements CategoryInterface
$_id
=
$category
[
'_id'
];
$name
=
$category
[
'name'
];
$url_key
=
$category
[
'url_key'
];
$cate
=
Category
::
find
()
->
asArray
()
->
where
([
$cate
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$_id
,
])
->
all
();
if
(
is_array
(
$cate
)
&&
!
empty
(
$cate
))
{
...
...
@@ -355,7 +365,7 @@ class CategoryMongodb implements CategoryInterface
$category_id
=
$category
[
'_id'
];
$parent_id
=
$category
[
'parent_id'
];
if
(
$parent_id
)
{
$cate
=
Category
::
find
()
->
asArray
()
->
where
([
$cate
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$parent_id
,
])
->
all
();
//var_dump($cate);
...
...
@@ -394,7 +404,7 @@ class CategoryMongodb implements CategoryInterface
protected
function
getChildCate
(
$category_id
)
{
//echo $category_id;
$data
=
Category
::
find
()
->
asArray
()
->
where
([
$data
=
$this
->
_categoryModel
::
find
()
->
asArray
()
->
where
([
'parent_id'
=>
$category_id
,
])
->
all
();
$arr
=
[];
...
...
yii/Yii.php
浏览文件 @
7038e3e0
...
...
@@ -15,6 +15,45 @@ require $dir.'/BaseYii.php';
class
Yii
extends
\
yii\BaseYii
{
public
static
$service
;
/**
* rewriteMap , like:
* [
* '\fecshop\models\mongodb\Category' => '\appadmin\models\mongodb\Category'
* ]
*/
public
static
$rewriteMap
;
/**
* @property $absoluteClassName | String , like: '\fecshop\app\appfront\modules\Cms\block\home\Index'
* @property $arguments | Array ,数组,里面的每一个子项就是用于实例化的一个参数,多少个子项,就代表有多个参数,用于对象的实例化。
* 通过$rewriteMap,查找是否存在重写,如果存在,则得到重写的className
* 然后返回 类名 和 对象
*/
public
static
function
mapGet
(
$absoluteClassName
,
$arguments
=
[]){
$absoluteClassName
=
self
::
mapGetName
(
$absoluteClassName
);
if
(
!
empty
(
$arguments
)
&&
is_array
(
$arguments
))
{
$class
=
new
ReflectionClass
(
$absoluteClassName
);
$absoluteOb
=
$class
->
newInstanceArgs
(
$arguments
);
/**
* 下面的 ...,是php的语法糖(只能php5.6以上,放弃),也就是把$paramArray数组里面的各个子项参数,
* 作为对象生成的参数,详细可以参看:https://segmentfault.com/q/1010000006789348
*/
//$absoluteOb = new $absoluteClassName(...$arguments);
}
else
{
$absoluteOb
=
new
$absoluteClassName
;
}
return
[
$absoluteClassName
,
$absoluteOb
];
}
/**
* @property $absoluteClassName | String , like: '\fecshop\app\appfront\modules\Cms\block\home\Index'
* 通过$rewriteMap,查找是否存在重写,如果存在,则返回重写的className
*/
public
static
function
mapGetName
(
$absoluteClassName
){
if
(
isset
(
self
::
$rewriteMap
[
$absoluteClassName
])
&&
self
::
$rewriteMap
[
$absoluteClassName
]){
$absoluteClassName
=
self
::
$rewriteMap
[
$absoluteClassName
];
}
return
$absoluteClassName
;
}
}
spl_autoload_register
([
'Yii'
,
'autoload'
],
true
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录