Completed
Pull Request — master (#144)
by Michael
03:08
created

CreateHtmlSmartyCodes   F

Complexity

Total Complexity 88

Size/Duplication

Total Lines 650
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 158
dl 0
loc 650
rs 2
c 0
b 0
f 0
wmc 88

38 Methods

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

How to fix   Complexity   

Complex Class

Complex classes like CreateHtmlSmartyCodes 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 CreateHtmlSmartyCodes, and based on these observations, apply Extract Interface, too.

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

253
    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...
254
    {
255
        $rUlClass = ('' != $ulClass) ? " class='{$ulClass}'" : '';
256
        $ret      = "<ul{$rUlClass}>\n";
257
        $ret      .= "\t{$content}\n";
258
        $ret      .= "</ul>\n";
259
260
        return $ret;
261
    }
262
263
    /**
264
     * @public function getHtmlOl
265
     * @param string $content
266
     *
267
     * @param string $olClass
268
     * @param string $t
269
     * @return string
270
     */
271
    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

271
    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...
272
    {
273
        $rOlClass = ('' != $olClass) ? " class='{$olClass}'" : '';
274
        $ret      = "<ol{$rOlClass}>\n";
275
        $ret      .= "\t{$content}\n";
276
        $ret      .= "</ol>\n";
277
278
        return $ret;
279
    }
280
281
    /**
282
     * @public function getHtmlLi
283
     * @param string $content
284
     * @param string $liClass
285
     *
286
     * @param string $t
287
     * @return string
288
     */
289
    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

289
    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...
290
    {
291
        $rLiClass = ('' != $liClass) ? " class='{$liClass}'" : '';
292
293
        return "<li{$rLiClass}>{$content}</li>";
294
    }
295
296
    /**
297
     * @public function getHtmlStrong
298
     * @param string $content
299
     * @param string $strongClass
300
     *
301
     * @param string $t
302
     * @return string
303
     */
304
    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

304
    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...
305
    {
306
        $rStrongClass = ('' != $strongClass) ? " class='{$strongClass}'" : '';
307
308
        return "<strong{$rStrongClass}>{$content}</strong>";
309
    }
310
311
    /**
312
     * @public function getHtmlAnchor
313
     * @param string $url
314
     * @param string $content
315
     * @param string $title
316
     * @param string $target
317
     * @param string $aClass
318
     *
319
     * @param string $rel
320
     * @param string $t
321
     * @return string
322
     */
323
    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

323
    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...
324
    {
325
        $target  = ('' != $target) ? " target='{$target}'" : '';
326
        $rAClass = ('' != $aClass) ? " class='{$aClass}'" : '';
327
        $rel     = ('' != $rel) ? " rel='{$rel}'" : '';
328
329
        return "<a{$rAClass} href='{$url}' title='{$title}'{$target}{$rel}>{$content}</a>";
330
    }
331
332
    /**
333
     * @public function getHtmlImage
334
     * @param string $src
335
     * @param string $alt
336
     * @param string $imgClass
337
     *
338
     * @param string $t
339
     * @return string
340
     */
341
    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

341
    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...
342
    {
343
        $rImgClass = ('' != $imgClass) ? " class='{$imgClass}'" : '';
344
        $ret       = "<img{$rImgClass} src='{$src}' alt='{$alt}' />";
345
346
        return $ret;
347
    }
348
349
    /**
350
     * @public function getHtmlTable
351
     * @param string $content
352
     * @param string $tableClass
353
     *
354
     * @param string $t
355
     * @return string
356
     */
357
    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

357
    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...
358
    {
359
        $rTableClass = ('' != $tableClass) ? " class='{$tableClass}'" : '';
360
        $ret         = "<table{$rTableClass}>\n";
361
        $ret         .= "\t{$content}\n";
362
        $ret         .= "</table>\n";
363
364
        return $ret;
365
    }
366
367
    /**
368
     * @public function getHtmlTableThead
369
     * @param string $content
370
     * @param string $theadClass
371
     *
372
     * @param string $t
373
     * @return string
374
     */
375
    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

375
    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...
376
    {
377
        $rTheadClass = ('' != $theadClass) ? " class='{$theadClass}'" : '';
378
        $ret         = "\t<thead{$rTheadClass}>\n";
379
        $ret         .= "\t\t{$content}\n";
380
        $ret         .= "\t</thead>\n";
381
382
        return $ret;
383
    }
384
385
    /**
386
     * @public function getHtmlTableTbody
387
     * @param string $content
388
     * @param string $tbodyClass
389
     *
390
     * @param string $t
391
     * @return string
392
     */
393
    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

393
    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...
394
    {
395
        $rTbodyClass = ('' != $tbodyClass) ? " class='{$tbodyClass}'" : '';
396
        $ret         = "\t<tbody{$rTbodyClass}>\n";
397
        $ret         .= "\t\t{$content}\n";
398
        $ret         .= "\t</tbody>\n";
399
400
        return $ret;
401
    }
402
403
    /**
404
     * @public function getHtmlTableTfoot
405
     * @param string $content
406
     * @param string $tfootClass
407
     *
408
     * @param string $t
409
     * @return string
410
     */
411
    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

411
    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...
412
    {
413
        $rTfootClass = ('' != $tfootClass) ? " class='{$tfootClass}'" : '';
414
        $ret         = "\t<tfoot{$rTfootClass}>\n";
415
        $ret         .= "\t\t{$content}\n";
416
        $ret         .= "\t</tfoot>\n";
417
418
        return $ret;
419
    }
420
421
    /**
422
     * @public function getHtmlTableRow
423
     * @param string $content
424
     * @param string $trClass
425
     *
426
     * @param string $t
427
     * @return string
428
     */
429
    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

429
    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...
430
    {
431
        $rTrClass = ('' != $trClass) ? " class='{$trClass}'" : '';
432
        $ret      = "\t<tr{$rTrClass}>\n";
433
        $ret      .= "\t\t{$content}\n";
434
        $ret      .= "\t</tr>\n";
435
436
        return $ret;
437
    }
438
439
    /**
440
     * @public function getHtmlTableHead
441
     * @param string $content
442
     * @param string $thClass
443
     * @param string $colspan
444
     *
445
     * @param string $t
446
     * @return string
447
     */
448
    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

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