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