|
wuzhicms的免登陆接口文件上传后。
在火车头怎么设置发布参数呢?
老是发布出错。也没有错误信息提示。
- class index {
-
- public function __construct() {
- $this->db = load_class('db');
- $this->locoyconfig = load_class('config','locoy');
- }
- public function index() {
- index::safe($GLOBALS['safekey']);
- echo $this->safekey;
- }
- //读取栏目id
- public function cat(){
- index::safe($GLOBALS['safekey']);
- $form = load_class('form');
- $categorys = get_cache('category','content');
- foreach($categorys as $cid=>$cate) {
- $categorys[$cid]['cid'] = $cid;
- }
- echo $formcategorys = $form->tree_select($categorys, 0, 'name="catids[]" class="form-control" multiple="multiple" ', '≡ 请选择 ≡');
- }
- //发布文章内容
- public function postnews(){
- if(isset($GLOBALS['submit'])){
- index::safe($GLOBALS['safekey']);
- //数据构造
- $cid = isset($GLOBALS['cid']) ? intval($GLOBALS['cid']) : 0;
- $cate_config = get_cache('category_'.$cid,'content');
- if(!$cate_config) MSG(L('category not exists'));
- //如果设置了modelid,那么则按照设置的modelid。共享模型添加必须数据必须指定该值。
- if(isset($GLOBALS['modelid']) && is_numeric($GLOBALS['modelid'])) {
- $modelid = $GLOBALS['modelid'];
- } else {
- $modelid = $cate_config['modelid'];
- }
-
- $formdata = array(
- "title" => $GLOBALS[title],
- "content" =>$GLOBALS[content],
- "keywords" =>$GLOBALS[keywords],
- "remark" => $GLOBALS[remark],
- "route" => 0 ,
- "status" => 9 ,
- "addtime" => date("Y-m-d H:i:s",time()),
- "sort" => 75,
- "copyfrom" => $GLOBALS['copyfrom'],
- "allowcomment" => 1
- );
- //图片本地化
- if(isset($GLOBALS['thumb']) ) {
- $upload = load_class('attachment',"attachment");
- $formdata['thumb'] = $upload->get_remote_file($GLOBALS['thumb']);
- }
-
-
-
-
- //插入时间,更新时间,如果用户设置了时间。则按照用户设置的时间
- $addtime = empty($formdata['addtime']) ? SYS_TIME : strtotime($formdata['addtime']);
- //添加数据之前,将用户提交的数据按照字段的配置,进行处理
- require get_cache_path('content_add','model');
- $form_add = new form_add($modelid);
- $formdata = $form_add->execute($formdata);
- $formdata['master_data']['addtime'] = $formdata['master_data']['updatetime'] = $addtime;
- //如果是共享模型,那么需要在将字段modelid增加到数据库
- if($formdata['master_table']=='content_share') {
- $formdata['master_data']['modelid'] = $modelid;
- }
- $formdata['master_data']['cid'] = $cid;
- //默认状态 status ,9为通过审核,1-4为审核的工作流,0为回收站
- $formdata['master_data']['status'] = isset($GLOBALS['form']['status']) ? intval($GLOBALS['form']['status']) : 9;
- //非超级管理员,验证该栏目是否设置了审核
- if($cate_config['workflowid'] && $_SESSION['role']!=1 && in_array($formdata['master_data']['status'],array(9,8))) {
- $formdata['master_data']['status'] = 1;
- }
- //如果 route为 0 默认,1,加密,2外链 ,3,自定义 例如:wuzhicms-diy-url-example 用户,不能不需要自己写后缀。程序自动补全。
- $formdata['master_data']['route'] = intval($GLOBALS['form']['route']);
- $formdata['master_data']['publisher'] = get_cookie('username');
- //标题样式
- $title_css = preg_match('/([a-z0-9]+)/i',$GLOBALS['title_css']) ? $GLOBALS['title_css'] : '';
- $formdata['master_data']['css'] = $title_css;
- //echo $formdata['master_table'];exit;
- if(empty($formdata['master_data']['remark']) && isset($formdata['attr_data']['content'])) {
- $formdata['master_data']['remark'] = mb_strcut(strip_tags($formdata['attr_data']['content']),0,255);
- }
- $id = $this->db->insert($formdata['master_table'],$formdata['master_data']);
- if($cate_config['type']==1) {
- $urls['url'] = $cate_config['url'];
- } elseif($formdata['master_data']['route']>1) {//外部链接
- $urls['url'] = remove_xss($GLOBALS['url']);
- } else {
- //生成url
- $urlclass = load_class('url','content',$cate_config);
- $urls = $urlclass->showurl(array('id'=>$id,'cid'=>$cid,'addtime'=>$addtime,'page'=>1,'route'=>$formdata['master_data']['route']));
- }
- $this->db->update($formdata['master_table'],array('url'=>$urls['url']),array('id'=>$id));
- if(!empty($formdata['attr_table'])) {
- $formdata['attr_data']['id'] = $id;
- // print_r($formdata['attr_data']);exit;
- $this->db->insert($formdata['attr_table'],$formdata['attr_data']);
- }
- $formdata['master_data']['url'] = $urls['url'];
- //执行更新
- require get_cache_path('content_update','model');
- $form_update = new form_update($modelid);
- $data = $form_update->execute($formdata);
- //判断是否存在,防止意外发生
- if(!$this->db->get_one('content_rank',array('cid'=>$cid,'id'=>$id))) {
- //统计表加默认数据
- $this->db->insert('content_rank',array('cid'=>$cid,'id'=>$id,'updatetime'=>SYS_TIME));
- }
- //生成静态
- if($cate_config['showhtml'] && $formdata['master_data']['status']==9) {
- $data = $this->db->get_one($formdata['master_table'],array('id'=>$id));
- if(!empty($formdata['attr_table'])) {
- $attrdata = $this->db->get_one($formdata['attr_table'],array('id'=>$id));
- $data = array_merge($data,$attrdata);
- }
- //上一页
- $data['previous_page'] = $this->db->get_one($formdata['master_table'],"`cid` = '$cid' AND `id`<'$id' AND `status`=9",'*',0,'id DESC');
- //下一页
- $data['next_page'] = '';
- $this->html = load_class('html','content');
- $this->html->set_category($cate_config);
- $this->html->set_categorys();
- $this->html->load_formatcache();
- $this->html->show($data,1,1,$urls['root']);
- $loadhtml = true;
- } else {
- $loadhtml = false;
- }
- //生成相关栏目列表
- if($cate_config['listhtml']) {
- if($loadhtml==false) {
- $this->html = load_class('html','content');
- $this->html->set_category($cate_config);
- $this->html->set_categorys();
- $loadhtml = true;
- }
- for($i=1;$i<6;$i++) {
- $cateurls = $urlclass->listurl(array('cid'=>$cid,'page'=>$i));
- $this->html->listing($cateurls['root'],$i);
- if($GLOBALS['result_lists']==0) {
- break;
- }
- }
- //生成上级栏目
- if($cate_config['pid']) {
- $cate_config2 = get_cache('category_'.$cate_config['pid'],'content');
- $urlclass->set_category($cate_config2);
- $cateurls = $urlclass->listurl(array('cid'=>$cate_config['pid'],'page'=>1));
- $this->html->set_category($cate_config2);
- $this->html->listing($cateurls['root'],1);
- }
- }
- //生成首页
- if($loadhtml) {
- $this->html->index();
- } else {
- $this->html = load_class('html','content');
- $this->html->set_categorys();
- $this->html->index();
- }
- //添加到最新列表中
- $lastlist = get_cache('lastlist','content');
- $newcontent = array(0=>array('cid'=>$cid,'title'=>$formdata['master_data']['title'],'url'=>$urls['url'],'addtime'=>SYS_TIME));
- if(is_array($lastlist)) {
- $lastlist = array_merge($newcontent,$lastlist);
- if(count($lastlist)>100) array_pop($lastlist);
- } else {
- $lastlist = $newcontent;
- }
- set_cache('lastlist',$lastlist,'content');
- //编辑操作日志
- //$this->editor_logs('add',$formdata['master_data']['title'],$urls['url'], "?m=content&f=content&v=edit&id=$id&cid=$cid");
-
-
- //MSG($formdata['master_data']['title']."<br>发布完成!正在跳转,请稍后!",$url,1500);
- echo '发布成功!';
-
- }
-
- }
复制代码 postnews() 和 cat() ,一个是读取栏目,一个是发布内容。cat可以调用成功,但是postnews(),总没搞对,找了很多资料没有结果,有人能帮忙一下吗?感激不尽!
|
|