Index: trunk/extensions/FlaggedRevs/specialpages/UnstablePages_body.php |
— | — | @@ -1,138 +0,0 @@ |
2 | | -<?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) ) { |
4 | | - echo "FlaggedRevs extension\n"; |
5 | | - exit( 1 ); |
6 | | -} |
7 | | - |
8 | | -class Unstablepages extends SpecialPage |
9 | | -{ |
10 | | - public function __construct() { |
11 | | - parent::__construct( 'UnstablePages' ); |
12 | | - } |
13 | | - |
14 | | - public function execute( $par ) { |
15 | | - global $wgRequest, $wgUser; |
16 | | - |
17 | | - $this->setHeaders(); |
18 | | - $this->skin = $wgUser->getSkin(); |
19 | | - |
20 | | - $this->namespace = $wgRequest->getInt( 'namespace' ); |
21 | | - |
22 | | - $this->showForm(); |
23 | | - $this->showPageList(); |
24 | | - } |
25 | | - |
26 | | - protected function showForm() { |
27 | | - global $wgOut, $wgScript; |
28 | | - $namespaces = FlaggedRevs::getReviewNamespaces(); |
29 | | - $wgOut->addHTML( wfMsgExt( 'unstablepages-text', array( 'parseinline' ) ) ); |
30 | | - if ( count( $namespaces ) > 1 ) { |
31 | | - $form = Xml::openElement( 'form', array( 'name' => 'unstablepages', |
32 | | - 'action' => $wgScript, 'method' => 'get' ) ); |
33 | | - $form .= "<fieldset><legend>" . wfMsg( 'unstablepages' ) . "</legend>\n"; |
34 | | - $form .= FlaggedRevsXML::getNamespaceMenu( $this->namespace ) . ' '; |
35 | | - $form .= " " . Xml::submitButton( wfMsg( 'go' ) ); |
36 | | - $form .= Xml::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ); |
37 | | - $form .= "</fieldset></form>\n"; |
38 | | - $wgOut->addHTML( $form ); |
39 | | - } |
40 | | - } |
41 | | - |
42 | | - protected function showPageList() { |
43 | | - global $wgOut, $wgUser, $wgLang; |
44 | | - # Take this opportunity to purge out expired configurations |
45 | | - FlaggedRevs::purgeExpiredConfigurations(); |
46 | | - $pager = new unstablepagesPager( $this, array(), $this->namespace ); |
47 | | - if ( $pager->getNumRows() ) { |
48 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
49 | | - $wgOut->addHTML( $pager->getBody() ); |
50 | | - $wgOut->addHTML( $pager->getNavigationBar() ); |
51 | | - } else { |
52 | | - $wgOut->addHTML( wfMsgExt( 'unstablepages-none', array( 'parse' ) ) ); |
53 | | - } |
54 | | - } |
55 | | - |
56 | | - public function formatRow( $row ) { |
57 | | - global $wgLang, $wgUser; |
58 | | - |
59 | | - $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
60 | | - $link = $this->skin->makeKnownLinkObj( $title, $title->getPrefixedText() ); |
61 | | - |
62 | | - $stitle = SpecialPage::getTitleFor( 'Stabilization' ); |
63 | | - $config = $this->skin->makeKnownLinkObj( $stitle, wfMsgHtml( 'unstablepages-config' ), |
64 | | - 'page=' . $title->getPrefixedUrl() ); |
65 | | - $stable = $this->skin->makeKnownLinkObj( $title, wfMsgHtml( 'unstablepages-stable' ), |
66 | | - 'stable=1' ); |
67 | | - if ( $row->fpc_expiry != 'infinity' && strlen( $row->fpc_expiry ) ) { |
68 | | - $expiry_description = " (" . wfMsgForContent( |
69 | | - 'protect-expiring', |
70 | | - $wgLang->timeanddate( $row->fpc_expiry ), |
71 | | - $wgLang->date( $row->fpc_expiry ), |
72 | | - $wgLang->time( $row->fpc_expiry ) |
73 | | - ) . ")"; |
74 | | - } else { |
75 | | - $expiry_description = ""; |
76 | | - } |
77 | | - |
78 | | - return "<li>{$link} ({$config}) [{$stable}]{$expiry_description}</li>"; |
79 | | - } |
80 | | -} |
81 | | - |
82 | | -/** |
83 | | - * Query to list out stable versions for a page |
84 | | - */ |
85 | | -class UnstablePagesPager extends AlphabeticPager { |
86 | | - public $mForm, $mConds, $namespace; |
87 | | - |
88 | | - function __construct( $form, $conds = array(), $namespace = 0 ) { |
89 | | - $this->mForm = $form; |
90 | | - $this->mConds = $conds; |
91 | | - # Must be a content page... |
92 | | - if ( !is_null( $namespace ) ) { |
93 | | - $namespace = intval( $namespace ); |
94 | | - } |
95 | | - $vnamespaces = FlaggedRevs::getReviewNamespaces(); |
96 | | - if ( is_null( $namespace ) || !in_array( $namespace, $vnamespaces ) ) { |
97 | | - $namespace = !$vnamespaces ? - 1 : $vnamespaces[0]; |
98 | | - } |
99 | | - $this->namespace = $namespace; |
100 | | - parent::__construct(); |
101 | | - } |
102 | | - |
103 | | - function formatRow( $row ) { |
104 | | - return $this->mForm->formatRow( $row ); |
105 | | - } |
106 | | - |
107 | | - function getQueryInfo() { |
108 | | - $conds = $this->mConds; |
109 | | - $conds[] = 'page_id = fpc_page_id'; |
110 | | - $conds['fpc_override'] = 0; |
111 | | - $conds['page_namespace'] = $this->namespace; |
112 | | - return array( |
113 | | - 'tables' => array( 'flaggedpage_config', 'page' ), |
114 | | - 'fields' => 'page_namespace,page_title,fpc_expiry,fpc_page_id', |
115 | | - 'conds' => $conds, |
116 | | - 'options' => array() |
117 | | - ); |
118 | | - } |
119 | | - |
120 | | - function getIndexField() { |
121 | | - return 'fpc_page_id'; |
122 | | - } |
123 | | - |
124 | | - function getStartBody() { |
125 | | - wfProfileIn( __METHOD__ ); |
126 | | - # Do a link batch query |
127 | | - $lb = new LinkBatch(); |
128 | | - while ( $row = $this->mResult->fetchObject() ) { |
129 | | - $lb->add( $row->page_namespace, $row->page_title ); |
130 | | - } |
131 | | - $lb->execute(); |
132 | | - wfProfileOut( __METHOD__ ); |
133 | | - return '<ul>'; |
134 | | - } |
135 | | - |
136 | | - function getEndBody() { |
137 | | - return '</ul>'; |
138 | | - } |
139 | | -} |