225 lines
5.9 KiB
PHP
225 lines
5.9 KiB
PHP
<?php
|
|
class ArchivesController extends Zend_Controller_Action
|
|
{
|
|
|
|
private $limit=10;
|
|
|
|
function preDispatch()
|
|
{
|
|
$this->view->config = Zend_Registry::get('config');
|
|
$this->db=Zend_Registry::get('db');
|
|
$this->view->theme = new Theme();
|
|
}
|
|
|
|
function testAction()
|
|
{
|
|
$this->_helper->viewRenderer('archive-view-player');
|
|
}
|
|
|
|
function indexAction()
|
|
{
|
|
$News = new Archive($this->db);
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
$types = $category->GetCategory();
|
|
|
|
foreach($types as $k=>$v)
|
|
{
|
|
$parts = array(
|
|
'ptype'=>$v['ptype'],
|
|
'type_code'=>$v['code'],
|
|
);
|
|
$types[$k]['url'] = $News->makeCategoryUrl($parts);
|
|
}
|
|
|
|
$this->view->types = $types;
|
|
$this->view->deepField = $category->DeepTitle;
|
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
$sql = "SELECT id,title_en,code,ptype FROM ".$News->tbl_categorys." where ptype='news'";
|
|
$sth = $this->db->query($sql);
|
|
$rows = $sth->fetchAll();
|
|
|
|
$newslist = array();
|
|
|
|
foreach($rows as $v)
|
|
{
|
|
$sql = "SELECT n.*,c.title as typetitle,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
|
|
WHERE n.language='en' and n.ts_published<'$time' AND ct.cid={$v['id']} AND n.is_pub=true
|
|
ORDER BY ts_published DESC
|
|
LIMIT 10";
|
|
|
|
$rs = $this->db->query($sql);
|
|
$archives = $rs->fetchAll();
|
|
|
|
foreach($archives as $k=>$va)
|
|
{
|
|
$ev = $News->getArchiveUrlByCid($va['id'],$v['id']);
|
|
$archives[$k]['url'] = $ev['archive_url'];
|
|
}
|
|
|
|
$parts = array(
|
|
'ptype'=>$v['ptype'],
|
|
'type_code'=>$v['code'],
|
|
);
|
|
$url = $News->makeCategoryUrl($parts);
|
|
|
|
$newslist[$v['id']] = array("title"=>$v['title_en'],"url"=>$url,"id"=>$v['id'],"list"=>$archives);
|
|
}
|
|
$this->view->lists = $newslist;
|
|
|
|
|
|
}
|
|
|
|
function listAction()
|
|
{
|
|
$ptype = strtolower($this->_request->getParam('ptype'));
|
|
$type = strtolower($this->_request->getParam('type'));
|
|
$page = $this->_request->getParam('page');
|
|
|
|
if(preg_match("/archive-(\d+)\.html/",$page,$matches))
|
|
{
|
|
$this->_forward('archive', 'archives', null, array('archive' => $matches['1'] , 'type'=> $type,'ptype'=>$ptype));
|
|
return true;
|
|
}
|
|
|
|
if(preg_match("/[^a-z0-9]/",$ptype) || preg_match("/[^a-z0-9]/",$type) || preg_match("/[^0-9]/",$page))
|
|
{
|
|
$this->_forward('error', 'error', null, null);
|
|
return true;
|
|
}
|
|
|
|
|
|
$News = new Archive($this->db);
|
|
|
|
$sql = "SELECT id,code,title FROM ".$News->tbl_categorys." WHERE code='$type' AND is_pub=true ";
|
|
$rs = $this->db->query($sql);
|
|
$row = $rs->fetch();
|
|
|
|
if(empty($row['id']))
|
|
{
|
|
$this->_forward('error', 'error', null, null);
|
|
}
|
|
|
|
else{
|
|
|
|
$this->view->url = $row['code'];
|
|
$this->view->title = $row['title'];
|
|
$this->view->type=$type;
|
|
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
$types = $category->GetCategory(0,$ptype);
|
|
foreach($types as $k=>$v)
|
|
{
|
|
$parts = array(
|
|
'ptype'=>$v['ptype'],
|
|
'type_code'=>$v['code'],
|
|
);
|
|
$types[$k]['url'] = $News->makeCategoryUrl($parts);
|
|
}
|
|
|
|
$this->view->types = $types;
|
|
$this->view->deepField = $category->DeepTitle;
|
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
$sql = "SELECT n.*,c.id as typeid,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 ct.cid=c.id
|
|
WHERE n.language='en' and c.id='{$row['id']}' AND n.ts_published<'".$time."' AND n.is_pub=true
|
|
ORDER BY n.ts_published DESC";
|
|
|
|
$rs = $this->db->query($sql);
|
|
$rows = $rs->fetchAll();
|
|
|
|
foreach($rows as $k=>$va)
|
|
{
|
|
$ev = $News->getArchiveUrlByCid($va['id'],$va['typeid']);
|
|
$rows[$k]['url'] = $ev['archive_url'];
|
|
}
|
|
|
|
$paginator = Zend_Paginator::factory($rows);
|
|
$paginator->setCurrentPageNumber($page);
|
|
$paginator->setItemCountPerPage($this->view->config->page->max);
|
|
$paginator->setView($this->view);
|
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
|
|
$this->view->paginator=$paginator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function archiveAction()
|
|
{
|
|
$ptype = $this->_request->getParam('ptype');
|
|
$type = $this->_request->getParam('type');
|
|
$archive = $this->_request->getParam('archive');
|
|
|
|
if(preg_match("/[^a-z0-9]/",$ptype) || preg_match("/[^a-z0-9]/",$type) || preg_match("/[^0-9]/",$archive))
|
|
{
|
|
$this->_forward('error', 'error', null, null);
|
|
}
|
|
|
|
$this->view->ptype = $ptype;
|
|
$this->view->type = $type;
|
|
|
|
$News = new Archive($this->db);
|
|
$category = new ArchiveCategory($this->db);
|
|
|
|
$types = $category->GetCategory(0,$ptype);
|
|
foreach($types as $k=>$v)
|
|
{
|
|
$parts = array(
|
|
'ptype'=>$v['ptype'],
|
|
'type_code'=>$v['code'],
|
|
);
|
|
$types[$k]['url'] = $News->makeCategoryUrl($parts);
|
|
}
|
|
|
|
$this->view->types = $types;
|
|
|
|
$this->view->deepField = $category->DeepTitle;
|
|
|
|
$time = date("Y-m-d H:i:s",time());
|
|
|
|
|
|
$sql = "SELECT
|
|
n.*,c.title as typename,c.code,u.realname as author,ct.uuid as mduuid
|
|
FROM ".$News->tbl_archives." n
|
|
left join ".$News->tbl_catalog." ct on ct.aid=n.id
|
|
left join ".$News->tbl_categorys." c ON ct.cid=c.id
|
|
LEFT JOIN users u ON n.userid=u.id
|
|
WHERE c.code='".$type."' AND n.ts_published<'".$time."' AND n.is_pub=true AND n.id=".$archive."
|
|
ORDER BY n.ts_published DESC";
|
|
|
|
$rs = $this->db->query($sql);
|
|
$row = $rs->fetch();
|
|
|
|
if(empty($row['id']))
|
|
{
|
|
$this->_forward('error', 'error', null, null);
|
|
}
|
|
|
|
$this->view->infos = $row;
|
|
|
|
if(!empty($row['mduuid']))
|
|
{
|
|
$sql = "SELECT md.uuid,md.title FROM ar_catalog ct
|
|
LEFT JOIN metadata md ON ct.uuid=md.uuid
|
|
WHERE ct.aid=$archive";
|
|
$sth = $this->db->query($sql);
|
|
$this->view->mdinfo = $sth->fetchAll();
|
|
}
|
|
|
|
}
|
|
|
|
function searchAction()
|
|
{
|
|
|
|
}
|
|
|
|
} |