2012-12-03 10:08:25 +00:00
< ? php
2018-06-26 03:13:28 +00:00
class ArchivesController extends Zend_Controller_Action
2012-12-03 10:08:25 +00:00
{
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
private $limit = 10 ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
function preDispatch ()
{
$this -> view -> config = Zend_Registry :: get ( 'config' );
$this -> db = Zend_Registry :: get ( 'db' );
2013-03-25 09:21:37 +00:00
$this -> view -> theme = new Theme ();
}
2018-06-26 03:13:28 +00:00
2013-03-25 09:21:37 +00:00
function testAction ()
{
$this -> _helper -> viewRenderer ( 'archive-view-player' );
2012-12-03 10:08:25 +00:00
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
function indexAction ()
{
2018-02-04 07:05:06 +00:00
$this -> _helper -> layout -> setLayout ( 'layout-sanji' );
2012-12-03 10:08:25 +00:00
$News = new Archive ( $this -> db );
$category = new ArchiveCategory ( $this -> db );
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$types = $category -> GetCategory ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
foreach ( $types as $k => $v )
{
$parts = array (
'ptype' => $v [ 'ptype' ],
'type_code' => $v [ 'code' ],
);
$types [ $k ][ 'url' ] = $News -> makeCategoryUrl ( $parts );
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> types = $types ;
$this -> view -> deepField = $category -> DeepTitle ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$time = date ( " Y-m-d H:i:s " , time ());
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$sql = " SELECT id,title,code,ptype FROM " . $News -> tbl_categorys . " where ptype='news' " ;
$sth = $this -> db -> query ( $sql );
$rows = $sth -> fetchAll ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$newslist = array ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
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 . ts_published < '$time' AND ct . cid = { $v [ 'id' ]} AND n . is_pub = true
ORDER BY ts_published DESC
LIMIT 10 " ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$rs = $this -> db -> query ( $sql );
$archives = $rs -> fetchAll ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
foreach ( $archives as $k => $va )
{
$ev = $News -> getArchiveUrlByCid ( $va [ 'id' ], $v [ 'id' ]);
$archives [ $k ][ 'url' ] = $ev [ 'archive_url' ];
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$parts = array (
'ptype' => $v [ 'ptype' ],
'type_code' => $v [ 'code' ],
);
$url = $News -> makeCategoryUrl ( $parts );
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$newslist [ $v [ 'id' ]] = array ( " title " => $v [ 'title' ], " url " => $url , " id " => $v [ 'id' ], " list " => $archives );
}
$this -> view -> lists = $newslist ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
function listAction ()
{
2018-02-04 07:05:06 +00:00
$this -> _helper -> layout -> setLayout ( 'layout-sanji' );
2012-12-03 10:08:25 +00:00
$ptype = strtolower ( $this -> _request -> getParam ( 'ptype' ));
$type = strtolower ( $this -> _request -> getParam ( 'type' ));
$page = $this -> _request -> getParam ( 'page' );
2018-06-26 03:13:28 +00:00
2012-12-04 04:34:47 +00:00
if ( preg_match ( " /archive-( \ d+) \ .html/ " , $page , $matches ))
2012-12-03 10:08:25 +00:00
{
2012-12-04 04:34:47 +00:00
$this -> _forward ( 'archive' , 'archives' , null , array ( 'archive' => $matches [ '1' ] , 'type' => $type , 'ptype' => $ptype ));
2012-12-03 10:08:25 +00:00
return true ;
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
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 ;
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$News = new Archive ( $this -> db );
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$sql = " SELECT id,code,title FROM " . $News -> tbl_categorys . " WHERE code=' $type ' AND is_pub=true " ;
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
if ( empty ( $row [ 'id' ]))
{
$this -> _forward ( 'error' , 'error' , null , null );
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
else {
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> url = $row [ 'code' ];
2018-02-04 07:05:06 +00:00
$this -> view -> title = $row [ 'title' ];
2013-04-09 12:52:14 +00:00
$this -> view -> type = $type ;
2012-12-03 10:08:25 +00:00
$category = new ArchiveCategory ( $this -> db );
2018-06-26 03:13:28 +00:00
2013-04-20 13:06:25 +00:00
$types = $category -> GetCategory ( 0 , $ptype );
2012-12-03 10:08:25 +00:00
foreach ( $types as $k => $v )
{
$parts = array (
'ptype' => $v [ 'ptype' ],
'type_code' => $v [ 'code' ],
);
$types [ $k ][ 'url' ] = $News -> makeCategoryUrl ( $parts );
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> types = $types ;
$this -> view -> deepField = $category -> DeepTitle ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$time = date ( " Y-m-d H:i:s " , time ());
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$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 c . id = '{$row[' id ']}' AND n . ts_published < '".$time."' AND n . is_pub = true
ORDER BY n . ts_published DESC " ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
foreach ( $rows as $k => $va )
{
$ev = $News -> getArchiveUrlByCid ( $va [ 'id' ], $va [ 'typeid' ]);
$rows [ $k ][ 'url' ] = $ev [ 'archive_url' ];
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $page );
$paginator -> setItemCountPerPage ( $this -> view -> config -> page -> max );
$paginator -> setView ( $this -> view );
2018-05-12 09:54:23 +00:00
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination_param.phtml' );
2012-12-03 10:08:25 +00:00
$this -> view -> paginator = $paginator ;
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
function archiveAction ()
{
2018-02-04 07:05:06 +00:00
$this -> _helper -> layout -> setLayout ( 'layout-sanji' );
2012-12-04 04:34:47 +00:00
$ptype = $this -> _request -> getParam ( 'ptype' );
2012-12-03 10:08:25 +00:00
$type = $this -> _request -> getParam ( 'type' );
$archive = $this -> _request -> getParam ( 'archive' );
2012-12-04 04:34:47 +00:00
if ( preg_match ( " /[^a-z0-9]/ " , $ptype ) || preg_match ( " /[^a-z0-9]/ " , $type ) || preg_match ( " /[^0-9]/ " , $archive ))
2012-12-03 10:08:25 +00:00
{
$this -> _forward ( 'error' , 'error' , null , null );
}
2012-12-04 04:34:47 +00:00
$this -> view -> ptype = $ptype ;
$this -> view -> type = $type ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$News = new Archive ( $this -> db );
$category = new ArchiveCategory ( $this -> db );
2018-06-26 03:13:28 +00:00
2013-04-20 13:02:05 +00:00
$types = $category -> GetCategory ( 0 , $ptype );
2012-12-03 10:08:25 +00:00
foreach ( $types as $k => $v )
{
$parts = array (
'ptype' => $v [ 'ptype' ],
'type_code' => $v [ 'code' ],
);
$types [ $k ][ 'url' ] = $News -> makeCategoryUrl ( $parts );
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> types = $types ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> deepField = $category -> DeepTitle ;
2018-06-26 03:13:28 +00:00
2012-12-05 07:12:38 +00:00
$time = date ( " Y-m-d H:i:s " , time ());
2018-06-26 03:13:28 +00:00
2012-12-07 07:49:37 +00:00
$sql = " SELECT
n .* , c . title as typename , c . code , u . realname as author , ct . uuid as mduuid
FROM " . $News->tbl_archives . " n
2012-12-03 10:08:25 +00:00
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 " ;
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$rs = $this -> db -> query ( $sql );
$row = $rs -> fetch ();
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
if ( empty ( $row [ 'id' ]))
{
$this -> _forward ( 'error' , 'error' , null , null );
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
$this -> view -> infos = $row ;
2018-06-26 03:13:28 +00:00
2012-12-05 07:12:38 +00:00
if ( ! empty ( $row [ 'mduuid' ]))
{
2012-12-07 07:49:37 +00:00
$sql = " SELECT md.uuid,md.title FROM ar_catalog ct
LEFT JOIN metadata md ON ct . uuid = md . uuid
WHERE ct . aid = $archive " ;
2012-12-05 07:12:38 +00:00
$sth = $this -> db -> query ( $sql );
2012-12-11 03:12:25 +00:00
$this -> view -> mdinfo = $sth -> fetchAll ();
2012-12-05 07:12:38 +00:00
}
2018-06-26 03:13:28 +00:00
$sql = " SELECT * FROM archive WHERE is_pub=true AND image IS NOT NULL AND image != '' and id in (select ar_catalog.aid from ar_category left join ar_catalog on ar_category.id=ar_catalog.cid where ar_category.code='localnews') order by ts_published asc LIMIT 3 " ;
$this -> view -> news = $this -> db -> fetchAll ( $sql );
2012-12-03 10:08:25 +00:00
}
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
function searchAction ()
{
2018-06-26 03:13:28 +00:00
2012-12-03 10:08:25 +00:00
}
}