2011-09-23 03:49:10 +00:00
|
|
|
|
<?php
|
|
|
|
|
class Admin_NewsController extends Zend_Controller_Action
|
|
|
|
|
{
|
|
|
|
|
function preDispatch()
|
|
|
|
|
{
|
|
|
|
|
$this->db=Zend_Registry::get('db');
|
|
|
|
|
$this->view->config = Zend_Registry::get('config');
|
|
|
|
|
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
|
|
|
|
$this->view->messages = $this->messenger->getMessages();
|
2013-05-17 00:41:46 +00:00
|
|
|
|
$this->_helper->layout->setLayout('administry');
|
2013-05-21 09:37:33 +00:00
|
|
|
|
$this->view->theme = new Theme();
|
2011-09-23 03:49:10 +00:00
|
|
|
|
}
|
|
|
|
|
function postDispatch()
|
|
|
|
|
{
|
|
|
|
|
$this->view->messages = $this->messenger->getMessages();
|
|
|
|
|
}
|
|
|
|
|
function indexAction()
|
|
|
|
|
{
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$News = new Archive($this->db);
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$sql = "SELECT count(id) as c FROM ".$News->tbl_archives;
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
$this->view->totle = $row;
|
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$sql = "SELECT count(id) as c FROM ".$News->tbl_categorys;
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
$this->view->typec = $row;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2011-10-21 08:12:04 +00:00
|
|
|
|
}//indexAction 首页
|
|
|
|
|
|
|
|
|
|
function newslistAction(){
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$News = new Archive($this->db);
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$type = $this->_request->getParam('type');
|
|
|
|
|
|
|
|
|
|
if(!empty($type))
|
|
|
|
|
{
|
2012-11-27 03:57:27 +00:00
|
|
|
|
$sql = "select n.*,c.id as typeid,c.title as catlog,c.code from ".$News->tbl_archives." n
|
|
|
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
|
|
|
left join ".$News->tbl_categorys." c on c.id = ct.cid
|
2012-04-09 07:50:57 +00:00
|
|
|
|
LEFT JOIN users u ON n.userid=u.id
|
2012-11-30 09:03:41 +00:00
|
|
|
|
WHERE c.id='$type' AND n.title IS NOT NULL order by n.ts_created desc";
|
2012-03-27 07:02:36 +00:00
|
|
|
|
}else
|
|
|
|
|
{
|
2012-11-30 09:03:41 +00:00
|
|
|
|
$sql = "select
|
|
|
|
|
n.id,n.title,n.userid,n.ts_published,n.is_pub
|
|
|
|
|
from ".$News->tbl_archives." n
|
2012-11-23 09:54:37 +00:00
|
|
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
|
|
|
left join ".$News->tbl_categorys." c on c.id = ct.cid
|
2012-04-09 07:50:57 +00:00
|
|
|
|
LEFT JOIN users u ON n.userid=u.id
|
2012-11-30 09:03:41 +00:00
|
|
|
|
WHERE n.title IS NOT NULL
|
|
|
|
|
GROUP BY n.id
|
|
|
|
|
ORDER BY n.ts_created desc
|
|
|
|
|
";
|
2012-03-27 07:02:36 +00:00
|
|
|
|
}
|
2011-10-21 08:12:04 +00:00
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$rows = $rs->fetchAll();
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2012-12-03 10:08:25 +00:00
|
|
|
|
foreach($rows as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if(empty($v['typeid']))
|
|
|
|
|
{
|
|
|
|
|
$ev = $News->getArchiveUrlByCid($v['id']);
|
|
|
|
|
}else{
|
|
|
|
|
$ev = $News->getArchiveUrlByCid($v['id'],$v['typeid']);
|
|
|
|
|
}
|
|
|
|
|
$rows[$k]['type_title'] = $ev['type_title'];
|
|
|
|
|
$rows[$k]['type_url'] = $ev['type_url'];
|
|
|
|
|
$rows[$k]['url'] = $ev['archive_url'];
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-21 08:12:04 +00:00
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
|
|
|
$paginator->setCurrentPageNumber($this->_getParam('page'));
|
|
|
|
|
$paginator->setItemCountPerPage($this->view->config->page->max);
|
|
|
|
|
$paginator->setView($this->view);
|
|
|
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
|
|
|
$this->view->paginator=$paginator;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
|
$this->view->types= $category->GetFullCategory();
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$this->view->type = $type;
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2011-10-21 08:12:04 +00:00
|
|
|
|
}//newslistAction 新闻列表
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
|
|
|
|
function catlogAction()
|
|
|
|
|
{
|
|
|
|
|
$add = $this->_request->getParam('add');
|
|
|
|
|
$submit = $this->_request->getParam('submit');
|
|
|
|
|
|
|
|
|
|
$delete = $this->_request->getParam('delete');
|
|
|
|
|
|
|
|
|
|
$edit = $this->_request->getParam('edit');
|
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$News = new Archive($this->db);
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2011-09-23 03:49:10 +00:00
|
|
|
|
if($add)
|
|
|
|
|
{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->view->ptype = $News->ptype;
|
|
|
|
|
|
2012-11-06 03:19:24 +00:00
|
|
|
|
$this->_helper->viewRenderer('category-add');
|
2012-11-28 09:27:53 +00:00
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
|
$catlogs = $category->GetFullCategory();
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->categories=$catlogs;
|
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-08-23 08:01:19 +00:00
|
|
|
|
if(empty($submit)){
|
2012-11-06 03:19:24 +00:00
|
|
|
|
|
|
|
|
|
//$this->_helper->viewRenderer('category-add');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-08-23 08:01:19 +00:00
|
|
|
|
}else{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-11-06 03:19:24 +00:00
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
|
|
$data['title'] = $this->_request->getParam('ctitle');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data['code'] = $this->_request->getParam('code');
|
2012-11-06 03:19:24 +00:00
|
|
|
|
$data['fid'] = $this->_request->getParam('fid');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data['ptype'] = $this->_request->getParam('ptype');
|
2014-05-08 03:05:38 +00:00
|
|
|
|
$data['title_en'] = $this->_request->getParam('title_en');
|
2012-11-28 09:27:53 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data['is_pub'] = 1;
|
2012-11-06 03:19:24 +00:00
|
|
|
|
|
|
|
|
|
$this->view->info = $data;
|
|
|
|
|
|
|
|
|
|
if(empty($data['title']))
|
|
|
|
|
{
|
|
|
|
|
$this->view->error = "请输入标题";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if(empty($data['code']))
|
2012-11-06 03:19:24 +00:00
|
|
|
|
{
|
|
|
|
|
$this->view->error = "请输入栏目连接,如http://westdc.westgis.ac.cn/news/notice,则只需要输入notice";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if(!preg_match("/^[a-z]+$/",$data['code']))
|
2012-11-06 03:19:24 +00:00
|
|
|
|
{
|
|
|
|
|
$this->view->error = "url格式不正确,仅允许26个小写字母";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$LftRgt = $category->Insert($data['fid']);
|
|
|
|
|
$data['tid'] = $data['fid'];
|
|
|
|
|
$data['lft'] = $LftRgt['left'];
|
|
|
|
|
$data['rgt'] = $LftRgt['right'];
|
|
|
|
|
unset($data['fid']);
|
|
|
|
|
|
|
|
|
|
if($this->db->insert($category->CategoryTable,$data))
|
2011-09-23 03:49:10 +00:00
|
|
|
|
{
|
2012-11-06 03:19:24 +00:00
|
|
|
|
$this->view->msg = '提示信息:栏目添加成功!';
|
|
|
|
|
$this->view->jump_url = '/admin/news/catlog';
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
$this->view->error = "添加失败,请重试";
|
|
|
|
|
return true;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}//栏目添加
|
|
|
|
|
if($delete>0)
|
|
|
|
|
{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$sql = "delete from ".$News->tbl_categorys." where id='$delete'";
|
2011-09-23 03:49:10 +00:00
|
|
|
|
if($this->db->exec($sql)>0)
|
|
|
|
|
{
|
|
|
|
|
$this->messenger->addMessage('提示信息:栏目删除成功!');
|
|
|
|
|
$this->_redirect('/admin/news/catlog');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}//栏目删除
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
2011-09-23 03:49:10 +00:00
|
|
|
|
if($edit>0)
|
|
|
|
|
{
|
2012-08-23 08:01:19 +00:00
|
|
|
|
$submit = $this->_getParam('submit');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->_helper->viewRenderer('category-edit');
|
|
|
|
|
|
|
|
|
|
$this->view->ptype = $News->ptype;
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$category = new ArchiveCategory($this->db);
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->info = $category->GetOne($edit);
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$this->view->categories = $category->GetFullCategory();
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
|
|
|
|
if(!empty($submit))
|
2011-09-23 03:49:10 +00:00
|
|
|
|
{
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data = array();
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data['title'] = $this->_request->getParam('ctitle');
|
|
|
|
|
$data['code'] = $this->_request->getParam('code');
|
2013-06-06 02:30:09 +00:00
|
|
|
|
$data['fid'] = $this->_request->getParam('fid');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$data['ptype'] = $this->_request->getParam('ptype');
|
|
|
|
|
$data['is_pub'] = $this->_request->getParam('is_pub');
|
2014-05-08 03:05:38 +00:00
|
|
|
|
$data['title_en'] = $this->_request->getParam('title_en');
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->view->info = $data;
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if(empty($data['title']))
|
2012-08-31 07:38:09 +00:00
|
|
|
|
{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->view->error = "请输入标题";
|
|
|
|
|
return true;
|
2012-08-31 07:38:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if(empty($data['code']))
|
2012-08-23 08:01:19 +00:00
|
|
|
|
{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->view->error = "请输入栏目连接,如http://westdc.westgis.ac.cn/news/notice,则只需要输入notice";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!preg_match("/^[a-z]+$/",$data['code']))
|
|
|
|
|
{
|
|
|
|
|
$this->view->error = "url格式不正确,仅允许26个小写字母";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-06 02:30:09 +00:00
|
|
|
|
$LftRgt = $category->Insert($data['fid']);
|
|
|
|
|
$data['tid'] = $data['fid'];
|
|
|
|
|
$data['lft'] = $LftRgt['left'];
|
|
|
|
|
$data['rgt'] = $LftRgt['right'];
|
|
|
|
|
unset($data['fid']);
|
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if($this->db->update($News->tbl_categorys,$data,"id=$edit"))
|
|
|
|
|
{
|
|
|
|
|
$this->view->msg = '提示信息:栏目添加成功!';
|
|
|
|
|
$this->view->jump_url = '/admin/news/catlog';
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
$this->view->error = "添加失败,请重试";
|
|
|
|
|
return true;
|
2012-08-23 08:01:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-23 03:49:10 +00:00
|
|
|
|
}
|
2012-08-23 08:01:19 +00:00
|
|
|
|
|
|
|
|
|
}//栏目编辑
|
|
|
|
|
|
2011-09-23 03:49:10 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-30 15:12:27 +00:00
|
|
|
|
|
|
|
|
|
$category = new ArchiveCategory($this->db);
|
2012-12-04 04:34:47 +00:00
|
|
|
|
$News = new Archive($this->db);
|
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$catlogs = $category->GetFullCategory();
|
2012-12-04 04:34:47 +00:00
|
|
|
|
$ptype = $News->ptype;
|
|
|
|
|
|
|
|
|
|
foreach($catlogs as $k=>$v)
|
|
|
|
|
{
|
2012-12-05 07:31:51 +00:00
|
|
|
|
$url_parts = array(
|
|
|
|
|
"ptype"=>$v['ptype'],
|
|
|
|
|
"type_code"=>$v['code']
|
|
|
|
|
);
|
|
|
|
|
$catlogs[$k]['url'] = $News->makeCategoryUrl($url_parts);
|
|
|
|
|
|
2012-12-04 04:34:47 +00:00
|
|
|
|
foreach($ptype as $kk=>$vv)
|
|
|
|
|
{
|
|
|
|
|
if($catlogs[$k]['ptype'] == $vv)
|
|
|
|
|
{
|
|
|
|
|
$catlogs[$k]['ptype'] = $kk;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-23 03:49:10 +00:00
|
|
|
|
$this->view->catlogs=$catlogs;
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
}//栏目列表
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}//栏目管理
|
|
|
|
|
|
2012-08-23 08:01:19 +00:00
|
|
|
|
function getSubCategory($fid)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT * FROM news_category WHERE fid=?";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($fid));
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
if(empty($rows) || count($rows)<1)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}else{
|
|
|
|
|
return $rows;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getCategory($id)
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT * FROM news_category WHERE id=?";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute(array($id));
|
|
|
|
|
$rows = $sth->fetch();
|
|
|
|
|
return $rows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getAllcategory($id=0)
|
2012-11-23 09:54:37 +00:00
|
|
|
|
{
|
2012-08-23 08:01:19 +00:00
|
|
|
|
$_addon = '';
|
|
|
|
|
if(!empty($id))
|
|
|
|
|
{
|
|
|
|
|
$_addon = "WHERE id not in ($id)";
|
|
|
|
|
}
|
2012-11-27 03:57:27 +00:00
|
|
|
|
$sql = "SELECT * FROM ar_category $_addon ORDER BY id DESC";
|
2012-08-23 08:01:19 +00:00
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute();
|
|
|
|
|
return $sth->fetchAll();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
//新闻添加页面
|
2011-09-23 03:49:10 +00:00
|
|
|
|
function newsaddAction()
|
2012-11-30 15:12:27 +00:00
|
|
|
|
{
|
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
|
$catlogs = $category->GetFullCategory();
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->types=$catlogs;
|
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
2011-09-23 03:49:10 +00:00
|
|
|
|
}//newsadd 新闻添加
|
2012-11-28 09:27:53 +00:00
|
|
|
|
|
|
|
|
|
//文档编辑
|
|
|
|
|
function newseditAction()
|
|
|
|
|
{
|
2012-11-30 15:12:27 +00:00
|
|
|
|
|
|
|
|
|
$News = new Archive($this->db);
|
2012-11-28 09:27:53 +00:00
|
|
|
|
|
|
|
|
|
$id = $this->_request->getParam('id');
|
2012-11-30 09:03:41 +00:00
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM ar_catalog WHERE aid=$id";
|
|
|
|
|
$sth = $this->db->query($sql);
|
|
|
|
|
$rows = $sth->fetchAll();
|
|
|
|
|
|
|
|
|
|
$types = array();
|
|
|
|
|
foreach($rows as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
$types[$v['id']] = $v['cid'];
|
|
|
|
|
}
|
|
|
|
|
$this->view->typeid = $types;
|
2012-11-28 09:27:53 +00:00
|
|
|
|
|
|
|
|
|
$sql = "select arc.*,ct.cid as typeid from ".$News->tbl_archives." arc
|
|
|
|
|
LEFT JOIN ".$News->tbl_catalog." ct ON arc.id=ct.aid
|
|
|
|
|
where arc.id=$id";
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
|
|
|
|
|
$this->view->ev = $row;
|
|
|
|
|
|
|
|
|
|
if(!empty($row['image']))
|
|
|
|
|
{
|
|
|
|
|
$sql = "SELECT * FROM attachments WHERE filename='".str_replace("/upload/",'',$row['image'])."'";
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
$this->view->att = $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->view->keywords = join(",",$News->GetTags($id));
|
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
|
$catlogs = $category->GetFullCategory();
|
2012-11-28 09:27:53 +00:00
|
|
|
|
$this->view->types=$catlogs;
|
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
|
|
|
|
}
|
2012-12-03 04:00:47 +00:00
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
|
//文档编辑或者添加
|
2011-10-09 10:15:50 +00:00
|
|
|
|
function archivesaddAction()
|
|
|
|
|
{
|
|
|
|
|
$this->_helper->layout->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
$News = new Archive($this->db);
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-04-09 07:50:57 +00:00
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$uid = $user->id;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-09 10:15:50 +00:00
|
|
|
|
$datavar = array(
|
2012-11-23 09:54:37 +00:00
|
|
|
|
'title',
|
|
|
|
|
'source',
|
|
|
|
|
'image',
|
|
|
|
|
'body',
|
|
|
|
|
'typeid',
|
|
|
|
|
'pub',
|
|
|
|
|
'pubtimer',
|
|
|
|
|
'pubtime',
|
|
|
|
|
'description',
|
2014-05-08 08:01:44 +00:00
|
|
|
|
'keyword',
|
|
|
|
|
'language'
|
2011-10-09 10:15:50 +00:00
|
|
|
|
);
|
|
|
|
|
foreach($_POST as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
if(in_array($k,$datavar))
|
|
|
|
|
{
|
|
|
|
|
$$k=$v;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$msg=array();
|
|
|
|
|
if(empty($title)) $msg[]="标题不能为空";
|
2012-11-23 09:54:37 +00:00
|
|
|
|
if(mb_strlen($title)>200) $msg[]="标题长度不能超过200个字符";
|
|
|
|
|
if(mb_strlen($keyword)>200) $msg[] = "关键词长度不能超过200个字符,现在输入了".strlen($keyword)."个字符";
|
2012-12-13 08:36:14 +00:00
|
|
|
|
if(mb_strlen($description)>1000) $msg[] = "内容描述不能超过1000个字符,现在输入了".strlen($description)."个字符";
|
2011-10-09 10:15:50 +00:00
|
|
|
|
if(empty($body)) $msg[]="请填写内容";
|
2012-11-30 09:03:41 +00:00
|
|
|
|
if(empty($typeid)) $msg[]="请选择栏目";
|
|
|
|
|
if(!is_array($typeid) || count($typeid)<1)
|
|
|
|
|
{
|
|
|
|
|
$msg[]="请选择栏目";
|
|
|
|
|
}
|
2011-10-09 10:15:50 +00:00
|
|
|
|
|
|
|
|
|
if(count($msg)>0)
|
|
|
|
|
{
|
|
|
|
|
echo '<div class="box box-error">发布失败:</div>
|
|
|
|
|
<div class="box box-error-msg">
|
|
|
|
|
<ol>';
|
|
|
|
|
foreach ($msg as $v)
|
|
|
|
|
{
|
|
|
|
|
echo '<li>'.$v.'</li>';
|
|
|
|
|
}
|
|
|
|
|
echo'</ol>
|
|
|
|
|
</div>
|
|
|
|
|
';
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!empty($pubtimer))
|
|
|
|
|
{
|
|
|
|
|
$pubtime = date("Y-m-d H:i:s",strtotime($pubtime));
|
2011-10-09 10:15:50 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$pubtime = date("Y-m-d H:i:s",time());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$data=array(
|
2012-12-03 04:00:47 +00:00
|
|
|
|
'title' => $title,
|
2012-11-23 09:54:37 +00:00
|
|
|
|
'userid' => $uid,
|
2012-12-03 04:00:47 +00:00
|
|
|
|
'description'=> $description,
|
|
|
|
|
'image' => $image,
|
|
|
|
|
'source' => $source,
|
|
|
|
|
'ts_published' => $pubtime,
|
2012-11-23 09:54:37 +00:00
|
|
|
|
'is_pub' => $pub,
|
2014-05-08 08:01:44 +00:00
|
|
|
|
'body' => $body,
|
|
|
|
|
'language' => $language
|
2012-11-23 09:54:37 +00:00
|
|
|
|
);
|
|
|
|
|
|
2012-11-27 03:57:27 +00:00
|
|
|
|
$update = $this->_getParam('update');
|
2012-11-23 09:54:37 +00:00
|
|
|
|
|
2012-11-28 09:27:53 +00:00
|
|
|
|
if(is_numeric($update) && !empty($update))
|
2012-11-27 03:57:27 +00:00
|
|
|
|
{
|
2012-12-03 04:00:47 +00:00
|
|
|
|
$updated = $News->updateArchive($update,$data,$typeid,$keyword);
|
|
|
|
|
if($updated>0)
|
2011-10-10 06:30:51 +00:00
|
|
|
|
{
|
2012-11-27 03:57:27 +00:00
|
|
|
|
echo '<div class="box box-success">修改成功!</div><script>
|
2012-11-23 09:54:37 +00:00
|
|
|
|
setTimeout("self.location=\'/admin/news/newslist\'",500);
|
|
|
|
|
</script>';
|
2012-11-27 03:57:27 +00:00
|
|
|
|
return true;
|
2012-11-23 09:54:37 +00:00
|
|
|
|
}else{
|
2012-11-27 03:57:27 +00:00
|
|
|
|
echo '<div class="box box-success">修改失败!请重试</div>';
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
try{
|
2012-12-03 04:00:47 +00:00
|
|
|
|
$newAid = $News->addArchive($data,$typeid,$keyword);
|
|
|
|
|
if($newAid>0){
|
|
|
|
|
echo '<div class="box box-success">发布成功!</div><script>
|
|
|
|
|
setTimeout("self.location=\'/admin/news/newslist\'",500);
|
|
|
|
|
</script>';
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
echo '<div class="box box-error">发布失败!请重试</div>';
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2012-11-27 03:57:27 +00:00
|
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
echo '<div class="box box-error">文章发布失败:</div>
|
|
|
|
|
<div class="box box-error-msg">
|
|
|
|
|
<ol>
|
|
|
|
|
<li>'.$e->getMessage().'</li>
|
|
|
|
|
</ol>
|
|
|
|
|
</div>';
|
|
|
|
|
return true;
|
2011-10-09 10:15:50 +00:00
|
|
|
|
}
|
2012-03-27 07:02:36 +00:00
|
|
|
|
}
|
|
|
|
|
}// 文章发布
|
|
|
|
|
|
|
|
|
|
function deleteAction(){
|
2011-10-09 10:15:50 +00:00
|
|
|
|
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$id = $this->_request->getParam('id');
|
|
|
|
|
|
2012-11-30 15:12:27 +00:00
|
|
|
|
|
|
|
|
|
$News = new Archive($this->db);
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$News->DeleteArchives($id);
|
2012-03-27 07:02:36 +00:00
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
$this->messenger->addMessage('提示信息:档案删除成功!');
|
2012-03-27 07:02:36 +00:00
|
|
|
|
$this->_redirect('/admin/news/newslist');
|
|
|
|
|
|
|
|
|
|
}//文章删除
|
2012-08-31 07:38:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function uploadAction(){
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
|
$userid = $user->id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
include_once('files.php');
|
|
|
|
|
$files=new files();
|
|
|
|
|
$msg = $files -> upload('../htdocs/upload/',$_FILES['Filedata'],'image');
|
|
|
|
|
|
|
|
|
|
if(empty($msg['error']))
|
|
|
|
|
{
|
|
|
|
|
$msg['error']="";
|
|
|
|
|
$filename = $msg['db_path'];
|
|
|
|
|
$filesize = $msg['file_size'];
|
|
|
|
|
$filedesc = $this->_request->getParam('filedesc');
|
|
|
|
|
$filetype = 'thumb';
|
|
|
|
|
$realname = $msg['realname'];
|
|
|
|
|
$fileurl = $msg['file_url'];
|
|
|
|
|
|
|
|
|
|
$sql = "insert into attachments (filename,filetype,filedesc,userid,filesize,realname) values ('$filename','$filetype','$filedesc','$userid','$filesize','$realname') RETURNING id";
|
|
|
|
|
$sth = $this->db->prepare($sql);
|
|
|
|
|
$sth->execute();
|
|
|
|
|
$att = $sth->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
$msg['attid'] = $attid = $att['id'];
|
|
|
|
|
|
|
|
|
|
$imgct = files::getImageType('../htdocs/upload/'.$filename);
|
|
|
|
|
|
|
|
|
|
if(!isset($imgct['error'])) $preview = '<img src="/upload/'.$filename.'" style="display:block;max-height:300px;" />';
|
|
|
|
|
else $preview = "";
|
|
|
|
|
|
|
|
|
|
$msg['html'] = $preview.$realname.'[已完成]<input type="hidden" name="image" value="/upload/'.$filename.'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$attid.'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
|
|
|
|
|
$msg['preview'] = "/images/".$attid;
|
|
|
|
|
echo Zend_Json::encode($msg);
|
|
|
|
|
exit();
|
|
|
|
|
}else{
|
|
|
|
|
$msg['error'] = '附件上传失败:'.$msg['error'];
|
|
|
|
|
@unlink($filename);
|
|
|
|
|
echo Zend_Json::encode($msg);
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(Exception $e){
|
|
|
|
|
$msg['error'] = "错误:".$e->getMessage();
|
|
|
|
|
echo Zend_Json::encode($msg);
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getattsAction(){
|
|
|
|
|
|
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$id = $this->_request->getParam('id');
|
|
|
|
|
|
|
|
|
|
if($id!='')
|
|
|
|
|
{
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
|
{
|
|
|
|
|
$sql = "select att.realname,att.id,att.filename from attachments att
|
|
|
|
|
left join archives_att ratt on att.id=ratt.attid
|
|
|
|
|
where ratt.arcid=$id";
|
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
|
$atts = $rs->fetchAll();
|
|
|
|
|
|
|
|
|
|
include_once('files/files.php');
|
|
|
|
|
|
|
|
|
|
foreach($atts as $k=>$v)
|
|
|
|
|
{
|
|
|
|
|
$imgct = files::getImageType('../htdocs/upload/'.$v['filename']);
|
|
|
|
|
|
|
|
|
|
if(!isset($imgct['error'])) $preview = '<img src="/images/'.$v['id'].'" style="display:block;" />';
|
|
|
|
|
else $preview = "";
|
|
|
|
|
|
|
|
|
|
$atts[$k]['html']= $preview.$v['realname'].'[已完成]<input type="hidden" name="atts[]" value="'.$v['id'].'" /><div class="cancel"><a href="javascript:;" id="deletebtn_'.$v['id'].'"><img border="0" src="/static/js/uploadify/cancel.png" /></a></div>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo Zend_Json::encode($atts);
|
|
|
|
|
exit();
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
exit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function delattAction(){
|
|
|
|
|
$this->_helper->layout()->disableLayout();
|
|
|
|
|
$this->_helper->viewRenderer->setNoRender();
|
|
|
|
|
|
|
|
|
|
$id = $this->_request->getParam('id');
|
|
|
|
|
$aid = $this->_getParam('aid');
|
|
|
|
|
$basepath = '../htdocs/upload/';
|
|
|
|
|
$info = $this->getFileinfo($id);
|
|
|
|
|
$filepath = $basepath.$info['filename'];
|
|
|
|
|
try{
|
|
|
|
|
if(empty($aid))
|
|
|
|
|
{
|
|
|
|
|
$sql = "DELETE FROM attachments WHERE id=$id";
|
|
|
|
|
if($this->db->exec($sql)>0)
|
|
|
|
|
{
|
|
|
|
|
@unlink($filepath);
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
$sql = "delete from archives_att where attid='$id' and arcid='$aid'";
|
|
|
|
|
if($this->db->exec($sql)>0)
|
|
|
|
|
{
|
|
|
|
|
$sql = "DELETE FROM attachments WHERE id=$id";
|
|
|
|
|
if($this->db->exec($sql)>0){@unlink($filepath);}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch(Exception $e){}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getFileinfo($id){
|
|
|
|
|
$sql = "select * from attachments where id='$id'";
|
|
|
|
|
$re= $this->db->query($sql);
|
|
|
|
|
$row= $re->fetch();
|
|
|
|
|
return $row;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function jsonexit($data){
|
|
|
|
|
$this->getResponse()->setHeader('Content-Type', 'application/json')->appendBody(Zend_Json::encode($data));
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-23 09:54:37 +00:00
|
|
|
|
function replacehtml($html)
|
|
|
|
|
{
|
|
|
|
|
$newString = htmlentities($html, ENT_QUOTES, "UTF-8");
|
|
|
|
|
return $newString;
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-21 09:37:33 +00:00
|
|
|
|
public function moveAction()
|
|
|
|
|
{
|
|
|
|
|
$up = (int)$this->_getParam('up');
|
|
|
|
|
$down = (int)$this->_getParam('down');
|
|
|
|
|
|
|
|
|
|
include_once('helper/view.php');
|
|
|
|
|
include_once('ArchiveCategory.php');
|
|
|
|
|
|
|
|
|
|
if(empty($up) && empty($down))
|
|
|
|
|
{
|
|
|
|
|
view::Post("参数错误",$this,-1);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
|
|
|
|
|
|
if(!empty($up))
|
|
|
|
|
{
|
|
|
|
|
$s = $category->move('up',$up);
|
|
|
|
|
}
|
|
|
|
|
if(!empty($down))
|
|
|
|
|
{
|
|
|
|
|
$s = $category->move('down',$down);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(is_array($s))
|
|
|
|
|
{
|
|
|
|
|
$this->view->moved = $s;
|
|
|
|
|
}else{
|
|
|
|
|
view::Post($this,$s,-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2011-09-23 03:49:10 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|