state();
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['child'] = Dever::db('collection/info')->state(array('cate_id' => $v['id']));
}
}
return $data;
}
# 获取数据
public function num($id)
{
$data = Dever::db('collection/info')->one($id);
$data = Dever::load('collection/lib/info')->one($data);
$cate = Dever::db('collection/cate')->one($data['cate_id']);
$html = '《' . $cate['name'] . '》
';
if ($data['buy'] == 1) {
$name = '购买总数';
$html .= '收费
';
} else {
$name = '阅读人数';
$html .= '免费
';
}
$html .= $name . ':('.$data['num_buy'].'+'.$data['num_add_buy'].')*'.$data['num_ratio_buy'].'='.$data['num_buy_total'];
$html .= '
阅读次数:'.$data['num_view'].'+'.$data['num_add_view'].'='.$data['num_view_total'];
return $html;
}
# 获取数据
public function objectNum($id)
{
$data = Dever::db('collection/object')->one($id);
$data = Dever::load('collection/lib/info')->one($data);
$html = '购买数:('.$data['num_buy'].'+'.$data['num_add_buy'].')*'.$data['num_ratio_buy'].'='.$data['num_buy_total'];
return $html;
}
private function search($table = 'content/article')
{
$keyword = Dever::input('keyword');
$yes = Dever::input('yes');
$where = array();
$cate = Dever::input('cate');
if ($cate) {
$where['cate_id'] = $cate;
}
if ($yes) {
$yes = Dever::db($table)->search(array('ids' => $yes));
}
if (!$keyword) {
$where['limit'] = '0,50';
$data = Dever::db($table)->search($where);
} else {
$where['name'] = $keyword;
$data = Dever::db($table)->search($where);
}
$result = array();
if ($yes) {
foreach ($yes as $k => $v) {
if (isset($data[$k])) {
unset($data[$k]);
}
$yes[$k]['selected'] = 'selected';
}
$data = $yes + $data;
$data = array_merge($data, array());
} else {
$data = array_merge($data, array());
}
if (!$data) {
Dever::alert('暂无数据');
}
return $data;
}
# 搜索
public function search_journal_api()
{
return $this->search('collection/info');
}
# 按照分类搜索
public function search_cate_journal_api()
{
$level_num = Dever::input('level_num');
$level_id = Dever::input('level_id');
$auth = Dever::tops();
$where = array();
if ($level_num == 1) {
$default = array
(
'value' => -1,
'name' => '选择分类',
);
if ($auth) {
$where['ids'] = $auth;
}
$data = Dever::db('collection/cate')->getIds($where);
} elseif ($level_num == 2 && $level_id > 0) {
$default = array
(
'value' => -1,
'name' => '选择合集',
);
if ($level_id > 0) {
$where['cate_id'] = $level_id;
} elseif ($auth) {
$where['cate_id'] = $auth;
}
$data = Dever::db('collection/info')->getIds($where);
} else {
return array();
}
array_unshift($data, $default);
$result['level_total'] = 2;
$result['list'] = $data;
return $result;
}
# 显示内页
public function content()
{
$where['info_id'] = Dever::input('search_option_info_id');
$where['page_id'] = Dever::input('send_page_id');
$where['state'] = Dever::input('search_option_state');
$data = Dever::db('collection/content')->all($where);
$database = Dever::load('manage/database');
$type = Dever::db('collection/cate')->config['gettype'];
if ($data) {
foreach ($data as $k => $v) {
$data[$k]['height'] = 'height: 154px;';
$data[$k]['info_height'] = 'height: auto;';
$data[$k]['type_name'] = '[' . $type[$v['type']]['name'] . ']';
$data[$k]['text'] = '';
$link = $database->url('edit', $v['id']) . '&search_option_info_id=' . $where['info_id'];
$data[$k]['edit'] = "fastEdit($(this), '".$link."', '编辑数据内容', '', 1)";
$data[$k]['editurl'] = $link;
$table = $type[$v['type']]['table'];
$list = false;
$method = 'edit';
if (strstr($table, '-')) {
$list = true;
$temp = explode('-', $table);
$table = $temp[0];
$method = 'list';
}
# 验证有没有数据
$info = Dever::db($table)->one(array('content_id' => $v['id'], 'info_id' => $v['info_id']));
$id = false;
if ($list) {
$data[$k]['data_name'] = '内容列表';
} elseif ($info) {
$id = $info['id'];
$data[$k]['data_name'] = '更新内容';
} else {
$data[$k]['data_name'] = '新增内容';
}
$temp = explode('/', $table);
$project_name = $temp[0];
$table_name = $temp[1];
$param['search_option_info_id'] = $v['info_id'];
$param['search_option_content_id'] = $v['id'];
# 当前表和项目
$param['table'] = $table_name;
$param['project'] = $project_name;
# 保存之后要跳转的表和项目
if ($list) {
$param['oper_page_type'] = 1;
# 更新后要跳转的
$param['oper_save_table'] = $table_name;
$param['oper_save_project'] = $project_name;
# 上级表和项目
$param['oper_table'] = 'content';
$param['oper_project'] = 'collection';
$param['top_table'] = 'page.info';
$param['top_project'] = 'collection';
} else {
$param['oper_save_table'] = 'content';
$param['oper_save_project'] = 'collection';
$param['oper_table'] = 'page';
$param['oper_project'] = 'collection';
$param['top_table'] = 'info';
$param['top_project'] = 'collection';
}
$data[$k]['data_editurl'] = $database->url($method, $id, $table_name, '', $project_name, $param);
$data[$k]['delete'] = $database->url('delete', $v['id']);
}
}
return $data;
}
private function text_name($link, $content_id, $info_id, $location, $name)
{
$where['info_id'] = $info_id;
$where['content_id'] = $content_id;
$where['location'] = $location;
$info = Dever::db('collection/content_text')->one($where);
$link .= '&search_option_info_id=' . $info_id. '&search_option_content_id=' . $content_id.'&table=content_text&search_option_location='.$location;
if ($info) {
$link .= '&where_id=' . $info['id'];
}
$html = ''.$name.'';
return $html;
}
public function text($database, $content_id, $info_id)
{
$link = $database->url('edit');
$location = Dever::db('collection/content_text')->config['location'];
$html = '
'.$name.' | '; if ($i == 2 || $i == 5) { $html .= '