• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Révision3e2e3016390a7550c3cdc0c3cfc6f8d41d719927 (tree)
l'heure2014-11-30 10:24:01
Auteurhenoheno <henoheno>
Commiterumorigu

Message de Log

BugTrack2/269: YTable(): Cleanup

Change Summary

Modification

--- a/lib/convert_html.php
+++ b/lib/convert_html.php
@@ -654,46 +654,61 @@ class Table extends Element
654654 }
655655 }
656656
657-// , title1 , title2 , title3
658-// , cell1 , cell2 , cell3
659-// , cell4 , cell5 , cell6
657+// , cell1 , cell2 , cell3
658+// , cell4 , cell5 , cell6
659+// , cell7 , right,==
660+// ,left ,==, cell8
660661 class YTable extends Element
661662 {
662- var $col;
663+ var $col; // Number of columns
663664
664- function YTable($_value)
665+ // TODO: Seems unable to show literal '==' without tricks.
666+ // But it will be imcompatible.
667+ // TODO: Why toString() or toXHTML() here
668+ function YTable($row = array('cell1 ', ' cell2 ', ' cell3'))
665669 {
666670 parent::Element();
667671
668- $align = $value = $matches = array();
669- foreach($_value as $val) {
670- if (preg_match('/^(\s+)?(.+?)(\s+)?$/', $val, $matches)) {
671- $align[] =($matches[1] != '') ?
672- ((isset($matches[3]) && $matches[3] != '') ?
673- ' style="text-align:center"' :
674- ' style="text-align:right"'
675- ) : '';
676- $value[] = $matches[2];
672+ $str = array();
673+ $col = count($row);
674+
675+ $matches = $_value = $_align = array();
676+ foreach($row as $cell) {
677+ if (preg_match('/^(\s+)?(.+?)(\s+)?$/', $cell, $matches)) {
678+ if ($matches[2] == '==') {
679+ // Colspan
680+ $_value[] = FALSE;
681+ $_align[] = FALSE;
682+ } else {
683+ $_value[] = $matches[2];
684+ if ($matches[1] == '') {
685+ $_align[] = ''; // left
686+ } else if (isset($matches[3])) {
687+ $_align[] = 'center';
688+ } else {
689+ $_align[] = 'right';
690+ }
691+ }
677692 } else {
678- $align[] = '';
679- $value[] = $val;
693+ $_value[] = $cell;
694+ $_align[] = '';
680695 }
681696 }
682- $this->col = count($value);
683- $colspan = array();
684- foreach ($value as $val)
685- $colspan[] = ($val == '==') ? 0 : 1;
686- $str = '';
687- $count = count($value);
688- for ($i = 0; $i < $count; $i++) {
689- if ($colspan[$i]) {
690- while ($i + $colspan[$i] < $count && $value[$i + $colspan[$i]] == '==')
691- $colspan[$i]++;
692- $colspan[$i] = ($colspan[$i] > 1) ? ' colspan="' . $colspan[$i] . '"' : '';
693- $str .= '<td class="style_td"' . $align[$i] . $colspan[$i] . '>' . make_link($value[$i]) . '</td>';
694- }
697+
698+ for ($i = 0; $i < $col; $i++) {
699+ if ($_value[$i] === FALSE) continue;
700+ $colspan = 1;
701+ while (isset($_value[$i + $colspan]) && $_value[$i + $colspan] === FALSE) ++$colspan;
702+ $colspan = ($colspan > 1) ? ' colspan="' . $colspan . '"' : '';
703+ $align = $_align[$i] ? ' style="text-align:' . $_align[$i] . '"' : '';
704+ $str[] = '<td class="style_td"' . $align . $colspan . '>';
705+ $str[] = make_link($_value[$i]);
706+ $str[] = '</td>';
707+ unset($_value[$i], $_align[$i]);
695708 }
696- $this->elements[] = $str;
709+
710+ $this->col = $col;
711+ $this->elements[] = implode('', $str);
697712 }
698713
699714 function canContain(& $obj)
@@ -710,8 +725,9 @@ class YTable extends Element
710725 function toString()
711726 {
712727 $rows = '';
713- foreach ($this->elements as $str)
728+ foreach ($this->elements as $str) {
714729 $rows .= "\n" . '<tr class="style_tr">' . $str . '</tr>' . "\n";
730+ }
715731 $rows = $this->wrap($rows, 'table', ' class="style_table" cellspacing="1" border="0"');
716732 return $this->wrap($rows, 'div', ' class="ie5"');
717733 }