<%PubMed(CreateNew)%> +Manually add paper <%parsedinclude(paging.inc)%> @@ -293,7 +294,7 @@ onclick="window.open(this.href);return false;" -
From 6ed2c565455ca6cd2c9470ced180bb4a700ae5c8 Mon Sep 17 00:00:00 2001
From: kmorimatsu ' . _ERROR_DISALLOWED . ' Error: ' . _ERROR_BADTICKET . '
'.
@@ -16,8 +16,9 @@ class NP_PubMed extends NucleusPlugin {
function getTableList() { return array(sql_table('plugin_pubmed_references'), sql_table('plugin_pubmed_manuscripts')); }
function install(){
global $member;
- $this->createOption('droptable','Drop table when uninstall?','yesno','no');
$this->createOption('lastquerytime','hidden option','text','0','access=hidden');
+ $this->createOption('lastmanualpmid','hidden option','text','1000000000','access=hidden');
+ $this->createOption('droptable','Drop table when uninstall?','yesno','no');
$this->createOption('email','E-mail address to be sent to PubMed search site (set blank if not use):','text',$member->getEmail());
sql_query('CREATE TABLE IF NOT EXISTS '.sql_table('plugin_pubmed_references').' ('.
' id int(11) not null auto_increment,'.
@@ -373,6 +374,7 @@ END;
htmlspecialchars($text).'';
break;
case 'edit':
+ if (!$member->isLoggedIn()) return;
$itemid=(int)$item->itemid;
$text=$p1?'manuscript management':htmlspecialchars($p1,ENT_QUOTES);
$width=(int)$p2;
diff --git a/NP_PubMed/trunk/pubmed/index.php b/NP_PubMed/trunk/pubmed/index.php
index ab0ca51..ffe7488 100644
--- a/NP_PubMed/trunk/pubmed/index.php
+++ b/NP_PubMed/trunk/pubmed/index.php
@@ -5,8 +5,8 @@ require('../../../config.php');
// An instance will be created at the end of this file
class PubMedAdmin extends BaseActions {
- var $oPluginAdmin,$plugin;
- var $blogid;
+ private $oPluginAdmin,$plugin;
+ private $blogid;
function __construct(){
if (method_exists($this,'BaseActions')) $this->BaseActions();
@@ -19,9 +19,15 @@ class PubMedAdmin extends BaseActions {
if (!($this->blogid=intPostVar('blogid'))) $this->blogid=intGetVar('blogid');
$CONF['ItemURL']=quickQuery('SELECT burl as result FROM '.sql_table('blog'). ' WHERE bnumber='.(int)$this->blogid);
- // Check if there is right to maintain the blog by member.
- if (!$member->isLoggedIn() || !$member->teamRights($this->blogid) || !$manager->existsBlogID($this->blogid))
- {
+ // Check if there is right to maintain the blog or the manuscript.
+ $ok=true;
+ if (!$member->isLoggedIn()) $ok=false;
+ if (!$member->CanLogin()) $ok=false;
+ if ($this->blogid) {
+ if (!$member->teamRights($this->blogid)) $ok=false;
+ if (!$manager->existsBlogID($this->blogid)) $ok=false;
+ }
+ if (!$ok) {
$this->oPluginAdmin->start();
echo '' .
+ echo '
' .
'Manuscript management' . "
\n";
break;
default:
@@ -340,8 +345,7 @@ class PubMedAdmin extends BaseActions {
$mname=$this->_checkmanuscriptname(postVar('manuscriptname'));
if ($mname) sql_query('INSERT INTO '.sql_table('plugin_pubmed_manuscripts').' SET'.
' userid='.(int)$mid.','.
- ' manuscriptname="'.addslashes($mname).'"'.
- ' sorttext="authorname"');
+ ' manuscriptname="'.addslashes($mname).'"');
return $this->action_manuscriptlist();
}
private function _getSortMethod($tempname){
@@ -423,6 +427,143 @@ class PubMedAdmin extends BaseActions {
$this->contents=array('mid'=>$manuscriptid,'mname'=>$mname);
$this->_showUsingArray('editmanuscript',$array);
}
+ function action_addmanually(){
+ global $manager;
+ if (count($_POST)) {
+ // Add item with the defined PMID
+ $pmid=intPostVar('pmid');
+ // Determine author list
+ $author=requestArray('author');
+ $authorf=requestArray('authorf');
+ $authorm=requestArray('authorm');
+ $authors=array();
+ foreach($author as $key=>$value){
+ if (!strlen($value)) break;
+ $a=$author[$key];
+ $f=$authorf[$key];
+ $m=$authorm[$key];
+ $i=substr($f,0,1).substr($m,0,1);
+ $authors[$key]=array(
+ 'LastName'=>$a,
+ 'ForeName'=>$f,
+ 'Initials'=>$i);
+ }
+ ksort($authors);
+ // Construct Article
+ if (($year=intPostVar('year'))==0) $year='???';
+ if (strlen($journalname=postVar('journal'))==0) $journalname='???';
+ if (strlen($volume=postVar('volume'))==0) $volume='???';
+ if (strlen($pages=postVar('pages'))==0) $pages='???';
+ if (strlen($title=postVar('title'))==0) $title='???';
+ if (strlen($abstract=postVar('abstract'))==0) $abstract='???';
+ $journal=array(
+ 'ISOAbbreviation'=>$journalname,
+ 'JournalIssue'=>array(
+ 'Volume'=>$volume,
+ 'PubDate'=>array('Year'=>$year)
+ )
+ );
+ $article=array(
+ 'Journal'=>$journal,
+ 'ArticleTitle'=>$title,
+ 'Pagination'=>array('MedlinePgn'=>$pages),
+ 'AuthorList'=>array('Author'=>$authors)
+ );
+ // Construct XML data as more
+ $medline=array(
+ 'PMID'=>$pmid,
+ 'Article'=>$article
+ );
+ $more=''.htmlspecialchars($abstract).'';
+ $more.=" ';
+ // Construct body
+ $body="PMID: $pmid\n";
+ $body.=' \n";
+ $body.=''.htmlspecialchars($journalname).
+ ' '.htmlspecialchars($volume).
+ ' '.htmlspecialchars($pages)."\n";
+ $body.=''.htmlspecialchars($title).'';
+ // Construct title
+ switch($n){
+ case 1:
+ $title=$authors[1]['LastName'];
+ break;
+ case 2:
+ $title=$authors[1]['LastName'].' and '.$authors[2]['LastName'];
+ break;
+ default:
+ $title=$authors[1]['LastName'].' et al.';
+ break;
+ }
+ $title=htmlspecialchars($title." ($year) $journalname");
+ // Construct category options
+ $defcatid=(int)cookieVar($CONF['CookiePrefix'] . 'NP_PubMed_defcatid');
+ if (!$defcatid) {
+ $blog=$manager->getBlog($this->blogid);
+ $defcatid=$blog->getDefaultCategory();
+ }
+ $res=sql_query('SELECT * FROM '.sql_table('category').
+ ' WHERE cblog='.(int)$this->blogid.' ORDER BY cname ASC');
+ $array=array();
+ while($row=mysql_fetch_assoc($res)){
+ $row['selected']= ($row['catid']==$defcatid);
+ $array[]=$row;
+ }
+ // parse
+ $this->contents=array('title'=>$title,'body'=>$body,'more'=>$more);
+ $this->_showUsingArray('addmanuallyconfirm',$array);
+ return;
+ }
+ // Decide PMID
+ $pmid=1+$this->plugin->getOption('lastmanualpmid');
+ if ($pmid<1000000000) $pmid=1000000001;
+ $i=1;
+ while(quickQuery('SELECT count(*) as result from '.sql_table('item').
+ ' WHERE iblog='.(int)$this->blogid.
+ ' AND ibody LIKE "%'.(int)$pmid.'%"') ){
+ $this->plugin->setOption('lastmanualpmid',$pmid);
+ $pmid+=$i;
+ $i+=rand(1,$i);
+ }
+ // Get the number of authors
+ $numauthor=intGetVar('numauthor');
+ if (!$numauthor) $numauthor=3;
+ $array=array();
+ for ($i=1;$i<=$numauthor;$i++) {
+ $array[]=array('i'=>$i);
+ }
+ // parse
+ $this->contents=array('pmid'=>$pmid,'i'=>$numauthor,'numauthor'=>$numauthor*2);
+ $this->_showUsingArray('addmanually',$array);
+ }
+ function _convert2xml($key,$value,$nest=0){
+ if (!preg_match('/^[a-zA-Z0-9_]+$/',$key)) exit;
+ if (!is_array($value)) {
+ $value=str_replace(array('<','>'),array('>','<'),$value);
+ return str_repeat(' ',$nest)."<$key>$value$key>\n";
+ }
+ $xml='';
+ foreach ($value as $k=>$v) {
+ if (is_numeric($k)) $xml.=$this->_convert2xml($key,$v,$nest+1);
+ else {
+ if ($xml=='') $xml=str_repeat(' ',$nest)."<$key>\n";
+ $xml.=$this->_convert2xml($k,$v,$nest+1);
+ }
+ }
+ if (!is_numeric($k)) $xml.=str_repeat(' ',$nest)."$key>\n";
+ return $xml;
+ }
}
new PubMedAdmin;
diff --git a/NP_PubMed/trunk/pubmed/index.xml b/NP_PubMed/trunk/pubmed/index.xml
index ccdf69c..d07376b 100644
--- a/NP_PubMed/trunk/pubmed/index.xml
+++ b/NP_PubMed/trunk/pubmed/index.xml
@@ -242,4 +242,124 @@ Are you sure?
]]>
+
+
+
+