Passed
Branch master (38ab27)
by Michael
03:06
created

TDMCreateHtmlSmartyCodes   F

Complexity

Total Complexity 88

Size/Duplication

Total Lines 651
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 651
rs 1.4178
c 1
b 0
f 0
wmc 88

38 Methods

Rating   Name   Duplication   Size   Complexity  
A getHtmlUl() 0 8 2
A getSmartyForeach() 0 9 3
A getHtmlAnchor() 0 7 4
A getSmartyIncludeFileListForeach() 0 3 1
A getHtmlTableData() 0 6 3
A getSmartySection() 0 9 3
A getHtmlParagraph() 0 8 2
A getHtmlTag() 0 15 4
A getInstance() 0 8 2
A getHtmlEmpty() 0 3 1
A getHtmlOl() 0 8 2
A getHtmlTableTbody() 0 8 2
A getSmartySingleVar() 0 3 1
A getHtmlSpan() 0 6 2
A getHtmlLi() 0 5 2
A getHtmlDiv() 0 8 2
A getHtmlImage() 0 6 2
A getSmartyComment() 0 3 1
A getSmartyConst() 0 3 1
A getHtmlComment() 0 3 1
A getSmartyDoubleVar() 0 3 1
A getSmartyIncludeFileListSection() 0 3 1
A getHtmlTableThead() 0 8 2
A getSmartyNoSimbol() 0 3 1
A getHtmlTableTfoot() 0 8 2
A getHtmlTableRow() 0 8 2
B getSmartyIncludeFile() 0 13 9
A __construct() 0 2 1
A getHtmlTable() 0 8 2
A getHtmlHNumb() 0 6 2
A getAttributes() 0 10 3
A getHtmlPre() 0 8 2
A getHtmlI() 0 6 2
A getHtmlTableHead() 0 6 3
A getHtmlStrong() 0 5 2
A getHtmlBr() 0 9 3
B getSmartyConditions() 0 27 6
A getSmartyForeachQuery() 0 9 3

How to fix   Complexity   

Complex Class

Complex classes like TDMCreateHtmlSmartyCodes often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use TDMCreateHtmlSmartyCodes, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: TDMCreateHtmlSmartyCodes.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TDMCreateHtmlSmartyCodes.
27
 */
28
class TDMCreateHtmlSmartyCodes
29
{
30
    /**
31
    *  @public function constructor
32
    *  @param null
33
    */
34
35
    public function __construct()
36
    {
37
    }
38
39
    /**
40
    *  @static function getInstance
41
    *  @param null
42
     * @return TDMCreateHtmlSmartyCodes
43
     */
44
    public static function getInstance()
45
    {
46
        static $instance = false;
47
        if (!$instance) {
48
            $instance = new self();
49
        }
50
51
        return $instance;
52
    }
53
54
    /**
55
     * @public function getHtmlTag
56
     * @param string $tag
57
     * @param array  $attributes
58
     * @param string $content
59
     * @param bool   $noClosed
60
     *
61
     * @param string $t
62
     * @return string
63
     */
64
    public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed = false, $t = '')
65
    {
66
        if (empty($attributes)) {
67
            $attributes = [];
68
        }
69
        $attr = $this->getAttributes($attributes);
70
        if ('br' === $tag) {
71
            $ret = "{$t}<{$tag}{$attr}>\n";
72
        } elseif ($noClosed) {
73
            $ret = "{$t}<{$tag}{$attr} />\n";
74
        } else {
75
            $ret = "{$t}<{$tag}{$attr}>{$content}</{$tag}>\n";
76
        }
77
78
        return $ret;
79
    }
80
81
    /**
82
    *  @private function setAttributes
83
    *  @param array $attributes
84
    *
85
    * @return string
86
    */
87
    private function getAttributes($attributes)
88
    {
89
        $str = '';
90
        foreach ($attributes as $name => $value) {
91
            if ('_' !== $name) {
92
                $str .= ' '.$name.'="'.$value.'"';
93
            }
94
        }
95
96
        return $str;
97
    }
98
99
    /**
100
    *  @public function getHtmlEmpty
101
    *  @param string $empty
102
     *
103
     * @return string
104
     */
105
    public function getHtmlEmpty($empty = '')
106
    {
107
        return "{$empty}";
108
    }
109
110
    /**
111
    *  @public function getHtmlComment
112
    *  @param string $htmlComment
113
     *
114
     * @return string
115
     */
116
    public function getHtmlComment($htmlComment = '')
117
    {
118
        return "<!-- {$htmlComment} -->";
119
    }
120
121
    /**
122
     * @public function getHtmlBr
123
     * @param int    $brNumb
124
     * @param string $htmlClass
125
     *
126
     * @param string $t
127
     * @return string
128
     */
129
    public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '')
130
    {
131
        $brClass = ('' != $htmlClass) ? " class='{$htmlClass}'" : '';
132
        $ret = '';
133
        for ($i = 0; $i < $brNumb; ++$i) {
134
            $ret .= "{$t}<br{$brClass} />\n";
135
        }
136
137
        return $ret;
138
    }
139
140
    /**
141
     * @public function getHtmlHNumb
142
     * @param string $content
143
     *
144
     * @param string $n
145
     * @param string $htmlHClass
146
     * @param string $t
147
     * @return string
148
     */
149
    public function getHtmlHNumb($content = '', $n = '1', $htmlHClass = '', $t = '')
150
    {
151
        $hClass = ('' != $htmlHClass) ? " class='{$htmlHClass}'" : '';
152
        $ret = "{$t}<h{$n}{$hClass}>{$content}</h{$n}>\n";
153
154
        return $ret;
155
    }
156
157
    /**
158
     * @public function getHtmlDiv
159
     * @param string $content
160
     *
161
     * @param string $divClass
162
     * @param string $t
163
     * @return string
164
     */
165
    public function getHtmlDiv($content = '', $divClass = '', $t = '')
166
    {
167
        $rDivClass = ('' != $divClass) ? " class='{$divClass}'" : '';
168
        $ret = "{$t}<div{$rDivClass}>\n";
169
        $ret .= "{$t}{$content}";
170
        $ret .= "{$t}</div>\n";
171
172
        return $ret;
173
    }
174
175
    /**
176
     * @public function getHtmlPre
177
     * @param string $content
178
     *
179
     * @param string $preClass
180
     * @param string $t
181
     * @return string
182
     */
183
    public function getHtmlPre($content = '', $preClass = '', $t = '')
184
    {
185
        $rPreClass = ('' != $preClass) ? " class='{$preClass}'" : '';
186
        $ret = "{$t}<pre{$rPreClass}>\n";
187
        $ret .= "{$t}{$content}";
188
        $ret .= "{$t}</pre>\n";
189
190
        return $ret;
191
    }
192
193
    /**
194
     * @public function getHtmlSpan
195
     * @param string $content
196
     *
197
     * @param string $spanClass
198
     * @param string $t
199
     * @return string
200
     */
201
    public function getHtmlSpan($content = '', $spanClass = '', $t = '')
202
    {
203
        $rSpanClass = ('' != $spanClass) ? " class='{$spanClass}'" : '';
204
        $ret = "{$t}<span{$rSpanClass}>{$content}</span>\n";
205
206
        return $ret;
207
    }
208
209
    /**
210
     * @public function getHtmlParagraph
211
     * @param string $content
212
     *
213
     * @param string $pClass
214
     * @param string $t
215
     * @return string
216
     */
217
    public function getHtmlParagraph($content = '', $pClass = '', $t = '')
218
    {
219
        $rPClass = ('' != $pClass) ? " class='{$pClass}'" : '';
220
        $ret = "{$t}<p{$rPClass}>\n";
221
        $ret .= "{$t}{$content}";
222
        $ret .= "{$t}</p>\n";
223
224
        return $ret;
225
    }
226
227
    /**
228
     * @public function getHtmlI
229
     * @param string $content
230
     *
231
     * @param string $iClass
232
     * @param string $t
233
     * @return string
234
     */
235
    public function getHtmlI($content = '', $iClass = '', $t = '')
236
    {
237
        $rIClass = ('' != $iClass) ? " class='{$iClass}'" : '';
238
        $ret = "{$t}<i{$rIClass}>{$content}</i>\n";
239
240
        return $ret;
241
    }
242
243
    /**
244
     * @public function getHtmlUl
245
     * @param string $content
246
     *
247
     * @param string $ulClass
248
     * @param string $t
249
     * @return string
250
     */
251
    public function getHtmlUl($content = '', $ulClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

251
    public function getHtmlUl($content = '', $ulClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
252
    {
253
        $rUlClass = ('' != $ulClass) ? " class='{$ulClass}'" : '';
254
        $ret = "<ul{$rUlClass}>\n";
255
        $ret .= "\t{$content}\n";
256
        $ret .= "</ul>\n";
257
258
        return $ret;
259
    }
260
261
    /**
262
     * @public function getHtmlOl
263
     * @param string $content
264
     *
265
     * @param string $olClass
266
     * @param string $t
267
     * @return string
268
     */
269
    public function getHtmlOl($content = '', $olClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

269
    public function getHtmlOl($content = '', $olClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
270
    {
271
        $rOlClass = ('' != $olClass) ? " class='{$olClass}'" : '';
272
        $ret = "<ol{$rOlClass}>\n";
273
        $ret .= "\t{$content}\n";
274
        $ret .= "</ol>\n";
275
276
        return $ret;
277
    }
278
279
    /**
280
     * @public function getHtmlLi
281
     * @param string $content
282
     * @param string $liClass
283
     *
284
     * @param string $t
285
     * @return string
286
     */
287
    public function getHtmlLi($content = '', $liClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

287
    public function getHtmlLi($content = '', $liClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
288
    {
289
        $rLiClass = ('' != $liClass) ? " class='{$liClass}'" : '';
290
291
        return "<li{$rLiClass}>{$content}</li>";
292
    }
293
294
    /**
295
     * @public function getHtmlStrong
296
     * @param string $content
297
     * @param string $strongClass
298
     *
299
     * @param string $t
300
     * @return string
301
     */
302
    public function getHtmlStrong($content = '', $strongClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

302
    public function getHtmlStrong($content = '', $strongClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
303
    {
304
        $rStrongClass = ('' != $strongClass) ? " class='{$strongClass}'" : '';
305
306
        return "<strong{$rStrongClass}>{$content}</strong>";
307
    }
308
309
    /**
310
     * @public function getHtmlAnchor
311
     * @param string $url
312
     * @param string $content
313
     * @param string $title
314
     * @param string $target
315
     * @param string $aClass
316
     *
317
     * @param string $rel
318
     * @param string $t
319
     * @return string
320
     */
321
    public function getHtmlAnchor($url = '#', $content = '&nbsp;', $title = '', $target = '', $aClass = '', $rel = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

321
    public function getHtmlAnchor($url = '#', $content = '&nbsp;', $title = '', $target = '', $aClass = '', $rel = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
322
    {
323
        $target = ('' != $target) ? " target='{$target}'" : '';
324
        $rAClass = ('' != $aClass) ? " class='{$aClass}'" : '';
325
        $rel = ('' != $rel) ? " rel='{$rel}'" : '';
326
327
        return "<a{$rAClass} href='{$url}' title='{$title}'{$target}{$rel}>{$content}</a>";
328
    }
329
330
    /**
331
     * @public function getHtmlImage
332
     * @param string $src
333
     * @param string $alt
334
     * @param string $imgClass
335
     *
336
     * @param string $t
337
     * @return string
338
     */
339
    public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

339
    public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
340
    {
341
        $rImgClass = ('' != $imgClass) ? " class='{$imgClass}'" : '';
342
        $ret = "<img{$rImgClass} src='{$src}' alt='{$alt}' />";
343
344
        return $ret;
345
    }
346
347
    /**
348
     * @public function getHtmlTable
349
     * @param string $content
350
     * @param string $tableClass
351
     *
352
     * @param string $t
353
     * @return string
354
     */
355
    public function getHtmlTable($content = '', $tableClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

355
    public function getHtmlTable($content = '', $tableClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
356
    {
357
        $rTableClass = ('' != $tableClass) ? " class='{$tableClass}'" : '';
358
        $ret = "<table{$rTableClass}>\n";
359
        $ret .= "\t{$content}\n";
360
        $ret .= "</table>\n";
361
362
        return $ret;
363
    }
364
365
    /**
366
     * @public function getHtmlTableThead
367
     * @param string $content
368
     * @param string $theadClass
369
     *
370
     * @param string $t
371
     * @return string
372
     */
373
    public function getHtmlTableThead($content = '', $theadClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

373
    public function getHtmlTableThead($content = '', $theadClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
374
    {
375
        $rTheadClass = ('' != $theadClass) ? " class='{$theadClass}'" : '';
376
        $ret = "\t<thead{$rTheadClass}>\n";
377
        $ret .= "\t\t{$content}\n";
378
        $ret .= "\t</thead>\n";
379
380
        return $ret;
381
    }
382
383
    /**
384
     * @public function getHtmlTableTbody
385
     * @param string $content
386
     * @param string $tbodyClass
387
     *
388
     * @param string $t
389
     * @return string
390
     */
391
    public function getHtmlTableTbody($content = '', $tbodyClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

391
    public function getHtmlTableTbody($content = '', $tbodyClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
392
    {
393
        $rTbodyClass = ('' != $tbodyClass) ? " class='{$tbodyClass}'" : '';
394
        $ret = "\t<tbody{$rTbodyClass}>\n";
395
        $ret .= "\t\t{$content}\n";
396
        $ret .= "\t</tbody>\n";
397
398
        return $ret;
399
    }
400
401
    /**
402
     * @public function getHtmlTableTfoot
403
     * @param string $content
404
     * @param string $tfootClass
405
     *
406
     * @param string $t
407
     * @return string
408
     */
409
    public function getHtmlTableTfoot($content = '', $tfootClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

409
    public function getHtmlTableTfoot($content = '', $tfootClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
410
    {
411
        $rTfootClass = ('' != $tfootClass) ? " class='{$tfootClass}'" : '';
412
        $ret = "\t<tfoot{$rTfootClass}>\n";
413
        $ret .= "\t\t{$content}\n";
414
        $ret .= "\t</tfoot>\n";
415
416
        return $ret;
417
    }
418
419
    /**
420
     * @public function getHtmlTableRow
421
     * @param string $content
422
     * @param string $trClass
423
     *
424
     * @param string $t
425
     * @return string
426
     */
427
    public function getHtmlTableRow($content = '', $trClass = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

427
    public function getHtmlTableRow($content = '', $trClass = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
428
    {
429
        $rTrClass = ('' != $trClass) ? " class='{$trClass}'" : '';
430
        $ret = "\t<tr{$rTrClass}>\n";
431
        $ret .= "\t\t{$content}\n";
432
        $ret .= "\t</tr>\n";
433
434
        return $ret;
435
    }
436
437
    /**
438
     * @public function getHtmlTableHead
439
     * @param string $content
440
     * @param string $thClass
441
     * @param string $colspan
442
     *
443
     * @param string $t
444
     * @return string
445
     */
446
    public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', $t = '')
0 ignored issues
show
Unused Code introduced by
The parameter $t is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

446
    public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', /** @scrutinizer ignore-unused */ $t = '')

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
447
    {
448
        $rThClass = ('' != $thClass) ? " class='{$thClass}'" : '';
449
        $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : '';
450
451
        return "<th{$colspan}{$rThClass}>{$content}</th>";
452
    }
453
454
    /**
455
    *  @public function getHtmlTableData
456
     * @param $content
457
     * @param $tdClass
458
     * @param $colspan
459
     *
460
     * @return string
461
     */
462
    public function getHtmlTableData($content = '', $tdClass = '', $colspan = '')
463
    {
464
        $rTdClass = ('' != $tdClass) ? " class='{$tdClass}'" : '';
465
        $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : '';
466
467
        return "<td{$colspan}{$rTdClass}>{$content}</td>";
468
    }
469
470
    /**
471
    *  @public function getSmartyComment
472
    *  @param string $comment
473
     *
474
     * @return string
475
     */
476
    public function getSmartyComment($comment = '')
477
    {
478
        return "<{* {$comment} *}>";
479
    }
480
481
    /**
482
    *  @public function getSmartyNoSimbol
483
    *  @param string $noSimbol
484
     *
485
     * @return string
486
     */
487
    public function getSmartyNoSimbol($noSimbol = '')
488
    {
489
        return "<{{$noSimbol}}>";
490
    }
491
492
    /**
493
    *  @public function getSmartyConst
494
    *  @param string $language
495
    *  @param mixed $const
496
     *
497
     * @return string
498
     */
499
    public function getSmartyConst($language, $const)
500
    {
501
        return "<{\$smarty.const.{$language}{$const}}>";
502
    }
503
504
    /**
505
    *  @public function getSmartySingleVar
506
    *  @param string $var
507
     *
508
     * @return string
509
     */
510
    public function getSmartySingleVar($var)
511
    {
512
        return "<{\${$var}}>";
513
    }
514
515
    /**
516
    *  @public function getSmartyDoubleVar
517
    *  @param string $leftVar
518
    *  @param string $rightVar
519
     *
520
     * @return string
521
     */
522
    public function getSmartyDoubleVar($leftVar, $rightVar)
523
    {
524
        return "<{\${$leftVar}.{$rightVar}}>";
525
    }
526
527
    /**
528
     * @public function getSmartyIncludeFile
529
     * @param        $moduleDirname
530
     * @param string $fileName
531
     * @param bool   $admin
532
     *
533
     * @param bool   $q
534
     * @return string
535
     */
536
    public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admin = false, $q = false)
537
    {
538
        if (!$admin && !$q) {
539
            $ret = "<{include file='db:{$moduleDirname}_{$fileName}.tpl'}>\n";
540
        } elseif ($admin && !$q) {
541
            $ret = "<{include file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>\n";
542
        } elseif (!$admin && $q) {
543
            $ret = "<{includeq file='db:{$moduleDirname}_{$fileName}.tpl'}>\n";
544
        } elseif ($admin && $q) {
545
            $ret = "<{includeq file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>\n";
546
        }
547
548
        return $ret;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $ret does not seem to be defined for all execution paths leading up to this point.
Loading history...
549
    }
550
551
    /**
552
    *  @public function getSmartyIncludeFileListSection
553
     * @param $moduleDirname
554
     * @param $fileName
555
     * @param $tableFieldName
556
     *
557
     * @return string
558
     */
559
    public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $tableFieldName)
560
    {
561
        return "<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}[i]}>";
562
    }
563
564
    /**
565
    *  @public function getSmartyIncludeFileListForeach
566
     * @param $moduleDirname
567
     * @param $fileName
568
     * @param $tableFieldName
569
     *
570
     * @return string
571
     */
572
    public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName)
573
    {
574
        return "<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}}>";
575
    }
576
577
    /**
578
     * @public function getSmartyConditions
579
     * @param string $condition
580
     * @param string $operator
581
     * @param string $type
582
     * @param string $contentIf
583
     * @param mixed  $contentElse
584
     * @param bool   $count
585
     *
586
     * @param bool   $noSimbol
587
     * @return string
588
     */
589
    public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false)
590
    {
591
        if (!$contentElse) {
592
            if (!$count) {
593
                $ret = "<{if \${$condition}{$operator}{$type}}>\n";
594
            } elseif (!$noSimbol) {
595
                $ret = "<{if {$condition}{$operator}{$type}}>\n";
596
            } else {
597
                $ret = "<{if count(\${$condition}){$operator}{$type}}>\n";
598
            }
599
            $ret .= "\t{$contentIf}\n";
600
            $ret .= "<{/if}>\n";
601
        } else {
602
            if (!$count) {
603
                $ret = "<{if \${$condition}{$operator}{$type}}>\n";
604
            } elseif (!$noSimbol) {
605
                $ret = "<{if {$condition}{$operator}{$type}}>\n";
606
            } else {
607
                $ret = "<{if count(\${$condition}){$operator}{$type}}>\n";
608
            }
609
            $ret .= "\t{$contentIf}\n";
610
            $ret .= "<{else}>\n";
611
            $ret .= "\t{$contentElse}\n";
612
            $ret .= "<{/if}>\n";
613
        }
614
615
        return $ret;
616
    }
617
618
    /**
619
     * @public function getSmartyForeach
620
     * @param string $item
621
     * @param string $from
622
     * @param string $content
623
     *
624
     * @param string $name
625
     * @param string $key
626
     * @return string
627
     */
628
    public function getSmartyForeach($item = 'item', $from = 'from', $content = 'content', $name = '', $key = '')
629
    {
630
        $name = '' != $name ? " name={$name}" : '';
631
        $key = '' != $key ? " key={$key}" : '';
632
        $ret = "<{foreach item={$item} from=\${$from}{$key}{$name}}>\n";
633
        $ret .= "\t{$content}\n";
634
        $ret .= "<{/foreach}>\n";
635
636
        return $ret;
637
    }
638
639
    /**
640
     * @public function getSmartyForeachQuery
641
     * @param string $item
642
     * @param string $from
643
     * @param string $content
644
     *
645
     * @param string $loop
646
     * @param string $key
647
     * @return string
648
     */
649
    public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = 'content', $loop = 'loop', $key = '')
650
    {
651
        $loop = '' != $loop ? " loop={$loop}" : '';
652
        $key = '' != $key ? " key={$key}" : '';
653
        $ret = "<{foreachq item={$item} from=\${$from}{$key}{$loop}}>\n";
654
        $ret .= "\t{$content}\n";
655
        $ret .= "<{/foreachq}>\n";
656
657
        return $ret;
658
    }
659
660
    /**
661
     * @public function getSmartySection
662
     * @param string $name
663
     * @param string $loop
664
     * @param string $content
665
     *
666
     * @param int    $start
667
     * @param int    $step
668
     * @return string
669
     */
670
    public function getSmartySection($name = 'name', $loop = 'loop', $content = 'content', $start = 0, $step = 0)
671
    {
672
        $start = 0 != $start ? " start={$start}" : '';
673
        $step = 0 != $step ? " step={$step}" : '';
674
        $ret = "<{section name={$name} loop=\${$loop}{$start}{$step}}>\n";
675
        $ret .= "\t{$content}\n";
676
        $ret .= "<{/section}>\n";
677
678
        return $ret;
679
    }
680
}
681