Updates
[lhc/web/wiklou.git] / includes / SpecialProtectedpages.php
1 <?php
2 /**
3 *
4 * @addtogroup SpecialPage
5 */
6
7 /**
8 *
9 * @addtogroup SpecialPage
10 */
11 class ProtectedPagesPage extends PageQueryPage {
12
13 function getName( ) {
14 return "Protectedpages";
15 }
16
17 function getPageHeader() {
18 return '<p>' . wfMsg('protectedpagestext') . '</p>';
19 }
20
21 /**
22 * LEFT JOIN is expensive
23 *
24 * @return true
25 */
26 function isExpensive( ) {
27 return 1;
28 }
29
30 function isSyndicated() { return false; }
31
32 /**
33 * @return false
34 */
35 function sortDescending() {
36 return false;
37 }
38
39 /**
40 * @return string an sqlquery
41 */
42 function getSQL() {
43 $dbr =& wfGetDB( DB_SLAVE );
44 list( $page, $page_restrictions ) = $dbr->tableNamesN( 'page', 'page_restrictions' );
45 return "SELECT DISTINCT page_id, 'Protectedpages' as type, page_namespace AS namespace, page_title as title, " .
46 "page_title AS value, pr_level, pr_expiry " .
47 "FROM $page, $page_restrictions WHERE page_id = pr_page AND pr_user IS NULL ";
48 }
49
50 /**
51 * Make link to the page, and add the protection levels.
52 *
53 * @param $skin Skin to be used
54 * @param $result Result row
55 * @return string
56 */
57 function formatResult( $skin, $result ) {
58 global $wgLang;
59 $title = Title::makeTitleSafe( $result->namespace, $result->title );
60 $link = $skin->makeLinkObj( $title );
61
62 $description_items = array ();
63
64 $protType = wfMsg( 'restriction-level-' . $result->pr_level );
65
66 $description_items[] = $protType;
67
68 $expiry_description = '';
69
70 if ( $result->pr_expiry != 'infinity' && strlen($result->pr_expiry) ) {
71 $expiry = Block::decodeExpiry( $result->pr_expiry );
72
73 $expiry_description = wfMsgForContent( 'protect-expiring', $wgLang->timeanddate( $expiry ) );
74
75 $description_items[] = $expiry_description;
76 }
77
78 return wfSpecialList( $link, implode( $description_items, ', ' ) );
79 }
80 }
81
82 /**
83 * Constructor
84 */
85 function wfSpecialProtectedpages() {
86
87 list( $limit, $offset ) = wfCheckLimits();
88
89 $depp = new ProtectedPagesPage();
90
91 Title::purgeExpiredRestrictions();
92
93 return $depp->doQuery( $offset, $limit );
94 }
95
96 ?>