質問箱/4580
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
**[[質問箱/4580]] [#gb56bd75]
|RIGHT:100|LEFT:410|c
|~カテゴリ||
|~サマリ|テーブルの種類を増やしたい|
|~バージョン|1.4.7|
|~投稿者|[[gnil]]|
|~状態|完了|
|~投稿日|&new{2010-05-25 (火) 01:16:04};|
***質問 [#se0d9262]
自分で作成した表のスタイルを複数使い分けたいです。~
[[質問箱/4243]]の方法を試しましたが<table>のclass指定がで...
***回答 [#g71570cf]
- table のclass を個別に指定可能にする改造なら、[[質問箱/...
- [[質問箱/3510]]は試したのですがtableだけでth,tdが指定出...
- 別個に作成された改造なので変数名が被っているなどの問題...
if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out)...
の部分が被っている後半の改造だと予想して、回答しています...
- 前半のものは何故か上手く変更されないので後半にある改造...
if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out...
の部分は
if (! preg_match('/^\|(.+)\|([hHfFcCsS]?)([12]?)$/', $t...
見たいに変えればいいのですかね?&br;詳しくないので分かり...
- やはり上手く行かないのでどなたか助言や良い方法がありま...
- paddingが違うのは[[CSS]]の設定の問題では? -- &new{201...
- paddingが違うのは意図的にやってるので知ってます、&br;[[...
- 質問箱3/510と質問箱4/243の差分を適当にマージしてみまし...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
---115行目あたり
// '|'-separated table
function & Factory_Table(& $root, $text)
{
- if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $ou...
+ if (! preg_match('/^\|(.+)\|([hHfFcCsS]?)([12]?)$/', $...
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_table;
+ var $style_cell;
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_cell = array($out[3]);
$is_template = ($this->type == 'c');
$row = array();
- foreach ($cells as $cell)
- $row[] = & new TableCell($cell, $is_template);
+ $this->style_table = 'style_table';
+ if($this->type == 's') {
+ $this->style_table = trim(array_shift($cells));
+ for ($ncol = 0; $ncol < $this->col; $ncol++)
+ $row[] = & new TableCell('', $is_template);
+ } else {
+ foreach ($cells as $cell)
+ $row[] = & new TableCell($cell, $is_template);
+ }
$this->elements[] = $row;
--- 585行目あたり
function & insert(& $obj)
{
$this->elements[] = $obj->elements[0];
$this->types[] = $obj->type;
+ $this->style_cell[] = $obj->style_cell[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_cell[$nrow];
+ } else if ($stylecss != '' && $this->style_cell[$nro...
+ $this->style_cell[$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_cell[$nrow] == '') {
+// $tmp = $flag;
+ $tmp = '1';
+ } else {
+ $tmp = $this->style_cell[$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);
}
- $string = $this->wrap($string, 'table', ' class="styl...
+ $string = $this->wrap($string, 'table', ' class="' .
+ htmlspecialchars($this->style_table) . '" cellspacin...
return $this->wrap($string, 'div', ' class="ie5"');
}
-
見落としなどがあるかもしれませんが・・・。ちなみに、コメ...
- 質問箱4/243の前半部分は自動指定''のみ''の改造なので、個...
- 「各セルに個別のスタイルを指定したい」みたいな質問が、...
- 出来ました。本当にありがとうございます!&br;説明不足で...
#comment
終了行:
**[[質問箱/4580]] [#gb56bd75]
|RIGHT:100|LEFT:410|c
|~カテゴリ||
|~サマリ|テーブルの種類を増やしたい|
|~バージョン|1.4.7|
|~投稿者|[[gnil]]|
|~状態|完了|
|~投稿日|&new{2010-05-25 (火) 01:16:04};|
***質問 [#se0d9262]
自分で作成した表のスタイルを複数使い分けたいです。~
[[質問箱/4243]]の方法を試しましたが<table>のclass指定がで...
***回答 [#g71570cf]
- table のclass を個別に指定可能にする改造なら、[[質問箱/...
- [[質問箱/3510]]は試したのですがtableだけでth,tdが指定出...
- 別個に作成された改造なので変数名が被っているなどの問題...
if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out)...
の部分が被っている後半の改造だと予想して、回答しています...
- 前半のものは何故か上手く変更されないので後半にある改造...
if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $out...
の部分は
if (! preg_match('/^\|(.+)\|([hHfFcCsS]?)([12]?)$/', $t...
見たいに変えればいいのですかね?&br;詳しくないので分かり...
- やはり上手く行かないのでどなたか助言や良い方法がありま...
- paddingが違うのは[[CSS]]の設定の問題では? -- &new{201...
- paddingが違うのは意図的にやってるので知ってます、&br;[[...
- 質問箱3/510と質問箱4/243の差分を適当にマージしてみまし...
-- lib/convert_html.php (行数は、r1.18 の時の目安)
---115行目あたり
// '|'-separated table
function & Factory_Table(& $root, $text)
{
- if (! preg_match('/^\|(.+)\|([hHfFcC]?)$/', $text, $ou...
+ if (! preg_match('/^\|(.+)\|([hHfFcCsS]?)([12]?)$/', $...
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_table;
+ var $style_cell;
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_cell = array($out[3]);
$is_template = ($this->type == 'c');
$row = array();
- foreach ($cells as $cell)
- $row[] = & new TableCell($cell, $is_template);
+ $this->style_table = 'style_table';
+ if($this->type == 's') {
+ $this->style_table = trim(array_shift($cells));
+ for ($ncol = 0; $ncol < $this->col; $ncol++)
+ $row[] = & new TableCell('', $is_template);
+ } else {
+ foreach ($cells as $cell)
+ $row[] = & new TableCell($cell, $is_template);
+ }
$this->elements[] = $row;
--- 585行目あたり
function & insert(& $obj)
{
$this->elements[] = $obj->elements[0];
$this->types[] = $obj->type;
+ $this->style_cell[] = $obj->style_cell[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_cell[$nrow];
+ } else if ($stylecss != '' && $this->style_cell[$nro...
+ $this->style_cell[$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_cell[$nrow] == '') {
+// $tmp = $flag;
+ $tmp = '1';
+ } else {
+ $tmp = $this->style_cell[$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);
}
- $string = $this->wrap($string, 'table', ' class="styl...
+ $string = $this->wrap($string, 'table', ' class="' .
+ htmlspecialchars($this->style_table) . '" cellspacin...
return $this->wrap($string, 'div', ' class="ie5"');
}
-
見落としなどがあるかもしれませんが・・・。ちなみに、コメ...
- 質問箱4/243の前半部分は自動指定''のみ''の改造なので、個...
- 「各セルに個別のスタイルを指定したい」みたいな質問が、...
- 出来ました。本当にありがとうございます!&br;説明不足で...
#comment
ページ名: