修改文献列表显示方式,添加按年显示的功能

This commit is contained in:
Li Jianxuan 2013-11-04 07:08:58 +00:00
parent 075ff2b2c0
commit 6ae3223a84
9 changed files with 328 additions and 80 deletions

View File

@ -1128,6 +1128,7 @@ class Admin_DataController extends Zend_Controller_Action
$keyword = $this->view->q = trim($this->_getParam('q'));
$order = $this->view->search_order = trim($this->_getParam('order'));
$sort = $this->view->search_sort = trim($this->_getParam('sort'));
$field = $this->view->search_field = $this->_getParam('field');
$reference = new Reference();
@ -1136,6 +1137,11 @@ class Admin_DataController extends Zend_Controller_Action
$reference->keyword = $keyword;
}
if(!empty($field))
{
$reference->field = $field;
}
if(!empty($order))
{
$reference->order = $order;
@ -1146,11 +1152,18 @@ class Admin_DataController extends Zend_Controller_Action
$reference->sort = $sort;
}
$this->view->reference = $reference;
//文献首页
if(empty($ac))
{
$this->view->referenceType = $reference->referenceType();
view::addPaginator($reference->fetchReferences(),$this,12);
$this->view->page = $this->_getParam('page');
$this->view->pagelimit = 12;
view::addPaginator($reference->fetchReferences(),$this, $this->view->pagelimit);
$this->view->years = $reference->countByYear();
return true;
}
else if ($ac == "water")
@ -1172,6 +1185,8 @@ class Admin_DataController extends Zend_Controller_Action
return true;
}
unset($this->view->reference);
//添加
if($ac == "add")
{
@ -1378,6 +1393,18 @@ class Admin_DataController extends Zend_Controller_Action
return true;
}//ris单篇更新
//ris导出
if($ac == "risoutput")
{
$this->_helper->viewRenderer('ref-risoutput');
$this->view->years = $reference->countByYear();
if(!empty($submit))
{
}
}//ris output
}//文献管理 refAction()

View File

