Completed
Push — master ( 358131...b96cff )
by Gino
04:05
created

TDMCreateHtmlSmartyCodes::getHtmlHNumb()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 24.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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       The XOOPS Project http://sourceforge.net/projects/xoops/
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
defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
26
/**
27
 * Class TDMCreateHtmlSmartyCodes.
28
 */
29
class TDMCreateHtmlSmartyCodes extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
30
{
31
    /*
32
    * @var string
33
    */
34
    protected $htmlcode;
35
36
    /*
37
    *  @public function constructor
38
    *  @param null
39
    */
40
    /**
41
     *
42
     */
43
    public function __construct()
44
    {
45
        parent::__construct();
46
    }
47
48
    /*
49
    *  @static function &getInstance
50
    *  @param null
51
    */
52
    /**
53
     * @return TDMCreateHtmlSmartyCodes
54
     */
55
    public static function &getInstance()
56
    {
57
        static $instance = false;
58
        if (!$instance) {
59
            $instance = new self();
60
        }
61
62
        return $instance;
63
    }
64
65
    /*
66
    *  @public function getHtmlTag
67
    *  @param string $tag
68
    *  @param array  $attributes
69
    *  @param string $content
70
    *  @param bool   $closed
71
    */
72
    /**
73
     * @param $tag
74
     * @param $attributes
75
     * @param $content
76
     * @param $closed
77
     *
78
     * @return string
79
     */
80
    public function getHtmlTag($tag = '', $attributes = array(), $content = '', $closed = true)
81
    {
82
        if (empty($attributes)) {
83
            $attributes = array();
84
        }
85
        $attr = $this->getAttributes($attributes);
86
        if (!$closed) {
87
            $ret = "<{$tag}{$attr} />";
88
        } else {
89
            $ret = "<{$tag}{$attr}>{$content}</{$tag}>";
90
        }
91
92
        return $ret;
93
    }
94
95
     /*
96
    *  @private function setAttributes
97
    *  @param array $attributes
98
    */
99
    /**
100
     * @param  $attributes
101
     *
102
     * @return string
103
     */
104
    private function getAttributes($attributes)
105
    {
106
        $str = '';
107
        foreach ($attributes as $name => $value) {
108
            if ($name != '_') {
109
                $str .= ' '.$name.'="'.$value.'"';
110
            }
111
        }
112
113
        return $str;
114
    }
115
116
    /*
117
    *  @public function getHtmlEmpty
118
    *  @param string $empty
119
    */
120
    /**
121
     * @param $empty
122
     *
123
     * @return string
124
     */
125
    public function getHtmlEmpty($empty = '')
126
    {
127
        return "{$empty}";
128
    }
129
130
    /*
131
    *  @public function getHtmlComment
132
    *  @param string $htmlComment
133
    */
134
    /**
135
     * @param $htmlComment
136
     *
137
     * @return string
138
     */
139
    public function getHtmlComment($htmlComment = '')
140
    {
141
        return "<!-- {$htmlComment} -->";
142
    }
143
144
    /*
145
    *  @public function getHtmlBr
146
    *  @param string $brNumb
147
    *  @param string $class
148
    */
149
    /**
150
     * @param $brNumb
151
     * @param $class
152
     *
153
     * @return string
154
     */
155
    public function getHtmlBr($brNumb = 1, $htmlClass = '')
156
    {
157
        $brClass = ($htmlClass != '') ? " class='{$htmlClass}'" : '';
158
        $ret = '';
159
        for ($i = 0; $i < $brNumb; ++$i) {
160
            $ret .= "<br{$brClass} />";
161
        }
162
163
        return $ret;
164
    }
165
166
    /*
167
    *  @public function getHtmlHNumb
168
    *  @param string $htmlHClass
169
    *  @param string $content
170
    */
171
    /**
172
     * @param $content
173
     * @param $htmlHClass
174
     *
175
     * @return string
176
     */
177
    public function getHtmlHNumb($content = '', $n = '1', $htmlHClass = '')
178
    {
179
        $hClass = ($htmlHClass != '') ? " class='{$htmlHClass}'" : '';
180
        $ret = "<h{$n}{$hClass}>{$content}</h{$n}>";
181
182
        return $ret;
183
    }
184
185
    /*
186
    *  @public function getHtmlDiv
187
    *  @param string $class
188
    *  @param string $content
189
    */
190
    /**
191
     * @param $content
192
     * @param $class
193
     *
194
     * @return string
195
     */
196
    public function getHtmlDiv($content = '', $divClass = '')
197
    {
198
        $rDivClass = ($divClass != '') ? " class='{$divClass}'" : '';
199
        $ret = "<div{$rDivClass}>\n";
200
		$ret .= "\t{$content}\n";
201
		$ret .= "</div>\n";
202
203
        return $ret;
204
    }
205
206
    /*
207
    *  @public function getHtmlPre
208
    *  @param string $class
209
    *  @param string $content
210
    */
211
    /**
212
     * @param $content
213
     * @param $class
214
     *
215
     * @return string
216
     */
217
    public function getHtmlPre($content = '', $preClass = '')
218
    {
219
        $rPreClass = ($preClass != '') ? " class='{$preClass}'" : '';
220
        $ret = "<pre{$rPreClass}>\n";
221
		$ret .= "\t{$content}\n";
222
		$ret .= "</pre>\n";
223
224
        return $ret;
225
    }
226
227
    /*
228
    *  @public function getHtmlSpan
229
    *  @param string $class
230
    *  @param string $content
231
    */
232
    /**
233
     * @param $content
234
     * @param $class
235
     *
236
     * @return string
237
     */
238
    public function getHtmlSpan($content = '', $spanClass = '')
239
    {
240
        $rSpanClass = ($spanClass != '') ? " class='{$spanClass}'" : '';
241
        $ret = "<span{$rSpanClass}>{$content}</span>";
242
		
243
        return $ret;
244
    }
245
246
    /*
247
    *  @public function getHtmlParagraph
248
    *  @param string $class
249
    *  @param string $content
250
    */
251
    /**
252
     * @param $content
253
     * @param $class
254
     *
255
     * @return string
256
     */
257
    public function getHtmlParagraph($content = '', $pClass = '')
258
    {
259
        $rPClass = ($pClass != '') ? " class='{$pClass}'" : '';
260
        $ret = "<p{$rPClass}>\n";
261
		$ret .= "\t{$content}\n";
262
		$ret .= "</p>\n";
263
		
264
        return $ret;
265
    }
266
267
    /*
268
    *  @public function getHtmlI
269
    *  @param string $class
270
    *  @param string $content
271
    */
272
    /**
273
     * @param $content
274
     * @param $class
275
     *
276
     * @return string
277
     */
278
    public function getHtmlI($content = '', $iClass = '')
279
    {
280
        $rIClass = ($iClass != '') ? " class='{$iClass}'" : '';
281
        $ret = "<i{$rIClass}>{$content}</i>";
282
283
        return $ret;
284
    }
285
286
    /*
287
    *  @public function getHtmlUl
288
    *  @param string $class
289
    *  @param string $content
290
    */
291
    /**
292
     * @param $content
293
     * @param $class
294
     *
295
     * @return string
296
     */
297
    public function getHtmlUl($content = '', $ulClass = '')
298
    {
299
        $rUlClass = ($ulClass != '') ? " class='{$ulClass}'" : '';
300
        $ret = "<ul{$rUlClass}>\n";
301
		$ret .= "\t{$content}\n";
302
		$ret .= "</ul>\n";
303
304
        return $ret;
305
    }
306
307
    /*
308
    *  @public function getHtmlOl
309
    *  @param string $class
310
    *  @param string $content
311
    */
312
    /**
313
     * @param $content
314
     * @param $class
315
     *
316
     * @return string
317
     */
318
    public function getHtmlOl($content = '', $olClass = '')
319
    {
320
        $rOlClass = ($olClass != '') ? " class='{$olClass}'" : '';
321
        $ret = "<ol{$rOlClass}>\n";
322
		$ret .= "\t{$content}\n";
323
		$ret .= "</ol>\n";
324
		
325
        return $ret;
326
    }
327
328
    /*
329
    *  @public function getHtmlLi
330
    *  @param string $class
331
    *  @param string $content
332
    */
333
    /**
334
     * @param $content
335
     * @param $class
336
     *
337
     * @return string
338
     */
339
    public function getHtmlLi($content = '', $liClass = '')
340
    {
341
        $rLiClass = ($liClass != '') ? " class='{$liClass}'" : '';
342
343
        return "<li{$rLiClass}>{$content}</li>";
344
    }
345
346
    /*
347
    *  @public function getHtmlStrong
348
    *  @param string $class
349
    *  @param string $content
350
    */
351
    /**
352
     * @param $content
353
     * @param $class
354
     *
355
     * @return string
356
     */
357
    public function getHtmlStrong($content = '', $strongClass = '')
358
    {
359
        $rStrongClass = ($strongClass != '') ? " class='{$strongClass}'" : '';
360
		
361
        return "<strong{$rStrongClass}>{$content}</strong>";
362
    }
363
364
    /*
365
    *  @public function getHtmlAnchor
366
    *  @param string $class
367
    *  @param string $url
368
    *  @param string $target
369
    *  @param string $content
370
    */
371
    /**
372
     * @param $url
373
     * @param $content
374
     * @param $target
375
     * @param $class
376
     *
377
     * @return string
378
     */
379
    public function getHtmlAnchor($url = '#', $content = '&nbsp;', $title = '', $target = '', $aClass = '', $rel = '')
380
    {
381
        $target = ($target != '') ? " target='{$target}'" : '';
382
        $rAClass = ($aClass != '') ? " class='{$aClass}'" : '';
383
        $rel = ($rel != '') ? " rel='{$rel}'" : '';
384
385
        return "<a{$rAClass} href='{$url}' title='{$title}'{$target}{$rel}>{$content}</a>";
386
    }
387
388
    /*
389
    *  @public function getHtmlImage
390
    *  @param string $src
391
    *  @param string $alt
392
    *  @param string $class
393
    */
394
    /**
395
     * @param $src
396
     * @param $alt
397
     * @param $class
398
     *
399
     * @return string
400
     */
401
    public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '')
