• R/O
  • HTTP
  • SSH
  • HTTPS

nucleus-plugins: Commit

Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの


Commit MetaInfo

Revision6ed2c565455ca6cd2c9470ced180bb4a700ae5c8 (tree)
Time2009-02-04 05:18:10
Authorkmorimatsu <kmorimatsu@1ca2...>
Commiterkmorimatsu

Log Message

NP_PubMed v0.2.2

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@896 1ca29b6e-896d-4ea0-84a5-967f57386b96

Change Summary

Incremental Difference

--- a/NP_PubMed/trunk/NP_PubMed.php
+++ b/NP_PubMed/trunk/NP_PubMed.php
@@ -3,7 +3,7 @@ class NP_PubMed extends NucleusPlugin {
33 function getName() { return 'NP_PubMed'; }
44 function getMinNucleusVersion() { return 330; }
55 function getAuthor() { return 'Katsumi'; }
6- function getVersion() { return '0.2.1'; }
6+ function getVersion() { return '0.2.2'; }
77 function getURL() {return 'http://japan.nucleuscms.org/wiki/plugins:authors:katsumi';}
88 function getDescription() {
99 return $this->getName().' plugin<br />'.
@@ -16,8 +16,9 @@ class NP_PubMed extends NucleusPlugin {
1616 function getTableList() { return array(sql_table('plugin_pubmed_references'), sql_table('plugin_pubmed_manuscripts')); }
1717 function install(){
1818 global $member;
19- $this->createOption('droptable','Drop table when uninstall?','yesno','no');
2019 $this->createOption('lastquerytime','hidden option','text','0','access=hidden');
20+ $this->createOption('lastmanualpmid','hidden option','text','1000000000','access=hidden');
21+ $this->createOption('droptable','Drop table when uninstall?','yesno','no');
2122 $this->createOption('email','E-mail address to be sent to PubMed search site (set blank if not use):','text',$member->getEmail());
2223 sql_query('CREATE TABLE IF NOT EXISTS '.sql_table('plugin_pubmed_references').' ('.
2324 ' id int(11) not null auto_increment,'.
@@ -373,6 +374,7 @@ END;
373374 htmlspecialchars($text).'</a>';
374375 break;
375376 case 'edit':
377+ if (!$member->isLoggedIn()) return;
376378 $itemid=(int)$item->itemid;
377379 $text=$p1?'manuscript management':htmlspecialchars($p1,ENT_QUOTES);
378380 $width=(int)$p2;
--- a/NP_PubMed/trunk/pubmed/index.php
+++ b/NP_PubMed/trunk/pubmed/index.php
@@ -5,8 +5,8 @@ require('../../../config.php');
55 // An instance will be created at the end of this file
66
77 class PubMedAdmin extends BaseActions {
8- var $oPluginAdmin,$plugin;
9- var $blogid;
8+ private $oPluginAdmin,$plugin;
9+ private $blogid;
1010 function __construct(){
1111 if (method_exists($this,'BaseActions')) $this->BaseActions();
1212
@@ -19,9 +19,15 @@ class PubMedAdmin extends BaseActions {
1919 if (!($this->blogid=intPostVar('blogid'))) $this->blogid=intGetVar('blogid');
2020 $CONF['ItemURL']=quickQuery('SELECT burl as result FROM '.sql_table('blog'). ' WHERE bnumber='.(int)$this->blogid);
2121
22- // Check if there is right to maintain the blog by member.
23- if (!$member->isLoggedIn() || !$member->teamRights($this->blogid) || !$manager->existsBlogID($this->blogid))
24- {
22+ // Check if there is right to maintain the blog or the manuscript.
23+ $ok=true;
24+ if (!$member->isLoggedIn()) $ok=false;
25+ if (!$member->CanLogin()) $ok=false;
26+ if ($this->blogid) {
27+ if (!$member->teamRights($this->blogid)) $ok=false;
28+ if (!$manager->existsBlogID($this->blogid)) $ok=false;
29+ }
30+ if (!$ok) {
2531 $this->oPluginAdmin->start();
2632 echo '<p>' . _ERROR_DISALLOWED . '</p>';
2733 $this->oPluginAdmin->end();
@@ -30,7 +36,6 @@ class PubMedAdmin extends BaseActions {
3036
3137 // If some data is/are posted, check the ticket.
3238 // Therefore, POST method must be used to change important parameter(s).
33- if (!isset($_POST)) $_POST=&$HTTP_POST_VARS;
3439 if (count($_POST) && !$manager->checkTicket()) {
3540 $this->oPluginAdmin->start();
3641 echo '<p class="error">Error: ' . _ERROR_BADTICKET . '</p>';
@@ -49,8 +54,8 @@ class PubMedAdmin extends BaseActions {
4954 $this->oPluginAdmin->start();
5055 switch(getVar('action')) {
5156 case 'manuscriptlist':
52- echo '<h2><a href="'.$this->plugin->getAdminURL().'?blogid='.
53- (int)$this->blogid.'&amp;action=manuscriptlist">' .
57+ echo '<h2><a href="'.$this->plugin->getAdminURL().
58+ '?action=manuscriptlist">' .
5459 'Manuscript management' . "</a></h2>\n";
5560 break;
5661 default:
@@ -340,8 +345,7 @@ class PubMedAdmin extends BaseActions {
340345 $mname=$this->_checkmanuscriptname(postVar('manuscriptname'));
341346 if ($mname) sql_query('INSERT INTO '.sql_table('plugin_pubmed_manuscripts').' SET'.
342347 ' userid='.(int)$mid.','.
343- ' manuscriptname="'.addslashes($mname).'"'.
344- ' sorttext="authorname"');
348+ ' manuscriptname="'.addslashes($mname).'"');
345349 return $this->action_manuscriptlist();
346350 }
347351 private function _getSortMethod($tempname){
@@ -423,6 +427,143 @@ class PubMedAdmin extends BaseActions {
423427 $this->contents=array('mid'=>$manuscriptid,'mname'=>$mname);
424428 $this->_showUsingArray('editmanuscript',$array);
425429 }
430+ function action_addmanually(){
431+ global $manager;
432+ if (count($_POST)) {
433+ // Add item with the defined PMID
434+ $pmid=intPostVar('pmid');
435+ // Determine author list
436+ $author=requestArray('author');
437+ $authorf=requestArray('authorf');
438+ $authorm=requestArray('authorm');
439+ $authors=array();
440+ foreach($author as $key=>$value){
441+ if (!strlen($value)) break;
442+ $a=$author[$key];
443+ $f=$authorf[$key];
444+ $m=$authorm[$key];
445+ $i=substr($f,0,1).substr($m,0,1);
446+ $authors[$key]=array(
447+ 'LastName'=>$a,
448+ 'ForeName'=>$f,
449+ 'Initials'=>$i);
450+ }
451+ ksort($authors);
452+ // Construct Article
453+ if (($year=intPostVar('year'))==0) $year='???';
454+ if (strlen($journalname=postVar('journal'))==0) $journalname='???';
455+ if (strlen($volume=postVar('volume'))==0) $volume='???';
456+ if (strlen($pages=postVar('pages'))==0) $pages='???';
457+ if (strlen($title=postVar('title'))==0) $title='???';
458+ if (strlen($abstract=postVar('abstract'))==0) $abstract='???';
459+ $journal=array(
460+ 'ISOAbbreviation'=>$journalname,
461+ 'JournalIssue'=>array(
462+ 'Volume'=>$volume,
463+ 'PubDate'=>array('Year'=>$year)
464+ )
465+ );
466+ $article=array(
467+ 'Journal'=>$journal,
468+ 'ArticleTitle'=>$title,
469+ 'Pagination'=>array('MedlinePgn'=>$pages),
470+ 'AuthorList'=>array('Author'=>$authors)
471+ );
472+ // Construct XML data as more
473+ $medline=array(
474+ 'PMID'=>$pmid,
475+ 'Article'=>$article
476+ );
477+ $more='<span class="np_pubmed_abstract">'.htmlspecialchars($abstract).'</span>';
478+ $more.="<span style=\"display:none;\"><![CDATA[\n";
479+ $more.=$this->_convert2xml('MedlineCitation',$medline);
480+ $more.=']]></span>';
481+ // Construct body
482+ $body="<!--$year--><!--PMID: $pmid-->PMID: $pmid\n";
483+ $body.='<span class="np_pubmed_authors">';
484+ $n=count($authors);
485+ for ($i=1;$i<=$n;$i++) {
486+ if (1<$i) {
487+ $body.=', ';
488+ if ($i==$n) $body.='and ';
489+ }
490+ $body.=htmlspecialchars($authors[$i]['LastName']);
491+ }
492+ $body.=" ($year)</span>\n";
493+ $body.='<span class="np_pubmed_article"><i>'.htmlspecialchars($journalname).
494+ '</i> <b>'.htmlspecialchars($volume).
495+ '</b> '.htmlspecialchars($pages)."</span>\n";
496+ $body.='<span class="np_pubmed_title">'.htmlspecialchars($title).'</span>';
497+ // Construct title
498+ switch($n){
499+ case 1:
500+ $title=$authors[1]['LastName'];
501+ break;
502+ case 2:
503+ $title=$authors[1]['LastName'].' and '.$authors[2]['LastName'];
504+ break;
505+ default:
506+ $title=$authors[1]['LastName'].' et al.';
507+ break;
508+ }
509+ $title=htmlspecialchars($title." ($year) $journalname");
510+ // Construct category options
511+ $defcatid=(int)cookieVar($CONF['CookiePrefix'] . 'NP_PubMed_defcatid');
512+ if (!$defcatid) {
513+ $blog=$manager->getBlog($this->blogid);
514+ $defcatid=$blog->getDefaultCategory();
515+ }
516+ $res=sql_query('SELECT * FROM '.sql_table('category').
517+ ' WHERE cblog='.(int)$this->blogid.' ORDER BY cname ASC');
518+ $array=array();
519+ while($row=mysql_fetch_assoc($res)){
520+ $row['selected']= ($row['catid']==$defcatid);
521+ $array[]=$row;
522+ }
523+ // parse
524+ $this->contents=array('title'=>$title,'body'=>$body,'more'=>$more);
525+ $this->_showUsingArray('addmanuallyconfirm',$array);
526+ return;
527+ }
528+ // Decide PMID
529+ $pmid=1+$this->plugin->getOption('lastmanualpmid');
530+ if ($pmid<1000000000) $pmid=1000000001;
531+ $i=1;
532+ while(quickQuery('SELECT count(*) as result from '.sql_table('item').
533+ ' WHERE iblog='.(int)$this->blogid.
534+ ' AND ibody LIKE "%'.(int)$pmid.'%"') ){
535+ $this->plugin->setOption('lastmanualpmid',$pmid);
536+ $pmid+=$i;
537+ $i+=rand(1,$i);
538+ }
539+ // Get the number of authors
540+ $numauthor=intGetVar('numauthor');
541+ if (!$numauthor) $numauthor=3;
542+ $array=array();
543+ for ($i=1;$i<=$numauthor;$i++) {
544+ $array[]=array('i'=>$i);
545+ }
546+ // parse
547+ $this->contents=array('pmid'=>$pmid,'i'=>$numauthor,'numauthor'=>$numauthor*2);
548+ $this->_showUsingArray('addmanually',$array);
549+ }
550+ function _convert2xml($key,$value,$nest=0){
551+ if (!preg_match('/^[a-zA-Z0-9_]+$/',$key)) exit;
552+ if (!is_array($value)) {
553+ $value=str_replace(array('<','>'),array('&gt;','&lt;'),$value);
554+ return str_repeat(' ',$nest)."<$key>$value</$key>\n";
555+ }
556+ $xml='';
557+ foreach ($value as $k=>$v) {
558+ if (is_numeric($k)) $xml.=$this->_convert2xml($key,$v,$nest+1);
559+ else {
560+ if ($xml=='') $xml=str_repeat(' ',$nest)."<$key>\n";
561+ $xml.=$this->_convert2xml($k,$v,$nest+1);
562+ }
563+ }
564+ if (!is_numeric($k)) $xml.=str_repeat(' ',$nest)."</$key>\n";
565+ return $xml;
566+ }
426567 }
427568
428569 new PubMedAdmin;
--- a/NP_PubMed/trunk/pubmed/index.xml
+++ b/NP_PubMed/trunk/pubmed/index.xml
@@ -242,4 +242,124 @@ Are you sure?&nbsp;&nbsp;
242242 ]]></foot>
243243 </template>
244244
245+
246+
247+ <template>
248+ <name>addmanually</name>
249+ <head><![CDATA[
250+
251+<p>Add a paper that does not have PMID.</p>
252+
253+<form method="post" action="">
254+<%ticket(hidden)%>
255+<table>
256+<tr>
257+ <td>PMID:</td>
258+ <td><input type="text" name="pmid" size="20" value="<%int(pmid)%>"/></td>
259+ <td>year:</td>
260+ <td colspan="3"><input type="text" name="year" size="10" value=""/></td>
261+</tr><tr>
262+ <td>title:</td>
263+ <td colspan="5"><input type="text" name="title" size="100" value=""/></td>
264+</tr><tr>
265+ <td>journal name:</td>
266+ <td><input type="text" name="journal" size="20" value=""/></td>
267+ <td>volume:</td>
268+ <td><input type="text" name="volume" size="10" value=""/></td>
269+ <td>pages:</td>
270+ <td><input type="text" name="pages" size="10" value=""/></td>
271+</tr>
272+<tr>
273+ <td>author(s)</td>
274+ <td colspan="5">
275+
276+ ]]></head>
277+ <body><![CDATA[
278+
279+ <%int(i)%>:
280+ <input type="text" name="author[<%int(i)%>]" size="20" value=""/>,
281+ <input type="text" name="authorf[<%int(i)%>]" size="20" value=""/>
282+ <input type="text" name="authorm[<%int(i)%>]" size="2" value=""/>.
283+ <br />
284+
285+ ]]></body>
286+ <foot><![CDATA[
287+
288+ <span id="np_pubmed_author<%int(i)%>">
289+ <a href="<%self%>?blogid=<%blogid%>&amp;action=addmanually&amp;numauthor=<%int(numauthor)%>" onclick="np_pubmed_author(<%int(i)%>); return false;">more authors</a>
290+ </span>
291+ </td>
292+</tr><tr>
293+ <td>abstract:</td>
294+ <td colspan="5"><textarea name="abstract" cols="100" rows="10"></textarea></td>
295+</tr>
296+</table>
297+<input type="submit" value="Add this paper"/>
298+</form>
299+<script type="text/javascript">
300+//<![CDATA[
301+function np_pubmed_author(i){
302+ var obj=document.getElementById('np_pubmed_author'+i);
303+ i++;
304+ var t=''+i+': ';
305+ t+='<input type="text" name="author['+i+']" size="20" value=""/>, ';
306+ t+='<input type="text" name="authorf['+i+']" size="20" value=""/> ';
307+ t+='<input type="text" name="authorm['+i+']" size="2" value=""/>. ';
308+ t+='<br />';
309+ t+='<span id="np_pubmed_author'+i+'"><a href="" onclick="np_pubmed_author('+i+'); return false;">more authors</a></span>';
310+ obj.innerHTML=t;
311+}
312+//]]>]]<![CDATA[>
313+</script>
314+
315+ ]]></foot>
316+
317+ </template>
318+
319+
320+
321+ <template>
322+ <name>addmanuallyconfirm</name>
323+ <head><![CDATA[
324+
325+<form method="post" action="<%conf(AdminURL)%>">
326+<%ticket(hidden)%>
327+<input name="action" value="additem" type="hidden">
328+<input name="blogid" value="<%blogid%>" type="hidden">
329+<input name="draftid" value="0" type="hidden">
330+<input name="closed" value="0" type="hidden">
331+<input name="actiontype" value="addnow" type="hidden">
332+<input value="Add this:" type="submit">
333+<input name="title" value="<%hsc(title)%>" class="np_pubmed_form" type="hidden">
334+<input name="body" value="<%hsc(body)%>" class="np_pubmed_form" type="hidden">
335+<input name="more" value="<%hsc(more)%>" class="np_pubmed_form" type="hidden">
336+
337+<select name="catid" class="np_pubmed_form">
338+<option value="newcat-<%blogid%>">New category</option>
339+
340+ ]]></head>
341+ <body><![CDATA[
342+
343+<%if(selected)%>
344+ <option value="<%int(catid)%>" selected="selected"><%stg(cname)%></option>
345+<%else%>
346+ <option value="<%int(catid)%>"><%stg(cname)%></option>
347+<%endif%>
348+
349+ ]]></body>
350+ <foot><![CDATA[
351+
352+</select>
353+&nbsp;
354+(<a href="<%self%>?blogid=<%blogid%>&amp;action=addmanually" onclick="history.go(-1); return false;">go back</a>)
355+</form>
356+
357+<pre><%hsc(title)%></pre>
358+<pre><%hsc(body)%></pre>
359+<pre><%hsc(more)%></pre>
360+
361+ ]]></foot>
362+ </template>
363+
364+
245365 </document>
--- a/NP_PubMed/trunk/spring/sidebar.inc
+++ b/NP_PubMed/trunk/spring/sidebar.inc
@@ -12,8 +12,10 @@
1212 <dt>Navigation</dt>
1313 <dd><a href="http://www.ncbi.nlm.nih.gov/sites/entrez?db=PubMed" onclick="window.open(this.href);return false;">NIH PubMed site</a></dd>
1414 <!-- admin link, only visible if logged in -->
15-<%if(loggedin)%>
15+<%if(admin)%>
1616 <dd><a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>">PubMed search</a></dd>
17+<%endif%>
18+<%if(loggedin)%>
1719 <dd><a href="<%adminurl%>" title="Admin Area">Admin</a></dd>
1820 <%endif%>
1921 </dl>
@@ -24,7 +26,7 @@
2426 <div class="sidebar">
2527 <dl class="sidebardl">
2628 <dt>Manuscripts</dt>
27-<dd><a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>&amp;action=manuscriptlist">(manegement)</a></dd>
29+<dd><a href="<%adminurl%>plugins/pubmed/?action=manuscriptlist">(manegement)</a></dd>
2830 <%PubMed(manuscriptlist,spring/item)%>
2931 </dl>
3032 </div>
--- a/NP_PubMed/trunk/spring/skinbackup.xml
+++ b/NP_PubMed/trunk/spring/skinbackup.xml
@@ -7,7 +7,7 @@
77
88
99 <skin name="spring" type="text/html" includeMode="skindir" includePrefix="spring/">
10- <description>Nucleus CMS spring skin</description>
10+ <description>NP_PubMed spring skin</description>
1111 <part name="archive"><![CDATA[<%parsedinclude(head.inc)%>
1212
1313 <!-- page header -->
@@ -141,6 +141,7 @@ body { margin: 0px; }
141141 <div class="content">
142142 <%PubMed(SearchLink)%><br /><br />
143143 <%PubMed(CreateNew)%>
144+<a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>&amp;action=addmanually">Manually add paper</a>
144145
145146 <%parsedinclude(paging.inc)%>
146147
@@ -293,7 +294,7 @@ onclick="window.open(this.href);return false;"
293294
294295
295296 <template name="spring/index">
296- <description>Nucleus CMS spring index template</description>
297+ <description>NP_PubMed spring index template</description>
297298 <part name="ARCHIVELIST_LISTITEM"><![CDATA[<dd>
298299 <a href="<%archivelink%>" title="Archive for %B, %Y">%Y-%m</a>
299300 </dd>]]></part>
@@ -387,7 +388,7 @@ return false;
387388
388389
389390 <template name="spring/item">
390- <description>Nucleus CMS spring item template</description>
391+ <description>NP_PubMed spring item template</description>
391392 <part name="CATLIST_LISTITEM"><![CDATA[<dd>
392393 <a href="<%catlink%>" title="Manuscript: <%catname%>"><%catname%></a>
393394 </dd>]]></part>
Show on old repository browser