Lazy/Template/Boilerplate.pm

filter: Statementstmt 17.4% 38 / 218 Branchbran 0.0% 0 / 58 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 8.3% 2 / 24 Podpod 4.5% 1 / 22 totaltotal 12.7% 41 / 322 CC 40 SCAR 35.3
CC
40
Cov
14%
buildTmplDatasetSingle
90.0
buildTmplDatasetMultiple
56.0
buildTemplates
42.0
CRAP 34.2
« Lazy/Session/Data.pm ↑ Summary Lazy/Widget/Composite.pm »
1 package CGI::Lazy::Template::Boilerplate;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use CGI::Lazy::Globals;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $datasetMultipleStartBegin = <<END;
8 <table id="__WIDGETID__Table">
9 <caption> <tmpl_var name="CAPTION"> </caption>
10 <tr> <!-- even if you don't use this row, leave it here, or pushRow will break -->
11 END
12  
13 1 our $datasetMultipleHDR = <<END;
14 <th>
15 <tmpl_var name='HEADING.ITEM.__FIELDNAME__'>
16 </th>
17  
18 END
19  
20 1 our $datasetMultipleStartEnd = <<END;
21 </tr>
22 <tmpl_loop name='ROW.LOOP'>
23 <tr id="<tmpl_var name="ROW">">
24  
25 END
26  
27 1 our $tdPrototypeMultiText = <<END;
28 <td>
29 <input
30 type="text"
31 name="<tmpl_var name='NAME.__FIELDNAME__'>"
32 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
33 id="<tmpl_var name='ID.__FIELDNAME__'>"
34 onchange="__WIDGETID__Controller.unflag(this);__WIDGETID__Controller.pushRow(this);"
35 />
36 </td>
37 END
38  
39 1 our $tdPrototypeMultiSelect = <<END;
40 <td>
41 <select
42 name="<tmpl_var name='NAME.__FIELDNAME__'>"
43 id="<tmpl_var name='ID.__FIELDNAME__'>"
44 onchange="__WIDGETID__Controller.unflag(this);__WIDGETID__Controller.pushRow(this);"
45 />
46 <tmpl_loop name="LOOP.__FIELDNAME__">
47 <option value="<tmpl_var name="ITEM.VALUE">" <tmpl_var name="ITEM.SELECTED">> <tmpl_var name="ITEM.LABEL"> </option>
48 </tmpl_loop>
49 </select>
50 </td>
51 END
52  
53 1 our $tdPrototypeMultiCheckbox = <<END;
54 <td>
55 <input
56 type="checkbox"
57 <tmpl_var name='CHECKED.__FIELDNAME__'>
58 name="<tmpl_var name='NAME.__FIELDNAME__'>"
59 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
60 id="<tmpl_var name='ID.__FIELDNAME__'>"
61 onchange="__WIDGETID__Controller.unflag(this); __WIDGETID__Controller.pushRow(this);"
62 />
63 </td>
64 END
65  
66 1 our $tdPrototypeMultiRadio = <<END;
67 <td>
68 <tmpl_loop name="LOOP.__FIELDNAME__">
69 <tmpl_var name='VALUELABEL.__FIELDNAME__'>
70 <input
71 type="radio"
72 <tmpl_var name='CHECKED.__FIELDNAME__'>
73 name="<tmpl_var name='NAME.__FIELDNAME__'>"
74 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
75 id="<tmpl_var name='ID.__FIELDNAME__'>"
76 onchange="__WIDGETID__Controller.unflag(this);__WIDGETID__Controller.pushRow(this);"
77 />
78 </tmpl_loop>
79 </td>
80  
81 END
82  
83 1 our $tdPrototypeMultiRO = <<END;
84 <td>
85 <tmpl_var name='VALUE.__FIELDNAME__'>
86 </td>
87 END
88  
89 1 our $tdPrototypeSingleMulti = <<END;
90 <td>
91 <tmpl_var name='VALUE.__FIELDNAME__'>
92 </td>
93 END
94  
95 1 our $tdPrototypeSingleText = <<END;
96 <td>
97 <input
98 type="text"
99 name="<tmpl_var name='NAME.__FIELDNAME__'>"
100 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
101 id="<tmpl_var name='ID.__FIELDNAME__'>"
102 onchange="__WIDGETID__Controller.unflag(this);"
103 />
104 </td>
105 END
106  
107 1 our $tdPrototypeSingleRadio = <<END;
108 <td>
109 <tmpl_loop name="LOOP.__FIELDNAME__">
110 <tmpl_var name='VALUELABEL.__FIELDNAME__'>
111 <input
112 type="radio"
113 <tmpl_var name='CHECKED.__FIELDNAME__'>
114 name="<tmpl_var name='NAME.__FIELDNAME__'>"
115 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
116 id="<tmpl_var name='ID.__FIELDNAME__'>"
117 onchange="__WIDGETID__Controller.unflag(this);"
118 />
119 </tmpl_loop>
120 </td>
121  
122 END
123  
124 1 our $tdPrototypeSingleCheckbox = <<END;
125 <td>
126 <input
127 type="checkbox"
128 <tmpl_var name="CHECKED.__FIELDNAME__">
129 name="<tmpl_var name='NAME.__FIELDNAME__'>"
130 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
131 id="<tmpl_var name='ID.__FIELDNAME__'>"
132 onchange="__WIDGETID__Controller.unflag(this);"
133 />
134 </td>
135 END
136  
137 1 our $tdPrototypeSingleSelect = <<END;
138 <td>
139 <select
140 name="<tmpl_var name='NAME.__FIELDNAME__'>"
141 id="<tmpl_var name='ID.__FIELDNAME__'>"
142 onchange="__WIDGETID__Controller.unflag(this);"
143 >
144 <tmpl_loop name="LOOP.__FIELDNAME__">
145 <option value="<tmpl_var name="ITEM.VALUE">" <tmpl_var name="ITEM.SELECTED"> > <tmpl_var name="ITEM.LABEL"> </option>
146 </tmpl_loop>
147  
148 </select>
149 </td>
150 END
151  
152 1 our $tdPrototypeSingleRO = <<END;
153 <td>
154 <tmpl_var name='VALUE.__FIELDNAME__'>
155 </td>
156 END
157  
158 1 our $datasetDeleteTd = <<END;
159 <tmpl_if name="DELETE.FLAG">
160 <td>
161 <input
162 type = 'checkbox'
163 tabindex=-1
164 id = "<tmpl_var name = 'DELETE.ID'>"
165 onclick="__WIDGETID__Controller.deleteRow(this);"
166 >
167 </td>
168 </tmpl_if>
169 END
170  
171 1 our $datasetMultipleEnd = <<END;
172 </tr>
173 </tmpl_loop>
174 </table>
175 END
176  
177 1 our $cssClean = <<END;
178 div#__WIDGETID__ {
179  
180 }
181  
182 END
183  
184 1 our $datasetSingleStart = <<END;
185 <table id="__WIDGETID__.table">
186 END
187  
188 1 our $datasetSingleRowStart = <<END;
189 <tr>
190 END
191  
192 1 our $datasetSingleLableTd = <<END;
193 <td
194 id="__FIELDNAME__Label">
195 <tmpl_var name="LABEL.__FIELDNAME__">
196 </td>
197 END
198  
199 1 our $datasetSingleRowEnd = <<END;
200 </tr>
201  
202 END
203  
204 1 our $datasetSingleEnd = <<END;
205
206 </table>
207  
208 END
209  
210 1 our $datasetMultipleHeaderStart = <<END;
211 <div id="__WIDGETID__HDR">
212 <table>
213 <caption> <tmpl_var name="CAPTION"> </caption>
214 <tr>
215  
216 END
217  
218 1 our $datasetMultipleHeaderDeleteTd = <<END;
219 <th>
220 <tmpl_var name="HEADING.ITEM.DELETE">
221 </th>
222  
223 END
224  
225 1 our $datasetMultipleHeaderEnd = <<END;
226 </tr>
227  
228  
229 </table>
230 </div>
231  
232  
233 END
234  
235 1 our $controllerStart = <<END;
236 <table>
237 <tr>
238  
239 END
240  
241 1 our $controllerEnd = <<END;
242 </tr>
243 </table>
244  
245 END
246  
247 1 our $tdPrototypeControllerSelect = <<END;
248 <td>
249 <select
250 name="<tmpl_var name='NAME.__FIELDNAME__'>"
251 id="<tmpl_var name='ID.__FIELDNAME__'>"
252 onchange="__WIDGETID__Controller.select();"
253 />
254 <tmpl_loop name="LOOP.__FIELDNAME__">
255 <option value="<tmpl_var name="ITEM.VALUE">" <tmpl_var name="ITEM.SELECTED">> <tmpl_var name="ITEM.LABEL"> </option>
256 </tmpl_loop>
257 </select>
258 </td>
259 END
260  
261 1 our $tdPrototypeControllerCheckbox = <<END;
262 <td>
263 <input
264 type="checkbox"
265 <tmpl_var name='CHECKED.__FIELDNAME__'>
266 name="<tmpl_var name='NAME.__FIELDNAME__'>"
267 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
268 id="<tmpl_var name='ID.__FIELDNAME__'>"
269 onchange="__WIDGETID__Controller.select();"
270 />
271 </td>
272 END
273  
274 1 our $tdPrototypeControllerRadio = <<END;
275 <td>
276 <tmpl_loop name="LOOP.__FIELDNAME__">
277 <tmpl_var name='VALUELABEL.__FIELDNAME__'>
278 <input
279 type="radio"
280 <tmpl_var name='CHECKED.__FIELDNAME__'>
281 name="<tmpl_var name='NAME.__FIELDNAME__'>"
282 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
283 id="<tmpl_var name='ID.__FIELDNAME__'>"
284 onchange="__WIDGETID__Controller.select();"
285 />
286 </tmpl_loop>
287 </td>
288  
289 END
290  
291 1 our $tdPrototypeControllerText = <<END;
292 <td>
293 <input
294 type="text"
295 name="<tmpl_var name='NAME.__FIELDNAME__'>"
296 value="<tmpl_var name='VALUE.__FIELDNAME__'>"
297 id="<tmpl_var name='ID.__FIELDNAME__'>"
298 onchange="__WIDGETID__Controller.select();"
299 />
300 </td>
301 END
302  
303 #--------------------------------------------------------------------------------------------
304 0 ▶sub buildTmplController {
Subroutine buildTmplController: not called CC=5 SCAR=34.0
Pod undocumented
305 0 my $self = shift;
306  
307 0 my $tmpl = $controllerStart;
308  
309 0 foreach my $control (@{$self->controls}) {
310 0 my $type = $control->{type};
311  
312 0 ▶ if ($type eq 'select') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'select') { } 0 0 0
elsif ($type eq 'checkbox') { } 0 0 0
elsif ($type eq 'radio') { } 0 0 0
313 0 $tmpl .= $self->parse4FieldAndID($control->{name}, $tdPrototypeControllerSelect);
314 } elsif ($type eq 'checkbox') {
315 0 $tmpl .= $self->parse4FieldAndID($control->{name}, $tdPrototypeControllerCheckbox);
316 } elsif ($type eq 'radio') {
317 0 $tmpl .= $self->parse4FieldAndID($control->{name}, $tdPrototypeControllerRadio);
318 } else {
319 0 $tmpl .= $self->parse4FieldAndID($control->{name}, $tdPrototypeControllerText);
320 }
321 }
322
323 0 $tmpl .= $controllerEnd;
324  
325 0 return $self->outputTmpl($tmpl, 'Controller');
326 }
327  
328 #--------------------------------------------------------------------------------------------
329 0 ▶sub buildTmplDatasetMultiple {
Subroutine buildTmplDatasetMultiple: not called CC=7 SCAR=40.3
Pod undocumented
330 0 my $self = shift;
331  
332 0 my $tmpl = $self->parse4ID($datasetMultipleStartBegin);
333 0 $tmpl .= $self->parse4Field($_, $datasetMultipleHDR) for $self->widget->recordset->visibleFields;
334 0 $tmpl .= $datasetMultipleStartEnd;
335
336 0 foreach my $fieldname (@{$self->fieldlist}) {
337 0 ▶ if ($self->widget->recordset->webcontrol($fieldname)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->widget->recordset->webcontrol($fieldname)) { } 0 0 0
338 0 my $webcontrol = $self->widget->recordset->webcontrol($fieldname);
339 0 my $type = $webcontrol->{type};
340  
341 0 ▶ if ($type eq 'select') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'select') { } 0 0 0
elsif ($type eq 'checkbox') { } 0 0 0
elsif ($type eq 'radio') { } 0 0 0
342 0 $tmpl .= $self->parse4FieldAndID($fieldname, $tdPrototypeMultiSelect);
343 } elsif ($type eq 'checkbox') {
344 0 $tmpl .= $self->parse4FieldAndID($fieldname, $tdPrototypeMultiCheckbox);
345 } elsif ($type eq 'radio') {
346 0 $tmpl .= $self->parse4FieldAndID($fieldname, $tdPrototypeMultiRadio);
347 } else {
348 0 $tmpl .= $self->parse4FieldAndID($fieldname, $tdPrototypeMultiText);
349 }
350 } else {
351 0 $tmpl .= $self->parse4FieldAndID($fieldname, $tdPrototypeMultiText);
352 }
353 }
354  
355 0 $tmpl .= $self->parse4ID($datasetDeleteTd);
356 0 $tmpl .= $self->parse4ID($datasetMultipleEnd);
357  
358 0 $self->outputTmpl($tmpl);
359 }
360  
361 #--------------------------------------------------------------------------------------------
362 0 ▶sub buildTmplDatasetMultipleHeadings {
Subroutine buildTmplDatasetMultipleHeadings: not called CC=2 SCAR=17.9
Pod undocumented
363 0 my $self = shift;
364  
365 0 my $tmpl = $self->parse4ID($datasetMultipleHeaderStart);
366 0 $tmpl .= $self->parse4Field($_, $datasetMultipleHDR) for @{$self->fieldlist};
367 0 $tmpl .= $self->parse4ID($datasetMultipleHeaderDeleteTd);
368 0 $tmpl .= $self->parse4ID($datasetMultipleHeaderEnd);
369  
370 0 $self->outputTmpl($tmpl, 'HDR');
371 }
372  
373 #--------------------------------------------------------------------------------------------
374 0 ▶sub buildTmplDatasetMultipleRO {
Subroutine buildTmplDatasetMultipleRO: not called CC=3 SCAR=24.8
Pod undocumented
375 0 my $self = shift;
376  
377 0 my $tmpl = $self->parse4ID($datasetMultipleStartBegin);
378 0 $tmpl .= $self->parse4Field($_, $datasetMultipleHDR) for $self->widget->recordset->visibleFields;
379 0 $tmpl .= $datasetMultipleStartEnd;
380 0 $tmpl .= $self->parse4FieldAndID($_, $tdPrototypeMultiRO) for @{$self->fieldlist};
381 0 $tmpl .= $self->parse4ID($datasetMultipleEnd);
382  
383 0 $self->outputTmpl($tmpl, 'RO');
384 }
385  
386 #--------------------------------------------------------------------------------------------
387 0 ▶sub buildTmplDatasetSingle {
Subroutine buildTmplDatasetSingle: not called CC=9 SCAR=45.0
Pod undocumented
388 0 my $self = shift;
389  
390 0 my $widgetID = $self->widgetID;
391 0 my $fieldlist = $self->fieldlist;
392 0 my $fields = scalar @$fieldlist;
393 0 ▶ my $rows = ($fields / 5 == int $fields) ? $fields / 5 : int $fields / 5 + 1;
Branch: 1 branch
BranchTrueFalseTotal
$fields / 5 == int $fields ? : 0 0 0
394  
395 0 my $tmpl = $self->parse4ID($datasetSingleStart);
396  
397 0 my $field = 0;
398 0 ▶ for (my $i = 0; $i < $rows; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $rows) 0 0 0
399 0 my $column = 0;
400 0 $tmpl .= $datasetSingleRowStart;
401 0 ▶ while ($column < 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column < 6) 0 0 0
402 0 ▶ if ($fieldlist->[$field]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldlist->[$field]) 0 0 0
403 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $datasetSingleLableTd);
404  
405 0 ▶ if ($self->widget->recordset->webcontrol($fieldlist->[$field])) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->widget->recordset->webcontrol($fieldlist->[$field])) { } 0 0 0
406 0 my $webcontrol = $self->widget->recordset->webcontrol($fieldlist->[$field]);
407 0 my $type = $webcontrol->{type};
408  
409 0 ▶ if ($type eq 'select') {
Branch: 3 branches
BranchTrueFalseTotal
if ($type eq 'select') { } 0 0 0
elsif ($type eq 'checkbox') { } 0 0 0
elsif ($type eq 'radio') { } 0 0 0
410 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleSelect));
411 } elsif ($type eq 'checkbox') {
412 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleCheckbox));
413 } elsif ($type eq 'radio') {
414 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleRadio));
415 } else {
416 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleText));
417 }
418 } else {
419 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleText));
420 }
421 }
422 0 $column++;
423 0 $field++;
424 }
425  
426 0 $tmpl .= $datasetSingleRowEnd;
427  
428 }
429  
430 0 $tmpl .= $self->parse4ID($datasetSingleEnd);
431  
432 0 $self->outputTmpl($tmpl);
433 }
434  
435 #--------------------------------------------------------------------------------------------
436 0 ▶sub buildTmplDatasetSingleRO {
Subroutine buildTmplDatasetSingleRO: not called CC=5 SCAR=34.0
Pod undocumented
437 0 my $self = shift;
438  
439 0 my $widgetID = $self->widgetID;
440 0 my $fieldlist = $self->fieldlist;
441 0 my $fields = scalar @$fieldlist;
442 0 ▶ my $rows = ($fields / 5 == int $fields) ? $fields / 5 : int $fields / 5 + 1;
Branch: 1 branch
BranchTrueFalseTotal
$fields / 5 == int $fields ? : 0 0 0
443  
444 0 my $tmpl = $self->parse4ID($datasetSingleStart);
445  
446 0 my $field = 0;
447 0 ▶ for (my $i = 0; $i < $rows; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $rows) 0 0 0
448 0 my $column = 0;
449 0 $tmpl .= $datasetSingleRowStart;
450 0 ▶ while ($column < 6) {
Branch: 1 branch
BranchTrueFalseTotal
if ($column < 6) 0 0 0
451 0 ▶ if ($fieldlist->[$field]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fieldlist->[$field]) 0 0 0
452 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $datasetSingleLableTd);
453 0 $tmpl .= $self->parse4Field($fieldlist->[$field], $self->parse4ID($tdPrototypeSingleRO));
454 }
455 0 $column++;
456 0 $field++;
457 }
458  
459 0 $tmpl .= $datasetSingleRowEnd;
460  
461 }
462  
463 0 $tmpl .= $self->parse4ID($datasetSingleEnd);
464  
465 0 $self->outputTmpl($tmpl, 'RO');
466 }
467  
468 #--------------------------------------------------------------------------------------------
469 0 ▶sub buildTmplDatasetSingleMulti {
Subroutine buildTmplDatasetSingleMulti: not called CC=3 SCAR=24.8
Pod undocumented
470 0 my $self = shift;
471  
472 0 my $tmpl = $self->parse4ID($datasetMultipleStartBegin);
473 0 $tmpl .= $self->parse4Field($_, $datasetMultipleHDR) for $self->widget->recordset->multipleFieldList;
474 0 $tmpl .= $datasetMultipleStartEnd;
475 0 $tmpl .= $self->parse4Field($_, $tdPrototypeSingleMulti) for @{$self->fieldlist};
476 0 $tmpl .= $self->parse4ID($datasetMultipleEnd);
477  
478 0 $self->outputTmpl($tmpl, 'Multi');
479 }
480 #--------------------------------------------------------------------------------------------
481 0 ▶sub buildTemplates {
Subroutine buildTemplates: not called CC=6 SCAR=37.4
Pod documented
482 0 my $self = shift;
483
484 0 ▶ if ($self->{_composite} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_composite"}) 0 0 0
485 0 $_->buildTemplates foreach (@{$self->{_members}});
486 0 return;
487 }
488  
489 0 ▶ if ($self->type eq 'Dataset-single') {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->type eq 'Dataset-single') { } 0 0 0
elsif ($self->type eq 'Dataset-multi') { } 0 0 0
elsif ($self->type eq 'Controller') { } 0 0 0
490 0 $self->buildTmplDatasetSingle;
491 0 $self->buildTmplDatasetSingleMulti;
492 0 $self->buildTmplDatasetSingleRO;
493  
494 } elsif ($self->type eq 'Dataset-multi') {
495 0 $self->buildTmplDatasetMultiple;
496 0 $self->buildTmplDatasetMultipleRO;
497 0 $self->buildTmplDatasetMultipleHeadings;
498  
499 } elsif ($self->type eq 'Controller') {
500 0 $self->buildTmplController;
501  
502 }
503  
504 0 return;
505 }
506  
507 #--------------------------------------------------------------------------------------------
508 0 ▶sub controls {
Subroutine controls: not called CC=1 SCAR=6.9
Pod undocumented
509 0 my $self = shift;
510  
511 0 return $self->{_controls};
512 }
513  
514 #--------------------------------------------------------------------------------------------
515 0 ▶sub fieldlist {
Subroutine fieldlist: not called CC=1 SCAR=6.9
Pod undocumented
516 0 my $self = shift;
517  
518 0 return $self->{_fieldlist};
519 }
520  
521 #--------------------------------------------------------------------------------------------
522 0 ▶sub new {
Subroutine new: not called CC=6 SCAR=37.4
Pod undocumented
523 0 my $class = shift;
524 0 my $template = shift;
525 0 my $widget = shift;
526  
527  
528 0 ▶ die "Boilerplate called with no widget!" unless $widget;
Branch: 1 branch
BranchTrueFalseTotal
unless $widget 0 0 0
529  
530  
531 0 my $self = {
532 _template => $template,
533 _widget => $widget,
534 };
535  
536 0 ▶ if (ref $widget eq 'CGI::Lazy::Widget::Dataset') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $widget eq 'CGI::Lazy::Widget::Dataset') { } 0 0 0
elsif (ref $widget eq 'CGI::Lazy::Widget::Controller') { } 0 0 0
elsif (ref $widget eq 'CGI::Lazy::Widget::Composite') { } 0 0 0
537 0 $self->{_widgetID} = $widget->widgetID;
538 0 $self->{_fieldlist} = $widget->recordset->visibleFields;
539 0 $self->{_type} = 'Dataset-'.$widget->type;
540 0 $self->{_style} = $widget->vars->{style};
541  
542 } elsif (ref $widget eq 'CGI::Lazy::Widget::Controller') {
543 0 $self->{_widgetID} = $widget->widgetID;
544 0 $self->{_type} = 'Controller';
545 0 $self->{_controls} = $widget->controls;
546
547 } elsif (ref $widget eq 'CGI::Lazy::Widget::Composite') {
548 0 $self->{_widgetID} = $widget->widgetID;
549 0 $self->{_composite} = 1;
550  
551 0 foreach (@{$widget->memberarray}) {
552 0 push @{$self->{_members}}, $template->boilerplate($_);
553 }
554 }
555  
556  
557 0 return bless $self, $class;
558 }
559  
560 #--------------------------------------------------------------------------------------------
561 0 ▶sub output {
Subroutine output: not called CC=3 SCAR=24.8
Pod undocumented
562 0 my $self = shift;
563 0 my $text = shift;
564 0 my $type = shift;
565 0 my $extra = shift;
566  
567 0 my $filename = $self->widgetID;
568 0 ▶ $filename .= $extra if $extra;
Branch: 1 branch
BranchTrueFalseTotal
if $extra 0 0 0
569 0 $filename .=".$type";
570  
571 0 my $file = $self->q->config->buildDir."/".$filename;
572  
573 0 ▶ open OF, "+> $file" or die "Couldn't open $file for writing: $!";
Branch: 1 branch
BranchTrueFalseTotal
open OF, "+> $file" or die "Couldn't open $file for writing: $!" 0 0 0
574 0 print OF $text;
575 0 close OF;
576 }
577  
578 #--------------------------------------------------------------------------------------------
579 0 ▶sub outputTmpl {
Subroutine outputTmpl: not called CC=1 SCAR=6.9
Pod undocumented
580 0 my $self = shift;
581 0 my $text = shift;
582 0 my $type = shift;
583  
584 0 $self->output($text, "tmpl", $type);
585 }
586  
587 #--------------------------------------------------------------------------------------------
588 0 ▶sub parse4ID {
Subroutine parse4ID: not called CC=1 SCAR=6.9
Pod undocumented
589 0 my $self = shift;
590 0 my $text = shift;
591
592 0 my $widgetID = $self->widgetID;
593  
594 0 $text =~ s/__WIDGETID__/$widgetID/gs;
595  
596 0 return $text;
597 }
598  
599 #--------------------------------------------------------------------------------------------
600 0 ▶sub parse4Field {
Subroutine parse4Field: not called CC=1 SCAR=6.9
Pod undocumented
601 0 my $self = shift;
602 0 my $fieldname = shift;
603 0 my $text = shift;
604  
605 0 $text =~ s/__FIELDNAME__/$fieldname/gs;
606  
607 0 return $text;
608 }
609  
610 #--------------------------------------------------------------------------------------------
611 0 ▶sub parse4FieldAndID {
Subroutine parse4FieldAndID: not called CC=1 SCAR=6.9
Pod undocumented
612 0 my $self = shift;
613 0 my $fieldname = shift;
614 0 my $text = shift;
615  
616 0 $text = $self->parse4Field($fieldname, $text);
617 0 $text = $self->parse4ID($text);
618  
619 0 return $text;
620 }
621  
622 #--------------------------------------------------------------------------------------------
623 0 ▶sub q {
Subroutine q: not called CC=1 SCAR=6.9
Pod undocumented
624 0 my $self = shift;
625  
626 0 return $self->template->q;
627 }
628  
629 #--------------------------------------------------------------------------------------------
630 0 ▶sub style {
Subroutine style: not called CC=1 SCAR=6.9
Pod undocumented
631 0 my $self = shift;
632  
633 0 return $self->{_style};
634 }
635  
636 #--------------------------------------------------------------------------------------------
637 0 ▶sub template {
Subroutine template: not called CC=1 SCAR=6.9
Pod undocumented
638 0 my $self = shift;
639  
640 0 return $self->{_template};
641 }
642  
643 #--------------------------------------------------------------------------------------------
644 0 ▶sub type {
Subroutine type: not called CC=1 SCAR=6.9
Pod undocumented
645 0 my $self = shift;
646  
647 0 return $self->{_type};
648 }
649  
650 #--------------------------------------------------------------------------------------------
651 0 ▶sub widget {
Subroutine widget: not called CC=1 SCAR=6.9
Pod undocumented
652 0 my $self = shift;
653  
654 0 return $self->{_widget};
655 }
656  
657 #--------------------------------------------------------------------------------------------
658 0 ▶sub widgetID {
Subroutine widgetID: not called CC=1 SCAR=6.9
Pod undocumented
659 0 my $self = shift;
660  
661 0 return $self->{_widgetID};
662 }
663  
664  
665 1 1
666  
667 __END__
« Lazy/Session/Data.pm ↑ Summary Lazy/Widget/Composite.pm »