402
    {
403
        $rImgClass = ($imgClass != '') ? " class='{$imgClass}'" : '';
404
        $ret = "<img{$rImgClass} src='{$src}' alt='{$alt}' />";
405
406
        return $ret;
407
    }
408
409
    /*
410
    *  @public function getHtmlTable
411
    *  @param string $class
412
    *  @param string $content
413
    */
414
    /**
415
     * @param $content
416
     * @param $class
417
     *
418
     * @return string
419
     */
420
    public function getHtmlTable($content = '', $tableClass = '')
421
    {
422
        $rTableClass = ($tableClass != '') ? " class='{$tableClass}'" : '';
423
        $ret = "<table{$rTableClass}>\n";
424
		$ret .= "\t{$content}\n";
425
		$ret .= "</table>\n";
426
		
427
        return $ret;
428
    }
429
430
    /*
431
    *  @public function getHtmlTableThead
432
    *  @param string $class
433
    *  @param string $content
434
    */
435
    /**
436
     * @param $content
437
     * @param $class
438
     *
439
     * @return string
440
     */
441
    public function getHtmlTableThead($content = '', $theadClass = '')
442
    {
443
        $rTheadClass = ($theadClass != '') ? " class='{$theadClass}'" : '';
444
        $ret = "\t<thead{$rTheadClass}>\n";
445
		$ret .= "\t\t{$content}\n";
446
		$ret .= "\t</thead>\n";
447
		
448
        return $ret;
449
    }
