| Total Complexity | 93 |
| Total Lines | 728 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
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 |
||
| 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 | * @param string $n |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function getHtmlTag($tag = '', $attributes = [], $content = '', $noClosed = false, $t = '', $n = "\n") |
||
| 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 | * @param string $t |
||
| 107 | * @param string $n |
||
| 108 | * @return string |
||
| 109 | */ |
||
| 110 | public function getHtmlEmpty($empty = '', $t = '', $n = "") |
||
| 111 | { |
||
| 112 | return "{$t}{$empty}{$n}"; |
||
| 113 | } |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @public function getHtmlComment |
||
| 117 | * @param string $htmlComment |
||
| 118 | * |
||
| 119 | * @param string $n |
||
| 120 | * @return string |
||
| 121 | */ |
||
| 122 | public function getHtmlComment($htmlComment = '', $n = '') |
||
| 123 | { |
||
| 124 | return "<!-- {$htmlComment} -->{$n}"; |
||
| 125 | } |
||
| 126 | |||
| 127 | /** |
||
| 128 | * @public function getHtmlBr |
||
| 129 | * @param int $brNumb |
||
| 130 | * @param string $htmlClass |
||
| 131 | * |
||
| 132 | * @param string $t |
||
| 133 | * @param string $n |
||
| 134 | * @return string |
||
| 135 | */ |
||
| 136 | public function getHtmlBr($brNumb = 1, $htmlClass = '', $t = '', $n = "\n") |
||
| 137 | { |
||
| 138 | $brClass = ('' != $htmlClass) ? " class='{$htmlClass}'" : ''; |
||
| 139 | $ret = ''; |
||
| 140 | for ($i = 0; $i < $brNumb; ++$i) { |
||
| 141 | $ret .= "{$t}<br{$brClass} />{$n}"; |
||
| 142 | } |
||
| 143 | |||
| 144 | return $ret; |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * @public function getHtmlHNumb |
||
| 149 | * @param string $content |
||
| 150 | * |
||
| 151 | * @param string $l |
||
| 152 | * @param string $htmlHClass |
||
| 153 | * @param string $t |
||
| 154 | * @param string $n |
||
| 155 | * @return string |
||
| 156 | */ |
||
| 157 | public function getHtmlHNumb($content = '', $l = '1', $htmlHClass = '', $t = '', $n = "\n") |
||
| 158 | { |
||
| 159 | $hClass = ('' != $htmlHClass) ? " class='{$htmlHClass}'" : ''; |
||
| 160 | $ret = "{$t}<h{$l}{$hClass}>{$content}</h{$l}>{$n}"; |
||
| 161 | |||
| 162 | return $ret; |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * @public function getHtmlDiv |
||
| 167 | * @param string $content |
||
| 168 | * |
||
| 169 | * @param string $divClass |
||
| 170 | * @param string $t |
||
| 171 | * @param string $n |
||
| 172 | * @param bool $split |
||
| 173 | * @return string |
||
| 174 | */ |
||
| 175 | public function getHtmlDiv($content = '', $divClass = '', $t = '', $n = "\n", $split = true) |
||
| 176 | { |
||
| 177 | $rDivClass = ('' != $divClass) ? " class='{$divClass}'" : ''; |
||
| 178 | |||
| 179 | if ($split) { |
||
| 180 | $ret = "{$t}<div{$rDivClass}>{$n}"; |
||
| 181 | $ret .= "{$content}"; |
||
| 182 | $ret .= "{$t}</div>{$n}"; |
||
| 183 | } else { |
||
| 184 | $ret = "{$t}<div{$rDivClass}>{$content}</div>{$n}"; |
||
| 185 | } |
||
| 186 | |||
| 187 | return $ret; |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @public function getHtmlPre |
||
| 192 | * @param string $content |
||
| 193 | * |
||
| 194 | * @param string $preClass |
||
| 195 | * @param string $t |
||
| 196 | * @param string $n |
||
| 197 | * @return string |
||
| 198 | */ |
||
| 199 | public function getHtmlPre($content = '', $preClass = '', $t = '', $n = "\n") |
||
| 200 | { |
||
| 201 | $rPreClass = ('' != $preClass) ? " class='{$preClass}'" : ''; |
||
| 202 | $ret = "{$t}<pre{$rPreClass}>{$n}"; |
||
| 203 | $ret .= "{$content}"; |
||
| 204 | $ret .= "{$t}</pre>{$n}"; |
||
| 205 | |||
| 206 | return $ret; |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @public function getHtmlSpan |
||
| 211 | * @param string $content |
||
| 212 | * |
||
| 213 | * @param string $spanClass |
||
| 214 | * @param string $t |
||
| 215 | * @param string $n |
||
| 216 | * @return string |
||
| 217 | */ |
||
| 218 | public function getHtmlSpan($content = '', $spanClass = '', $t = '', $n = "\n") |
||
| 219 | { |
||
| 220 | $rSpanClass = ('' != $spanClass) ? " class='{$spanClass}'" : ''; |
||
| 221 | $ret = "{$t}<span{$rSpanClass}>{$content}</span>{$n}"; |
||
| 222 | |||
| 223 | return $ret; |
||
| 224 | } |
||
| 225 | |||
| 226 | /** |
||
| 227 | * @public function getHtmlParagraph |
||
| 228 | * @param string $content |
||
| 229 | * |
||
| 230 | * @param string $pClass |
||
| 231 | * @param string $t |
||
| 232 | * @param string $n |
||
| 233 | * @return string |
||
| 234 | */ |
||
| 235 | public function getHtmlParagraph($content = '', $pClass = '', $t = '', $n = "\n") |
||
| 236 | { |
||
| 237 | $rPClass = ('' != $pClass) ? " class='{$pClass}'" : ''; |
||
| 238 | $ret = "{$t}<p{$rPClass}>{$n}"; |
||
| 239 | $ret .= "{$content}"; |
||
| 240 | $ret .= "{$t}</p>{$n}"; |
||
| 241 | |||
| 242 | return $ret; |
||
| 243 | } |
||
| 244 | |||
| 245 | /** |
||
| 246 | * @public function getHtmlI |
||
| 247 | * @param string $content |
||
| 248 | * |
||
| 249 | * @param string $iClass |
||
| 250 | * @param string $t |
||
| 251 | * @param string $n |
||
| 252 | * @return string |
||
| 253 | */ |
||
| 254 | public function getHtmlI($content = '', $iClass = '', $t = '', $n = "\n") |
||
| 255 | { |
||
| 256 | $rIClass = ('' != $iClass) ? " class='{$iClass}'" : ''; |
||
| 257 | $ret = "{$t}<i{$rIClass}>{$content}</i>{$n}"; |
||
| 258 | |||
| 259 | return $ret; |
||
| 260 | } |
||
| 261 | |||
| 262 | /** |
||
| 263 | * @public function getHtmlUl |
||
| 264 | * @param string $content |
||
| 265 | * |
||
| 266 | * @param string $ulClass |
||
| 267 | * @param string $t |
||
| 268 | * @param string $n |
||
| 269 | * @return string |
||
| 270 | */ |
||
| 271 | public function getHtmlUl($content = '', $ulClass = '', $t = '', $n = "\n") |
||
| 272 | { |
||
| 273 | $rUlClass = ('' != $ulClass) ? " class='{$ulClass}'" : ''; |
||
| 274 | $ret = "{$t}<ul{$rUlClass}>{$n}"; |
||
| 275 | $ret .= "{$content}"; |
||
| 276 | $ret .= "{$t}</ul>{$n}"; |
||
| 277 | |||
| 278 | return $ret; |
||
| 279 | } |
||
| 280 | |||
| 281 | /** |
||
| 282 | * @public function getHtmlOl |
||
| 283 | * @param string $content |
||
| 284 | * |
||
| 285 | * @param string $olClass |
||
| 286 | * @param string $t |
||
| 287 | * @param string $n |
||
| 288 | * @return string |
||
| 289 | */ |
||
| 290 | public function getHtmlOl($content = '', $olClass = '', $t = '', $n = "\n") |
||
| 291 | { |
||
| 292 | $rOlClass = ('' != $olClass) ? " class='{$olClass}'" : ''; |
||
| 293 | $ret = "{$t}<ol{$rOlClass}>{$n}"; |
||
| 294 | $ret .= "{$content}"; |
||
| 295 | $ret .= "{$t}</ol>{$n}"; |
||
| 296 | |||
| 297 | return $ret; |
||
| 298 | } |
||
| 299 | |||
| 300 | /** |
||
| 301 | * @public function getHtmlLi |
||
| 302 | * @param string $content |
||
| 303 | * @param string $liClass |
||
| 304 | * |
||
| 305 | * @param string $t |
||
| 306 | * @param string $n |
||
| 307 | * @param bool $split |
||
| 308 | * @return string |
||
| 309 | */ |
||
| 310 | public function getHtmlLi($content = '', $liClass = '', $t = '', $n = "\n", $split = false) |
||
| 311 | { |
||
| 312 | $rLiClass = ('' != $liClass) ? " class='{$liClass}'" : ''; |
||
| 313 | if ($split) { |
||
| 314 | $ret = "{$t}<li{$rLiClass}>{$n}"; |
||
| 315 | $ret .= "{$content}"; |
||
| 316 | $ret .= "{$t}</li>{$n}"; |
||
| 317 | } else { |
||
| 318 | $ret = "{$t}<li{$rLiClass}>{$content}</li>{$n}"; |
||
| 319 | } |
||
| 320 | |||
| 321 | return $ret; |
||
| 322 | } |
||
| 323 | |||
| 324 | /** |
||
| 325 | * @public function getHtmlStrong |
||
| 326 | * @param string $content |
||
| 327 | * @param string $strongClass |
||
| 328 | * |
||
| 329 | * @param string $t |
||
| 330 | * @param string $n |
||
| 331 | * @return string |
||
| 332 | */ |
||
| 333 | public function getHtmlStrong($content = '', $strongClass = '', $t = '', $n = '') |
||
| 334 | { |
||
| 335 | $rStrongClass = ('' != $strongClass) ? " class='{$strongClass}'" : ''; |
||
| 336 | |||
| 337 | return "{$t}<strong{$rStrongClass}>{$content}</strong>{$n}"; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * @public function getHtmlAnchor |
||
| 342 | * @param string $url |
||
| 343 | * @param string $content |
||
| 344 | * @param string $title |
||
| 345 | * @param string $target |
||
| 346 | * @param string $aClass |
||
| 347 | * |
||
| 348 | * @param string $rel |
||
| 349 | * @param string $t |
||
| 350 | * @param string $n |
||
| 351 | * @return string |
||
| 352 | */ |
||
| 353 | public function getHtmlAnchor($url = '#', $content = ' ', $title = '', $target = '', $aClass = '', $rel = '', $t = '', $n = '') |
||
| 354 | { |
||
| 355 | $target = ('' != $target) ? " target='{$target}'" : ''; |
||
| 356 | $rAClass = ('' != $aClass) ? " class='{$aClass}'" : ''; |
||
| 357 | $rel = ('' != $rel) ? " rel='{$rel}'" : ''; |
||
| 358 | |||
| 359 | return "{$t}<a{$rAClass} href='{$url}' title='{$title}'{$target}{$rel}>{$content}</a>{$n}"; |
||
| 360 | } |
||
| 361 | |||
| 362 | /** |
||
| 363 | * @public function getHtmlImage |
||
| 364 | * @param string $src |
||
| 365 | * @param string $alt |
||
| 366 | * @param string $imgClass |
||
| 367 | * |
||
| 368 | * @param string $t |
||
| 369 | * @return string |
||
| 370 | */ |
||
| 371 | public function getHtmlImage($src = 'blank.gif', $alt = 'blank.gif', $imgClass = '', $t = '') |
||
| 372 | { |
||
| 373 | $rImgClass = ('' != $imgClass) ? " class='{$imgClass}'" : ''; |
||
| 374 | $ret = "{$t}<img{$rImgClass} src='{$src}' alt='{$alt}' />"; |
||
| 375 | |||
| 376 | return $ret; |
||
| 377 | } |
||
| 378 | |||
| 379 | /** |
||
| 380 | * @public function getHtmlTable |
||
| 381 | * @param string $content |
||
| 382 | * @param string $tableClass |
||
| 383 | * |
||
| 384 | * @param string $t |
||
| 385 | * @param string $n |
||
| 386 | * @return string |
||
| 387 | */ |
||
| 388 | public function getHtmlTable($content = '', $tableClass = '', $t = '', $n = "\n") |
||
| 389 | { |
||
| 390 | $rTableClass = ('' != $tableClass) ? " class='{$tableClass}'" : ''; |
||
| 391 | $ret = "{$t}<table{$rTableClass}>{$n}"; |
||
| 392 | $ret .= "{$content}"; |
||
| 393 | $ret .= "{$t}</table>{$n}"; |
||
| 394 | |||
| 395 | return $ret; |
||
| 396 | } |
||
| 397 | |||
| 398 | /** |
||
| 399 | * @public function getHtmlTableThead |
||
| 400 | * @param string $content |
||
| 401 | * @param string $theadClass |
||
| 402 | * |
||
| 403 | * @param string $t |
||
| 404 | * @param string $n |
||
| 405 | * @return string |
||
| 406 | */ |
||
| 407 | public function getHtmlTableThead($content = '', $theadClass = '', $t = '', $n = "\n") |
||
| 408 | { |
||
| 409 | $rTheadClass = ('' != $theadClass) ? " class='{$theadClass}'" : ''; |
||
| 410 | $ret = "{$t}<thead{$rTheadClass}>{$n}"; |
||
| 411 | $ret .= "{$content}"; |
||
| 412 | $ret .= "{$t}</thead>{$n}"; |
||
| 413 | |||
| 414 | return $ret; |
||
| 415 | } |
||
| 416 | |||
| 417 | /** |
||
| 418 | * @public function getHtmlTableTbody |
||
| 419 | * @param string $content |
||
| 420 | * @param string $tbodyClass |
||
| 421 | * |
||
| 422 | * @param string $t |
||
| 423 | * @param string $n |
||
| 424 | * @return string |
||
| 425 | */ |
||
| 426 | public function getHtmlTableTbody($content = '', $tbodyClass = '', $t = '', $n = "\n") |
||
| 427 | { |
||
| 428 | $rTbodyClass = ('' != $tbodyClass) ? " class='{$tbodyClass}'" : ''; |
||
| 429 | $ret = "{$t}<tbody{$rTbodyClass}>{$n}"; |
||
| 430 | $ret .= "{$content}"; |
||
| 431 | $ret .= "{$t}</tbody>{$n}"; |
||
| 432 | |||
| 433 | return $ret; |
||
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * @public function getHtmlTableTfoot |
||
| 438 | * @param string $content |
||
| 439 | * @param string $tfootClass |
||
| 440 | * |
||
| 441 | * @param string $t |
||
| 442 | * @param string $n |
||
| 443 | * @param bool $split |
||
| 444 | * @return string |
||
| 445 | */ |
||
| 446 | public function getHtmlTableTfoot($content = '', $tfootClass = '', $t = '', $n = "\n", $split = true) |
||
| 447 | { |
||
| 448 | $rTfootClass = ('' != $tfootClass) ? " class='{$tfootClass}'" : ''; |
||
| 449 | if ($split) { |
||
| 450 | $ret = "{$t}<tfoot{$rTfootClass}>{$n}"; |
||
| 451 | $ret .= "{$content}"; |
||
| 452 | $ret .= "{$t}</tfoot>{$n}"; |
||
| 453 | } else { |
||
| 454 | $ret = "{$t}<tfoot{$rTfootClass}>{$content}</tfoot>{$n}"; |
||
| 455 | } |
||
| 456 | |||
| 457 | return $ret; |
||
| 458 | } |
||
| 459 | |||
| 460 | /** |
||
| 461 | * @public function getHtmlTableRow |
||
| 462 | * @param string $content |
||
| 463 | * @param string $trClass |
||
| 464 | * |
||
| 465 | * @param string $t |
||
| 466 | * @param string $n |
||
| 467 | * @return string |
||
| 468 | */ |
||
| 469 | public function getHtmlTableRow($content = '', $trClass = '', $t = '', $n = "\n") |
||
| 470 | { |
||
| 471 | $rTrClass = ('' != $trClass) ? " class='{$trClass}'" : ''; |
||
| 472 | $ret = "{$t}<tr{$rTrClass}>{$n}"; |
||
| 473 | $ret .= "{$content}"; |
||
| 474 | $ret .= "{$t}</tr>{$n}"; |
||
| 475 | |||
| 476 | return $ret; |
||
| 477 | } |
||
| 478 | |||
| 479 | /** |
||
| 480 | * @public function getHtmlTableHead |
||
| 481 | * @param string $content |
||
| 482 | * @param string $thClass |
||
| 483 | * @param string $colspan |
||
| 484 | * |
||
| 485 | * @param string $t |
||
| 486 | * @param string $n |
||
| 487 | * @param bool $split |
||
| 488 | * @return string |
||
| 489 | */ |
||
| 490 | public function getHtmlTableHead($content = '', $thClass = '', $colspan = '', $t = '', $n = "\n", $split = false) |
||
| 491 | { |
||
| 492 | $rThClass = ('' != $thClass) ? " class='{$thClass}'" : ''; |
||
| 493 | $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : ''; |
||
| 494 | if ($split) { |
||
| 495 | $ret = "{$t}<th{$colspan}{$rThClass}>{$n}"; |
||
| 496 | $ret .= "{$content}"; |
||
| 497 | $ret .= "{$t}</th>{$n}"; |
||
| 498 | } else { |
||
| 499 | $ret = "{$t}<th{$colspan}{$rThClass}>{$content}</th>{$n}"; |
||
| 500 | } |
||
| 501 | return $ret; |
||
| 502 | } |
||
| 503 | |||
| 504 | /** |
||
| 505 | * @public function getHtmlTableData |
||
| 506 | * @param string $content |
||
| 507 | * @param string $tdClass |
||
| 508 | * @param string $colspan |
||
| 509 | * |
||
| 510 | * @param string $t |
||
| 511 | * @param string $n |
||
| 512 | * @param bool $split |
||
| 513 | * @return string |
||
| 514 | */ |
||
| 515 | public function getHtmlTableData($content = '', $tdClass = '', $colspan = '', $t = '', $n = "\n", $split = false) |
||
| 516 | { |
||
| 517 | $rTdClass = ('' != $tdClass) ? " class='{$tdClass}'" : ''; |
||
| 518 | $colspan = ('' != $colspan) ? " colspan='{$colspan}'" : ''; |
||
| 519 | if ($split) { |
||
| 520 | $ret = "{$t}<td{$colspan}{$rTdClass}>{$n}"; |
||
| 521 | $ret .= "{$content}"; |
||
| 522 | $ret .= "{$t}</td>{$n}"; |
||
| 523 | } else { |
||
| 524 | $ret = "{$t}<td{$colspan}{$rTdClass}>{$content}</td>{$n}"; |
||
| 525 | } |
||
| 526 | return $ret; |
||
| 527 | } |
||
| 528 | |||
| 529 | /** |
||
| 530 | * @public function getSmartyComment |
||
| 531 | * @param string $comment |
||
| 532 | * |
||
| 533 | * @param string $t |
||
| 534 | * @param string $n |
||
| 535 | * @return string |
||
| 536 | */ |
||
| 537 | public function getSmartyComment($comment = '', $t = '', $n = "\n") |
||
| 538 | { |
||
| 539 | return "{$t}<{* {$comment} *}>{$n}"; |
||
| 540 | } |
||
| 541 | |||
| 542 | /** |
||
| 543 | * @public function getSmartyNoSimbol |
||
| 544 | * @param string $noSimbol |
||
| 545 | * |
||
| 546 | * @return string |
||
| 547 | */ |
||
| 548 | public function getSmartyNoSimbol($noSimbol = '') |
||
| 549 | { |
||
| 550 | return "<{{$noSimbol}}>"; |
||
| 551 | } |
||
| 552 | |||
| 553 | /** |
||
| 554 | * @public function getSmartyConst |
||
| 555 | * @param string $language |
||
| 556 | * @param mixed $const |
||
| 557 | * |
||
| 558 | * @return string |
||
| 559 | */ |
||
| 560 | public function getSmartyConst($language, $const) |
||
| 563 | } |
||
| 564 | |||
| 565 | /** |
||
| 566 | * @public function getSmartySingleVar |
||
| 567 | * @param string $var |
||
| 568 | * |
||
| 569 | * @param string $t |
||
| 570 | * @param string $n |
||
| 571 | * @return string |
||
| 572 | */ |
||
| 573 | public function getSmartySingleVar($var, $t = '', $n = "") |
||
| 574 | { |
||
| 575 | return "{$t}<{\${$var}}>{$n}"; |
||
| 576 | } |
||
| 577 | |||
| 578 | /** |
||
| 579 | * @public function getSmartyDoubleVar |
||
| 580 | * @param string $leftVar |
||
| 581 | * @param string $rightVar |
||
| 582 | * |
||
| 583 | * @param string $t |
||
| 584 | * @param string $n |
||
| 585 | * @return string |
||
| 586 | */ |
||
| 587 | public function getSmartyDoubleVar($leftVar, $rightVar, $t = '', $n = "") |
||
| 588 | { |
||
| 589 | return "{$t}<{\${$leftVar}.{$rightVar}}>{$n}"; |
||
| 590 | } |
||
| 591 | |||
| 592 | /** |
||
| 593 | * @public function getSmartyIncludeFile |
||
| 594 | * @param $moduleDirname |
||
| 595 | * @param string $fileName |
||
| 596 | * @param bool $admin |
||
| 597 | * |
||
| 598 | * @param bool $q |
||
| 599 | * @param string $t |
||
| 600 | * @param string $n |
||
| 601 | * @return string |
||
| 602 | */ |
||
| 603 | public function getSmartyIncludeFile($moduleDirname, $fileName = 'header', $admin = false, $q = false, $t = '', $n = "\n") |
||
| 604 | { |
||
| 605 | $ret = ''; |
||
| 606 | if (!$admin && !$q) { |
||
| 607 | $ret = "{$t}<{include file='db:{$moduleDirname}_{$fileName}.tpl'}>{$n}"; |
||
| 608 | } elseif ($admin && !$q) { |
||
| 609 | $ret = "{$t}<{include file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>{$n}"; |
||
| 610 | } elseif (!$admin && $q) { |
||
| 611 | $ret = "{$t}<{includeq file='db:{$moduleDirname}_{$fileName}.tpl'}>{$n}"; |
||
| 612 | } elseif ($admin && $q) { |
||
| 613 | $ret = "{$t}<{includeq file='db:{$moduleDirname}_admin_{$fileName}.tpl'}>{$n}"; |
||
| 614 | } |
||
| 615 | |||
| 616 | return $ret; |
||
| 617 | } |
||
| 618 | |||
| 619 | /** |
||
| 620 | * @public function getSmartyIncludeFileListSection |
||
| 621 | * @param $moduleDirname |
||
| 622 | * @param $fileName |
||
| 623 | * @param $tableFieldName |
||
| 624 | * |
||
| 625 | * @param string $t |
||
| 626 | * @param string $n |
||
| 627 | * @return string |
||
| 628 | */ |
||
| 629 | public function getSmartyIncludeFileListSection($moduleDirname, $fileName, $tableFieldName, $t = '', $n = '') |
||
| 632 | } |
||
| 633 | |||
| 634 | /** |
||
| 635 | * @public function getSmartyIncludeFileListForeach |
||
| 636 | * @param $moduleDirname |
||
| 637 | * @param $fileName |
||
| 638 | * @param $tableFieldName |
||
| 639 | * |
||
| 640 | * @param string $t |
||
| 641 | * @param string $n |
||
| 642 | * @return string |
||
| 643 | */ |
||
| 644 | public function getSmartyIncludeFileListForeach($moduleDirname, $fileName, $tableFieldName, $t = '', $n = '') |
||
| 647 | } |
||
| 648 | |||
| 649 | /** |
||
| 650 | * @public function getSmartyConditions |
||
| 651 | * @param string $condition |
||
| 652 | * @param string $operator |
||
| 653 | * @param string $type |
||
| 654 | * @param string $contentIf |
||
| 655 | * @param mixed $contentElse |
||
| 656 | * @param bool $count |
||
| 657 | * |
||
| 658 | * @param bool $noSimbol |
||
| 659 | * @param string $t |
||
| 660 | * @param string $n |
||
| 661 | * @return string |
||
| 662 | */ |
||
| 663 | public function getSmartyConditions($condition = '', $operator = '', $type = '', $contentIf = '', $contentElse = false, $count = false, $noSimbol = false, $t = '', $n = "\n") |
||
| 664 | { |
||
| 665 | if (!$contentElse) { |
||
| 666 | if (!$count) { |
||
| 667 | $ret = "{$t}<{if \${$condition}{$operator}{$type}}>{$n}"; |
||
| 668 | } elseif (!$noSimbol) { |
||
| 669 | $ret = "{$t}<{if {$condition}{$operator}{$type}}>{$n}"; |
||
| 670 | } else { |
||
| 671 | $ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$n}"; |
||
| 672 | } |
||
| 673 | $ret .= "{$contentIf}"; |
||
| 674 | $ret .= "{$t}<{/if}>{$n}"; |
||
| 675 | } else { |
||
| 676 | if (!$count) { |
||
| 677 | $ret = "{$t}<{if \${$condition}{$operator}{$type}}>{$n}"; |
||
| 678 | } elseif (!$noSimbol) { |
||
| 679 | $ret = "{$t}<{if {$condition}{$operator}{$type}}>{$n}"; |
||
| 680 | } else { |
||
| 681 | $ret = "{$t}<{if count(\${$condition}){$operator}{$type}}>{$n}"; |
||
| 682 | } |
||
| 683 | $ret .= "{$contentIf}"; |
||
| 684 | $ret .= "{$t}<{else}>{$n}"; |
||
| 685 | $ret .= "{$contentElse}"; |
||
| 686 | $ret .= "{$t}<{/if}>{$n}"; |
||
| 687 | } |
||
| 688 | |||
| 689 | return $ret; |
||
| 690 | } |
||
| 691 | |||
| 692 | /** |
||
| 693 | * @public function getSmartyForeach |
||
| 694 | * @param string $item |
||
| 695 | * @param string $from |
||
| 696 | * @param string $content |
||
| 697 | * |
||
| 698 | * @param string $name |
||
| 699 | * @param string $key |
||
| 700 | * @param string $t |
||
| 701 | * @param string $n |
||
| 702 | * @return string |
||
| 703 | */ |
||
| 704 | public function getSmartyForeach($item = 'item', $from = 'from', $content = 'content', $name = '', $key = '', $t = '', $n = "\n") |
||
| 713 | } |
||
| 714 | |||
| 715 | /** |
||
| 716 | * @public function getSmartyForeachQuery |
||
| 717 | * @param string $item |
||
| 718 | * @param string $from |
||
| 719 | * @param string $content |
||
| 720 | * |
||
| 721 | * @param string $loop |
||
| 722 | * @param string $key |
||
| 723 | * @param string $t |
||
| 724 | * @param string $n |
||
| 725 | * @return string |
||
| 726 | */ |
||
| 727 | public function getSmartyForeachQuery($item = 'item', $from = 'from', $content = 'content', $loop = 'loop', $key = '', $t = '', $n = "\n") |
||
| 728 | { |
||
| 729 | $loop = '' != $loop ? " loop={$loop}" : ''; |
||
| 730 | $key = '' != $key ? " key={$key}" : ''; |
||
| 731 | $ret = "{$t}<{foreachq item={$item} from=\${$from}{$key}{$loop}}>{$n}"; |
||
| 732 | $ret .= "{$content}"; |
||
| 733 | $ret .= "{$t}<{/foreachq}>{$n}"; |
||
| 734 | |||
| 735 | return $ret; |
||
| 736 | } |
||
| 737 | |||
| 738 | /** |
||
| 739 | * @public function getSmartySection |
||
| 740 | * @param string $name |
||
| 741 | * @param string $loop |
||
| 742 | * @param string $content |
||
| 743 | * |
||
| 744 | * @param int $start |
||
| 745 | * @param int $step |
||
| 746 | * @param string $t |
||
| 747 | * @param string $n |
||
| 748 | * @return string |
||
| 749 | */ |
||
| 750 | public function getSmartySection($name = 'name', $loop = 'loop', $content = 'content', $start = 0, $step = 0, $t = '', $n = "\n") |
||
| 759 | } |
||
| 760 | } |
||
| 761 |