This commit is contained in:
Gitea
2022-01-24 10:43:35 +08:00
commit 15dfc6576b
786 changed files with 219240 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年04月17日
* 公司设置控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\CompanyModel;
class CompanyController extends Controller
{
private $model;
public function __construct()
{
$this->model = new CompanyModel();
}
// 显示公司设置
public function index()
{
// 获取公司配置
$this->assign('companys', $this->model->getList());
$this->display('content/company.html');
}
// 修改公司设置
public function mod()
{
if (! $_POST) {
return;
}
$data = array(
'name' => post('name'),
'address' => post('address'),
'postcode' => post('postcode'),
'contact' => post('contact'),
'mobile' => post('mobile'),
'phone' => post('phone'),
'fax' => post('fax'),
'email' => post('email'),
'qq' => post('qq'),
'weixin' => post('weixin'),
'blicense' => post('blicense'),
'other' => post('other')
);
if ($this->model->checkCompany()) {
if ($this->model->modCompany($data)) {
$this->log('修改公司信息成功!');
success('修改成功!', - 1);
} else {
location(- 1);
}
} else {
$data['acode'] = session('acode');
if ($this->model->addCompany($data)) {
$this->log('修改公司信息成功!');
success('修改成功!', - 1);
} else {
location(- 1);
}
}
}
}

View File

@@ -0,0 +1,551 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年12月15日
* 文章控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\ContentModel;
class ContentController extends Controller
{
private $model;
private $blank;
public function __construct()
{
$this->model = new ContentModel();
}
// 文章列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getContent($id)) {
$this->assign('more', true);
$this->assign('content', $result);
} else {
$this->assign('list', true);
if (! $mcode = get('mcode', 'var')) {
error('传递的模型编码参数有误,请核对后重试!');
}
if (isset($_GET['keyword'])) {
if (! ! $scode = get('scode', 'var')) {
$result = $this->model->findContent($mcode, $scode, get('keyword', 'vars'));
} else {
$result = $this->model->findContentAll($mcode, get('keyword', 'vars'));
}
} else {
$result = $this->model->getList($mcode);
}
$this->assign('contents', $result);
// 文章分类下拉列表
$sort_model = model('admin.content.ContentSort');
$sort_select = $sort_model->getListSelect($mcode);
$this->assign('search_select', $this->makeSortSelect($sort_select, get('scode')));
$this->assign('sort_select', $this->makeSortSelect($sort_select, session('addscode')));
$this->assign('subsort_select', $this->makeSortSelect($sort_select));
// 模型名称
$this->assign('model_name', model('admin.content.Model')->getName($mcode));
// 扩展字段
$this->assign('extfield', model('admin.content.ExtField')->getModelField($mcode));
$this->assign('baidu_zz_token', $this->config('baidu_zz_token'));
$this->assign('baidu_ks_token', $this->config('baidu_ks_token'));
// 前端地址连接符判断
$url_break_char = $this->config('url_break_char') ?: '_';
$this->assign('url_break_char', $url_break_char);
// 获取会员分组
$this->assign('groups', model('admin.member.MemberGroup')->getSelect());
}
$this->display('content/content.html');
}
// 文章增加
public function add()
{
if ($_POST) {
// 获取数据
$scode = post('scode');
$subscode = post('subscode');
$title = post('title');
$titlecolor = post('titlecolor');
$subtitle = post('subtitle');
$filename = trim(post('filename'), '/');
$author = post('author');
$source = post('source');
$outlink = post('outlink');
$date = post('date');
$ico = post('ico');
$pics = post('pics');
// 获取多图标题
$picstitle = post('picstitle');
if ($picstitle) {
$picstitle = implode(',', $picstitle);
}
$content = post('content');
$tags = str_replace('', ',', post('tags'));
$enclosure = post('enclosure');
$keywords = post('keywords');
$description = post('description');
$status = post('status', 'int');
$istop = post('istop', 'int', '', '', 0);
$isrecommend = post('isrecommend', 'int', '', '', 0);
$isheadline = post('isheadline', 'int', '', '', 0);
$gid = post('gid', 'int') ?: 0;
$gtype = post('gtype', 'int') ?: 4;
$gnote = post('gnote');
if (! $scode) {
alert_back('内容分类不能为空!');
}
if (! $title) {
alert_back('文章标题不能为空!');
}
if ($filename && ! preg_match('/^[a-zA-Z0-9\-]+$/', $filename)) {
alert_back('内容URL名称只允许字母、数字、横线组成!');
}
// 自动提起前一百个字符为描述
if (! $description && isset($_POST['content'])) {
$description = escape_string(clear_html_blank(substr_both(strip_tags($_POST['content']), 0, 150)));
}
// 缩放缩略图
if ($ico) {
resize_img(ROOT_PATH . $ico, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
// 检查自定义URL名称
if ($filename) {
while ($this->model->checkFilename($filename)) {
$filename = $filename . '-' . mt_rand(1, 20);
}
}
// 记住新增栏目
session('addscode', $scode);
// 构建数据
$data = array(
'acode' => session('acode'),
'scode' => $scode,
'subscode' => $subscode,
'title' => $title,
'titlecolor' => $titlecolor,
'subtitle' => $subtitle,
'filename' => $filename,
'author' => $author,
'source' => $source,
'outlink' => $outlink,
'date' => $date,
'ico' => $ico,
'pics' => $pics,
'picstitle' => $picstitle,
'content' => $content,
'tags' => $tags,
'enclosure' => $enclosure,
'keywords' => $keywords,
'description' => clear_html_blank($description),
'sorting' => 255,
'status' => $status,
'istop' => $istop,
'isrecommend' => $isrecommend,
'isheadline' => $isheadline,
'gid' => $gid,
'gtype' => $gtype,
'gnote' => $gnote,
'visits' => 0,
'likes' => 0,
'oppose' => 0,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if (! ! $id = $this->model->addContent($data)) {
// 扩展内容添加
foreach ($_POST as $key => $value) {
if (preg_match('/^ext_[\w\-]+$/', $key)) {
if (! isset($data2['contentid'])) {
$data2['contentid'] = $id;
}
$temp = post($key);
if (is_array($temp)) {
$data2[$key] = implode(',', $temp);
} else {
$data2[$key] = str_replace("\r\n", '<br>', $temp);
}
}
}
if (isset($data2)) {
if (! $this->model->addContentExt($data2)) {
$this->model->delContent($id);
$this->log('新增文章失败!');
error('新增失败!', - 1);
}
}
$this->log('新增文章成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Content/index/mcode/' . get('mcode')));
}
} else {
$this->log('新增文章失败!');
error('新增失败!', - 1);
}
}
}
// 生成分类选择
private function makeSortSelect($tree, $selectid = null)
{
$list_html = '';
foreach ($tree as $value) {
// 默认选择项
if ($selectid == $value->scode) {
$select = "selected='selected'";
} else {
$select = '';
}
$list_html .= "<option value='{$value->scode}' $select>{$this->blank}{$value->name}";
// 子菜单处理
if ($value->son) {
$this->blank .= '  ';
$list_html .= $this->makeSortSelect($value->son, $selectid);
}
}
// 循环完后回归位置
$this->blank = substr($this->blank, 0, - 6);
return $list_html;
}
// 文章删除
public function del()
{
// 执行批量删除
if ($_POST) {
if (! ! $list = post('list')) {
if ($this->model->delContentList($list)) {
$this->model->delContentExtList($list);
$this->log('批量删除文章成功!');
success('批量删除成功!', - 1);
} else {
$this->log('批量删除文章失败!');
error('批量删除失败!', - 1);
}
} else {
alert_back('请选择要删除的内容!');
}
}
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delContent($id)) {
$this->model->delContentExt($id);
$this->log('删除文章' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除文章' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 文章修改
public function mod()
{
if (! ! $submit = post('submit')) {
switch ($submit) {
case 'sorting': // 修改列表排序
$listall = post('listall');
if ($listall) {
$sorting = post('sorting');
foreach ($listall as $key => $value) {
if ($sorting[$key] === '' || ! is_numeric($sorting[$key]))
$sorting[$key] = 255;
$this->model->modContent($value, "sorting=" . $sorting[$key]);
}
$this->log('修改内容排序成功!');
success('修改成功!', - 1);
} else {
alert_back('排序失败,无任何内容!');
}
break;
case 'copy':
$list = post('list');
$scode = post('scode');
if (! $list) {
alert_back('请选择要复制的内容!');
}
if (! $scode) {
alert_back('请选择目标栏目!');
}
if ($this->model->copyContent($list, $scode)) {
$this->log('复制内容成功!');
success('复制内容成功!', - 1);
} else {
alert_back('复制内容失败!');
}
break;
case 'move':
$list = post('list');
$scode = post('scode');
if (! $list) {
alert_back('请选择要移动的内容!');
}
if (! $scode) {
alert_back('请选择目标栏目!');
}
if ($this->model->modContent($list, "scode='" . $scode . "'")) {
$this->log('移动内容成功!');
success('移动内容成功!', - 1);
} else {
alert_back('移动内容失败!');
}
break;
case 'baiduzz':
$list = post('list');
$urls = post('urls');
if (! $list) {
alert_back('请选择要推送的内容!');
}
// 依次推送
$domain = get_http_url();
if (! $token = $this->config('baidu_zz_token')) {
alert_back('请先到系统配置中填写百度普通收录推送token值');
}
$api = "http://data.zz.baidu.com/urls?site=$domain&token=$token";
foreach ($list as $key => $value) {
$url = $domain . $urls[$value];
$this->log('百度普通收录推送:' . $url);
$post_urls[] = $url;
}
$result = post_baidu($api, $post_urls);
if (isset($result->error)) {
alert_back('百度普通收录推送发生错误:' . $result->message);
} elseif (isset($result->success)) {
alert_back('成功推送' . $result->success . '条,今天剩余可推送' . $result->remain . '条数!');
} else {
alert_back('发生未知错误!');
}
case 'baiduks':
$list = post('list');
$urls = post('urls');
if (! $list) {
alert_back('请选择要推送的内容!');
}
// 依次推送
$domain = get_http_url();
if (! $token = $this->config('baidu_ks_token')) {
alert_back('请先到系统配置中填写百度快速收录推送token值');
}
$api = "http://data.zz.baidu.com/urls?site=$domain&token=$token&type=daily";
foreach ($list as $key => $value) {
$url = $domain . $urls[$value];
$this->log('百度快速收录推送:' . $url);
$post_urls[] = $url;
}
$result = post_baidu($api, $post_urls);
if (isset($result->error)) {
alert_back('百度快速收录推送发生错误:' . $result->message);
} elseif (isset($result->success_daily)) {
alert_back('成功推送' . $result->success_daily . '条,今天剩余可推送' . $result->remain_daily . '条数!');
} else {
alert_back('发生未知错误!');
}
}
}
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modContent($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$scode = post('scode');
$subscode = post('subscode');
$title = post('title');
$titlecolor = post('titlecolor');
$subtitle = post('subtitle');
$filename = trim(post('filename'), '/');
$author = post('author');
$source = post('source');
$outlink = post('outlink');
$date = post('date');
$ico = post('ico');
$pics = post('pics');
// 获取多图标题
$picstitle = post('picstitle');
if ($picstitle) {
$picstitle = implode(',', $picstitle);
}
$content = post('content');
$tags = str_replace('', ',', post('tags'));
$enclosure = post('enclosure');
$keywords = post('keywords');
$description = post('description');
$status = post('status', 'int');
$istop = post('istop', 'int', '', '', 0);
$isrecommend = post('isrecommend', 'int', '', '', 0);
$isheadline = post('isheadline', 'int', '', '', 0);
$gid = post('gid', 'int') ?: 0;
$gtype = post('gtype', 'int') ?: 4;
$gnote = post('gnote');
if (! $scode) {
alert_back('内容分类不能为空!');
}
if (! $title) {
alert_back('文章标题不能为空!');
}
if ($filename && ! preg_match('/^[a-zA-Z0-9\-]+$/', $filename)) {
alert_back('内容URL名称只允许字母、数字、横线组成!');
}
// 自动提起前一百个字符为描述
if (! $description && isset($_POST['content'])) {
$description = escape_string(clear_html_blank(substr_both(strip_tags($_POST['content']), 0, 150)));
}
// 缩放缩略图
if ($ico) {
resize_img(ROOT_PATH . $ico, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
if ($filename) {
while ($this->model->checkFilename($filename, "id<>$id")) {
$filename = $filename . '-' . mt_rand(1, 20);
}
}
// 构建数据
$data = array(
'scode' => $scode,
'subscode' => $subscode,
'title' => $title,
'titlecolor' => $titlecolor,
'subtitle' => $subtitle,
'filename' => $filename,
'author' => $author,
'source' => $source,
'outlink' => $outlink,
'date' => $date,
'ico' => $ico,
'pics' => $pics,
'picstitle' => $picstitle,
'content' => $content,
'tags' => $tags,
'enclosure' => $enclosure,
'keywords' => $keywords,
'description' => clear_html_blank($description),
'status' => $status,
'istop' => $istop,
'isrecommend' => $isrecommend,
'isheadline' => $isheadline,
'gid' => $gid,
'gtype' => $gtype,
'gnote' => $gnote,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modContent($id, $data)) {
// 扩展内容修改
foreach ($_POST as $key => $value) {
if (preg_match('/^ext_[\w\-]+$/', $key)) {
$temp = post($key);
if (is_array($temp)) {
$data2[$key] = implode(',', $temp);
} else {
$data2[$key] = str_replace("\r\n", '<br>', $temp);
}
}
}
if (isset($data2)) {
if ($this->model->findContentExt($id)) {
$this->model->modContentExt($id, $data2);
} else {
$data2['contentid'] = $id;
$this->model->addContentExt($data2);
}
}
$this->log('修改文章' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Content/index/mcode/2'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getContent($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('content', $result);
if (! $mcode = get('mcode', 'var')) {
error('传递的模型编码参数有误,请核对后重试!');
}
// 文章分类
$sort_model = model('admin.content.ContentSort');
$sort_select = $sort_model->getListSelect($mcode);
$this->assign('sort_select', $this->makeSortSelect($sort_select, $result->scode));
$this->assign('subsort_select', $this->makeSortSelect($sort_select, $result->subscode));
// 模型名称
$this->assign('model_name', model('admin.content.Model')->getName($mcode));
// 扩展字段
$this->assign('extfield', model('admin.content.ExtField')->getModelField($mcode));
// 获取会员分组
$this->assign('groups', model('admin.member.MemberGroup')->getSelect());
$this->display('content/content.html');
}
}
}

View File

@@ -0,0 +1,557 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年12月26日
* 内容栏目控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\ContentSortModel;
class ContentSortController extends Controller
{
private $count;
private $blank;
private $outData = array();
private $model;
public function __construct()
{
$this->model = new ContentSortModel();
}
// 内容栏目列表
public function index()
{
$this->assign('list', true);
$tree = $this->model->getList();
$sorts = $this->makeSortList($tree);
$this->assign('sorts', $sorts);
// 内容模型
$models = model('admin.content.Model');
$this->assign('allmodels', $models->getSelectAll());
$this->assign('models', $models->getSelect());
// 内容栏目下拉表
$sort_tree = $this->model->getSelect();
$sort_select = $this->makeSortSelect($sort_tree);
$this->assign('sort_select', $sort_select);
// 模板文件
$htmldir = $this->config('tpl_html_dir') ? '/' . $this->config('tpl_html_dir') : '';
$this->assign('tpls', file_list(ROOT_PATH . current($this->config('tpl_dir')) . '/' . $this->model->getTheme() . $htmldir));
// 前端地址连接符判断
$url_break_char = $this->config('url_break_char') ?: '_';
$this->assign('url_break_char', $url_break_char);
// 获取会员分组
$this->assign('groups', model('admin.member.MemberGroup')->getSelect());
$this->display('content/contentsort.html');
}
// 生成无限级内容栏目列表
private function makeSortList($tree)
{
// 循环生成
foreach ($tree as $value) {
$this->count ++;
$this->outData[$this->count] = new \stdClass();
$this->outData[$this->count]->id = $value->id;
$this->outData[$this->count]->blank = $this->blank;
$this->outData[$this->count]->name = $value->name;
$this->outData[$this->count]->subname = $value->subname;
$this->outData[$this->count]->scode = $value->scode;
$this->outData[$this->count]->pcode = $value->pcode;
$this->outData[$this->count]->mcode = $value->mcode;
$this->outData[$this->count]->listtpl = $value->listtpl;
$this->outData[$this->count]->contenttpl = $value->contenttpl;
$this->outData[$this->count]->ico = $value->ico;
$this->outData[$this->count]->pic = $value->pic;
$this->outData[$this->count]->keywords = $value->keywords;
$this->outData[$this->count]->description = $value->description;
$this->outData[$this->count]->outlink = $value->outlink;
$this->outData[$this->count]->sorting = $value->sorting;
$this->outData[$this->count]->status = $value->status;
$this->outData[$this->count]->filename = $value->filename;
$this->outData[$this->count]->type = $value->type;
$this->outData[$this->count]->urlname = $value->urlname;
$this->outData[$this->count]->create_user = $value->create_user;
$this->outData[$this->count]->update_user = $value->update_user;
$this->outData[$this->count]->create_time = $value->create_time;
$this->outData[$this->count]->update_time = $value->update_time;
if ($value->son) {
$this->outData[$this->count]->son = true;
} else {
$this->outData[$this->count]->son = false;
}
// 子菜单处理
if ($value->son) {
$this->blank .= '  ';
$this->makeSortList($value->son);
}
}
// 循环完后回归缩进位置
$this->blank = substr($this->blank, 6);
return $this->outData;
}
// 内容栏目增加
public function add()
{
if ($_POST) {
if (! ! $multiplename = post('multiplename')) {
$multiplename = str_replace('', ',', $multiplename);
$pcode = post('pcode', 'var');
$type = post('type');
$mcode = post('mcode');
$listtpl = basename(post('listtpl'));
$contenttpl = basename(post('contenttpl'));
$status = post('status');
if (! $pcode) { // 父编码默认为0
$pcode = 0;
}
if (! $mcode) {
alert_back('栏目模型必须选择!');
}
if (! $type) {
alert_back('栏目类型不能为空!');
}
$names = explode(',', $multiplename);
$lastcode = $this->model->getLastCode();
$scode = get_auto_code($lastcode);
foreach ($names as $key => $value) {
$data[] = array(
'acode' => session('acode'),
'pcode' => $pcode,
'scode' => $scode,
'name' => $value,
'mcode' => $mcode,
'listtpl' => $listtpl,
'contenttpl' => $contenttpl,
'status' => $status,
'gid' => 0,
'gtype' => 4,
'subname' => '',
'filename' => '',
'outlink' => '',
'ico' => '',
'pic' => '',
'title' => '',
'keywords' => '',
'description' => '',
'sorting' => 255,
'create_user' => session('username'),
'update_user' => session('username')
);
$scode = get_auto_code($scode);
}
} else {
// 获取数据
$scode = get_auto_code($this->model->getLastCode()); // 自动编码;
$pcode = post('pcode', 'var');
$name = post('name');
$type = post('type');
$mcode = post('mcode');
$listtpl = basename(post('listtpl'));
$contenttpl = basename(post('contenttpl'));
$status = post('status');
$subname = post('subname');
$filename = trim(post('filename'), '/');
$outlink = post('outlink');
$ico = post('ico');
$pic = post('pic');
$title = post('title');
$keywords = post('keywords');
$description = post('description');
$gid = post('gid', 'int') ?: 0;
$gtype = post('gtype', 'int') ?: 4;
$gnote = post('gnote');
$def1 = post('def1');
$def2 = post('def2');
$def3 = post('def3');
if (! $scode) {
alert_back('编码不能为空!');
}
if (! $pcode) { // 父编码默认为0
$pcode = 0;
}
if (! $name) {
alert_back('栏目名不能为空!');
}
if (! $mcode) {
alert_back('栏目模型必须选择!');
}
if (! $type) {
alert_back('栏目类型不能为空!');
}
if ($filename && ! preg_match('/^[a-zA-Z0-9\-\/]+$/', $filename)) {
alert_back('URL名称只允许字母、数字、横线、斜线组成!');
}
if ($filename && $this->model->checkUrlname($filename)) {
alert_back('URL名称与模型URL名称冲突请换一个名称');
}
// 缩放缩略图
if ($ico) {
resize_img(ROOT_PATH . $ico, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
// 检查编码
if ($this->model->checkSort("scode='$scode'")) {
alert_back('该内容栏目编号已经存在,不能再使用!');
}
// 检查自定义URL名称
if ($filename) {
while ($this->model->checkFilename($filename)) {
$filename = $filename . '_' . mt_rand(1, 20);
}
}
// 构建数据
$data = array(
'acode' => session('acode'),
'pcode' => $pcode,
'scode' => $scode,
'name' => $name,
'mcode' => $mcode,
'listtpl' => $listtpl,
'contenttpl' => $contenttpl,
'status' => $status,
'gid' => $gid,
'gtype' => $gtype,
'gnote' => $gnote,
'subname' => $subname,
'def1' => $def1,
'def2' => $def2,
'def3' => $def3,
'filename' => $filename,
'outlink' => $outlink,
'ico' => $ico,
'pic' => $pic,
'title' => $title,
'keywords' => $keywords,
'description' => $description,
'sorting' => 255,
'create_user' => session('username'),
'update_user' => session('username')
);
}
// 执行添加
if ($this->model->addSort($data)) {
if ($type == 1 && ! $outlink) { // 在填写了外链时不生成单页
if ($multiplename) {
foreach ($data as $key => $value) {
$this->addSingle($value['scode'], $value['name']);
}
} else {
$this->addSingle($scode, $name);
}
}
$this->log('新增数据内容栏目' . $scode . '成功!');
success('新增成功!', url('/admin/ContentSort/index'));
} else {
$this->log('新增数据内容栏目' . $scode . '失败!');
error('新增失败!', - 1);
}
}
}
// 生成内容栏目下拉选择
private function makeSortSelect($tree, $selectid = null)
{
$list_html = '';
foreach ($tree as $value) {
// 默认选择项
if ($selectid == $value->scode) {
$select = "selected='selected'";
} else {
$select = '';
}
if (get('scode') != $value->scode) { // 不显示本身,避免出现自身为自己的父节点
$list_html .= "<option value='{$value->scode}' $select>{$this->blank}{$value->name}</option>";
}
// 子菜单处理
if ($value->son) {
$this->blank .= '  ';
$list_html .= $this->makeSortSelect($value->son, $selectid);
}
}
// 循环完后回归位置
$this->blank = substr($this->blank, 0, - 6);
return $list_html;
}
// 内容栏目删除
public function del()
{
// 执行批量删除
if ($_POST) {
if (! ! $list = post('list')) {
if ($this->model->delSortList($list)) {
$this->log('批量删除栏目成功!');
success('批量删除成功!', - 1);
} else {
$this->log('批量删除栏目失败!');
error('批量删除失败!', - 1);
}
} else {
alert_back('请选择要删除的栏目!');
}
}
if (! $scode = get('scode', 'var')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delSort($scode)) {
$this->log('删除数据内容栏目' . $scode . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除数据内容栏目' . $scode . '失败!');
error('删除失败!', - 1);
}
}
// 内容栏目修改
public function mod()
{
if (! ! $submit = post('submit')) {
switch ($submit) {
case 'sorting': // 修改列表排序
$listall = post('listall');
if ($listall) {
$sorting = post('sorting');
foreach ($listall as $key => $value) {
if ($sorting[$key] === '' || ! is_numeric($sorting[$key]))
$sorting[$key] = 255;
$this->model->modSortSorting($value, "sorting=" . $sorting[$key]);
}
$this->log('批量修改栏目排序成功!');
success('修改成功!', - 1);
} else {
alert_back('排序失败,无任何内容!');
}
break;
}
}
if (! $scode = get('scode', 'var')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modSort($scode, "$field='$value',update_user='" . session('username') . "'")) {
$this->log('修改数据内容栏目' . $scode . '状态' . $value . '成功!');
location(- 1);
} else {
$this->log('修改数据内容栏目' . $scode . '状态' . $value . '失败!');
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$pcode = post('pcode', 'var');
$name = post('name');
$mcode = post('mcode');
$type = post('type');
$listtpl = basename(post('listtpl'));
$contenttpl = basename(post('contenttpl'));
$status = post('status');
$subname = post('subname');
$filename = trim(post('filename'), '/');
$outlink = post('outlink');
$ico = post('ico');
$pic = post('pic');
$title = post('title');
$keywords = post('keywords');
$description = post('description');
$modsub = post('modsub', 'int');
$gid = post('gid', 'int') ?: 0;
$gtype = post('gtype', 'int') ?: 4;
$gnote = post('gnote');
$def1 = post('def1');
$def2 = post('def2');
$def3 = post('def3');
if (! $pcode) { // 父编码默认为0
$pcode = 0;
}
if (! $name) {
alert_back('栏目名不能为空!');
}
if (! $mcode) {
alert_back('栏目模型必须选择!');
}
if (! $type) {
alert_back('栏目类型不能为空!');
}
if ($filename && ! preg_match('/^[a-zA-Z0-9\-\/]+$/', $filename)) {
alert_back('URL名称只允许字母、数字、横线、斜线组成!');
}
if ($filename && $this->model->checkUrlname($filename)) {
alert_back('URL名称与模型URL名称冲突请换一个名称');
}
// 缩放缩略图
if ($ico) {
resize_img(ROOT_PATH . $ico, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
if ($filename) {
while ($this->model->checkFilename($filename, "scode<>'$scode'")) {
$filename = $filename . '-' . mt_rand(1, 20);
}
}
// 构建数据
$data = array(
'pcode' => $pcode,
'name' => $name,
'mcode' => $mcode,
'listtpl' => $listtpl,
'contenttpl' => $contenttpl,
'status' => $status,
'gid' => $gid,
'gtype' => $gtype,
'gnote' => $gnote,
'subname' => $subname,
'def1' => $def1,
'def2' => $def2,
'def3' => $def3,
'filename' => $filename,
'outlink' => $outlink,
'ico' => $ico,
'pic' => $pic,
'title' => $title,
'keywords' => $keywords,
'description' => $description,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modSort($scode, $data, $modsub)) {
// 如果修改为单页并且跳转,则删除单页内容,否则判断是否存在内容,不存在则添加
if ($type == 1 && $outlink) {
$this->model->delContent($scode);
} elseif ($type == 1 && ! $this->model->findContent($scode)) {
$this->addSingle($scode, $name);
}
$this->log('修改数据内容栏目' . $scode . '成功!');
success('修改成功!', url('/admin/ContentSort/index'));
} else {
location(- 1);
}
} else { // 调取修改内容
$this->assign('mod', true);
$sort = $this->model->getSort($scode);
if (! $sort) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('sort', $sort);
// 父编码下拉选择
$sort_tree = $this->model->getSelect();
$sort_select = $this->makeSortSelect($sort_tree, $sort->pcode);
$this->assign('sort_select', $sort_select);
// 模板文件
$htmldir = $this->config('tpl_html_dir') ? '/' . $this->config('tpl_html_dir') : '';
$this->assign('tpls', file_list(ROOT_PATH . current($this->config('tpl_dir')) . '/' . $this->model->getTheme() . $htmldir));
// 内容模型
$models = model('admin.content.Model');
$this->assign('models', $models->getSelect());
// 获取会员分组
$this->assign('groups', model('admin.member.MemberGroup')->getSelect());
$this->display('content/contentsort.html');
}
}
// 添加栏目时执行单页内容增加
public function addSingle($scode, $title)
{
// 构建数据
$data = array(
'acode' => session('acode'),
'scode' => $scode,
'subscode' => '',
'title' => $title,
'titlecolor' => '#333333',
'subtitle' => '',
'filename' => '',
'author' => session('realname'),
'source' => '本站',
'outlink' => '',
'date' => date('Y-m-d H:i:s'),
'ico' => '',
'pics' => '',
'content' => '',
'tags' => '',
'enclosure' => '',
'keywords' => '',
'description' => '',
'sorting' => 255,
'status' => 1,
'istop' => 0,
'isrecommend' => 0,
'isheadline' => 0,
'gid' => 0,
'gtype' => 4,
'gnote' => '',
'visits' => 0,
'likes' => 0,
'oppose' => 0,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addSingle($data)) {
return true;
} else {
return false;
}
}
}

View File

@@ -0,0 +1,231 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月1日
* 扩展字段控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\ExtFieldModel;
class ExtFieldController extends Controller
{
private $model;
public function __construct()
{
$this->model = new ExtFieldModel();
}
// 扩展字段列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getExtField($id)) {
$this->assign('more', true);
$this->assign('extfield', $result);
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findExtField($field, $keyword);
} else {
$result = $this->model->getList();
}
// 内容模型
$models = model('admin.content.Model');
$this->assign('models', $models->getSelect());
$this->assign('extfields', $result);
}
$this->display('content/extfield.html');
}
// 扩展字段增加
public function add()
{
if ($_POST) {
// 获取数据
$mcode = post('mcode');
$name = post('name', 'var');
$type = post('type', 'int');
if (! ! $value = post('value')) {
$value = str_replace("\r\n", ",", $value); // 替换回车
$value = str_replace("", ",", $value); // 替换中文逗号分割符
}
$description = post('description');
$sorting = post('sorting', 'int');
if (! $mcode) {
alert_back('内容模型不能为空!');
}
if (! $name) {
alert_back('字段名称不能为空!');
} else {
$name = "ext_" . $name;
}
if (! $type) {
alert_back('字段类型不能为空!');
}
if (! $description) {
alert_back('字段描述不能为空!');
}
// 构建数据
$data = array(
'mcode' => $mcode,
'name' => $name,
'type' => $type,
'value' => $value,
'description' => $description,
'sorting' => $sorting
);
// 字段类型及长度
switch ($type) {
case '2': // 多行
$mysql = 'varchar(1000)';
$sqlite = 'TEXT(1000)';
break;
case '7': // 时间日期
$mysql = 'datetime';
$sqlite = 'TEXT';
break;
case '8': // 编辑器
$mysql = 'TEXT';
$sqlite = 'TEXT(10000)';
break;
default:
$mysql = 'varchar(200)';
$sqlite = 'TEXT(200)';
}
// 字段不存在时创建
if (! $this->model->isExistField($name)) {
if (get_db_type() == 'sqlite') {
$result = $this->model->amd("ALTER TABLE ay_content_ext ADD COLUMN $name $sqlite NULL");
} else {
$result = $this->model->amd("ALTER TABLE ay_content_ext ADD $name $mysql NULL COMMENT '$description'");
}
} elseif ($this->model->checkExtField($name)) { // 字段存在且已使用则 报错
alert_back('字段已经存在,不能重复添加!');
}
// 执行扩展字段记录添加
if ($this->model->addExtField($data)) {
$this->log('新增扩展字段成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/ExtField/index'));
}
} else {
$this->log('新增扩展字段失败!');
error('新增失败!', - 1);
}
}
}
// 扩展字段删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
$name = $this->model->getExtFieldName($id);
if ($this->model->delExtField($id)) {
// mysql数据库执行字段删除sqlite暂时不支持
if (! ! $name) {
if (get_db_type() == 'mysql') {
$result = $this->model->amd("ALTER TABLE ay_content_ext DROP COLUMN $name");
}
}
$this->log('删除扩展字段' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除扩展字段' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 扩展字段修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modExtField($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$mcode = post('mcode');
$type = post('type');
if (! ! $value = post('value')) {
$value = str_replace("\r\n", ",", $value); // 替换回车
$value = str_replace("", ",", $value); // 替换中文逗号分割符
}
$description = post('description');
$sorting = post('sorting', 'int');
if (! $mcode) {
alert_back('内容模型不能为空!');
}
if (! $description) {
alert_back('字段描述不能为空!');
}
// 构建数据
$data = array(
'mcode' => $mcode,
'type' => $type,
'value' => $value,
'description' => $description,
'sorting' => $sorting
);
// 执行修改
if ($this->model->modExtField($id, $data)) {
$this->log('修改扩展字段' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/ExtField/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getExtField($id)) {
error('编辑的内容已经不存在!', - 1);
}
// 内容模型
$models = model('admin.content.Model');
$this->assign('models', $models->getSelect());
$this->assign('extfield', $result);
$this->display('content/extfield.html');
}
}
}

View File

@@ -0,0 +1,354 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年5月28日
* 自定义表单控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\FormModel;
class FormController extends Controller
{
private $model;
public function __construct()
{
$this->model = new FormModel();
}
// 自定义表单列表
public function index()
{
if ((! ! $fcode = get('fcode', 'var')) && $form = $this->model->getFormByCode($fcode)) {
$this->assign('form', $form);
if (get('action') == 'showdata') {
$this->assign('showdata', true);
$this->assign('fields', $this->model->getFormFieldByCode($fcode)); // 获取字段
$table = $this->model->getFormTableByCode($fcode);
if (get('export')) {
$this->assign('formdata', $this->model->getFormData($table, false));
header('Content-Type:application/vnd.ms-excel');
header('Cache-Control: max-age=0');
header("Content-Disposition:filename=" . $form->form_name . "-" . date("YmdHis") . ".xls");
$this->display('content/exform.html');
} else {
$this->assign('formdata', $this->model->getFormData($table, true));
}
}
if (get('action') == 'showfield') {
$this->assign('showfield', true);
$this->assign('fields', $this->model->getFormFieldByCode($fcode));
}
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findForm($field, $keyword);
} else {
$result = $this->model->getList();
}
$this->assign('forms', $result);
}
$this->display('content/form.html');
}
// 自定义表单增加
public function add()
{
if ($_POST) {
if (get('action') == 'addform') {
$fcode = get_auto_code($this->model->getLastCode());
$form_name = post('form_name');
$table_name = 'ay_diy_' . post('table_name', 'var');
if (! $form_name) {
alert_back('表单名称不能为空!');
}
if (! $table_name) {
alert_back('表单数据表不能为空!');
}
$data = array(
'fcode' => $fcode,
'form_name' => $form_name,
'table_name' => $table_name,
'create_user' => session('username'),
'update_user' => session('username')
);
if (get_db_type() == 'sqlite') {
$result = $this->model->amd("CREATE TABLE `$table_name` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,`create_time` TEXT NOT NULL)");
} else {
$result = $this->model->amd("CREATE TABLE `$table_name` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`create_time` datetime NOT NULL,PRIMARY KEY (`id`))ENGINE=MyISAM DEFAULT CHARSET=utf8");
}
if ($this->model->addForm($data)) {
$this->log('新增自定义表单成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Form/index'));
}
} else {
$this->log('新增自定义表单失败!');
error('新增失败!', - 1);
}
} else {
// 获取数据
$fcode = post('fcode', 'var');
$name = post('name', 'var');
$length = post('length', 'int') ?: 20;
$required = post('required', 'int') ?: 0;
$description = post('description');
$sorting = post('sorting', 'int') ?: 255;
if (! $fcode) {
alert_back('表单编码不能为空!');
}
if (! $name) {
alert_back('字段名称不能为空!');
}
if (! $description) {
alert_back('字段描述不能为空!');
}
// 构建数据
$data = array(
'fcode' => $fcode,
'name' => $name,
'length' => $length,
'required' => $required,
'description' => $description,
'sorting' => $sorting,
'create_user' => session('username'),
'update_user' => session('username')
);
// 获取表名称
$table = $this->model->getFormTableByCode($fcode);
// 字段类型及长度
$mysql = "varchar($length)";
$sqlite = "TEXT($length)";
// 字段不存在时创建
if (! $this->model->isExistField($table, $name)) {
if (get_db_type() == 'sqlite') {
$result = $this->model->amd("ALTER TABLE $table ADD COLUMN $name $sqlite NULL");
} else {
$result = $this->model->amd("ALTER TABLE $table ADD $name $mysql NULL COMMENT '$description'");
}
} elseif ($this->model->checkFormField($fcode, $name)) {
alert_back('字段已经存在,不能重复添加!');
}
// 执行自定义表单记录添加
if ($this->model->addFormField($data)) {
$this->log('新增表单字段成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Form/index/fcode/' . $fcode . '/action/showfield'));
}
} else {
$this->log('新增表单字段失败!');
error('新增失败!', - 1);
}
}
}
}
// 自定义表单删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 删除表单
if (get('action') == 'delform') {
if ($id == 1) {
alert_back('留言表单不允许删除');
}
$table = $this->model->getFormTable($id);
$fcode = $this->model->getFormCode($id);
if ($this->model->delForm($id)) {
$this->model->delFormFieldByCode($fcode); // 删除字段记录
$this->model->amd("DROP TABLE IF EXISTS $table"); // 删除表
$this->log('删除自定义表单' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除自定义表单' . $id . '失败!');
error('删除失败!', - 1);
}
} elseif (get('action') == 'deldata') {
// 获取表单
if (! $fcode = get('fcode', 'var')) {
error('传递的参数值fcode错误', - 1);
}
$table = $this->model->getFormTableByCode($fcode);
if ($this->model->delFormData($table, $id)) {
$this->log('删除表单数据' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除表单数据' . $id . '失败!');
error('删除失败!', - 1);
}
} else {
// 获取表单
if (! $fcode = get('fcode', 'var')) {
error('传递的参数值fcode错误', - 1);
}
// 获取操作表
$table = $this->model->getFormTableByCode($fcode);
$name = $this->model->getFormFieldName($id);
if ($this->model->delFormField($id)) {
// mysql数据库执行字段删除sqlite暂时不支持
if (! ! $name) {
if (get_db_type() == 'mysql') {
$result = $this->model->amd("ALTER TABLE $table DROP COLUMN $name");
}
}
$this->log('删除自定义表单' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除自定义表单' . $id . '失败!');
error('删除失败!', - 1);
}
}
}
// 自定义表单修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modFormField($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
if (get('action') == 'addmenu') {
if ($this->model->addFormMenu($id)) {
$this->log('添加自定义表单' . $id . '到菜单成功!');
if (! ! $backurl = get('backurl')) {
success('添加成功!', base64_decode($backurl));
} else {
success('添加成功!', url('/admin/Form/index'));
}
} else {
location(- 1);
}
}
// 修改操作
if ($_POST) {
// 修改表单
if (get('action') == 'modform') {
$form_name = post('form_name');
if (! $form_name) {
alert_back('表单名称不能为空!');
}
$data = array(
'form_name' => $form_name,
'update_user' => session('username')
);
// 执行修改
if ($this->model->modForm($id, $data)) {
$this->log('修改自定义表单' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Form/index'));
}
} else {
location(- 1);
}
} else {
// 获取数据
$description = post('description');
$required = post('required', 'int') ?: 0;
$sorting = post('sorting', 'int') ?: 255;
if (! $description) {
alert_back('字段描述不能为空!');
}
// 构建数据
$data = array(
'description' => $description,
'required' => $required,
'sorting' => $sorting,
'update_user' => session('username')
);
// 执行修改
if ($this->model->modFormField($id, $data)) {
$this->log('修改表单字段' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Form/index'));
}
} else {
location(- 1);
}
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (get('action') == 'modform') {
if (! $result = $this->model->getForm($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('form', $result);
} else {
if (! $result = $this->model->getFormField($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('field', $result);
}
$this->display('content/form.html');
}
}
// 清空
public function clear()
{
// 获取表单
if (! $fcode = get('fcode', 'var')) {
error('传递的参数值fcode错误', - 1);
}
$table = $this->model->getFormTableByCode($fcode);
if ($this->model->clearFormData($table)) {
alert_location('清空成功!', - 1);
} else {
alert_location('清空失败!', - 1);
}
}
}

View File

@@ -0,0 +1,168 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年03月23日
* 自定义标签控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\LabelModel;
class LabelController extends Controller
{
private $model;
public function __construct()
{
$this->model = new LabelModel();
}
// 自定义标签列表
public function index()
{
// 修改参数配置
if ($_POST) {
foreach ($_POST as $key => $value) {
if (preg_match('/^[\w\-]+$/', $key)) { // 带有违规字符时不带入查询
$data = post($key);
$data = str_replace("\r\n", "<br>", $data); // 多行文本时替换回车
$this->model->modValue($key, $data);
}
}
success('修改成功!', url('admin/Label/index'));
}
$this->assign('list', true);
$this->assign('labels', $this->model->getList());
$this->display('content/label.html');
}
// 自定义标签字段增加
public function add()
{
if ($_POST) {
// 获取数据
$name = post('name', 'var');
$description = post('description');
$type = post('type');
if (! $name) {
alert_back('标签名称不能为空!');
}
if (! $description) {
alert_back('标题描述不能为空!');
}
if (! $type) {
alert_back('标签类型不能为空!');
}
// 检查标签名称
if ($this->model->checkLabel("name='$name'")) {
alert_back('该自定义标签称已经存在,不能再使用!');
}
// 构建数据
$data = array(
'name' => $name,
'description' => $description,
'value' => '', // 添加时设置为空
'type' => $type,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addLabel($data)) {
$this->log('修改自定义标签' . $name . '成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('admin/Label/index' . get_tab('t2'), false));
}
} else {
$this->log('新增自定义标签' . $name . '失败!');
error('新增失败!', url('admin/Label/index' . get_tab('t2'), false));
}
}
}
// 自定义标签字段删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delLabel($id)) {
$this->log('删除自定义标签' . $id . '成功!');
success('删除成功!', url('admin/Label/index' . get_tab('t2'), false));
} else {
$this->log('删除自定义标签' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 自定义标签字段修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 修改操作
if ($_POST) {
// 获取数据
$name = post('name', 'var');
$description = post('description');
$type = post('type');
if (! $name) {
alert_back('标签名称不能为空!');
}
if (! $description) {
alert_back('标签描述不能为空!');
}
if (! $type) {
alert_back('标签类型不能为空!');
}
// 检查标签名称
if ($this->model->checkLabel("name='$name' AND id<>$id")) {
alert_back('该自定义标签名称已经存在,不能再使用!');
}
// 构建数据
$data = array(
'name' => $name,
'description' => $description,
'type' => $type,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modLabel($id, $data)) {
$this->log('修改自定义标签字段' . $id . '成功!');
success('修改成功!', url('admin/Label/index' . get_tab('t2'), false));
} else {
location(- 1);
}
} else {
$this->assign('mod', true);
// 调取修改内容
$result = $this->model->getLabel($id);
if (! $result) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('label', $result);
$this->display('content/label.html');
}
}
}

View File

@@ -0,0 +1,213 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月1日
* 友情链接控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\LinkModel;
class LinkController extends Controller
{
private $model;
public function __construct()
{
$this->model = new LinkModel();
}
// 友情链接列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getLink($id)) {
$this->assign('more', true);
$this->assign('link', $result);
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findLink($field, $keyword);
} else {
$result = $this->model->getList();
}
$this->assign('gids', $this->model->getGid());
$this->assign('links', $result);
}
$this->display('content/link.html');
}
// 友情链接增加
public function add()
{
if ($_POST) {
// 获取数据
$gid = post('gid', 'int');
$name = post('name');
$link = post('link');
$logo = post('logo');
$sorting = post('sorting');
if (! $gid) {
$gid = $this->model->getMaxGid() + 1;
}
if (! $name) {
alert_back('名称不能为空!');
}
if (! $link) {
alert_back('链接不能为空!');
}
if (! $sorting) {
$sorting = 255;
}
// logo图缩放
if ($logo) {
resize_img(ROOT_PATH . $logo, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
// 构建数据
$data = array(
'acode' => session('acode'),
'gid' => $gid,
'name' => $name,
'link' => $link,
'logo' => $logo,
'sorting' => $sorting,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addLink($data)) {
$this->log('新增友情链接成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Link/index'));
}
} else {
$this->log('新增友情链接失败!');
error('新增失败!', - 1);
}
}
}
// 友情链接删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delLink($id)) {
$this->log('删除友情链接' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除友情链接' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 友情链接修改
public function mod()
{
if (! ! $submit = post('submit')) {
switch ($submit) {
case 'sorting': // 修改列表排序
$listall = post('listall');
if ($listall) {
$sorting = post('sorting');
foreach ($listall as $key => $value) {
if ($sorting[$key] === '' || ! is_numeric($sorting[$key]))
$sorting[$key] = 255;
$this->model->modLink($value, "sorting=" . $sorting[$key]);
}
$this->log('批量修改链接排序成功!');
success('修改成功!', - 1);
} else {
alert_back('排序失败,无任何内容!');
}
break;
}
}
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modLink($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$gid = post('gid', 'int');
$name = post('name');
$link = post('link');
$logo = post('logo');
$sorting = post('sorting');
if (! $gid) {
$gid = $this->model->getMaxGid() + 1;
}
if (! $name) {
alert_back('名称不能为空!');
}
if (! $link) {
alert_back('链接不能为空!');
}
// logo图缩放
if ($logo) {
resize_img(ROOT_PATH . $logo, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
// 构建数据
$data = array(
'gid' => $gid,
'name' => $name,
'link' => $link,
'logo' => $logo,
'sorting' => $sorting,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modLink($id, $data)) {
$this->log('修改友情链接' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Link/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getLink($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('gids', $this->model->getGid());
$this->assign('link', $result);
$this->display('content/link.html');
}
}
}

View File

@@ -0,0 +1,119 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年3月29日
* 留言控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\MessageModel;
class MessageController extends Controller
{
private $model;
public function __construct()
{
$this->model = new MessageModel();
}
// 列表
public function index()
{
$this->assign('list', true);
$this->assign('fields', $this->model->getFormFieldByCode(1)); // 获取字段
if (get('export')) {
$this->assign('messages', $this->model->getList(false));
header("Content-Type:application/vnd.ms-excel");
header('Cache-Control: max-age=0');
header("Content-Disposition:filename=留言记录-" . date("YmdHis") . ".xls");
$this->display('content/exmessage.html');
} else {
$this->assign('messages', $this->model->getList(true));
$this->display('content/message.html');
}
}
// 删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delMessage($id)) {
$this->log('删除留言' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除留言' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modMessage($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$recontent = post('recontent');
$status = post('status');
// 构建数据
$data = array(
'recontent' => $recontent,
'status' => $status,
'update_user' => session('username')
);
// 执行修改
if ($this->model->modMessage($id, $data)) {
$this->log('修改留言' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Message/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getMessage($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('message', $result);
$this->display('content/message.html');
}
}
// 清空
public function clear()
{
if ($this->model->clearMessage()) {
alert_location('清空成功!', url('/admin/Message/index'));
} else {
alert_location('清空失败!', url('/admin/Message/index'));
}
}
}

View File

@@ -0,0 +1,207 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月1日
* 内容模型控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\ModelModel;
class ModelController extends Controller
{
private $model;
public function __construct()
{
$this->model = new ModelModel();
}
// 内容模型列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getModel($id)) {
$this->assign('more', true);
$this->assign('model', $result);
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findModel($field, $keyword);
} else {
$result = $this->model->getList();
}
$this->assign('models', $result);
}
$this->display('content/model.html');
}
// 内容模型增加
public function add()
{
if ($_POST) {
// 获取数据
$mcode = get_auto_code($this->model->getLastCode());
$name = post('name');
$type = post('type');
$urlname = post('urlname');
$listtpl = basename(post('listtpl'));
$contenttpl = basename(post('contenttpl'));
$status = post('status');
if (! $name) {
alert_back('模型名称不能为空!');
}
if ($type == 1) {
if (! $urlname)
$urlname = 'about';
} else {
if (! $urlname)
$urlname = 'list';
}
if ($urlname && ! preg_match('/^[a-zA-Z0-9\-]+$/', $urlname)) {
alert_back('模型URL名称只允许字母、数字、横线组成!');
}
if ($this->model->checkUrlname($urlname, $type)) {
alert_back('模型URL名称与其他模型冲突请换一个名称');
}
if ($this->model->checkSortFilename($urlname)) {
alert_back('模型URL名称与栏目URL名称冲突请换一个名称');
}
// 构建数据
$data = array(
'mcode' => $mcode,
'name' => $name,
'type' => $type,
'urlname' => $urlname,
'listtpl' => $listtpl,
'contenttpl' => $contenttpl,
'status' => $status,
'issystem' => 0,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addModel($data)) {
$this->log('新增内容模型成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Model/index'));
}
} else {
$this->log('新增内容模型失败!');
error('新增失败!', - 1);
}
}
}
// 内容模型删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delModel($id)) {
$this->log('删除内容模型' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除内容模型' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 内容模型修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modModel($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$name = post('name');
$type = post('type');
$urlname = post('urlname');
$listtpl = basename(post('listtpl'));
$contenttpl = basename(post('contenttpl'));
$status = post('status');
if (! $name) {
alert_back('模型名称不能为空!');
}
if ($type == 1) {
if (! $urlname)
$urlname = 'about';
} else {
if (! $urlname)
$urlname = 'list';
}
if ($urlname && ! preg_match('/^[a-zA-Z0-9\-]+$/', $urlname)) {
alert_back('模型URL名称只允许字母、数字、横线组成!');
}
if ($this->model->checkUrlname($urlname, $type, "id<>$id")) {
alert_back('模型URL名称与其他模型冲突请换一个名称');
}
if ($this->model->checkSortFilename($urlname)) {
alert_back('模型URL名称与栏目URL名称冲突请换一个名称');
}
// 构建数据
$data = array(
'name' => $name,
'type' => $type,
'urlname' => $urlname,
'listtpl' => $listtpl,
'contenttpl' => $contenttpl,
'status' => $status,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modModel($id, $data)) {
$this->log('修改内容模型' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Model/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getModel($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('model', $result);
$this->display('content/model.html');
}
}
}

View File

@@ -0,0 +1,266 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年12月15日
* 单页内容控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\SingleModel;
class SingleController extends Controller
{
private $model;
private $blank;
public function __construct()
{
$this->model = new SingleModel();
}
// 单页内容列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getSingle($id)) {
$this->assign('more', true);
$this->assign('content', $result);
} else {
$this->assign('list', true);
if (! $mcode = get('mcode', 'var')) {
error('传递的模型编码参数有误,请核对后重试!');
}
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findSingle($mcode, $field, $keyword);
} else {
$result = $this->model->getList($mcode);
}
$this->assign('baidu_zz_token', $this->config('baidu_zz_token'));
$this->assign('baidu_ks_token', $this->config('baidu_ks_token'));
// 模型名称
$this->assign('model_name', model('admin.content.Model')->getName($mcode));
// 前端地址连接符判断
$url_break_char = $this->config('url_break_char') ?: '_';
$this->assign('url_break_char', $url_break_char);
$this->assign('contents', $result);
}
$this->display('content/single.html');
}
// 单页内容删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delSingle($id)) {
$this->log('删除单页内容' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除单页内容' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 单页内容修改
public function mod()
{
// 前端地址连接符判断
if (get('baiduzz') || get('baiduxzh')) {
$url_break_char = $this->config('url_break_char') ?: '_';
$url_rule_sort_suffix = $this->config('url_rule_sort_suffix') ? true : false;
}
// 站长普通推送
if (! ! $id = get('baiduzz')) {
$domain = get_http_url();
if (! $token = $this->config('baidu_zz_token')) {
alert_back('请先到系统配置中填写百度普通收录推送token值');
}
$api = "http://data.zz.baidu.com/urls?site=$domain&token=$token";
$data = $this->model->getSingle($id);
$data->urlname = $data->urlname ?: 'about';
if ($data->outlink) {
alert_back('链接类型不允许推送!');
}
if ($data->filename) {
$urls[] = $domain . homeurl('/home/Index/' . $data->filename, $url_rule_sort_suffix);
} else {
$urls[] = $domain . homeurl('/home/Index/' . $data->urlname . $url_break_char . $data->scode, $url_rule_sort_suffix);
}
$result = post_baidu($api, $urls);
if (isset($result->error)) {
$this->log('百度普通收录推送失败:' . $urls[0]);
alert_back('推送发生错误:' . $result->message);
} elseif (isset($result->success)) {
$this->log('百度普通收录推送成功:' . $urls[0]);
alert_back('成功推送' . $result->success . '条,今天剩余可推送' . $result->remain . '条数!');
} else {
alert_back('发生未知错误!');
}
}
// 站长快速推送
if (! ! $id = get('baiduks')) {
$domain = get_http_url();
if (! $token = $this->config('baidu_ks_token')) {
alert_back('请先到系统配置中填写百度快速收录推送token值');
}
$api = "http://data.zz.baidu.com/urls?site=$domain&token=$token&type=daily";
$data = $this->model->getSingle($id);
$data->urlname = $data->urlname ?: 'about';
if ($data->outlink) {
alert_back('链接类型不允许推送!');
}
if ($data->filename) {
$urls[] = $domain . homeurl('/home/Index/' . $data->filename, $url_rule_sort_suffix);
} else {
$urls[] = $domain . homeurl('/home/Index/' . $data->urlname . $url_break_char . $data->scode, $url_rule_sort_suffix);
}
$result = post_baidu($api, $urls);
if (isset($result->error)) {
$this->log('百度快速收录推送失败:' . $urls[0]);
alert_back('推送发生错误:' . $result->message);
} elseif (isset($result->success_daily)) {
$this->log('百度快速收录推送成功:' . $urls[0]);
alert_back('成功推送' . $result->success_daily . '条,今天剩余可推送' . $result->remain_daily . '条数!');
} else {
alert_back('发生未知错误!');
}
}
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modSingle($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$title = post('title');
$author = post('author');
$source = post('source');
$ico = post('ico');
$pics = post('pics');
$content = post('content');
$tags = str_replace('', ',', post('tags'));
$titlecolor = post('titlecolor');
$subtitle = post('subtitle');
$outlink = post('outlink');
$date = post('date');
$enclosure = post('enclosure');
$keywords = post('keywords');
$description = post('description');
$status = post('status', 'int');
// 获取多图标题
$picstitle = post('picstitle');
if ($picstitle) {
$picstitle = implode(',', $picstitle);
}
if (! $title) {
alert_back('单页内容标题不能为空!');
}
// 自动提起前一百个字符为描述
if (! $description && isset($_POST['content'])) {
$description = escape_string(clear_html_blank(substr_both(strip_tags($_POST['content']), 0, 150)));
}
// 缩放缩略图
if ($ico) {
resize_img(ROOT_PATH . $ico, '', $this->config('ico.max_width'), $this->config('ico.max_height'));
}
// 构建数据
$data = array(
'title' => $title,
'content' => $content,
'tags' => $tags,
'author' => $author,
'source' => $source,
'ico' => $ico,
'pics' => $pics,
'picstitle' => $picstitle,
'titlecolor' => $titlecolor,
'subtitle' => $subtitle,
'outlink' => $outlink,
'date' => $date,
'enclosure' => $enclosure,
'keywords' => $keywords,
'description' => clear_html_blank($description),
'status' => $status,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modSingle($id, $data)) {
// 扩展内容修改
foreach ($_POST as $key => $value) {
if (preg_match('/^ext_[\w\-]+$/', $key)) {
$temp = post($key);
if (is_array($temp)) {
$data2[$key] = implode(',', $temp);
} else {
$data2[$key] = str_replace("\r\n", '<br>', $temp);
}
}
}
if (isset($data2)) {
if ($this->model->findContentExt($id)) {
$this->model->modContentExt($id, $data2);
} else {
$data2['contentid'] = $id;
$this->model->addContentExt($data2);
}
}
$this->log('修改单页内容' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Single/index/mcode/1'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getSingle($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('content', $result);
// 扩展字段
if (! $mcode = get('mcode', 'var')) {
error('传递的模型编码参数有误,请核对后重试!');
}
$this->assign('extfield', model('admin.content.ExtField')->getModelField($mcode));
$this->display('content/single.html');
}
}
}

View File

@@ -0,0 +1,82 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2017年3月21日
* 站点设置控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\SiteModel;
class SiteController extends Controller
{
public function __construct()
{
$this->model = new SiteModel();
}
// 显示站点信息
public function index()
{
// 获取主题列表
$themes = dir_list(ROOT_PATH . current($this->config('tpl_dir')));
$this->assign('themes', $themes);
// 获取系统配置
$this->assign('sites', $this->model->getList());
// 显示
$this->display('content/site.html');
}
// 修改站点信息
public function mod()
{
if (! $_POST) {
return;
}
$data = array(
'title' => post('title'),
'subtitle' => post('subtitle'),
'domain' => post('domain'),
'logo' => post('logo'),
'keywords' => post('keywords'),
'description' => post('description'),
'icp' => post('icp'),
'theme' => basename(post('theme')) ?: 'default',
'statistical' => post('statistical'),
'copyright' => post('copyright')
);
path_delete(RUN_PATH . '/config'); // 清理缓存的配置文件
if ($this->model->checkSite()) {
if ($this->model->modSite($data)) {
$this->log('修改站点信息成功!');
success('修改成功!', - 1);
} else {
location(- 1);
}
} else {
$data['acode'] = session('acode');
if ($this->model->addSite($data)) {
$this->log('修改站点信息成功!');
success('修改成功!', - 1);
} else {
location(- 1);
}
}
}
// 服务器基础信息
public function server()
{
$this->assign('server', get_server_info());
$this->display('system/server.html');
}
}

View File

@@ -0,0 +1,195 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2018年3月1日
* 轮播图控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\SlideModel;
class SlideController extends Controller
{
private $model;
public function __construct()
{
$this->model = new SlideModel();
}
// 轮播图列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getSlide($id)) {
$this->assign('more', true);
$this->assign('slide', $result);
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findSlide($field, $keyword);
} else {
$result = $this->model->getList();
}
$this->assign('gids', $this->model->getGid());
$this->assign('slides', $result);
}
$this->display('content/slide.html');
}
// 轮播图增加
public function add()
{
if ($_POST) {
// 获取数据
$gid = post('gid', 'int');
$pic = post('pic');
$link = post('link');
$title = post('title');
$subtitle = post('subtitle');
$sorting = post('sorting', 'int');
if (! $gid) {
$gid = $this->model->getMaxGid() + 1;
}
if (! $pic) {
alert_back('图片不能为空!');
}
// 构建数据
$data = array(
'acode' => session('acode'),
'gid' => $gid,
'pic' => $pic,
'link' => $link,
'title' => $title,
'subtitle' => $subtitle,
'sorting' => $sorting,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addSlide($data)) {
$this->log('新增轮播图成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Slide/index'));
}
} else {
$this->log('新增轮播图失败!');
error('新增失败!', - 1);
}
}
}
// 轮播图删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delSlide($id)) {
$this->log('删除轮播图' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除轮播图' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 轮播图修改
public function mod()
{
if (! ! $submit = post('submit')) {
switch ($submit) {
case 'sorting': // 修改列表排序
$listall = post('listall');
if ($listall) {
$sorting = post('sorting');
foreach ($listall as $key => $value) {
if ($sorting[$key] === '' || ! is_numeric($sorting[$key]))
$sorting[$key] = 255;
$this->model->modSlide($value, "sorting=" . $sorting[$key]);
}
$this->log('批量修改轮播图排序成功!');
success('修改成功!', - 1);
} else {
alert_back('排序失败,无任何内容!');
}
break;
}
}
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modSlide($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$gid = post('gid', 'int');
$pic = post('pic');
$link = post('link');
$title = post('title');
$subtitle = post('subtitle');
$sorting = post('sorting', 'int');
if (! $gid) {
$gid = $this->model->getMaxGid() + 1;
}
if (! $pic) {
alert_back('图片不能为空!');
}
// 构建数据
$data = array(
'gid' => $gid,
'pic' => $pic,
'link' => $link,
'title' => $title,
'subtitle' => $subtitle,
'sorting' => $sorting,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modSlide($id, $data)) {
$this->log('修改轮播图' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Slide/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getSlide($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('gids', $this->model->getGid());
$this->assign('slide', $result);
$this->display('content/slide.html');
}
}
}

View File

@@ -0,0 +1,157 @@
<?php
/**
* @copyright (C)2016-2099 Hnaoyun Inc.
* @author XingMeng
* @email hnxsh@foxmail.com
* @date 2019年07月12日
* 内链链接控制器
*/
namespace app\admin\controller\content;
use core\basic\Controller;
use app\admin\model\content\TagsModel;
class TagsController extends Controller
{
private $model;
public function __construct()
{
$this->model = new TagsModel();
}
// 文章内链列表
public function index()
{
if ((! ! $id = get('id', 'int')) && $result = $this->model->getTags($id)) {
$this->assign('more', true);
$this->assign('tags', $result);
} else {
$this->assign('list', true);
if (! ! ($field = get('field', 'var')) && ! ! ($keyword = get('keyword', 'vars'))) {
$result = $this->model->findTags($field, $keyword);
} else {
$result = $this->model->getList();
}
$this->assign('tags', $result);
}
$this->display('content/tags.html');
}
// 文章内链增加
public function add()
{
if ($_POST) {
// 获取数据
$name = post('name');
$link = post('link');
if (! $name) {
alert_back('名称不能为空!');
}
if (! $link) {
alert_back('链接不能为空!');
}
// 构建数据
$data = array(
'acode' => session('acode'),
'name' => $name,
'link' => $link,
'create_user' => session('username'),
'update_user' => session('username')
);
// 执行添加
if ($this->model->addTags($data)) {
$this->log('新增文章内链成功!');
if (! ! $backurl = get('backurl')) {
success('新增成功!', base64_decode($backurl));
} else {
success('新增成功!', url('/admin/Tags/index'));
}
} else {
$this->log('新增文章内链失败!');
error('新增失败!', - 1);
}
}
}
// 文章内链删除
public function del()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
if ($this->model->delTags($id)) {
$this->log('删除文章内链' . $id . '成功!');
success('删除成功!', - 1);
} else {
$this->log('删除文章内链' . $id . '失败!');
error('删除失败!', - 1);
}
}
// 文章内链修改
public function mod()
{
if (! $id = get('id', 'int')) {
error('传递的参数值错误!', - 1);
}
// 单独修改状态
if (($field = get('field', 'var')) && ! is_null($value = get('value', 'var'))) {
if ($this->model->modTags($id, "$field='$value',update_user='" . session('username') . "'")) {
location(- 1);
} else {
alert_back('修改失败!');
}
}
// 修改操作
if ($_POST) {
// 获取数据
$name = post('name');
$link = post('link');
if (! $name) {
alert_back('名称不能为空!');
}
if (! $link) {
alert_back('链接不能为空!');
}
// 构建数据
$data = array(
'name' => $name,
'link' => $link,
'update_user' => session('username')
);
// 执行添加
if ($this->model->modTags($id, $data)) {
$this->log('修改文章内链' . $id . '成功!');
if (! ! $backurl = get('backurl')) {
success('修改成功!', base64_decode($backurl));
} else {
success('修改成功!', url('/admin/Tags/index'));
}
} else {
location(- 1);
}
} else {
// 调取修改内容
$this->assign('mod', true);
if (! $result = $this->model->getTags($id)) {
error('编辑的内容已经不存在!', - 1);
}
$this->assign('tags', $result);
$this->display('content/tags.html');
}
}
}