450
451
    /*
452
    *  @public function getHtmlTableTbody
453
    *  @param string $class
454
    *  @param string $content
455
    */
456
    /**
457
     * @param $content
458
     * @param $class
459
     *
460
     * @return string
461
     */
462
    public function getHtmlTableTbody($content = '', $tbodyClass = '')
463
    {
464
        $rTbodyClass = ($tbodyClass != '') ? " class='{$tbodyClass}'" : '';
465
        $ret = "\t<tbody{$rTbodyClass}>\n";
466
		$ret .= "\t\t{$content}\n";
467
		$ret .= "\t</tbody>\n";
468
		
469
        return $ret;
470
    }
471
472
    /*
473
    *  @public function getHtmlTableTfoot
474
    *  @param string $class
475
    *  @param string $content
476
    */
477
    /**
478
     * @param $content
479
     * @param $class
480
     *
481
     * @return string
482
     */
483
    public function getHtmlTableTfoot($content = '', $tfootClass = '')
484
    {
485
        $rTfootClass = ($tfootClass != '') ? " class='{$tfootClass}'" : '';
486
        $ret = "\t<tfoot{$rTfootClass}>\n";
487
		$ret .= "\t\t{$content}\n";
488
		$ret .= "\t</tfoot>\n";
489
		
490
        return $ret;
491
    }
492
493
    /*
494
    *  @public function getHtmlTableRow
495
    *  @param string $class
496
    *  @param string $content
497
    */
498
    /**
499
     * @param $content
500
     * @param $class
501
     *
502
     * @return string
503
     */
504
    public function getHtmlTableRow($content = '', $trClass = '')
505
    {
506
        $rTrClass = ($trClass != '') ? " class='{$trClass}'" : '';
507
        $ret = "\t<tr{$rTrClass}>\n";
508
		$ret .= "\t\t{$content}\n";
509
		$ret .= "\t</tr>\n";
510
		
511
        return $ret;
512
    }
