function getName() { return 'NP_PubMed'; }\r
function getMinNucleusVersion() { return 330; }\r
function getAuthor() { return 'Katsumi'; }\r
- function getVersion() { return '0.2.1'; }\r
+ function getVersion() { return '0.2.2'; }\r
function getURL() {return 'http://japan.nucleuscms.org/wiki/plugins:authors:katsumi';}\r
function getDescription() {\r
return $this->getName().' plugin<br />'.\r
function getTableList() { return array(sql_table('plugin_pubmed_references'), sql_table('plugin_pubmed_manuscripts')); }\r
function install(){\r
global $member;\r
- $this->createOption('droptable','Drop table when uninstall?','yesno','no');\r
$this->createOption('lastquerytime','hidden option','text','0','access=hidden');\r
+ $this->createOption('lastmanualpmid','hidden option','text','1000000000','access=hidden');\r
+ $this->createOption('droptable','Drop table when uninstall?','yesno','no');\r
$this->createOption('email','E-mail address to be sent to PubMed search site (set blank if not use):','text',$member->getEmail());\r
sql_query('CREATE TABLE IF NOT EXISTS '.sql_table('plugin_pubmed_references').' ('.\r
' id int(11) not null auto_increment,'.\r
htmlspecialchars($text).'</a>';\r
break;\r
case 'edit':\r
+ if (!$member->isLoggedIn()) return;\r
$itemid=(int)$item->itemid;\r
$text=$p1?'manuscript management':htmlspecialchars($p1,ENT_QUOTES);\r
$width=(int)$p2;\r
// An instance will be created at the end of this file\r
\r
class PubMedAdmin extends BaseActions {\r
- var $oPluginAdmin,$plugin;\r
- var $blogid;\r
+ private $oPluginAdmin,$plugin;\r
+ private $blogid;\r
function __construct(){\r
if (method_exists($this,'BaseActions')) $this->BaseActions();\r
\r
if (!($this->blogid=intPostVar('blogid'))) $this->blogid=intGetVar('blogid');\r
$CONF['ItemURL']=quickQuery('SELECT burl as result FROM '.sql_table('blog'). ' WHERE bnumber='.(int)$this->blogid);\r
\r
- // Check if there is right to maintain the blog by member.\r
- if (!$member->isLoggedIn() || !$member->teamRights($this->blogid) || !$manager->existsBlogID($this->blogid))\r
- {\r
+ // Check if there is right to maintain the blog or the manuscript.\r
+ $ok=true;\r
+ if (!$member->isLoggedIn()) $ok=false;\r
+ if (!$member->CanLogin()) $ok=false;\r
+ if ($this->blogid) {\r
+ if (!$member->teamRights($this->blogid)) $ok=false;\r
+ if (!$manager->existsBlogID($this->blogid)) $ok=false;\r
+ }\r
+ if (!$ok) {\r
$this->oPluginAdmin->start();\r
echo '<p>' . _ERROR_DISALLOWED . '</p>';\r
$this->oPluginAdmin->end();\r
\r
// If some data is/are posted, check the ticket.\r
// Therefore, POST method must be used to change important parameter(s).\r
- if (!isset($_POST)) $_POST=&$HTTP_POST_VARS;\r
if (count($_POST) && !$manager->checkTicket()) {\r
$this->oPluginAdmin->start();\r
echo '<p class="error">Error: ' . _ERROR_BADTICKET . '</p>';\r
$this->oPluginAdmin->start();\r
switch(getVar('action')) {\r
case 'manuscriptlist':\r
- echo '<h2><a href="'.$this->plugin->getAdminURL().'?blogid='.\r
- (int)$this->blogid.'&action=manuscriptlist">' . \r
+ echo '<h2><a href="'.$this->plugin->getAdminURL().\r
+ '?action=manuscriptlist">' . \r
'Manuscript management' . "</a></h2>\n";\r
break;\r
default:\r
$mname=$this->_checkmanuscriptname(postVar('manuscriptname'));\r
if ($mname) sql_query('INSERT INTO '.sql_table('plugin_pubmed_manuscripts').' SET'.\r
' userid='.(int)$mid.','.\r
- ' manuscriptname="'.addslashes($mname).'"'.\r
- ' sorttext="authorname"');\r
+ ' manuscriptname="'.addslashes($mname).'"');\r
return $this->action_manuscriptlist();\r
}\r
private function _getSortMethod($tempname){\r
$this->contents=array('mid'=>$manuscriptid,'mname'=>$mname);\r
$this->_showUsingArray('editmanuscript',$array);\r
}\r
+ function action_addmanually(){\r
+ global $manager;\r
+ if (count($_POST)) {\r
+ // Add item with the defined PMID\r
+ $pmid=intPostVar('pmid');\r
+ // Determine author list\r
+ $author=requestArray('author');\r
+ $authorf=requestArray('authorf');\r
+ $authorm=requestArray('authorm');\r
+ $authors=array();\r
+ foreach($author as $key=>$value){\r
+ if (!strlen($value)) break;\r
+ $a=$author[$key];\r
+ $f=$authorf[$key];\r
+ $m=$authorm[$key];\r
+ $i=substr($f,0,1).substr($m,0,1);\r
+ $authors[$key]=array(\r
+ 'LastName'=>$a,\r
+ 'ForeName'=>$f,\r
+ 'Initials'=>$i);\r
+ }\r
+ ksort($authors);\r
+ // Construct Article\r
+ if (($year=intPostVar('year'))==0) $year='???';\r
+ if (strlen($journalname=postVar('journal'))==0) $journalname='???';\r
+ if (strlen($volume=postVar('volume'))==0) $volume='???';\r
+ if (strlen($pages=postVar('pages'))==0) $pages='???';\r
+ if (strlen($title=postVar('title'))==0) $title='???';\r
+ if (strlen($abstract=postVar('abstract'))==0) $abstract='???';\r
+ $journal=array(\r
+ 'ISOAbbreviation'=>$journalname,\r
+ 'JournalIssue'=>array(\r
+ 'Volume'=>$volume,\r
+ 'PubDate'=>array('Year'=>$year)\r
+ )\r
+ );\r
+ $article=array(\r
+ 'Journal'=>$journal,\r
+ 'ArticleTitle'=>$title,\r
+ 'Pagination'=>array('MedlinePgn'=>$pages),\r
+ 'AuthorList'=>array('Author'=>$authors)\r
+ );\r
+ // Construct XML data as more\r
+ $medline=array(\r
+ 'PMID'=>$pmid,\r
+ 'Article'=>$article\r
+ );\r
+ $more='<span class="np_pubmed_abstract">'.htmlspecialchars($abstract).'</span>';\r
+ $more.="<span style=\"display:none;\"><![CDATA[\n";\r
+ $more.=$this->_convert2xml('MedlineCitation',$medline);\r
+ $more.=']]></span>';\r
+ // Construct body\r
+ $body="<!--$year--><!--PMID: $pmid-->PMID: $pmid\n";\r
+ $body.='<span class="np_pubmed_authors">';\r
+ $n=count($authors);\r
+ for ($i=1;$i<=$n;$i++) {\r
+ if (1<$i) {\r
+ $body.=', ';\r
+ if ($i==$n) $body.='and ';\r
+ }\r
+ $body.=htmlspecialchars($authors[$i]['LastName']);\r
+ }\r
+ $body.=" ($year)</span>\n";\r
+ $body.='<span class="np_pubmed_article"><i>'.htmlspecialchars($journalname).\r
+ '</i> <b>'.htmlspecialchars($volume).\r
+ '</b> '.htmlspecialchars($pages)."</span>\n";\r
+ $body.='<span class="np_pubmed_title">'.htmlspecialchars($title).'</span>';\r
+ // Construct title\r
+ switch($n){\r
+ case 1:\r
+ $title=$authors[1]['LastName'];\r
+ break;\r
+ case 2:\r
+ $title=$authors[1]['LastName'].' and '.$authors[2]['LastName'];\r
+ break;\r
+ default:\r
+ $title=$authors[1]['LastName'].' et al.';\r
+ break;\r
+ }\r
+ $title=htmlspecialchars($title." ($year) $journalname");\r
+ // Construct category options\r
+ $defcatid=(int)cookieVar($CONF['CookiePrefix'] . 'NP_PubMed_defcatid');\r
+ if (!$defcatid) {\r
+ $blog=$manager->getBlog($this->blogid);\r
+ $defcatid=$blog->getDefaultCategory();\r
+ }\r
+ $res=sql_query('SELECT * FROM '.sql_table('category').\r
+ ' WHERE cblog='.(int)$this->blogid.' ORDER BY cname ASC');\r
+ $array=array();\r
+ while($row=mysql_fetch_assoc($res)){\r
+ $row['selected']= ($row['catid']==$defcatid);\r
+ $array[]=$row;\r
+ }\r
+ // parse\r
+ $this->contents=array('title'=>$title,'body'=>$body,'more'=>$more);\r
+ $this->_showUsingArray('addmanuallyconfirm',$array);\r
+ return;\r
+ }\r
+ // Decide PMID\r
+ $pmid=1+$this->plugin->getOption('lastmanualpmid');\r
+ if ($pmid<1000000000) $pmid=1000000001;\r
+ $i=1;\r
+ while(quickQuery('SELECT count(*) as result from '.sql_table('item').\r
+ ' WHERE iblog='.(int)$this->blogid.\r
+ ' AND ibody LIKE "%'.(int)$pmid.'%"') ){\r
+ $this->plugin->setOption('lastmanualpmid',$pmid);\r
+ $pmid+=$i;\r
+ $i+=rand(1,$i);\r
+ }\r
+ // Get the number of authors\r
+ $numauthor=intGetVar('numauthor');\r
+ if (!$numauthor) $numauthor=3;\r
+ $array=array();\r
+ for ($i=1;$i<=$numauthor;$i++) {\r
+ $array[]=array('i'=>$i);\r
+ }\r
+ // parse\r
+ $this->contents=array('pmid'=>$pmid,'i'=>$numauthor,'numauthor'=>$numauthor*2);\r
+ $this->_showUsingArray('addmanually',$array);\r
+ }\r
+ function _convert2xml($key,$value,$nest=0){\r
+ if (!preg_match('/^[a-zA-Z0-9_]+$/',$key)) exit;\r
+ if (!is_array($value)) {\r
+ $value=str_replace(array('<','>'),array('>','<'),$value);\r
+ return str_repeat(' ',$nest)."<$key>$value</$key>\n";\r
+ }\r
+ $xml='';\r
+ foreach ($value as $k=>$v) {\r
+ if (is_numeric($k)) $xml.=$this->_convert2xml($key,$v,$nest+1);\r
+ else {\r
+ if ($xml=='') $xml=str_repeat(' ',$nest)."<$key>\n";\r
+ $xml.=$this->_convert2xml($k,$v,$nest+1);\r
+ }\r
+ }\r
+ if (!is_numeric($k)) $xml.=str_repeat(' ',$nest)."</$key>\n";\r
+ return $xml;\r
+ }\r
}\r
\r
new PubMedAdmin;\r
]]></foot>\r
</template>\r
\r
+\r
+\r
+ <template>\r
+ <name>addmanually</name>\r
+ <head><![CDATA[\r
+\r
+<p>Add a paper that does not have PMID.</p>\r
+\r
+<form method="post" action="">\r
+<%ticket(hidden)%>\r
+<table>\r
+<tr>\r
+ <td>PMID:</td>\r
+ <td><input type="text" name="pmid" size="20" value="<%int(pmid)%>"/></td>\r
+ <td>year:</td>\r
+ <td colspan="3"><input type="text" name="year" size="10" value=""/></td>\r
+</tr><tr>\r
+ <td>title:</td>\r
+ <td colspan="5"><input type="text" name="title" size="100" value=""/></td>\r
+</tr><tr>\r
+ <td>journal name:</td>\r
+ <td><input type="text" name="journal" size="20" value=""/></td>\r
+ <td>volume:</td>\r
+ <td><input type="text" name="volume" size="10" value=""/></td>\r
+ <td>pages:</td>\r
+ <td><input type="text" name="pages" size="10" value=""/></td>\r
+</tr>\r
+<tr>\r
+ <td>author(s)</td>\r
+ <td colspan="5">\r
+\r
+ ]]></head>\r
+ <body><![CDATA[\r
+\r
+ <%int(i)%>:\r
+ <input type="text" name="author[<%int(i)%>]" size="20" value=""/>,\r
+ <input type="text" name="authorf[<%int(i)%>]" size="20" value=""/>\r
+ <input type="text" name="authorm[<%int(i)%>]" size="2" value=""/>.\r
+ <br />\r
+\r
+ ]]></body>\r
+ <foot><![CDATA[\r
+\r
+ <span id="np_pubmed_author<%int(i)%>">\r
+ <a href="<%self%>?blogid=<%blogid%>&action=addmanually&numauthor=<%int(numauthor)%>" onclick="np_pubmed_author(<%int(i)%>); return false;">more authors</a>\r
+ </span>\r
+ </td>\r
+</tr><tr>\r
+ <td>abstract:</td>\r
+ <td colspan="5"><textarea name="abstract" cols="100" rows="10"></textarea></td>\r
+</tr>\r
+</table>\r
+<input type="submit" value="Add this paper"/>\r
+</form>\r
+<script type="text/javascript">\r
+//<![CDATA[\r
+function np_pubmed_author(i){\r
+ var obj=document.getElementById('np_pubmed_author'+i);\r
+ i++;\r
+ var t=''+i+': ';\r
+ t+='<input type="text" name="author['+i+']" size="20" value=""/>, ';\r
+ t+='<input type="text" name="authorf['+i+']" size="20" value=""/> ';\r
+ t+='<input type="text" name="authorm['+i+']" size="2" value=""/>. ';\r
+ t+='<br />';\r
+ t+='<span id="np_pubmed_author'+i+'"><a href="" onclick="np_pubmed_author('+i+'); return false;">more authors</a></span>';\r
+ obj.innerHTML=t;\r
+}\r
+//]]>]]<![CDATA[>\r
+</script>\r
+\r
+ ]]></foot>\r
+\r
+ </template>\r
+\r
+\r
+\r
+ <template>\r
+ <name>addmanuallyconfirm</name>\r
+ <head><![CDATA[\r
+\r
+<form method="post" action="<%conf(AdminURL)%>">\r
+<%ticket(hidden)%>\r
+<input name="action" value="additem" type="hidden">\r
+<input name="blogid" value="<%blogid%>" type="hidden">\r
+<input name="draftid" value="0" type="hidden">\r
+<input name="closed" value="0" type="hidden">\r
+<input name="actiontype" value="addnow" type="hidden">\r
+<input value="Add this:" type="submit">\r
+<input name="title" value="<%hsc(title)%>" class="np_pubmed_form" type="hidden">\r
+<input name="body" value="<%hsc(body)%>" class="np_pubmed_form" type="hidden">\r
+<input name="more" value="<%hsc(more)%>" class="np_pubmed_form" type="hidden">\r
+\r
+<select name="catid" class="np_pubmed_form">\r
+<option value="newcat-<%blogid%>">New category</option>\r
+\r
+ ]]></head>\r
+ <body><![CDATA[\r
+\r
+<%if(selected)%>\r
+ <option value="<%int(catid)%>" selected="selected"><%stg(cname)%></option>\r
+<%else%>\r
+ <option value="<%int(catid)%>"><%stg(cname)%></option>\r
+<%endif%>\r
+\r
+ ]]></body>\r
+ <foot><![CDATA[\r
+\r
+</select>\r
+ \r
+(<a href="<%self%>?blogid=<%blogid%>&action=addmanually" onclick="history.go(-1); return false;">go back</a>)\r
+</form>\r
+\r
+<pre><%hsc(title)%></pre>\r
+<pre><%hsc(body)%></pre>\r
+<pre><%hsc(more)%></pre>\r
+\r
+ ]]></foot>\r
+ </template>\r
+\r
+\r
</document>\r