1: <?php
2: /**
3: * Generates the match dictionary for the incoming request.
4: *
5: * PHP version 5
6: *
7: * @category Kolab
8: * @package Kolab_FreeBusy
9: * @author Gunnar Wrobel <wrobel@pardus.de>
10: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
11: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
12: */
13:
14: /**
15: * Generates the match dictionary for the incoming request.
16: *
17: * Copyright 2011-2012 Horde LLC (http://www.horde.org/)
18: *
19: * See the enclosed file COPYING for license information (LGPL). If you did not
20: * receive this file, see
21: * http://www.horde.org/licenses/lgpl21.
22: *
23: * @category Kolab
24: * @package Kolab_FreeBusy
25: * @author Gunnar Wrobel <wrobel@pardus.de>
26: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
27: * @link http://pear.horde.org/index.php?package=Kolab_FreeBusy
28: */
29: class Horde_Kolab_FreeBusy_Controller_MatchDict
30: {
31: /**
32: * The routes mapper.
33: *
34: * @var Horde_Routes_Mapper
35: */
36: private $_mapper;
37:
38: /**
39: * The incoming request.
40: *
41: * @var Horde_Controller_Request
42: */
43: private $_request;
44:
45: /**
46: * The match dictionary.
47: *
48: * @var array
49: */
50: private $_match_dict;
51:
52: /**
53: * Constructor
54: */
55: public function __construct(
56: Horde_Routes_Mapper $mapper, Horde_Controller_Request $request
57: )
58: {
59: $this->_mapper = $mapper;
60: $this->_request = $request;
61: }
62:
63: /**
64: * Return the match dictionary for the incoming request.
65: *
66: * @return array The match dictionary.
67: */
68: public function getMatchDict()
69: {
70: if ($this->_match_dict === null) {
71: $path = $this->_request->getPath();
72: if (($pos = strpos($path, '?')) !== false) {
73: $path = substr($path, 0, $pos);
74: }
75: if (!$path) {
76: $path = '/';
77: }
78: $this->_match_dict = new Horde_Support_Array($this->_mapper->match($path));
79: }
80: return $this->_match_dict;
81: }
82: }