merge heihedata branch from r3802 to r3810 into trunk

This commit is contained in:
wlx 2013-07-15 13:33:19 +00:00
parent aa2a230753
commit 3bfb53767a
9 changed files with 402 additions and 11 deletions

View File

@ -123,6 +123,24 @@ class Admin_ReviewController extends Zend_Controller_Action
}
}//changestatus 更改状态
function editorAction()
{
include_once("helper/view.php");
include_once("data/Review.php");
$this->view->keyword = $keyword = $this->_request->getParam('keyword');
$review = new Review();
if(!empty($keyword))
{
$filter['keyword'] = $keyword;
$data = $review->needEditor($filter);
}else{
$data = $review->needEditor();
}
\view::addPaginator($data,$this,NULL,20);
}
/*
* acceptAction()待审元数据
@ -191,16 +209,12 @@ class Admin_ReviewController extends Zend_Controller_Action
$sql = "select m.*,md.title,u.username,u.realname from mdstatus m
right join metadata md on md.uuid=m.uuid
left join users u on u.id=m.userid
where m.status in (1,2,3,4) order by m.ts_created desc";
where m.status in (1,2,3,4)
order by m.ts_created desc";
$re = $this->db->query($sql);
$rows = $re->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;
\view::addPaginator($rows,$this,NULL,20);
}//列表
}//acceptAction

View File

@ -48,7 +48,7 @@ table thead tr th {background:#EBF2F6;color:#444;}
<td><?php echo $item['realname'].'['.$item['username'].']'; ?></td>
<td><?php echo date("Y-m-d H:i",strtotime($item['ts_accepted']));?></td>
<td>
<a href="/admin/review/changeadmin/?id=<?php echo $item['id'];?>">分配编辑</a>
<a href="/admin/review/changeadmin/?id=<?php echo $item['id'];?>">更改责任编辑</a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -0,0 +1,60 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle('后台管理');
$this->headTitle()->setSeparator(' - ');
$this->breadcrumb('<a href="/">首页</a>');
$this->breadcrumb('<a href="/admin">后台首页</a>');
$this->breadcrumb('元数据评审');
$this->breadcrumb()->setSeparator(' > ');
?>
<style>
table thead tr th {background:#EBF2F6;color:#444;}
.high{background:#444;color:#FFF;}
</style>
<div class="row-fluid">
<div class="span3">
<?= $this->partial('review/left.phtml'); ?>
</div>
<div class="span9">
<?php if ($this->msg or $this->messages) :?>
<div id="message">
<?php if ($this->msg) : ?>
<p><?php echo $this->msg; ?></p>
<?php endif; if ($this->messages): foreach($this->messages as $msg): ?>
<p><?php echo $msg; ?></p>
<?php endforeach;endif; ?>
</div>
<?php endif; ?>
<form action="" method="get" class="search input-append">
<input type="hidden" name="search" value='1' />
<input type="text" name="keyword" class="q" value="<?php echo $this->keyword; ?>" />
<button type="submit" class="btn">搜索</button>
</form>
<table class="table table-bordered table-hover"><thead>
<tr>
<th width='600'>元数据标题</th>
<th width='120'>责任编辑</th>
<th width='120'>接收时间</th>
<th width='180'>操作</th>
</tr></thead>
<?php if (count($this->paginator)): ?>
<tbody id="list">
<?php foreach ($this->paginator as $item): ?>
<tr>
<td><a href="/data/<?php echo $item['uuid'];?>"><?= $item['title']?></a></td>
<td><?php echo $item['realname'].'['.$item['username'].']'; ?></td>
<td><?php echo date("Y-m-d H:i",strtotime($item['ts_accepted']));?></td>
<td>
<a href="/admin/review/changeadmin/?id=<?php echo $item['id'];?>">分配编辑</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<?php endif; ?>
</table>
<div class="pagenavi"><?= $this->paginator; ?></div>
</div><!-- span9 -->
</div>

View File

@ -1,6 +1,7 @@
<ul class="nav nav-pills nav-stacked well">
<span class="label"><h4>元数据评审</h4></span>
<li id="Nav-review-draft"><a href="/admin/review/draft">投稿元数据</a></li>
<li id="Nav-review-editor"><a href="/admin/review/editor">分配责任编辑</a></li>
<li id="Nav-review-accept"><a href="/admin/review/accept">待审元数据</a></li>
<!-- <li id="Nav-review-inreview"><a href="/admin/review/inreview">在审元数据</a></li> -->
<li id="Nav-review-myreview"><a href="/admin/review/myreview">我负责的元数据</a></li>

View File

@ -1239,4 +1239,34 @@ class HeiheController extends DataController
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination_param.phtml');
$this->view->paginator=$paginator;
}
function onlinelistAction()
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$limit=30;
$offset=$limit*($page-1);
$state=$this->db->query("select count(*) from heihemetadata where datatype=0 and uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$select=$this->db->select();
$select->from('heihemetadata','*')->where('datatype=0')->where("uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')")->order('title')->limitPage($page,$limit);
$this->view->metadata = $this->db->fetchAll($select);
$this->view->page=new Pagination($sum,$page,$limit);
}
function offlinelistAction()
{
$page=(int)$this->_request->getParam('page');
if (empty($page)) $page=1;
$limit=30;
$offset=$limit*($page-1);
$state=$this->db->query("select count(*) from heihemetadata where datatype=1 and uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')");
$row=$state->fetchAll();
$sum=$row[0]['count'];
$select=$this->db->select();
$select->from('heihemetadata','*')->where('datatype=1')->where("uuid in (select ds.uuid from datasource ds left join source s on ds.sourceid=s.id where s.code='heihe')")->order('title')->limitPage($page,$limit);
$this->view->metadata = $this->db->fetchAll($select);
$this->view->page=new Pagination($sum,$page,$limit);
}
}

View File

@ -0,0 +1,34 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle('离线数据浏览');
$this->headTitle()->setSeparator(' - ');
$this->nav[] = array('link'=>"/heihe/offline",'title'=>'离线数据浏览');
?>
<?= $this->render('breadcrumbs.phtml') ?>
<div class="row">
<div class="span2">
<?= $this->partial('heihe/navi.phtml'); ?>
</div>
<div class="span10">
<?php echo $this->page->getNavigation(); ?>
<hr />
<div class="mdlist">
<ol start="<?php echo $this->offset; ?>">
<?php foreach($this->metadata as $md) : ?>
<div class="media well well-small">
<a href="/service/bigthumb/uuid/<?= $md['uuid'] ?>" class="pull-left colorbox">
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>
<?php endforeach; ?>
</ol>
</div>
<hr />
<?php echo $this->page->getNavigation(); ?>
</div>
</div>

View File

@ -0,0 +1,34 @@
<?php
$this->headTitle($this->config->title->site);
$this->headTitle($this->config->title->data);
$this->headTitle('在线数据浏览');
$this->headTitle()->setSeparator(' - ');
$this->nav[] = array('link'=>"/heihe/offline",'title'=>'在线数据浏览');
?>
<?= $this->render('breadcrumbs.phtml') ?>
<div class="row">
<div class="span2">
<?= $this->partial('heihe/navi.phtml'); ?>
</div>
<div class="span10">
<?php echo $this->page->getNavigation(); ?>
<hr />
<div class="mdlist">
<ol start="<?php echo $this->offset; ?>">
<?php foreach($this->metadata as $md) : ?>
<div class="media well well-small">
<a href="/service/bigthumb/uuid/<?= $md['uuid'] ?>" class="pull-left colorbox">
<img class="media-object" src="/service/thumb/id/<?php echo $md['id'];?>">
</a>
<div class="media-body">
<h4 class="media-heading"><a href="/heihe/<?php echo $md['uuid'];?>"><?php echo $this->escape($md['title']);?></a></h4>
<div class="summary"><?php echo str_replace(array("\r\n", "\n", "\r"),'<br />',mb_strlen($md['description'])>400?$this->escape(mb_substr($md['description'],0,400,'UTF-8').'...'):$this->escape($md['description']));?></div>
</div>
</div>
<?php endforeach; ?>
</ol>
</div>
<hr />
<?php echo $this->page->getNavigation(); ?>
</div>
</div>

View File

@ -9,10 +9,15 @@ class Review extends Zend_Controller_Plugin_Abstract
public $tbl_mdreview = "mdreview";
public $tbl_user = "users";
function __construct($db)
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = Zend_Registry::get('db');
}else{
$this->db = $db;
}
}
public function events(Zend_EventManager_EventCollection $events = NULL)
{
@ -63,6 +68,56 @@ class Review extends Zend_Controller_Plugin_Abstract
return $reviews;
}
//需要分配责任编辑的元数据评审
function needEditor($filter = "")
{
$wheresql = array();
$ordersql = array();
$wheresql[] = " m.status in (1,2,3,4) ";
$wheresql[] = " (m.userid IS NULL OR u.usertype != 'administrator') ";
if(isset($filter['keyword']) && !empty($filter['keyword']))
{
$wheresql[] = " (md.title like '%".$filter['keyword']."%' OR u.username LIKE '%".$filter['keyword']."%' OR u.realname LIKE '%".$filter['keyword']."%') ";
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
}else{
$wheresql = "";
}
if(isset($filter['order']) && !empty($filter['order']))
{
$sort = "DESC";
if(isset($filter['sort']) && !empty($filter['sort']) && in_array( strtolower($filter['sort']),array('desc','asc')))
{
$sort = $filter['sort'];
}
$ordersql[] = " {$filter['order']} $sort ";
}
if(count($ordersql)>0)
{
$ordersql = " ORDER BY ".join(',',$ordersql);
}else{
$ordersql = " ORDER BY m.ts_created desc ";
}
$sql = "select m.*,md.title,u.username,u.realname from mdstatus m
right join metadata md on md.uuid=m.uuid
left join users u on u.id=m.userid
$wheresql
$ordersql";
$re = $this->db->query($sql);
$rows = $re->fetchAll();
return $rows;
}
//后台我负责的评审
function adminReviews($filter = "")
{
@ -91,7 +146,6 @@ class Review extends Zend_Controller_Plugin_Abstract
$sort = $filter['sort'];
}
$ordersql[] = " {$filter['order']} $sort ";
}
if(count($wheresql)>0)

View File

@ -0,0 +1,164 @@
<?php
namespace helper;
class email
{
private $db;
private $config;
public $mail; //Zend_Mail Object
private $charset = "utf-8";
private $name = "寒区旱区科学数据中心";
private $tbl_mailTemplate = "emailtext";
protected $events = NULL;
public $subject;
public $body;
public $type;
function __construct($db = NULL,Zend_Mail_Transport_Smtp $transport = NULL)
{
if(empty($db))
{
$this->db = Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = Zend_Registry::get('config');
$smtp = $this->config->smtp;
$mail_config = array(
'ssl' => $smtp->ssl,
'auth'=> $smtp->auth,
'username'=> $smtp->username,
'password'=> $smtp->password
);
$transport = new Zend_Mail_Transport_Smtp($smtp->host, $mail_config);
Zend_Mail::setDefaultTransport($transport);
if(empty($mail))
{
$this->mail = new Zend_Mail();
}else{
$this->mail = $mail;
}
}
public function events(Zend_EventManager_EventCollection $events = NULL)
{
if ($events !== NULL) {
$this->events = $events;
} elseif ($this->events === NULL) {
$this->events = new Zend_EventManager_EventManager(__CLASS__);
}
return $this->events;
}
//默认使用westdc作为发件人
public function withWestdc()
{
$this->mail->setFrom($this->config->supportemail,$this->name);
}
//加载模板
public function loadTemplate($id,$data){
if(is_numeric($this->tmpid))
{
$sql = "SELECT * FROM {$this->tbl_mailTemplate} WHERE id='".$id."'";
}else{
$sql = "SELECT * FROM {$this->tbl_mailTemplate} WHERE \"template\"='".$id."'";
}
$rs = $this->db->query($sql);
$row = $rs->fetch();
$subject = $row['subject'];
$body = $row['body'];
if(count($data) > 0)
{
$patterns = array();
$replacements = array();
foreach($this->data as $k=>$v)
{
$patterns[]='/{'.$k.'}/i';
$replacements[]=$v;
}
ksort($patterns);
ksort($replacements);
$body = preg_replace($patterns, $replacements, $body);
$subject = preg_replace($patterns, $replacements, $subject);
}//count($this->data)
$this->subject = $subject;
$this->body = $body;
$this->type = $row['type'];
}//加载模板
//使用loadTemplate 的结果发送邮件
//在此之前需要使用 $this->mail->addTo()添加收件人
public function send($from = NULL){
if(empty($this->subject) || empty($this->body))
{
return "邮件信息不完整";
}
if($this->type == 'html')
{
$this->mail->setBodyHtml($this->body);
}else{
$this->mail->setBodyText($this->body);
}
if(empty($from))
{
$this->withWestdc();
}else{
$this->mail->setFrom($from['email'],$from['name']);
}
$this->mail->setSubject($this->subject);
$this->mail->send();
}
}
class EmailListener implements Zend_EventManager_ListenerAggregate
{
private $db;
function __construct($db = NULL)
{
if(empty($db))
{
$this->db = Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = Zend_Registry::get('config');
}
public function attach(Zend_EventManager_EventCollection $events)
{
$events->attach('send', array($this, 'send'), 100);
}
public function detach(Zend_EventManager_EventCollection $events)
{
}
public function send()
{
//邮件发送事件
}
}