Make wfExpandUrl use wfRemoveDotSegments on the resulting path. This finishes
[lhc/web/wiklou.git] / includes / context / ContextSource.php
1 <?php
2 /**
3 * Request-dependant objects containers.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @since 1.18
21 *
22 * @author Happy-melon
23 * @file
24 */
25
26 /**
27 * The simplest way of implementing IContextSource is to hold a RequestContext as a
28 * member variable and provide accessors to it.
29 */
30 abstract class ContextSource implements IContextSource {
31
32 /**
33 * @var IContextSource
34 */
35 private $context;
36
37 /**
38 * Get the RequestContext object
39 *
40 * @return RequestContext
41 */
42 public function getContext() {
43 if ( $this->context === null ) {
44 $class = get_class( $this );
45 wfDebug( __METHOD__ . " ($class): called and \$context is null. Using RequestContext::getMain() for sanity\n" );
46 $this->context = RequestContext::getMain();
47 }
48 return $this->context;
49 }
50
51 /**
52 * Set the IContextSource object
53 *
54 * @param $context IContextSource
55 */
56 public function setContext( IContextSource $context ) {
57 $this->context = $context;
58 }
59
60 /**
61 * Get the WebRequest object
62 *
63 * @return WebRequest
64 */
65 public function getRequest() {
66 return $this->getContext()->getRequest();
67 }
68
69 /**
70 * Get the Title object
71 *
72 * @return Title
73 */
74 public function getTitle() {
75 return $this->getContext()->getTitle();
76 }
77
78 /**
79 * Get the OutputPage object
80 *
81 * @return OutputPage object
82 */
83 public function getOutput() {
84 return $this->getContext()->getOutput();
85 }
86
87 /**
88 * Get the User object
89 *
90 * @return User
91 */
92 public function getUser() {
93 return $this->getContext()->getUser();
94 }
95
96 /**
97 * Get the Language object
98 *
99 * @return Language
100 */
101 public function getLang() {
102 return $this->getContext()->getLang();
103 }
104
105 /**
106 * Get the Skin object
107 *
108 * @return Skin
109 */
110 public function getSkin() {
111 return $this->getContext()->getSkin();
112 }
113
114 /**
115 * Get a Message object with context set
116 * Parameters are the same as wfMessage()
117 *
118 * @return Message object
119 */
120 public function msg( /* $args */ ) {
121 $args = func_get_args();
122 return call_user_func_array( array( $this->getContext(), 'msg' ), $args );
123 }
124 }
125