OSDN Git Service

BugTrack/664 Should replace #img(,clear) => #clear
[pukiwiki/pukiwiki.git] / plugin / img.inc.php
1 <?php
2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
4 //
5 // $Id: img.inc.php,v 1.12 2004/08/23 11:41:57 henoheno Exp $
6 //
7
8 // Stop word-wrapping
9 define('PLUGIN_IMG_CLEAR', "<div style=\"clear:both\"></div>\n");
10
11 // ²èÁü¤ò¥¤¥ó¥é¥¤¥óɽ¼¨
12 function plugin_img_convert()
13 {
14         $usage = "#img(): Usage: (URI-to-image[,right[,clear]])<br />\n";
15         $args = func_get_args();
16
17         // Check the 2nd argument first, for compatibility
18         $arg = isset($args[1]) ? strtoupper($args[1]) : '';
19         if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
20                 $align = 'left';
21         } else if ($arg == 'R' || $arg == 'RIGHT') {
22                 $align = 'right';
23         } else {
24                 // Stop word-wrapping only (Ugly but compatible)
25                 // Short usage: #img(,clear)
26                 return PLUGIN_IMG_CLEAR;
27         }
28
29         $url = isset($args[0]) ? $args[0] : '';
30         if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
31                 return $usage;
32
33         $arg = isset($args[2]) ? strtoupper($args[2]) : '';
34         $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
35
36         return <<<EOD
37 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
38  <img src="$url" alt="" />
39 </div>$clear
40 EOD;
41 }
42 ?>