PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/code/smarty/Smarty/sysplugins/smarty_internal_wrapper.php

https://github.com/Voelkerball/BaBeSK
PHP | 131 lines | 75 code | 7 blank | 49 comment | 1 complexity | 1f583879be60e9bf34f20260b52f9815 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. /**
  3. * Project: Smarty: the PHP compiling template engine
  4. * File: smarty_internal_wrapper.php
  5. * SVN: $Id: $
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library 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. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * For questions, help, comments, discussion, etc., please join the
  22. * Smarty mailing list. Send a blank e-mail to
  23. * smarty-discussion-subscribe@googlegroups.com
  24. *
  25. * @link http://www.smarty.net/
  26. * @copyright 2008 New Digital Group, Inc.
  27. * @author Monte Ohrt <monte at ohrt dot com>
  28. * @author Uwe Tews
  29. * @package Smarty
  30. * @subpackage PluginsInternal
  31. * @version 3-SVN$Rev: 3286 $
  32. */
  33. /*
  34. * Smarty Backward Compatability Wrapper
  35. */
  36. class Smarty_Internal_Wrapper {
  37. protected $smarty;
  38. function __construct($smarty) {
  39. $this->smarty = $smarty;
  40. }
  41. /**
  42. * Converts smarty2-style function call to smarty 3-style function call
  43. * This is expensive, be sure to port your code to Smarty 3!
  44. *
  45. * @param string $name Smarty 2 function name
  46. * @param array $args Smarty 2 function args
  47. */
  48. function convert($name, $args) {
  49. // throw notice about deprecated function
  50. if($this->smarty->deprecation_notices)
  51. trigger_error("function call '$name' is unknown or deprecated.",E_USER_NOTICE);
  52. // get first and last part of function name
  53. $name_parts = explode('_',$name,2);
  54. switch($name_parts[0]) {
  55. case 'register':
  56. case 'unregister':
  57. switch($name_parts[1]) {
  58. case 'object':
  59. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Object"),$args);
  60. case 'compiler_function':
  61. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Plugin"),array_merge(array('compiler'),$args));
  62. case 'prefilter':
  63. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('pre'),$args));
  64. case 'postfilter':
  65. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('post'),$args));
  66. case 'outputfilter':
  67. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Filter"),array_merge(array('output'),$args));
  68. case 'resource':
  69. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Resource"),$args);
  70. default:
  71. return call_user_func_array(array($this->smarty,"{$name_parts[0]}Plugin"),array_merge(array($name_parts[1]),$args));
  72. }
  73. case 'get':
  74. switch($name_parts[1]) {
  75. case 'template_vars':
  76. return call_user_func_array(array($this->smarty,'getTemplateVars'),$args);
  77. case 'config_vars':
  78. return call_user_func_array(array($this->smarty,'getConfigVars'),$args);
  79. default:
  80. return call_user_func_array(array($myobj,$name_parts[1]),$args);
  81. }
  82. case 'clear':
  83. switch($name_parts[1]) {
  84. case 'all_assign':
  85. return call_user_func_array(array($this->smarty,'clearAllAssign'),$args);
  86. case 'assign':
  87. return call_user_func_array(array($this->smarty,'clearAssign'),$args);
  88. case 'all_cache':
  89. return call_user_func_array(array($this->smarty,'clearAllCache'),$args);
  90. case 'cache':
  91. return call_user_func_array(array($this->smarty,'clearCache'),$args);
  92. case 'compiled_template':
  93. return call_user_func_array(array($this->smarty,'clearCompiledTemplate'),$args);
  94. }
  95. case 'config':
  96. switch($name_parts[1]) {
  97. case 'load':
  98. return call_user_func_array(array($this->smarty,'configLoad'),$args);
  99. }
  100. case 'trigger':
  101. switch($name_parts[1]) {
  102. case 'error':
  103. return call_user_func_array('trigger_error',$args);
  104. }
  105. case 'load':
  106. switch($name_parts[1]) {
  107. case 'filter':
  108. return call_user_func_array(array($this->smarty,'loadFilter'),$args);
  109. }
  110. }
  111. throw new SmartyException("unknown method '$name'");
  112. }
  113. /**
  114. * trigger Smarty error
  115. *
  116. * @param string $error_msg
  117. * @param integer $error_type
  118. */
  119. function trigger_error($error_msg, $error_type = E_USER_WARNING)
  120. {
  121. trigger_error("Smarty error: $error_msg", $error_type);
  122. }
  123. }
  124. ?>