1、后台的一些bug修复
2、内核更新 3、后台的扩展模型做了一点更新一点,还不够完善
This commit is contained in:
@@ -42,8 +42,8 @@ class Action extends Admin {
|
||||
$model = model('Action');
|
||||
if(IS_POST){
|
||||
$data = input('post.');
|
||||
$result = $model->save();
|
||||
if ($result) {
|
||||
$result = $model->save($data);
|
||||
if (false != $result) {
|
||||
action_log('add_action', 'Action', $result, session('user_auth.uid'));
|
||||
return $this->success('添加成功!',url('index'));
|
||||
}else{
|
||||
|
||||
@@ -43,8 +43,7 @@ class Ad extends Admin {
|
||||
public function add(){
|
||||
$place = model('AdPlace');
|
||||
if (IS_POST) {
|
||||
$data = input('post.');
|
||||
$result = $place->save($data);
|
||||
$result = $place->change();
|
||||
if (false !== false) {
|
||||
return $this->success("添加成功!");
|
||||
}else{
|
||||
@@ -63,14 +62,9 @@ class Ad extends Admin {
|
||||
public function edit($id = null){
|
||||
$place = model('AdPlace');
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $place->save($data,array('id'=>$data['id']));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->adplace->getError());
|
||||
}
|
||||
$result = $place->change();
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/index'));
|
||||
}else{
|
||||
return $this->error($this->adplace->getError());
|
||||
}
|
||||
@@ -122,14 +116,9 @@ class Ad extends Admin {
|
||||
public function addad($id){
|
||||
$ad = model('ad');
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $ad->save($data);
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('admin/ad/lists',array('id'=>$data['place_id'])));
|
||||
}else{
|
||||
return $this->error($ad->getError());
|
||||
}
|
||||
$result = $ad->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!", url('admin/ad/lists',array('id'=>$data['place_id'])));
|
||||
}else{
|
||||
return $this->error($ad->getError());
|
||||
}
|
||||
@@ -148,14 +137,9 @@ class Ad extends Admin {
|
||||
public function editad($id = null){
|
||||
$ad = model('ad');
|
||||
if (IS_POST) {
|
||||
$data = $this->request->post();
|
||||
if ($data) {
|
||||
$result = $ad->save($data,array('id'=>$data['id']));
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/lists',array('id'=>$data['place_id'])));
|
||||
}else{
|
||||
return $this->error($ad->getError());
|
||||
}
|
||||
$result = $ad->change();
|
||||
if ($result) {
|
||||
return $this->success("修改成功!", url('admin/ad/lists',array('id'=>$data['place_id'])));
|
||||
}else{
|
||||
return $this->error($ad->getError());
|
||||
}
|
||||
|
||||
@@ -24,28 +24,17 @@ class Addons extends Admin {
|
||||
/**
|
||||
* 插件列表
|
||||
*/
|
||||
public function index(){
|
||||
$row = $this->addons->getList();
|
||||
foreach($row as $key => $value){
|
||||
$value['status_text'] = '';
|
||||
if($value['uninstall'] == 1){
|
||||
$value['uninstall_text'] = '未安装';
|
||||
}else{
|
||||
$value['uninstall_text'] = '已安装';
|
||||
if($value['status'] == 0){
|
||||
$value['status_text'] = '禁用';
|
||||
}else{
|
||||
$value['status_text'] = '启用';
|
||||
}
|
||||
}
|
||||
$list[] = $value;
|
||||
public function index($refresh = 0){
|
||||
if ($refresh) {
|
||||
$this->addons->refresh();
|
||||
}
|
||||
$list = $this->addons->order('id desc')->paginate(25);
|
||||
// 记录当前列表页的cookie
|
||||
Cookie('__forward__',$_SERVER['REQUEST_URI']);
|
||||
|
||||
$data = array(
|
||||
'list' => $list,
|
||||
//'page' => $page->show()
|
||||
'page' => $list->render()
|
||||
);
|
||||
$this->setMeta("插件管理");
|
||||
$this->assign($data);
|
||||
|
||||
@@ -75,7 +75,7 @@ class Attribute extends Admin {
|
||||
if ($result) {
|
||||
return $this->success("创建成功!",url('Attribute/index',array('model_id'=>$model_id)));
|
||||
}else{
|
||||
return $this->error($this->model->getError(),'');
|
||||
return $this->error($this->model->getError());
|
||||
}
|
||||
}else{
|
||||
if (!$model_id) {
|
||||
|
||||
@@ -82,9 +82,9 @@ class Content extends Admin{
|
||||
if (IS_POST) {
|
||||
$result = $this->model->change();
|
||||
if ($result) {
|
||||
return $this->success("添加成功!",url('admin/content/index',array('model_id'=>$this->modelInfo['id'])));
|
||||
return $this->success("添加成功!", url('admin/content/index',array('model_id'=>$this->modelInfo['id'])));
|
||||
}else{
|
||||
return $this->error($this->model->getError(),'');
|
||||
return $this->error($this->model->getError(), url('admin/content/add',array('model_id'=>$this->modelInfo['id'])));
|
||||
}
|
||||
}else{
|
||||
$info = array(
|
||||
@@ -109,16 +109,15 @@ class Content extends Admin{
|
||||
* 内容修改
|
||||
* @author molong <ycgpp@126.com>
|
||||
*/
|
||||
public function edit(){
|
||||
public function edit($id){
|
||||
if (IS_POST) {
|
||||
$result = $this->model->change();
|
||||
if ($result !== false) {
|
||||
return $this->success("更新成功!",url('admin/content/index',array('model_id'=>$this->modelInfo['id'])));
|
||||
}else{
|
||||
return $this->error($this->model->getError(),'');
|
||||
return $this->error($this->model->getError(), url('admin/content/edit',array('model_id'=>$this->modelInfo['id'],'id'=>$id)));
|
||||
}
|
||||
}else{
|
||||
$id = input('id','','trim,intval');
|
||||
if (!$id) {
|
||||
return $this->error("非法操作!");
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
{/volist}
|
||||
</tbody>
|
||||
</table>
|
||||
{$page}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -983,26 +983,6 @@ function get_category_child($id){
|
||||
return array_unique($ids);
|
||||
}
|
||||
|
||||
function getContentNav($type, $info){
|
||||
$data = array();
|
||||
|
||||
$map['model_id'] = $info['model_id'];
|
||||
$map['category_id'] = $info['category_id'];
|
||||
if ($type == 'prev') {
|
||||
$map['id'] = array('gt',$info['id']);
|
||||
$data = db('Document')->where($map)->order('id desc')->find();
|
||||
}elseif ($type == 'next') {
|
||||
$map['id'] = array('lt',$info['id']);
|
||||
$data = db('Document')->where($map)->order('id asc')->find();
|
||||
}
|
||||
if (!empty($data)) {
|
||||
$html = '<a href="' . url('index/content/detail',array('model_id'=>$info['model_id'], 'id'=>$data['id'])) . '">' . $data['title'] . '</a>';
|
||||
}else{
|
||||
$html = '没有了……';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
function send_email($to, $subject, $message){
|
||||
$config = array(
|
||||
'protocol' => 'smtp',
|
||||
@@ -1018,4 +998,56 @@ function send_email($to, $subject, $message){
|
||||
$email->message($message);
|
||||
|
||||
return $email->send();
|
||||
}
|
||||
|
||||
//php获取中文字符拼音首字母
|
||||
function getFirstCharter($s0){
|
||||
$fchar = ord($s0{0});
|
||||
if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($s0{0});
|
||||
$s1 = \iconv("UTF-8","gb2312", $s0);
|
||||
$s2 = \iconv("gb2312","UTF-8", $s1);
|
||||
if($s2 == $s0){$s = $s1;}else{$s = $s0;}
|
||||
$asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
|
||||
if($asc >= -20319 and $asc <= -20284) return "A";
|
||||
if($asc >= -20283 and $asc <= -19776) return "B";
|
||||
if($asc >= -19775 and $asc <= -19219) return "C";
|
||||
if($asc >= -19218 and $asc <= -18711) return "D";
|
||||
if($asc >= -18710 and $asc <= -18527) return "E";
|
||||
if($asc >= -18526 and $asc <= -18240) return "F";
|
||||
if($asc >= -18239 and $asc <= -17923) return "G";
|
||||
if($asc >= -17922 and $asc <= -17418) return "H";
|
||||
if($asc >= -17417 and $asc <= -16475) return "J";
|
||||
if($asc >= -16474 and $asc <= -16213) return "K";
|
||||
if($asc >= -16212 and $asc <= -15641) return "L";
|
||||
if($asc >= -15640 and $asc <= -15166) return "M";
|
||||
if($asc >= -15165 and $asc <= -14923) return "N";
|
||||
if($asc >= -14922 and $asc <= -14915) return "O";
|
||||
if($asc >= -14914 and $asc <= -14631) return "P";
|
||||
if($asc >= -14630 and $asc <= -14150) return "Q";
|
||||
if($asc >= -14149 and $asc <= -14091) return "R";
|
||||
if($asc >= -14090 and $asc <= -13319) return "S";
|
||||
if($asc >= -13318 and $asc <= -12839) return "T";
|
||||
if($asc >= -12838 and $asc <= -12557) return "W";
|
||||
if($asc >= -12556 and $asc <= -11848) return "X";
|
||||
if($asc >= -11847 and $asc <= -11056) return "Y";
|
||||
if($asc >= -11055 and $asc <= -10247) return "Z";
|
||||
return null;
|
||||
}
|
||||
|
||||
function PyFirst($zh){
|
||||
$ret = "";
|
||||
$s1 = \iconv("UTF-8","gb2312", $zh);
|
||||
$s2 = \iconv("gb2312","UTF-8", $s1);
|
||||
if($s2 == $zh){$zh = $s1;}
|
||||
for($i = 0; $i < strlen($zh); $i++){
|
||||
$s1 = substr($zh,$i,1);
|
||||
$p = ord($s1);
|
||||
if($p > 160){
|
||||
$s2 = substr($zh,$i++,2);
|
||||
$ret .= getFirstCharter($s2);
|
||||
}else{
|
||||
$ret .= $s1;
|
||||
}
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class Base extends \think\Controller{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
protected function setSeo($title = null,$keywords = null,$description = null){
|
||||
protected function setSeo($title = '', $keywords = '', $description = ''){
|
||||
$seo = array(
|
||||
'title' => $title,
|
||||
'keywords' => $keywords,
|
||||
@@ -87,14 +87,11 @@ class Base extends \think\Controller{
|
||||
);
|
||||
//获取还没有经过变量替换的META信息
|
||||
$meta = model('SeoRule')->getMetaOfCurrentPage($seo);
|
||||
foreach ($seo as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
foreach ($value as $k => $v) {
|
||||
$meta[$key] = str_replace("[".$k."]", $v . '|', $meta[$key]);
|
||||
}
|
||||
}else{
|
||||
$meta[$key] = str_replace("[".$key."]", $value . '|', $meta[$key]);
|
||||
foreach ($seo as $key => $item) {
|
||||
if (is_array($item)) {
|
||||
$item = implode(',', $item);
|
||||
}
|
||||
$meta[$key] = str_replace("[".$key."]", $item . '|', $meta[$key]);
|
||||
}
|
||||
|
||||
$data = array(
|
||||
|
||||
@@ -19,15 +19,27 @@ class Addons extends \app\common\model\Base {
|
||||
protected $auto = array('status');
|
||||
protected $insert = array('create_time');
|
||||
|
||||
protected function setStatusAttr(){
|
||||
protected function setStatusAttr($value){
|
||||
return 1;
|
||||
}
|
||||
|
||||
protected function setIsinstallAttr($value){
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected function getStatusTextAttr($value, $data){
|
||||
return $data['status'] ? "启用" : "禁用";
|
||||
}
|
||||
|
||||
protected function getUninstallAttr($value, $data){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取插件列表
|
||||
* 更新插件列表
|
||||
* @param string $addon_dir
|
||||
*/
|
||||
public function getList($addon_dir = ''){
|
||||
public function refresh($addon_dir = ''){
|
||||
if(!$addon_dir){
|
||||
$addon_dir = SENT_ADDON_PATH;
|
||||
}
|
||||
@@ -36,13 +48,9 @@ class Addons extends \app\common\model\Base {
|
||||
$this->error = '插件目录不可读或者不存在';
|
||||
return FALSE;
|
||||
}
|
||||
$addons = array();
|
||||
$where['name'] = array('in',$dirs);
|
||||
$list = db('Addons')->where($where)->field(true)->select();
|
||||
foreach($list as $addon){
|
||||
$addon['uninstall'] = 0;
|
||||
$addons[$addon['name']] = $addon;
|
||||
}
|
||||
$addons = $this->where($where)->select();
|
||||
|
||||
foreach ($dirs as $value) {
|
||||
$value = ucfirst($value);
|
||||
if(!isset($addons[$value])){
|
||||
@@ -61,9 +69,6 @@ class Addons extends \app\common\model\Base {
|
||||
}
|
||||
}
|
||||
}
|
||||
int_to_string($addons, array('status'=>array(-1=>'损坏', 0=>'禁用', 1=>'启用', null=>'未安装')));
|
||||
$addons = list_sort_by($addons,'uninstall','desc');
|
||||
return $addons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,27 +43,24 @@ class Attribute extends Base{
|
||||
}
|
||||
|
||||
public function change(){
|
||||
$data = input('post.');
|
||||
$data = \think\Request::instance()->post();
|
||||
|
||||
if (!empty($data)) {
|
||||
if ($data['id']) {
|
||||
$status = $this->validate('attribute.edit')->save($data, array('id'=>$data['id']));
|
||||
}else{
|
||||
$status = $this->validate('attribute.add')->save($data);
|
||||
}
|
||||
|
||||
if (false !== $status) {
|
||||
//在数据库内添加字段
|
||||
$result = $this->checkTableField($data);
|
||||
if (!$result) {
|
||||
$this->error = "字段创建失败!";
|
||||
return false;
|
||||
}
|
||||
if ($data['id']) {
|
||||
$status = $this->save($data, array('id'=>$data['id']));
|
||||
}else{
|
||||
$status = $this->save($data);
|
||||
}
|
||||
|
||||
if (false !== $status) {
|
||||
return $status;
|
||||
}else{
|
||||
$this->error = "添加失败!";
|
||||
return false;
|
||||
}
|
||||
return $status;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,17 +85,15 @@ class Document extends \think\model\Merge{
|
||||
/* 添加或新增基础内容 */
|
||||
if(empty($data['id'])){ //新增数据
|
||||
unset($data['id']);
|
||||
$id = $this->save($data); //添加基础内容
|
||||
$id = $this->validate('document.edit')->save($data); //添加基础内容
|
||||
|
||||
if(!$id){
|
||||
$this->error = '添加基础内容出错!';
|
||||
return false;
|
||||
}
|
||||
$data['id'] = $id;
|
||||
} else { //更新数据
|
||||
$status = $this->save($data, array('id'=>$data['id'])); //更新基础内容
|
||||
$status = $this->validate('document.edit')->save($data, array('id'=>$data['id'])); //更新基础内容
|
||||
if(false === $status){
|
||||
$this->error = '更新基础内容出错!';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
38
application/common/validate/Attribute.php
Normal file
38
application/common/validate/Attribute.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Attribute extends Base{
|
||||
|
||||
protected $rule = array(
|
||||
'name' => 'require|/^[a-zA-Z]\w{0,39}$/',
|
||||
'title' => 'require',
|
||||
'type' => 'require',
|
||||
'length' => 'requireIn:type,textarea,editor|integer',
|
||||
'remark' => 'require',
|
||||
);
|
||||
|
||||
protected $message = array(
|
||||
'length.requireIn' => '字段长度必须!',
|
||||
'length.integer' => '字段必须为整形',
|
||||
'name.require' => '字段名不能为空!',
|
||||
'title.require' => '字段标题不能为空!',
|
||||
'type.require' => '类型不能为空!',
|
||||
'remark.require' => '描述不能为空!',
|
||||
);
|
||||
|
||||
protected $scene = array(
|
||||
'add' => 'name,title,type,remark,length',
|
||||
'edit' => 'name,title,type,remark,length'
|
||||
);
|
||||
}
|
||||
32
application/common/validate/Base.php
Normal file
32
application/common/validate/Base.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Base extends \think\Validate{
|
||||
|
||||
|
||||
protected function requireIn($value, $rule, $data){
|
||||
if (is_string($rule)) {
|
||||
$rule = explode(',', $rule);
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
$field = array_shift($rule);
|
||||
$val = $this->getDataValue($data, $field);
|
||||
if (!in_array($val, $rule) && $value == '') {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace app\common\validate;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Config extends \think\Validate{
|
||||
class Config extends Base{
|
||||
|
||||
protected $rule = array(
|
||||
'name' => 'require|unique',
|
||||
|
||||
29
application/common/validate/Document.php
Normal file
29
application/common/validate/Document.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Document extends Base{
|
||||
|
||||
protected $rule = array(
|
||||
'title' => 'require',
|
||||
);
|
||||
|
||||
protected $message = array(
|
||||
'title.require' => '字段标题不能为空!',
|
||||
);
|
||||
|
||||
protected $scene = array(
|
||||
'add' => 'title',
|
||||
'edit' => 'title'
|
||||
);
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace app\common\validate;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Member extends \think\Validate{
|
||||
class Member extends Base{
|
||||
|
||||
protected $rule = array(
|
||||
'username' => 'require|unique:member|/^[a-zA-Z]\w{0,39}$/',
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace app\common\validate;
|
||||
/**
|
||||
* 设置模型
|
||||
*/
|
||||
class Model extends \think\Validate{
|
||||
class Model extends Base{
|
||||
|
||||
protected $rule = array(
|
||||
'name' => 'require|unique:model|/^[a-zA-Z]\w{0,39}$/',
|
||||
|
||||
@@ -96,7 +96,10 @@ class Content extends Fornt{
|
||||
}
|
||||
$cate = $this->getCategory($id);
|
||||
|
||||
$map = array();
|
||||
$category = get_category_child($id);
|
||||
$map = array(
|
||||
'category_id' => array('IN', $category)
|
||||
);
|
||||
|
||||
$order = "id desc";
|
||||
$list = model('Document')->where($map)->order($order)->paginate(15);
|
||||
|
||||
Reference in New Issue
Block a user