Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

smarty_internal_method_addautoloadfilters.php 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Smarty Method AddAutoloadFilters
  4. *
  5. * Smarty::addAutoloadFilters() method
  6. *
  7. * @package Smarty
  8. * @subpackage PluginsInternal
  9. * @author Uwe Tews
  10. */
  11. class Smarty_Internal_Method_AddAutoloadFilters extends Smarty_Internal_Method_SetAutoloadFilters
  12. {
  13. /**
  14. * Add autoload filters
  15. *
  16. * @api Smarty::setAutoloadFilters()
  17. *
  18. * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
  19. * @param array $filters filters to load automatically
  20. * @param string $type "pre", "output", … specify the
  21. * filter type to set. Defaults to
  22. * none treating $filters' keys as
  23. * the appropriate types
  24. *
  25. * @return \Smarty|\Smarty_Internal_Template
  26. * @throws \SmartyException
  27. */
  28. public function addAutoloadFilters(Smarty_Internal_TemplateBase $obj, $filters, $type = null)
  29. {
  30. $smarty = $obj->_getSmartyObj();
  31. if ($type !== null) {
  32. $this->_checkFilterType($type);
  33. if (!empty($smarty->autoload_filters[ $type ])) {
  34. $smarty->autoload_filters[ $type ] = array_merge($smarty->autoload_filters[ $type ], (array) $filters);
  35. } else {
  36. $smarty->autoload_filters[ $type ] = (array) $filters;
  37. }
  38. } else {
  39. foreach ((array) $filters as $type => $value) {
  40. $this->_checkFilterType($type);
  41. if (!empty($smarty->autoload_filters[ $type ])) {
  42. $smarty->autoload_filters[ $type ] =
  43. array_merge($smarty->autoload_filters[ $type ], (array) $value);
  44. } else {
  45. $smarty->autoload_filters[ $type ] = (array) $value;
  46. }
  47. }
  48. }
  49. return $obj;
  50. }
  51. }