Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

Commit

Permalink
Merge pull request #39 from DiliCMS/develop
Browse files Browse the repository at this point in the history
Release v2.3.0
  • Loading branch information
Che Kun committed Mar 20, 2014
2 parents 3bd4168 + d0530f0 commit 6435b61
Show file tree
Hide file tree
Showing 39 changed files with 1,206 additions and 363 deletions.
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
# DiliCMS更新日志

## 版本号 2.3.0

> 2014年3月20日 更新内容
- 分类模型新增【自动更新缓存选项】
- 站点设置增加预设缩略图配置
- 内容模型和分类模型增加缩略图配置
- 新增缩略图功能(该版本此功能依赖[php-imagick](http://www.php.net/manual/zh/book.imagick.php)扩展)
- 增加 HTTP BASIC AUTH 认证设置
- 增加登录throttle, 密码输入四次后将会被冻结2小时
- 欢迎页面加入讨论群二维码
- 安装页面加入讨论群二维码


## 版本号 2.2.0

> 见v2.2.0-rc.1和v2.2.0-rc.2
## 版本号 2.2.0-rc.2

> 2013年1月4日 更新内容
> 2014年1月4日 更新内容
- 修复分类管理没有兼容新插件结构的错误
- 修复分类path错乱,以及其引起的级别限制无效和删除不全的错误

## 版本号 2.2.0-rc.1

> 2013年12月29日 更新内容
> 2014年12月29日 更新内容
- 1.全新的插件系统,每个插件都已HMVC组织实现
- 2.二级菜单[插件管理]改名为[扩展管理]
Expand Down
72 changes: 63 additions & 9 deletions admin/controllers/attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ public function _upload_post()
{

//不能加载SESSION类库
$session_id = $this->input->post('hash', TRUE);
$session = $this->db->where('session_id', $session_id)->get($this->db->dbprefix('sessions'))->row();
$hash = $this->input->post('hash', TRUE);
list($session_id, $model_type, $model) = explode('^', $hash);
$session = $this->db->where('session_id', $session_id)->get($this->db->dbprefix('sessions'))->row();
$status = "ok";
$response = "";
if ($session)
Expand All @@ -73,12 +74,6 @@ public function _upload_post()
}
else
{
//获取用户信息,让插件管理类正确执行(暂时的解决方案)
$this->_admin = $this->user_mdl->get_full_user_by_username($userdata['uid'], 'uid');
//加载ACL
$this->load->library('acl');
//加载插件经理
$this->load->library('plugin_manager');
if ( ! $_FILES['Filedata']['error'])
{
$data['folder'] = date('Y/m', $now);
Expand All @@ -99,6 +94,10 @@ public function _upload_post()
else
{
$data['image'] = (in_array($data['type'], array('jpg', 'gif', 'png', 'jpeg', 'bmp'))) ? 1 : 0;
//currently we only support Imagick to resize images
if ($data['image'] and extension_loaded('imagick')) {
$this->thumbnail($model_type, $model, $target_file, $data['type']);
}
$this->db->insert($this->db->dbprefix('attachments'), $data);
$response = $this->db->insert_id() . '|' . $data['realname'] . '|' . $data['name'] . '|' . $data['image'].'|'.$data['folder'].'|'.$data['type'];
}
Expand All @@ -124,6 +123,50 @@ public function _upload_post()

// ------------------------------------------------------------------------

/**
* 缩略图片
*
* @access private
* @param $model_type
* @param $model
* @param $target
* @param $ext
* @return void
*/
private function thumbnail($model_type, $model, $target, $ext)
{
//do we have thumbnail settings for target model?
if ($model_type and $model and in_array($model_type, array('model', 'category'))) {
if ($model_type == 'model') {
$this->settings->load('model/' . $model);
$target_model = $this->settings->item('models');
$target_model = $target_model[$model];
} elseif ($model_type == 'category') {
$this->settings->load('category/cate_' . $model);
$target_model = $this->settings->item('cate_models');
$target_model = $target_model[$model];
}
$thumb_preferences = json_decode($target_model['thumb_preferences']);
if ($thumb_preferences and count($thumb_preferences->enabled) > 0) {
$thumbs_preferences = json_decode(setting('thumbs_preferences'));
if ($thumbs_preferences) {
$this->load->library('tailor');
foreach ($thumbs_preferences as $pref) {
if (in_array($pref->size, $thumb_preferences->enabled)) {
$this->tailor->initialize($target, $ext);
$this->tailor->measure($pref->size, $pref->rule);
$this->tailor->save($target.'.'.$pref->size);
}
}
return $thumb_preferences->default == 'original' ? '' : $thumb_preferences->default;
}
}
return '';
}
}

// ------------------------------------------------------------------------

/**
* 编辑器文件上传接口
*
Expand Down Expand Up @@ -201,8 +244,17 @@ public function _save_post()
$this->db->insert($this->db->dbprefix('attachments'), $upload);
if ($aid = $this->db->insert_id())
{
$thumbnailDefaultSize = '';
//currently we only support Imagick to resize images
if ($upload['image'] and extension_loaded('imagick')) {
$thumbnailDefaultSize = $this->thumbnail($this->session->userdata('model_type'), $this->session->userdata('model'), $target_file, $upload['type']);
}

//已上传成功并已插入数据库
$url = setting('attachment_url').'/'.$upload['folder'].'/'.$upload['name'].'.'.$upload['type'];
if ($thumbnailDefaultSize) {
$url .= '.'.$thumbnailDefaultSize.'.'.($upload['type'] == 'gif' ? 'gif' : 'jpg');
}
$error = '';
$object = $aid . '|' . $upload['realname'] . '|' . $upload['name'] . '|' . $upload['image'].'|'.$upload['folder'].'|'.$upload['type'];
}
Expand All @@ -229,6 +281,8 @@ public function _save_post()
public function config()
{
$this->load->library('session');
$model_type = $this->session->userdata('model_type') ?: '';
$model = $this->session->userdata('model') ?: '';
echo '<?xml version="1.0" encoding="UTF-8"?>
<parameter>
<allowsExtend>
Expand All @@ -255,7 +309,7 @@ public function config()
</language>
<config>
<userid>'.$this->session->userdata('uid').'</userid>
<hash>'.$this->session->userdata('session_id').'</hash>
<hash>'.$this->session->userdata('session_id').'^'.$model_type.'^'.$model.'</hash>
<maxupload>'.$this->settings->item('attachment_maxupload').'</maxupload>
</config>
</parameter>';
Expand Down
8 changes: 8 additions & 0 deletions admin/controllers/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function __construct()
parent::__construct();
$this->_check_permit();
$this->load->model('category_mdl');
$this->load->helper('thumb');
}

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -97,6 +98,9 @@ public function _add_post()
$data['perpage'] = $this->input->post('perpage', TRUE);
$data['level'] = $this->input->post('level', TRUE);
$data['hasattach'] = $this->input->post('hasattach', TRUE);
$data['auto_update'] = $this->input->post('auto_update', TRUE);
//处理缩略图设置
create_thumb_preferences($data);
//新增分类模型
$this->category_mdl->add_new_category($data);
//更新缓存
Expand Down Expand Up @@ -178,6 +182,9 @@ public function _edit_post($id = 0)
$data['perpage'] = $this->input->post('perpage', TRUE);
$data['level'] = $this->input->post('level', TRUE);
$data['hasattach'] = $this->input->post('hasattach', TRUE);
$data['auto_update'] = $this->input->post('auto_update', TRUE);
//处理缩略图设置
create_thumb_preferences($data);
$this->category_mdl->edit_category_model($target_model, $data);
update_cache('category', $data['name']);
update_cache('menu');
Expand All @@ -187,6 +194,7 @@ public function _edit_post($id = 0)
else
{
$data['model'] = $target_model;
$data['model']->thumb_preferences = json_decode($target_model->thumb_preferences);
$data['bread'] = make_bread(Array(
'模型管理' => '',
'分类模型管理' => site_url('category/view'),
Expand Down
69 changes: 46 additions & 23 deletions admin/controllers/category_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ public function form()
*/
public function _save_post()
{

$model = $this->input->get('model', TRUE);

$this->session->set_userdata('model_type', 'category');
$this->session->set_userdata('model', $model);

$this->settings->load('category/cate_' . $model);
$data['model'] = $this->settings->item('cate_models');
$data['model'] = $data['model'][$model];
Expand All @@ -228,37 +232,37 @@ public function _save_post()
$data['content'] = array();
$data['button_name'] = '添加';
}

if ($data['parentid'] > 0)
{
$current_level = $this->db->where('classid', $data['parentid'])
->get($this->db->dbprefix('u_c_') . $model)
->row()
->level + 1;
->level + 1;
}
else
{
$current_level = 1;
$current_level = 1;
}


$data['path'] = $this->_find_path($current_level);

$this->load->library('form_validation');

foreach ($data['model']['fields'] as $v)
{
if ($v['rules'] != '')
{
$this->form_validation->set_rules($v['name'], $v['description'], str_replace(",", "|", $v['rules']));
$this->form_validation->set_rules($v['name'], $v['description'], str_replace(",", "|", $v['rules']));
}
}

$this->load->library('form');
$this->load->library('field_behavior');
if ($this->form_validation->run() == FALSE)
{

$bread = Array(
'分类管理' => '',
$data['model']['description'] => site_url('category_content/view?model=' . $data['model']['name']),
Expand All @@ -272,7 +276,13 @@ public function _save_post()
}
$bread[ $id ? '编辑' : '添加' ] = '';
$data['bread'] = make_bread($bread);


$thumb_preferences = json_decode($data['model']['thumb_preferences']);
$data['thumb_default_size'] = '';
if ($thumb_preferences and $thumb_preferences->default != 'original') {
$data['thumb_default_size'] = $thumb_preferences->default;
}

$this->_template('category_content_form', $data);
}
else
Expand All @@ -298,7 +308,7 @@ public function _save_post()
if ($parent_class)
{
$data['path'] = $parent_class->path;
$data['level'] = $parent_class->level + 1;
$data['level'] = $parent_class->level + 1;
}
else
{
Expand All @@ -310,7 +320,7 @@ public function _save_post()
$data['level'] = 1;
}
$attachment = $this->input->post('uploadedfile', TRUE);

if ($id)
{
$this->plugin_manager->trigger('updating', $data, $id);
Expand All @@ -323,9 +333,12 @@ public function _save_post()
->set('from', 1)
->set('content', $id)
->where('aid in (' . $attachment . ')')
->update($this->db->dbprefix('attachments'));
->update($this->db->dbprefix('attachments'));
}
$this->_message('修改成功!', 'category_content/form', TRUE, '?model=' . $modeldata['name'] . '&id=' . $id);
if ($modeldata['auto_update']) {
update_cache('category', $model);
}
$this->_message('修改成功!', 'category_content/form', TRUE, '?model=' . $modeldata['name'] . '&id=' . $id);
}
else
{
Expand All @@ -335,14 +348,17 @@ public function _save_post()
$this->plugin_manager->trigger('inserted', $data, $id);
if($attachment != '0')
{
$this->db->set('model',$modeldata['id'])->set('from',1)->set('content',$id)->where('aid in ('.$attachment.')')->update($this->db->dbprefix('attachments'));
$this->db->set('model',$modeldata['id'])->set('from',1)->set('content',$id)->where('aid in ('.$attachment.')')->update($this->db->dbprefix('attachments'));
}
$this->_message('添加成功!','category_content/view',true,'?model='.$modeldata['name'].'&u_c_level='.$data['parentid']);
if ($modeldata['auto_update']) {
update_cache('category', $model);
}
$this->_message('添加成功!','category_content/view',true,'?model='.$modeldata['name'].'&u_c_level='.$data['parentid']);
}
}

}

// ------------------------------------------------------------------------

/**
Expand Down Expand Up @@ -370,7 +386,8 @@ public function _del_post()
$this->_check_permit();
$ids = $this->input->get_post('classid', TRUE);
$model = $this->input->get('model', TRUE);
$model_id = $this->db->select('id')->where('name', $model)->get($this->db->dbprefix('cate_models'))->row()->id;
$model_data = $this->db->select('id')->where('name', $model)->get($this->db->dbprefix('cate_models'))->row();
$model_id = $model_data->id;
if ($ids)
{

Expand Down Expand Up @@ -413,6 +430,9 @@ public function _del_post()
->delete($this->db->dbprefix('attachments'));
$this->db->where_in('classid', $ids)->delete($this->db->dbprefix('u_c_') . $model);
$this->plugin_manager->trigger('deleted', $ids);
if ($model_data->auto_update) {
update_cache('category', $model);
}
}
$this->_message('删除操作成功完成!', '', TRUE);
}
Expand Down Expand Up @@ -442,7 +462,7 @@ public function attachment($action = 'list')
}
echo implode(',', $response);
}
else if($action == 'del')
elseif ($action == 'del')
{
$attach = $this->db->select('aid, name, folder, type')
->where('aid', $this->input->get('id', TRUE))
Expand All @@ -457,7 +477,10 @@ public function attachment($action = 'list')
$attach->type);
$this->db->where('aid', $attach->aid)->delete($this->db->dbprefix('attachments'));
echo 'ok';
}

} else {
echo 'ok';
}
}
}

Expand Down
Loading

0 comments on commit 6435b61

Please sign in to comment.