2011-10-11 10:06:51 +00:00
< ? php
class Admin_SysController 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-06-08 09:51:44 +00:00
$this -> _helper -> layout -> setLayout ( 'administry' ); //新UI
2013-05-28 09:11:43 +00:00
$this -> view -> theme = new Theme ();
2011-10-11 10:06:51 +00:00
}
function postDispatch ()
{
$this -> view -> messages = $this -> messenger -> getMessages ();
}
function indexAction ()
{
//$this->_helper->viewRenderer('');
//$this->messenger->addMessage('');
//$this->_redirect('');
} //indexAction 首页
function emailtextAction (){
$ac = $this -> _request -> getParam ( 'ac' );
$submit = $this -> _request -> getParam ( 'submit' );
$id = $this -> _request -> getParam ( 'id' );
2011-10-12 08:33:46 +00:00
if ( $ac == 'add' && empty ( $submit ))
{
$this -> _helper -> viewRenderer ( 'emailtextadd' );
}
2011-10-11 10:06:51 +00:00
if ( $ac == 'add' && ! empty ( $submit ))
{
$title = $this -> _request -> getParam ( 'title' );
2011-10-12 13:45:45 +00:00
$template = $this -> _request -> getParam ( 'template' );
2011-10-11 10:06:51 +00:00
$body = $this -> _request -> getParam ( 'body' );
if ( empty ( $title )) $title == '未命名模板' ;
2011-10-12 13:45:45 +00:00
$sql = " insert into emailtext (subject,template,body) values (' $title ',' $template ',' $body ') " ;
2011-10-11 10:06:51 +00:00
try {
if ( $this -> db -> exec ( $sql ) > 0 )
{
$this -> messenger -> addMessage ( '模板添加成功' );
$this -> _redirect ( '/admin/sys/emailtext' );
}
} catch ( Exception $e ){
$this -> messenger -> addMessage ( '模板添加失败:' . $e -> getMessage ());
$this -> _redirect ( '/admin/sys/emailtext' );
}
} //创建新模板
else if ( $ac == 'edit' && ! empty ( $id ))
{
if ( ! empty ( $submit ))
{
$title = $this -> _request -> getParam ( 'title' );
2011-10-12 13:45:45 +00:00
$template = $this -> _request -> getParam ( 'template' );
2011-10-11 10:06:51 +00:00
$body = $this -> _request -> getParam ( 'body' );
2011-10-12 13:45:45 +00:00
$sql = " update emailtext set subject=' $title ',template=' $template ',body=' $body ',ts_changed=now() where id=' $id ' " ;
2011-10-11 10:06:51 +00:00
try {
if ( $this -> db -> exec ( $sql ) > 0 )
{
$this -> messenger -> addMessage ( '模板编辑成功' );
$this -> _redirect ( '/admin/sys/emailtext' );
}
} catch ( Exception $e ){
$this -> messenger -> addMessage ( '模板编辑失败:' . $e -> getMessage ());
$this -> _redirect ( '/admin/sys/emailtext' );
}
2011-10-12 08:33:46 +00:00
} else {
2011-10-11 10:06:51 +00:00
$sql = " select * from emailtext where id=' $id ' " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetch ();
$this -> view -> info = $rows ;
2011-10-12 08:33:46 +00:00
$this -> _helper -> viewRenderer ( 'emailtextedit' );
}
} //模板编辑
else if ( $ac == 'test' && ! empty ( $id ))
{
if ( ! empty ( $submit ))
{
try {
2011-10-12 13:45:45 +00:00
$subject = $this -> _request -> getParam ( 'subject' );
2011-10-13 08:18:12 +00:00
$email = $this -> _request -> getParam ( 'email' );
$body = $this -> _request -> getParam ( 'body' );
2011-10-12 13:45:45 +00:00
if ( empty ( $subject ) || empty ( $email ))
2011-10-12 08:33:46 +00:00
{
$this -> messenger -> addMessage ( '请填写测试邮件发送信息' );
$this -> _redirect ( '/admin/sys/emailtext/ac/test/id/' . $id );
2011-10-13 08:18:12 +00:00
}
2011-10-13 10:12:17 +00:00
$mailtp = new EmailText ( $this -> db , $this -> _request -> getParam ( 'id' ), array ( 'user' => $this -> _request -> getParam ( 'user' )));
$body = $mailtp -> getBody ();
2011-10-13 08:18:12 +00:00
if ( $body === false )
{
$this -> messenger -> addMessage ( '模板加载失败' );
$this -> _redirect ( '/admin/sys/emailtext/ac/test/id/' . $id );
}
2011-10-12 08:33:46 +00:00
$mail = new WestdcMailer ( $this -> view -> config -> smtp );
$mail -> setBodyText ( $body );
$mail -> setFrom ( $this -> view -> config -> service -> email , '西部数据中心服务组' );
$mail -> addTo ( $email );
$mail -> setSubject ( $subject );
if ( $mail -> send ()){
$this -> messenger -> addMessage ( '测试邮件发送成功' );
$this -> _redirect ( '/admin/sys/emailtext/ac/test/id/' . $id );
} else {
$this -> messenger -> addMessage ( '测试邮件发送失败' );
$this -> _redirect ( '/admin/sys/emailtext/ac/test/id/' . $id );
}
} catch ( Exception $e ){
$this -> messenger -> addMessage ( '测试邮件发送失败' . $e -> getMessage ());
$this -> _redirect ( '/admin/sys/emailtext/ac/test/id/' . $id );
2011-10-12 13:45:45 +00:00
}
2011-10-12 08:33:46 +00:00
}
else
2011-10-13 08:18:12 +00:00
{
2011-10-12 13:45:45 +00:00
$sql = " select * from emailtext where id=' $id ' " ;
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetch ();
$this -> view -> info = $rows ;
2011-10-12 08:33:46 +00:00
$this -> _helper -> viewRenderer ( 'emailtexttest' );
}
} //模板测试
2011-10-11 10:06:51 +00:00
2011-10-13 08:18:12 +00:00
else if ( $ac == 'help' )
{
$this -> _helper -> viewRenderer ( 'emailtexthelp' );
}
2011-10-11 10:06:51 +00:00
else
{
2011-10-13 08:18:12 +00:00
try {
2012-05-09 12:30:32 +00:00
$sql = " select id,subject,template,ts_created,ts_changed from emailtext order by ts_changed desc " ;
2011-10-11 10:06:51 +00:00
$rs = $this -> db -> query ( $sql );
$rows = $rs -> fetchAll ();
$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-10-13 08:18:12 +00:00
} catch ( Exception $e ){
echo $e -> getMessage ();
}
2011-10-11 10:06:51 +00:00
} //邮件模板管理首页
} //emailtextAction 邮件模板管理
2011-11-16 10:01:39 +00:00
function seekspaceAction ()
{
set_time_limit ( 0 );
$submit = $this -> _request -> getParam ( 'submit' );
if ( ! empty ( $submit ))
{
$sql = " select item_id from knl_article order by id desc " ;
$row = $this -> db -> fetchRow ( $sql );
try {
$this -> db -> beginTransaction ();
$sql = " insert into knl_article (item_id) select item_id from knl_dcvalue where dc_type_id=66 and text_value='Article' and item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set title=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=64) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set url=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=25) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set publisher=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=39) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set ts_issued=t.text_value from (select text_value,item_id from knl_dcvalue where dc_type_id=15) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set ts_created=cast(t.text_value as timestamp without time zone) from (select text_value,item_id from knl_dcvalue where dc_type_id=12) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " update knl_article k set keywords[t.place]=t.text_value from (select text_value,item_id,place from knl_dcvalue where dc_type_id=57) as t where k.item_id=t.item_id and k.item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " insert into knl_keyword (keyword,item_id,place) select text_value,item_id,place from knl_dcvalue where dc_type_id=57 and item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$sql = " insert into knl_author (author,item_id,place) select text_value,item_id,place from knl_dcvalue where dc_type_id=3 and item_id> " . $row [ 'item_id' ];
$this -> db -> query ( $sql );
$this -> db -> query ( " delete from knl_keyword where item_id not in (select item_id from knl_article) " );
$this -> db -> query ( " delete from knl_author where item_id not in (select item_id from knl_article) " );
$this -> db -> commit ();
} catch ( Exception $e ) {
$this -> db -> rollBack ();
$this -> view -> msg = $e -> getMessage ();
}
$this -> view -> msg = '与文献平台同步成功!' ;
}
$sql = " select (select count(*) from knl_article) as westdccount,(select count(*) from knl_dcvalue where dc_type_id=66 and text_value='Article') as seekcount " ;
$this -> view -> count = $this -> db -> fetchRow ( $sql );
}
function getmsgAction (){
$this -> _helper -> layout () -> disableLayout ();
$this -> _helper -> viewRenderer -> setNoRender ();
$msg = array ();
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
if ( $user -> usertype == " administrator " )
{
include_once ( " message.php " );
$rs = message :: getNew ( $this -> db , $userid , " admin " );
echo Zend_Json :: encode ( $rs );
exit ();
} else {
$msg [ 'error' ] = " 您没有权限 " ;
echo Zend_Json :: encode ( $msg );
exit ();
}
} else {
$msg [ 'error' ] = " 您没有权限 " ;
echo Zend_Json :: encode ( $msg );
exit ();
}
2011-10-29 07:12:47 +00:00
}
2011-11-16 10:01:39 +00:00
function messageAction (){
$do = $this -> _request -> getParam ( 'do' );
$id = $this -> _request -> getParam ( 'id' );
if ( $do == 'read' && ! empty ( $id ))
{
$this -> _helper -> viewRenderer ( 'messageview' );
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
if ( $user -> usertype == " administrator " )
{
include_once ( " message.php " );
$rs = message :: getOne ( $this -> db , $userid , $id );
$this -> view -> info = $rs [ 'info' ];
}
}
}
2011-11-17 09:37:17 +00:00
//读取所有消息
else if ( $do == " listall " )
{
$sql = " SELECT * FROM messages m
LEFT JOIN messages_logs ml ON m . id = ml . mid
ORDER BY m . sendtime DESC " ;
$result = $this -> db -> query ( $sql );
$rows = $result -> fetchAll ();
$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 ;
}
//标记为已读
else if ( $do == " close " && ! empty ( $id ))
{
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
include_once ( " message.php " );
$rs = message :: read ( $this -> db , $userid , $id );
$this -> _redirect ( '/admin/sys/message' );
}
}
//标记为已处理(不再推送给其他管理员)
else if ( $do == " over " && ! empty ( $id ))
{
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
if ( $user -> usertype == " administrator " )
{
include_once ( " message.php " );
$rs = message :: over ( $this -> db , $id );
if ( $rs ){
echo " 操作成功! " ; exit ();
} else {
echo " 操作失败! " ; exit ();
}
} else {
echo " 非法操作! " ; exit ();
}
} else {
echo " 非法操作! " ; exit ();
}
}
2011-11-16 10:01:39 +00:00
//拉取新消息
else
{
$auth = Zend_Auth :: getInstance ();
if ( $auth -> hasIdentity ())
{
$user = $auth -> getIdentity ();
$userid = $user -> id ;
if ( $user -> usertype == " administrator " )
{
include_once ( " message.php " );
$rs = message :: getNew ( $this -> db , $userid , " admin " );
$this -> view -> totle = $rs [ 'count' ];
$paginator = Zend_Paginator :: factory ( $rs [ '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 ;
}
}
} //end
2013-06-08 09:51:44 +00:00
} //getmessageAction() 获取站内消息
//ftp测试
function ftptestAction ()
{
}
//区域管理
function regionsAction ()
{
include_once ( " data/Regions.php " );
include_once ( " helper/view.php " );
$region = new Region ( $this -> db );
$ac = $this -> _getParam ( 'ac' );
$id = $this -> _getParam ( " id " );
$RegionListener = new RegionListener ();
@ $region -> events () -> attachAggregate ( $RegionListener );
if ( empty ( $ac ) || $ac == " index " )
{
$filter = array ();
$q = $this -> _getParam ( 'keyword' );
if ( ! empty ( $q ))
{
$filter [ 'q' ] = $q ;
$this -> view -> keyword = $q ;
}
$data = $region -> fetchRegion ( 'all' , $filter );
view :: addPaginator ( $data , $this , NULL , 15 );
}
if ( $ac == " add " || $ac == " edit " )
{
$this -> _helper -> viewRenderer ( 'regions-add' );
$submit = $this -> _getParam ( 'submit' );
if ( ! empty ( $submit ))
{
$this -> view -> data = $data = $this -> _getParam ( " data " );
$s = $region -> addRegion ( $data , $id );
if ( $s === true )
{
$msg = " 添加成功 " ;
if ( ! empty ( $id ))
$msg = " 编辑成功 " ;
view :: Post ( $this , $msg , " /admin/sys/regions " );
return true ;
} else {
if ( is_string ( $s ))
{
$this -> view -> error = view :: Error ( $s );
return true ;
} else {
$this -> view -> error = view :: Error ( " 操作失败请重试 " );
return true ;
}
}
} else {
if ( ! empty ( $id ))
{
$this -> view -> data = $region -> get ( $id );
}
}
} //添加
if ( $ac == " del " )
{
$langid = $this -> _getParam ( 'langid' );
if ( ! empty ( $id ) && ! empty ( $langid ))
{
$region -> del ( $id , $langid );
} else {
$region -> del ( $id );
}
view :: Post ( $this , " 删除成功 " , - 1 );
} //删除
} //区域管理
function recoveryAction ()
{
$pages = 20 ;
$ac = $this -> _request -> getParam ( 'ac' );
if ( $ac == '' || $ac == 'online' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-11 05:39:56 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-05-28 03:32:53 +00:00
where s . status > 4 and m . datatype = 0 and ds . host = 'ftp1.westgis.ac.cn'
ORDER BY m . id DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-11 07:04:21 +00:00
$this -> view -> paginator = $paginator ;
$ac = 'online' ;
2013-06-08 09:51:44 +00:00
} else if ( $ac == 'heihe' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-11 05:39:56 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-06-08 09:51:44 +00:00
left join datasource on datasource . uuid = m . uuid
left join source on datasource . sourceid = source . id
2013-05-28 03:32:53 +00:00
where s . status > 4 and m . datatype = 1 and ds . host = 'ftp1.westgis.ac.cn' and source . code = 'heihe'
ORDER BY m . id DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'water' )
{
2013-06-11 05:39:56 +00:00
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
LEFT JOIN mdstatus s ON m . uuid = s . uuid
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
left join datasource on datasource . uuid = m . uuid
left join source on datasource . sourceid = source . id
where s . status > 4 and m . datatype = 1 and ds . host = 'ftp1.westgis.ac.cn' and source . code = 'water'
2013-06-03 10:01:56 +00:00
ORDER BY m . title DESC " ;
2013-05-28 03:32:53 +00:00
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'heihe1' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-08 09:51:44 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join datasource on datasource . uuid = m . uuid
2013-06-11 05:39:56 +00:00
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-06-08 09:51:44 +00:00
left join source on datasource . sourceid = source . id
where s . status in ( 2 , 3 , 4 ) and ds . host = 'ftp1.westgis.ac.cn' and source . code = 'heihe'
2013-05-28 03:32:53 +00:00
ORDER BY m . title DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'hiwater' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-08 09:51:44 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
2013-06-11 05:39:56 +00:00
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-06-08 09:51:44 +00:00
left join datasource on datasource . uuid = m . uuid
left join source on datasource . sourceid = source . id
2013-05-28 03:32:53 +00:00
where ds . host = 'ftp1.westgis.ac.cn' and source . code = 'hiwater'
ORDER BY m . title DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'westee' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-11 05:39:56 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-05-28 03:32:53 +00:00
where ds . host = 'ftp1.westgis.ac.cn' and m . uuid in ( select uuid from westeemd )
ORDER BY m . title DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'other' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
2013-06-11 05:39:56 +00:00
floor ( t . filesize / 1024 / 1024 * 100 ) / 100 as filesize ,
t . filecount from metadata m
2013-05-28 03:32:53 +00:00
LEFT JOIN mdstatus s ON m . uuid = s . uuid
2013-06-11 05:39:56 +00:00
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t on ds . id = t . dsid
2013-05-28 03:32:53 +00:00
where ds . host = 'ftp1.westgis.ac.cn' and m . uuid not in ( select uuid from datasource ) and m . uuid not in ( select uuid from westeemd )
ORDER BY m . title DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
2013-06-08 09:51:44 +00:00
$this -> view -> paginator = $paginator ;
}
$this -> view -> activeID = " btn- " . $ac ;
}
2013-06-11 05:39:56 +00:00
function problemAction ()
{
$pages = 20 ;
$ac = $this -> _request -> getParam ( 'ac' );
if ( $ac == '' || $ac == 'ref' )
{
$sql = " SELECT m.title,m.uuid,m.citation,g.id as gid from metadata m
LEFT JOIN mdstatus s ON m . uuid = s . uuid
left join geonetworkmetadata g on g . uuid = m . uuid
where s . status > 4 and m . citation like '%??%'
ORDER BY m . id DESC " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
$this -> _helper -> viewRenderer ( 'problem-ref' );
$ac = 'ref' ;
} else if ( $ac == 'file' )
{
$sql = " SELECT m.title,m.uuid,m.filesize,ds.host,ds.path from metadata m
LEFT JOIN mdstatus s ON m . uuid = s . uuid
LEFT JOIN dataset ds ON m . uuid = ds . uuid
where s . status > 4 and ds . id not in ( select distinct dsid from datafile )
group by m . title , m . uuid , ds . host , ds . path , m . filesize
ORDER BY m . title DESC ; " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
} else if ( $ac == 'tiny' )
{
$sql = " SELECT m.title,m.uuid,ds.host,ds.path,
floor ( sum ( datafile . filesize ) / 1024 / 1024 * 100 ) / 100 as filesize ,
count ( datafile . id ) as filecount
from metadata m
LEFT JOIN mdstatus s ON m . uuid = s . uuid
LEFT JOIN dataset ds ON m . uuid = ds . uuid
left join datasource on datasource . uuid = m . uuid
left join datafile on ds . id = datafile . dsid
left join source on datasource . sourceid = source . id
where s . status > 4 and ds . id in ( select t . dsid from ( select dsid , count ( id ) as filecount , sum ( filesize ) as filesize from datafile group by dsid ) as t
where t . filesize < 1024 * 5 )
group by m . title , m . uuid , ds . host , ds . path
ORDER BY m . title DESC ; " ;
$sth = $this -> db -> prepare ( $sql );
$sth -> execute ();
$rows = $sth -> fetchAll ();
$paginator = Zend_Paginator :: factory ( $rows );
$paginator -> setCurrentPageNumber ( $this -> _getParam ( 'page' ));
$paginator -> setItemCountPerPage ( $pages );
$paginator -> setView ( $this -> view );
Zend_View_Helper_PaginationControl :: setDefaultViewPartial ( 'pagination.phtml' );
$this -> view -> paginator = $paginator ;
}
$this -> view -> activeID = " btn- " . $ac ;
}
2011-10-11 10:06:51 +00:00
}