513
514
    /*
515
    *  @public function getHtmlTableHead
516
    *  @param string $class
517
    *  @param string $content
518
    */
519
    /**
520
     * @param $content
521
     * @param $class
522
     * @param $colspan
523
     *
524
     * @return string
525
     */
526
    public function getHtmlTableHead($content = '', $thClass = '', $colspan = '')
527
    {
528
        $rThClass = ($thClass != '') ? " class='{$thClass}'" : '';
529
        $colspan = ($colspan != '') ? " colspan='{$colspan}'" : '';
530
        
531
        return "<th{$colspan}{$rThClass}>{$content}</th>";
532
    }
533
534
    /*
535
    *  @public function getHtmlTableData
536
    *  @param string $class
537
    *  @param string $content
538
    */
539
    /**
540
     * @param $content
541
     * @param $class
542
     * @param $colspan
543
     *
544
     * @return string
545
     */
546
    public function getHtmlTableData($content = '', $tdClass = '', $colspan = '')
547
    {
548
        $rTdClass = ($tdClass != '') ? " class='{$tdClass}'" : '';
549
        $colspan = ($colspan != '') ? " colspan='{$colspan}'" : '';
550
        
551
        return "<td{$colspan}{$rTdClass}>{$content}</td>";
552
    }
553
554
    /*
555
    *  @public function getSmartyComment
556
    *  @param string $comment
557
    */
558
    /**
559
     * @param $comment
560
     *
561
     * @return string
562
     */
563
    public function getSmartyComment($comment = '')
0 ignored issues
show
Unused Code introduced by
The parameter $comment is not used and could be removed.

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

Loading history...
564
    {
565
        return "<{* {$content} *}>";
0 ignored issues
show
Bug introduced by
The variable $content does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
566
    }
567
568
    /*
569
    *  @public function getSmartyNoSimbol
570
    *  @param string $content
571
    */
572
    /**
573
     * @param $content
574
     *
575
     * @return string
576
     */
577
    public function getSmartyNoSimbol($noSimbol = '')
578
    {
579
        return "<{{$noSimbol}}>";
580
    }
581
582
    /*
583
    *  @public function getSmartyConst
584
    *  @param string $language
585
    *  @param mixed $const
586
    */
587
    /**
588
     * @param $language
589
     * @param $const
590
     *
591
     * @return string
592
     */
593
    public function getSmartyConst($language, $const)
594
    {
595
        return "<{\$smarty.const.{$language}{$const}}>";
596
    }
597
598
    /*
599
    *  @public function getSmartySingleVar
600
    *  @param string $var
601
    */
602
    /**
603
     * @param string $var
604
     *
605
     * @return string
606
     */
607
    public function getSmartySingleVar($var)
608
    {
609
        return "<{\${$var}}>";
610
    }
611
612
    /*
613
    *  @public function getSmartyDoubleVar
614
    *  @param string $leftVar
615
    *  @param string $rightVar
616
    */
617
    /**
618
     * @param string $leftVar
619
     * @param string $rightVar
620
     *
621
     * @return string
622
     */
623
    public function getSmartyDoubleVar($leftVar, $rightVar)
624
    {
625
        return "<{\${$leftVar}.{$rightVar}}>";
626
    }
627
628
    /*
629
    *  @public function getSmartyIncludeFile
630
    *  @param string $name
631
    */
632
    /**
633
     * @param $moduleDirname
634
     * @param $fileName
635
     * @param $admin
636
     *
637
     * @return string
638
     */
639
    public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admin = false, $q = false)
640
    {
641
        if (!$admin && !$q) {
642
            $ret = "<{include file='db:{$moduleDirname}_{$fileName}.tpl'}>\n";
643
        } elseif ($admin && !$q) {
644
            $ret = "<{include file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>\n";
645
        } elseif (!$admin && $q) {
646
            $ret = "<{includeq file='db:{$moduleDirname}_{$fileName}.tpl'}>\n";
647
        } elseif ($admin && $q) {
648
            $ret = "<{includeq file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>\n";
649
        }
650
651
        return $ret;
0 ignored issues
show
Bug introduced by
The variable $ret does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
652
    }
653
654
    /*
655
    *  @public function getSmartyIncludeFileListSection
656
    *  @param string $name
657
    */
658
    /**
659
     * @param $moduleDirname
660
     * @param $fileName
661
     * @param $tableFieldName
662
     *
663
     * @return string
664
     */
665
    public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $tableFieldName)
666
    {
667
        return "<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}[i]}>";
668
    }
