code
stringlengths 15
9.96M
| docstring
stringlengths 1
10.1k
| func_name
stringlengths 1
124
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 6
186
| url
stringlengths 50
236
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Title'),
'name' => 'title',
'columns_type' => 'string',
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Identify'),
'name' => 'identify',
'columns_type' => 'string',
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' => 'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Cms/block/staticblock/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Cms/block/staticblock/Index.php | BSD-3-Clause |
public function getLastData(){
return [
'editBar' => $this->getEditBar(),
'saveUrl' => CUrl::getUrl('fecadmin/role/managereditsave'),
'groupResources' => $this->getGroupResources(),
'tags' => $this->getTagsArr(),
//'menu' => self::getMenuStr(),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/role/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/role/Manageredit.php | BSD-3-Clause |
public function save(){
$param = Yii::$app->request->post('editFormData');
$saveStatus = Yii::$service->admin->role->saveRoleAndResources($param);
if ($saveStatus){
echo json_encode(array(
"statusCode"=>"200",
"message"=>Yii::$service->page->translate->__('Save Success'),
));
exit;
} else {
$errors = Yii::$service->helper->errors->get();
echo json_encode(["statusCode"=>"300",
"message" => $errors,
]);
exit;
}
} | 保存 | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/role/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/role/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('fecadmin/role/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('fecadmin/role/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->admin->role;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/role/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/role/Manager.php | BSD-3-Clause |
public function getSearchArr(){
$data = [
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Role Name'),
'name' => 'role_name' ,
'columns_type' =>'string'
],
];
return $data;
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/role/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/role/Manager.php | BSD-3-Clause |
public function getTableFieldArr(){
$table_th_bar = [
[
'orderField' => 'role_id',
'label' => Yii::$service->page->translate->__('Role Id'),
'width' => '110',
'align' => 'left',
],
[
'orderField' => 'role_name',
'label' => Yii::$service->page->translate->__('Role Name'),
'width' => '110',
'align' => 'left',
],
[
'label' => Yii::$service->page->translate->__('Status'),
'orderField' => 'role_description',
'width' => '110',
'align' => 'left',
],
];
return $table_th_bar ;
} | 定义表格显示部分的配置 | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/role/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/role/Manager.php | BSD-3-Clause |
public function getLastData(){
return [
'editBar' => $this->getEditBar(),
'saveUrl' => CUrl::getUrl('fecadmin/config/managereditsave'),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/config/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/config/Manageredit.php | BSD-3-Clause |
public function getSearchArr(){
$data = [
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('config label'),
'name' => 'label' ,
'columns_type' => 'string'
],
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('config key') ,
'name' => 'key' ,
'columns_type' => 'string'
],
];
return $data;
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/config/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/config/Manager.php | BSD-3-Clause |
public function getTableFieldArr(){
$table_th_bar = [
[
'orderField' => 'id',
'label' => 'ID',
'width' => '40',
'align' => 'left',
],
[
'orderField' => 'label',
'label' => Yii::$service->page->translate->__('Config Label'),
'width' => '150',
'align' => 'left',
],
[
'orderField' => 'key',
'label' => Yii::$service->page->translate->__('Config Key') ,
'width' => '110',
'align' => 'left',
],
[
'orderField' => 'value',
'label' => Yii::$service->page->translate->__('Config Value') ,
'width' => '150',
'align' => 'left',
],
[
'orderField' => 'created_at',
'label' => Yii::$service->page->translate->__('Created At') ,
'width' => '70',
'align' => 'center',
],
[
'orderField' => 'updated_at',
'label' => Yii::$service->page->translate->__('Updated At') ,
'width' => '70',
'align' => 'center',
],
[
'orderField' => 'created_person',
'label' => Yii::$service->page->translate->__('Create Person') ,
'width' => '50',
'align' => 'left',
],
];
return $table_th_bar ;
} | 定义表格显示部分的配置 | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/config/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/config/Manager.php | BSD-3-Clause |
public function getSearchArr(){
$data = [
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Account'),
'name' => 'account' ,
'columns_type' => 'string'
],
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('User Name'),
'name' => 'person' ,
'columns_type' => 'string'
],
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Resource'),
'name' => 'menu' ,
'columns_type' => 'string'
],
[ # 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' =>'datetime',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
]
],
];
return $data;
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/log/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/log/Index.php | BSD-3-Clause |
public function getTableFieldArr(){
$table_th_bar = [
[
'orderField' => 'id',
'label' => Yii::$service->page->translate->__('Id'),
'width' => '70',
'align' => 'center',
],
[
'orderField' => 'account',
'label' => Yii::$service->page->translate->__('Account'),
'width' => '70',
'align' => 'center',
],
[
'orderField' => 'person',
'label' => Yii::$service->page->translate->__('User Name'),
'width' => '70',
'align' => 'left',
],
[
'orderField' => 'menu',
'label' => Yii::$service->page->translate->__('Resource'),
'width' => '70',
'align' => 'left',
],
[
'orderField' => 'url',
'label' => Yii::$service->page->translate->__('Url'),
'width' => '220',
'align' => 'left',
],
[
'orderField' => 'created_at',
'label' => Yii::$service->page->translate->__('Created At'),
'width' => '130',
'align' => 'center',
//'convert' => ['datetime' =>'date'], # int date datetime 显示的转换
],
];
return $table_th_bar ;
} | 定义表格显示部分的配置 | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/log/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/log/Index.php | BSD-3-Clause |
public function getTableTbodyHtml($data){
$fileds = $this->getTableFieldArr();
$str .= '';
$csrfString = \fec\helpers\CRequest::getCsrfString();
$primaryKey = $this->_service->getPrimaryKey();
foreach ($data as $one) {
$str .= '<tr target="sid_user" rel="'.$one[$primaryKey].'">';
$str .= '<td><input name="'.$primaryKey.'s" value="'.$one[$primaryKey].'" type="checkbox"></td>';
foreach ($fileds as $field) {
$orderField = $field['orderField'];
$display = $field['display'];
$val = $one[$orderField];
$originVal = $one[$orderField];
if ($val) {
if ($orderField == 'menu') {
$valArr = explode(" ", $val, 2);
$val1 = Yii::$service->page->translate->__($valArr[0]);
$val2 = Yii::$service->page->translate->__($valArr[1]);
$val = $val1 . ' ' . $val2;
}else if (isset($field['display']) && !empty($field['display'])) {
$display = $field['display'];
$val = $display[$val] ? $display[$val] : $val;
}
if (isset($field['convert']) && !empty($field['convert'])) {
$convert = $field['convert'];
foreach ($convert as $origin =>$to) {
if (strstr($origin,'date')) {
if ($to == 'date') {
$val = date('Y-m-d',strtotime($val));
} else if ($to == 'datetime') {
$val = date('Y-m-d H:i:s',strtotime($val));
} else if ($to == 'int') {
$val = strtotime($val);
}
} else if ($origin == 'int') {
if ($to == 'date') {
$val = date('Y-m-d',$val);
} else if ($to == 'datetime') {
$val = date('Y-m-d H:i:s',$val);
} else if ($to == 'int') {
$val = $val;
}
}
}
}
}
$str .= '<td><span title='.$originVal.'>'.$val.'</span></td>';
}
$str .= '</tr>';
}
return $str ;
} | table 内容部分 | getTableTbodyHtml | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/log/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/log/Index.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/resource/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/resource/Manageredit.php | BSD-3-Clause |
public function save()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$this->_service->save($this->_param);
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} else {
echo json_encode([
'statusCode'=>'300',
'message'=>$errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/resource/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/resource/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('fecadmin/resource/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('fecadmin/resource/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->admin->urlKey;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/resource/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/resource/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Tag'),
'name' => 'tag',
'columns_type' => 'string', // int使用标准匹配, string使用模糊查询
'value' => Yii::$service->admin->urlKey->getTags(),
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Tag Name'),
'name' => 'name',
'columns_type' => 'string',
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Resource'),
'name' => 'url_key',
'columns_type' => 'string',
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' => 'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/resource/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/resource/Manager.php | BSD-3-Clause |
public function getSearchArr(){
return [];
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/cache/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/cache/Index.php | BSD-3-Clause |
public function isFileCache()
{
$arr = \Yii::$app->controller->module->params['cacheConfigFile'];
if (is_array($arr)) {
// 加载common公用基础redis配置
if (!isset($arr[$this->commonConfigKey]) || !$arr[$this->commonConfigKey]) {
$this->errors = 'module config: cacheFileConfigFile[commonConfig] can not empty';
return false;
}
$file = Yii::getAlias($arr[$this->commonConfigKey]);
$config = require($file);
if (!isset($config['components']['cache']['class']) || !$config['components']['cache']['class'] || $config['components']['cache']['class'] != 'yii\caching\FileCache') {
$this->errors = 'can not find $config[\'components\'][\'cache\'][\'fileCache\'] in '.$file;
return false;
}
return true;
}
return false;
} | 判断是否是文件cache | isFileCache | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/cache/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/cache/Index.php | BSD-3-Clause |
public function reflush(){
// 如果是文件缓存
if ($this->isFileCache()) {
$this->flushFileCache();
exit;
}
// flush redis cache
$this->flushRedisCache();
exit;
} | 清空选择的入口的所有缓存。 | reflush | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/cache/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/cache/Index.php | BSD-3-Clause |
public function getSearchArr(){
$data = [
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Account'),
'name' => 'account' ,
'columns_type' => 'string'
],
[ # 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Name'),
'name' => 'person' ,
'columns_type' => 'string'
],
[ # selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Type'),
'name' => 'tj_type',
'columns_type' => 'int', # int使用标准匹配, string使用模糊查询
'value' => [ # select 类型的值
'login' => Yii::$service->page->translate->__('Login'),
'' => Yii::$service->page->translate->__('Visit All'),
],
],
[ # 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' => 'datetime',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
]
],
];
return $data;
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/logtj/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/logtj/Index.php | BSD-3-Clause |
public function getTableFieldArr(){
$table_th_bar = [
[
'orderField' => 'account',
'label' => Yii::$service->page->translate->__('Account'),
'width' => '70',
'align' => 'center',
],
[
'orderField' => 'person',
'label' => Yii::$service->page->translate->__('Name'),
'width' => '70',
'align' => 'left',
],
//[
// 'orderField' => 'menu',
// 'label' => '操作菜单',
// 'width' => '70',
// 'align' => 'left',
//],
[
'orderField' => 'click_count',
'label' => Yii::$service->page->translate->__('Count'),
'width' => '220',
'align' => 'left',
],
];
return $table_th_bar ;
} | 定义表格显示部分的配置 | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/logtj/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/logtj/Index.php | BSD-3-Clause |
public function getTableTbody(){
$obj = Yii::$service->admin->systemLog->getSystemLogModel();
$offset = ($this->_param['pageNum'] -1)*$this->_param['numPerPage'] ;
$limit = $this->_param['numPerPage'];
$limit = " limit $offset , $limit ";
$group = " account ";
$account = CRequest::param('account');
$person = CRequest::param('person');
$tj_type = CRequest::param('tj_type');
$created_at_lt = $this->_param['created_at_lt'];
$created_at_gte = $this->_param['created_at_gte'];
$where = [];
if($account)
$where []= " account = '$account' ";
if($person)
$where []= " person = '$person' ";
if($tj_type == 'login'){
$where []= " menu = 'login' ";
$group .= " ,menu ";
}
if($created_at_lt)
$where []= " created_at < '$created_at_lt' ";
if($created_at_gte)
$where []= " created_at >= '$created_at_gte' ";
if(!empty($where)){
$where = ' where '.implode(' and ',$where);
}else{
$where = '';
}
$table = $obj::tableName();
$db = \Yii::$app->db;
# 得到 总数。
$sql = "select count(*) as count from (select account,person,menu ,count(*) as click_count
from $table $where group by $group ) as t ";
$data_count = $db->createCommand($sql,[])->queryOne();
$this->_param['numCount'] = $data_count['count'];
# 得到数据
$sql = "select account,person,menu ,count(*) as click_count
from $table $where group by $group order by click_count DESC $limit ";
$data = $db->createCommand($sql,[])->queryAll();
return $this->getTableTbodyHtml($data);
} | 得到表格的内容部分 | getTableTbody | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/logtj/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/logtj/Index.php | BSD-3-Clause |
public function getTableTbodyHtml($data){
$fileds = $this->getTableFieldArr();
$str .= '';
$primaryKey = $this->_service->getPrimaryKey();
$csrfString = \fec\helpers\CRequest::getCsrfString();
foreach ($data as $one) {
$str .= '<tr target="sid_user" rel="'.$one[$primaryKey].'">';
//$str .= '<td><input name="'.$primaryKey.'s" value="'.$one[$primaryKey].'" type="checkbox"></td>';
foreach ($fileds as $field) {
$orderField = $field['orderField'];
$display = $field['display'];
$val = $one[$orderField];
$originVal = $one[$orderField];
if ($val) {
if (isset($field['display']) && !empty($field['display'])) {
$display = $field['display'];
$val = $display[$val] ? $display[$val] : $val;
}
if (isset($field['convert']) && !empty($field['convert'])) {
$convert = $field['convert'];
foreach ($convert as $origin =>$to) {
if (strstr($origin,'date')) {
if($to == 'date'){
$val = date('Y-m-d',strtotime($val));
} else if ($to == 'datetime') {
$val = date('Y-m-d H:i:s',strtotime($val));
} else if($to == 'int') {
$val = strtotime($val);
}
} else if($origin == 'int') {
if ($to == 'date') {
$val = date('Y-m-d',$val);
} else if ($to == 'datetime') {
$val = date('Y-m-d H:i:s',$val);
} else if ($to == 'int') {
$val = $val;
}
}
}
}
}
$str .= '<td><span title='.$originVal.'>'.$val.'</span></td>';
}
$str .= '</tr>';
}
return $str ;
} | table 内容部分 | getTableTbodyHtml | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/logtj/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/logtj/Index.php | BSD-3-Clause |
public function getLastData(){
$role_ids = $this->getUserRoleIds();
return [
'editBar' => $this->getEditBar(),
'role_ids'=>$role_ids,
'saveUrl' => CUrl::getUrl('fecadmin/account/managereditsave'),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/account/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/account/Manageredit.php | BSD-3-Clause |
public function getSearchArr(){
$data = [
[ # selecit的Int 类型
'type'=>'select',
'title'=> Yii::$service->page->translate->__('Status'),
'name'=>'status',
'columns_type' =>'int', # int使用标准匹配, string使用模糊查询
'value'=> [ # select 类型的值
Yii::$service->adminUser->adminUser->getActiveStatus() => Yii::$service->page->translate->__('Enable'),
Yii::$service->adminUser->adminUser->getDeleteStatus() => Yii::$service->page->translate->__('Disable'),
],
],
[ # 字符串类型
'type'=>'inputtext',
'title'=> Yii::$service->page->translate->__('User Name'),
'name'=>'username' ,
'columns_type' =>'string'
],
[ # 字符串类型
'type'=>'inputtext',
'title'=>Yii::$service->page->translate->__('Worker No'),
'name'=>'code' ,
'columns_type' =>'string'
],
[ # 字符串类型
'type'=>'inputtext',
'title'=>Yii::$service->page->translate->__('Email'),
'name'=>'email' ,
'columns_type' =>'string'
],
[ # 时间区间类型搜索
'type'=>'inputdatefilter',
'name'=> 'created_at_datetime',
'columns_type' =>'datetime',
'value'=>[
'gte'=> Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
]
],
];
return $data;
} | 定义搜索部分字段格式 | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/account/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/account/Manager.php | BSD-3-Clause |
public function getTableFieldArr(){
$table_th_bar = [
[
'orderField' => 'id',
'label' => 'ID',
'width' => '110',
'align' => 'center',
],
[
'orderField' => 'username',
'label' => Yii::$service->page->translate->__('User Name'),
'width' => '110',
'align' => 'center',
],
[
'orderField' => 'person',
'label' => Yii::$service->page->translate->__('Name'),
'width' => '110',
'align' => 'center',
],
[
'orderField' => 'code',
'label' => Yii::$service->page->translate->__('Worker No'),
'width' => '110',
'align' => 'center',
],
[
'orderField' => 'email',
'label' => Yii::$service->page->translate->__('Email'),
'width' => '110',
'align' => 'center',
],
[
'orderField' => 'created_at_datetime',
'label' => Yii::$service->page->translate->__('Created At'),
'width' => '190',
'align' => 'center',
//'convert' => ['datetime' =>'date'],
],
[
'orderField' => 'updated_at_datetime',
'label' => Yii::$service->page->translate->__('Updated At'),
'width' => '190',
'align' => 'center',
//'convert' => ['datetime' =>'date'], # int date datetime 显示的转换
],
[
'orderField' => 'status',
'label' => Yii::$service->page->translate->__('Status'),
'width' => '60',
'align' => 'center',
'display' => [ # 显示转换 ,譬如 值为1显示为激活,值为10显示为关闭
'1' => Yii::$service->page->translate->__('Enable'),
'10' => Yii::$service->page->translate->__('Disable'),
],
],
];
return $table_th_bar ;
} | 定义表格显示部分的配置 | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/block/account/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/block/account/Manager.php | BSD-3-Clause |
public function actionIndex()
{
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 我的账户 | actionIndex | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/ResourceController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/ResourceController.php | BSD-3-Clause |
public function actionManager()
{
//echo $this->action->id ;exit;
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 我的账户 | actionManager | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/ResourceController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/ResourceController.php | BSD-3-Clause |
public function init()
{
parent::init();
if (!Yii::$service->page->theme->fecshopThemeDir) {
Yii::$service->page->theme->fecshopThemeDir = Yii::getAlias(CConfig::param('appadminBaseTheme'));
}
if (!Yii::$service->page->theme->layoutFile) {
Yii::$service->page->theme->layoutFile = CConfig::param('appadminBaseLayoutName');
}
// 设置本地模板路径
$localThemeDir = Yii::$app->params['localThemeDir'];
if($localThemeDir){
Yii::$service->page->theme->setLocalThemeDir($localThemeDir);
}
/*
* set i18n translate category.
*/
Yii::$service->page->translate->category = 'appadmin';
Yii::$service->page->theme->layoutFile = 'login.php';
} | init theme component property : $fecshopThemeDir and $layoutFile
$fecshopThemeDir is appfront base theme directory.
layoutFile is current layout relative path. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LoginController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LoginController.php | BSD-3-Clause |
public function render($view, $params = [])
{
$viewFile = Yii::$service->page->theme->getViewFile($view);
$content = Yii::$app->view->renderFile($viewFile, $params, $this);
return $this->renderContent($content);
} | @param $view|string , (only) view file name ,by this module id, this controller id , generate view relative path.
@param $params|Array,
1.get exist view file from mutil theme by theme protity.
2.get content by yii view compontent function renderFile() , | render | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LoginController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LoginController.php | BSD-3-Clause |
public function findLayoutFile($view)
{
$layoutFile = '';
$relativeFile = 'layouts/'.Yii::$service->page->theme->layoutFile;
$absoluteDir = Yii::$service->page->theme->getThemeDirArr();
foreach ($absoluteDir as $dir) {
if ($dir) {
$file = $dir.'/'.$relativeFile;
if (file_exists($file)) {
$layoutFile = $file;
return $layoutFile;
}
}
}
throw new InvalidValueException('layout file is not exist!');
} | Get current layoutFile absolute path from mutil theme dir by protity. | findLayoutFile | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LoginController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LoginController.php | BSD-3-Clause |
public function init()
{
parent::init();
if (!Yii::$service->page->theme->fecshopThemeDir) {
Yii::$service->page->theme->fecshopThemeDir = Yii::getAlias(CConfig::param('appadminBaseTheme'));
}
if (!Yii::$service->page->theme->layoutFile) {
Yii::$service->page->theme->layoutFile = CConfig::param('appadminBaseLayoutName');
}
// 设置本地模板路径
$localThemeDir = Yii::$app->params['localThemeDir'];
if($localThemeDir){
Yii::$service->page->theme->setLocalThemeDir($localThemeDir);
}
/*
* set i18n translate category.
*/
Yii::$service->page->translate->category = 'appadmin';
/*
* 自定义Yii::$classMap,用于重写
*/
} | init theme component property : $fecshopThemeDir and $layoutFile
$fecshopThemeDir is appfront base theme directory.
layoutFile is current layout relative path. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LogoutController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LogoutController.php | BSD-3-Clause |
public function render($view, $params = [])
{
$viewFile = Yii::$service->page->theme->getViewFile($view);
$content = Yii::$app->view->renderFile($viewFile, $params, $this);
return $this->renderContent($content);
} | @param $view|string , (only) view file name ,by this module id, this controller id , generate view relative path.
@param $params|Array,
1.get exist view file from mutil theme by theme protity.
2.get content by yii view compontent function renderFile() , | render | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LogoutController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LogoutController.php | BSD-3-Clause |
public function findLayoutFile($view)
{
$layoutFile = '';
$relativeFile = 'layouts/'.Yii::$service->page->theme->layoutFile;
$absoluteDir = Yii::$service->page->theme->getThemeDirArr();
foreach ($absoluteDir as $dir) {
if ($dir) {
$file = $dir.'/'.$relativeFile;
if (file_exists($file)) {
$layoutFile = $file;
return $layoutFile;
}
}
}
throw new InvalidValueException('layout file is not exist!');
} | Get current layoutFile absolute path from mutil theme dir by protity. | findLayoutFile | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/LogoutController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/LogoutController.php | BSD-3-Clause |
public function actionIndex()
{
$block = $this->getBlock();
if(CRequest::param("method") == 'reflush'){
$block->reflush();
}
$data = $block->getLastData();
return $this->render($this->action->id,$data);
} | 刷新缓存 | actionIndex | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/CacheController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/CacheController.php | BSD-3-Clause |
public function actionManager()
{
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 权限 | actionManager | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/RoleController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/RoleController.php | BSD-3-Clause |
public function actionManageredit()
{
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 权限 | actionManageredit | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/RoleController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/RoleController.php | BSD-3-Clause |
public function actionManagereditsave()
{
$this->getBlock("manageredit")->save();
} | 权限 | actionManagereditsave | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/RoleController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/RoleController.php | BSD-3-Clause |
public function actionManagerdelete()
{
$this->getBlock("manageredit")->delete();
} | 权限 | actionManagerdelete | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/RoleController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/RoleController.php | BSD-3-Clause |
public function actionManager()
{
echo '<div style="padding:20px;">该功能废弃</div>';
} | 刷新缓存 | actionManager | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/SystemlogController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/SystemlogController.php | BSD-3-Clause |
public function actionIndex()
{
echo "<br><b> Page: 404 !!!! ,页面找不到 ".Yii::$app->request->getUrl().",,请先建立相应的module/controller/action
,再访问该URL
</b>";
exit;
} | 刷新缓存 | actionIndex | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/ErrorController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/ErrorController.php | BSD-3-Clause |
public function actionManager()
{
//echo $this->action->id ;exit;
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 我的账户
public function actionIndex()
{
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
}
我的账户 | actionManager | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/AccountController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/AccountController.php | BSD-3-Clause |
public function actionIndex()
{
$data = $this->getBlock()->getLastData();
return $this->render($this->action->id,$data);
} | 我的账户 | actionIndex | php | fecshop/yii2_fecshop | app/appadmin/modules/Fecadmin/controllers/MyaccountController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Fecadmin/controllers/MyaccountController.php | BSD-3-Clause |
public function getLastData()
{
$primaryKey = Yii::$service->helper->errorHandler->getPrimaryKey();
$primaryVal = Yii::$app->request->get($primaryKey);
$errorHander = Yii::$service->helper->errorHandler->getByPrimaryKey($primaryVal);
return $errorHander->attributes;
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/error/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/error/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('system/error/manageredit');
/*
* service component, data provider
*/
$this->_service = Yii::$service->helper->errorHandler;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/error/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/error/Index.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Id'),
'name' => Yii::$service->helper->errorHandler->getPrimaryKey(),
'columns_type' => 'string',
],
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Category'),
'name' => 'category',
'columns_type' =>'string', // int使用标准匹配, string使用模糊查询
'value'=> [ // select 类型的值
'appfront' =>'appfront',
'apphtml5' =>'apphtml5',
'appapi' =>'appapi',
'appserver' =>'appserver',
],
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' => 'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/error/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/error/Index.php | BSD-3-Clause |
public function getEditBar()
{
/*
if(!strstr($this->_currentParamUrl,"?")){
$csvUrl = $this->_currentParamUrl."?type=export";
}else{
$csvUrl = $this->_currentParamUrl."&type=export";
}
<li class="line">line</li>
<li><a class="icon csvdownload" href="'.$csvUrl.'" target="dwzExport" targetType="navTab" title="实要导出这些记录吗?"><span>导出EXCEL</span></a></li>
*/
return '<ul class="toolBar">
</ul>';
} | get edit html bar, it contains add ,eidt ,delete button. | getEditBar | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/error/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/error/Index.php | BSD-3-Clause |
public function getLastData($developer_info)
{
$addon_author = isset($developer_info['addon_author']) ? $developer_info['addon_author'] : '';
$package = isset($developer_info['package']) ? $developer_info['package'] : '';
return [
'addon_author' => $addon_author,
'package' => $package,
'saveUrl' => Yii::$service->url->getUrl('system/adminurlkey/manager'),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/adminurlkey/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/adminurlkey/Manager.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Managerview.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Managerview.php | BSD-3-Clause |
public function save()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$this->_service->save($this->_param, 'cms/article/index');
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Managerview.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Managerview.php | BSD-3-Clause |
public function extensionEnable()
{
$ids = Yii::$app->request->post('ids');
$idArr = explode(',', $ids);
if (!Yii::$service->extension->enableAddons($idArr)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('Enable Extension fail'),
]);
exit;
}
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Enable Extension Success') ,
]);
exit;
} | 插件激活 | extensionEnable | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Managerview.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Managerview.php | BSD-3-Clause |
public function extensionDisable()
{
$ids = Yii::$app->request->post('ids');
$idArr = explode(',', $ids);
if (!Yii::$service->extension->disableAddons($idArr)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('Enable Extension fail'),
]);
exit;
}
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Enable Extension Success') ,
]);
exit;
} | 插件关闭 | extensionDisable | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Managerview.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Managerview.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | BSD-3-Clause |
public function save()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$status = $this->_param['status'];
$priority = $this->_param['priority'];
$id = $this->_param['id'];
if (!$status) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('status can not empty'),
]);
exit;
}
if (!$priority) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('priority can not empty'),
]);
exit;
}
if (!$id) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('id can not empty'),
]);
exit;
}
$saveStatus = $this->_service->save([
'id' => $id,
'priority' => $priority,
'status' => $status,
]);
if (!$saveStatus) {
$errors = Yii::$service->helper->errors->get();
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | BSD-3-Clause |
public function extensionEnable()
{
$ids = Yii::$app->request->post('ids');
$idArr = explode(',', $ids);
if (!Yii::$service->extension->enableAddons($idArr)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('Enable Extension fail'),
]);
exit;
}
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Enable Extension Success') ,
]);
exit;
} | 插件激活 | extensionEnable | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | BSD-3-Clause |
public function extensionDisable()
{
$ids = Yii::$app->request->post('ids');
$idArr = explode(',', $ids);
if (!Yii::$service->extension->disableAddons($idArr)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('Enable Extension fail'),
]);
exit;
}
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Enable Extension Success') ,
]);
exit;
} | 插件关闭 | extensionDisable | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('system/extensioninstalled/manageredit');
$this->_viewUrl = CUrl::getUrl('system/extensioninstalled/managerview');
/*
* delete data url
*/
$this->_enableUrl = CUrl::getUrl('system/extensioninstalled/managerenable');
$this->_disableUrl = CUrl::getUrl('system/extensioninstalled/managerdisable');
/*
* service component, data provider
*/
$this->_service = Yii::$service->extension;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Extension Type'),
'name' => 'type',
'columns_type' => 'string', // int使用标准匹配, string使用模糊查询
'value' => Yii::$service->extension->getTypeArr(),
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' => 'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensioninstalled/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensioninstalled/Manager.php | BSD-3-Clause |
public function getLastData($developer_info)
{
$addon_author = isset($developer_info['addon_author']) ? $developer_info['addon_author'] : '';
$package = isset($developer_info['package']) ? $developer_info['package'] : '';
return [
'addon_author' => $addon_author,
'package' => $package,
'saveUrl' => Yii::$service->url->getUrl('system/extensiongii/manager'),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensiongii/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensiongii/Manager.php | BSD-3-Clause |
public function init()
{
// parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensionmarket/Login.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensionmarket/Login.php | BSD-3-Clause |
public function init()
{
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensionmarket/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensionmarket/Manager.php | BSD-3-Clause |
public function getToolBar($numCount, $pageNum, $numPerPage)
{
return '<div class="pages">
<span>' . Yii::$service->page->translate->__('Show') . '</span>
<span>' . Yii::$service->page->translate->__('Line, Total {numCount} Line', ['numCount' => $numCount]) . '</span>
</div>
<div class="pagination" targetType="navTab" totalCount="'.$numCount.'" numPerPage="'.$numPerPage.'" pageNumShown="10" currentPage="'.$pageNum.'"></div>
';
} | list pager, it contains numPerPage , pageNum , totalNum. | getToolBar | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensionmarket/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensionmarket/Manager.php | BSD-3-Clause |
public function initInstalledExtensions()
{
$filter = [
'asArray' => true,
'fetchAll' => true,
];
$data = Yii::$service->extension->coll($filter);
$installedArr = [];
$versionArr = [];
$localCreatedArr = [];
if (is_array($data['coll'])) {
foreach ($data['coll'] as $one) {
$namespace = $one['namespace'];
if ($namespace) {
if (Yii::$service->extension->isInstalledStatus($one['installed_status'])) {
$installedArr[] = $namespace;
}
if (Yii::$service->extension->isTypeLocalCreated($one['type'])) {
$localCreatedArr[] = $namespace;
}
$versionArr[$namespace] = $one['installed_version'];
}
}
}
$this->versionArr = $versionArr;
$this->installedNameSpaceArr = $installedArr;
$this->localCreatedArr = $localCreatedArr;
} | namespace | initInstalledExtensions | php | fecshop/yii2_fecshop | app/appadmin/modules/System/block/extensionmarket/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/block/extensionmarket/Manager.php | BSD-3-Clause |
public function actionUpgrade()
{
$namespace = Yii::$app->request->get('namespace');
$packageName = Yii::$app->request->get('packageName');
$addonName = Yii::$app->request->get('addonName');
$folderName = Yii::$app->request->get('folderName');
// 进行zip文件下载到指定的文件路径
$zipFilePath = Yii::$service->extension->remoteService->downloadAddons($namespace, $packageName, $folderName, $addonName);
if (!$zipFilePath) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('download remote addons fail'),
]);
exit;
}
// 进行zip文件的解压
$dest_dir = dirname($zipFilePath);
if (!Yii::$service->helper->zipFile->unzip($zipFilePath, $dest_dir, true, true)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('unzip addons fail'),
]);
exit;
}
// 删除zip压缩包
unlink($zipFilePath);
/**
* 对于某些比较大的应用插件,下载时间可能需要几分钟
* 对于mysql,如果设置了超时时间,会超时导致无法执行sql,进行mysql重连。报错
* 因此下面对mysql进行了关闭,重新打开
*/
\Yii::$app->db->close();
\Yii::$app->db->open();
// 将addons信息写入数据库
/*
array(6) {
["id"]=>
string(2) "50"
["namespace"]=>
string(13) "fectfurnilife"
["package"]=>
string(7) "fecmall"
["name"]=>
string(15) "furnilife_theme"
["config_file_path"]=>
string(26) "furnilife_theme/config.php"
["version"]=>
string(5) "1.0.0"
}
*/
$data = Yii::$service->extension->remoteService->getAddonsInfoByNamespace($namespace);
if (!is_array($data)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('get remote addons info by namespace fail'),
]);
exit;
}
// 将远程获取的数据,保存到数据库中。
if (!Yii::$service->extension->upgradeInit($data)){
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('init new install addon to db fail'),
]);
exit;
}
// 进行插件的升级
if (!Yii::$service->extension->administer->upgrade($namespace)) {
$errors = Yii::$service->helper->errors->get(',');
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__($errors),
]);
exit;
}
// 输入安装成功信息。
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('addons install success'),
]);
exit;
} | 升级 | actionUpgrade | php | fecshop/yii2_fecshop | app/appadmin/modules/System/controllers/ExtensionmarketController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/controllers/ExtensionmarketController.php | BSD-3-Clause |
public function actionHandupgrade()
{
$namespace = Yii::$app->request->get('namespace');
$packageName = Yii::$app->request->get('packageName');
$addonName = Yii::$app->request->get('addonName');
$folderName = Yii::$app->request->get('folderName');
// zip下载文件
$zipFilePath = Yii::$service->extension->remoteService->getExtensionZipFilePath($packageName, $folderName);
if (!file_exists($zipFilePath)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('hand upgrade fail: '.$zipFilePath. ', is not exist'),
]);
exit;
}
if (!is_executable($zipFilePath)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('hand upgrade fail: '.$zipFilePath. ', is not executable'),
]);
exit;
}
// 进行zip文件的解压
$dest_dir = dirname($zipFilePath);
if (!Yii::$service->helper->zipFile->unzip($zipFilePath, $dest_dir, true, true)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('unzip addons fail'),
]);
exit;
}
// 删除zip压缩包
unlink($zipFilePath);
/**
* 对于某些比较大的应用插件,下载时间可能需要几分钟
* 对于mysql,如果设置了超时时间,会超时导致无法执行sql,进行mysql重连。报错
* 因此下面对mysql进行了关闭,重新打开
*/
\Yii::$app->db->close();
\Yii::$app->db->open();
// 将addons信息写入数据库
/*
array(6) {
["id"]=>
string(2) "50"
["namespace"]=>
string(13) "fectfurnilife"
["package"]=>
string(7) "fecmall"
["name"]=>
string(15) "furnilife_theme"
["config_file_path"]=>
string(26) "furnilife_theme/config.php"
["version"]=>
string(5) "1.0.0"
}
*/
$data = Yii::$service->extension->remoteService->getAddonsInfoByNamespace($namespace);
if (!is_array($data)) {
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('get remote addons info by namespace fail'),
]);
exit;
}
// 将远程获取的数据,保存到数据库中。
if (!Yii::$service->extension->upgradeInit($data)){
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__('init new install addon to db fail'),
]);
exit;
}
// 进行插件的升级
if (!Yii::$service->extension->administer->upgrade($namespace)) {
$errors = Yii::$service->helper->errors->get(',');
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__($errors),
]);
exit;
}
// 输入安装成功信息。
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('addons install success'),
]);
exit;
} | hand升级 | actionHandupgrade | php | fecshop/yii2_fecshop | app/appadmin/modules/System/controllers/ExtensionmarketController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/controllers/ExtensionmarketController.php | BSD-3-Clause |
public function actionUninstall()
{
$namespace = Yii::$app->request->get('namespace');
$packageName = Yii::$app->request->get('packageName');
$addonName = Yii::$app->request->get('addonName');
$folderName = Yii::$app->request->get('folderName');
// 进行插件的卸载
if (!Yii::$service->extension->administer->uninstall($namespace)) {
$errors = Yii::$service->helper->errors->get(',');
echo json_encode([
'statusCode' => '300',
'message' => Yii::$service->page->translate->__($errors),
]);
exit;
}
// 输出卸载成功信息。
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('addons uninstall success'),
]);
exit;
} | 卸载 | actionUninstall | php | fecshop/yii2_fecshop | app/appadmin/modules/System/controllers/ExtensionmarketController.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/System/controllers/ExtensionmarketController.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('catalog/urlrewrite/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('catalog/urlrewrite/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->url->rewrite;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/urlrewrite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/urlrewrite/Index.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Origin Url'),
'name' => 'origin_url',
'columns_type' => 'string',
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Custom Url'),
'name' => 'custom_url_key',
'columns_type' => 'string',
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/urlrewrite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/urlrewrite/Index.php | BSD-3-Clause |
public function getTableFieldArr()
{
$table_th_bar = [
[
'orderField' => $this->_primaryKey,
'label' => Yii::$service->page->translate->__('Id'),
'width' => '50',
'align' => 'center',
],
[
'orderField' => 'type',
'label' => Yii::$service->page->translate->__('Type'),
'width' => '50',
'align' => 'left',
],
[
'orderField' => 'custom_url_key',
'label' => Yii::$service->page->translate->__('Custom Url'),
'width' => '110',
'align' => 'left',
],
[
'orderField' => 'origin_url',
'label' => Yii::$service->page->translate->__('Origin Url'),
'width' => '110',
'align' => 'left',
],
];
return $table_th_bar;
} | config function ,return table columns config. | getTableFieldArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/urlrewrite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/urlrewrite/Index.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrandcategory/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrandcategory/Manageredit.php | BSD-3-Clause |
public function save()
{
$this->_param = Yii::$app->request->post($this->_editFormData);
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$this->_service->save($this->_param);
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success') ,
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrandcategory/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrandcategory/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = Yii::$service->url->getUrl('catalog/productbrandcategory/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = Yii::$service->url->getUrl('catalog/productbrandcategory/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->brandcategory;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrandcategory/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrandcategory/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' =>'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrandcategory/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrandcategory/Manager.php | BSD-3-Clause |
public function getLastData()
{
$display_data = $this->_one['display_data'];
$display_type = $this->_one['display_type'];
if ($display_data) {
$display_data = unserialize($display_data);
}
$displayTypes = Yii::$service->product->attr->getDisplayTypes();
return [
'editBar' => $this->getEditBar(),
'display_data' => $display_data,
'display_type' => $display_type,
'display_types' => $displayTypes,
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattr/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattr/Manageredit.php | BSD-3-Clause |
public function getSaveDisplayData()
{
$dd = $this->_param['display_data'];
$display_data_arr = [];
if ($dd) {
$arr = explode('||', $dd );
foreach ($arr as $a) {
if ($a) {
$display_data_arr[] = [
'key' => $a,
];
}
}
}
if (empty($display_data_arr)) {
return '';
}
return serialize($display_data_arr);
} | display_data | getSaveDisplayData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattr/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattr/Manageredit.php | BSD-3-Clause |
public function save()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$this->_param['display_data'] = $this->getSaveDisplayData();
$this->_service->save($this->_param);
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success') ,
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattr/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattr/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('catalog/productattr/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('catalog/productattr/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->attr;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattr/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattr/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattr/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattr/Manager.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'review' => $this->_one,
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productreview/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productreview/Manageredit.php | BSD-3-Clause |
public function save()
{
$request_param = CRequest::param();
$this->_param = $request_param[$this->_editFormData];
/**
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$identity = Yii::$app->user->identity;
$audit_user_id = $identity['id'];
$this->_param['audit_user'] = $audit_user_id;
$this->_param['audit_date'] = time();
//$this->_param['review_date'] = strtotime($this->_param['review_date']);
$this->_service->save($this->_param);
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productreview/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productreview/Manageredit.php | BSD-3-Clause |
public function init()
{
$this->_auditUrl = CUrl::getUrl('catalog/productreview/manageraudit');
$this->_auditRejectedUrl = CUrl::getUrl('catalog/productreview/managerauditrejected');
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('catalog/productreview/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('catalog/productreview/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->review;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productreview/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productreview/Index.php | BSD-3-Clause |
public function getSearchArr()
{
$activeStatus = Yii::$service->product->review->activeStatus();
$refuseStatus = Yii::$service->product->review->refuseStatus();
$noActiveStatus = Yii::$service->product->review->noActiveStatus();
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Review Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
$noActiveStatus => Yii::$service->page->translate->__('Pending Review'),
$activeStatus => Yii::$service->page->translate->__('Approved'),
$refuseStatus => Yii::$service->page->translate->__('Not Approved'),
],
],
[ // 字符串类型
'type' => 'inputtext',
'title' => Yii::$service->page->translate->__('Spu'),
'name' => 'product_spu',
'columns_type' => 'string',
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'title' => Yii::$service->page->translate->__('Review Date'),
'name' => 'review_date',
'columns_type' => 'int',
'value'=>[
'gte' => Yii::$service->page->translate->__('Review Begin'),
'lt' => Yii::$service->page->translate->__('Review End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productreview/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productreview/Index.php | BSD-3-Clause |
public function init()
{
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->favorite;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productfavorite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productfavorite/Index.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
/*
[ # 字符串类型
'type'=>'inputtext',
'title'=>'product_id',
'name'=>'product_id' ,
'columns_type' =>'string'
],
*/
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' =>'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productfavorite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productfavorite/Index.php | BSD-3-Clause |
public function getEditBar()
{
return '';
} | get edit html bar, it contains add ,eidt ,delete button. | getEditBar | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productfavorite/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productfavorite/Index.php | BSD-3-Clause |
public function getLastData()
{
return [
'editBar' => $this->getEditBar(),
'textareas' => $this->_textareas,
'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
'image' => $this->_one['logo'],
'imageurl' => Yii::$service->category->image->getUrl($this->_one['logo']),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrand/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrand/Manageredit.php | BSD-3-Clause |
public function save()
{
$this->_param = Yii::$app->request->post($this->_editFormData);
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
$image = Yii::$app->request->post('image');
$this->_param['logo'] = $image;
$this->_service->save($this->_param);
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success') ,
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrand/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrand/Manageredit.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = Yii::$service->url->getUrl('catalog/productbrand/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = Yii::$service->url->getUrl('catalog/productbrand/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->brand;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrand/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrand/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
[ // 时间区间类型搜索
'type' => 'inputdatefilter',
'name' => 'created_at',
'columns_type' =>'int',
'value' => [
'gte' => Yii::$service->page->translate->__('Created Begin'),
'lt' => Yii::$service->page->translate->__('Created End'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productbrand/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productbrand/Manager.php | BSD-3-Clause |
public function saveUploadExcelFile($fileFullDir){
$name = $_FILES["file"]["name"];
$fileFullDir .= 'product_'.time().'_'.rand(1000,9999);
if(strstr($name,'.xlsx')){
$fileFullDir .='.xlsx';
} else if (strstr($name,'.xls')){
$fileFullDir .='.xls';
}
$this->_fileFullDir = $fileFullDir;
$result = @move_uploaded_file($_FILES["file"]["tmp_name"],$fileFullDir);
return $result;
} | 1.保存前台上传的文件。 | saveUploadExcelFile | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productupload/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productupload/Manager.php | BSD-3-Clause |
public function init()
{
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('catalog/productattrgroup/manageredit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('catalog/productattrgroup/managerdelete');
/*
* service component, data provider
*/
$this->_service = Yii::$service->product->attrGroup;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattrgroup/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattrgroup/Manager.php | BSD-3-Clause |
public function getSearchArr()
{
$data = [
[ // selecit的Int 类型
'type' => 'select',
'title' => Yii::$service->page->translate->__('Status'),
'name' => 'status',
'columns_type' => 'int', // int使用标准匹配, string使用模糊查询
'value' => [ // select 类型的值
1 => Yii::$service->page->translate->__('Enable'),
2 => Yii::$service->page->translate->__('Disable'),
],
],
];
return $data;
} | get search bar Arr config. | getSearchArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productattrgroup/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productattrgroup/Manager.php | BSD-3-Clause |
public function init()
{
/*
* service component, data provider
*/
// parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/categoryupload/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/categoryupload/Manager.php | BSD-3-Clause |
public function saveUploadExcelFile($fileFullDir){
$name = $_FILES["file"]["name"];
$fileFullDir .= 'category_'.time().'_'.rand(1000,9999);
if(strstr($name,'.xlsx')){
$fileFullDir .='.xlsx';
} else if (strstr($name,'.xls')){
$fileFullDir .='.xls';
}
$this->_fileFullDir = $fileFullDir;
$result = @move_uploaded_file($_FILES["file"]["tmp_name"],$fileFullDir);
return $result;
} | 1.保存前台上传的文件。 | saveUploadExcelFile | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/categoryupload/Manager.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/categoryupload/Manager.php | BSD-3-Clause |
public function getCategoryByProductId($product_id)
{
return Yii::$service->product->getCategoryIdsByProductId($product_id);
} | 得到產品的分類id | getCategoryByProductId | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Getproductcategory.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Getproductcategory.php | BSD-3-Clause |
public function getLastData()
{
return [
'baseInfo' => $this->getBaseInfo(),
'priceInfo' => $this->getPriceInfo(),
'tier_price' => $this->_one['tier_price'],
'metaInfo' => $this->getMetaInfo(),
'groupAttr' => $this->getGroupAttr(),
'descriptionInfo' => $this->getDescriptionInfo(),
'attrGroup' => $this->_attr->getProductAttrGroupSelect(),
'primaryInfo' => $this->getCurrentProductPrimay(),
'img_html' => $this->getImgHtml(),
'custom_option' => $this->_one['custom_option'],
'product_id' => $this->_one[Yii::$service->product->getPrimaryKey()],
//'editBar' => $this->getEditBar(),
//'textareas' => $this->_textareas,
//'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
'operate' => Yii::$app->request->get('operate'),
'custom_option_add' => $this->getCustomOptionAdd(),
'custom_option_img' => $this->getCustomOpImgHtml(),
'custom_option_list'=> $this->_custom_option_list_str,
'relation' => $this->getRelationInfo(),
'thirdInfo' => $this->getThirdDataInfo(),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Manageredit.php | BSD-3-Clause |
public function save()
{
$this->initParamType();
/*
* if attribute is date or date time , db storage format is int ,by frontend pass param is int ,
* you must convert string datetime to time , use strtotime function.
*/
// var_dump()
if (Yii::$app->request->post('operate') == 'copy') {
$productPrimaryKey = Yii::$service->product->getPrimaryKey();
if (isset($this->_param[$productPrimaryKey])) {
unset($this->_param[$productPrimaryKey]);
//echo 111;
//var_dump($this->_param);
//exit;
}
}
$this->_service->save($this->_param, 'catalog/product/index');
$errors = Yii::$service->helper->errors->get();
if (!$errors) {
echo json_encode([
'statusCode' => '200',
'message' => Yii::$service->page->translate->__('Save Success'),
]);
exit;
} else {
echo json_encode([
'statusCode' => '300',
'message' => $errors,
]);
exit;
}
} | save article data, get rewrite url and save to article url key. | save | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Manageredit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Manageredit.php | BSD-3-Clause |
public function getLastData()
{
return [
'baseInfo' => $this->getBaseInfo(),
'priceInfo' => $this->getPriceInfo(),
'tier_price' => $this->_one['tier_price'],
'metaInfo' => $this->getMetaInfo(),
'groupGeneralAttr' => $this->getGroupGeneralAttr(),
'groupSpuAttr' => $this->getGroupSpuAttr(),
'descriptionInfo' => $this->getDescriptionInfo(),
'attrGroup' => $this->_attr->getProductAttrGroupSelect(),
'primaryInfo' => $this->getCurrentProductPrimay(),
'img_html' => $this->getImgHtml(),
'custom_option' => $this->_one['custom_option'],
'product_id' => $this->_one[Yii::$service->product->getPrimaryKey()],
//'editBar' => $this->getEditBar(),
//'textareas' => $this->_textareas,
//'lang_attr' => $this->_lang_attr,
'saveUrl' => $this->_saveUrl,
'operate' => Yii::$app->request->get('operate'),
'custom_option_add' => $this->getCustomOptionAdd(),
'custom_option_img' => $this->getCustomOpImgHtml(),
'custom_option_list'=> $this->_custom_option_list_str,
'relation' => $this->getRelationInfo(),
'thirdInfo' => $this->getThirdDataInfo(),
];
} | 传递给前端的数据 显示编辑form | getLastData | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Managerbatchedit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Managerbatchedit.php | BSD-3-Clause |
public function getSpuArr($spu_attrs)
{
if (!$spu_attrs) {
return null;
}
$arr = [];
$spu_arrs = explode('***', $spu_attrs);
foreach ($spu_arrs as $spu_arr) {
if ($spu_arr) {
$spu_attr_arr = explode('|||', $spu_arr);
$arr2 = [];
foreach ($spu_attr_arr as $spu_attr_one) {
if ($spu_attr_one) {
list($attr, $val) = explode('###', $spu_attr_one);
$arr2[$attr] = $val;
}
}
$arr[] = $arr2;
}
}
return $arr;
} | 字符串解析出来数组。 | getSpuArr | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Managerbatchedit.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Managerbatchedit.php | BSD-3-Clause |
public function init()
{
/**
* 通过Yii::mapGet() 得到重写后的class类名以及对象。Yii::mapGet是在文件@fecshop\yii\Yii.php中
*/
list($this->_productHelperName,$this->_productHelper) = Yii::mapGet($this->_productHelperName);
/*
* edit data url
*/
$this->_editUrl = CUrl::getUrl('catalog/productinfo/manageredit');
$this->_batchInsertUrl = CUrl::getUrl('catalog/productinfo/managerbatchedit');
/*
* delete data url
*/
$this->_deleteUrl = CUrl::getUrl('catalog/productinfo/managerdelete');
$this->_copyUrl = CUrl::getUrl('catalog/productinfo/manageredit', ['operate'=>'copy']);
/*
* service component, data provider
*/
$this->_service = Yii::$service->product;
parent::init();
} | init param function ,execute in construct. | init | php | fecshop/yii2_fecshop | app/appadmin/modules/Catalog/block/productinfo/Index.php | https://github.com/fecshop/yii2_fecshop/blob/master/app/appadmin/modules/Catalog/block/productinfo/Index.php | BSD-3-Clause |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.