Completed
Pull Request — master (#144)
by Michael
03:13
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
 * @version         $Id: CreateHtmlSmartyCodes.php 12258 2014-01-02 09:33:29Z timgno $
27
 */
28
29
/**
30
 * Class CreateHtmlSmartyCodes.
31
 */
32
class CreateHtmlSmartyCodes
33
{
34
    /**
35
     * @public function constructor
36
     * @param null
37
     */
38
    public function __construct()
39
    {
40
    }
41
42
    /**
43
     * @static function getInstance
44
     * @param null
45
     * @return Tdmcreate\Files\CreateHtmlSmartyCodes
46
     */
47
    public static function getInstance()
48
    {
49
        static $instance = false;
50
        if (!$instance) {
51
            $instance = new self();
52
        }
53
54
        return $instance;
55
    }
56
57
    /**
58
     * @public function getHtmlTag
59
     * @param string $tag
60
     * @param array  $attributes
61
     * @param string $content
62
     * @param bool   $noClosed
63
     *
64
     * @param string $t
65
     * @return string
66
     */
67
    public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed = false, $t = '')
68
    {
69
        if (empty($attributes)) {
70
            $attributes = [];
71
        }
72
        $attr = $this->getAttributes($attributes);
73
        if ('br' === $tag) {
74
            $ret = "{$t}<{$tag}{$attr}>\n";
75
        } elseif ($noClosed) {
76
            $ret = "{$t}<{$tag}{$attr} />\n";
77
        } else {
78
            $ret = "{$t}<{$tag}{$attr}>{$content}</{$tag}>\n";
79
        }
80
81
        return $ret;
82
    }
83
84
    /**
85
     * @private function setAttributes
86
     * @param array $attributes
87
     *
88
     * @return string
89
     */
90
    private function getAttributes($attributes)
91
    {
92
        $str = '';
93
        foreach ($attributes as $name => $value) {
94
            if ('_' !== $name) {
95
                $str .= ' ' . $name . '="' . $value . '"';
96
            }
97
        }
98
99
        return $str;
100
    }
101
102
    /**
103
     * @public function getHtmlEmpty
104
     * @param string $empty
105
     *
106
     * @return string
107
     */
108
    public function getHtmlEmpty($empty = '')
109
    {
110
        return (string)$empty;
111
    }
112
113
    /**
114
     * @public function getHtmlComment
115
     * @param string $htmlComment
116
     *
117
     * @return string
118
     */
119
    public function getHtmlComment($htmlComment = '')
120
    {
121
        return "<!-- {$htmlComment} -->";
122
    }
123
124
    /**
125
     * @public function getHtmlBr
126
     * @param int    $brNumb
127
     * @param string $htmlClass
128
     *
129
     * @param string $t
130
     * @return string
131
     */
132
    public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '')
133
    {
134
        $brClass = ('' != $htmlClass) ? " class='{$htmlClass}'" : '';
135
        $ret     = '';
136
        for ($i = 0; $i < $brNumb; ++$i) {
137
            $ret .= "{$t}<br{$brClass} />\n";
138
        }
139
140
        return $ret;
141
    }
142
143
    /**
144
     * @public function getHtmlHNumb
145
     * @param string $content
146
     *
147
     * @param string $n
148
     * @param string $htmlHClass
149
     * @param string $t
150
     * @return string
151
     */
152
    public function getHtmlHNumb($content = '', $n = '1', $htmlHClass = '', $t = '')
153
    {
154
        $hClass = ('' != $htmlHClass) ? " class='{$htmlHClass}'" : '';
155
        $ret    = "{$t}<h{$n}{$hClass}>{$content}</h{$n}>\n";
156
157
        return $ret;
158
    }
159
160
    /**
161
     * @public function getHtmlDiv
162
     * @param string $content
163
     *
164
     * @param string $divClass
165
     * @param string $t
166
     * @return string
167
     */
168
    public function getHtmlDiv($content = '', $divClass = '', $t = '')
169
    {
170
        $rDivClass = ('' != $divClass) ? " class='{$divClass}'" : '';
171
        $ret       = "{$t}<div{$rDivClass}>\n";
172
        $ret       .= "{$t}{$content}";
173
        $ret       .= "{$t}</div>\n";
174
175
        return $ret;
176
    }
177
178
    /**
179
     * @public function getHtmlPre
180
     * @param string $content
181
     *
182
     * @param string $preClass
183
     * @param string $t
184
     * @return string
185
     */
186
    public function getHtmlPre($content = '', $preClass = '', $t = '')
187
    {
188
        $rPreClass = ('' != $preClass) ? " class='{$preClass}'" : '';
189
        $ret       = "{$t}<pre{$rPreClass}>\n";
190
        $ret       .= "{$t}{$content}";
191
        $ret       .= "{$t}</pre>\n";
192
193
        return $ret;
194
    }
195
196
    /**
197
     * @public function getHtmlSpan
198
     * @param string $content
199
     *
200
     * @param string $spanClass
201
     * @param string $t
202
     * @return string
203
     */
204
    public function getHtmlSpan($content = '', $spanClass = '', $t = '')
205
    {
206
        $rSpanClass = ('' != $spanClass) ? " class='{$spanClass}'" : '';
207
        $ret        = "{$t}<span{$rSpanClass}>{$content}</span>\n";
208
209
        return $ret;
210
    }
211
212
    /**
213
     * @public function getHtmlParagraph
214
     * @param string $content
215
     *
216
     * @param string $pClass
217
     * @param string $t
218
     * @return string
219
     */
220
    public function getHtmlParagraph($content = '', $pClass = '', $t = '')
221
    {
222
        $rPClass = ('' != $pClass) ? " class='{$pClass}'" : '';
223
        $ret     = "{$t}<p{$rPClass}>\n";
224
        $ret     .= "{$t}{$content}";
225
        $ret     .= "{$t}</p>\n";
226
227
        return $ret;
228
    }
229
230
    /**
231
     * @public function getHtmlI
232
     * @param string $content
233
     *
234
     * @param string $iClass
235
     * @param string $t
236
     * @return string
237
     */
238
    public function getHtmlI($content = '', $iClass = '', $t = '')
239
    {
240
        $rIClass = ('' != $iClass) ? " class='{$iClass}'" : '';
241
        $ret     = "{$t}<i{$rIClass}>{$content}</i>\n";
242
243
        return $ret;
244
    }
245
246
    /**
247
     * @public function getHtmlUl
248
     * @param string $content
249
     *
250
     * @param string $ulClass
251
     * @param string $t
252
     * @return string
253
     */
254
    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

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

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

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

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

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

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

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

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

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

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

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

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