/** * @Description : 获取发布库内容 * @Author : dong(dong@hoge.cn) * @Category : publishcontent * @Date : 2014-2-14 * @LastUpdateDate : 2014-2-14 * @Copyright : hogesoft * @Param : site_id(站点id);column_id(栏目id,多个逗号隔开);client_type(终端id); * @Return : json */ public function show() { $site_id = $column_id = ''; $content_data = array(); $id = urldecode($this->input['_id']); $app = urldecode($this->input['con_app']) == 'all' ? '' : urldecode($this->input['con_app']); //查询出站点下模块的内容 //$offset = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 0; $page = $this->input['page'] ? intval(urldecode($this->input['page'])) : 1; $count = $this->input['offset'] ? intval(urldecode($this->input['offset'])) : 20; $offset = $count * ($page - 1); $content_data = $this->obj->get_content_allinfo($this->get_condition(), $offset, $count, $this->other_field); if ($content_data['col_id_str']) { $col_parent = $this->column->get_col_parents($content_data['col_id_str']); $column_datas = $this->column->get_column_by_id(' id,name,site_id,column_dir,relate_dir,fid,childdomain,father_domain,custom_content_dir,col_con_maketype ', $content_data['col_id_str'], 'id'); } if ($content_data['site_id_arr']) { $site_datas = $this->column->get_site(' id,site_name,weburl,sub_weburl,custom_content_dir ', ' AND id in(' . implode(',', $content_data['site_id_arr']) . ')', 'id'); } unset($content_data['col_id_str']); unset($content_data['site_id_arr']); foreach ($content_data as $k => $v) { $content_data[$k]['state'] = $v['status']; if ($v['outlink']) { $content_data[$k]['content_url'] = stripos($v['outlink'], 'http') === 0 ? $v['outlink'] : 'http://' . $v['outlink']; } else { $v['column_id'] = $v['use_maincolumn'] ? $v['main_column_id'] : $v['column_id']; $content_data[$k]['content_url'] = mk_content_url($site_datas[$v['site_id']], $column_datas[$v['column_id']], $v); } } //取出应用模块 $appdata = $this->obj->get_app(); $appchilddata = $this->obj->get_app_child($app); //取出所有客户端 include_once CUR_CONF_PATH . 'lib/client.class.php'; $client_obj = new client(); $client = $client_obj->get_all_client('*', '', 'id'); $sql = "SELECT COUNT(*) AS total" . $this->other_field . " FROM " . DB_PREFIX . "content_client_relation cr LEFT JOIN " . DB_PREFIX . "content_relation r ON cr.relation_id=r.id WHERE 1 " . $this->get_condition(); $pagearr = $this->db->query_first($sql); $pagearr['offset'] = $count; $pagearr['count'] = $count; $pagearr['total_page'] = ceil($pagearr['total'] / $count); $pagearr['current_page'] = floor($offset / $count) + 1; $alldata['content_data'] = $content_data; $alldata['col_parent'] = $col_parent; $alldata['app_data'] = $appdata; $alldata['appchild_data'] = $appchilddata; $alldata['client'] = $client; $alldata['page'] = $pagearr; $this->addItem($alldata); $this->output(); }
public function video_record() { $site = $this->input['site']; if (!$site || !is_array($site)) { $this->errorOutput('NO_SITE_IDS'); } $video_record = $content_id = $content_data = array(); foreach ($site as $k => $v) { $sql = "SELECT * FROM " . DB_PREFIX . "content_video_record WHERE site_id=" . $v['site_id'] . " ORDER BY id DESC LIMIT " . $v['video_record_count']; $info = $this->db->query($sql); while ($row = $this->db->fetch_array($info)) { $video_record[$row['site_id']][] = $row; $content_data_detail = $row['content_data'] ? unserialize($row['content_data']) : array(); $content_data_detail['site_id'] = $row['site_id']; $content_data_detail['column_id'] = $row['column_id']; $content_data_detail['struct_id'] = $row['struct_id']; $content_data_detail['id'] = $row['relation_id']; $content_data_detail['op'] = $row['opration']; $content_data[$row['relation_id']] = $content_data_detail; $column_ids[$row['column_id']] = $row['column_id']; $site_ids[$row['site_id']] = $row['site_id']; } } if ($content_data) { include_once CUR_CONF_PATH . 'lib/column.class.php'; $column_obj = new column(); if ($column_ids) { $column_datas = $column_obj->get_column_by_id(' id,name,childdomain,column_dir,site_id,relate_dir,father_domain ', implode(',', $column_ids), 'id'); } if ($site_ids) { $site_datas = $column_obj->get_site(' id,site_name,weburl,sub_weburl ', ' AND id in(' . implode(',', $site_ids) . ')', 'id'); } foreach ($content_data as $k => $v) { $content_data[$k]['content_url'] = mk_content_url($site_datas[$v['site_id']], $column_datas[$v['column_id']], $v); } } $result['video_record'] = $video_record; $result['content_data'] = $content_data; $this->addItem($result); $this->output(); }
public function mk_content_by_rid($rid = '') { if ($rid) { $data['content_id'] = $rid; $allmk = true; } else { $data['content_id'] = intval($this->input['rid']); } if (!$data['content_id']) { if ($this->input['rewrite']) { exit; } echo "没有查询的id"; exit; } if ($this->settings['App_mkpublish']) { include_once CUR_CONF_PATH . 'lib/column.class.php'; $this->column = new column(); $content_data = $this->obj->get_all_content_by_relationid($data['content_id']); if (!$content_data && $this->input['rewrite']) { exit; } $column_data = $this->column->get_site_column_first(' id,name,site_id,fid,childdomain,father_domain,column_dir,relate_dir,col_con_maketype ', $content_data['column_id']); $site_data = $column_data['site_data']; unset($column_data['site_data']); $content_data['content_url'] = $content_data['outlink'] ? $content_data['outlink'] : mk_content_url($site_data, $column_data, $content_data); $content_data['column_info'] = $column_data; if (!$content_data) { if ($this->input['rewrite']) { exit; } if ($allmk) { if ($this->input['rewrite']) { exit; } return "这条内容已打回" . "<br>"; } else { if ($this->input['rewrite']) { exit; } echo "这条内容已打回"; exit; } } if (!$content_data) { $this->mk->del_publish(array('rid' => $data['content_id'])); exit; } $sql = "SELECT id FROM " . DB_PREFIX . "content_field WHERE bundle_id='" . $content_data['bundle_id'] . "' AND module_id='" . $content_data['module_id'] . "' AND content_type!='' AND struct_ast_id='' ORDER BY id"; $content_type = $this->db->query_first($sql); $plan['title'] = $content_data['title']; $plan['site_id'] = $content_data['site_id']; $plan['page_data_id'] = $content_data['column_id']; $plan['content_type'] = intval($content_type['id']); $plan['template_sign'] = $content_data['template_sign']; $plan['rid'] = $content_data['id']; $plan['content_type_sign'] = $content_data['bundle_id']; $plan['client_type'] = 2; $plan['content_detail'] = array('content_url' => $content_data['content_url'], 'id' => $content_data['id'], 'rid' => $content_data['rid'], 'cid' => $content_data['cid'], 'content_fromid' => $content_data['content_fromid'], 'file_name' => $content_data['file_name'], 'template_sign' => $content_data['template_sign'], 'content_type_sign' => $content_data['content_type_sign'], 'column_id' => $content_data['column_id'], 'site_id' => $content_data['site_id']); $error_data = $plan; //取栏目的page_id include_once ROOT_PATH . 'lib/class/publishsys.class.php'; $this->pub_sys = new publishsys(); $page_data = $this->pub_sys->get_page_by_sign('column', $content_data['site_id']); if (!$page_data['id']) { //插入错误日志; $error_data['failure'] = '模板->页面管理:可能没有栏目页面类型,或者栏目配置错误'; $this->insert_error_log($error_data); return; } $plan['page_id'] = $page_data['id']; if ($content_data['template_sign']) { //查询页面类型id $page_data_c = $this->pub_sys->get_page_by_sign($content_data['bundle_id']); if (!$page_data_c['id']) { return; } if ($page_data_c['id']) { $plan['page_data_id_c'] = $content_data['content_fromid']; $plan['page_id_c'] = $page_data_c['id']; } else { $plan['template_sign'] = ''; //插入错误日志; $error_data['failure'] = '模板->页面管理:可能没有专题页面类型,或者专题配置,专题添加参数错误'; $this->insert_error_log($error_data); return; } } if ($allmk) { $plan['publish_time'] = TIMENOW; $plan['title'] = $content_data['title']; $this->mk->insert_plan($plan); } else { $this->mk->mk_publish($plan); } if ($this->input['rewrite']) { header('Location: ' . $content_data['content_url']); //echo @file_get_contents($content_data['content_url']); exit; } if ($allmk) { return $content_data['content_url'] . '<br>'; } else { echo json_encode($content_data); return; } } echo "未安装生成发布"; exit; }
public function get_all_content_by_relationid($id, $need_process = false) { include_once CUR_CONF_PATH . 'lib/column.class.php'; $column = new column(); $sql = "SELECT c.*,r.*,c.id as cid,c.column_id as main_column_id,r.site_id,r.column_id,r.column_name,r.id as id,r.order_id,r.weight,r.file_name,r.file_domain,r.file_dir,r.file_custom_filename,r.publish_time,r.status FROM " . DB_PREFIX . "content_relation r LEFT JOIN " . DB_PREFIX . "content c ON r.content_id=c.id WHERE r.id =" . $id; $info = $this->db->query_first($sql); if ($info['indexpic']) { $info['indexpic'] = unserialize($info['indexpic']); } if ($info['video']) { $info['video'] = unserialize($info['video']); } if ($info['childs_data']) { $info['childs_data'] = unserialize($info['childs_data']); } if ($info['catalog']) { $info['catalog'] = unserialize($info['catalog']); } if ($need_process) { if ($info) { $column_data = $column->get_site_column_first(' id,name,site_id,fid,childdomain,father_domain,column_dir,relate_dir,col_con_maketype ', $info['column_id']); $site_data = $column_data['site_data']; unset($column_data['site_data']); $info['column_info'] = $column_data; if ($info['use_maincolumn']) { $column_data = $column->get_site_column_first(' id,name,site_id,fid,childdomain,father_domain,column_dir,relate_dir,col_con_maketype ', $info['main_column_id']); $site_data = $column_data['site_data']; $info['content_url'] = $info['outlink'] ? $info['outlink'] : mk_content_url($site_data, $column_data, array('column_id' => $info['main_column_id']) + $info); unset($column_data['site_data']); $info['main_column_info'] = $column_data; } else { $info['content_url'] = $info['outlink'] ? $info['outlink'] : mk_content_url($site_data, $column_data, $info); } } } unset($info['keywords_unicode'], $info['title_unicode'], $info['title_pinyin']); return $info; }
public function get_content_list() { $offset = $this->input['offset'] ? $this->input['offset'] : 0; $count = $this->input['count'] ? $this->input['count'] : 15; $result = $this->get_content_condition(); $condition = $result['condition'] ? $result['condition'] : ''; $sql = 'SELECT distinct content_id FROM ' . DB_PREFIX . 'content_relation r ' . $condition; $sql .= 'LIMIT ' . $offset . ',' . $count; $q = $this->db->query($sql); while ($r = $this->db->fetch_array($q)) { if ($r['content_id']) { $cid[] = $r['content_id']; } } if ($cid) { $cids = implode(',', $cid); $sql = 'SELECT c.*,r.column_id,r.click_num,r.comment_num,r.publish_time,r.file_dir,r.file_custom_filename,r.file_name,r.file_domain FROM ' . DB_PREFIX . 'content_relation r LEFT JOIN ' . DB_PREFIX . 'content c ON c.id = r.content_id WHERE c.id in(' . $cids . ')'; $query = $this->db->query($sql); while ($r = $this->db->fetch_array($query)) { $r['publish_time'] = $r['publish_time'] ? date('Y-m-d H:i:s', $r['publish_time']) : ''; if ($r['column_id']) { $column_ids[] = $r['column_id']; $column[$r['id']][] = $r['column_id']; } $content[$r['id']] = $r; } } if ($column_ids) { $column_datas = $this->column->get_column_site_by_ids(' id,name,fid,childdomain,father_domain,column_dir,relate_dir,col_con_maketype,cssid,is_outlink,linkurl ', implode(',', $column_ids)); } if (!$content) { $this->errorOutput(NOCONTENT); } foreach ($content as $k => $v) { if ($column[$k]) { foreach ($column[$k] as $vv) { $column_datas[$vv]['content_url'] = $v['outlink'] ? $v['outlink'] : (empty($column_datas[$vv]) ? '' : mk_content_url($column_datas[$vv], $column_datas[$vv], $v)); $v['column_info'][$vv] = $column_datas[$vv]; } } $data[] = $v; } if ($this->input['need_count']) { $sql = 'SELECT count( distinct r.content_id) as total FROM ' . DB_PREFIX . 'content c LEFT JOIN ' . DB_PREFIX . 'content_relation r ON c.id = r.content_id ' . $condition; $total = $this->db->query_first($sql); $ret['total'] = $total['total']; $ret['data'] = $data; } else { $ret = $data; } $this->addItem($ret); $this->output(); }