• R/O
  • SSH
  • HTTPS

jinrousiki: Commit


Commit MetaInfo

Revisión2125 (tree)
Tiempo2018-01-07 20:53:19
Autorumethyl

Log Message

ImageHTML: img タグの要素並び調整

Cambiar Resumen

Diferencia incremental

--- trunk/include/html/html_class.php (revision 2124)
+++ trunk/include/html/html_class.php (revision 2125)
@@ -21,6 +21,15 @@
2121 return '</' . $name . '>';
2222 }
2323
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+
2433 //共通 HTML ヘッダ生成
2534 public static function GenerateHeader($title, $css = null, $close = false) {
2635 $str = Text::Format(self::GetHeader(), ServerConfig::ENCODE, $title);
@@ -274,15 +283,6 @@
274283 return '<p>%s</p>';
275284 }
276285
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-
286286 //HTML ヘッダタグ
287287 private static function GetHeader() {
288288 return <<<EOF
--- trunk/include/html/media/image_html_class.php (revision 2124)
+++ trunk/include/html/media/image_html_class.php (revision 2125)
@@ -2,20 +2,20 @@
22 //-- HTML 生成クラス (画像拡張) --//
33 class ImageHTML {
44 //画像生成
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);
77 }
88
9+ //alt, title 属性生成
10+ public static function GenerateTitle($alt, $title) {
11+ return HTML::GenerateAttribute('alt', $alt) . HTML::GenerateAttribute('title', $title);
12+ }
13+
914 //CSS 属性生成
1015 public static function GenerateCSS($class) {
11- return sprintf(' class="%s"', $class);
16+ return HTML::GenerateAttribute('class', $class);
1217 }
1318
14- //title 属性生成
15- public static function GenerateTitle($alt, $title) {
16- return sprintf(' alt="%s" title="%s"', $alt, $title);
17- }
18-
1919 //ユーザアイコン生成
2020 public static function GenerateIcon(User $user) {
2121 return sprintf(self::GetIcon(),
--- trunk/include/media/image_class.php (revision 2124)
+++ trunk/include/media/image_class.php (revision 2125)
@@ -5,7 +5,7 @@
55 public static function Room() {
66 static $filter;
77
8- if (is_null($filter)) {
8+ if (true === is_null($filter)) {
99 $filter = new RoomImage();
1010 }
1111 return $filter;
@@ -15,7 +15,7 @@
1515 public static function Role() {
1616 static $filter;
1717
18- if (is_null($filter)) {
18+ if (true === is_null($filter)) {
1919 $filter = new RoleImage();
2020 }
2121 return $filter;
@@ -25,7 +25,7 @@
2525 public static function Winner() {
2626 static $filter;
2727
28- if (is_null($filter)) {
28+ if (true === is_null($filter)) {
2929 $filter = new WinnerImage();
3030 }
3131 return $filter;
@@ -43,14 +43,14 @@
4343
4444 //画像タグ生成
4545 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)) {
4847 Text::Escape($alt);
4948 $title = ImageHTML::GenerateTitle($alt, $alt);
5049 } else {
5150 $title = '';
5251 }
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);
5454 return $table ? TableHTML::GenerateTd($str) : $str;
5555 }
5656
@@ -61,7 +61,9 @@
6161
6262 //出力 (存在確認対応版)
6363 final public function OutputExists($name) {
64- if ($this->Exists($name)) $this->Output($name);
64+ if ($this->Exists($name)) {
65+ $this->Output($name);
66+ }
6567 }
6668
6769 //画像のファイルパス取得
@@ -84,8 +86,11 @@
8486 public function GenerateMaxUser($number) {
8587 $name = 'max' . $number;
8688 $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+ }
8994 }
9095 }
9196
Show on old repository browser