public function doSiteSitePost() { if (IS_POST) { $data = json_decode($_POST['data'], TRUE); $data['site_info'] = $_POST['data']; $insertId = $this->web->save($data); $web['id'] = $this->webid ?: $insertId; //添加回复规则 $rule = []; $rule['rid'] = Db::table('reply_cover')->where('web_id', $web['id'])->pluck('rid'); $rule['module'] = 'cover'; $rule['name'] = '微站:' . $data['title']; $rule['keywords'] = [['content' => $data['keyword']]]; $rid = service('WeChat')->rule($rule); //添加封面回复 $replyCover = new ReplyCover(); $replyCover->where('rid', $rid)->delete(); $data['web_id'] = $web['id']; $data['rid'] = $rid; $data['module'] = 'article'; $data['url'] = '?a=entry/home&m=article&t=web&siteid=' . SITEID . '&webid=' . $web['id']; $replyCover->save($data); message('保存站点数据成功', site_url('site'), 'success'); } if ($this->webid) { //编辑数据时 $web = $this->web->find($this->webid); $field = json_decode($web['site_info'], TRUE); $field['id'] = $this->webid; } View::with('field', isset($field) ? json_encode($field, JSON_UNESCAPED_UNICODE) : ''); return View::make($this->template . '/manage/sitePost.php'); }
public function doSitePost() { $webPage = new WebPage(); if (IS_POST) { $modules = json_decode($_POST['modules'], TRUE); //会员中心数据 if (empty($modules[0]['params']['thumb'])) { message('封面图片不能为空', 'back', 'error'); } $data['title'] = $modules[0]['params']['title']; $data['description'] = $modules[0]['params']['description']; $data['params'] = $modules; $data['html'] = $_POST['html']; $data['type'] = 3; $data['status'] = 1; $res = $webPage->where('siteid', SITEID)->where('type', 3)->first() ?: []; $data['id'] = empty($res['id']) ? 0 : $res['id']; $webPage->save($data); //添加菜单,首先删除原菜单 $menus = json_decode($_POST['menus'], TRUE); //删除旧的菜单 $webNavModel = new WebNav(); $webNavModel->where('siteid', SITEID)->where('entry', 'profile')->delete(); foreach ((array) $menus as $m) { if (!empty($m['name'])) { $data = []; $data['name'] = $m['name']; $data['css'] = $m['css']; $data['url'] = $m['url']; $data['icontype'] = 1; $data['entry'] = 'profile'; $webNavModel->save($data); } } //************************************回复关键词处理************************************ $rid = Db::table('rule')->where('siteid', SITEID)->where('name', '##会员中心##')->pluck('rid'); //会员中心顶部资料,回复关键词,描述,缩略图 $ucenter = $modules[0]['params']; //添加回复规则 $rule['rid'] = $rid; $rule['name'] = '##会员中心##'; $rule['module'] = 'cover'; //回复关键词 $rule['keywords'] = [['content' => $ucenter['keyword']]]; service('WeChat')->rule($rule); //回复封面 $replyCover = new ReplyCover(); $cover['rid'] = $rid; $cover['title'] = $ucenter['title']; $cover['description'] = $ucenter['description']; $cover['thumb'] = $ucenter['thumb']; $cover['url'] = "?a=entry/home&t=web&m=uc&siteid=" . SITEID; $replyCover->where('rid', $rid)->delete(); $replyCover->save($cover); message('会员中心视图保存成功', 'refresh', 'success'); } //模块 $modules = $webPage->where('siteid', SITEID)->where('type', 3)->pluck('params'); //菜单 $menusData = Db::table('web_nav')->where('siteid', SITEID)->where('entry', 'profile')->field('id,name,url,css')->orderBy('orderby', 'desc')->orderBy('id', 'asc')->get() ?: []; //将CSS样式返序列化,用于显示图标等信息 foreach ($menusData as $k => $v) { $menusData[$k]['css'] = json_decode($v['css'], TRUE); } View::with('rid', Db::table('rule')->where('siteid', SITEID)->where('name', '##会员中心##')->pluck('rid')); View::with(['modules' => $modules, 'menusData' => $menusData]); return View::make($this->template . '/ucenter/post.php'); }
public function cover() { //验证登录 service('user')->loginAuth(); //后台分配菜单 service('menu')->assign(); if (!service('module')->verifyModuleAccess()) { message('你没有操作权限', 'back', 'error'); } $bid = Request::get('bid'); $replyCover = new ReplyCover(); $moduleBindings = Db::table('modules_bindings')->where('bid', $bid)->first(); if (IS_POST) { Validate::make([['title', 'required', '标题不能为空'], ['description', 'required', '描述不能为空'], ['thumb', 'required', '封面图片不能为空']]); $data = json_decode($_POST['keyword'], TRUE); $data['rid'] = $replyCover->where('module', v('module.name'))->where('do', $moduleBindings['do'])->pluck('rid'); $data['module'] = 'cover'; $data['rank'] = $data['istop'] == 1 ? 255 : min(255, intval($data['rank'])); $data['keywords'] = $data['keyword']; $rid = service('WeChat')->rule($data); //添加封面回复 $replyCover['id'] = $replyCover->where('rid', $rid)->pluck('id'); $replyCover['do'] = $moduleBindings['do']; $replyCover['rid'] = $rid; $replyCover['title'] = $_POST['title']; $replyCover['description'] = $_POST['description']; $replyCover['thumb'] = $_POST['thumb']; $replyCover['url'] = $_POST['url']; $replyCover['module'] = v('module.name'); $replyCover->save(); message('功能封面更新成功', 'back', 'success'); } $field = $replyCover->where('siteid', SITEID)->where('module', v('module.name'))->where('do', $moduleBindings['do'])->first(); //获取关键词回复 if ($field) { $data = Db::table('rule')->where('rid', $field['rid'])->first(); $data['keyword'] = Db::table('rule_keyword')->orderBy('id', 'asc')->where('rid', $field['rid'])->get() ?: []; View::with('rule', $data); } $field['url'] = '?a=site/' . $moduleBindings['do'] . "&siteid=" . SITEID . "&t=web&m=" . v('module.name'); $field['name'] = $moduleBindings['title']; return view()->with('field', $field); }