質問箱/4243
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
**[[質問箱/4243]] [#gd0ecf02]
|RIGHT:70|LEFT:410|c
|~カテゴリ||
|~サマリ|テーブルの改造で特定の行に色をつける|
|~バージョン|1.4.7|
|~投稿者|[[アベス]]|
|~状態|完了|
|~投稿日|&new{2008-02-14 (木) 01:41:30};|
***質問 [#i68cadc8]
|aaa|aaa|h
と作成すると、見出しになりますよね。
これの要領で
|aaa|aaa|o←アルファベットは適当
にすると この行だけ色を変更することはできないでしょうか?
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):かきくけこ|
|さしすせそ|
|BGCOLOR(#ffffff):たちつてと|
のように色を1行ごとによって変更したいのですが
BGCOLORをいれると見にくくなる上に面倒なので
|かきくけこ|かきくけこ|o
でその行は全てBGCOLOR(#):が適用されると楽だなと思いました
***回答 [#s6c80e79]
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):|c
|かきくけこ|
|BGCOLOR():|c
|さしすせそ|
|BGCOLOR(#ffffff):|c
|たちつてと|
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):|c
|かきくけこ|
|BGCOLOR():|c
|さしすせそ|
|BGCOLOR(#ffffff):|c
|たちつてと|
- このように書式指定行というのはあります。[[整形ルール]]...
- [[質問箱/4130]] と同じ質問かな? -- &new{2008-02-14 (...
- cはもちろん知っていますが、毎回はさむことになるとやはり...
- 次のような改造はどうでしょうか? -- &new{2008-02-17 (...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
--- 535行目あたり
- function toString()
+ function toString($flag)
{
if ($this->rowspan == 0 || $this->colspan == 0) retur...
- $param = ' class="style_' . $this->tag . '"';
+ if ($flag) {
+ $param = ' class="style_' . $this->tag . '1"';
+ } else {
+ $param = ' class="style_' . $this->tag . '2"';
+ }
if ($this->rowspan > 1)
$param .= ' rowspan="' . $this->rowspan . '"';
if ($this->colspan > 1) {
$param .= ' colspan="' . $this->colspan . '"';
unset($this->style['width']);
}
if (! empty($this->style))
$param .= ' style="' . join(' ', $this->style) . '"';
return $this->wrap(parent::toString(), $this->tag, $p...
}
--- 635行目あたり
// toString
$string = '';
foreach ($parts as $type => $part)
{
+ $flag = FALSE;
$part_string = '';
foreach (array_keys($this->elements) as $nrow) {
if ($this->types[$nrow] != $type)
continue;
+ $flag = ! $flag;
$row = & $this->elements[$nrow];
$row_string = '';
foreach (array_keys($row) as $ncol)
- $row_string .= $row[$ncol]->toString();
+ $row_string .= $row[$ncol]->toString($flag);
$part_string .= $this->wrap($row_string, 'tr');
}
$string .= $this->wrap($part_string, $part);
}
-- css に次の定義を追加((「CSV形式の表組み」等が''style_t...
thead td.style_td1
thead td.style_td2
tfoot td.style_td1
tfoot td.style_td2
thead th.style_th1
thead th.style_th2
tfoot th.style_th1
tfoot th.style_th2
.style_th1
.style_th2
.style_td1
.style_td2
-- サイトごとやスキンごと等、複数のcss を設定する手間はあ...
- 細かい詳細ありがとうございます、ほとんど理想的な動作を...
しかしrowspanを使うとデザインが少し崩れてしまいます。~
|~あいうえお|かきくけこ|
|~|さしすせそ|
|~たちつてと|なにぬねの|
|~|はひふへほ|
|~まみむめも|やゆよ|
|~らりるれろ|わをん|
上記の場合、th1である「あ行」は正常ですが、th2となってほ...
rowspanを使用していない「ま行」はth1、「ら行」はth2と当然...
さらに理想としては、「か行」と「さ行」はtd1に、「な行」と...
表で表示すると
|BGCOLOR(#ffffff):~あいうえお|BGCOLOR(#ffffff):かきくけこ|
|~|BGCOLOR(#ffffff):さしすせそ|
|~|BGCOLOR(#ffffff):たちつてと|
|BGCOLOR(#ffdddd):~たちつてと|BGCOLOR(#ffDDDD):なにぬねの|
|~|BGCOLOR(#ffDDDD):はひふへほ|
|~|BGCOLOR(#ffDDDD):まみむめも|
|BGCOLOR(#ffffff):~アイウエオ|BGCOLOR(#ffffff):カキクケコ|
|~|BGCOLOR(#ffffff):サシスセソ|
|~|BGCOLOR(#ffffff):タチツテト|
という風な形です。~
もちろんこのままで十分満足なのですが、rowspanを使うことを...
厳しそうならこのまま完了にしたいと思っています、わがまま...
- やっぱり自動で処理する機能だけでは困る場合がありますか...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
---115行目あたり
// '|'-separated table
function & Factory_Table(& $root, $text)
{
- if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $ou...
+ if (! preg_match('/^\|(.+)\|([hHfFcC]?)([12]?)$/', $te...
return Factory_Inline($text);
} else {
return new Table($out);
}
}
--- 535行目あたり
- function toString()
+ function toString($flag)
{
if ($this->rowspan == 0 || $this->colspan == 0) retur...
- $param = ' class="style_' . $this->tag . '"';
+ $param = ' class="style_' . $this->tag . $flag . '"';
if ($this->rowspan > 1)
$param .= ' rowspan="' . $this->rowspan . '"';
if ($this->colspan > 1) {
--- 560行目あたり
class Table extends Element
{
var $type;
var $types;
var $col; // number of column
+ var $style;
function Table($out)
{
parent::Element();
$cells = explode('|', $out[1]);
$this->col = count($cells);
$this->type = strtolower($out[2]);
$this->types = array($this->type);
+ $this->style = array($out[3]);
$is_template = ($this->type == 'c');
$row = array();
foreach ($cells as $cell)
--- 585行目あたり
function & insert(& $obj)
{
$this->elements[] = $obj->elements[0];
$this->types[] = $obj->type;
+ $this->style[] = $obj->style[0];
return $this;
}
--- 610行目あたり
// Set colspan and style
$stylerow = NULL;
+ $stylecss = '';
foreach (array_keys($this->elements) as $nrow) {
$row = & $this->elements[$nrow];
- if ($this->types[$nrow] == 'c')
+ if ($this->types[$nrow] == 'c') {
$stylerow = & $row;
+ $stylecss = & $this->style[$nrow];
+ } else if ($stylecss != '' && $this->style[$nrow] ==...
+ $this->style[$nrow] = $stylecss;
+ }
$colspan = 1;
foreach (array_keys($row) as $ncol) {
if ($row[$ncol]->colspan == 0) {
--- 635行目あたり
// toString
$string = '';
foreach ($parts as $type => $part)
{
+ $flag = 0;
$part_string = '';
foreach (array_keys($this->elements) as $nrow) {
if ($this->types[$nrow] != $type)
continue;
+
+ switch ($flag)
+ {
+ case 1:
+ ++$flag;
+ break;
+
+ default:
+ $flag = 1;
+ }
+ if ($this->style[$nrow] == '') {
+ $tmp = $flag;
+ } else {
+ $tmp = $this->style[$nrow];
+ }
$row = & $this->elements[$nrow];
$row_string = '';
foreach (array_keys($row) as $ncol)
- $row_string .= $row[$ncol]->toString();
+ $row_string .= $row[$ncol]->toString($tmp);
$part_string .= $this->wrap($row_string, 'tr');
}
$string .= $this->wrap($part_string, $part);
}
-- css に追加する定義は前と同じなので省略
-- 使い方のイメージはこんな感じ
|~style_th1|style_td1|1
|~|style_td1|1
|~|style_td1|1
||COLOR(#666666):|c2
|~style_th2|style_td2|
|~|style_td2|
|~|style_td1|1
|||c
|~自動設定|自動設定|
|~|自動設定|
|~|自動設定|
|BGCOLOR(#ffffff):~style_th1|BGCOLOR(#ffffff):style_td1|
|~|BGCOLOR(#ffffff):style_td1|
|~|BGCOLOR(#ffffff):style_td1|
|BGCOLOR(#ffdddd):|COLOR(#666666):BGCOLOR(#ffdddd):|c
|~style_th2|style_td2|
|~|style_td2|
|~|BGCOLOR(#ffffff):style_td1|
|||c
|BGCOLOR(#ffffff):~自動設定|BGCOLOR(#ffffff):自動設定|
|~|BGCOLOR(#ffdddd):自動設定|
|~|BGCOLOR(#ffffff):自動設定|
--- 表組みの行末に(この改造の場合では)''1''や''2''を書...
-- あまり長文になってもアレなので書きませんが、一応「swit...
-- 横長の表になればなるほど、セルを縦に結合したときに期待...
// ↓、初心者向けの注意書き
-- あと、最初の改造のときに書き忘れてましたが、この改造は...
- ありがとうございます、理想的な動きをしてくれるようにな...
例の説明もわかりやすくてとても助かります。~
ループパターンは、そうですね。rowspanを使うこともあり、使...
表組み全般に適応されるとのことですが、自分のskinでは特に...
よく雑誌とかでも表組みは行間ごとに色を変えていて、見やす...
ここまで詳しく書き込んでくれてどうもありがとうございまし...
#comment
終了行:
**[[質問箱/4243]] [#gd0ecf02]
|RIGHT:70|LEFT:410|c
|~カテゴリ||
|~サマリ|テーブルの改造で特定の行に色をつける|
|~バージョン|1.4.7|
|~投稿者|[[アベス]]|
|~状態|完了|
|~投稿日|&new{2008-02-14 (木) 01:41:30};|
***質問 [#i68cadc8]
|aaa|aaa|h
と作成すると、見出しになりますよね。
これの要領で
|aaa|aaa|o←アルファベットは適当
にすると この行だけ色を変更することはできないでしょうか?
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):かきくけこ|
|さしすせそ|
|BGCOLOR(#ffffff):たちつてと|
のように色を1行ごとによって変更したいのですが
BGCOLORをいれると見にくくなる上に面倒なので
|かきくけこ|かきくけこ|o
でその行は全てBGCOLOR(#):が適用されると楽だなと思いました
***回答 [#s6c80e79]
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):|c
|かきくけこ|
|BGCOLOR():|c
|さしすせそ|
|BGCOLOR(#ffffff):|c
|たちつてと|
|見出し|h
|あいうえお|
|BGCOLOR(#ffffff):|c
|かきくけこ|
|BGCOLOR():|c
|さしすせそ|
|BGCOLOR(#ffffff):|c
|たちつてと|
- このように書式指定行というのはあります。[[整形ルール]]...
- [[質問箱/4130]] と同じ質問かな? -- &new{2008-02-14 (...
- cはもちろん知っていますが、毎回はさむことになるとやはり...
- 次のような改造はどうでしょうか? -- &new{2008-02-17 (...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
--- 535行目あたり
- function toString()
+ function toString($flag)
{
if ($this->rowspan == 0 || $this->colspan == 0) retur...
- $param = ' class="style_' . $this->tag . '"';
+ if ($flag) {
+ $param = ' class="style_' . $this->tag . '1"';
+ } else {
+ $param = ' class="style_' . $this->tag . '2"';
+ }
if ($this->rowspan > 1)
$param .= ' rowspan="' . $this->rowspan . '"';
if ($this->colspan > 1) {
$param .= ' colspan="' . $this->colspan . '"';
unset($this->style['width']);
}
if (! empty($this->style))
$param .= ' style="' . join(' ', $this->style) . '"';
return $this->wrap(parent::toString(), $this->tag, $p...
}
--- 635行目あたり
// toString
$string = '';
foreach ($parts as $type => $part)
{
+ $flag = FALSE;
$part_string = '';
foreach (array_keys($this->elements) as $nrow) {
if ($this->types[$nrow] != $type)
continue;
+ $flag = ! $flag;
$row = & $this->elements[$nrow];
$row_string = '';
foreach (array_keys($row) as $ncol)
- $row_string .= $row[$ncol]->toString();
+ $row_string .= $row[$ncol]->toString($flag);
$part_string .= $this->wrap($row_string, 'tr');
}
$string .= $this->wrap($part_string, $part);
}
-- css に次の定義を追加((「CSV形式の表組み」等が''style_t...
thead td.style_td1
thead td.style_td2
tfoot td.style_td1
tfoot td.style_td2
thead th.style_th1
thead th.style_th2
tfoot th.style_th1
tfoot th.style_th2
.style_th1
.style_th2
.style_td1
.style_td2
-- サイトごとやスキンごと等、複数のcss を設定する手間はあ...
- 細かい詳細ありがとうございます、ほとんど理想的な動作を...
しかしrowspanを使うとデザインが少し崩れてしまいます。~
|~あいうえお|かきくけこ|
|~|さしすせそ|
|~たちつてと|なにぬねの|
|~|はひふへほ|
|~まみむめも|やゆよ|
|~らりるれろ|わをん|
上記の場合、th1である「あ行」は正常ですが、th2となってほ...
rowspanを使用していない「ま行」はth1、「ら行」はth2と当然...
さらに理想としては、「か行」と「さ行」はtd1に、「な行」と...
表で表示すると
|BGCOLOR(#ffffff):~あいうえお|BGCOLOR(#ffffff):かきくけこ|
|~|BGCOLOR(#ffffff):さしすせそ|
|~|BGCOLOR(#ffffff):たちつてと|
|BGCOLOR(#ffdddd):~たちつてと|BGCOLOR(#ffDDDD):なにぬねの|
|~|BGCOLOR(#ffDDDD):はひふへほ|
|~|BGCOLOR(#ffDDDD):まみむめも|
|BGCOLOR(#ffffff):~アイウエオ|BGCOLOR(#ffffff):カキクケコ|
|~|BGCOLOR(#ffffff):サシスセソ|
|~|BGCOLOR(#ffffff):タチツテト|
という風な形です。~
もちろんこのままで十分満足なのですが、rowspanを使うことを...
厳しそうならこのまま完了にしたいと思っています、わがまま...
- やっぱり自動で処理する機能だけでは困る場合がありますか...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
---115行目あたり
// '|'-separated table
function & Factory_Table(& $root, $text)
{
- if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $ou...
+ if (! preg_match('/^\|(.+)\|([hHfFcC]?)([12]?)$/', $te...
return Factory_Inline($text);
} else {
return new Table($out);
}
}
--- 535行目あたり
- function toString()
+ function toString($flag)
{
if ($this->rowspan == 0 || $this->colspan == 0) retur...
- $param = ' class="style_' . $this->tag . '"';
+ $param = ' class="style_' . $this->tag . $flag . '"';
if ($this->rowspan > 1)
$param .= ' rowspan="' . $this->rowspan . '"';
if ($this->colspan > 1) {
--- 560行目あたり
class Table extends Element
{
var $type;
var $types;
var $col; // number of column
+ var $style;
function Table($out)
{
parent::Element();
$cells = explode('|', $out[1]);
$this->col = count($cells);
$this->type = strtolower($out[2]);
$this->types = array($this->type);
+ $this->style = array($out[3]);
$is_template = ($this->type == 'c');
$row = array();
foreach ($cells as $cell)
--- 585行目あたり
function & insert(& $obj)
{
$this->elements[] = $obj->elements[0];
$this->types[] = $obj->type;
+ $this->style[] = $obj->style[0];
return $this;
}
--- 610行目あたり
// Set colspan and style
$stylerow = NULL;
+ $stylecss = '';
foreach (array_keys($this->elements) as $nrow) {
$row = & $this->elements[$nrow];
- if ($this->types[$nrow] == 'c')
+ if ($this->types[$nrow] == 'c') {
$stylerow = & $row;
+ $stylecss = & $this->style[$nrow];
+ } else if ($stylecss != '' && $this->style[$nrow] ==...
+ $this->style[$nrow] = $stylecss;
+ }
$colspan = 1;
foreach (array_keys($row) as $ncol) {
if ($row[$ncol]->colspan == 0) {
--- 635行目あたり
// toString
$string = '';
foreach ($parts as $type => $part)
{
+ $flag = 0;
$part_string = '';
foreach (array_keys($this->elements) as $nrow) {
if ($this->types[$nrow] != $type)
continue;
+
+ switch ($flag)
+ {
+ case 1:
+ ++$flag;
+ break;
+
+ default:
+ $flag = 1;
+ }
+ if ($this->style[$nrow] == '') {
+ $tmp = $flag;
+ } else {
+ $tmp = $this->style[$nrow];
+ }
$row = & $this->elements[$nrow];
$row_string = '';
foreach (array_keys($row) as $ncol)
- $row_string .= $row[$ncol]->toString();
+ $row_string .= $row[$ncol]->toString($tmp);
$part_string .= $this->wrap($row_string, 'tr');
}
$string .= $this->wrap($part_string, $part);
}
-- css に追加する定義は前と同じなので省略
-- 使い方のイメージはこんな感じ
|~style_th1|style_td1|1
|~|style_td1|1
|~|style_td1|1
||COLOR(#666666):|c2
|~style_th2|style_td2|
|~|style_td2|
|~|style_td1|1
|||c
|~自動設定|自動設定|
|~|自動設定|
|~|自動設定|
|BGCOLOR(#ffffff):~style_th1|BGCOLOR(#ffffff):style_td1|
|~|BGCOLOR(#ffffff):style_td1|
|~|BGCOLOR(#ffffff):style_td1|
|BGCOLOR(#ffdddd):|COLOR(#666666):BGCOLOR(#ffdddd):|c
|~style_th2|style_td2|
|~|style_td2|
|~|BGCOLOR(#ffffff):style_td1|
|||c
|BGCOLOR(#ffffff):~自動設定|BGCOLOR(#ffffff):自動設定|
|~|BGCOLOR(#ffdddd):自動設定|
|~|BGCOLOR(#ffffff):自動設定|
--- 表組みの行末に(この改造の場合では)''1''や''2''を書...
-- あまり長文になってもアレなので書きませんが、一応「swit...
-- 横長の表になればなるほど、セルを縦に結合したときに期待...
// ↓、初心者向けの注意書き
-- あと、最初の改造のときに書き忘れてましたが、この改造は...
- ありがとうございます、理想的な動きをしてくれるようにな...
例の説明もわかりやすくてとても助かります。~
ループパターンは、そうですね。rowspanを使うこともあり、使...
表組み全般に適応されるとのことですが、自分のskinでは特に...
よく雑誌とかでも表組みは行間ごとに色を変えていて、見やす...
ここまで詳しく書き込んでくれてどうもありがとうございまし...
#comment
ページ名: