Index: trunk/extensions/RPED/RPED.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | 'author' => 'Tisane', |
34 | 34 | 'url' => 'http://www.mediawiki.org/wiki/Extension:RemotePageExistenceDetection', |
35 | 35 | 'descriptionmsg' => 'rped-desc', |
36 | | - 'version' => '1.0.1', |
| 36 | + 'version' => '1.0.2', |
37 | 37 | ); |
38 | 38 | |
39 | 39 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -44,3 +44,7 @@ |
45 | 45 | |
46 | 46 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'RPEDHooks::RPEDCreateTable'; |
47 | 47 | $wgHooks['LinkBegin'][] = 'RPEDHooks::wikipediaLink'; |
| 48 | + |
| 49 | +$wgRPEDBrokenLinkStyle = "color: red"; |
| 50 | +$wgRPEDExcludeNamespaced = false; |
| 51 | +$wgRemoteStyle = 'color: blue'; |
\ No newline at end of file |
Index: trunk/extensions/RPED/RPED.hooks.php |
— | — | @@ -14,7 +14,8 @@ |
15 | 15 | public static function wikipediaLink( $skin, $target, &$text, |
16 | 16 | &$customAttribs, &$query, &$options, &$ret |
17 | 17 | ) { |
18 | | - global $wgLocalStyle, $wgRemoteStyle, $wgPureWikiDeletionInEffect, $wgTitle, $wgRequest; |
| 18 | + global $wgLocalStyle, $wgRemoteStyle, $wgPureWikiDeletionInEffect |
| 19 | + , $wgTitle, $wgRequest, $wgRPEDBrokenLinkStyle, $wgRPEDExcludeNamespaced; |
19 | 20 | wfLoadExtensionMessages('RPED'); |
20 | 21 | if ( $wgTitle->getNamespace () == -1 ) { |
21 | 22 | return true; |
— | — | @@ -30,6 +31,40 @@ |
31 | 32 | |
32 | 33 | $itIsBlank = false; |
33 | 34 | |
| 35 | + // If it's an external link, see if it leads to Wikipedia, and |
| 36 | + // if so, whether that page exists on Wikipedia |
| 37 | + if ( $target->isExternal() ) { |
| 38 | + $interwikiURL = wfMsgExt( 'rped-wikipedia-url','parsemag'); |
| 39 | + $dbr = wfGetDB( DB_SLAVE ); |
| 40 | + $title = $target->getDBkey (); |
| 41 | + |
| 42 | + if ( strpos ( $title, ':' ) && $wgRPEDExcludeNamespaced ) { |
| 43 | + return true; |
| 44 | + } |
| 45 | + |
| 46 | + $interwikiPrefix = $target->getInterwiki (); |
| 47 | + $result = $dbr->selectRow( |
| 48 | + 'interwiki', |
| 49 | + 'iw_prefix', |
| 50 | + array( "iw_url" => $interwikiURL |
| 51 | + , "iw_prefix" => $interwikiPrefix ) |
| 52 | + ); |
| 53 | + |
| 54 | + if ( !$result ) { |
| 55 | + return true; |
| 56 | + } |
| 57 | + |
| 58 | + $result = $dbr->selectRow( |
| 59 | + 'rped_page', |
| 60 | + 'rped_page_id', |
| 61 | + array( "rped_page_title" => $title ) |
| 62 | + ); |
| 63 | + if ( !$result ) { |
| 64 | + $query['action'] = "edit"; |
| 65 | + $customAttribs['style'] = $wgRPEDBrokenLinkStyle; |
| 66 | + } |
| 67 | + return true; |
| 68 | + } |
34 | 69 | // Return immediately if we know it's existent on the local wiki |
35 | 70 | if ( in_array( 'known', $options ) ) { |
36 | 71 | if ( !isset( $query['action'] ) && !isset( $query['curid'] ) ) { |
— | — | @@ -50,7 +85,6 @@ |
51 | 86 | 'blank_page_id', |
52 | 87 | array( "blank_page_id" => $id ) |
53 | 88 | ); |
54 | | - |
55 | 89 | if ( !$result ) { |
56 | 90 | return true; |
57 | 91 | } |
— | — | @@ -79,8 +113,9 @@ |
80 | 114 | if ( !$result ) { |
81 | 115 | return true; |
82 | 116 | } else { |
83 | | - $title = htmlentities( $title ); |
84 | | - $url = wfMsgExt( 'rped-wikipedia-url','parsemag') . $title; |
| 117 | + $newTitle = $target->getPrefixedURL (); |
| 118 | + #$title = urlencode ( $title ); |
| 119 | + $url = wfMsgExt( 'rped-wikipedia-url','parsemag', $newTitle ); |
85 | 120 | |
86 | 121 | // The page that we'll link to |
87 | 122 | $text = '<a href="' . $url . $fragment. '">' . $text. '</a>'; |
Index: trunk/extensions/RPED/ApiRPED.php |
— | — | @@ -31,6 +31,11 @@ |
32 | 32 | return; |
33 | 33 | } |
34 | 34 | |
| 35 | + /* |
| 36 | + * Insert or delete a row from the rped_page table |
| 37 | + * @param key "insert" or "delete" |
| 38 | + * @param $value Page name to delete |
| 39 | + */ |
35 | 40 | public function paramProcess( $key,$value ){ |
36 | 41 | $dbr = wfGetDB( DB_SLAVE ); |
37 | 42 | $dbw = wfGetDB( DB_MASTER ); |
Index: trunk/extensions/RPED/RPED.i18n.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | $messages['en'] = array( |
14 | 14 | 'rped' => 'Remote page existence detection', |
15 | 15 | 'rped-desc' => 'Links wikilinks to Wikipedia if the page does not exist on the local wiki but exists on Wikipedia', |
16 | | - 'rped-wikipedia-url' => 'http://en.wikipedia.org/wiki/', |
| 16 | + 'rped-wikipedia-url' => 'http://en.wikipedia.org/wiki/$1', |
17 | 17 | ); |
18 | 18 | |
19 | 19 | /** Belarusian (Taraškievica orthography) (Беларуская (тарашкевіца)) |
— | — | @@ -22,7 +22,7 @@ |
23 | 23 | $messages['be-tarask'] = array( |
24 | 24 | 'rped' => 'Выяўленьне існаваньня вонкавай старонкі', |
25 | 25 | 'rped-desc' => 'Устаўляе вікі-спасылкі на Вікіпэдыю, калі старонка не існуе ў лякальнай вікі, але існуе ў Вікіпэдыі', |
26 | | - 'rped-wikipedia-url' => 'http://be.wikipedia.org/', |
| 26 | + 'rped-wikipedia-url' => 'http://be.wikipedia.org/wiki/$1', |
27 | 27 | ); |
28 | 28 | |
29 | 29 | /** Breton (Brezhoneg) |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | $messages['br'] = array( |
34 | 34 | 'rped' => 'Detektadur a-bell ar pajennoù zo anezho', |
35 | 35 | 'rped-desc' => "Liammañ a ra ar wikiliammoù ouzh Wikipedia ma n'eus ket eus ar bajenn war ar wiki lec'hel ha m'emañ war Wikipedia", |
36 | | - 'rped-wikipedia-url' => 'http://br.wikipedia.org/', |
| 36 | + 'rped-wikipedia-url' => 'http://br.wikipedia.org/wiki/$1', |
37 | 37 | ); |
38 | 38 | |
39 | 39 | /** German (Deutsch) |
— | — | @@ -41,7 +41,7 @@ |
42 | 42 | $messages['de'] = array( |
43 | 43 | 'rped' => 'Ermittlung websitefremder Webseiten', |
44 | 44 | 'rped-desc' => 'Leitet Wikilinks zur Wikipedia, sofern die betreffende Seite nicht im lokalen Wiki, aber in der Wikipedia vorhanden ist', |
45 | | - 'rped-wikipedia-url' => 'http://de.wikipedia.org/', |
| 45 | + 'rped-wikipedia-url' => 'http://de.wikipedia.org/wiki/$1', |
46 | 46 | ); |
47 | 47 | |
48 | 48 | /** Lower Sorbian (Dolnoserbski) |
— | — | @@ -50,7 +50,7 @@ |
51 | 51 | $messages['dsb'] = array( |
52 | 52 | 'rped' => 'Namakanje eksistence zdalonego boka', |
53 | 53 | 'rped-desc' => 'Wótkazujo wikiwótkaze do Wikipedije, jolic bok njeeksistěrujo w lokalnem wikiju, ale eksistěrujo we Wikipediji', |
54 | | - 'rped-wikipedia-url' => 'http://dsb.wikipedia.org/', |
| 54 | + 'rped-wikipedia-url' => 'http://dsb.wikipedia.org/wiki/$1', |
55 | 55 | ); |
56 | 56 | |
57 | 57 | /** Spanish (Español) |
— | — | @@ -59,7 +59,7 @@ |
60 | 60 | $messages['es'] = array( |
61 | 61 | 'rped' => 'Detección de existencia de página remota', |
62 | 62 | 'rped-desc' => 'Enlaza los wikienlaces a Wikipedia si la página no existe en la wiki local pero existe en Wikipedia', |
63 | | - 'rped-wikipedia-url' => 'http://es.wikipedia.org/', |
| 63 | + 'rped-wikipedia-url' => 'http://es.wikipedia.org/wiki/$1', |
64 | 64 | ); |
65 | 65 | |
66 | 66 | /** French (Français) |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | $messages['fr'] = array( |
70 | 70 | 'rped' => "Détection d'existence des pages à distance", |
71 | 71 | 'rped-desc' => "Lie les wikiliens vers Wikipédia si la page n'existe pas sur le wiki local mais existe sur Wikipédia", |
72 | | - 'rped-wikipedia-url' => 'http://fr.wikipedia.org/', |
| 72 | + 'rped-wikipedia-url' => 'http://fr.wikipedia.org/wiki/$1', |
73 | 73 | ); |
74 | 74 | |
75 | 75 | /** Galician (Galego) |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | $messages['gl'] = array( |
79 | 79 | 'rped' => 'Detección remota da existencia de páxinas', |
80 | 80 | 'rped-desc' => 'Crea ligazóns cara á Wikipedia se a páxina non existe no wiki local pero si na Wikipedia', |
81 | | - 'rped-wikipedia-url' => 'http://gl.wikipedia.org/', |
| 81 | + 'rped-wikipedia-url' => 'http://gl.wikipedia.org/wiki/$1', |
82 | 82 | ); |
83 | 83 | |
84 | 84 | /** Swiss German (Alemannisch) |
— | — | @@ -86,7 +86,7 @@ |
87 | 87 | $messages['gsw'] = array( |
88 | 88 | 'rped' => 'Erkännig vu främde Netzsyte', |
89 | 89 | 'rped-desc' => 'Leitet Wikilinks uf d Wikipedia, wänn die Syte nit im lokale Wiki git, derfir aber in dr Wikipedia', |
90 | | - 'rped-wikipedia-url' => 'http://gsw.wikipedia.org/', |
| 90 | + 'rped-wikipedia-url' => 'http://gsw.wikipedia.org/wiki/$1', |
91 | 91 | ); |
92 | 92 | |
93 | 93 | /** Upper Sorbian (Hornjoserbsce) |
— | — | @@ -95,7 +95,7 @@ |
96 | 96 | $messages['hsb'] = array( |
97 | 97 | 'rped' => 'Wotkryće eksistency zdaleneje strony', |
98 | 98 | 'rped-desc' => 'Wotkazuje wikiwotkazy do Wikipedije, jeli strona njeeksistuje w lokalnym wikiju, ale eksistuje we Wikipediji', |
99 | | - 'rped-wikipedia-url' => 'http://hsb.wikipedia.org/', |
| 99 | + 'rped-wikipedia-url' => 'http://hsb.wikipedia.org/wiki/$1', |
100 | 100 | ); |
101 | 101 | |
102 | 102 | /** Hungarian (Magyar) |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | $messages['hu'] = array( |
106 | 106 | 'rped' => 'Ellenőrzi, hogy egy távoli lap létezik-e', |
107 | 107 | 'rped-desc' => 'A wikilinkeket a Wikipédiára irányítja, ha a lap nem létezik a helyi wikiben, de a Wikipédián igen', |
108 | | - 'rped-wikipedia-url' => 'http://hu.wikipedia.org/', |
| 108 | + 'rped-wikipedia-url' => 'http://hu.wikipedia.org/wiki/$1', |
109 | 109 | ); |
110 | 110 | |
111 | 111 | /** Interlingua (Interlingua) |
— | — | @@ -113,7 +113,7 @@ |
114 | 114 | $messages['ia'] = array( |
115 | 115 | 'rped' => 'Detection del existentia de paginas remote', |
116 | 116 | 'rped-desc' => 'Face wiki-ligamines a Wikipedia si le pagina non existe in le wiki local ma existe in Wikipedia', |
117 | | - 'rped-wikipedia-url' => 'http://ia.wikipedia.org/', |
| 117 | + 'rped-wikipedia-url' => 'http://ia.wikipedia.org/wiki/$1', |
118 | 118 | ); |
119 | 119 | |
120 | 120 | /** Indonesian (Bahasa Indonesia) |
— | — | @@ -137,7 +137,7 @@ |
138 | 138 | * @author Universal Life |
139 | 139 | */ |
140 | 140 | $messages['lad'] = array( |
141 | | - 'rped-wikipedia-url' => 'http://lad.wikipedia.org/', |
| 141 | + 'rped-wikipedia-url' => 'http://lad.wikipedia.org/wiki/$1', |
142 | 142 | ); |
143 | 143 | |
144 | 144 | /** Luxembourgish (Lëtzebuergesch) |
— | — | @@ -154,7 +154,7 @@ |
155 | 155 | $messages['mk'] = array( |
156 | 156 | 'rped' => 'Пронаоѓач на постоечка надворешна страница', |
157 | 157 | 'rped-desc' => 'Поврзува викиврски со Википедија ако страницата не постои на локалното вики, но постои на Википедија', |
158 | | - 'rped-wikipedia-url' => 'http://mk.wikipedia.org/', |
| 158 | + 'rped-wikipedia-url' => 'http://mk.wikipedia.org/wiki/$1', |
159 | 159 | ); |
160 | 160 | |
161 | 161 | /** Dutch (Nederlands) |
— | — | @@ -163,7 +163,7 @@ |
164 | 164 | $messages['nl'] = array( |
165 | 165 | 'rped' => "Detectie van pagina's in andere wiki's", |
166 | 166 | 'rped-desc' => 'Verwijst naar Wikipedia als de pagina niet bestaat in de lokale wiki maar wel in Wikipedia', |
167 | | - 'rped-wikipedia-url' => 'http://nl.wikipedia.org/', |
| 167 | + 'rped-wikipedia-url' => 'http://nl.wikipedia.org/wiki/$1', |
168 | 168 | ); |
169 | 169 | |
170 | 170 | /** Norwegian (bokmål) (Norsk (bokmål)) |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | $messages['no'] = array( |
174 | 174 | 'rped' => 'Eksistensdeteksjon av eksterne sider', |
175 | 175 | 'rped-desc' => 'Lenker wikilenker til Wikipedia om siden ikke finnes på den lokale wikien men finnes på Wikipedia', |
176 | | - 'rped-wikipedia-url' => 'http://no.wikipedia.org/', |
| 176 | + 'rped-wikipedia-url' => 'http://no.wikipedia.org/wiki/$1', |
177 | 177 | ); |
178 | 178 | |
179 | 179 | /** Occitan (Occitan) |
— | — | @@ -189,7 +189,7 @@ |
190 | 190 | $messages['pms'] = array( |
191 | 191 | 'rped' => "Determinassion d'esistensa dle pàgine a distansa", |
192 | 192 | 'rped-desc' => "A colega j'anliure wiki a Wikipedia se la pàgina a esist pa an sla wiki local ma a esist dzora a Wikipedia", |
193 | | - 'rped-wikipedia-url' => 'http://pms.wikipedia.org/', |
| 193 | + 'rped-wikipedia-url' => 'http://pms.wikipedia.org/wiki/$1', |
194 | 194 | ); |
195 | 195 | |
196 | 196 | /** Portuguese (Português) |
— | — | @@ -198,7 +198,7 @@ |
199 | 199 | $messages['pt'] = array( |
200 | 200 | 'rped' => 'Detecção da existência de páginas remotas', |
201 | 201 | 'rped-desc' => 'Liga um link à Wikipédia, se a página de destino não existe na wiki local mas existe na Wikipédia', |
202 | | - 'rped-wikipedia-url' => 'http://pt.wikipedia.org/', |
| 202 | + 'rped-wikipedia-url' => 'http://pt.wikipedia.org/wiki/$1', |
203 | 203 | ); |
204 | 204 | |
205 | 205 | /** Russian (Русский) |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | $messages['ru'] = array( |
209 | 209 | 'rped' => 'Обнаружение существования внешней страницы', |
210 | 210 | 'rped-desc' => 'Ставит вики-ссылки на Википедию, если страницы не существует в локальной вики, но она присутствует в Википедии', |
211 | | - 'rped-wikipedia-url' => 'http://ru.wikipedia.org/', |
| 211 | + 'rped-wikipedia-url' => 'http://ru.wikipedia.org/wiki/$1', |
212 | 212 | ); |
213 | 213 | |
214 | 214 | /** Tagalog (Tagalog) |
Index: trunk/extensions/PureWikiDeletion/PureWikiDeletion.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | 'url' => 'http://www.mediawiki.org/wiki/Extension:PureWikiDeletion', |
34 | 34 | 'description' => 'Implements pure wiki deletion', |
35 | 35 | 'descriptionmsg' => 'purewikideletion-desc', |
36 | | - 'version' => '1.0.3', |
| 36 | + 'version' => '1.0.4', |
37 | 37 | ); |
38 | 38 | |
39 | 39 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -62,6 +62,9 @@ |
63 | 63 | |
64 | 64 | $wgDefaultUserOptions['watchblank'] = 0; |
65 | 65 | $wgDefaultUserOptions['watchunblank'] = 0; |
| 66 | +$wgPureWikiDeletionLoginRequiredToBlank = false; |
| 67 | +$wgPureWikiDeletionLoginRequiredToUnblank = false; |
| 68 | +$wgPureWikiDeletionBlankLinkStyle="color: red"; |
66 | 69 | |
67 | 70 | $wgLogTypes[] = 'blank'; |
68 | 71 | $wgLogNames['blank'] = 'blank-log-name'; |
— | — | @@ -94,6 +97,10 @@ |
95 | 98 | return $rv; |
96 | 99 | } |
97 | 100 | |
| 101 | +/** |
| 102 | +* Do not allow an anonymous user to blank or unblank a page unless this wiki |
| 103 | +* allows it |
| 104 | +*/ |
98 | 105 | function PureWikiDeletionSaveHook( &$article, &$user, &$text, &$summary, |
99 | 106 | $minor, $watch, $sectionanchor, &$flags ) { |
100 | 107 | global $wgOut, $wgPureWikiDeletionLoginRequiredToBlank, $wgPureWikiDeletionLoginRequiredToUnblank; |
— | — | @@ -124,6 +131,9 @@ |
125 | 132 | return true; |
126 | 133 | } |
127 | 134 | |
| 135 | +/** |
| 136 | +* Checkboxes in preferences for watching pages a user blanks or unblanks |
| 137 | +*/ |
128 | 138 | function PureWikiDeletionGetPreferences( $user, &$preferences ) { |
129 | 139 | $prefs = array( |
130 | 140 | 'watchblank' => array( |
— | — | @@ -142,6 +152,10 @@ |
143 | 153 | return true; |
144 | 154 | } |
145 | 155 | |
| 156 | +/** |
| 157 | +* Stop an anonymous user from even wasting his time trying to unblank a page if |
| 158 | +* this wiki does not allow him to do so |
| 159 | +*/ |
146 | 160 | function PureWikiDeletionAlternateEditHook ( $editPage ) { |
147 | 161 | global $wgUser, $wgOut, $wgPureWikiDeletionLoginRequiredToUnblank; |
148 | 162 | if ( $wgUser->isLoggedIn() || !$wgPureWikiDeletionLoginRequiredToUnblank ) { |
Index: trunk/extensions/PureWikiDeletion/SpecialPureWikiDeletion.php |
— | — | @@ -1,7 +1,8 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
5 | | - * Special page to direct the user to a random page |
| 5 | + * Special page to direct the user to a random page that is not in the blank_page |
| 6 | + * table |
6 | 7 | * |
7 | 8 | * @ingroup SpecialPage |
8 | 9 | * @author Rob Church <robchur@gmail.com>, Ilmari Karonen |
— | — | @@ -115,453 +116,10 @@ |
116 | 117 | } |
117 | 118 | } |
118 | 119 | |
119 | | - |
120 | 120 | /** |
121 | | - * Implements Special:Allpages |
122 | | - * @ingroup SpecialPage |
123 | | - */ |
124 | | -class AllPagesExcludeBlank extends IncludableSpecialPage { |
125 | | - |
126 | | - /** |
127 | | - * Maximum number of pages to show on single subpage. |
128 | | - */ |
129 | | - protected $maxPerPage = 345; |
130 | | - |
131 | | - /** |
132 | | - * Maximum number of pages to show on single index subpage. |
133 | | - */ |
134 | | - protected $maxLineCount = 200; |
135 | | - |
136 | | - /** |
137 | | - * Maximum number of chars to show for an entry. |
138 | | - */ |
139 | | - protected $maxPageLength = 70; |
140 | | - |
141 | | - /** |
142 | | - * Determines, which message describes the input field 'nsfrom'. |
143 | | - */ |
144 | | - protected $nsfromMsg = 'allpagesfrom'; |
145 | | - |
146 | | - function __construct( $name = 'Allpages' ){ |
147 | | - parent::__construct( $name ); |
148 | | - } |
149 | | - |
150 | | - /** |
151 | | - * Entry point : initialise variables and call subfunctions. |
152 | | - * @param $par String: becomes "FOO" when called like Special:Allpages/FOO (default NULL) |
153 | | - * @param $specialPage See the SpecialPage object. |
154 | | - */ |
155 | | - function execute( $par ) { |
156 | | - global $wgRequest, $wgOut, $wgContLang; |
157 | | - |
158 | | - $this->setHeaders(); |
159 | | - $this->outputHeader(); |
160 | | - |
161 | | - # GET values |
162 | | - $from = $wgRequest->getVal( 'from', null ); |
163 | | - $to = $wgRequest->getVal( 'to', null ); |
164 | | - $namespace = $wgRequest->getInt( 'namespace' ); |
165 | | - |
166 | | - $namespaces = $wgContLang->getNamespaces(); |
167 | | - |
168 | | - $wgOut->setPagetitle( ( $namespace > 0 && in_array( $namespace, array_keys( $namespaces) ) ) ? |
169 | | - wfMsg( 'allinnamespace', str_replace( '_', ' ', $namespaces[$namespace] ) ) : |
170 | | - wfMsg( 'allarticles' ) |
171 | | - ); |
172 | | - |
173 | | - if( isset($par) ) { |
174 | | - $this->showChunk( $namespace, $par, $to ); |
175 | | - } elseif( isset($from) && !isset($to) ) { |
176 | | - $this->showChunk( $namespace, $from, $to ); |
177 | | - } else { |
178 | | - $this->showToplevel( $namespace, $from, $to ); |
179 | | - } |
180 | | - } |
181 | | - |
182 | | - /** |
183 | | - * HTML for the top form |
184 | | - * @param integer $namespace A namespace constant (default NS_MAIN). |
185 | | - * @param string $from dbKey we are starting listing at. |
186 | | - * @param string $to dbKey we are ending listing at. |
187 | | - */ |
188 | | - function namespaceForm( $namespace = NS_MAIN, $from = '', $to = '' ) { |
189 | | - global $wgScript; |
190 | | - $t = $this->getTitle(); |
191 | | - |
192 | | - $out = Xml::openElement( 'div', array( 'class' => 'namespaceoptions' ) ); |
193 | | - $out .= Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ); |
194 | | - $out .= Xml::hidden( 'title', $t->getPrefixedText() ); |
195 | | - $out .= Xml::openElement( 'fieldset' ); |
196 | | - $out .= Xml::element( 'legend', null, wfMsg( 'allpages' ) ); |
197 | | - $out .= Xml::openElement( 'table', array( 'id' => 'nsselect', 'class' => 'allpages' ) ); |
198 | | - $out .= "<tr> |
199 | | - <td class='mw-label'>" . |
200 | | - Xml::label( wfMsg( 'allpagesfrom' ), 'nsfrom' ) . |
201 | | - "</td> |
202 | | - <td class='mw-input'>" . |
203 | | - Xml::input( 'from', 30, str_replace('_',' ',$from), array( 'id' => 'nsfrom' ) ) . |
204 | | - "</td> |
205 | | - </tr> |
206 | | - <tr> |
207 | | - <td class='mw-label'>" . |
208 | | - Xml::label( wfMsg( 'allpagesto' ), 'nsto' ) . |
209 | | - "</td> |
210 | | - <td class='mw-input'>" . |
211 | | - Xml::input( 'to', 30, str_replace('_',' ',$to), array( 'id' => 'nsto' ) ) . |
212 | | - "</td> |
213 | | - </tr> |
214 | | - <tr> |
215 | | - <td class='mw-label'>" . |
216 | | - Xml::label( wfMsg( 'namespace' ), 'namespace' ) . |
217 | | - "</td> |
218 | | - <td class='mw-input'>" . |
219 | | - Xml::namespaceSelector( $namespace, null ) . ' ' . |
220 | | - Xml::submitButton( wfMsg( 'allpagessubmit' ) ) . |
221 | | - "</td> |
222 | | - </tr>"; |
223 | | - $out .= Xml::closeElement( 'table' ); |
224 | | - $out .= Xml::closeElement( 'fieldset' ); |
225 | | - $out .= Xml::closeElement( 'form' ); |
226 | | - $out .= Xml::closeElement( 'div' ); |
227 | | - return $out; |
228 | | - } |
229 | | - |
230 | | - /** |
231 | | - * @param integer $namespace (default NS_MAIN) |
232 | | - */ |
233 | | - function showToplevel( $namespace = NS_MAIN, $from = '', $to = '' ) { |
234 | | - global $wgOut, $wgContLang; |
235 | | - $align = $wgContLang->isRtl() ? 'left' : 'right'; |
236 | | - |
237 | | - # TODO: Either make this *much* faster or cache the title index points |
238 | | - # in the querycache table. |
239 | | - |
240 | | - $dbr = wfGetDB( DB_SLAVE ); |
241 | | - $out = ""; |
242 | | - $where = array( 'page_namespace' => $namespace ); |
243 | | - |
244 | | - $from = Title::makeTitleSafe( $namespace, $from ); |
245 | | - $to = Title::makeTitleSafe( $namespace, $to ); |
246 | | - $from = ( $from && $from->isLocal() ) ? $from->getDBKey() : null; |
247 | | - $to = ( $to && $to->isLocal() ) ? $to->getDBKey() : null; |
248 | | - |
249 | | - if( isset($from) ) |
250 | | - $where[] = 'page_title >= '.$dbr->addQuotes( $from ); |
251 | | - if( isset($to) ) |
252 | | - $where[] = 'page_title <= '.$dbr->addQuotes( $to ); |
253 | | - |
254 | | - global $wgMemc; |
255 | | - $key = wfMemcKey( 'allpages', 'ns', $namespace, $from, $to ); |
256 | | - $lines = $wgMemc->get( $key ); |
257 | | - |
258 | | - $count = $dbr->estimateRowCount( 'page', '*', $where, __METHOD__ ); |
259 | | - $maxPerSubpage = intval($count/$this->maxLineCount); |
260 | | - $maxPerSubpage = max($maxPerSubpage,$this->maxPerPage); |
261 | | - |
262 | | - if( !is_array( $lines ) ) { |
263 | | - $options = array( 'LIMIT' => 1 ); |
264 | | - $options['ORDER BY'] = 'page_title ASC'; |
265 | | - $firstTitle = $dbr->selectField( 'page', 'page_title', $where, __METHOD__, $options ); |
266 | | - $lastTitle = $firstTitle; |
267 | | - # This array is going to hold the page_titles in order. |
268 | | - $lines = array( $firstTitle ); |
269 | | - # If we are going to show n rows, we need n+1 queries to find the relevant titles. |
270 | | - $done = false; |
271 | | - while( !$done ) { |
272 | | - // Fetch the last title of this chunk and the first of the next |
273 | | - $chunk = ( $lastTitle === false ) |
274 | | - ? array() |
275 | | - : array( 'page_title >= ' . $dbr->addQuotes( $lastTitle ) ); |
276 | | - $res = $dbr->select( 'page', /* FROM */ |
277 | | - 'page_title', /* WHAT */ |
278 | | - array_merge($where,$chunk), |
279 | | - __METHOD__, |
280 | | - array ('LIMIT' => 2, 'OFFSET' => $maxPerSubpage - 1, 'ORDER BY' => 'page_title ASC') |
281 | | - ); |
282 | | - |
283 | | - if( $s = $dbr->fetchObject( $res ) ) { |
284 | | - array_push( $lines, $s->page_title ); |
285 | | - } else { |
286 | | - // Final chunk, but ended prematurely. Go back and find the end. |
287 | | - $endTitle = $dbr->selectField( 'page', 'MAX(page_title)', |
288 | | - array_merge($where,$chunk), |
289 | | - __METHOD__ ); |
290 | | - array_push( $lines, $endTitle ); |
291 | | - $done = true; |
292 | | - } |
293 | | - if( $s = $res->fetchObject() ) { |
294 | | - array_push( $lines, $s->page_title ); |
295 | | - $lastTitle = $s->page_title; |
296 | | - } else { |
297 | | - // This was a final chunk and ended exactly at the limit. |
298 | | - // Rare but convenient! |
299 | | - $done = true; |
300 | | - } |
301 | | - $res->free(); |
302 | | - } |
303 | | - $wgMemc->add( $key, $lines, 3600 ); |
304 | | - } |
305 | | - |
306 | | - // If there are only two or less sections, don't even display them. |
307 | | - // Instead, display the first section directly. |
308 | | - if( count( $lines ) <= 2 ) { |
309 | | - if( !empty($lines) ) { |
310 | | - $this->showChunk( $namespace, $lines[0], $lines[count($lines)-1] ); |
311 | | - } else { |
312 | | - $wgOut->addHTML( $this->namespaceForm( $namespace, $from, $to ) ); |
313 | | - } |
314 | | - return; |
315 | | - } |
316 | | - |
317 | | - # At this point, $lines should contain an even number of elements. |
318 | | - $out .= "<table class='allpageslist' style='background: inherit;'>"; |
319 | | - while( count ( $lines ) > 0 ) { |
320 | | - $inpoint = array_shift( $lines ); |
321 | | - $outpoint = array_shift( $lines ); |
322 | | - $out .= $this->showline( $inpoint, $outpoint, $namespace ); |
323 | | - } |
324 | | - $out .= '</table>'; |
325 | | - $nsForm = $this->namespaceForm( $namespace, $from, $to ); |
326 | | - |
327 | | - # Is there more? |
328 | | - if( $this->including() ) { |
329 | | - $out2 = ''; |
330 | | - } else { |
331 | | - if( isset($from) || isset($to) ) { |
332 | | - global $wgUser; |
333 | | - $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">'; |
334 | | - $out2 .= '<tr valign="top"><td>' . $nsForm; |
335 | | - $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' . |
336 | | - $wgUser->getSkin()->makeKnownLinkObj( $this->getTitle(), wfMsgHtml ( 'allpages' ) ); |
337 | | - $out2 .= "</td></tr></table>"; |
338 | | - } else { |
339 | | - $out2 = $nsForm; |
340 | | - } |
341 | | - } |
342 | | - $wgOut->addHTML( $out2 . $out ); |
343 | | - } |
344 | | - |
345 | | - /** |
346 | | - * Show a line of "ABC to DEF" ranges of articles |
347 | | - * @param string $inpoint Lower limit of pagenames |
348 | | - * @param string $outpout Upper limit of pagenames |
349 | | - * @param integer $namespace (Default NS_MAIN) |
350 | | - */ |
351 | | - function showline( $inpoint, $outpoint, $namespace = NS_MAIN ) { |
352 | | - global $wgContLang; |
353 | | - $align = $wgContLang->isRtl() ? 'left' : 'right'; |
354 | | - $inpointf = htmlspecialchars( str_replace( '_', ' ', $inpoint ) ); |
355 | | - $outpointf = htmlspecialchars( str_replace( '_', ' ', $outpoint ) ); |
356 | | - // Don't let the length runaway |
357 | | - $inpointf = $wgContLang->truncate( $inpointf, $this->maxPageLength ); |
358 | | - $outpointf = $wgContLang->truncate( $outpointf, $this->maxPageLength ); |
359 | | - |
360 | | - $queryparams = $namespace ? "namespace=$namespace&" : ''; |
361 | | - $special = $this->getTitle(); |
362 | | - $link = $special->escapeLocalUrl( $queryparams . 'from=' . urlencode($inpoint) . '&to=' . urlencode($outpoint) ); |
363 | | - |
364 | | - $out = wfMsgHtml( 'alphaindexline', |
365 | | - "<a href=\"$link\">$inpointf</a></td><td>", |
366 | | - "</td><td><a href=\"$link\">$outpointf</a>" |
367 | | - ); |
368 | | - return '<tr><td align="' . $align . '">'.$out.'</td></tr>'; |
369 | | - } |
370 | | - |
371 | | - /** |
372 | | - * @param integer $namespace (Default NS_MAIN) |
373 | | - * @param string $from list all pages from this name (default FALSE) |
374 | | - * @param string $to list all pages to this name (default FALSE) |
375 | | - */ |
376 | | - function showChunk( $namespace = NS_MAIN, $from = false, $to = false ) { |
377 | | - global $wgOut, $wgUser, $wgContLang, $wgLang; |
378 | | - |
379 | | - $sk = $wgUser->getSkin(); |
380 | | - |
381 | | - $fromList = $this->getNamespaceKeyAndText($namespace, $from); |
382 | | - $toList = $this->getNamespaceKeyAndText( $namespace, $to ); |
383 | | - $namespaces = $wgContLang->getNamespaces(); |
384 | | - $align = $wgContLang->isRtl() ? 'left' : 'right'; |
385 | | - |
386 | | - $n = 0; |
387 | | - |
388 | | - if ( !$fromList || !$toList ) { |
389 | | - $out = wfMsgWikiHtml( 'allpagesbadtitle' ); |
390 | | - } elseif ( !in_array( $namespace, array_keys( $namespaces ) ) ) { |
391 | | - // Show errormessage and reset to NS_MAIN |
392 | | - $out = wfMsgExt( 'allpages-bad-ns', array( 'parseinline' ), $namespace ); |
393 | | - $namespace = NS_MAIN; |
394 | | - } else { |
395 | | - list( $namespace, $fromKey, $from ) = $fromList; |
396 | | - list( $namespace2, $toKey, $to ) = $toList; |
397 | | - |
398 | | - $dbr = wfGetDB( DB_SLAVE ); |
399 | | - $conds = array( |
400 | | - 'page_namespace' => $namespace, |
401 | | - 'page_title >= ' . $dbr->addQuotes( $fromKey ) |
402 | | - ); |
403 | | - if( $toKey !== "" ) { |
404 | | - $conds[] = 'page_title <= ' . $dbr->addQuotes( $toKey ); |
405 | | - } |
406 | | - |
407 | | - $res = $dbr->select( 'page', |
408 | | - array( 'page_namespace', 'page_title', 'page_is_redirect' ), |
409 | | - $conds, |
410 | | - __METHOD__, |
411 | | - array( |
412 | | - 'ORDER BY' => 'page_title', |
413 | | - 'LIMIT' => $this->maxPerPage + 1, |
414 | | - 'USE INDEX' => 'name_title', |
415 | | - ) |
416 | | - ); |
417 | | - |
418 | | - if( $res->numRows() > 0 ) { |
419 | | - $out = '<table style="background: inherit;" border="0" width="100%">'; |
420 | | - |
421 | | - while( ( $n < $this->maxPerPage ) && ( $s = $res->fetchObject() ) ) { |
422 | | - $t = Title::makeTitle( $s->page_namespace, $s->page_title ); |
423 | | - if( $t ) { |
424 | | - $link = ( $s->page_is_redirect ? '<div class="allpagesredirect">' : '' ) . |
425 | | - $sk->makeKnownLinkObj( $t, htmlspecialchars( $t->getText() ), false, false ) . |
426 | | - ($s->page_is_redirect ? '</div>' : '' ); |
427 | | - } else { |
428 | | - $link = '[[' . htmlspecialchars( $s->page_title ) . ']]'; |
429 | | - } |
430 | | - if( $n % 3 == 0 ) { |
431 | | - $out .= '<tr>'; |
432 | | - } |
433 | | - $out .= "<td width=\"33%\">$link</td>"; |
434 | | - $n++; |
435 | | - if( $n % 3 == 0 ) { |
436 | | - $out .= '</tr>'; |
437 | | - } |
438 | | - } |
439 | | - if( ($n % 3) != 0 ) { |
440 | | - $out .= '</tr>'; |
441 | | - } |
442 | | - $out .= '</table>'; |
443 | | - } else { |
444 | | - $out = ''; |
445 | | - } |
446 | | - } |
447 | | - |
448 | | - if ( $this->including() ) { |
449 | | - $out2 = ''; |
450 | | - } else { |
451 | | - if( $from == '' ) { |
452 | | - // First chunk; no previous link. |
453 | | - $prevTitle = null; |
454 | | - } else { |
455 | | - # Get the last title from previous chunk |
456 | | - $dbr = wfGetDB( DB_SLAVE ); |
457 | | - $res_prev = $dbr->select( |
458 | | - 'page', |
459 | | - 'page_title', |
460 | | - array( 'page_namespace' => $namespace, 'page_title < '.$dbr->addQuotes($from) ), |
461 | | - __METHOD__, |
462 | | - array( 'ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => ($this->maxPerPage - 1 ) ) |
463 | | - ); |
464 | | - |
465 | | - # Get first title of previous complete chunk |
466 | | - if( $dbr->numrows( $res_prev ) >= $this->maxPerPage ) { |
467 | | - $pt = $dbr->fetchObject( $res_prev ); |
468 | | - $prevTitle = Title::makeTitle( $namespace, $pt->page_title ); |
469 | | - } else { |
470 | | - # The previous chunk is not complete, need to link to the very first title |
471 | | - # available in the database |
472 | | - $options = array( 'LIMIT' => 1 ); |
473 | | - if ( ! $dbr->implicitOrderby() ) { |
474 | | - $options['ORDER BY'] = 'page_title'; |
475 | | - } |
476 | | - $reallyFirstPage_title = $dbr->selectField( 'page', 'page_title', |
477 | | - array( 'page_namespace' => $namespace ), __METHOD__, $options ); |
478 | | - # Show the previous link if it s not the current requested chunk |
479 | | - if( $from != $reallyFirstPage_title ) { |
480 | | - $prevTitle = Title::makeTitle( $namespace, $reallyFirstPage_title ); |
481 | | - } else { |
482 | | - $prevTitle = null; |
483 | | - } |
484 | | - } |
485 | | - } |
486 | | - |
487 | | - $self = $this->getTitle(); |
488 | | - |
489 | | - $nsForm = $this->namespaceForm( $namespace, $from, $to ); |
490 | | - $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">'; |
491 | | - $out2 .= '<tr valign="top"><td>' . $nsForm; |
492 | | - $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' . |
493 | | - $sk->makeKnownLinkObj( $self, |
494 | | - wfMsgHtml ( 'allpages' ) ); |
495 | | - |
496 | | - # Do we put a previous link ? |
497 | | - if( isset( $prevTitle ) && $pt = $prevTitle->getText() ) { |
498 | | - $q = 'from=' . $prevTitle->getPartialUrl() |
499 | | - . ( $namespace ? '&namespace=' . $namespace : '' ); |
500 | | - $prevLink = $sk->makeKnownLinkObj( $self, |
501 | | - wfMsgHTML( 'prevpage', htmlspecialchars( $pt ) ), $q ); |
502 | | - $out2 = $wgLang->pipeList( array( $out2, $prevLink ) ); |
503 | | - } |
504 | | - |
505 | | - if( $n == $this->maxPerPage && $s = $res->fetchObject() ) { |
506 | | - # $s is the first link of the next chunk |
507 | | - $t = Title::MakeTitle($namespace, $s->page_title); |
508 | | - $q = 'from=' . $t->getPartialUrl() |
509 | | - . ( $namespace ? '&namespace=' . $namespace : '' ); |
510 | | - $nextLink = $sk->makeKnownLinkObj( $self, |
511 | | - wfMsgHtml( 'nextpage', htmlspecialchars( $t->getText() ) ), $q ); |
512 | | - $out2 = $wgLang->pipeList( array( $out2, $nextLink ) ); |
513 | | - } |
514 | | - $out2 .= "</td></tr></table>"; |
515 | | - } |
516 | | - |
517 | | - $wgOut->addHTML( $out2 . $out ); |
518 | | - if( isset($prevLink) or isset($nextLink) ) { |
519 | | - $wgOut->addHTML( '<hr /><p style="font-size: smaller; float: ' . $align . '">' ); |
520 | | - if( isset( $prevLink ) ) { |
521 | | - $wgOut->addHTML( $prevLink ); |
522 | | - } |
523 | | - if( isset( $prevLink ) && isset( $nextLink ) ) { |
524 | | - $wgOut->addHTML( wfMsgExt( 'pipe-separator' |
525 | | - , 'escapenoentities' ) ); |
526 | | - } |
527 | | - if( isset( $nextLink ) ) { |
528 | | - $wgOut->addHTML( $nextLink ); |
529 | | - } |
530 | | - $wgOut->addHTML( '</p>' ); |
531 | | - |
532 | | - } |
533 | | - |
534 | | - } |
535 | | - |
536 | | - /** |
537 | | - * @param int $ns the namespace of the article |
538 | | - * @param string $text the name of the article |
539 | | - * @return array( int namespace, string dbkey, string pagename ) or NULL on error |
540 | | - * @static (sort of) |
541 | | - * @access private |
542 | | - */ |
543 | | - function getNamespaceKeyAndText($ns, $text) { |
544 | | - if ( $text == '' ) |
545 | | - return array( $ns, '', '' ); # shortcut for common case |
546 | | - |
547 | | - $t = Title::makeTitleSafe($ns, $text); |
548 | | - if ( $t && $t->isLocal() ) { |
549 | | - return array( $t->getNamespace(), $t->getDBkey(), |
550 | | - $t->getText() ); |
551 | | - } else if ( $t ) { |
552 | | - return NULL; |
553 | | - } |
554 | | - |
555 | | - # try again, in case the problem was an empty pagename |
556 | | - $text = preg_replace('/(#|$)/', 'X$1', $text); |
557 | | - $t = Title::makeTitleSafe($ns, $text); |
558 | | - if ( $t && $t->isLocal() ) { |
559 | | - return array( $t->getNamespace(), '', '' ); |
560 | | - } else { |
561 | | - return NULL; |
562 | | - } |
563 | | - } |
564 | | -} |
565 | | - |
| 121 | +* Fill the blank_page table with title of all the currently blank pages; ignore |
| 122 | +* the File namespace. Purge caches as needed |
| 123 | +*/ |
566 | 124 | class PopulateBlankedPagesTable extends SpecialPage { |
567 | 125 | function __construct() { |
568 | 126 | parent::__construct( 'PopulateBlankedPagesTable','purewikideletion' ); |
Index: trunk/extensions/PureWikiDeletion/PureWikiDeletion.hooks.php |
— | — | @@ -9,6 +9,9 @@ |
10 | 10 | |
11 | 11 | class PureWikiDeletionHooks { |
12 | 12 | |
| 13 | + /** |
| 14 | + * When a user visits the URL of a blanked page, redirect to the edit page |
| 15 | + */ |
13 | 16 | public static function PureWikiDeletionOutputPageParserOutputHook( &$out, $parseroutput ) { |
14 | 17 | $dbr = wfGetDB( DB_SLAVE ); |
15 | 18 | $target = $out->getTitle(); |
— | — | @@ -33,6 +36,11 @@ |
34 | 37 | return true; |
35 | 38 | } |
36 | 39 | |
| 40 | + /** |
| 41 | + * After a page is saved, add or remove it from the blank_page table if |
| 42 | + * it has been blanked or unblanked, respectively; if blanked, redirect |
| 43 | + * the user to the "Action complete" page |
| 44 | + */ |
37 | 45 | public static function PureWikiDeletionSaveCompleteHook( &$article, &$user, $text, $summary, |
38 | 46 | $minoredit, &$watchthis, $sectionanchor, &$flags, $revision, &$status, $baseRevId, |
39 | 47 | &$redirect ) { |
— | — | @@ -107,7 +115,9 @@ |
108 | 116 | return true; |
109 | 117 | } |
110 | 118 | |
111 | | - |
| 119 | + /** |
| 120 | + * Change the link style if the target page is in the blank_table |
| 121 | + */ |
112 | 122 | public static function PureWikiDeletionLink( $skin, $target, &$text, &$customAttribs, &$query, &$options |
113 | 123 | , &$ret ) { |
114 | 124 | global $wgPureWikiDeletionBlankLinkStyle; |
— | — | @@ -136,6 +146,9 @@ |
137 | 147 | return true; |
138 | 148 | } |
139 | 149 | |
| 150 | + /** |
| 151 | + * Provide historical information about a blank page that the user is editing |
| 152 | + */ |
140 | 153 | public static function PureWikiDeletionEditHook( &$editPage ) { |
141 | 154 | global $wgLang, $wgUser; |
142 | 155 | wfLoadExtensionMessages( 'PureWikiDeletion' ); |
— | — | @@ -179,6 +192,9 @@ |
180 | 193 | return true; |
181 | 194 | } |
182 | 195 | |
| 196 | + /** |
| 197 | + * Remove blanked pages from the blank_page table when they are deleted |
| 198 | + */ |
183 | 199 | public static function PureWikiDeletionDeleteHook( &$article, &$user, $reason, $id ) |
184 | 200 | { |
185 | 201 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -192,7 +208,10 @@ |
193 | 209 | } |
194 | 210 | return true; |
195 | 211 | } |
196 | | - |
| 212 | + |
| 213 | + /** |
| 214 | + * Add blanked pages back to the blank_page table when they are undeleted |
| 215 | + */ |
197 | 216 | public static function PureWikiDeletionUndeleteHook( $title, $create ) { |
198 | 217 | $dbr = wfGetDB( DB_SLAVE ); |
199 | 218 | $myRevision = Revision::loadFromTitle( $dbr, $title ); |