c8db1d87cdc0b5cdc25daa7038c090f3ff1f0ba9
[lhc/web/wiklou.git] / includes / specials / SpecialMyRedirectPages.php
1 <?php
2 /**
3 * Special pages that are used to get user independent links pointing to
4 * current user's pages (user page, talk page, contributions, etc.).
5 * This can let us cache a single copy of some generated content for all
6 * users or be linked in wikitext help pages.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * http://www.gnu.org/copyleft/gpl.html
22 *
23 * @file
24 * @ingroup SpecialPage
25 */
26
27 /**
28 * Special page pointing to current user's user page.
29 *
30 * @ingroup SpecialPage
31 */
32 class SpecialMypage extends RedirectSpecialArticle {
33 public function __construct() {
34 parent::__construct( 'Mypage' );
35 }
36
37 /**
38 * @param string|null $subpage
39 * @return Title
40 */
41 public function getRedirect( $subpage ) {
42 if ( $subpage === null || $subpage === '' ) {
43 return Title::makeTitle( NS_USER, $this->getUser()->getName() );
44 }
45
46 return Title::makeTitle( NS_USER, $this->getUser()->getName() . '/' . $subpage );
47 }
48 }
49
50 /**
51 * Special page pointing to current user's talk page.
52 *
53 * @ingroup SpecialPage
54 */
55 class SpecialMytalk extends RedirectSpecialArticle {
56 public function __construct() {
57 parent::__construct( 'Mytalk' );
58 }
59
60 /**
61 * @param string|null $subpage
62 * @return Title
63 */
64 public function getRedirect( $subpage ) {
65 if ( $subpage === null || $subpage === '' ) {
66 return Title::makeTitle( NS_USER_TALK, $this->getUser()->getName() );
67 }
68
69 return Title::makeTitle( NS_USER_TALK, $this->getUser()->getName() . '/' . $subpage );
70 }
71 }
72
73 /**
74 * Special page pointing to current user's contributions.
75 *
76 * @ingroup SpecialPage
77 */
78 class SpecialMycontributions extends RedirectSpecialPage {
79 public function __construct() {
80 parent::__construct( 'Mycontributions' );
81 $this->mAllowedRedirectParams = array( 'limit', 'namespace', 'tagfilter',
82 'offset', 'dir', 'year', 'month', 'feed' );
83 }
84
85 /**
86 * @param string|null $subpage
87 * @return Title
88 */
89 public function getRedirect( $subpage ) {
90 return SpecialPage::getTitleFor( 'Contributions', $this->getUser()->getName() );
91 }
92 }
93
94 /**
95 * Special page pointing to current user's uploaded files.
96 *
97 * @ingroup SpecialPage
98 */
99 class SpecialMyuploads extends RedirectSpecialPage {
100 public function __construct() {
101 parent::__construct( 'Myuploads' );
102 $this->mAllowedRedirectParams = array( 'limit', 'ilshowall', 'ilsearch' );
103 }
104
105 /**
106 * @param string|null $subpage
107 * @return Title
108 */
109 public function getRedirect( $subpage ) {
110 return SpecialPage::getTitleFor( 'Listfiles', $this->getUser()->getName() );
111 }
112 }
113
114 /**
115 * Special page pointing to current user's uploaded files (including old versions).
116 *
117 * @ingroup SpecialPage
118 */
119 class SpecialAllMyUploads extends RedirectSpecialPage {
120 public function __construct() {
121 parent::__construct( 'AllMyUploads' );
122 $this->mAllowedRedirectParams = array( 'limit', 'ilsearch' );
123 }
124
125 /**
126 * @param string|null $subpage
127 * @return Title
128 */
129 public function getRedirect( $subpage ) {
130 $this->mAddedRedirectParams['ilshowall'] = 1;
131
132 return SpecialPage::getTitleFor( 'Listfiles', $this->getUser()->getName() );
133 }
134 }