Nucleus CMS日本語版用プラグインのうち、日本語版開発者がサポートしているもの
Revision | 6ed2c565455ca6cd2c9470ced180bb4a700ae5c8 (tree) |
---|---|
Time | 2009-02-04 05:18:10 |
Author | kmorimatsu <kmorimatsu@1ca2...> |
Commiter | kmorimatsu |
NP_PubMed v0.2.2
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@896 1ca29b6e-896d-4ea0-84a5-967f57386b96
@@ -3,7 +3,7 @@ class NP_PubMed extends NucleusPlugin { | ||
3 | 3 | function getName() { return 'NP_PubMed'; } |
4 | 4 | function getMinNucleusVersion() { return 330; } |
5 | 5 | function getAuthor() { return 'Katsumi'; } |
6 | - function getVersion() { return '0.2.1'; } | |
6 | + function getVersion() { return '0.2.2'; } | |
7 | 7 | function getURL() {return 'http://japan.nucleuscms.org/wiki/plugins:authors:katsumi';} |
8 | 8 | function getDescription() { |
9 | 9 | return $this->getName().' plugin<br />'. |
@@ -16,8 +16,9 @@ class NP_PubMed extends NucleusPlugin { | ||
16 | 16 | function getTableList() { return array(sql_table('plugin_pubmed_references'), sql_table('plugin_pubmed_manuscripts')); } |
17 | 17 | function install(){ |
18 | 18 | global $member; |
19 | - $this->createOption('droptable','Drop table when uninstall?','yesno','no'); | |
20 | 19 | $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'); | |
21 | 22 | $this->createOption('email','E-mail address to be sent to PubMed search site (set blank if not use):','text',$member->getEmail()); |
22 | 23 | sql_query('CREATE TABLE IF NOT EXISTS '.sql_table('plugin_pubmed_references').' ('. |
23 | 24 | ' id int(11) not null auto_increment,'. |
@@ -373,6 +374,7 @@ END; | ||
373 | 374 | htmlspecialchars($text).'</a>'; |
374 | 375 | break; |
375 | 376 | case 'edit': |
377 | + if (!$member->isLoggedIn()) return; | |
376 | 378 | $itemid=(int)$item->itemid; |
377 | 379 | $text=$p1?'manuscript management':htmlspecialchars($p1,ENT_QUOTES); |
378 | 380 | $width=(int)$p2; |
@@ -5,8 +5,8 @@ require('../../../config.php'); | ||
5 | 5 | // An instance will be created at the end of this file |
6 | 6 | |
7 | 7 | class PubMedAdmin extends BaseActions { |
8 | - var $oPluginAdmin,$plugin; | |
9 | - var $blogid; | |
8 | + private $oPluginAdmin,$plugin; | |
9 | + private $blogid; | |
10 | 10 | function __construct(){ |
11 | 11 | if (method_exists($this,'BaseActions')) $this->BaseActions(); |
12 | 12 |
@@ -19,9 +19,15 @@ class PubMedAdmin extends BaseActions { | ||
19 | 19 | if (!($this->blogid=intPostVar('blogid'))) $this->blogid=intGetVar('blogid'); |
20 | 20 | $CONF['ItemURL']=quickQuery('SELECT burl as result FROM '.sql_table('blog'). ' WHERE bnumber='.(int)$this->blogid); |
21 | 21 | |
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) { | |
25 | 31 | $this->oPluginAdmin->start(); |
26 | 32 | echo '<p>' . _ERROR_DISALLOWED . '</p>'; |
27 | 33 | $this->oPluginAdmin->end(); |
@@ -30,7 +36,6 @@ class PubMedAdmin extends BaseActions { | ||
30 | 36 | |
31 | 37 | // If some data is/are posted, check the ticket. |
32 | 38 | // Therefore, POST method must be used to change important parameter(s). |
33 | - if (!isset($_POST)) $_POST=&$HTTP_POST_VARS; | |
34 | 39 | if (count($_POST) && !$manager->checkTicket()) { |
35 | 40 | $this->oPluginAdmin->start(); |
36 | 41 | echo '<p class="error">Error: ' . _ERROR_BADTICKET . '</p>'; |
@@ -49,8 +54,8 @@ class PubMedAdmin extends BaseActions { | ||
49 | 54 | $this->oPluginAdmin->start(); |
50 | 55 | switch(getVar('action')) { |
51 | 56 | case 'manuscriptlist': |
52 | - echo '<h2><a href="'.$this->plugin->getAdminURL().'?blogid='. | |
53 | - (int)$this->blogid.'&action=manuscriptlist">' . | |
57 | + echo '<h2><a href="'.$this->plugin->getAdminURL(). | |
58 | + '?action=manuscriptlist">' . | |
54 | 59 | 'Manuscript management' . "</a></h2>\n"; |
55 | 60 | break; |
56 | 61 | default: |
@@ -340,8 +345,7 @@ class PubMedAdmin extends BaseActions { | ||
340 | 345 | $mname=$this->_checkmanuscriptname(postVar('manuscriptname')); |
341 | 346 | if ($mname) sql_query('INSERT INTO '.sql_table('plugin_pubmed_manuscripts').' SET'. |
342 | 347 | ' userid='.(int)$mid.','. |
343 | - ' manuscriptname="'.addslashes($mname).'"'. | |
344 | - ' sorttext="authorname"'); | |
348 | + ' manuscriptname="'.addslashes($mname).'"'); | |
345 | 349 | return $this->action_manuscriptlist(); |
346 | 350 | } |
347 | 351 | private function _getSortMethod($tempname){ |
@@ -423,6 +427,143 @@ class PubMedAdmin extends BaseActions { | ||
423 | 427 | $this->contents=array('mid'=>$manuscriptid,'mname'=>$mname); |
424 | 428 | $this->_showUsingArray('editmanuscript',$array); |
425 | 429 | } |
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('>','<'),$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 | + } | |
426 | 567 | } |
427 | 568 | |
428 | 569 | new PubMedAdmin; |
@@ -242,4 +242,124 @@ Are you sure? | ||
242 | 242 | ]]></foot> |
243 | 243 | </template> |
244 | 244 | |
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%>&action=addmanually&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 | + | |
354 | +(<a href="<%self%>?blogid=<%blogid%>&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 | + | |
245 | 365 | </document> |
@@ -12,8 +12,10 @@ | ||
12 | 12 | <dt>Navigation</dt> |
13 | 13 | <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> |
14 | 14 | <!-- admin link, only visible if logged in --> |
15 | -<%if(loggedin)%> | |
15 | +<%if(admin)%> | |
16 | 16 | <dd><a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>">PubMed search</a></dd> |
17 | +<%endif%> | |
18 | +<%if(loggedin)%> | |
17 | 19 | <dd><a href="<%adminurl%>" title="Admin Area">Admin</a></dd> |
18 | 20 | <%endif%> |
19 | 21 | </dl> |
@@ -24,7 +26,7 @@ | ||
24 | 26 | <div class="sidebar"> |
25 | 27 | <dl class="sidebardl"> |
26 | 28 | <dt>Manuscripts</dt> |
27 | -<dd><a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>&action=manuscriptlist">(manegement)</a></dd> | |
29 | +<dd><a href="<%adminurl%>plugins/pubmed/?action=manuscriptlist">(manegement)</a></dd> | |
28 | 30 | <%PubMed(manuscriptlist,spring/item)%> |
29 | 31 | </dl> |
30 | 32 | </div> |
@@ -7,7 +7,7 @@ | ||
7 | 7 | |
8 | 8 | |
9 | 9 | <skin name="spring" type="text/html" includeMode="skindir" includePrefix="spring/"> |
10 | - <description>Nucleus CMS spring skin</description> | |
10 | + <description>NP_PubMed spring skin</description> | |
11 | 11 | <part name="archive"><![CDATA[<%parsedinclude(head.inc)%> |
12 | 12 | |
13 | 13 | <!-- page header --> |
@@ -141,6 +141,7 @@ body { margin: 0px; } | ||
141 | 141 | <div class="content"> |
142 | 142 | <%PubMed(SearchLink)%><br /><br /> |
143 | 143 | <%PubMed(CreateNew)%> |
144 | +<a href="<%adminurl%>plugins/pubmed/?blogid=<%blogsetting(id)%>&action=addmanually">Manually add paper</a> | |
144 | 145 | |
145 | 146 | <%parsedinclude(paging.inc)%> |
146 | 147 |
@@ -293,7 +294,7 @@ onclick="window.open(this.href);return false;" | ||
293 | 294 | |
294 | 295 | |
295 | 296 | <template name="spring/index"> |
296 | - <description>Nucleus CMS spring index template</description> | |
297 | + <description>NP_PubMed spring index template</description> | |
297 | 298 | <part name="ARCHIVELIST_LISTITEM"><![CDATA[<dd> |
298 | 299 | <a href="<%archivelink%>" title="Archive for %B, %Y">%Y-%m</a> |
299 | 300 | </dd>]]></part> |
@@ -387,7 +388,7 @@ return false; | ||
387 | 388 | |
388 | 389 | |
389 | 390 | <template name="spring/item"> |
390 | - <description>Nucleus CMS spring item template</description> | |
391 | + <description>NP_PubMed spring item template</description> | |
391 | 392 | <part name="CATLIST_LISTITEM"><![CDATA[<dd> |
392 | 393 | <a href="<%catlink%>" title="Manuscript: <%catname%>"><%catname%></a> |
393 | 394 | </dd>]]></part> |