| 1 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 2 | |||||||||||||||
| 3 | =encoding utf8 | ||||||||||||||
| 4 | |||||||||||||||
| 5 | =head1 NAME | ||||||||||||||
| 6 | |||||||||||||||
| 7 | Quiq::Html::Table::Base - Basisklasse für tabellengenerierende Klassen | ||||||||||||||
| 8 | |||||||||||||||
| 9 | =head1 BASE CLASS | ||||||||||||||
| 10 | |||||||||||||||
| 11 | L<Quiq::Hash> | ||||||||||||||
| 12 | |||||||||||||||
| 13 | =head1 DESCRIPTION | ||||||||||||||
| 14 | |||||||||||||||
| 15 | Diese Klasse dient als Basisklasse für speziellere tabellengenerierende | ||||||||||||||
| 16 | Klassen. Sie organisiert "des Drumherum" einer HTML-Tabelle. | ||||||||||||||
| 17 | Insbesondere besitzt sie die Attribute des table-Tag und rendert diesen. | ||||||||||||||
| 18 | Die Zeilen werden von der Klasse nicht behandelt, dies ist Aufgabe | ||||||||||||||
| 19 | der speziellen, abgeleiteten Klasse. | ||||||||||||||
| 20 | |||||||||||||||
| 21 | Abgeleitete Klassen rufen für die Basisfunktionalität den Konstruktor | ||||||||||||||
| 22 | und die html-Methode dieser Klasse auf. | ||||||||||||||
| 23 | |||||||||||||||
| 24 | =head1 ATTRIBUTES | ||||||||||||||
| 25 | |||||||||||||||
| 26 | =over 4 | ||||||||||||||
| 27 | |||||||||||||||
| 28 | =item border => $n (Default: 1) | ||||||||||||||
| 29 | |||||||||||||||
| 30 | Wert des border-Attriuts der Tabelle. | ||||||||||||||
| 31 | |||||||||||||||
| 32 | =item cellpadding => $n (Default: undef) | ||||||||||||||
| 33 | |||||||||||||||
| 34 | Wert des cellpadding-Attriuts der Tabelle. | ||||||||||||||
| 35 | |||||||||||||||
| 36 | =item cellspacing => $n (Default: 0) | ||||||||||||||
| 37 | |||||||||||||||
| 38 | Wert des cellspacing-Attriuts der Tabelle. | ||||||||||||||
| 39 | |||||||||||||||
| 40 | =item class => $class (Default: undef) | ||||||||||||||
| 41 | |||||||||||||||
| 42 | CSS Klasse der Tabelle. | ||||||||||||||
| 43 | |||||||||||||||
| 44 | =item flat => $bool (Default: 0) | ||||||||||||||
| 45 | |||||||||||||||
| 46 | Wenn wahr, wird der HTML-Code der Tabelle einzeilig generiert. | ||||||||||||||
| 47 | |||||||||||||||
| 48 | =item id => $id (Default: undef) | ||||||||||||||
| 49 | |||||||||||||||
| 50 | CSS-Id der Tabelle. | ||||||||||||||
| 51 | |||||||||||||||
| 52 | =item indentPos => $n (Default: 0) | ||||||||||||||
| 53 | |||||||||||||||
| 54 | Rücke den HTML-Code bis auf die erste Zeile um $n Leerzeichen ein. | ||||||||||||||
| 55 | Diese Option ist nützlich, wenn die Tabelle für einen Platzhalter mit | ||||||||||||||
| 56 | der Einrücktiefe $n in den HTML-Code eingesetzt werden soll. | ||||||||||||||
| 57 | |||||||||||||||
| 58 | =item style => $cssCode (Default: undef) | ||||||||||||||
| 59 | |||||||||||||||
| 60 | Wert des style-Attributs der Tabelle. | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =item width => $width (Default: undef) | ||||||||||||||
| 63 | |||||||||||||||
| 64 | Wert des width-Attributs der Tabelle. | ||||||||||||||
| 65 | |||||||||||||||
| 66 | =back | ||||||||||||||
| 67 | |||||||||||||||
| 68 | =cut | ||||||||||||||
| 69 | |||||||||||||||
| 70 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 71 | |||||||||||||||
| 72 | package Quiq::Html::Table::Base; | ||||||||||||||
| 73 | 3 | ▶ | use base qw/Quiq::Hash/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 74 | |||||||||||||||
| 75 | 3 | ▶ | use v5.10; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 76 | 3 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 77 | 3 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 78 | |||||||||||||||
| 79 | 3 | our $VERSION = '1.240'; | |||||||||||||
| 80 | |||||||||||||||
| 81 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 82 | |||||||||||||||
| 83 | =head1 METHODS | ||||||||||||||
| 84 | |||||||||||||||
| 85 | =head2 Konstruktor | ||||||||||||||
| 86 | |||||||||||||||
| 87 | =head3 new() - Konstruktor | ||||||||||||||
| 88 | |||||||||||||||
| 89 | =head4 Synopsis | ||||||||||||||
| 90 | |||||||||||||||
| 91 | $e = $class->new(@keyVal); | ||||||||||||||
| 92 | |||||||||||||||
| 93 | =head4 Description | ||||||||||||||
| 94 | |||||||||||||||
| 95 | Instantiiere ein Tabellenobjekt mit den Eingenschaften @keyVal und | ||||||||||||||
| 96 | liefere eine Referenz auf dieses Objekt zurück. | ||||||||||||||
| 97 | |||||||||||||||
| 98 | Da der Konstruktor von einer Subklasse gerufen wird, kann die Subklasse | ||||||||||||||
| 99 | den Umfang der Attribute erweitern. | ||||||||||||||
| 100 | |||||||||||||||
| 101 | =cut | ||||||||||||||
| 102 | |||||||||||||||
| 103 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 104 | |||||||||||||||
| 105 | 5 | ▶ | sub new { | ||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 106 | 5 | my $class = shift; | |||||||||||||
| 107 | # @_: @keyVal | ||||||||||||||
| 108 | |||||||||||||||
| 109 | # Defaultwerte | ||||||||||||||
| 110 | |||||||||||||||
| 111 | 5 | my $self = $class->SUPER::new( | |||||||||||||
| 112 | border => 1, | ||||||||||||||
| 113 | cellpadding => undef, | ||||||||||||||
| 114 | cellspacing => 0, | ||||||||||||||
| 115 | class => undef, | ||||||||||||||
| 116 | flat => 0, | ||||||||||||||
| 117 | id => undef, | ||||||||||||||
| 118 | indentPos => 0, | ||||||||||||||
| 119 | style => undef, | ||||||||||||||
| 120 | width => undef, | ||||||||||||||
| 121 | @_, # Umfang der Attribute kann von Subklasse erweitert werden | ||||||||||||||
| 122 | ); | ||||||||||||||
| 123 | |||||||||||||||
| 124 | 5 | return $self; | |||||||||||||
| 125 | } | ||||||||||||||
| 126 | |||||||||||||||
| 127 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 128 | |||||||||||||||
| 129 | =head2 Objektmethoden | ||||||||||||||
| 130 | |||||||||||||||
| 131 | =head3 html() - Generiere HTML-Code | ||||||||||||||
| 132 | |||||||||||||||
| 133 | =head4 Synopsis | ||||||||||||||
| 134 | |||||||||||||||
| 135 | $html = $e->html($h,$body); | ||||||||||||||
| 136 | $html = $class->html($h,$body,@keyVal); | ||||||||||||||
| 137 | |||||||||||||||
| 138 | =head4 Arguments | ||||||||||||||
| 139 | |||||||||||||||
| 140 | =over 4 | ||||||||||||||
| 141 | |||||||||||||||
| 142 | =item $h | ||||||||||||||
| 143 | |||||||||||||||
| 144 | HTML Tag-Objekt. | ||||||||||||||
| 145 | |||||||||||||||
| 146 | =item $body | ||||||||||||||
| 147 | |||||||||||||||
| 148 | HTML-Code mit den Zeilen (Kopf und Rumpf) der Tabelle. | ||||||||||||||
| 149 | |||||||||||||||
| 150 | =item @keyVal | ||||||||||||||
| 151 | |||||||||||||||
| 152 | Attribut-Wert-Paare des Konstruktoraufrufs, wenn die | ||||||||||||||
| 153 | Methode das Objekt instantiieren soll. | ||||||||||||||
| 154 | |||||||||||||||
| 155 | =back | ||||||||||||||
| 156 | |||||||||||||||
| 157 | =head4 Description | ||||||||||||||
| 158 | |||||||||||||||
| 159 | Generiere den HTML-Code der Tablle und liefere diesen zurück. | ||||||||||||||
| 160 | |||||||||||||||
| 161 | =cut | ||||||||||||||
| 162 | |||||||||||||||
| 163 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 164 | |||||||||||||||
| 165 | 4 | ▶ | sub html { | ||||||||||||
|
Subroutine
html: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||
| 166 | 4 | my $this = shift; | |||||||||||||
| 167 | 4 | my $h = shift; | |||||||||||||
| 168 | 4 | my $body = shift; | |||||||||||||
| 169 | # @_: @keyVal | ||||||||||||||
| 170 | |||||||||||||||
| 171 | 4 | ▶ | my $self = ref $this? $this: $this->new(@_); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 172 | |||||||||||||||
| 173 | # Attribute | ||||||||||||||
| 174 | |||||||||||||||
| 175 | 4 | my ($border,$cellpadding,$cellspacing,$class,$flat,$id,$indentPos, | |||||||||||||
| 176 | $style,$width) = | ||||||||||||||
| 177 | $self->get(qw/border cellpadding cellspacing class flat id indentPos | ||||||||||||||
| 178 | style width/); | ||||||||||||||
| 179 | |||||||||||||||
| 180 | # Generierung | ||||||||||||||
| 181 | |||||||||||||||
| 182 | 4 | ▶ | return '' if !defined $body; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 183 | |||||||||||||||
| 184 | # Nicht-leer | ||||||||||||||
| 185 | |||||||||||||||
| 186 | 3 | ▶ | my $html = $h->tag('table', | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 187 | -indPos => $indentPos, | ||||||||||||||
| 188 | $flat? (-fmt=>'p',-nl=>0): (-fmt=>'v',-nl=>1), | ||||||||||||||
| 189 | class => $class, | ||||||||||||||
| 190 | id => $id, | ||||||||||||||
| 191 | style => $style, | ||||||||||||||
| 192 | border => $border? $border: undef, | ||||||||||||||
| 193 | cellpadding => $cellpadding, | ||||||||||||||
| 194 | cellspacing => $cellspacing, | ||||||||||||||
| 195 | width => $width, | ||||||||||||||
| 196 | $body, | ||||||||||||||
| 197 | ); | ||||||||||||||
| 198 | |||||||||||||||
| 199 | 3 | return $html; | |||||||||||||
| 200 | } | ||||||||||||||
| 201 | |||||||||||||||
| 202 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 203 | |||||||||||||||
| 204 | =head1 VERSION | ||||||||||||||
| 205 | |||||||||||||||
| 206 | 1.240 | ||||||||||||||
| 207 | |||||||||||||||
| 208 | =head1 AUTHOR | ||||||||||||||
| 209 | |||||||||||||||
| 210 | Frank Seitz, L<http://fseitz.de/> | ||||||||||||||
| 211 | |||||||||||||||
| 212 | =head1 COPYRIGHT | ||||||||||||||
| 213 | |||||||||||||||
| 214 | Copyright (C) 2026 Frank Seitz | ||||||||||||||
| 215 | |||||||||||||||
| 216 | =head1 LICENSE | ||||||||||||||
| 217 | |||||||||||||||
| 218 | This code is free software; you can redistribute it and/or modify | ||||||||||||||
| 219 | it under the same terms as Perl itself. | ||||||||||||||
| 220 | |||||||||||||||
| 221 | =cut | ||||||||||||||
| 222 | |||||||||||||||
| 223 | # ----------------------------------------------------------------------------- | ||||||||||||||
| 224 | |||||||||||||||
| 225 | 3 | 1; | |||||||||||||
| 226 | |||||||||||||||
| 227 | # eof | ||||||||||||||