1、后台的一些bug修复

2、内核更新
3、后台的扩展模型做了一点更新一点,还不够完善
This commit is contained in:
2016-07-19 14:08:00 +08:00
parent 124745c341
commit 783369c9e4
26 changed files with 492 additions and 238 deletions

View File

@@ -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(

View File

@@ -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;
}
/**

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View 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'
);
}

View 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;
}
}
}

View File

@@ -12,7 +12,7 @@ namespace app\common\validate;
/**
* 设置模型
*/
class Config extends \think\Validate{
class Config extends Base{
protected $rule = array(
'name' => 'require|unique',

View 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'
);
}

View File

@@ -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}$/',

View File

@@ -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}$/',