Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / includes / actions / ViewAction.php
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
16 *
17 * @file
18 * @ingroup Actions
19 */
20
21 /**
22 * An action that views article content
23 *
24 * This is a wrapper that will call Article::view().
25 *
26 * @ingroup Actions
27 */
28 class ViewAction extends FormlessAction {
29
30 public function getName() {
31 return 'view';
32 }
33
34 public function onView() {
35 return null;
36 }
37
38 public function show() {
39 $config = $this->context->getConfig();
40
41 if (
42 $config->get( 'DebugToolbar' ) == false && // don't let this get stuck on pages
43 $this->page->checkTouched() // page exists and is not a redirect
44 ) {
45 // Include any redirect in the last-modified calculation
46 $redirFromTitle = $this->page->getRedirectedFrom();
47 if ( !$redirFromTitle ) {
48 $touched = $this->page->getTouched();
49 } elseif ( $config->get( 'MaxRedirects' ) <= 1 ) {
50 $touched = max( $this->page->getTouched(), $redirFromTitle->getTouched() );
51 } else {
52 // Don't bother following the chain and getting the max mtime
53 $touched = null;
54 }
55
56 // Send HTTP 304 if the IMS matches or otherwise set expiry/last-modified headers
57 if ( $touched && $this->getOutput()->checkLastModified( $touched ) ) {
58 wfDebug( __METHOD__ . ": done 304\n" );
59 return;
60 }
61 }
62
63 $this->page->view();
64 }
65 }