Index: trunk/phase3/includes/SpecialNewpages.php |
— | — | @@ -8,10 +8,10 @@ |
9 | 9 | /** |
10 | 10 | * Start point |
11 | 11 | */ |
12 | | -function wfSpecialNewPages( $par ) { |
| 12 | +function wfSpecialNewPages( $par, $sp ) { |
13 | 13 | $page = new NewPagesForm(); |
14 | 14 | |
15 | | - $page->showList( $par ); |
| 15 | + $page->showList( $par, $sp->including() ); |
16 | 16 | } |
17 | 17 | |
18 | 18 | /** |
— | — | @@ -22,16 +22,18 @@ |
23 | 23 | /** |
24 | 24 | * Show a form for filtering namespace and username |
25 | 25 | * |
| 26 | + * @param string $par |
| 27 | + * @param bool $including true if the page is being included with {{Special:Newpages}} |
26 | 28 | * @return string |
27 | 29 | */ |
28 | | - public function showList() { |
29 | | - global $wgScript, $wgContLang, $wgGroupPermissions, $wgRequest, $wgUser, $wgOut; |
| 30 | + public function showList( $par, $including ) { |
| 31 | + global $wgScript, $wgLang, $wgContLang, $wgGroupPermissions, $wgRequest, $wgUser, $wgOut; |
30 | 32 | $sk = $wgUser->getSkin(); |
31 | 33 | $align = $wgContLang->isRTL() ? 'left' : 'right'; |
32 | 34 | $self = SpecialPage::getTitleFor( 'NewPages' ); |
33 | 35 | |
34 | 36 | // show/hide links |
35 | | - $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' )); |
| 37 | + $showhide = array( wfMsgHtml( 'show' ), wfMsgHtml( 'hide' ) ); |
36 | 38 | |
37 | 39 | $hidelinks = array(); |
38 | 40 | |
— | — | @@ -55,104 +57,137 @@ |
56 | 58 | $options = $defaults; |
57 | 59 | |
58 | 60 | // Override all values from requests, if specified |
59 | | - foreach ( $defaults as $v => $t ) { |
60 | | - if ( is_bool($t) ) { |
61 | | - $options[$v] = $wgRequest->getBool( $v, $options[$v] ); |
62 | | - } elseif( is_int($t) ) { |
63 | | - $options[$v] = $wgRequest->getInt( $v, $options[$v] ); |
64 | | - } elseif( is_string($t) ) { |
65 | | - $options[$v] = $wgRequest->getText( $v, $options[$v] ); |
66 | | - } |
67 | | - } |
68 | | - |
69 | | - // hack disable |
70 | | - $options['username'] = ''; |
| 61 | + foreach ( $defaults as $v => $t ) { |
| 62 | + if ( is_bool($t) ) { |
| 63 | + $options[$v] = $wgRequest->getBool( $v, $options[$v] ); |
| 64 | + } elseif( is_int($t) ) { |
| 65 | + $options[$v] = $wgRequest->getInt( $v, $options[$v] ); |
| 66 | + } elseif( is_string($t) ) { |
| 67 | + $options[$v] = $wgRequest->getText( $v, $options[$v] ); |
| 68 | + } |
| 69 | + } |
71 | 70 | |
72 | | - $wgOut->setSyndicated( true ); |
73 | | - $wgOut->setFeedAppendQuery( "namespace={$options['namespace']}&username={$options['username']}" ); |
| 71 | + $shownav = !$including; |
| 72 | + if ( $par ) { |
| 73 | + $bits = preg_split( '/\s*,\s*/', trim( $par ) ); |
| 74 | + foreach ( $bits as $bit ) { |
| 75 | + if ( 'shownav' == $bit ) |
| 76 | + $shownav = true; |
| 77 | + if ( 'hideliu' === $bit ) |
| 78 | + $options['hideliu'] = true; |
| 79 | + if ( 'hidepatrolled' == $bit ) |
| 80 | + $options['hidepatrolled'] = true; |
| 81 | + if ( 'hidebots' == $bit ) |
| 82 | + $options['hidebots'] = true; |
| 83 | + if ( is_numeric( $bit ) ) |
| 84 | + $options['limit'] = intval( $bit ); |
74 | 85 | |
75 | | - $feedType = $wgRequest->getVal( 'feed' ); |
76 | | - if( $feedType ) { |
77 | | - wfProfileOut( __METHOD__ ); |
78 | | - return $this->feed( $feedType, $options ); |
| 86 | + $m = array(); |
| 87 | + if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) |
| 88 | + $options['limit'] = intval($m[1]); |
| 89 | + if ( preg_match( '/^offset=(\d+)$/', $bit, $m ) ) |
| 90 | + $options['offset'] = intval($m[1]); |
| 91 | + if ( preg_match( '/^namespace=(.*)$/', $bit, $m ) ) { |
| 92 | + $ns = $wgLang->getNsIndex( $m[1] ); |
| 93 | + if( $ns !== false ) { |
| 94 | + $options['namespace'] = $ns; |
| 95 | + } |
| 96 | + } |
| 97 | + } |
79 | 98 | } |
80 | 99 | |
81 | | - $nondefaults = array(); |
82 | | - foreach ( $options as $v => $t ) { |
83 | | - if ( $v === 'offset' ) continue; # Reset offset if parameters change |
84 | | - wfAppendToArrayIfNotDefault( $v, $t, $defaults, $nondefaults ); |
85 | | - } |
| 100 | + // hack disable |
| 101 | + $options['username'] = ''; |
| 102 | + |
| 103 | + if( !$including ){ |
| 104 | + $wgOut->setSyndicated( true ); |
| 105 | + $wgOut->setFeedAppendQuery( "namespace={$options['namespace']}&username={$options['username']}" ); |
86 | 106 | |
87 | | - $links = array(); |
88 | | - foreach ( $hidelinks as $key => $msg ) { |
89 | | - $reversed = 1 - $options[$key]; |
90 | | - $link = $sk->makeKnownLinkObj( $self, $showhide[$reversed], |
91 | | - wfArrayToCGI( array( $key => $reversed ), $nondefaults ) |
92 | | - ); |
93 | | - $links[$key] = wfMsgHtml( $msg, $link ); |
94 | | - } |
| 107 | + $feedType = $wgRequest->getVal( 'feed' ); |
| 108 | + if( $feedType ) { |
| 109 | + wfProfileOut( __METHOD__ ); |
| 110 | + return $this->feed( $feedType, $options ); |
| 111 | + } |
95 | 112 | |
96 | | - $hl = implode( ' | ', $links ); |
| 113 | + $nondefaults = array(); |
| 114 | + foreach ( $options as $v => $t ) { |
| 115 | + if ( $v === 'offset' ) continue; # Reset offset if parameters change |
| 116 | + wfAppendToArrayIfNotDefault( $v, $t, $defaults, $nondefaults ); |
| 117 | + } |
97 | 118 | |
98 | | - // Store query values in hidden fields so that form submission doesn't lose them |
99 | | - $hidden = array(); |
100 | | - foreach ( $nondefaults as $key => $value ) { |
101 | | - if ( $key === 'namespace' ) continue; |
102 | | - if ( $key === 'username' ) continue; |
103 | | - $hidden[] = Xml::hidden( $key, $value ); |
104 | | - } |
105 | | - $hidden = implode( "\n", $hidden ); |
| 119 | + $links = array(); |
| 120 | + foreach ( $hidelinks as $key => $msg ) { |
| 121 | + $reversed = 1 - $options[$key]; |
| 122 | + $link = $sk->makeKnownLinkObj( $self, $showhide[$reversed], |
| 123 | + wfArrayToCGI( array( $key => $reversed ), $nondefaults ) |
| 124 | + ); |
| 125 | + $links[$key] = wfMsgHtml( $msg, $link ); |
| 126 | + } |
106 | 127 | |
107 | | - $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . |
108 | | - Xml::hidden( 'title', $self->getPrefixedDBkey() ) . |
109 | | - Xml::openElement( 'fieldset' ) . |
110 | | - Xml::element( 'legend', null, wfMsg( 'newpages' ) ) . |
111 | | - Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) . |
112 | | - "<tr> |
113 | | - <td align=\"$align\">" . |
114 | | - Xml::label( wfMsg( 'namespace' ), 'namespace' ) . |
115 | | - "</td> |
116 | | - <td>" . |
117 | | - Xml::namespaceSelector( $options['namespace'], 'all' ) . |
118 | | - "</td> |
119 | | - </tr> |
120 | | - <!-- |
121 | | - <tr> |
122 | | - <td align=\"$align\">" . |
123 | | - Xml::label( wfMsg( 'newpages-username' ), 'mw-np-username' ) . |
124 | | - "</td> |
125 | | - <td>" . |
126 | | - Xml::input( 'username', 30, $options['username'], array( 'id' => 'mw-np-username' ) ) . |
127 | | - "</td> |
128 | | - </tr> |
129 | | - --> |
130 | | - <tr> <td></td> |
131 | | - <td>" . |
132 | | - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . |
133 | | - "</td> |
134 | | - </tr>" . |
135 | | - "<tr> |
136 | | - <td></td> |
137 | | - <td>" . |
138 | | - $hl . |
139 | | - "</td> |
140 | | - </tr>" . |
141 | | - Xml::closeElement( 'table' ) . |
142 | | - Xml::closeElement( 'fieldset' ) . |
143 | | - $hidden . |
144 | | - Xml::closeElement( 'form' ); |
| 128 | + $hl = implode( ' | ', $links ); |
145 | 129 | |
146 | | - $wgOut->addHTML( $form ); |
| 130 | + // Store query values in hidden fields so that form submission doesn't lose them |
| 131 | + $hidden = array(); |
| 132 | + foreach ( $nondefaults as $key => $value ) { |
| 133 | + if ( $key === 'namespace' ) continue; |
| 134 | + if ( $key === 'username' ) continue; |
| 135 | + $hidden[] = Xml::hidden( $key, $value ); |
| 136 | + } |
| 137 | + $hidden = implode( "\n", $hidden ); |
147 | 138 | |
| 139 | + $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) . |
| 140 | + Xml::hidden( 'title', $self->getPrefixedDBkey() ) . |
| 141 | + Xml::openElement( 'fieldset' ) . |
| 142 | + Xml::element( 'legend', null, wfMsg( 'newpages' ) ) . |
| 143 | + Xml::openElement( 'table', array( 'id' => 'mw-newpages-table' ) ) . |
| 144 | + "<tr> |
| 145 | + <td align=\"$align\">" . |
| 146 | + Xml::label( wfMsg( 'namespace' ), 'namespace' ) . |
| 147 | + "</td> |
| 148 | + <td>" . |
| 149 | + Xml::namespaceSelector( $options['namespace'], 'all' ) . |
| 150 | + "</td> |
| 151 | + </tr> |
| 152 | + <!-- |
| 153 | + <tr> |
| 154 | + <td align=\"$align\">" . |
| 155 | + Xml::label( wfMsg( 'newpages-username' ), 'mw-np-username' ) . |
| 156 | + "</td> |
| 157 | + <td>" . |
| 158 | + Xml::input( 'username', 30, $options['username'], array( 'id' => 'mw-np-username' ) ) . |
| 159 | + "</td> |
| 160 | + </tr> |
| 161 | + --> |
| 162 | + <tr> <td></td> |
| 163 | + <td>" . |
| 164 | + Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . |
| 165 | + "</td> |
| 166 | + </tr>" . |
| 167 | + "<tr> |
| 168 | + <td></td> |
| 169 | + <td>" . |
| 170 | + $hl . |
| 171 | + "</td> |
| 172 | + </tr>" . |
| 173 | + Xml::closeElement( 'table' ) . |
| 174 | + Xml::closeElement( 'fieldset' ) . |
| 175 | + $hidden . |
| 176 | + Xml::closeElement( 'form' ); |
| 177 | + |
| 178 | + $wgOut->addHTML( $form ); |
| 179 | + } |
| 180 | + |
148 | 181 | $pager = new NewPagesPager( $this, array(), $options['namespace'], $options['hideliu'], |
149 | 182 | $options['hidepatrolled'], $options['hidebots'], $options['username'] ); |
| 183 | + $pager->mLimit = $options['limit']; |
| 184 | + $pager->mOffset = $options['offset']; |
150 | 185 | |
151 | 186 | if( $pager->getNumRows() ) { |
152 | | - $wgOut->addHTML( $pager->getNavigationBar() . |
| 187 | + $wgOut->addHTML( ( $shownav ? $pager->getNavigationBar() : '' ) . |
153 | 188 | $pager->getStartBody() . |
154 | 189 | $pager->getBody() . |
155 | 190 | $pager->getEndBody() . |
156 | | - $pager->getNavigationBar() ); |
| 191 | + ( $shownav ? $pager->getNavigationBar() : '' ) ); |
157 | 192 | } else { |
158 | 193 | $wgOut->addHTML( '<p>' . wfMsgHtml( 'specialpage-empty' ) . '</p>' ); |
159 | 194 | } |
— | — | @@ -289,7 +324,7 @@ |
290 | 325 | * @addtogroup Pager |
291 | 326 | */ |
292 | 327 | class NewPagesPager extends ReverseChronologicalPager { |
293 | | - private $hideliu, $hidepatrolled, $hidebots, $namespace, $user; |
| 328 | + private $hideliu, $hidepatrolled, $hidebots, $namespace, $user, $spTitle; |
294 | 329 | |
295 | 330 | function __construct( $form, $conds=array(), $namespace, $hliu=false, $hpatrolled=false, $hbots=1, $user='' ) { |
296 | 331 | parent::__construct(); |
— | — | @@ -304,6 +339,12 @@ |
305 | 340 | $this->hidebots = (bool)$hbots; |
306 | 341 | } |
307 | 342 | |
| 343 | + function getTitle(){ |
| 344 | + if( !isset( $this->spTitle ) ) |
| 345 | + $this->spTitle = SpecialPage::getTitleFor( 'Newpages' ); |
| 346 | + return $this->spTitle; |
| 347 | + } |
| 348 | + |
308 | 349 | function getQueryInfo() { |
309 | 350 | $conds = $this->mConds; |
310 | 351 | $conds['rc_new'] = 1; |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -185,6 +185,8 @@ |
186 | 186 | * (bug 13727) Don't delete log entries from recentchanges on page deletion |
187 | 187 | * (bug 13752) Section redirects now works again |
188 | 188 | * (bug 13725) Upload form watch checkbox state set correctly with wpDestFile |
| 189 | +* (bug 13756) Don't show the form and navigation links of Special:Newpages if |
| 190 | + the page is included |
189 | 191 | |
190 | 192 | |
191 | 193 | === API changes in 1.13 === |