669
670
    /*
671
    *  @public function getSmartyIncludeFileListForeach
672
    *  @param string $name
673
    */
674
    /**
675
     * @param $moduleDirname
676
     * @param $fileName
677
     * @param $tableFieldName
678
     *
679
     * @return string
680
     */
681
    public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName)
682
    {
683
        return "<{include file='db:{$moduleDirname}_{$fileName}_list.tpl' {$tableFieldName}=\${$tableFieldName}}>";
684
    }
685
686
    /*
687
    *  @public function getSmartyConditions
688
    *  @param string $condition
689
    *  @param string $operator
690
    *  @param string $type
691
    *  @param string $contentIf
692
    *  @param mixed  $contentElse
693
    *  @param bool   $count
694
    */
695
    /**
696
     * @param string $condition
697
     * @param string $operator
698
     * @param string $type
699
     * @param string $contentIf
700
     * @param mixed  $contentElse
701
     * @param bool   $count
702
     *
703
     * @return string
704
     */
705
    public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false)
706
    {
707
        if (!$contentElse) {
708 View Code Duplication
            if (!$count) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
709
                $ret = "<{if \${$condition}{$operator}{$type}}>\n";
710
            } elseif (!$noSimbol) {
711
                $ret = "<{if {$condition}{$operator}{$type}}>\n";
712
            } else {
713
                $ret = "<{if count(\${$condition}){$operator}{$type}}>\n";
714
            }
715
            $ret .= "\t{$contentIf}\n";
716
			$ret .= "<{/if}>\n";
717
        } else {
718 View Code Duplication
            if (!$count) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
719
                $ret = "<{if \${$condition}{$operator}{$type}}>\n";				
720
            } elseif (!$noSimbol) {
721
                $ret = "<{if {$condition}{$operator}{$type}}>\n";				
722
            } else {
723
                $ret = "<{if count(\${$condition}){$operator}{$type}}>\n";				
724
            }  
725
			$ret .= "\t{$contentIf}\n";
726
			$ret .= "<{else}>\n";
727
			$ret .= "\t{$contentElse}\n";
728
			$ret .= "<{/if}>\n";
729
        }
730
731
        return $ret;
732
    }
733
734
    /*
735
    *  @public function getSmartyForeach
736
    *  @param string $item
737
    *  @param string $from
738
    *  @param string $content
739
    */
740
    /**
741
     * @param string $item
742
     * @param string $from
743
     * @param string $content
744
     *
745
     * @return string
746
     */
747 View Code Duplication
    public function getSmartyForeach($item = 'item', $from = 'from', $content = 'content', $name = '', $key = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
748
    {
749
        $name = $name != '' ? " name={$name}" : '';
750
        $key = $key != '' ? " key={$key}" : '';
751
        $ret = "<{foreach item={$item} from=\${$from}{$key}{$name}}>\n";
752
		$ret .= "\t{$content}\n";
753
		$ret .= "<{/foreach}>\n";
754
		
755
        return $ret;
756
    }
757
758
    /*
759
    *  @public function getSmartyForeachQuery
760
    *  @param string $item
761
    *  @param string $from
762
    *  @param string $content
763
    */
764
    /**
765
     * @param string $item
766
     * @param string $from
767
     * @param string $content
768
     *
769
     * @return string
770
     */
771 View Code Duplication
    public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = 'content', $loop = 'loop', $key = '')
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
772
    {
773
        $loop = $loop != '' ? " loop={$loop}" : '';
774
        $key = $key != '' ? " key={$key}" : '';
775
		$ret = "<{foreachq item={$item} from=\${$from}{$key}{$loop}}>\n";
776
		$ret .= "\t{$content}\n";
777
		$ret .= "<{/foreachq}>\n";
778
        
779
        return $ret;
780
    }
781
782
    /*
783
    *  @public function getSmartySection
784
    *  @param string $name
785
    *  @param string $loop
786
    *  @param string $content
787
    */
788
    /**
789
     * @param string $name
790
     * @param string $loop
791
     * @param string $content
792
     *
793
     * @return string
794
     */
795 View Code Duplication
    public function getSmartySection($name = 'name', $loop = 'loop', $content = 'content', $start = 0, $step = 0)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
796
    {
797
        $start = $start != 0 ? " start={$start}" : '';
798
        $step = $step != 0 ? " step={$step}" : '';
799
		$ret = "<{section name={$name} loop=\${$loop}{$start}{$step}}>\n";
800
		$ret .= "\t{$content}\n";
801
		$ret .= "<{/section}>\n";
802
        
803
        return $ret;
804
    }
805
}
806