Révision | d4fab39a0c628be31df506a699c57d6ea88870fc (tree) |
---|---|
l'heure | 2011-02-04 00:01:25 |
Auteur | henoheno <henoheno> |
Commiter | henoheno |
BugTrack2/343 BugTrack/779: Cleanup:
* "Double $quotes"; => 'Single ' . $quotes;
* if (foo) bar; => if (foo) { bar; }
* Adding spaces
@@ -1,6 +1,6 @@ | ||
1 | 1 | <?php |
2 | 2 | // PukiWiki - Yet another WikiWikiWeb clone |
3 | -// $Id: ref.inc.php,v 1.51 2011/01/25 15:01:01 henoheno Exp $ | |
3 | +// $Id: ref.inc.php,v 1.52 2011/02/03 15:01:25 henoheno Exp $ | |
4 | 4 | // Copyright (C) |
5 | 5 | // 2002-2006 PukiWiki Developers Team |
6 | 6 | // 2001-2002 Originally written by yu-ji |
@@ -10,10 +10,11 @@ | ||
10 | 10 | // Include an attached image-file as an inline-image |
11 | 11 | |
12 | 12 | // File icon image |
13 | -if (! defined('FILE_ICON')) | |
13 | +if (! defined('FILE_ICON')) { | |
14 | 14 | define('FILE_ICON', |
15 | 15 | '<img src="' . IMAGE_DIR . 'file.png" width="20" height="20"' . |
16 | 16 | ' alt="file" style="border-width:0px" />'); |
17 | +} | |
17 | 18 | |
18 | 19 | ///////////////////////////////////////////////// |
19 | 20 | // Default settings |
@@ -43,7 +44,7 @@ define('PLUGIN_REF_DIRECT_ACCESS', FALSE); // FALSE or TRUE | ||
43 | 44 | define('PLUGIN_REF_IMAGE', '/\.(gif|png|jpe?g)$/i'); |
44 | 45 | |
45 | 46 | // Usage (a part of) |
46 | -define('PLUGIN_REF_USAGE', "([pagename/]attached-file-name[,parameters, ... ][,title])"); | |
47 | +define('PLUGIN_REF_USAGE', '([pagename/]attached-file-name[,parameters, ... ][,title])'); | |
47 | 48 | |
48 | 49 | function plugin_ref_inline() |
49 | 50 | { |
@@ -64,12 +65,12 @@ function plugin_ref_inline() | ||
64 | 65 | function plugin_ref_convert() |
65 | 66 | { |
66 | 67 | if (! func_num_args()) |
67 | - return '<p>#ref(): Usage:' . PLUGIN_REF_USAGE . "</p>\n"; | |
68 | + return '<p>#ref(): Usage:' . PLUGIN_REF_USAGE . '</p>' . "\n"; | |
68 | 69 | |
69 | 70 | $params = plugin_ref_body(func_get_args()); |
70 | 71 | |
71 | 72 | if (isset($params['_error']) && $params['_error'] != '') { |
72 | - return "<p>#ref(): {$params['_error']}</p>\n"; | |
73 | + return '<p>#ref(): ' . $params['_error'] . '</p>' . "\n"; | |
73 | 74 | } |
74 | 75 | |
75 | 76 | if ((PLUGIN_REF_WRAP_TABLE && ! $params['nowrap']) || $params['wrap']) { |
@@ -85,7 +86,8 @@ function plugin_ref_convert() | ||
85 | 86 | // Netscape 6 = x (wrapで寄せが効かない) |
86 | 87 | // IE6 = o |
87 | 88 | $margin = ($params['around'] ? '0px' : 'auto'); |
88 | - $margin_align = ($params['_align'] == 'center') ? '' : ";margin-{$params['_align']}:0px"; | |
89 | + $margin_align = ($params['_align'] == 'center') ? '' : | |
90 | + ';margin-' . $params['_align'] . ':0px'; | |
89 | 91 | $params['_body'] = <<<EOD |
90 | 92 | <table class="style_table" style="margin:$margin$margin_align"> |
91 | 93 | <tr> |
@@ -98,11 +100,11 @@ EOD; | ||
98 | 100 | if ($params['around']) { |
99 | 101 | $style = ($params['_align'] == 'right') ? 'float:right' : 'float:left'; |
100 | 102 | } else { |
101 | - $style = "text-align:{$params['_align']}"; | |
103 | + $style = 'text-align:' . $params['_align']; | |
102 | 104 | } |
103 | 105 | |
104 | 106 | // divで包む |
105 | - return "<div class=\"img_margin\" style=\"$style\">{$params['_body']}</div>\n"; | |
107 | + return '<div class="img_margin" style="' . $style . '">' . $params['_body'] . '</div>' . "\n"; | |
106 | 108 | } |
107 | 109 | |
108 | 110 | function plugin_ref_body($args) |
@@ -123,8 +125,8 @@ function plugin_ref_body($args) | ||
123 | 125 | 'noimg' => FALSE, // 画像を展開しない |
124 | 126 | 'zoom' => FALSE, // 縦横比を保持する |
125 | 127 | '_size' => FALSE, // サイズ指定あり |
126 | - '_w' => 0, // 幅 | |
127 | - '_h' => 0, // 高さ | |
128 | + '_w' => 0, // 幅 | |
129 | + '_h' => 0, // 高さ | |
128 | 130 | '_%' => 0, // 拡大率 |
129 | 131 | '_args' => array(), |
130 | 132 | '_done' => FALSE, |
@@ -173,7 +175,7 @@ function plugin_ref_body($args) | ||
173 | 175 | $is_file_second = is_file($file); |
174 | 176 | |
175 | 177 | // If the second argument is WikiName, or double-bracket-inserted pagename (compat) |
176 | - $is_bracket_bracket = preg_match("/^($WikiName|\[\[$BracketName\]\])$/", $args[0]); | |
178 | + $is_bracket_bracket = preg_match('/^(' . $WikiName . '|\[\[' . $BracketName . '\]\])$/', $args[0]); | |
177 | 179 | |
178 | 180 | if ($is_file_second && $is_bracket_bracket) { |
179 | 181 | // Believe the second argument (compat) |
@@ -307,7 +309,9 @@ function plugin_ref_body($args) | ||
307 | 309 | |
308 | 310 | if (! empty($_title)) { |
309 | 311 | $title = htmlsc(join(',', $_title)); |
310 | - if ($is_image) $title = make_line_rules($title); | |
312 | + if ($is_image) { | |
313 | + $title = make_line_rules($title); | |
314 | + } | |
311 | 315 | } |
312 | 316 | } |
313 | 317 |
@@ -335,7 +339,9 @@ function plugin_ref_body($args) | ||
335 | 339 | $width = (int)($width * $params['_%'] / 100); |
336 | 340 | $height = (int)($height * $params['_%'] / 100); |
337 | 341 | } |
338 | - if ($width && $height) $info = "width=\"$width\" height=\"$height\" "; | |
342 | + if ($width && $height) { | |
343 | + $info = 'width="' . $width . '" height="' . $height . '" '; | |
344 | + } | |
339 | 345 | } |
340 | 346 | |
341 | 347 | // アラインメント判定 |
@@ -348,12 +354,19 @@ function plugin_ref_body($args) | ||
348 | 354 | } |
349 | 355 | |
350 | 356 | if ($is_image) { // 画像 |
351 | - $params['_body'] = "<img src=\"$url\" alt=\"$title\" title=\"$title\" $info/>"; | |
352 | - if (! $params['nolink'] && $url2) | |
353 | - $params['_body'] = "<a href=\"$url2\" title=\"$title\">{$params['_body']}</a>"; | |
357 | + $params['_body'] = '<img src="' . $url . '" ' . | |
358 | + 'alt="' . $title . '" ' . | |
359 | + 'title="' . $title . '" ' . | |
360 | + $info . '/>'; | |
361 | + if (! $params['nolink'] && $url2) { | |
362 | + $params['_body'] = | |
363 | + '<a href="' . $url2 . '" title="' . $title . '">' . | |
364 | + $params['_body'] . '</a>'; | |
365 | + } | |
354 | 366 | } else { |
355 | 367 | $icon = $params['noicon'] ? '' : FILE_ICON; |
356 | - $params['_body'] = "<a href=\"$url\" title=\"$info\">$icon$title</a>"; | |
368 | + $params['_body'] = '<a href="' . $url . '" title="' . $info . '">' . | |
369 | + $icon . $title . '</a>'; | |
357 | 370 | } |
358 | 371 | |
359 | 372 | return $params; |