数据作者文献库
+作者推荐文献库
-
- paginator as $item): ?>
-
- - 下载'; - endif; + paginator)): ?> +
数据中心文献库
-
+
-
-
- 西部计划资源 -
- 环境与生态科学期刊资源 -
- 环境与生态科学信息网关 -
- 环境与生态科学开放知识资源 -
- 西部环境与生态科学文献库 -
- 黑河流域研究 -
西部计划文献库
+数据施引文献库
+数据施引文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。
+从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。 + 数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。
+ +作者推荐文献库
+作者推荐文献库是对发布在数据中心的科学数据的作者所推荐的和其数据相关的科技文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。
+用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。 + 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
+ +WATER文献库
+WATER文献库是对由WATER项目所相关的科技文献,包括WATER项目自身发表的文献以及WATER数据用户所发表的文献。
+用户可以通过WATER文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。 + 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
+ +西部计划文献库
旨在发展和形成一个支持环境与生态科学领域开放学术信息的自助存档、交流和发现的领域知识平台。 首先,实现对国家自然科学基金委组织实施的“中国西部环境与生态科学研究计划”历年来所支持的研究项目和课题所产生的有重要科研和学术价值的知识产出进行统一组织和管理, @@ -38,20 +50,6 @@ $this->breadcrumb()->setSeparator(' > '); 特别是对有重要学术影响的研究性数字知识库所涉及的环境与生态科学领域的学术信息进行搜索、发现、聚集和再组织。
数据作者文献库
-数据作者文献库是对发布在数据中心的科学数据中相关的参考文献,主要是由数据作者发表的、和其数据紧密相关的科学文献。
-用户可以通过数据作者的文献库中挖掘出对应的数据信息,实现从文献到数据的一个知识挖掘。将数据中心所有的数据作者文献构建一个和数据紧密相关的知识库,可以供用户更好的了解和发现数据和知识。 - 支持用户对数据作者的学术信息进行搜索、发现、聚集和再组织。
- -数据用户文献库
-数据用户文献库是数据用户在使用科学数据后公开发表在科技期刊上的文献,由用户自发通知数据中心、数据作者收集和数据中心集中手机三种方式进行收集整理。
-从数据用户的文献库中,可以挖掘出更多的知识,了解用户是如何使用数据中心提供的科学数据。数据作者也可以从其中获取到数据相关的趋势性知识。 - 数据中心也欢迎用户提供更多的公开发表成果,我们将持续更新其内容,以满足数据的深层挖掘,实现学术信息进行搜索、发现、聚集和再组织。
- -paper['title']; ?>
++ + author) : ?> +
作者
+-
+ author as $a) : ?>
+
- 【所有文章】 + +
+ + + paper['abstract']){ ?> +
摘要
+paper['abstract']; ?>
++ + + tag) > 0) { ?> +
关键词
+-
+ tag as $t) : ?>
+
+
+
+ + + paper['reference'])) { ?> +
引用方式
++ paper['reference']; ?> ++
+ + + + +
数据文献搜索
diff --git a/application/default/views/scripts/knowledge/search.phtml b/application/default/views/scripts/knowledge/search.phtml index 164b3b2b..fa37577c 100644 --- a/application/default/views/scripts/knowledge/search.phtml +++ b/application/default/views/scripts/knowledge/search.phtml @@ -43,7 +43,7 @@ $('#Nav-knowledge-westplan').addClass('active'); + \ No newline at end of file diff --git a/application/default/views/scripts/water/view.phtml b/application/default/views/scripts/water/view.phtml index b05aaf16..e17dd3e4 100755 --- a/application/default/views/scripts/water/view.phtml +++ b/application/default/views/scripts/water/view.phtml @@ -23,10 +23,10 @@ h3.gs_rt{font-size:110%;} = $this->render('breadcrumbs.phtml'); ?> metadata;if ($md):?> -escape($md->title);
-if ($md->title_en) echo '
'.$this->escape($md->title_en);?>
-
-+
escape($md->title);
+ if ($md->title_en) echo '
'.$this->escape($md->title_en);?>
+
+ '.$this->escape($md->title_en);?>
本数据引用方式数据引用帮助
datadoi) || !strpos($md->citation,$md->datadoi)) : ?>文章的引用 escape($md->citation);?>
- datadoi) && !strpos($md->citation,$md->datadoi)) : ?> -数据的引用datadoi) && !strpos($md->citation,$md->datadoi)) : ?> +
数据的引用 + authors,1,-1).'. '.$md->title.'. '.$md->publisher.', '.$md->publish_year.'. doi:'.$md->doi; echo ' ['.substr($md->author_en,1,-1).'. '.$md->title_en.'. '.$md->publisher_en.', '.(empty($md->ts_published)?$md->publish_year:date('Y',strtotime($md->ts_published))).'. doi:'.$md->doi.']'; ?> (下载引用:RIS格式 | RIS英文格式 | Bibtex格式 | Bibtex英文格式)
- ref) : ?> + ref) : ?>-
建议参考文献
+相关文献(作者推荐)
-
ref as $ref) :
+ echo '
- '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
- '.$ref->reference.' '; - else - echo '
- '.$ref->reference.' 下载 '; + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo ""; endforeach; ?>
-
数据用户发表文献
+专题文献
+-
+ themeref as $ref) :
+ echo '
- '.$ref->reference; + echo '查看'; + if (empty($ref->link)) + { + if(!empty($ref->attid)) + echo ' | 下载'; + }else{ + echo ' | 下载'; + } + echo " "; + endforeach; + ?> +
+
数据施引文献
-
userref as $ref) :
+ echo '
- '.$ref->reference; + echo '查看'; if (empty($ref->link)) - echo '
- '.$ref->reference.' '; - else - echo '
- '.$ref->reference.' 下载 '; + { + if(!empty($ref->attid)) + echo '下载'; + }else{ + echo '下载'; + } + echo ""; endforeach; + if (count($this->userref)==15) + { + echo '更多施引文献'; + } ?>
'.$this->escape($md->title_en);?> fund)) : ?>
-
fund as $k=>$v) : ?>
-
- = $v['fund_type'] ?>:= $v['title'] ?>(项目编号:= $v['fund_id']?>) [= $v['fund_type_en'] ?>(No. = $v['fund_id']?>)] +
- = $v['fund_type'] ?>:= $v['title'] ?>(项目编号:= $v['fund_id']?>) [= $v['fund_type_en'] ?>(No. = $v['fund_id']?>)]
'.$content.'
'."\r\n"; + $html.= ''.$content.''."\r\n"; }else{ $html.= '- '."\r\n";
foreach($content as $v) {
diff --git a/application/module/Helpers/dbh.php b/application/module/Helpers/dbh.php
index 83791cd1..b9f2e7a8 100644
--- a/application/module/Helpers/dbh.php
+++ b/application/module/Helpers/dbh.php
@@ -1,11 +1,15 @@
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)
diff --git a/application/module/Mail/Mail.php b/application/module/Mail/Mail.php
index 8736bffb..06288646 100644
--- a/application/module/Mail/Mail.php
+++ b/application/module/Mail/Mail.php
@@ -121,7 +121,12 @@ class Mail
$this->subject = $subject;
$this->body = $body;
- $this->type = $row['type'];
+ if(isset($row['type']))
+ {
+ $this->type = $row['type'];
+ }else{
+ $this->type = "text";
+ }
}//加载模板
diff --git a/application/module/Open/App.php b/application/module/Open/App.php
new file mode 100644
index 00000000..a4da49a0
--- /dev/null
+++ b/application/module/Open/App.php
@@ -0,0 +1,193 @@
+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
+ public function getUserApp($uid = 0)
+ {
+ if(empty($uid))
+ {
+ $uid = view::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();
+
+ return $rows;
+ }
+
+ //获得某个App的信息
+ public function getAppInfo($id)
+ {
+ if(empty($id))
+ {
+ return false;
+ }
+ $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
+}
\ No newline at end of file
diff --git a/application/module/Open/Client.php b/application/module/Open/Client.php
new file mode 100644
index 00000000..2bfc6ff6
--- /dev/null
+++ b/application/module/Open/Client.php
@@ -0,0 +1,172 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+
+ $this->table = new \Helpers\Table();
+
+ $this->target = $target;
+
+ $Listener = new Listener();
+ @$this->events()->attachAggregate($Listener);
+ }
+
+ 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 initSource()
+ {
+ $this->source = new Source('heihedata');
+ }
+
+ public function getSource()
+ {
+ return $this->source;
+ }
+
+ //创建获取Code的URL
+ public function makeRequestCodeUrl($target = NULL)
+ {
+ if(empty($this->source))
+ {
+ $this->initSource();
+ }
+
+ if(empty($target))
+ {
+ $target = $this->target;
+ }
+
+ $main_target = $this->source->getTarget($target);
+
+ if($main_target === false)
+ {
+ return "此登录接口可能不存在";
+ }
+
+ $source = $this->source->getSource($target);
+
+ if($source === false)
+ {
+ return "此登录接口暂不可用";
+ }
+
+ $main_url = $main_target['code'];
+
+ $param = array(
+ $source->param['id'] => $source->config['id'],
+ $source->param['secret'] => $source->config['secret'],
+ $source->param['callback'] => $source->config['callback'],
+ $source->param['code_response'] => $main_target['code_response']
+ );
+
+ if(isset($source->config['other']))
+ {
+ $param = array_merge($param,$source->config['other']);
+ }
+
+ $url = $main_url."?".http_build_query($param);
+
+ return $url;
+
+ }
+
+ //获得token
+ public function requestToken($code,$target = NULL)
+ {
+ if(empty($target))
+ {
+ $target = $this->target;
+ }
+
+ if(empty($code))
+ {
+ return "未获得您的授权码";
+ }
+
+ $main_target = $this->source->getTarget($target);
+ $client = $this->source->getSource($target);
+
+ if($client === false)
+ {
+ return "请求发生错误,登录接口不存在或者可能不再适用";
+ }
+
+ $main_url = $main_target['token'];
+ $param = array(
+ $client->param['id'] => $client->config['id'],
+ $client->param['secret'] => $client->config['secret'],
+ $client->param['grant_type'] => $main_target['grant_type'],
+ $client->param['callback'] => $client->config['callback'],
+ $client->param['code'] => $code
+ );
+
+ $curl = new Curl();
+ $curl->port = 443;
+ $curl->initOptions(array('verifyssl'=>false));
+ $data = $curl->request($main_url,$param,"POST");
+
+ $cache_data = json_decode($data['response'],true);
+
+ if(!isset($cache_data['expires_in']))
+ {
+ return "未获得授权信息,请重试链接";
+ }
+
+ return $cache_data;
+
+ }
+
+ //储存token信息
+ public function storageTokenData($type,$token)
+ {
+ if(empty($type))
+ {
+ return "接口类型错误";
+ }
+
+ if(empty($token))
+ {
+ return "登录信息有误,请重新登录";
+ }
+
+ $param = compact("type","token");
+
+ $results = $this->events()->trigger('tokenStorage', $this, $param);
+ return $cache_data = $results->bottom();
+
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Event/AppEvent.php b/application/module/Open/Event/AppEvent.php
new file mode 100644
index 00000000..9985c74d
--- /dev/null
+++ b/application/module/Open/Event/AppEvent.php
@@ -0,0 +1,10 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //检查app参数
+ public function appCheckParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+ if(empty($data['subject']))
+ {
+ return "请输入应用名称";
+ }
+
+ if(empty($data['client_domain']))
+ {
+ return "请填写应用使用的域名,不带www";
+ }
+
+ if(empty($data['redirect_uri']))
+ {
+ return "请输入授权成功后的回调地址";
+ }
+
+ $sql = "SELECT id FROM {$this->table->oauth_clients} WHERE subject='{$data['subject']}'";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ if(!empty($row['id']))
+ {
+ return "此应用名称已存在,请重新输入";
+ }
+
+ return true;
+ }
+
+ //处理app参数数据
+ public function appProcessData(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+ $id = $e->getParam('id');
+
+ if(empty($id))
+ {
+ $data['client_id'] = $this->create_client_guid(__CLASS__);
+ $data['client_secret'] = strtoupper(substr(md5($data['client_id'].$data['client_domain'].$data['redirect_uri'].time()),10,24));
+ }
+ $data['user_id'] = view::User('id');
+
+ return $data;
+ }
+
+ //创建App成功后
+ public function appCreated(\Zend_EventManager_Event $e)
+ {
+ $id = $e->getParam('id');
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+ //App编辑成功后
+ public function appEdited(\Zend_EventManager_Event $e)
+ {
+ $id = $e->getParam('id');
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+ public function create_client_guid($namespace = '') {
+ static $guid = '';
+ $uid = uniqid("", true);
+ $data = $namespace;
+ if(isset($_SERVER['REQUEST_TIME']))
+ $data .= $_SERVER['REQUEST_TIME'];
+
+ if(isset($_SERVER['HTTP_USER_AGENT']))
+ $data .= $_SERVER['HTTP_USER_AGENT'];
+
+ if(isset($_SERVER['LOCAL_ADDR']))
+ $data .= $_SERVER['LOCAL_ADDR'];
+
+ if(isset($_SERVER['LOCAL_PORT']))
+ $data .= $_SERVER['LOCAL_PORT'];
+
+ if(isset($_SERVER['REMOTE_ADDR']))
+ $data .= $_SERVER['REMOTE_ADDR'];
+
+ if(isset($_SERVER['REMOTE_PORT']))
+ $data .= $_SERVER['REMOTE_PORT'];
+
+ $data .= time();
+
+ $hash = strtoupper(hash('ripemd128', $uid . $guid . md5($data)));
+ $guid = '' .
+ substr($hash, 0, 8) .
+ '-' .
+ substr($hash, 8, 4) .
+ '-' .
+ substr($hash, 12, 4) .
+ '-' .
+ substr($hash, 16, 4) .
+ '-' .
+ substr($hash, 20, 12) .
+ '';
+ return $guid;
+ }
+
+}
diff --git a/application/module/Open/Handler/ClientHandler.php b/application/module/Open/Handler/ClientHandler.php
new file mode 100644
index 00000000..b3cd8a2f
--- /dev/null
+++ b/application/module/Open/Handler/ClientHandler.php
@@ -0,0 +1,83 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //获得Handler,type必须与 \Open\Source中同步,否则会出现错误
+ //
+ public function getHandler($type,$data)
+ {
+ if($type == 'escience')
+ {
+ return new \Open\Handler\ClientTokenHandler\Escience($data);
+ }
+
+ if($type == 'sina')
+ {
+ return new \Open\Handler\ClientTokenHandler\Sina($data);
+ }
+
+ return false;
+ }
+
+ //存储token信息
+ public function tokenAndDataStorage(\Zend_EventManager_Event $e)
+ {
+ $type = $e->getParam('type');
+ $data = $e->getParam('token');
+
+ $handler = $this->getHandler($type,$data);
+
+ if($status = $handler->doit() === true)
+ {
+ return true;
+ }else{
+ return $status;
+ }
+ }
+
+ //检查用户账户是否存在
+ //存在就返回用户信息,不存在返回false
+ //通用事件,通过各个 TokenHandler中内置Listener直接挂载,不需要引入整个ClientListener
+ public function userCheck(\Zend_EventManager_Event $e)
+ {
+ $email = $e->getParam('email');
+
+ $user = new Users();
+ $current = $user->userExists($email);
+
+ if($current === false)
+ {
+ return false;
+ }
+
+ return $current;
+ }
+
+}
diff --git a/application/module/Open/Handler/ClientTokenHandler/Escience.php b/application/module/Open/Handler/ClientTokenHandler/Escience.php
new file mode 100644
index 00000000..68759322
--- /dev/null
+++ b/application/module/Open/Handler/ClientTokenHandler/Escience.php
@@ -0,0 +1,182 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+
+ //预处理token信息
+ $status = $this->preProcess($token);
+ }
+
+ //考虑加一个接口,每个Token操作类中必须包含此函数
+ public function doit()
+ {
+ //makeUserStorage在先,必须的
+ $status = $this->makeUserStorage();
+
+ if($status!==true)
+ {
+ return $status;
+ }
+
+ $status = $this->makeTokenStorage();
+
+ if($status !== true)
+ {
+ return $status;
+ }
+
+ return true;
+ }
+
+ //预处理
+ public function preProcess($tokenData)
+ {
+ if(!is_array($tokenData))
+ {
+ return "参数错误";
+ }
+
+ $this->userInfo = json_decode($tokenData['userInfo'],true);
+
+ unset($tokenData['userInfo']);
+
+ $this->token = $tokenData;
+
+ return true;
+ }
+
+ //检查用户信息,如果没有用户自动注册,有用户就自动绑定。
+ public function makeUserStorage()
+ {
+ $uid = view::User('id');
+
+ if(is_numeric($uid) && $uid > 0)
+ {
+ $this->userid = $uid;
+ return "您已经登录,无需重复登录";
+ }
+
+ if(empty($this->userid))
+ {
+ $current_oauth_email = $this->userInfo['cstnetId'];
+
+ $user = new Users(TRUE);
+ $current = $user->userExists($current_oauth_email);
+
+ if($current === false)
+ //自动注册用户
+ {
+ $data = array(
+ $user->account->FieldUsername => $current_oauth_email,
+ $user->account->FieldEmail => $current_oauth_email,
+ $user->account->FieldPasword => 0,
+ $user->account->FieldRealname => $this->userInfo['truename'],
+ );
+
+ $dbh = new dbh();
+
+ $id = $dbh->insert($user->account->memberTable,$data,true);
+
+ //登录
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $data[$user->account->FieldUsername],
+ $user->account->FieldPasword => $data[$user->account->FieldPasword]
+ ));
+
+ $this->userid = $id;
+
+ return true;
+ }
+
+ //帮用户自动登录
+ else{
+
+ $user->account->storeLogin(array(
+ $user->account->FieldUsername => $current[$user->account->FieldUsername],
+ $user->account->FieldPasword => $current[$user->account->FieldPasword]
+ ),false);
+
+ $this->userid = $current[$user->account->FieldIndex];
+
+ return true;
+ }
+
+ }
+
+ }
+
+ //生成写入token表的数据
+ //有token记录就更新,没有再插入
+ public function makeTokenStorage()
+ {
+ $data = array(
+ 'access_token' => $this->token['access_token'],
+ 'refresh_token' => $this->token['refresh_token'],
+ 'expires_in' => $this->token['expires_in'],
+ 'userid' => $this->userid,
+ "response_data" => json_encode($this->userInfo,JSON_NUMERIC_CHECK),
+ "source" => "escience"
+ );
+
+ //查看用户用escience登录的记录是否存在
+ $sql = "SELECT * FROM {$this->table->oauth_token} WHERE userid={$this->userid} AND source='{$data['source']}' LIMIT 1";
+ $rs = $this->db->query($sql);
+ $row = $rs->fetch();
+
+ $dbh = new dbh();
+
+ if(isset($row['id']))
+ {
+ $status = $dbh->update($this->table->oauth_token,$data," id={$row['id']} AND userid={$this->userid} ");
+ if($status)
+ {
+ return true;
+ }else{
+ return "更新授权信息时发生错误,请重新登录";
+ }
+ }else{
+ $status = $dbh->insert($this->table->oauth_token,$data);
+ if($status)
+ {
+ return true;
+ }else{
+ return "记录授权信息时发生错误,请重新登录";
+ }
+ }
+
+ return true;
+ }
+
+
+}
diff --git a/application/module/Open/Handler/OauthHandler.php b/application/module/Open/Handler/OauthHandler.php
new file mode 100644
index 00000000..5a5da972
--- /dev/null
+++ b/application/module/Open/Handler/OauthHandler.php
@@ -0,0 +1,46 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function checkParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+
+
+ return true;
+ }
+
+
+
+}
diff --git a/application/module/Open/Handler/OpenHandler.php b/application/module/Open/Handler/OpenHandler.php
new file mode 100644
index 00000000..aa0dc5e0
--- /dev/null
+++ b/application/module/Open/Handler/OpenHandler.php
@@ -0,0 +1,46 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function checkParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ if(!is_array($data))
+ {
+ return "参数错误";
+ }
+
+
+
+ return true;
+ }
+
+
+
+}
diff --git a/application/module/Open/Listener/AppListener.php b/application/module/Open/Listener/AppListener.php
new file mode 100644
index 00000000..41628b18
--- /dev/null
+++ b/application/module/Open/Listener/AppListener.php
@@ -0,0 +1,28 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('app.checkParam', array($Handler, 'appCheckParam'), 100);
+ $events->attach('app.processData', array($Handler, 'appProcessData'), 100);
+ $events->attach('app.created', array($Handler, 'appCreated'), 100);
+ $events->attach('app.eidted', array($Handler, 'appEdited'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/ClientListener.php b/application/module/Open/Listener/ClientListener.php
new file mode 100644
index 00000000..2ff2ad3e
--- /dev/null
+++ b/application/module/Open/Listener/ClientListener.php
@@ -0,0 +1,26 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('tokenStorage', array($Handler, 'tokenAndDataStorage'), 100);
+ $events->attach('user.check', array($Handler, 'userCheck'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/OauthListener.php b/application/module/Open/Listener/OauthListener.php
new file mode 100644
index 00000000..65056b9d
--- /dev/null
+++ b/application/module/Open/Listener/OauthListener.php
@@ -0,0 +1,25 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new OauthHandler();
+ $events->attach('submit.checkParam', array($Handler, 'checkParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Listener/OpenListener.php b/application/module/Open/Listener/OpenListener.php
new file mode 100644
index 00000000..64a06730
--- /dev/null
+++ b/application/module/Open/Listener/OpenListener.php
@@ -0,0 +1,25 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ $events->attach('submit.checkParam', array($Handler, 'checkParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/OAuth2.php b/application/module/Open/OAuth2.php
new file mode 100644
index 00000000..f31d6f37
--- /dev/null
+++ b/application/module/Open/OAuth2.php
@@ -0,0 +1,31 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+
+ }
+
+ //用户使用谷歌账号登陆
+ public function googleClient()
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/application/module/Open/OAuth2/Server.php b/application/module/Open/OAuth2/Server.php
new file mode 100644
index 00000000..05508c18
--- /dev/null
+++ b/application/module/Open/OAuth2/Server.php
@@ -0,0 +1,76 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ //根据ID或者Client_id获得app的信息
+ public function getClientInfo($id)
+ {
+ if(empty($id))
+ {
+ return "无效参数";
+ }
+
+ if(is_numeric($id))
+ {
+ $field = "id";
+ }else{
+ $field = "client_id";
+ }
+
+ $sql = "SELECT * FROM {$this->table->oauth_clients} WHERE $field=? LIMIT 1";
+ $sth = $this->db->prepare($sql);
+ $sth->execute(array($id));
+ $row = $sth->fetch();
+
+ return $row;
+ }
+
+ //验证App
+ public function clientCredentials($client_id,$client_secret)
+ {
+
+ $client = $this->getClientInfo($client_id);
+
+ if(empty($client['id']))
+ {
+ return "此应用ID未被证实";
+ }
+
+ if($client['status'] == -1)
+ {
+ return "此应用已关闭";
+ }
+
+ if($client['client_secret'] !== $client_secret)
+ {
+ return "Invalid client secret";
+ }
+
+ return true;
+ }
+
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Open.php b/application/module/Open/Open.php
new file mode 100644
index 00000000..29534eb9
--- /dev/null
+++ b/application/module/Open/Open.php
@@ -0,0 +1,46 @@
+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 clientCredentials()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Server.php b/application/module/Open/Server.php
new file mode 100644
index 00000000..3406b448
--- /dev/null
+++ b/application/module/Open/Server.php
@@ -0,0 +1,37 @@
+config = \Zend_Registry::get('config');
+ if(empty($db))
+ {
+ $this->db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ if(empty($auth))
+ {
+ $this->auth = \Zend_Auth::getInstance();
+ if($this->auth->hasIdentity())
+ {
+ $this->user = $this->auth->getIdentity();
+ }
+ }else{
+ $this->auth = false;
+ }
+ }
+
+ public function getCode()
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/Source.php b/application/module/Open/Source.php
new file mode 100644
index 00000000..49730998
--- /dev/null
+++ b/application/module/Open/Source.php
@@ -0,0 +1,157 @@
+source = new stdClass();
+ $this->target = new stdClass();
+
+ $this->website = $website;
+
+ $this->initSourceConfig();
+ $this->initTarget();
+ }
+
+ //获得当前绑定的站点
+ public function getCurrentSite(){
+ return $this->website;
+ }
+
+ //设置绑定的站点
+ public function setCurrentSite($website){
+ $this->website = $website;
+ $this->initSourceConfig();
+ }
+
+ private function initSourceConfig()
+ {
+ if(!in_array($this->website,$this->sourceType))
+ {
+ return false;
+ }
+
+ // Escience
+ // passport.escience.cn
+ $this->source->escience = new stdClass();
+ $this->source->escience->param = array(
+ "id" => "client_id",
+ "secret" => "client_secret",
+ "code_response" => "response_type",
+ "grant_type" => "grant_type",
+ "callback" => "redirect_uri",
+ "code"=>"code"
+ );
+
+ //新浪微博(新浪通行证)
+ $this->source->sina = new stdClass();
+ $this->source->sina->param = array(
+
+ );
+
+ if($this->website == 'westdc'){
+ $this->source->escience->config = array(
+ 'id' => '71852',
+ 'secret' => 'ad7gd3jZgbzhQM6vIh9vPnQFZQoTGHZI',
+ 'index' => 'http://westdc.westgis.ac.cn',
+ 'callback' => 'http://westdc.westgis.ac.cn/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+ }
+
+ if($this->website == 'heihedata'){
+ $this->source->escience->config = array(
+ 'id' => '78969',
+ 'secret' => 'iTGKdCkUPakA2hza2TJ4XZ4cnwlh8Hqz',
+ 'index' => 'http://www.heihedata.org',
+ 'callback' => 'http://www.heihedata.org/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+ }
+
+ if($this->website == 'card'){
+ $this->source->escience->config = array(
+ 'id' => '58176',
+ 'secret' => 'ZM5dEFX5GpJC62IcJ3iajx51T9hzhJkQ',
+ 'index' => 'http://card.westgis.ac.cn/',
+ 'callback' => 'http://card.westgis.ac.cn/account/callback/type/escience',
+ 'other' => array(
+ 'theme'=>'full'
+ )
+ );
+ }
+
+ }
+
+ //Oauth2登录目标
+ /*
+ name : 名称
+ code : 获取code的url
+ token : 获取 token的url
+ code_response : 获取token时使用的参数值(配合$this->source->OBJECTIVE->param中的code_response使用
+ grant_type : 获得token的认证方式,按照oauth2标准,应该是authorization_code
+ */
+ private function initTarget(){
+ //中国科技网通行证
+ $this->target->escience = array(
+ 'name' => '中国科技网通行证',
+ 'code' => 'http://passport.escience.cn/oauth2/authorize',
+ 'token' => 'https://passport.escience.cn/oauth2/token',
+ 'code_response' => 'code',
+ 'grant_type' => 'authorization_code',
+ );
+
+ //新浪
+ $this->target->sina = array(
+ 'name' => '新浪微博',
+ 'code' => 'https://api.weibo.com/oauth2/authorize',
+ 'token' => '',
+ 'code_response' => 'code',
+ 'grant_type' => 'authorization_code'
+ );
+ }
+
+ //获得一个源
+ public function getSource($type = "")
+ {
+ if(empty($type))
+ {
+ return $this->source;
+ }else{
+ if(isset($this->source->$type))
+ {
+ return $this->source->$type;
+ }else{
+ return false;
+ }
+ }
+ }
+
+ //获得Oauth2登录模板
+ public function getTarget($type = "")
+ {
+ if(empty($type))
+ {
+ return $this->target;
+ }else{
+ if(isset($this->target->$type))
+ {
+ return $this->target->$type;
+ }else{
+ return false;
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Open/app.php b/application/module/Open/app.php
deleted file mode 100644
index 23d3b377..00000000
--- a/application/module/Open/app.php
+++ /dev/null
@@ -1,45 +0,0 @@
-load();
- }
-
- //获得用户创建的app
- public function getUserApp($uid = 0)
- {
- if(empty($uid))
- {
- $uid = $this->user->id;
- }
-
- $sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE user_id=".$this->user->id;
- $rs = $this->db->query($sql);
- $rows = $rs->fetchAll();
-
- return $rows;
- }
-
- //获得某个App的信息
- public function getAppInfo($id)
- {
- if(empty($id))
- {
- return false;
- }
- $sql = "SELECT * FROM ".$this->tbl_oauth_clients." WHERE id=".$id;
- $rs = $this->db->query($sql);
- $rows = $rs->fetch();
-
- return $rows;
- }
-
-
-}
\ No newline at end of file
diff --git a/application/module/Open/open.php b/application/module/Open/open.php
deleted file mode 100644
index 8a6445df..00000000
--- a/application/module/Open/open.php
+++ /dev/null
@@ -1,66 +0,0 @@
-config = \Zend_Registry::get('config');
- if(empty($db))
- {
- $this->db = \Zend_Registry::get('db');
- }else{
- $this->db = $db;
- }
-
- if(empty($auth))
- {
- $this->auth = \Zend_Auth::getInstance();
- if($this->auth->hasIdentity())
- {
- $this->user = $this->auth->getIdentity();
- }
- }else{
- $this->auth = false;
- }
- }
-
- //检查用户资料完整性
- public function checkinfo()
- {
- 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;
- }
-
-}
\ No newline at end of file
diff --git a/application/module/Open/server.php b/application/module/Open/server.php
deleted file mode 100644
index ee0b7408..00000000
--- a/application/module/Open/server.php
+++ /dev/null
@@ -1,50 +0,0 @@
-config = \Zend_Registry::get('config');
- if(empty($db))
- {
- $this->db = \Zend_Registry::get('db');
- }else{
- $this->db = $db;
- }
-
- if(empty($auth))
- {
- $this->auth = \Zend_Auth::getInstance();
- if($this->auth->hasIdentity())
- {
- $this->user = $this->auth->getIdentity();
- }
- }else{
- $this->auth = false;
- }
- }
-
- public function bootstrap()
- {
- $dsn = "pgsql:dbname={$this->config->db->params->dbname};host={$this->config->db->params->host}";
-
- $storage = new \OAuth2\Storage\Pdo(array('dsn' => $dsn, 'username' => $this->config->db->params->username, 'password' => $this->config->db->params->password));
-
- $server = new \OAuth2\Server($storage);
-
- $server->addGrantType(new \OAuth2\GrantType\ClientCredentials($storage));
-
- $server->addGrantType(new \OAuth2\GrantType\AuthorizationCode($storage));
-
- //应用授权
- //$server->handleTokenRequest(OAuth2\Request::createFromGlobals())->send();
-
- return $server;
- }
-
-}
\ No newline at end of file
diff --git a/application/module/Order/Event/ApplicationEvent.php b/application/module/Order/Event/ApplicationEvent.php
new file mode 100644
index 00000000..b8031621
--- /dev/null
+++ b/application/module/Order/Event/ApplicationEvent.php
@@ -0,0 +1,7 @@
+db = \Zend_Registry::get('db');
+ }else{
+ $this->db = $db;
+ }
+
+ $this->config = \Zend_Registry::get('config');
+ $this->table = new Table();
+ }
+
+ public function applicationCheckParam(\Zend_EventManager_Event $e)
+ {
+ $data = $e->getParam('data');
+
+ return true;
+ }
+
+}
diff --git a/application/module/Order/Listener/ApplicationListener.php b/application/module/Order/Listener/ApplicationListener.php
new file mode 100644
index 00000000..3bfa7c7b
--- /dev/null
+++ b/application/module/Order/Listener/ApplicationListener.php
@@ -0,0 +1,25 @@
+event = new \Zend_EventManager_EventManager();
+ }
+
+ public function attach(\Zend_EventManager_EventCollection $events)
+ {
+ $Handler = new Handler();
+ //$events->attach('app.checkParam', array($Handler, 'appCheckParam'), 100);
+ }
+
+ public function detach(\Zend_EventManager_EventCollection $events)
+ {
+
+ }
+
+}
\ No newline at end of file
diff --git a/application/module/Order/listener/ManagerEvents.php b/application/module/Order/Listener/ManagerEvents.php
similarity index 84%
rename from application/module/Order/listener/ManagerEvents.php
rename to application/module/Order/Listener/ManagerEvents.php
index 2fedd65f..c3e370aa 100644
--- a/application/module/Order/listener/ManagerEvents.php
+++ b/application/module/Order/Listener/ManagerEvents.php
@@ -1,5 +1,5 @@
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 passed()
+ {
+ $select=$this->db->select();
+ $select ->from('offlineapp')
+ ->where('ts_approved is not null')
+ ->where('pdflink is not null')
+ ->where('status>=0')
+ ->order('ts_created desc');
+
+ if(!empty($this->keyword))
+ {
+ $select ->where(" (username LIKE '%{$this->keyword}%' OR
+ unit LIKE '%{$this->keyword}%' OR
+ project_id LIKE '%{$this->keyword}%' OR
+ project_type LIKE '%{$this->keyword}%' OR
+ project_leader LIKE '%{$this->keyword}%' OR
+ project LIKE '%{$this->keyword}%' )");
+ }
+
+ return $select;
+ }
+}
\ No newline at end of file
diff --git a/application/module/Order/Manager/Offlineapp.php b/application/module/Order/Manager/Offlineapp.php
index 74325e73..15a15168 100644
--- a/application/module/Order/Manager/Offlineapp.php
+++ b/application/module/Order/Manager/Offlineapp.php
@@ -3,7 +3,7 @@ namespace Order\Manager;
use Helpers\View as view;
use Helpers\dbh;
-use Order\listener\ManagerListener;
+use Order\Listener\ManagerListener;
class Offlineapp
{
@@ -75,15 +75,15 @@ class Offlineapp
";
$rs = $this->db->query($sql);
return $rs->fetchAll();
- }//
-
- //判断是否存在wsn数据申请
- public function hasWsnData($id)
- {
- $sql="select count(d.id) as wsn from dataorder d left join dataservice s on d.uuid=s.uuid where d.offlineappid=$id and s.service_type in (1,2) and position('waterwsn' in s.service_url)>0 and d.selection is not null";
- $rs=$this->db->query($sql);
- $row=$rs->fetch();
- return $row['wsn'];
+ }//
+
+ //判断是否存在wsn数据申请
+ public function hasWsnData($id)
+ {
+ $sql="select count(d.id) as wsn from dataorder d left join dataservice s on d.uuid=s.uuid where d.offlineappid=$id and s.service_type in (1,2) and position('waterwsn' in s.service_url)>0 and d.selection is not null";
+ $rs=$this->db->query($sql);
+ $row=$rs->fetch();
+ return $row['wsn'];
}
//重置申请表
@@ -100,7 +100,7 @@ class Offlineapp
@unlink($row['applicationform']);
}
- if($this->db->exec("UPDATE offlineapp SET applicationform=NULL WHERE id=$id")>0)
+ if($this->db->exec("UPDATE offlineapp SET applicationform=NULL,status=2 WHERE id=$id")>0 && $this->db->exec("UPDATE dataorder SET status=2 WHERE offlineappid=$id"))
{
@$this->events()->trigger('offlineapp.AppFormReseted', $this, compact('id'));
return true;
diff --git a/application/module/Order/mount/ManagerOperate.php b/application/module/Order/Mount/ManagerOperate.php
similarity index 89%
rename from application/module/Order/mount/ManagerOperate.php
rename to application/module/Order/Mount/ManagerOperate.php
index f2cb243d..b540321c 100644
--- a/application/module/Order/mount/ManagerOperate.php
+++ b/application/module/Order/Mount/ManagerOperate.php
@@ -1,5 +1,5 @@
getMessage());
+ view::Dump($e->getMessage());
}
return true;
diff --git a/application/module/Order/mount/PdfForm.php b/application/module/Order/Mount/PdfForm.php
similarity index 90%
rename from application/module/Order/mount/PdfForm.php
rename to application/module/Order/Mount/PdfForm.php
index 5c83af22..52024d4a 100644
--- a/application/module/Order/mount/PdfForm.php
+++ b/application/module/Order/Mount/PdfForm.php
@@ -1,10 +1,10 @@
0)
{
diff --git a/application/module/Reference/Reference.php b/application/module/Reference/Reference.php
index 576637ff..a38a9627 100644
--- a/application/module/Reference/Reference.php
+++ b/application/module/Reference/Reference.php
@@ -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);
@@ -228,6 +247,66 @@ class Reference
$rs=$this->db->query($sql);
return $rs->fetchAll();
}
+
+ //Get WestDC references
+ public function fetchWestdcReferences()
+ {
+ $wheresql = array();
+ $wheresql[]=" r.uuid='e31f5ea7-a4af-4ae3-9ac1-1a84132c4338' ";
+ if(!empty($this->keyword))
+ {
+ $wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
+ }
+ if(count($wheresql)>0)
+ {
+ $wheresql = " WHERE ".join(" AND ",$wheresql);
+ }else{
+ $wheresql = "";
+ }
+
+ if(empty($this->order))
+ {
+ $order = "ref.year,ref.title";
+ }else{
+ $order = "ref.{$this->order} {$this->sort}";
+ }
+
+ $sql="select distinct ref.* from mdref r left join {$this->table->reference} ref on r.refid=ref.id
+ $wheresql
+ ORDER BY $order";
+ $rs=$this->db->query($sql);
+ return $rs->fetchAll();
+ }
+
+ //Get references which need to deal with
+ public function fetchTodoReferences()
+ {
+ $wheresql = array();
+ $wheresql[]=" ref.id not in (select distinct refid from mdref) ";
+ if(!empty($this->keyword))
+ {
+ $wheresql[] = " (ref.title LIKE '%{$this->keyword}%' OR ref.reference LIKE '%{$this->keyword}%') ";
+ }
+ if(count($wheresql)>0)
+ {
+ $wheresql = " WHERE ".join(" AND ",$wheresql);
+ }else{
+ $wheresql = "";
+ }
+
+ if(empty($this->order))
+ {
+ $order = "ref.year,ref.title";
+ }else{
+ $order = "ref.{$this->order} {$this->sort}";
+ }
+
+ $sql="select distinct ref.* from {$this->table->reference} ref
+ $wheresql
+ ORDER BY $order";
+ $rs=$this->db->query($sql);
+ return $rs->fetchAll();
+ }
//单条文献的信息
public function getOneReferenceData($id)
@@ -393,10 +472,11 @@ class Reference
public function referenceType()
{
return array(
- 0 => '作者建议文献',
+ 0 => '相关文献',//作者建议的文献或数据中心建议的文献
1 => '施引文献',
2 => '参考文献',
- 3 => '多篇文献'
+ 3 => '多篇文献',
+ 4 => '专题文献'
);
}
@@ -456,4 +536,65 @@ 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;
+ }
+
+ //获得标签
+ public function getTagsByReference($id,$single = false)
+ {
+ if(is_numeric($id))
+ {
+ $sql = "SELECT * FROM {$this->table->reference_tag} WHERE id=$id";
+ $rs = $this->db->query($sql);
+ if(!$single)
+ {
+ return $rs->fetchAll();
+ }else{
+ foreach($rows = $rs->fetchAll() as $k=>$v)
+ {
+ $rows[$k] = (string)$v['tag'];
+ }
+ return $rows;
+ }
+ }
+
+ return;
+ }
+
}
diff --git a/application/module/Reference/Ris.php b/application/module/Reference/Ris.php
index 849430cc..72da0dc3 100644
--- a/application/module/Reference/Ris.php
+++ b/application/module/Reference/Ris.php
@@ -78,10 +78,15 @@ class Ris
//上传RIS文件
public function uploadRisFile()
{
+ if(!isset($_FILES['Filedata']))
+ {
+ return;
+ }
+
$file = $_FILES['Filedata'];
if (@is_uploaded_file($file['tmp_name']) === false) {
- return false;
+ return;
}
return $file;
@@ -90,7 +95,12 @@ class Ris
//文本直接导入
public function loadRisText()
{
- $text = $_REQUEST['ristest'];
+ if(!isset($_REQUEST['ristext']))
+ {
+ return;
+ }
+
+ $text = $_REQUEST['ristext'];
return $text;
}
@@ -140,7 +150,7 @@ class Ris
}
//将解析好的ris数据写入数据库
- public function pushToDataTable($data,$create_ref=false){
+ public function pushToDataTable($data){
if(!is_array($data) || count($data) < 1)
{
@@ -160,27 +170,22 @@ class Ris
@$author = $ref['author'];
$ref['ris'] = $this->makeRisData(array(0=>$this->ris_records[$k]));
- $reference = $this->makeReferenceFlag($ref);
-
- if ($create_ref)
- {
- $ref['reference'] = $reference;
- }else{
- $ref['reference'] = $ref['title'].'---'.date("Y-m-d H:i:s").".".microtime().rand();
- }
-
+
$results = $this->events()->trigger('checkLoad', $this, compact('ref'));
$id = $results->bottom();
- $this->unsetVar($ref);
-
if ($id > 0)
{
+ $this->unsetVar($ref);
$this->events()->trigger('deleteAuthor', $this, compact('id'));
$this->events()->trigger('deleteTag', $this, compact('id'));
+ unset($ref['reference']);
+
$dbh->update($this->table->reference,$ref," id=$id ");
} else {
+ $ref['reference'] = $this->makeReferenceFlag($ref);
+ $this->unsetVar($ref);
$id = $dbh->insert($this->table->reference,$ref,true);
}
@@ -189,6 +194,43 @@ class Ris
}
}
+ //更新单个reference的RIS
+ public function updateWithRis($id,$ref)
+ {
+ if(empty($id) || !is_numeric($id))
+ {
+ return false;
+ }
+
+ if (is_null($ref['title']))
+ {
+ return;
+ }
+
+ @$tags = $ref['tags'];
+ @$author = $ref['author'];
+
+ $ref['ris'] = $this->makeRisData(array(0=>$this->ris_records[0]));
+
+ $this->events()->trigger('deleteAuthor', $this, compact('id'));
+ $this->events()->trigger('deleteTag', $this, compact('id'));
+
+ $this->unsetVar($ref);
+ if(isset($ref['reference'])) unset($ref['reference']);
+
+ $this->dbh = $dbh = new dbh();
+
+ if($dbh->update($this->table->reference,$ref," id=$id "))
+ {
+ $this->insertTags($id,$tags);
+ $this->insertAuthor($id,$author);
+ return true;
+ }else{
+ return false;
+ }
+
+ }
+
//写入标签
public function insertTags($id,$tags){
if(is_array($tags) && count($tags) > 0)
@@ -217,6 +259,11 @@ class Ris
}
return true;
}else{
+ if(is_string($author))
+ {
+ $author_splited = $this->splitAuthor($author);
+ $this->dbh->insert($this->table->reference_author,array('id'=>$id , 'lastname'=>$author_splited['lastname'] , 'firstname'=>$author_splited['firstname'] , 'place'=>0 ));
+ }
return false;
}
}
@@ -230,17 +277,23 @@ class Ris
//创建reference 字段
public function makeReferenceFlag($ref){
- $str = array();
- isset($ref['author']) ? $str[] = $ref['author']:"";
- isset($ref['title']) ? $str[] = $ref['title']:"";
- isset($ref['year']) ? $str[] = $ref['year']:"";
- isset($ref['volume']) ? $str[] = $ref['volume']:"";
- isset($ref['issue']) ? $str[] = $ref['issue']:"";
- isset($ref['pages']) ? $str[] = $ref['pages']:"";
- isset($ref['endpage'])? $str[] = $ref['endpage']:"";
- isset($ref['doi']) ? $str[] = $ref['doi'] : "";
+ $str='';
+ if(is_array($ref['author']) && count($ref['author']) > 0)
+ {
+ $str .= join(', ',$ref['author']).'. ';
+ } else if (is_string($ref['author'])) {
+ $str .= $ref['author'].'. ';
+ }
+ $str .= $ref['title'].'. ';
+ $str .= $ref['publisher'].', ';
+ isset($ref['year']) ? $str .= $ref['year'].', ':"";
+ isset($ref['volume']) ? $str .= $ref['volume']:"";
+ isset($ref['issue']) ? $str .= '('.$ref['issue'].')':"";
+ isset($ref['pages']) ? $str .= ':'.$ref['pages']:"";
+ isset($ref['endpage'])? $str .= '-'.$ref['endpage']:"";
+ isset($ref['doi']) ? $str .= '. doi:'.$ref['doi'] : "";
- return join(",",$str);
+ return $str;
}
//卸载不需要的变量
diff --git a/application/module/Reference/RisOutput.php b/application/module/Reference/RisOutput.php
new file mode 100644
index 00000000..44b7151f
--- /dev/null
+++ b/application/module/Reference/RisOutput.php
@@ -0,0 +1,153 @@
+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 preRead($mode = "all")
+ {
+ if($mode == "all")
+ {
+ $sql = "SELECT * FROM {$this->table->reference} where length(ris)<10 or ris is null ORDER BY year DESC,title ASC,id ASC";
+ $rs = $this->db->query($sql);
+ return $rs->fetchAll();
+ }
+
+
+ }//preRead
+
+ //将数据组成RIS数组格式
+ public function processArrayDataToRisData($arrayData,$risPrior = true,$mixAuthor = true,$mixTags = true)
+ {
+ if(!is_array($arrayData))
+ {
+ return false;
+ }
+
+ $risData = array();
+
+ if($risPrior === true)
+ {
+ $risReader = new RISReader();
+ }
+
+ $this->ris = new Ris();
+ $this->attr = $this->ris->attr;
+ $this->attr_flip = array_flip($this->ris->attr);
+ unset($this->ris);
+
+ $this->reference = new Reference();
+
+ foreach($arrayData as $k=>$v)
+ {
+ $risData[$k] = $this->transformToRis($v);
+ if($mixAuthor === true || $mixTags === true)
+ {
+ if($mixAuthor === true)
+ {
+ $author = $this->reference->getAuthorByReference($v['id'],true);
+ if(is_array($author) && count($author)>0)
+ {
+ $risData[$k] = array_merge($risData[$k],array("AU"=>$author));
+ }
+ unset($author);
+ }//mixAuthor
+
+ if($mixTags === true)
+ {
+ $tags = $this->reference->getTagsByReference($v['id'],true);
+ if(is_array($tags) && count($tags) > 0)
+ {
+ $risData[$k] = array_merge($risData[$k],array("KW"=>$tags));
+ }
+ unset($tags);
+ }
+ }
+
+ if(!is_array($risData[$k]) || count($risData[$k]) < 1)
+ {
+ unset($risData[$k]);
+ }
+
+ unset($arrayData[$k]);
+ }
+
+ return $risData;
+ }//processArrayDataToRisData
+
+ //单条记录的整编
+ public function transformToRis($record)
+ {
+ $arr = array();
+
+ foreach($record as $k=>$v)
+ {
+ if(!empty($v))
+ {
+ if(isset($this->attr_flip[$k]))
+ {
+ //echo $k ."-". $this->attr_flip[$k] . '-' .$v;
+ //echo "
- 结束时间:
- 日期:
本数据的引用
-
diff --git a/htdocs/js/lib/custom/models/dataservice.js b/htdocs/js/lib/custom/models/dataservice.js
index e7443602..3055af00 100644
--- a/htdocs/js/lib/custom/models/dataservice.js
+++ b/htdocs/js/lib/custom/models/dataservice.js
@@ -168,6 +168,8 @@ westdc.dataservice.wsn = {
this.selects = "";
this.uls = new Array();
+ this.count = 0;
+ this.first = 0;
for(i in data.data)
{
this.input = new Array();
@@ -185,12 +187,32 @@ westdc.dataservice.wsn = {
+ ''
+ '
"; + $arr[$this->attr_flip[$k]] = array(0=>$v); + } + } + } + //echo "
"; + return $arr; + }//transformToRis + + //输出成文件 + public function output($risData) + { + $risWirte = new RISWriter(); + return @$risWirte->writeRecords($risData); + }//output +} diff --git a/application/module/Statistics/User.php b/application/module/Statistics/User.php new file mode 100644 index 00000000..c7b69c04 --- /dev/null +++ b/application/module/Statistics/User.php @@ -0,0 +1,130 @@ +db = \Zend_Registry::get('db'); + }else{ + $this->db = $db; + } + + $this->config = \Zend_Registry::get('config'); + + $this->table = new \Helpers\Table(); + } + + public function ThisYear(){ + return date("Y",time()); + } + + //按年统计新用户 + public function getNewUsersByYear($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + if($year == -1) + { + $sql = "select count(id),extract(year from ts_created) + from users + group by extract(year from ts_created) + order by date_part"; + }else{ + $sql = "select count(id),extract(year from ts_created) + from users + where extract(year from ts_created)='$year' + group by extract(year from ts_created)"; + } + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //按月统计新用户 + public function getNewUsersByMonth($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = "select count(id),extract(month from ts_created) + from users + where extract(year from ts_created)=$year + group by extract(month from ts_created) + order by date_part"; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //月均注册量 + public function getAverageSingupByMonth($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = "select round(count(id)/12) as count,extract(year from ts_created) + from users + where extract(year from ts_created)='$year' + group by extract(year from ts_created)"; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //总用户量 + public function getTotal($year = 0) + { + if(empty($year)) + { + $year = $this->ThisYear(); + } + + $sql = ""; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + + //平均申请数 + public function getAverageApplicationTimes($times = 1) + { + if(empty($year)) + { + $times = 1; + } + + $sql = ""; + + $rs = $this->db->query($sql); + $rows = $rs->fetchAll(); + return $rows; + } + +} diff --git a/data/doc.xsl b/data/doc.xsl index 3414eabc..53882637 100644 --- a/data/doc.xsl +++ b/data/doc.xsl @@ -111,6 +111,10 @@
观测点:'+data.data[i].name+'
可下载的变量: '+ this.input.join("") + this.timemap + ''; + }else{ + this.allcontrol = ""; + } + this.HTML = '
此数据还在评审过程中,我们真切地邀请您参加此数据的评审,以便我们能尽快发布此数据!评审
+ +数据评论
+