1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19:
20:
21: class MenusSmartyDecorator extends MenusDecoratorAbstract implements MenusDecoratorInterface
22: {
23: function hasAccess($menu, &$hasAccess)
24: {
25: }
26:
27: function accessFilter(&$accessFilter)
28: {
29: }
30:
31: function start()
32: {
33: }
34:
35: function end(&$menus)
36: {
37: }
38:
39: function decorateMenu(&$menu)
40: {
41: $decorations = array('link', 'image', 'title', 'alt_title');
42: foreach ($decorations as $decoration) {
43: $menu[$decoration] = self::_doDecoration($menu[$decoration]);
44: }
45: }
46:
47: function _doDecoration($string)
48: {
49: $xoops = Xoops::getInstance();
50: if (!preg_match('/{(.*\|.*)}/i', $string, $reg)) {
51: return $string;
52: }
53:
54: $expression = $reg[0];
55: list($validator, $value) = array_map('strtolower', explode('|', $reg[1]));
56:
57: if ($validator === 'smarty') {
58: if (isset($xoops->tpl()->_tpl_vars[$value])) {
59: $string = str_replace($expression, $xoops->tpl()->_tpl_vars[$value], $string);
60: }
61: }
62:
63: return $string;
64: }
65:
66: }
67: