chengkun
2025-04-30 6ab292fb7415be124651e312ec4f21c594568f17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
 
class news_controller extends company
{
    function index_action(){
        $companyM    =    $this->MODEL('company');
        $this->public_action();
        $this->company_satic();
        
        $where['uid']    =    $this->uid;
        
        if(trim($_GET['keyword'])){
            $urlarr['keyword']    =    trim($_GET['keyword']);
            $where['title']        =    array('like',trim($_GET['keyword']));
        }
        
        //分页链接
        $urlarr['page']    =    '{{page}}';
        $pageurl        =    Url('member',$urlarr);
        
        //提取分页
        $pageM            =    $this  -> MODEL('page');
        $pages            =    $pageM -> pageList('company_news',$where,$pageurl,$_GET['page']);
        
        //分页数大于0的情况下 执行列表查询
        if($pages['total'] > 0){
            
            $where['limit']            =    $pages['limit'];
            
            $List                    =    $companyM->getCompanyNewsList($where,array('field'=>'`title`,`id`,`status`,`ctime`,`statusbody`'));
            $this->yunset("rows",$List);
        }
        $this->com_tpl("news");
    }
    
    function add_action(){
        $this->public_action();
        $this->com_tpl("addnews");
    }
    
    function edit_action(){
        $companyM            =    $this->MODEL('company');
        
        $this->public_action();
        $editrow            =    $companyM->getCompanyNewsInfo(array('uid'=>$this->uid,'id'=>(int)$_GET['id']));
        
        $editrow['body']    =    str_replace(array("ti<x>tle","“","”"),array("title"," "," "),$editrow['body']);
        
        $this->yunset("editrow",$editrow);
        $this->com_tpl("addnews");
    }
    
    function save_action(){
        $companyM            =    $this->MODEL('company');
        
        if($_POST['action']=="save"){
            
            $sql['title']    =    $_POST['title'];
            $sql['body']    =    $_POST['body'];
            
            if(trim($sql['title'])=="" || $sql['body']==""){
                 $this->ACT_layer_msg("新闻标题内容不能为空!",2,$_SERVER['HTTP_REFERER']);
            }
            if(!$_POST['id']){
                $sql['uid']        =    $this->uid;
                $sql['did']        =    $this->userdid;
                $sql['ctime']    =    time();
                $sql['usertype']=    $this->usertype;
                $where            =    array();
            }else{
                $where['id']    =    (int)$_POST['id'];
                $where['uid']    =    $this->uid;
                $sql['status']    =    '0';
                $sql['uid']        =    $this->uid;
                $sql['usertype']=    $this->usertype;
                $sql['ctime']    =    time();
                $sql['did']        =    $this->userdid;
            }
            $return        =    $companyM->setCompanyNews($where,$sql);
            
            $this->ACT_layer_msg($return['msg'],$return['errcode'],"index.php?c=news");
        }
    }
    
    function del_action(){
        
        $companyM    =    $this->MODEL('company');
        
        $delid        =    $_POST['delid']?$_POST['delid']:$_GET['id'];
        
        $return        =    $companyM->delCompanyNews($delid , array('uid' => $this->uid,'usertype' => $this->usertype, 'utype' => 'user'));
        
        $this->layer_msg($return['msg'],$return['errcode'],$return['layertype'],$_SERVER['HTTP_REFERER']);
        
    }
    
    function show_action(){
        
        $companyM    =    $this->MODEL('company');
        
        $row        =    $companyM->getCompanyNewsInfo(array('uid'=>$this->uid,'id'=>$_POST['id']),array('field'=>'`statusbody`'));
        
        echo json_encode($row);die;
    }
}
?>