select_all('gongzhao', $whereData, $select); if (!empty($List)) { if ($data['utype'] == 'wxapp') { foreach ($List as $key => $va) { $List[$key]['title'] = mb_substr($va['title'], 0, 40, 'utf-8'); $List[$key]['datetime_n'] = date('Y-m-d', $va['startime']); $List[$key]['pic_n'] = checkpic($va['pic'],$this->config['sy_gongzhaologo']); } } $Listgongzhao ['list'] = $List; } return $Listgongzhao; } /** *获取公告数量 * */ function getNum() { return $this->select_num('gongzhao'); } /** * @desc 获取公告详情 */ function getInfo($where = array(), $data = array()) { $select = $data['field'] ? $data['field'] : '*'; $Info = $this->select_once('gongzhao', $where, $select); if (!empty($Info)) { if($Info['pic']){ $Info['pic_n'] = checkpic($Info['pic']); } $Info['content'] = str_replace(array(" ", "&"), array(" ", "&"), $Info['content']); preg_match_all('/config['sy_ossurl'] . $v, $Info['content']); } } } $Info['startime_n'] = date('Y-m-d', $Info['startime']); } return $Info; } /** * @desc 添加数据 */ public function addInfo($data = array()) { if (!empty($data['content'])) { $content = str_replace(array('"', '\''), array('', ''), $data['content']); preg_match_all('/]+src=(.*?)\s[^>]+>/im', $content, $match); if (!empty($match[1])) { $mbstr = substr(strrchr($match[1][0], "\\"), 1); $str = str_replace($mbstr, '', $match[1][0]); $str = str_replace("\\", '', $str); } $contentRep = array('&', "background-color:#ffffff", "background-color:#fff", "white-space:nowrap;"); $contentStr = str_replace($contentRep, array('&', '', '', ''), $data['content']); } $time = time(); $AddData = array( 'did' => $data['did'] == '' ? 0 : $data['did'], 'title' => $data['title'], 'startime' => !empty($data['startime']) ? strtotime($data['startime']) : $time, //开始时间 'endtime' => strtotime($data['endtime']), 'keyword' => $data['keyword'], 'description' => $data['description'], 'pic' => !empty($data['pic'])?$data['pic']:'', 'content' => $contentStr, 'datetime' => $time ); $nid = $this->insert_into('gongzhao', $AddData); return $nid; } /** * @desc 更新数据 */ public function upInfo($whereData, $data = array()) { if (!empty($whereData)) { if (!empty($data['content'])) { $content = str_replace(array('"', '\''), array('', ''), $data['content']); preg_match_all('/]+src=(.*?)\s[^>]+>/im', $content, $match); if (!empty($match[1])) { $mbstr = substr(strrchr($match[1][0], "\\"), 1); $str = str_replace($mbstr, '', $match[1][0]); $str = str_replace("\\", '', $str); } $contentRep = array('&', "background-color:#ffffff", "background-color:#fff", "white-space:nowrap;"); $contentStr = str_replace($contentRep, array('&', '', '', ''), $data['content']); $PostData = array( 'did' => $data['did'] == '' ? 0 : $data['did'], 'title' => $data['title'], 'startime' => strtotime($data['startime']), //开始时间 'endtime' => strtotime($data['endtime']), 'keyword' => $data['keyword'], 'description' => $data['description'], 'content' => $contentStr ); if(!empty($data['pic'])){ $PostData['pic'] = $data['pic']; } $nid = $this->update_once('gongzhao', $PostData, array('id' => $whereData['id'])); }elseif (isset($data['rec'])){ $nid = $this->update_once('gongzhao', $data, array('id' => $whereData['id'])); } return $nid; } } /** * @desc 删除数据 */ public function delgongzhao($delId) { if (empty($delId)) { return array( 'errcode' => 8, 'msg' => '请选择要删除的数据!', ); } else { if (is_array($delId)) { $delId = pylode(',', $delId); $return['layertype'] = 1; } else { $return['layertype'] = 0; } $nid = $this->delete_all('gongzhao', array('id' => array('in', $delId)), ''); if ($nid) { $return['msg'] = '公告'; $return['errcode'] = $nid ? '9' : '8'; $return['msg'] = $nid ? $return['msg'] . '删除成功!' : $return['msg'] . '删除失败!'; } } return $return; } } ?>