Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

modifiercompiler.wordwrap.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Smarty plugin
  4. *
  5. * @package Smarty
  6. * @subpackage PluginsModifierCompiler
  7. */
  8. /**
  9. * Smarty wordwrap modifier plugin
  10. * Type: modifier<br>
  11. * Name: wordwrap<br>
  12. * Purpose: wrap a string of text at a given length
  13. *
  14. * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
  15. * @author Uwe Tews
  16. *
  17. * @param array $params parameters
  18. * @param $compiler
  19. *
  20. * @return string with compiled code
  21. */
  22. function smarty_modifiercompiler_wordwrap($params, $compiler)
  23. {
  24. if (!isset($params[1])) {
  25. $params[1] = 80;
  26. }
  27. if (!isset($params[2])) {
  28. $params[2] = '"\n"';
  29. }
  30. if (!isset($params[3])) {
  31. $params[3] = 'false';
  32. }
  33. $function = 'wordwrap';
  34. if (Smarty::$_MBSTRING) {
  35. if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
  36. $compiler->parent_compiler->template->compiled->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
  37. $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
  38. } else {
  39. $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
  40. $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
  41. }
  42. $function = 'smarty_mb_wordwrap';
  43. }
  44. return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
  45. }