OSDN Git Service

Remove charset selector, use UTF-8
[pukiwiki/pukiwiki.git] / plugin / img.inc.php
index b75156c..06769ed 100644 (file)
@@ -1,39 +1,42 @@
 <?php
-/////////////////////////////////////////////////
 // PukiWiki - Yet another WikiWikiWeb clone.
+// $Id: img.inc.php,v 1.15 2007/04/08 10:22:18 henoheno Exp $
+// Copyright (C) 2002-2005, 2007 PukiWiki Developers Team
+// License: GPL v2 or (at your option) any later version
 //
-// $Id: img.inc.php,v 1.9 2004/08/18 14:25:52 henoheno Exp $
-//
+// Inline-image plugin (Output inline-image tag from a URI)
+
+define('PLUGIN_IMG_USAGE', '#img(): Usage: (URI-to-image[,right[,clear]])<br />' . "\n");
+define('PLUGIN_IMG_CLEAR', '<div style="clear:both"></div>' . "\n"); // Stop word-wrapping
 
-// ²èÁü¤ò¥¤¥ó¥é¥¤¥óɽ¼¨
 function plugin_img_convert()
 {
-       static $usage = '#img(): USAGE: (URI-to-image,r|right|l|left[,clear])';
+       if (PKWK_DISABLE_INLINE_IMAGE_FROM_URI)
+               return '#img(): PKWK_DISABLE_INLINE_IMAGE_FROM_URI prohibits this' .
+                       '<br />' . "\n";
 
        $args = func_get_args();
 
-       $url = isset($args[0]) ? $args[0] : '';
-       if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
-               return $usage;
-
+       // Check the 2nd argument first, for compatibility
        $arg = isset($args[1]) ? strtoupper($args[1]) : '';
-       if ($arg == 'R' || $arg == 'RIGHT') {
-               $align = 'right';
-       } else if ($arg == 'L' || $arg == 'LEFT') {
+       if ($arg == '' || $arg == 'L' || $arg == 'LEFT') {
                $align = 'left';
+       } else if ($arg == 'R' || $arg == 'RIGHT') {
+               $align = 'right';
        } else {
-               return '<div style="clear:both"></div>'; // Ugly but compatible
+               // Stop word-wrapping only (Ugly but compatible)
+               // Short usage: #img(,clear)
+               return PLUGIN_IMG_CLEAR;
        }
 
+       $url = isset($args[0]) ? $args[0] : '';
+       if (! is_url($url) || ! preg_match('/\.(jpe?g|gif|png)$/i', $url))
+               return PLUGIN_IMG_USAGE;
+
        $arg = isset($args[2]) ? strtoupper($args[2]) : '';
-       if ($arg == 'C' || $arg == 'CLEAR') {
-               $clear = '<div style="clear:both"></div>'; // No word-wrap
-       } else {
-               $clear = '';
-       }
+       $clear = ($arg == 'C' || $arg == 'CLEAR') ? PLUGIN_IMG_CLEAR : '';
 
        return <<<EOD
-
 <div style="float:$align;padding:.5em 1.5em .5em 1.5em">
  <img src="$url" alt="" />
 </div>$clear