/** * 添加/编辑文章保存 */ public function saveNote() { // 文章Model实例化 $noteModel = D('Note'); // post提交参数 $data = $_POST; if (empty($data['title'])) { alert('标题不能为空!'); } // 文章内容 if (empty($data['content'])) { alert('内容不能为空!'); } $data['content'] = urldecode($data['content']); if ($data['pic_path']) { $data['type'] = 1; } else { $data['type'] = 0; } // 编辑日记 if ($data['id']) { // 添加操作日志 TODO $linkDetail = $noteModel->field('title,content,pic_path')->where('id = ' . $data['id'])->select(); $param = array('title' => $data['title'], 'content' => $data['content'], 'pic_path' => $data['pic_path']); $arr = getChangeCloum($linkDetail, $param); // echo "<pre>";print_r($arr);exit; foreach ($arr as $k => $val) { $this->recordOperations(3, 11, $data['id'], '', '', '', $val['column'], $val['beforeContent'], $val['afterContent']); } // 编辑文章保存 $res = $noteModel->editNote($data); if ($res) { showmsg('日记修改成功!', '/iadmin.php/Note/index'); } else { alert('日记修改失败!'); } } else { // 添加日记保存 $id = $noteModel->addNote($data); // 添加操作日志 TODO $this->recordOperations(1, 12, $id); if ($id) { showmsg('日记添加成功!', '/iadmin.php/Note/index'); } else { alert('日记添加失败!'); } } }
/** * 添加/编辑文章保存 */ public function saveArticle() { // 文章Model实例化 $articleModel = D('Article'); // post提交参数 $data = $_POST; // 名称 if ($data['title']) { $param['title'] = $data['title']; } else { alert('文章名称不能为空!'); } // 名称 if ($data['pic_path']) { $param['pic_path'] = $data['pic_path']; } // 一级分类 if ($data['first']) { // 二级分类 if ($data['second']) { $param['second'] = $data['second']; } else { alert('二级分类不能为空!'); } } else { alert('一级分类不能为空!'); } // 摘要 if ($data['summary']) { $param['summary'] = $data['summary']; } else { alert('文章摘要不能为空!'); } // 文章内容 if ($data['content']) { $param['content'] = urldecode($data['content']); } else { alert('文章内容不能为空!'); } // print_r($param);exit(); // 编辑文章,记录到操作日志 if ($data['id']) { // 添加操作日志 TODO $articleDetail = $articleModel->field('cat_id,title,summary,content,pic_path')->where('id = ' . $data['id'])->select(); $list = array('cat_id' => $param['second'], 'title' => $param['title'], 'summary' => $param['summary'], 'content' => $param['content'], 'pic_path' => $param['pic_path']); $arr = getChangeCloum($articleDetail, $list); // echo "<pre>";print_r($arr);exit; foreach ($arr as $k => $val) { $this->recordOperations(3, 7, $data['id'], '', '', '', $val['column'], $val['beforeContent'], $val['afterContent']); } // 编辑文章保存 $param['id'] = $data['id']; $res = $articleModel->editArticle($param); if ($res) { showmsg('文章修改成功!', '/iadmin.php/Article/articleList'); } else { alert('文章修改失败!'); } } else { // 添加文章保存 $res = $articleModel->addArticle($param); // 操作记录 TODO $this->recordOperations(1, 8, $res); if ($res) { showmsg('文章添加成功!', '/iadmin.php/Article/articleList'); } else { alert('文章添加失败!'); } } }
/** * 添加/编辑友情链接保存 */ public function saveLink() { // 友情链接Model实例化 $linkModel = D('Link'); // post提交参数 $data = $_POST; // 标题 if (empty($data['title'])) { alert('站名不能为空!'); } // 链接地址 if (empty($data['url'])) { alert('链接地址不能为空!'); } // 图片 // if ($data['pic_path']) { // $data['type'] = 1; // }else{ // $data['type'] = 0; // } // 编辑链接 if ($data['id']) { // 添加操作日志 TODO $linkDetail = $linkModel->field('sort,title,url,type')->where('id = ' . $data['id'])->select(); $param = array('type' => $data['type'], 'title' => $data['title'], 'url' => $data['url'], 'sort' => $data['sort']); $arr = getChangeCloum($linkDetail, $param); // echo "<pre>";print_r($arr);exit; foreach ($arr as $k => $val) { $this->recordOperations(3, 9, $data['id'], '', '', '', $val['column'], $val['beforeContent'], $val['afterContent']); } // 编辑友情链接保存 $res = $linkModel->editLink($data); if ($res) { showmsg('链接修改成功!', '/iadmin.php/Link/index'); } else { alert('链接修改失败!'); } } else { // 添加链接保存 $id = $linkModel->addLink($data); // 添加操作日志 TODO $this->recordOperations(1, 10, $id); if ($id) { showmsg('链接添加成功!', '/iadmin.php/Link/index'); } else { alert('链接添加失败!'); } } }