ImageHTML: img タグの要素並び調整
@@ -21,6 +21,15 @@ | ||
21 | 21 | return '</' . $name . '>'; |
22 | 22 | } |
23 | 23 | |
24 | + //Attribute 要素生成 | |
25 | + public static function GenerateAttribute($name, $value = null) { | |
26 | + $str = ' ' . $name; | |
27 | + if (true === isset($value)) { | |
28 | + $str .= '="' . $value . '"'; | |
29 | + } | |
30 | + return $str; | |
31 | + } | |
32 | + | |
24 | 33 | //共通 HTML ヘッダ生成 |
25 | 34 | public static function GenerateHeader($title, $css = null, $close = false) { |
26 | 35 | $str = Text::Format(self::GetHeader(), ServerConfig::ENCODE, $title); |
@@ -274,15 +283,6 @@ | ||
274 | 283 | return '<p>%s</p>'; |
275 | 284 | } |
276 | 285 | |
277 | - //Attribute 要素生成 | |
278 | - private static function GenerateAttribute($name, $value = null) { | |
279 | - $str = ' ' . $name; | |
280 | - if (true === isset($value)) { | |
281 | - $str .= '="' . $value . '"'; | |
282 | - } | |
283 | - return $str; | |
284 | - } | |
285 | - | |
286 | 286 | //HTML ヘッダタグ |
287 | 287 | private static function GetHeader() { |
288 | 288 | return <<<EOF |
@@ -2,20 +2,20 @@ | ||
2 | 2 | //-- HTML 生成クラス (画像拡張) --// |
3 | 3 | class ImageHTML { |
4 | 4 | //画像生成 |
5 | - public static function Generate($path, $css, $title) { | |
6 | - return sprintf(self::Get(), $path, $css, $title); | |
5 | + public static function Generate($path, $title, $css) { | |
6 | + return sprintf(self::Get(), $path, $title, $css); | |
7 | 7 | } |
8 | 8 | |
9 | + //alt, title 属性生成 | |
10 | + public static function GenerateTitle($alt, $title) { | |
11 | + return HTML::GenerateAttribute('alt', $alt) . HTML::GenerateAttribute('title', $title); | |
12 | + } | |
13 | + | |
9 | 14 | //CSS 属性生成 |
10 | 15 | public static function GenerateCSS($class) { |
11 | - return sprintf(' class="%s"', $class); | |
16 | + return HTML::GenerateAttribute('class', $class); | |
12 | 17 | } |
13 | 18 | |
14 | - //title 属性生成 | |
15 | - public static function GenerateTitle($alt, $title) { | |
16 | - return sprintf(' alt="%s" title="%s"', $alt, $title); | |
17 | - } | |
18 | - | |
19 | 19 | //ユーザアイコン生成 |
20 | 20 | public static function GenerateIcon(User $user) { |
21 | 21 | return sprintf(self::GetIcon(), |
@@ -5,7 +5,7 @@ | ||
5 | 5 | public static function Room() { |
6 | 6 | static $filter; |
7 | 7 | |
8 | - if (is_null($filter)) { | |
8 | + if (true === is_null($filter)) { | |
9 | 9 | $filter = new RoomImage(); |
10 | 10 | } |
11 | 11 | return $filter; |
@@ -15,7 +15,7 @@ | ||
15 | 15 | public static function Role() { |
16 | 16 | static $filter; |
17 | 17 | |
18 | - if (is_null($filter)) { | |
18 | + if (true === is_null($filter)) { | |
19 | 19 | $filter = new RoleImage(); |
20 | 20 | } |
21 | 21 | return $filter; |
@@ -25,7 +25,7 @@ | ||
25 | 25 | public static function Winner() { |
26 | 26 | static $filter; |
27 | 27 | |
28 | - if (is_null($filter)) { | |
28 | + if (true === is_null($filter)) { | |
29 | 29 | $filter = new WinnerImage(); |
30 | 30 | } |
31 | 31 | return $filter; |
@@ -43,14 +43,14 @@ | ||
43 | 43 | |
44 | 44 | //画像タグ生成 |
45 | 45 | public function Generate($name, $alt = null, $table = false) { |
46 | - $css = $this->class == '' ? '' : ImageHTML::GenerateCSS($this->class); | |
47 | - if (isset($alt)) { | |
46 | + if (true === isset($alt)) { | |
48 | 47 | Text::Escape($alt); |
49 | 48 | $title = ImageHTML::GenerateTitle($alt, $alt); |
50 | 49 | } else { |
51 | 50 | $title = ''; |
52 | 51 | } |
53 | - $str = ImageHTML::Generate($this->GetPath($name), $css, $title); | |
52 | + $css = $this->class == '' ?: ImageHTML::GenerateCSS($this->class); | |
53 | + $str = ImageHTML::Generate($this->GetPath($name), $title, $css); | |
54 | 54 | return $table ? TableHTML::GenerateTd($str) : $str; |
55 | 55 | } |
56 | 56 |
@@ -61,7 +61,9 @@ | ||
61 | 61 | |
62 | 62 | //出力 (存在確認対応版) |
63 | 63 | final public function OutputExists($name) { |
64 | - if ($this->Exists($name)) $this->Output($name); | |
64 | + if ($this->Exists($name)) { | |
65 | + $this->Output($name); | |
66 | + } | |
65 | 67 | } |
66 | 68 | |
67 | 69 | //画像のファイルパス取得 |
@@ -84,8 +86,11 @@ | ||
84 | 86 | public function GenerateMaxUser($number) { |
85 | 87 | $name = 'max' . $number; |
86 | 88 | $alt = sprintf(GameMessage::ROOM_MAX_USER, $number); |
87 | - return in_array($number, RoomConfig::$max_user_list) && $this->Exists($name) ? | |
88 | - $this->Generate($name, $alt) : $alt; | |
89 | + if (true === in_array($number, RoomConfig::$max_user_list) && $this->Exists($name)) { | |
90 | + return $this->Generate($name, $alt); | |
91 | + } else { | |
92 | + return $alt; | |
93 | + } | |
89 | 94 | } |
90 | 95 | } |
91 | 96 |