OSDN Git Service

削除されたページを完全に削除できるようにした。
[fswiki/fswiki.git] / plugin / attach / RefImage.pm
1 ############################################################
2 #
3 # <p>źÉÕ¤·¤¿²èÁü¥Õ¥¡¥¤¥ë¤òɽ¼¨¤·¤Þ¤¹¡£</p>
4 # <pre>
5 # {{ref_image ¥Õ¥¡¥¤¥ë̾}}
6 # </pre>
7 # <p>
8 # ¥ª¥×¥·¥ç¥ó¤Ç²èÁü¤Î¥µ¥¤¥º¤ò»ØÄꤹ¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
9 # °Ê²¼¤ÎÎã¤Ç¤ÏÉý650¥Ô¥¯¥»¥ë¡¢¹â¤µ400¥Ô¥¯¥»¥ë¤Ç²èÁü¤òɽ¼¨¤·¤Þ¤¹¡£
10 # </p>
11 # <pre>
12 # {{ref_image ¥Õ¥¡¥¤¥ë̾,w650,h400}}
13 # </pre>
14 # <p>Ê̤Υڡ¼¥¸¤ËźÉÕ¤µ¤ì¤¿¥Õ¥¡¥¤¥ë¤ò»²¾È¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£</p>
15 # <pre>
16 # {{ref_image ¥Õ¥¡¥¤¥ë̾,¥Ú¡¼¥¸Ì¾}}
17 # </pre>
18 #
19 ############################################################
20 package plugin::attach::RefImage;
21 use strict;
22 #===========================================================
23 # ¥³¥ó¥¹¥È¥é¥¯¥¿
24 #===========================================================
25 sub new {
26         my $class = shift;
27         my $self = {};
28         return bless $self,$class;
29 }
30
31 #===========================================================
32 # ¥Ñ¥é¥°¥é¥Õ¥á¥½¥Ã¥É
33 #===========================================================
34 sub paragraph {
35         my $self = shift;
36         my $wiki = shift;
37         my $file = shift;
38         my $page = "";
39         
40         my @options = @_;
41         my $width  = "";
42         my $height = "";
43         
44         if($file eq ""){
45                 return &Util::paragraph_error("¥Õ¥¡¥¤¥ë¤¬»ØÄꤵ¤ì¤Æ¤¤¤Þ¤»¤ó¡£","WIKI");
46         }
47         foreach my $option (@options){
48                 if($option =~ /^w([0-9]+)$/){
49                         $width = $1;
50                 } elsif($option =~ /^h([0-9]+)$/){
51                         $height = $1;
52                 } else {
53                         $page = $option;
54                 }
55         }
56         if($page eq ""){
57                 $page = $wiki->get_CGI()->param("page");
58         }
59         unless($wiki->can_show($page)){
60                 return &Util::paragraph_error("¥Ú¡¼¥¸¤Î»²¾È¸¢¸Â¤¬¤¢¤ê¤Þ¤»¤ó¡£","WIKI");
61         }
62         
63         my $filename = $wiki->config('attach_dir')."/".&Util::url_encode($page).".".&Util::url_encode($file);
64         unless(-e $filename){
65                 return &Util::paragraph_error("¥Õ¥¡¥¤¥ë¤¬Â¸ºß¤·¤Þ¤»¤ó¡£","WIKI");
66         }
67         
68         $wiki->get_current_parser()->l_image($page, $file, $width, $height);
69         return undef;
70 }
71
72 1;