Loading CHANGELOG.md +4 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.0.4 ------------------ - Améliorations : création de Display pour faciliter le debug & centralisation de toutes les conversions HTML dedans 6.0.3 ------------------ - [FIX] Correction de détection des numéros de lignes Loading src/Calc/Display.php 0 → 100644 +92 −0 Original line number Diff line number Diff line <?php namespace Unicaen\OpenDocument\Calc; use Unicaen\OpenDocument\Calc; class Display { static public function sheet(Sheet $sheet): string { $h = '<table class="table table-bordered table-condensed">'; $h .= '<tr><th></th>'; for ($c = 1; $c <= $sheet->getMaxCol(); $c++) { $h .= '<th>' . (Calc::numberToLetter($c)) . '</th>'; } $h .= '</tr>'; for ($r = 1; $r <= $sheet->getMaxRow(); $r++) { $h .= '<tr><th>' . $r . '</th>'; for ($c = 1; $c <= $sheet->getMaxCol(); $c++) { $cell = $sheet->getCellByCoords($c, $r); if ($cell && $cell->getRow() == $r && $cell->getCol() == $c) { $h .= '<td rowspan="' . $cell->getRowSpan() . '" colspan="' . $cell->getColSpan() . '">' . ($cell ? $cell->getValue() : '') . '</td>'; } elseif (!$cell) { $h .= '<td></td>'; } } $h .= '</tr>'; } $h .= '</table>'; return $h; } static public function formule(Formule $formule) { $h = ''; $h .= '<div style="clear: both"><code>' . htmlentities($formule->text()) . '</code></div>'; $expr = $formule->analyse(); $h .= self::formuleExpr($expr); return $h; } static public function formuleExpr(array $expr, $inFunction=false): string { $h = ''; if (isset($expr['type'])){ // sous-expression $h .= ' <table class="table table-bordered table-condensed table-xs" style="width:auto">'; foreach ($expr as $t => $v) { if ($t == 'level'){ continue; } if (is_array($v)){ $v = self::formuleExpr($v, $expr['type'] == 'function'); }else{ $v = htmlentities($v); } $h .= ' <tr>'; $h .= ' <th>' . $t . '</th>'; $h .= ' <td>' . $v . '</td>'; $h .= ' </tr>'; } $h .= ' </table>'; }else{ // liste de sous-expressions $h .= '<table class="table-xs"><tr>'; $first = true; foreach ($expr as $index => $term) { if ($inFunction && !$first){ $h .= '<td style="vertical-align: top"> ; </td>'; } $h .= '<td style="vertical-align: top">'.self::formuleExpr($term).'</td>'; $first = false; } $h .= '</tr></table>'; } return $h; } } No newline at end of file src/Calc/Formule.php +7 −44 Original line number Diff line number Diff line Loading @@ -45,6 +45,13 @@ class Formule public function text(): string { return $this->formule; } public function analyse(): array { if (empty($this->terms)) { Loading Loading @@ -87,42 +94,6 @@ class Formule public function displayTerms() { echo '<div style="clear: both"><code>' . htmlentities($this->formule) . '</code></div>'; echo '<div>'; foreach ($this->terms as $index => $term) { $this->displayTerm($index, $term); } echo '</div>'; } private function displayTerm(int $index, array $term) { $type = $term['type']; unset($term['type']); ?> <div style="width:120px;float:left;margin:2px"> <div class="panel panel-default"> <div class="panel-heading"><b><?= $index ?></b> <?= $type ?: '<span style="color:red">IND</span>' ?></div> <table class="table table-bordered table-condensed table-extra-condensed"> <?php foreach ($term as $t => $v): ?> <tr> <th><?= $t ?></th> <td><?= htmlentities($v) ?></td> </tr> <?php endforeach; ?> </table> </div> </div> <?php } private function lexing() { $lexers = [ Loading Loading @@ -445,12 +416,4 @@ class Formule $expr = array_values($expr); } public function displayExprs() { echo '<div style="clear:both">'; phpDump($this->expr); echo '</div>'; } } No newline at end of file src/Calc/Sheet.php +0 −28 Original line number Diff line number Diff line Loading @@ -236,32 +236,4 @@ class Sheet return $this->getCellByCoords($col, $row); } public function html(): string { $h = '<table class="table table-bordered table-condensed">'; $h .= '<tr><th></th>'; for ($c = 1; $c <= $this->getMaxCol(); $c++) { $h .= '<th>' . (Calc::numberToLetter($c)) . '</th>'; } $h .= '</tr>'; for ($r = 1; $r <= $this->getMaxRow(); $r++) { $h .= '<tr><th>' . $r . '</th>'; for ($c = 1; $c <= $this->getMaxCol(); $c++) { $cell = $this->getCellByCoords($c, $r); if ($cell && $cell->getRow() == $r && $cell->getCol() == $c) { $h .= '<td rowspan="' . $cell->getRowSpan() . '" colspan="' . $cell->getColSpan() . '">' . ($cell ? $cell->getValue() : '') . '</td>'; }elseif(!$cell){ $h .= '<td></td>'; } } $h .= '</tr>'; } $h .= '</table>'; return $h; } } No newline at end of file Loading
CHANGELOG.md +4 −0 Original line number Diff line number Diff line CHANGELOG ========= 6.0.4 ------------------ - Améliorations : création de Display pour faciliter le debug & centralisation de toutes les conversions HTML dedans 6.0.3 ------------------ - [FIX] Correction de détection des numéros de lignes Loading
src/Calc/Display.php 0 → 100644 +92 −0 Original line number Diff line number Diff line <?php namespace Unicaen\OpenDocument\Calc; use Unicaen\OpenDocument\Calc; class Display { static public function sheet(Sheet $sheet): string { $h = '<table class="table table-bordered table-condensed">'; $h .= '<tr><th></th>'; for ($c = 1; $c <= $sheet->getMaxCol(); $c++) { $h .= '<th>' . (Calc::numberToLetter($c)) . '</th>'; } $h .= '</tr>'; for ($r = 1; $r <= $sheet->getMaxRow(); $r++) { $h .= '<tr><th>' . $r . '</th>'; for ($c = 1; $c <= $sheet->getMaxCol(); $c++) { $cell = $sheet->getCellByCoords($c, $r); if ($cell && $cell->getRow() == $r && $cell->getCol() == $c) { $h .= '<td rowspan="' . $cell->getRowSpan() . '" colspan="' . $cell->getColSpan() . '">' . ($cell ? $cell->getValue() : '') . '</td>'; } elseif (!$cell) { $h .= '<td></td>'; } } $h .= '</tr>'; } $h .= '</table>'; return $h; } static public function formule(Formule $formule) { $h = ''; $h .= '<div style="clear: both"><code>' . htmlentities($formule->text()) . '</code></div>'; $expr = $formule->analyse(); $h .= self::formuleExpr($expr); return $h; } static public function formuleExpr(array $expr, $inFunction=false): string { $h = ''; if (isset($expr['type'])){ // sous-expression $h .= ' <table class="table table-bordered table-condensed table-xs" style="width:auto">'; foreach ($expr as $t => $v) { if ($t == 'level'){ continue; } if (is_array($v)){ $v = self::formuleExpr($v, $expr['type'] == 'function'); }else{ $v = htmlentities($v); } $h .= ' <tr>'; $h .= ' <th>' . $t . '</th>'; $h .= ' <td>' . $v . '</td>'; $h .= ' </tr>'; } $h .= ' </table>'; }else{ // liste de sous-expressions $h .= '<table class="table-xs"><tr>'; $first = true; foreach ($expr as $index => $term) { if ($inFunction && !$first){ $h .= '<td style="vertical-align: top"> ; </td>'; } $h .= '<td style="vertical-align: top">'.self::formuleExpr($term).'</td>'; $first = false; } $h .= '</tr></table>'; } return $h; } } No newline at end of file
src/Calc/Formule.php +7 −44 Original line number Diff line number Diff line Loading @@ -45,6 +45,13 @@ class Formule public function text(): string { return $this->formule; } public function analyse(): array { if (empty($this->terms)) { Loading Loading @@ -87,42 +94,6 @@ class Formule public function displayTerms() { echo '<div style="clear: both"><code>' . htmlentities($this->formule) . '</code></div>'; echo '<div>'; foreach ($this->terms as $index => $term) { $this->displayTerm($index, $term); } echo '</div>'; } private function displayTerm(int $index, array $term) { $type = $term['type']; unset($term['type']); ?> <div style="width:120px;float:left;margin:2px"> <div class="panel panel-default"> <div class="panel-heading"><b><?= $index ?></b> <?= $type ?: '<span style="color:red">IND</span>' ?></div> <table class="table table-bordered table-condensed table-extra-condensed"> <?php foreach ($term as $t => $v): ?> <tr> <th><?= $t ?></th> <td><?= htmlentities($v) ?></td> </tr> <?php endforeach; ?> </table> </div> </div> <?php } private function lexing() { $lexers = [ Loading Loading @@ -445,12 +416,4 @@ class Formule $expr = array_values($expr); } public function displayExprs() { echo '<div style="clear:both">'; phpDump($this->expr); echo '</div>'; } } No newline at end of file
src/Calc/Sheet.php +0 −28 Original line number Diff line number Diff line Loading @@ -236,32 +236,4 @@ class Sheet return $this->getCellByCoords($col, $row); } public function html(): string { $h = '<table class="table table-bordered table-condensed">'; $h .= '<tr><th></th>'; for ($c = 1; $c <= $this->getMaxCol(); $c++) { $h .= '<th>' . (Calc::numberToLetter($c)) . '</th>'; } $h .= '</tr>'; for ($r = 1; $r <= $this->getMaxRow(); $r++) { $h .= '<tr><th>' . $r . '</th>'; for ($c = 1; $c <= $this->getMaxCol(); $c++) { $cell = $this->getCellByCoords($c, $r); if ($cell && $cell->getRow() == $r && $cell->getCol() == $c) { $h .= '<td rowspan="' . $cell->getRowSpan() . '" colspan="' . $cell->getColSpan() . '">' . ($cell ? $cell->getValue() : '') . '</td>'; }elseif(!$cell){ $h .= '<td></td>'; } } $h .= '</tr>'; } $h .= '</table>'; return $h; } } No newline at end of file