@ -28,7 +28,6 @@
<div id="datalist">
</div>
<input id="file_upload" name="Filedata" type="file" />
<input type="button" class="btn btn-small" onclick="$('#file_upload').uploadifyUpload();" value="上传" />
</p>
</form>
@ -71,7 +70,7 @@ var upload = {
makeFileHtml : function(data){
return '<div class="alert alert-success">'
+ '<button type="button" class="close" data-dismiss="alert" onclick="upload.deleteFile('+data.id+')"><i class="icon-trash icon-white"></i></button>'
+ data.realname
+ '<a href="/service/attach/id/' + data.id + '">' +data.realname + '</a>'
+'<input type="hidden" name="attid" value="'+data.id+'"></input>'
+'</div>';
},

View File

@ -1,10 +1,11 @@
<ul class="nav nav-tabs">
<li <?= empty($this->ac) ? 'class="active"':"" ?>><a href="/admin/data/ref">浏览所有</a></li>
<li <?= $this->ac=="water" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/water">WATER文献</a></li>
<li <?= $this->ac=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</a></li>
<li <?= $this->ac=="water" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/water">WATER文献</a></li>
<li <?= $this->ac=="westdc" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/westdc">数据中心文献</a></li>
<li <?= $this->ac=="todo" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/todo">待处理文献</a></li>
<li <?= $this->ac=="add" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/add">单篇添加</a></li>
<li <?= $this->ac=="multiupload" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/multiupload">批量上传</a></li>
<li <?= $this->ac=="files" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/files">文件管理</a></li>
<li <?= $this->ac=="ris" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/ris">RIS导入</a></li>
<li <?= $this->ac=="risoutput" ? 'class="active"':"" ?>><a href="/admin/data/ref/ac/risoutput">RIS导出</a></li>
</ul>

View File

@ -37,6 +37,13 @@ table thead tr th {background:#EBF2F6;}
<?php if(!empty($this->msg)) { ?>
<?= $this->msg ?>
<?php } else{ ?>
<?php if(!empty($this->years)) { ?>
<?php foreach($this->years as $k=>$v){ ?>
<a class="btn btn-info" href="?field[year]=<?= $v['year'] ?>"><?= empty($v['year']) ? "未知":$v['year'] ?>(<?= $v['num'] ?>)</a>
<?php } ?>
<?php } ?>
<div id="datalist">
<?php if (count($this->paginator)): ?>
<table class="table table-bordered table-striped">
@ -45,8 +52,7 @@ table thead tr th {background:#EBF2F6;}
<th>标题
<a href="?order=title&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=title&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
<th>年份
年份
<a href="?order=year&sort=ASC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-up"></i></a>
<a href="?order=year&sort=DESC&q=<?php if(!empty($this->q)) echo $this->q; ?>"><i class="icon-arrow-down"></i></a>
</th>
@ -58,37 +64,31 @@ table thead tr th {background:#EBF2F6;}
</tr>
</thead>
<tbody>
<?php $autoindex=0;
<?php
if($this->page > 1)
{
$autoindex = ($this->page - 1) * $this->pagelimit;
}else{
$autoindex=0;
}
foreach ($this->paginator as $item):
$autoindex++;?>
<tr id="DataLine_<?= $item['id']?>">
<?php if(!empty($item['title']) || !empty($item['year'])) { ?>
<td><?= $item['title'] ?></td>
<td><?= $item['year'] ?></td>
<td>
[<?= $autoindex ?>]&nbsp;
{<?php $authors = $this->reference->getAuthorByReference($item['id'],true); echo count($authors) ? join(",",$authors):'<font color="#CC0000">未知作者</font>'; ?>}&nbsp;
{<?= empty($item['title']) ? '<font color="#CC0000">未知标题</font>':$item['title'] ?>}&nbsp;
{<?= empty($item['publisher']) ? '<font color="#CC0000">未知期刊</font>':$item['publisher'] ?>}&nbsp;
{<?= empty($item['year']) ? '<font color="#CC0000">未知年份</font>':$item['year'] ?>}&nbsp;
</td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td>
<td rowspan="2">
<td>
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a>
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>(<a href="javascript:void(0);" onclick="$('#mdref')[0].reset();mdref.edit('',<?= $item['id']?>,'',0,0)">+</a>)
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<tr>
<td colspan="2"><?= $item['reference'] ?></td>
</tr>
<?php } ?>
<?php if(empty($item['title']) && empty($item['year'])) { ?>
<td colspan="2"><?= $item['reference'] ?></td>
<td><?= date("Y-m-d H:i",strtotime($item['ts_created'])) ?></td>
<td>
<a href="/admin/data/ref/ac/add/id/<?= $item['id']?>">编辑</a>
<a href="/admin/data/ref/ac/singleris/id/<?= $item['id'] ?>">RIS编辑</a>
<a href="/admin/data/ref/ac/data/id/<?= $item['id'] ?>">数据</a>
<a href="/admin/data/ref/ac/deleteref/id/<?= $item['id']?>">删除</a>
</td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>

View File

@ -20,4 +20,11 @@ class Table
//元数据
public $metadata = "metadata";
//会员
public $member = "users";
//开放平台
public $oauth_clients = "oauth_clients";
public $oauth_access_tokens = "oauth_access_tokens";
}

View File

@ -1,11 +1,15 @@
<?php
namespace Helpers;
use \Helpers\View as view;
class dbh
{
private $db; //传入PDO对象.
private $product = 0; //产品环境
public $debug = 0;
function __construct($db = NULL)
{
if(empty($db))
@ -41,6 +45,12 @@ class dbh
if($return == false){
$sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas)";
if($this->debug == 1)
{
view::Dump($sql,false);
}
try{
return $this->db->exec($sql);
}catch (Exception $e) {
@ -53,6 +63,12 @@ class dbh
}
}else{
$sql = "INSERT INTO \"".$table."\" ($fields) VALUES ($datas) RETURNING id";
if($this->debug == 1)
{
view::Dump($sql,false);
}
try{
$sth = $this->db->prepare($sql);
if($sth->execute())
@ -108,6 +124,12 @@ class dbh
try{
$sql = "UPDATE \"".$table."\" SET $fields $wheresql";
if($this->debug == 1)
{
view::Dump($sql,false);
}
if($this->db->exec($sql))
{
return true;
@ -125,6 +147,12 @@ class dbh
}else{
try{
$sql = "UPDATE \"".$table."\" SET $fields $wheresql";
if($this->debug == 1)
{
view::Dump($sql,false);
}
return $this->db->exec($sql);
}catch (Exception $e) {
if($this->product)

View File

@ -1,15 +1,72 @@
<?php
namespace Open;
use Open\Open as open;
use \Helpers\View as view;
use \Helpers\dbh;
use \Open\Open as open;
use \Open\Listener\AppListener as Listener;
class app extends open implements openbase
class App
{
public $tbl_oauth_clients = "oauth_clients"; //oauth 客户端表
public $config;
public $db;
public $table;
public $checkFiled = array('phone','realname','unit','address');
public function __construct($db = NULL,$auth = NULL)
{
$this->load();
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
}else{
$this->db = $db;
}
$this->config = \Zend_Registry::get('config');
$Listener = new Listener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
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;
}
public function appStatus()
{
return array(
-1 => '关闭',
0 => '测试',
1 => '启用'
);
}
//检查用户资料完整性
public function checkinfo()
{
$uid = view::User('id');
$sql = "SELECT * FROM ".$this->table->member. " WHERE id=$uid";
$rs = $this->db->query($sql);
$row = $rs->fetch();
foreach($this->checkFiled as $v)
{
if(empty($row[$v]))
{
return "请完善个人信息";
}
}
return true;
}
//获得用户创建的app
@ -17,10 +74,10 @@ class app extends open implements openbase
{
if(empty($uid))
{
$uid = $this->user->id;
$uid = view::User('id');
}
$sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE user_id=".$this->user->id;
$sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE user_id=".$uid ." ORDER BY id DESC";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
@ -34,12 +91,103 @@ class app extends open implements openbase
{
return false;
}
$sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE id=".$id;
$sql = "SELECT * FROM ".$this->table->oauth_clients." WHERE id=".$id;
$rs = $this->db->query($sql);
$rows = $rs->fetch();
return $rows;
}
//收集创建应用的参数
public function getAppCreateParam(\Zend_Controller_Request_Abstract $request = NULL)
{
$request = new \Zend_Controller_Request_Http();
$data = array(
'subject' => trim($request->getParam('subject')),
'client_domain' => trim($request->getParam('client_domain')),
'redirect_uri' => trim($request->getParam('redirect_uri')),
'status' => (int)$request->getParam('status')
);
return $data;
}//getAppCreateParam
//添加或者编辑
public function appCreate($id = NULL)
{
if(!empty($id))
{
if(!is_numeric($id) || $id<1)
{
return "参数错误";
}
}
$data = $this->getAppCreateParam();
$params = compact('data');
$results = $this->events()->trigger('app.checkParam', $this, $params);
$cache_data = $results->bottom();
if($cache_data !== true)
{
return $cache_data;
}
if(!empty($id))
{
$params = compact('data','id');
}
$results = $this->events()->trigger('app.processData', $this, $params);
$data = $results->bottom();
$dbh = new dbh();
if(empty($id))
{
$id = $dbh->insert($this->table->oauth_clients,$data,true);
if($id > 0)
{
$results = $this->events()->trigger('app.created', $this, compact("data","id"));
$cache_data = $results->bottom();
return $id;
}else{
return "应用创建中发生错误,请重试!";
}
}else{
$status = $dbh->update($this->table->oauth_clients,$data," id=$id ");
if($status)
{
$results = $this->events()->trigger('app.eidted', $this, compact("data","id"));
$cache_data = $results->bottom();
return true;
}else{
return "应用编辑中发生错误,请重试";
}
}
}//appCreate
//删除App
public function delete($id)
{
if(!is_numeric($id) || $id<1)
{
return "参数错误";
}
try{
$sql = "DELETE FROM {$this->table->oauth_clients} WHERE id=$id";
$rs = $this->db->exec($sql);
if($rs)
{
return true;
}else{
return "删除失败";
}
}catch(Excaption $e){
return "服务器处理中遇到错误";
}
}//delete
}

View File

@ -1,26 +1,18 @@
<?php
namespace open;
namespace Open;
interface openbase
{
public function __construct($db = NULL,$auth = NULL);
}
use \Helpers\View as view;
use \Open\Listener\OpenListener as Listener;
interface openextend extends openbase
{
public function load();
}
abstract class open extends \Zend_Controller_Plugin_Abstract implements openextend
class Open extends \Zend_Controller_Plugin_Abstract
{
public $db;
public $auth = NULL;
public $user;
public $config;
public $table;
public $checkFiled = array('phone','realname','unit','address');
public function load($db = NULL,$auth = NULL){
$this->config = \Zend_Registry::get('config');
public function __construct($db = NULL,$auth = NULL){
if(empty($db))
{
$this->db = \Zend_Registry::get('db');
@ -28,39 +20,27 @@ abstract class open extends \Zend_Controller_Plugin_Abstract implements openexte
$this->db = $db;
}
if(empty($auth))
{
$this->auth = \Zend_Auth::getInstance();
if($this->auth->hasIdentity())
{
$this->user = $this->auth->getIdentity();
}
}else{
$this->auth = false;
}
$this->config = \Zend_Registry::get('config');
$Listener = new Listener();
@$this->events()->attachAggregate($Listener);
$this->table = new \Helpers\Table();
}
//检查用户资料完整性
public function checkinfo()
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;
}
public function clientCredentials()
{
if($this->auth === false)
{
return "未登陆";
}
include_once("Users.php");
$user = new \Users($this->db);
$info = $user->getUserInfo($this->user->id);
foreach($this->checkFiled as $v)
{
if(empty($info[$v]))
{
return "请完善个人信息";
}
}
return true;
}
}

View File

@ -16,6 +16,7 @@ class Reference
public $keyword;
public $order;
public $sort = "DESC";
public $field;
public $reftype;
@ -176,6 +177,24 @@ class Reference
{
$wheresql[] = " ({$this->table->reference}.title LIKE '%{$this->keyword}%' OR {$this->table->reference}.reference LIKE '%{$this->keyword}%') ";
}
if(!empty($this->field))
{
foreach($this->field as $k=>$v)
{
if(!empty($v))
{
if(!is_numeric($v)) $v="'{$v}'";
$wheresql[] = " ({$this->table->reference}.{$k}={$v} ) ";
}else{
if(is_numeric($v))
$wheresql[] = " ({$this->table->reference}.{$k} IS NULL OR {$this->table->reference}.{$k}=0 ) ";
else
$wheresql[] = " ({$this->table->reference}.{$k} IS NULL ) ";
}//if(empty($v)
}//foreach
}
if(count($wheresql)>0)
{
$wheresql = " WHERE ".join(" AND ",$wheresql);
@ -517,4 +536,43 @@ class Reference
}
}
//按年份获得文献数量
public function countByYear()
{
$sql = "SELECT count(id) as num,year FROM {$this->table->reference} GROUP BY year ORDER BY year DESC";
$rs = $this->db->query($sql);
$rows = $rs->fetchAll();
return $rows;
}
//获得作者
public function getAuthorByReference($id,$join = false)
{
if(is_numeric($id))
{
$sql = "SELECT * FROM {$this->table->reference_author} WHERE id=$id ORDER BY place ASC";
$rs = $this->db->query($sql);
if(!$join)
{
return $rs->fetchAll();
}else{
foreach($rows = $rs->fetchAll() as $k=>$v)
{
$rows[$k] = (string)$v['firstname'].$v['lastname'];
}
return $rows;
}
}
if(is_array($id))
{
$sql = "SELECT * FROM {$this->table->reference_author} WHERE id IN (".join(",",$id).")";
$rs = $this->db->query($sql);
return $rs->fetchAll();
}
return;
}
}