Index: trunk/extensions/LiquidThreads/LiquidThreads.php |
— | — | @@ -101,7 +101,7 @@ |
102 | 102 | $wgAutoloadClasses['LqtParserFunctions'] = $dir . 'classes/ParserFunctions.php'; |
103 | 103 | $wgAutoloadClasses['LqtDeletionController'] = $dir . 'classes/DeletionController.php'; |
104 | 104 | $wgAutoloadClasses['LqtHooks'] = $dir . 'classes/Hooks.php'; |
105 | | -$wgAutoloadClasses['ThreadRevision'] = $dir."/classes/ThreadRevision.php"; |
| 105 | +$wgAutoloadClasses['ThreadRevision'] = $dir . "/classes/ThreadRevision.php"; |
106 | 106 | |
107 | 107 | // View classes |
108 | 108 | $wgAutoloadClasses['TalkpageView'] = $dir . 'pages/TalkpageView.php'; |
Index: trunk/extensions/LiquidThreads/classes/Dispatch.php |
— | — | @@ -13,41 +13,42 @@ |
14 | 14 | 'ThreadProtectionFormView' => 'ThreadProtectionFormView', |
15 | 15 | 'ThreadWatchView' => 'ThreadWatchView', |
16 | 16 | 'SummaryPageView' => 'SummaryPageView' |
17 | | - ); |
18 | | - |
| 17 | + ); |
| 18 | + |
19 | 19 | /** static cache of per-page LiquidThreads activation setting */ |
20 | 20 | static $userLQTActivated; |
21 | 21 | |
22 | 22 | static function talkpageMain( &$output, &$article, &$title, &$user, &$request ) { |
23 | 23 | // We are given a talkpage article and title. Fire up a TalkpageView |
24 | | - |
| 24 | + |
25 | 25 | if ( $title->getNamespace() == NS_LQT_THREAD + 1 /* talk page */ ) { |
26 | 26 | // Threads don't have talk pages; redirect to the thread page. |
27 | 27 | $output->redirect( $title->getSubjectPage()->getFullUrl() ); |
28 | 28 | return false; |
29 | 29 | } |
30 | | - |
| 30 | + |
31 | 31 | // If we came here from a red-link, redirect to the thread page. |
32 | 32 | $redlink = $request->getCheck( 'redlink' ) && |
33 | 33 | $request->getText( 'action' ) == 'edit'; |
34 | | - if( $redlink ) { |
| 34 | + if ( $redlink ) { |
35 | 35 | $output->redirect( $title->getFullURL() ); |
36 | 36 | return false; |
37 | 37 | } |
38 | 38 | |
39 | 39 | /* Certain actions apply to the "header", which is stored in the actual talkpage |
40 | | - in the database. Drop everything and behave like a normal page if those |
41 | | - actions come up, to avoid hacking the various history, editing, etc. code. */ |
| 40 | + * in the database. Drop everything and behave like a normal page if those |
| 41 | + * actions come up, to avoid hacking the various history, editing, etc. code. |
| 42 | + */ |
42 | 43 | $action = $request->getVal( 'action' ); |
43 | 44 | $header_actions = array( 'history', 'edit', 'submit', 'delete' ); |
44 | 45 | global $wgRequest; |
45 | | - if ($action == 'edit' && $request->getVal('section') == 'new') { |
| 46 | + if ( $action == 'edit' && $request->getVal( 'section' ) == 'new' ) { |
46 | 47 | // Hijack section=new for "new thread". |
47 | 48 | $request->setVal( 'lqt_method', 'talkpage_new_thread' ); |
48 | 49 | $request->setVal( 'section', '' ); |
49 | | - |
| 50 | + |
50 | 51 | $viewname = self::$views['TalkpageView']; |
51 | | - |
| 52 | + |
52 | 53 | } elseif ( $request->getVal( 'lqt_method', null ) === null && |
53 | 54 | ( in_array( $action, $header_actions ) || |
54 | 55 | $request->getVal( 'diff', null ) !== null ) ) { |
— | — | @@ -64,7 +65,6 @@ |
65 | 66 | } |
66 | 67 | |
67 | 68 | static function threadPermalinkMain( &$output, &$article, &$title, &$user, &$request ) { |
68 | | - |
69 | 69 | $action = $request->getVal( 'action' ); |
70 | 70 | $lqt_method = $request->getVal( 'lqt_method' ); |
71 | 71 | |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | } else { |
90 | 90 | $viewname = self::$views['ThreadPermalinkView']; |
91 | 91 | } |
92 | | - |
| 92 | + |
93 | 93 | $view = new $viewname( $output, $article, $title, $user, $request ); |
94 | 94 | return $view->show(); |
95 | 95 | } |
— | — | @@ -98,29 +98,28 @@ |
99 | 99 | $view = new $viewname( $output, $article, $title, $user, $request ); |
100 | 100 | return $view->show(); |
101 | 101 | } |
102 | | - |
| 102 | + |
103 | 103 | static function isLqtPage( $title ) { |
104 | 104 | global $wgLqtPages, $wgLqtTalkPages; |
105 | | - $isTalkPage = ($title->isTalkPage() && $wgLqtTalkPages) || |
| 105 | + $isTalkPage = ( $title->isTalkPage() && $wgLqtTalkPages ) || |
106 | 106 | in_array( $title->getPrefixedText(), $wgLqtPages ) || |
107 | 107 | self::hasUserEnabledLQT( $title->getArticleId() ); |
108 | | - |
| 108 | + |
109 | 109 | return $isTalkPage; |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | static function hasUserEnabledLQT( $article ) { |
113 | | - |
114 | | - if (is_object($article)) { |
| 113 | + if ( is_object( $article ) ) { |
115 | 114 | $article = $article->getId(); |
116 | 115 | } |
117 | | - |
| 116 | + |
118 | 117 | // Instance cache |
119 | 118 | if ( isset( self::$userLQTActivated[$article] ) ) { |
120 | 119 | $cacheVal = self::$userLQTActivated[$article]; |
121 | 120 | |
122 | 121 | return $cacheVal; |
123 | 122 | } |
124 | | - |
| 123 | + |
125 | 124 | // Memcached: It isn't clear that this is needed yet, but since I already wrote the |
126 | 125 | // code, I might as well leave it commented out instead of deleting it. |
127 | 126 | // Main reason I've left this commented out is because it isn't obvious how to |
— | — | @@ -135,15 +134,21 @@ |
136 | 135 | // return $wgLqtThreadArchiveStartDays; |
137 | 136 | // } |
138 | 137 | // } |
139 | | - |
| 138 | + |
140 | 139 | // Load from the database. |
141 | 140 | $dbr = wfGetDB( DB_SLAVE ); |
142 | | - |
143 | | - $dbVal = $dbr->selectField( 'page_props', 'pp_value', |
144 | | - array( 'pp_propname' => 'use-liquid-threads', |
145 | | - 'pp_page' => $article ), __METHOD__ ); |
146 | | - |
147 | | - if ($dbVal) { |
| 141 | + |
| 142 | + $dbVal = $dbr->selectField( |
| 143 | + 'page_props', |
| 144 | + 'pp_value', |
| 145 | + array( |
| 146 | + 'pp_propname' => 'use-liquid-threads', |
| 147 | + 'pp_page' => $article |
| 148 | + ), |
| 149 | + __METHOD__ |
| 150 | + ); |
| 151 | + |
| 152 | + if ( $dbVal ) { |
148 | 153 | self::$userLQTActivated[$article] = true; |
149 | 154 | # $wgMemc->set( $key, $dbVal, 1800 ); |
150 | 155 | return true; |
Index: trunk/extensions/LiquidThreads/classes/Hooks.php |
— | — | @@ -5,10 +5,12 @@ |
6 | 6 | // Shortcut for non-LQT pages. |
7 | 7 | if ( !LqtDispatch::isLqtPage( $ot ) ) |
8 | 8 | return true; |
9 | | - |
| 9 | + |
10 | 10 | // Move the threads on that page to the new page. |
11 | | - $threads = Threads::where( array( Threads::articleClause( new Article( $ot ) ), |
12 | | - Threads::topLevelClause() ) ); |
| 11 | + $threads = Threads::where( array( |
| 12 | + Threads::articleClause( new Article( $ot ) ), |
| 13 | + Threads::topLevelClause() ) |
| 14 | + ); |
13 | 15 | |
14 | 16 | foreach ( $threads as $t ) { |
15 | 17 | $t->moveToPage( $nt, false ); |
— | — | @@ -20,7 +22,7 @@ |
21 | 23 | static function customizeOldChangesList( &$changeslist, &$s, $rc ) { |
22 | 24 | if ( $rc->getTitle()->getNamespace() != NS_LQT_THREAD ) |
23 | 25 | return true; |
24 | | - |
| 26 | + |
25 | 27 | $thread = Threads::withRoot( new Article( $rc->getTitle() ) ); |
26 | 28 | if ( !$thread ) return true; |
27 | 29 | |
— | — | @@ -29,7 +31,7 @@ |
30 | 32 | |
31 | 33 | if ( $rc->mAttribs['rc_new'] ) { |
32 | 34 | global $wgOut; |
33 | | - |
| 35 | + |
34 | 36 | $sig = ""; |
35 | 37 | $changeslist->insertUserRelatedLinks( $sig, $rc ); |
36 | 38 | |
— | — | @@ -43,7 +45,7 @@ |
44 | 46 | $link = $sk->link( $thread->title(), wfMsg( 'lqt_rc_ellipsis' ), |
45 | 47 | array( 'class' => 'lqt_rc_ellipsis' ), array(), array( 'known' ) ); |
46 | 48 | } |
47 | | - |
| 49 | + |
48 | 50 | $quote = $wgOut->parseInline( $quote ) . $link; |
49 | 51 | |
50 | 52 | if ( $thread->isTopmostThread() ) { |
— | — | @@ -51,10 +53,10 @@ |
52 | 54 | } else { |
53 | 55 | $message_name = 'lqt_rc_new_reply'; |
54 | 56 | } |
55 | | - |
| 57 | + |
56 | 58 | $tmp_title = $thread->article()->getTitle(); |
57 | 59 | $tmp_title->setFragment( '#' . LqtView::anchorName( $thread ) ); |
58 | | - |
| 60 | + |
59 | 61 | // Make sure it points to the right page. The Pager seems to use the DB |
60 | 62 | // representation of a timestamp for its offset field, odd. |
61 | 63 | $dbr = wfGetDB( DB_SLAVE ); |
— | — | @@ -62,7 +64,7 @@ |
63 | 65 | $offset = $dbr->timestamp( $offset ); |
64 | 66 | |
65 | 67 | $thread_link = $changeslist->skin->link( $tmp_title, |
66 | | - htmlspecialchars($thread->subjectWithoutIncrement()), |
| 68 | + htmlspecialchars( $thread->subjectWithoutIncrement() ), |
67 | 69 | array(), array( 'offset' => $offset ), array( 'known' ) ); |
68 | 70 | |
69 | 71 | $talkpage_link = $changeslist->skin->link( |
— | — | @@ -72,19 +74,19 @@ |
73 | 75 | |
74 | 76 | $s = wfMsg( $message_name, $thread_link, $talkpage_link, $sig ) |
75 | 77 | . Xml::tags( 'blockquote', array( 'class' => 'lqt_rc_blockquote' ), $quote ); |
76 | | - |
| 78 | + |
77 | 79 | $classes = array(); |
78 | 80 | $changeslist->insertTags( $s, $rc, $classes ); |
79 | 81 | $changeslist->insertExtra( $s, $rc, $classes ); |
80 | 82 | } else { |
81 | 83 | // Add whether it was original author. |
82 | 84 | if ( $thread->author()->getName() != $rc->mAttribs['rc_user_text'] ) { |
83 | | - $appendix = Xml::tags( 'span', |
84 | | - array( 'class' => 'lqt_rc_author_notice ' . |
85 | | - 'lqt_rc_author_notice_others' ), |
86 | | - wfMsgExt( 'lqt_rc_author_others', 'parseinline' ) |
87 | | - ); |
88 | | - |
| 85 | + $appendix = Xml::tags( |
| 86 | + 'span', |
| 87 | + array( 'class' => 'lqt_rc_author_notice ' . 'lqt_rc_author_notice_others' ), |
| 88 | + wfMsgExt( 'lqt_rc_author_others', 'parseinline' ) |
| 89 | + ); |
| 90 | + |
89 | 91 | $s .= ' ' . $appendix; |
90 | 92 | } |
91 | 93 | } |
— | — | @@ -102,8 +104,10 @@ |
103 | 105 | && ! $watchlist_t->equals( $wgTitle ) |
104 | 106 | && ! $usertalk_t->equals( $wgTitle ) |
105 | 107 | ) { |
106 | | - $s = wfMsgExt( 'lqt_youhavenewmessages', array( 'parseinline' ), |
107 | | - $newmsg_t->getFullURL() ); |
| 108 | + $s = wfMsgExt( |
| 109 | + 'lqt_youhavenewmessages', array( 'parseinline' ), |
| 110 | + $newmsg_t->getFullURL() |
| 111 | + ); |
108 | 112 | $tpl->set( "newtalk", $s ); |
109 | 113 | $wgOut->setSquidMaxage( 0 ); |
110 | 114 | } else { |
— | — | @@ -112,62 +116,64 @@ |
113 | 117 | |
114 | 118 | return true; |
115 | 119 | } |
116 | | - |
| 120 | + |
117 | 121 | static function beforeWatchlist( &$conds, &$tables, &$join_conds, &$fields ) { |
118 | 122 | global $wgOut, $wgUser; |
119 | | - |
| 123 | + |
120 | 124 | $db = wfGetDB( DB_SLAVE ); |
121 | | - |
| 125 | + |
122 | 126 | if ( !in_array( 'page', $tables ) ) { |
123 | 127 | $tables[] = 'page'; |
124 | 128 | // Yes, this is the correct field to join to. Weird naming. |
125 | 129 | $join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' ); |
126 | 130 | } |
127 | | - $conds[] = "page_namespace != " . $db->addQuotes(NS_LQT_THREAD); |
128 | | - |
| 131 | + $conds[] = "page_namespace != " . $db->addQuotes( NS_LQT_THREAD ); |
| 132 | + |
129 | 133 | $talkpage_messages = NewMessages::newUserMessages( $wgUser ); |
130 | 134 | $tn = count( $talkpage_messages ); |
131 | | - |
| 135 | + |
132 | 136 | $watch_messages = NewMessages::watchedThreadsForUser( $wgUser ); |
133 | 137 | $wn = count( $watch_messages ); |
134 | | - |
| 138 | + |
135 | 139 | if ( $tn == 0 && $wn == 0 ) |
136 | 140 | return true; |
137 | | - |
| 141 | + |
138 | 142 | LqtView::addJSandCSS(); |
139 | 143 | wfLoadExtensionMessages( 'LiquidThreads' ); |
140 | 144 | $messages_title = SpecialPage::getTitleFor( 'NewMessages' ); |
141 | 145 | $new_messages = wfMsgExt( 'lqt-new-messages', 'parseinline' ); |
142 | | - |
| 146 | + |
143 | 147 | $sk = $wgUser->getSkin(); |
144 | | - $link = $sk->link( $messages_title, $new_messages, |
145 | | - array( 'class' => 'lqt_watchlist_messages_notice' ) ); |
| 148 | + $link = $sk->link( |
| 149 | + $messages_title, |
| 150 | + $new_messages, |
| 151 | + array( 'class' => 'lqt_watchlist_messages_notice' ) |
| 152 | + ); |
146 | 153 | $wgOut->addHTML( $link ); |
147 | | - |
| 154 | + |
148 | 155 | return true; |
149 | 156 | } |
150 | | - |
| 157 | + |
151 | 158 | static function getPreferences( $user, &$preferences ) { |
152 | 159 | global $wgEnableEmail; |
153 | 160 | wfLoadExtensionMessages( 'LiquidThreads' ); |
154 | | - |
155 | | - if ($wgEnableEmail) { |
156 | | - $preferences['lqtnotifytalk'] = |
157 | | - array( |
158 | | - 'type' => 'toggle', |
159 | | - 'label-message' => 'lqt-preference-notify-talk', |
160 | | - 'section' => 'personal/email' |
161 | | - ); |
| 161 | + |
| 162 | + if ( $wgEnableEmail ) { |
| 163 | + $preferences['lqtnotifytalk'] = array( |
| 164 | + 'type' => 'toggle', |
| 165 | + 'label-message' => 'lqt-preference-notify-talk', |
| 166 | + 'section' => 'personal/email' |
| 167 | + ); |
162 | 168 | } |
163 | | - |
164 | | - |
| 169 | + |
| 170 | + |
165 | 171 | $preferences['lqt-watch-threads'] = |
166 | 172 | array( |
167 | 173 | 'type' => 'toggle', |
168 | 174 | 'label-message' => 'lqt-preference-watch-threads', |
169 | 175 | 'section' => 'watchlist/advancedwatchlist', |
170 | 176 | ); |
171 | | - |
| 177 | + |
172 | 178 | // Display depth and count |
173 | 179 | $preferences['lqtdisplaydepth'] = |
174 | 180 | array( |
— | — | @@ -175,7 +181,7 @@ |
176 | 182 | 'label-message' => 'lqt-preference-display-depth', |
177 | 183 | 'section' => 'lqt', |
178 | 184 | ); |
179 | | - |
| 185 | + |
180 | 186 | // Display depth and count |
181 | 187 | $preferences['lqtdisplaycount'] = |
182 | 188 | array( |
— | — | @@ -183,36 +189,40 @@ |
184 | 190 | 'label-message' => 'lqt-preference-display-count', |
185 | 191 | 'section' => 'lqt', |
186 | 192 | ); |
187 | | - |
| 193 | + |
188 | 194 | return true; |
189 | 195 | } |
190 | | - |
| 196 | + |
191 | 197 | static function updateNewtalkOnEdit( $article ) { |
192 | 198 | $title = $article->getTitle(); |
193 | | - |
| 199 | + |
194 | 200 | if ( LqtDispatch::isLqtPage( $title ) ) { |
195 | 201 | // They're only editing the header, don't update newtalk. |
196 | 202 | return false; |
197 | 203 | } |
198 | | - |
| 204 | + |
199 | 205 | return true; |
200 | 206 | } |
201 | | - |
| 207 | + |
202 | 208 | static function dumpThreadData( $writer, &$out, $row, $title ) { |
203 | | - $editedStati = array( Threads::EDITED_NEVER => 'never', |
204 | | - Threads::EDITED_HAS_REPLY => 'has-reply', |
205 | | - Threads::EDITED_BY_AUTHOR => 'by-author', |
206 | | - Threads::EDITED_BY_OTHERS => 'by-others' ); |
207 | | - $threadTypes = array( Threads::TYPE_NORMAL => 'normal', |
208 | | - Threads::TYPE_MOVED => 'moved', |
209 | | - Threads::TYPE_DELETED => 'deleted' ); |
| 209 | + $editedStati = array( |
| 210 | + Threads::EDITED_NEVER => 'never', |
| 211 | + Threads::EDITED_HAS_REPLY => 'has-reply', |
| 212 | + Threads::EDITED_BY_AUTHOR => 'by-author', |
| 213 | + Threads::EDITED_BY_OTHERS => 'by-others' |
| 214 | + ); |
| 215 | + $threadTypes = array( |
| 216 | + Threads::TYPE_NORMAL => 'normal', |
| 217 | + Threads::TYPE_MOVED => 'moved', |
| 218 | + Threads::TYPE_DELETED => 'deleted' |
| 219 | + ); |
210 | 220 | // Is it a thread |
211 | 221 | if ( $row->thread_id ) { |
212 | 222 | $thread = new Thread( $row ); |
213 | 223 | $threadInfo = "\n"; |
214 | 224 | $attribs = array(); |
215 | 225 | $attribs['ThreadSubject'] = $thread->subject(); |
216 | | - if ($thread->hasSuperThread()) { |
| 226 | + if ( $thread->hasSuperThread() ) { |
217 | 227 | $attribs['ThreadParent'] = $thread->superThread()->id(); |
218 | 228 | } |
219 | 229 | $attribs['ThreadAncestor'] = $thread->topmostThread()->id(); |
— | — | @@ -224,39 +234,39 @@ |
225 | 235 | $attribs['ThreadAuthor'] = $thread->author()->getName(); |
226 | 236 | $attribs['ThreadEditStatus'] = $editedStati[$thread->editedness()]; |
227 | 237 | $attribs['ThreadType'] = $threadTypes[$thread->type()]; |
228 | | - |
229 | | - foreach( $attribs as $key => $value ) { |
230 | | - $threadInfo .= "\t".Xml::element( $key, null, $value ) . "\n"; |
| 238 | + |
| 239 | + foreach ( $attribs as $key => $value ) { |
| 240 | + $threadInfo .= "\t" . Xml::element( $key, null, $value ) . "\n"; |
231 | 241 | } |
232 | | - |
| 242 | + |
233 | 243 | $out .= Xml::tags( 'DiscussionThreading', null, $threadInfo ) . "\n"; |
234 | 244 | } |
235 | | - |
| 245 | + |
236 | 246 | return true; |
237 | 247 | } |
238 | | - |
| 248 | + |
239 | 249 | static function modifyExportQuery( $db, &$tables, &$cond, &$opts, &$join ) { |
240 | 250 | $tables[] = 'thread'; |
241 | | - |
| 251 | + |
242 | 252 | $join['thread'] = array( 'left join', array( 'thread_root=page_id' ) ); |
243 | | - |
| 253 | + |
244 | 254 | return true; |
245 | 255 | } |
246 | | - |
| 256 | + |
247 | 257 | static function customiseSearchResultTitle( &$title, &$text, $result, $terms, $page ) { |
248 | 258 | if ( $title->getNamespace() != NS_LQT_THREAD ) { |
249 | 259 | return true; |
250 | 260 | } |
251 | | - |
252 | | - $thread = Threads::withRoot( new Article($title) ); |
| 261 | + |
| 262 | + $thread = Threads::withRoot( new Article( $title ) ); |
253 | 263 | $text = $thread->subject(); |
254 | | - |
| 264 | + |
255 | 265 | $title = clone $thread->topmostThread()->title(); |
256 | | - $title->setFragment( '#'.$thread->getAnchorName() ); |
257 | | - |
| 266 | + $title->setFragment( '#' . $thread->getAnchorName() ); |
| 267 | + |
258 | 268 | return true; |
259 | 269 | } |
260 | | - |
| 270 | + |
261 | 271 | static function onUserRename( $renameUserSQL ) { |
262 | 272 | // Always use the job queue, talk page edits will take forever |
263 | 273 | $renameUserSQL->tablesJob['thread'] = |
— | — | @@ -265,57 +275,55 @@ |
266 | 276 | array( 'th_user_text', 'th_user', 'th_timestamp' ); |
267 | 277 | return true; |
268 | 278 | } |
269 | | - |
| 279 | + |
270 | 280 | static function editCheckboxes( $editPage, &$checkboxes, &$tabIndex ) { |
271 | 281 | $article = $editPage->getArticle(); |
272 | 282 | $title = $article->getTitle(); |
273 | | - |
| 283 | + |
274 | 284 | if ( !$article->exists() && $title->getNamespace() == NS_LQT_THREAD ) { |
275 | 285 | unset( $checkboxes['minor'] ); |
276 | 286 | } |
277 | | - |
| 287 | + |
278 | 288 | return true; |
279 | 289 | } |
280 | | - |
| 290 | + |
281 | 291 | static function customiseSearchProfiles( &$profiles ) { |
282 | 292 | wfLoadExtensionMessages( 'LiquidThreads' ); |
283 | | - |
| 293 | + |
284 | 294 | $namespaces = array( NS_LQT_THREAD, NS_LQT_SUMMARY ); |
285 | | - |
| 295 | + |
286 | 296 | // Add odd namespaces |
287 | | - foreach( SearchEngine::searchableNamespaces() as $ns => $nsName ) { |
288 | | - if ($ns % 2 == 1) { |
| 297 | + foreach ( SearchEngine::searchableNamespaces() as $ns => $nsName ) { |
| 298 | + if ( $ns % 2 == 1 ) { |
289 | 299 | $namespaces[] = $ns; |
290 | 300 | } |
291 | 301 | } |
292 | | - |
| 302 | + |
293 | 303 | $insert = array( |
294 | | - 'threads' => |
295 | | - array( |
296 | | - 'message' => 'searchprofile-threads', |
297 | | - 'tooltip' => 'searchprofile-threads-tooltip', |
298 | | - 'namespaces' => $namespaces, |
299 | | - 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ), |
300 | | - ), |
| 304 | + 'threads' => array( |
| 305 | + 'message' => 'searchprofile-threads', |
| 306 | + 'tooltip' => 'searchprofile-threads-tooltip', |
| 307 | + 'namespaces' => $namespaces, |
| 308 | + 'namespace-messages' => SearchEngine::namespacesAsText( $namespaces ), |
| 309 | + ), |
301 | 310 | ); |
302 | | - |
| 311 | + |
303 | 312 | $profiles = wfArrayInsertAfter( $profiles, $insert, 'help' ); |
304 | | - |
| 313 | + |
305 | 314 | return true; |
306 | 315 | } |
307 | | - |
| 316 | + |
308 | 317 | public static function onLoadExtensionSchemaUpdates() { |
309 | 318 | global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields, |
310 | 319 | $wgExtPGAlteredFields, $wgExtNewIndexes, $wgDBtype; |
311 | 320 | |
312 | 321 | $dir = realpath( dirname( __FILE__ ) . '/..' ); |
313 | | - |
| 322 | + |
314 | 323 | // DB updates |
315 | 324 | $wgExtNewTables[] = array( 'thread', "$dir/lqt.sql" ); |
316 | 325 | $wgExtNewTables[] = array( 'user_message_state', "$dir/lqt.sql" ); |
317 | 326 | $wgExtNewTables[] = array( 'thread_history', "$dir/schema-changes/thread_history_table.sql" ); |
318 | | - |
319 | | - |
| 327 | + |
320 | 328 | $wgExtNewFields[] = array( "thread", "thread_article_namespace", "$dir/schema-changes/split-thread_article.sql" ); |
321 | 329 | $wgExtNewFields[] = array( "thread", "thread_article_title", "$dir/schema-changes/split-thread_article.sql" ); |
322 | 330 | $wgExtNewFields[] = array( "thread", "thread_ancestor", "$dir/schema-changes/normalise-ancestry.sql" ); |
— | — | @@ -326,9 +334,9 @@ |
327 | 335 | $wgExtNewFields[] = array( "thread", "thread_subject", "$dir/schema-changes/store_subject-author.sql" ); |
328 | 336 | $wgExtNewFields[] = array( "thread", "thread_author_id", "$dir/schema-changes/store_subject-author.sql" ); |
329 | 337 | $wgExtNewFields[] = array( "thread", "thread_author_name", "$dir/schema-changes/store_subject-author.sql" ); |
330 | | - |
| 338 | + |
331 | 339 | $wgExtNewIndexes[] = array( 'thread', 'thread_summary_page', '(thread_summary_page)' ); |
332 | | - |
| 340 | + |
333 | 341 | return true; |
334 | 342 | } |
335 | 343 | } |
Index: trunk/extensions/LiquidThreads/classes/NewMessagesController.php |
— | — | @@ -2,7 +2,6 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) die; |
4 | 4 | |
5 | 5 | class NewMessages { |
6 | | - |
7 | 6 | static function markThreadAsUnreadByUser( $thread, $user ) { |
8 | 7 | self::writeUserMessageState( $thread, $user, null ); |
9 | 8 | } |
— | — | @@ -29,10 +28,17 @@ |
30 | 29 | } |
31 | 30 | |
32 | 31 | $dbw = wfGetDB( DB_MASTER ); |
33 | | - |
34 | | - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), |
35 | | - array( 'ums_user' => $user_id, 'ums_thread' => $thread_id, |
36 | | - 'ums_read_timestamp' => $timestamp ), __METHOD__ ); |
| 32 | + |
| 33 | + $dbw->replace( |
| 34 | + 'user_message_state', |
| 35 | + array( array( 'ums_user', 'ums_thread' ) ), |
| 36 | + array( |
| 37 | + 'ums_user' => $user_id, |
| 38 | + 'ums_thread' => $thread_id, |
| 39 | + 'ums_read_timestamp' => $timestamp |
| 40 | + ), |
| 41 | + __METHOD__ |
| 42 | + ); |
37 | 43 | } |
38 | 44 | |
39 | 45 | /** |
— | — | @@ -41,7 +47,7 @@ |
42 | 48 | */ |
43 | 49 | static function writeMessageStateForUpdatedThread( $t, $type, $changeUser ) { |
44 | 50 | global $wgUser; |
45 | | - |
| 51 | + |
46 | 52 | wfDebugLog( 'LiquidThreads', 'Doing notifications' ); |
47 | 53 | |
48 | 54 | $dbw =& wfGetDB( DB_MASTER ); |
— | — | @@ -50,40 +56,50 @@ |
51 | 57 | $root_t = $t->topmostThread()->root()->getTitle(); |
52 | 58 | |
53 | 59 | // Select any applicable watchlist entries for the thread. |
54 | | - $talkpageWhere = array( 'wl_namespace' => $tpTitle->getNamespace(), |
55 | | - 'wl_title' => $tpTitle->getDBkey() ); |
56 | | - $rootWhere = array( 'wl_namespace' => $root_t->getNamespace(), |
57 | | - 'wl_title' => $root_t->getDBkey() ); |
58 | | - |
| 60 | + $talkpageWhere = array( |
| 61 | + 'wl_namespace' => $tpTitle->getNamespace(), |
| 62 | + 'wl_title' => $tpTitle->getDBkey() |
| 63 | + ); |
| 64 | + $rootWhere = array( |
| 65 | + 'wl_namespace' => $root_t->getNamespace(), |
| 66 | + 'wl_title' => $root_t->getDBkey() |
| 67 | + ); |
| 68 | + |
59 | 69 | $talkpageWhere = $dbw->makeList( $talkpageWhere, LIST_AND ); |
60 | 70 | $rootWhere = $dbw->makeList( $rootWhere, LIST_AND ); |
61 | | - |
| 71 | + |
62 | 72 | $where_clause = $dbw->makeList( array( $talkpageWhere, $rootWhere ), LIST_OR ); |
63 | | - |
| 73 | + |
64 | 74 | // <= 1.15 compatibility, it kinda sucks having to do all this up here. |
65 | 75 | $tables = array( 'watchlist', 'user_message_state' ); |
66 | | - $joins = array( 'user_message_state' => |
67 | | - array( 'left join', |
68 | | - array( 'ums_user=wl_user', 'ums_thread' => $t->id() ) ) ); |
| 76 | + $joins = array( |
| 77 | + 'user_message_state' => array( |
| 78 | + 'left join', |
| 79 | + array( |
| 80 | + 'ums_user=wl_user', |
| 81 | + 'ums_thread' => $t->id() |
| 82 | + ) |
| 83 | + ) |
| 84 | + ); |
69 | 85 | $fields = array( 'wl_user', 'ums_user', 'ums_read_timestamp' ); |
70 | | - |
| 86 | + |
71 | 87 | $oldPrefCompat = false; |
72 | 88 | global $wgVersion; |
73 | 89 | if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
74 | 90 | $oldPrefCompat = true; |
75 | | - |
| 91 | + |
76 | 92 | $tables[] = 'user'; |
77 | 93 | $joins['user'] = array( 'left join', 'user_id=wl_user' ); |
78 | 94 | $fields[] = 'user_options'; |
79 | 95 | } else { |
80 | 96 | $tables[] = 'user_properties'; |
81 | | - $joins['user_properties'] = |
| 97 | + $joins['user_properties'] = array( |
| 98 | + 'left join', |
82 | 99 | array( |
83 | | - 'left join', |
84 | | - array( 'up_user=wl_user', |
85 | | - 'up_property' => 'lqtnotifytalk', |
86 | | - ) |
87 | | - ); |
| 100 | + 'up_user=wl_user', |
| 101 | + 'up_property' => 'lqtnotifytalk' |
| 102 | + ) |
| 103 | + ); |
88 | 104 | $fields[] = 'up_value'; |
89 | 105 | } |
90 | 106 | |
— | — | @@ -91,78 +107,83 @@ |
92 | 108 | // user_message_state row exists for them, and whether or not to send an email |
93 | 109 | // notification. |
94 | 110 | $dbr = wfGetDB( DB_SLAVE ); |
95 | | - $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins); |
96 | | - |
| 111 | + $res = $dbr->select( $tables, $fields, $where_clause, __METHOD__, array(), $joins ); |
| 112 | + |
97 | 113 | $insert_rows = array(); |
98 | 114 | $update_tuples = array(); |
99 | 115 | $notify_users = array(); |
100 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 116 | + while ( $row = $dbr->fetchObject( $res ) ) { |
101 | 117 | // Don't notify yourself |
102 | 118 | if ( $changeUser->getId() == $row->wl_user ) |
103 | 119 | continue; |
104 | | - |
| 120 | + |
105 | 121 | if ( $row->ums_user && !$row->ums_read_timestamp ) { |
106 | 122 | // It's already positive. |
107 | 123 | } else { |
108 | | - $insert_rows[] = |
109 | | - array( |
110 | | - 'ums_user' => $row->wl_user, |
111 | | - 'ums_thread' => $t->id(), |
112 | | - 'ums_read_timestamp' => null, |
113 | | - ); |
114 | | - |
| 124 | + $insert_rows[] = array( |
| 125 | + 'ums_user' => $row->wl_user, |
| 126 | + 'ums_thread' => $t->id(), |
| 127 | + 'ums_read_timestamp' => null, |
| 128 | + ); |
| 129 | + |
115 | 130 | // Set newtalk |
116 | 131 | $u = User::newFromId( $row->wl_user ); |
117 | 132 | $u->setNewtalk( true ); |
118 | 133 | } |
119 | | - |
| 134 | + |
120 | 135 | $wantsTalkNotification = false; |
121 | | - |
| 136 | + |
122 | 137 | if ( $oldPrefCompat ) { |
123 | 138 | $decodedOptions = self::decodeUserOptions( $row->user_options ); |
124 | | - |
125 | | - $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) && |
| 139 | + |
| 140 | + $wantsTalkNotification = ( is_null( $decodedOptions['lqtnotifytalk'] ) && |
126 | 141 | User::getDefaultOption( 'lqtnotifytalk' ) ) || $row->up_value; |
127 | 142 | } else { |
128 | 143 | $wantsTalkNotification = |
129 | | - (is_null($row->up_value) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
| 144 | + ( is_null( $row->up_value ) && User::getDefaultOption( 'lqtnotifytalk' ) ) |
130 | 145 | || $row->up_value; |
131 | 146 | } |
132 | | - |
| 147 | + |
133 | 148 | if ( $wantsTalkNotification ) { |
134 | 149 | $notify_users[] = $row->wl_user; |
135 | 150 | } |
136 | 151 | } |
137 | | - |
| 152 | + |
138 | 153 | // Add user talk notification |
139 | 154 | if ( $t->article()->getTitle()->getNamespace() == NS_USER_TALK ) { |
140 | 155 | $name = $t->article()->getTitle()->getText(); |
141 | | - |
| 156 | + |
142 | 157 | $user = User::newFromName( $name ); |
143 | 158 | if ( $user ) { |
144 | 159 | $user->setNewtalk( true ); |
145 | | - |
146 | | - $insert_rows[] = array( 'ums_user' => $user->getId(), |
147 | | - 'ums_thread' => $t->id(), |
148 | | - 'ums_read_timestamp' => null ); |
149 | | - |
| 160 | + |
| 161 | + $insert_rows[] = array( |
| 162 | + 'ums_user' => $user->getId(), |
| 163 | + 'ums_thread' => $t->id(), |
| 164 | + 'ums_read_timestamp' => null |
| 165 | + ); |
| 166 | + |
150 | 167 | if ( $user->getOption( 'enotifusertalkpages' ) ) { |
151 | 168 | $notify_users[] = $user->getId(); |
152 | 169 | } |
153 | 170 | } |
154 | 171 | } |
155 | | - |
| 172 | + |
156 | 173 | // Do the actual updates |
157 | | - if ( count($insert_rows) ) { |
158 | | - $dbw->replace( 'user_message_state', array( array( 'ums_user', 'ums_thread' ) ), |
159 | | - $insert_rows, __METHOD__ ); |
| 174 | + if ( count( $insert_rows ) ) { |
| 175 | + $dbw->replace( |
| 176 | + 'user_message_state', |
| 177 | + array( array( 'ums_user', 'ums_thread' ) ), |
| 178 | + $insert_rows, |
| 179 | + __METHOD__ |
| 180 | + ); |
160 | 181 | } |
161 | | - |
162 | | - if ( count($notify_users) ) { |
| 182 | + |
| 183 | + if ( count( $notify_users ) ) { |
163 | 184 | self::notifyUsersByMail( $t, $notify_users, wfTimestampNow(), $type ); |
164 | 185 | } |
165 | 186 | } |
166 | | - |
| 187 | + |
167 | 188 | // Would refactor User::decodeOptions, but the whole point is that this is |
168 | 189 | // compatible with old code :) |
169 | 190 | static function decodeUserOptions( $str ) { |
— | — | @@ -174,10 +195,10 @@ |
175 | 196 | $opts[$m[1]] = $m[2]; |
176 | 197 | } |
177 | 198 | } |
178 | | - |
| 199 | + |
179 | 200 | return $opts; |
180 | 201 | } |
181 | | - |
| 202 | + |
182 | 203 | static function notifyUsersByMail( $t, $watching_users, $timestamp, $type ) { |
183 | 204 | wfLoadExtensionMessages( 'LiquidThreads' ); |
184 | 205 | $messages = array( |
— | — | @@ -188,148 +209,169 @@ |
189 | 210 | Threads::CHANGE_REPLY_CREATED => 'lqt-enotif-subject-reply', |
190 | 211 | Threads::CHANGE_NEW_THREAD => 'lqt-enotif-subject-newthread', |
191 | 212 | ); |
192 | | - |
193 | | - if ( !isset($messages[$type]) || !isset($subjects[$type]) ) { |
| 213 | + |
| 214 | + if ( !isset( $messages[$type] ) || !isset( $subjects[$type] ) ) { |
194 | 215 | wfDebugLog( 'LiquidThreads', "Email notification failed: type $type unrecognised" ); |
195 | 216 | return; |
196 | 217 | } else { |
197 | 218 | $msgName = $messages[$type]; |
198 | 219 | $subjectMsg = $subjects[$type]; |
199 | 220 | } |
200 | | - |
| 221 | + |
201 | 222 | // Send email notification, fetching all the data in one go |
202 | | - |
| 223 | + |
203 | 224 | global $wgVersion; |
204 | 225 | $tables = array( 'user' ); |
205 | 226 | $fields = array( 'user.*' ); |
206 | 227 | $join_conds = array(); |
207 | 228 | $oldPreferenceFormat = false; |
208 | | - if (version_compare( $wgVersion, '1.16', '<' )) { |
| 229 | + if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
209 | 230 | $oldPreferenceFormat = true; |
210 | 231 | } else { |
211 | 232 | $tables[] = 'user_properties as tc_prop'; |
212 | 233 | $fields[] = 'tc_prop.up_value as timecorrection'; |
213 | | - |
| 234 | + |
214 | 235 | $join_conds['user_properties as tc_prop'] = |
215 | | - array( 'left join', |
| 236 | + array( 'left join', |
216 | 237 | array( |
217 | 238 | 'up_user=user_id', |
218 | 239 | 'up_property' => 'timecorrection', |
219 | 240 | ) |
220 | 241 | ); |
221 | | - |
| 242 | + |
222 | 243 | $tables[] = 'user_properties as l_prop'; |
223 | 244 | $fields[] = 'l_prop.up_value as language'; |
224 | | - |
| 245 | + |
225 | 246 | $join_conds['user_properties as l_prop'] = |
226 | | - array( 'left join', |
| 247 | + array( 'left join', |
227 | 248 | array( |
228 | 249 | 'up_user=user_id', |
229 | 250 | 'up_property' => 'language', |
230 | 251 | ) |
231 | 252 | ); |
232 | 253 | } |
233 | | - |
| 254 | + |
234 | 255 | $dbr = wfGetDB( DB_SLAVE ); |
235 | | - $res = $dbr->select( $tables, $fields, |
236 | | - array( 'user_id' => $watching_users ), __METHOD__, array(), |
237 | | - $join_conds |
238 | | - ); |
239 | | - |
| 256 | + $res = $dbr->select( |
| 257 | + $tables, |
| 258 | + $fields, |
| 259 | + array( 'user_id' => $watching_users ), |
| 260 | + __METHOD__, |
| 261 | + array(), |
| 262 | + $join_conds |
| 263 | + ); |
| 264 | + |
240 | 265 | // Set up one-time data. |
241 | 266 | $link_title = clone $t->article()->getTitle(); |
242 | | - $link_title->setFragment( '#'.$t->getAnchorName() ); |
| 267 | + $link_title->setFragment( '#' . $t->getAnchorName() ); |
243 | 268 | $permalink = $link_title->getFullURL(); |
244 | 269 | $talkPage = $t->article()->getTitle()->getPrefixedText(); |
245 | 270 | $from = new MailAddress( $wgPasswordSender, 'WikiAdmin' ); |
246 | 271 | $threadSubject = $t->subject(); |
247 | | - |
| 272 | + |
248 | 273 | // Parse content and strip HTML of post content |
249 | 274 | // Doesn't work for some reason (transaction issues?) |
250 | 275 | // $content = $t->root()->getContent(); |
251 | 276 | // global $wgOut; |
252 | 277 | // $html = $wgOut->parse( $content ); |
253 | 278 | // $text = StringUtils::delimiterReplace( '<', '>', '', $html ); |
254 | | - |
255 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 279 | + |
| 280 | + while ( $row = $dbr->fetchObject( $res ) ) { |
256 | 281 | $u = User::newFromRow( $row ); |
257 | | - |
258 | | - if ($oldPreferenceFormat) { |
| 282 | + |
| 283 | + if ( $oldPreferenceFormat ) { |
259 | 284 | $langCode = $u->getOption( 'language' ); |
260 | | - } elseif ($row->language) { |
| 285 | + } elseif ( $row->language ) { |
261 | 286 | $langCode = $row->language; |
262 | 287 | } else { |
263 | 288 | global $wgLanguageCode; |
264 | 289 | $langCode = $wgLanguageCode; |
265 | 290 | } |
266 | | - |
| 291 | + |
267 | 292 | $lang = Language::factory( $langCode ); |
268 | | - |
| 293 | + |
269 | 294 | // Adjust with time correction |
270 | | - if ($oldPreferenceFormat) { |
| 295 | + if ( $oldPreferenceFormat ) { |
271 | 296 | $timeCorrection = $u->getOption( 'timecorrection' ); |
272 | 297 | } else { |
273 | 298 | $timeCorrection = $row->timecorrection; |
274 | 299 | } |
275 | 300 | $adjustedTimestamp = $lang->userAdjust( $timestamp, $timeCorrection ); |
276 | | - |
| 301 | + |
277 | 302 | $date = $lang->date( $adjustedTimestamp ); |
278 | 303 | $time = $lang->time( $adjustedTimestamp ); |
279 | | - |
| 304 | + |
280 | 305 | $params = array( $u->getName(), $t->subjectWithoutIncrement(), |
281 | 306 | $date, $time, $talkPage, $permalink ); |
282 | | - |
| 307 | + |
283 | 308 | // Get message in user's own language, bug 20645 |
284 | 309 | $msg = wfMsgReal( $msgName, $params, true /* use DB */, $langCode, |
285 | 310 | true /*transform*/ ); |
286 | | - |
| 311 | + |
287 | 312 | global $wgPasswordSender; |
288 | | - |
| 313 | + |
289 | 314 | $to = new MailAddress( $u ); |
290 | | - $subject = wfMsgReal( $subjectMsg, array($threadSubject), true /* use DB */, |
291 | | - $langCode, true /* transform */); |
292 | | - |
| 315 | + $subject = wfMsgReal( $subjectMsg, array( $threadSubject ), true /* use DB */, |
| 316 | + $langCode, true /* transform */ ); |
| 317 | + |
293 | 318 | UserMailer::send( $to, $from, $subject, $msg ); |
294 | 319 | } |
295 | 320 | } |
296 | 321 | |
297 | 322 | static function newUserMessages( $user ) { |
298 | 323 | $talkPage = new Article( $user->getUserPage()->getTalkPage() ); |
299 | | - |
| 324 | + |
300 | 325 | $dbr = wfGetDB( DB_SLAVE ); |
301 | | - |
| 326 | + |
302 | 327 | $joinConds = array( 'ums_user' => null ); |
303 | | - $joinConds[] = $dbr->makeList( array( 'ums_user' => $user->getId(), |
304 | | - 'ums_thread=thread_id' ), LIST_AND ); |
| 328 | + $joinConds[] = $dbr->makeList( |
| 329 | + array( |
| 330 | + 'ums_user' => $user->getId(), |
| 331 | + 'ums_thread=thread_id' |
| 332 | + ), |
| 333 | + LIST_AND |
| 334 | + ); |
305 | 335 | $joinClause = $dbr->makeList( $joinConds, LIST_OR ); |
306 | | - |
307 | | - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*', |
308 | | - array( 'ums_read_timestamp' => null, |
309 | | - Threads::articleClause( $talkPage ) ), |
310 | | - __METHOD__, array(), |
311 | | - array( |
312 | | - 'user_message_state' => |
313 | | - array( 'LEFT OUTER JOIN', $joinClause ) |
314 | | - ) ); |
315 | | - |
| 336 | + |
| 337 | + $res = $dbr->select( |
| 338 | + array( 'thread', 'user_message_state' ), |
| 339 | + '*', |
| 340 | + array( |
| 341 | + 'ums_read_timestamp' => null, |
| 342 | + Threads::articleClause( $talkPage ) |
| 343 | + ), |
| 344 | + __METHOD__, |
| 345 | + array(), |
| 346 | + array( |
| 347 | + 'user_message_state' => |
| 348 | + array( 'LEFT OUTER JOIN', $joinClause ) |
| 349 | + ) |
| 350 | + ); |
| 351 | + |
316 | 352 | return Threads::loadFromResult( $res, $dbr ); |
317 | 353 | } |
318 | 354 | |
319 | 355 | static function watchedThreadsForUser( $user ) { |
320 | 356 | $talkPage = new Article( $user->getUserPage()->getTalkPage() ); |
321 | | - |
| 357 | + |
322 | 358 | $dbr = wfGetDB( DB_SLAVE ); |
323 | | - |
324 | | - $res = $dbr->select( array( 'thread', 'user_message_state' ), '*', |
325 | | - array( 'ums_read_timestamp' => null, |
326 | | - 'ums_user' => $user->getId(), |
327 | | - 'not (' . Threads::articleClause( $talkPage ) . ')', |
328 | | - ), |
329 | | - __METHOD__, array(), |
330 | | - array( 'user_message_state' => |
331 | | - array( 'INNER JOIN', 'ums_thread=thread_id' ), |
332 | | - ) ); |
333 | | - |
| 359 | + |
| 360 | + $res = $dbr->select( |
| 361 | + array( 'thread', 'user_message_state' ), |
| 362 | + '*', |
| 363 | + array( |
| 364 | + 'ums_read_timestamp' => null, |
| 365 | + 'ums_user' => $user->getId(), |
| 366 | + 'not (' . Threads::articleClause( $talkPage ) . ')', |
| 367 | + ), |
| 368 | + __METHOD__, |
| 369 | + array(), |
| 370 | + array( |
| 371 | + 'user_message_state' => |
| 372 | + array( 'INNER JOIN', 'ums_thread=thread_id' ), |
| 373 | + ) |
| 374 | + ); |
| 375 | + |
334 | 376 | return Threads::loadFromResult( $res, $dbr ); |
335 | 377 | } |
336 | 378 | } |
Index: trunk/extensions/LiquidThreads/classes/ThreadRevision.php |
— | — | @@ -6,157 +6,157 @@ |
7 | 7 | array( |
8 | 8 | 'th_id' => 'mId', |
9 | 9 | 'th_thread' => 'mThreadId', |
10 | | - |
| 10 | + |
11 | 11 | 'th_timestamp' => 'mTimestamp', |
12 | | - |
| 12 | + |
13 | 13 | 'th_user' => 'mUserId', |
14 | 14 | 'th_user_text' => 'mUserText', |
15 | | - |
| 15 | + |
16 | 16 | 'th_change_type' => 'mChangeType', |
17 | 17 | 'th_change_object' => 'mChangeObjectId', |
18 | 18 | 'th_change_comment' => 'mChangeComment', |
19 | 19 | 'th_content' => 'mObjSer', |
20 | 20 | ); |
21 | | - |
| 21 | + |
22 | 22 | protected $mId, $mThreadId, $mTimestamp, $mUserId, $mUserText, $mChangeType, |
23 | 23 | $mChangeObjectId, $mChangeObject, $mChangeComment, $mObjSer, $mThreadObj; |
24 | | - |
| 24 | + |
25 | 25 | static function loadFromId( $id ) { |
26 | 26 | $dbr = wfGetDB( DB_SLAVE ); |
27 | 27 | $row = $dbr->selectRow( 'thread_history', '*', array( 'th_id' => $id ), __METHOD__ ); |
28 | | - |
| 28 | + |
29 | 29 | return self::loadFromRow( $row ); |
30 | 30 | } |
31 | | - |
| 31 | + |
32 | 32 | static function loadFromRow( $row ) { |
33 | 33 | $rev = new ThreadRevision; |
34 | | - |
35 | | - foreach( self::$load as $col => $field ) { |
| 34 | + |
| 35 | + foreach ( self::$load as $col => $field ) { |
36 | 36 | $rev->$field = $row->$col; |
37 | 37 | } |
38 | | - |
| 38 | + |
39 | 39 | $rev->mUser = User::newFromName( $rev->mUserText, /* Don't validate */ false ); |
40 | 40 | $rev->mThreadObj = unserialize( $rev->mObjSer ); |
41 | | - |
| 41 | + |
42 | 42 | return $rev; |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | static function create( $thread, $change_type, $change_object = null, $comment = '', |
46 | 46 | $user = null, $timestamp = null ) { |
47 | | - if ( is_null($user) ) { |
| 47 | + if ( is_null( $user ) ) { |
48 | 48 | global $wgUser; |
49 | 49 | $user = $wgUser; |
50 | 50 | } |
51 | | - |
52 | | - if ( is_null($timestamp) ) { |
| 51 | + |
| 52 | + if ( is_null( $timestamp ) ) { |
53 | 53 | $timestamp = wfTimestampNow(); |
54 | 54 | } |
55 | | - |
| 55 | + |
56 | 56 | $rev = new ThreadRevision; |
57 | | - |
| 57 | + |
58 | 58 | $rev->mThreadId = $thread->topmostThread()->id(); |
59 | 59 | $rev->mTimestamp = $timestamp; |
60 | | - |
| 60 | + |
61 | 61 | $rev->mUser = $user; |
62 | 62 | $rev->mUserId = $user->getId(); |
63 | 63 | $rev->mUserText = $user->getName(); |
64 | | - |
| 64 | + |
65 | 65 | $rev->mChangeType = $change_type; |
66 | | - |
| 66 | + |
67 | 67 | if ( $change_object instanceof Thread ) { |
68 | 68 | $rev->mChangeObjectId = $change_object->id(); |
69 | 69 | $rev->mChangeObject = $change_object; |
70 | | - } elseif ( is_null($change_object) ) { |
| 70 | + } elseif ( is_null( $change_object ) ) { |
71 | 71 | $rev->mChangeObjectId = $thread->id(); |
72 | 72 | $rev->mChangeObject = $thread; |
73 | 73 | } else { |
74 | 74 | $rev->mChangeObjectId = $change_object; |
75 | 75 | } |
76 | | - |
| 76 | + |
77 | 77 | $rev->mChangeComment = $comment; |
78 | | - |
| 78 | + |
79 | 79 | $rev->mThreadObj = $thread->topmostThread(); |
80 | 80 | $rev->mObjSer = serialize( $rev->mThreadObj ); |
81 | | - |
| 81 | + |
82 | 82 | $rev->insert(); |
83 | | - |
| 83 | + |
84 | 84 | return $rev; |
85 | 85 | } |
86 | | - |
| 86 | + |
87 | 87 | function insert() { |
88 | 88 | $dbw = wfGetDB( DB_MASTER ); |
89 | | - |
| 89 | + |
90 | 90 | $row = $this->getRow(); |
91 | 91 | $row['th_id'] = $dbw->nextSequenceValue( 'thread_history_th_id' ); |
92 | | - |
| 92 | + |
93 | 93 | $dbw->insert( 'thread_history', $row, __METHOD__ ); |
94 | | - |
| 94 | + |
95 | 95 | $this->mId = $dbw->insertId(); |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | function save() { |
99 | 99 | $row = $this->getRow(); |
100 | | - |
| 100 | + |
101 | 101 | $dbw = wfGetDB( DB_MASTER ); |
102 | | - |
| 102 | + |
103 | 103 | $dbw->replace( 'thread_history', array( 'th_thread' ), $row, __METHOD__ ); |
104 | 104 | } |
105 | | - |
| 105 | + |
106 | 106 | function getRow() { |
107 | 107 | $row = array(); |
108 | | - |
| 108 | + |
109 | 109 | // First, prep the data for insertion |
110 | 110 | $dbw = wfGetDB( DB_MASTER ); |
111 | 111 | $this->mTimestamp = $dbw->timestamp( $this->mTimestamp ); |
112 | | - |
113 | | - foreach( self::$load as $col => $field ) { |
| 112 | + |
| 113 | + foreach ( self::$load as $col => $field ) { |
114 | 114 | $row[$col] = $this->$field; |
115 | 115 | } |
116 | | - |
| 116 | + |
117 | 117 | return $row; |
118 | 118 | } |
119 | | - |
| 119 | + |
120 | 120 | function getTimestamp() { |
121 | 121 | return wfTimestamp( TS_MW, $this->mTimestamp ); |
122 | 122 | } |
123 | | - |
| 123 | + |
124 | 124 | function getUser() { |
125 | | - if ($this->mUserId) { |
| 125 | + if ( $this->mUserId ) { |
126 | 126 | return User::newFromId( $this->mUserId ); |
127 | 127 | } |
128 | | - |
| 128 | + |
129 | 129 | return User::newFromText( $this->mUserText, /* No validation */ false ); |
130 | 130 | } |
131 | | - |
| 131 | + |
132 | 132 | function getChangeType() { |
133 | 133 | return $this->mChangeType; |
134 | 134 | } |
135 | | - |
| 135 | + |
136 | 136 | function getChangeObject() { |
137 | 137 | if ( !$this->mChangeObject && $this->mChangeObjectId ) { |
138 | 138 | $this->mChangeObject = Threads::withId( $this->mChangeObjectId ); |
139 | 139 | } |
140 | | - |
| 140 | + |
141 | 141 | return $this->mChangeObject; |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | function getChangeComment() { |
145 | 145 | return $this->mChangeComment; |
146 | 146 | } |
147 | | - |
| 147 | + |
148 | 148 | function getId() { |
149 | 149 | return $this->mId; |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | function getThreadObj() { |
153 | 153 | if ( !$this->mThreadObj && $this->mObjSer ) { |
154 | 154 | $this->mThreadObj = unserialize( $this->mObjSer ); |
155 | | - } elseif (!$this->mThreadObj) { |
| 155 | + } elseif ( !$this->mThreadObj ) { |
156 | 156 | throw new MWException( "Missing mObjSer" ); |
157 | 157 | } |
158 | | - |
| 158 | + |
159 | 159 | $this->mThreadObj->threadRevision = $this; |
160 | | - |
| 160 | + |
161 | 161 | return $this->mThreadObj; |
162 | 162 | } |
163 | 163 | } |
Index: trunk/extensions/LiquidThreads/classes/DeletionController.php |
— | — | @@ -2,97 +2,97 @@ |
3 | 3 | |
4 | 4 | class LqtDeletionController { |
5 | 5 | static $pageids_to_revive; |
6 | | - |
| 6 | + |
7 | 7 | static function onArticleDeleteComplete( &$article, &$user, $reason, $id ) { |
8 | 8 | $title = $article->getTitle(); |
9 | | - |
10 | | - if ($title->getNamespace() != NS_LQT_THREAD) { |
| 9 | + |
| 10 | + if ( $title->getNamespace() != NS_LQT_THREAD ) { |
11 | 11 | return true; |
12 | 12 | } |
13 | | - |
| 13 | + |
14 | 14 | $threads = Threads::where( array( 'thread_root' => $id ) ); |
15 | | - |
16 | | - if (!count($threads)) { |
17 | | - wfDebugLog( __METHOD__.": no threads with root $id, ignoring...\n" ); |
| 15 | + |
| 16 | + if ( !count( $threads ) ) { |
| 17 | + wfDebugLog( __METHOD__ . ": no threads with root $id, ignoring...\n" ); |
18 | 18 | return true; |
19 | 19 | } |
20 | | - |
21 | | - $thread = array_pop($threads); |
22 | | - |
| 20 | + |
| 21 | + $thread = array_pop( $threads ); |
| 22 | + |
23 | 23 | // Mark the thread as deleted |
24 | | - $thread->delete($reason); |
25 | | - |
| 24 | + $thread->delete( $reason ); |
| 25 | + |
26 | 26 | // Avoid orphaning subthreads, update their parentage. |
27 | 27 | wfLoadExtensionMessages( 'LiquidThreads' ); |
28 | 28 | if ( $thread->replies() && $thread->isTopmostThread() ) { |
29 | | - $reason = wfMsg('lqt-delete-parent-deleted', $reason ); |
30 | | - foreach( $thread->replies() as $reply ) { |
| 29 | + $reason = wfMsg( 'lqt-delete-parent-deleted', $reason ); |
| 30 | + foreach ( $thread->replies() as $reply ) { |
31 | 31 | $reply->root()->doDeleteArticle( $reason, false, $reply->root()->getId() ); |
32 | 32 | } |
33 | 33 | global $wgOut; |
34 | 34 | $wgOut->addWikiMsg( 'lqt-delete-replies-done' ); |
35 | 35 | } elseif ( $thread->replies() ) { |
36 | | - foreach( $thread->replies() as $reply ) { |
| 36 | + foreach ( $thread->replies() as $reply ) { |
37 | 37 | $reply->setSuperthread( $thread->superthread() ); |
38 | 38 | $reply->save( ); |
39 | 39 | } |
40 | 40 | } |
41 | | - |
| 41 | + |
42 | 42 | return true; |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | static function onArticleRevisionUndeleted( &$title, $revision, $page_id ) { |
46 | 46 | if ( $title->getNamespace() == NS_LQT_THREAD ) { |
47 | 47 | self::$pageids_to_revive[$page_id] = $title; |
48 | 48 | } |
49 | | - |
| 49 | + |
50 | 50 | return true; |
51 | 51 | } |
52 | | - |
| 52 | + |
53 | 53 | static function onArticleUndelete( &$udTitle, $created, $comment = '' ) { |
54 | | - if ( empty(self::$pageids_to_revive) ) { |
| 54 | + if ( empty( self::$pageids_to_revive ) ) { |
55 | 55 | return true; |
56 | 56 | } |
57 | | - |
58 | | - foreach( self::$pageids_to_revive as $pageid => $title ) { |
59 | | - if ($pageid == 0) { |
| 57 | + |
| 58 | + foreach ( self::$pageids_to_revive as $pageid => $title ) { |
| 59 | + if ( $pageid == 0 ) { |
60 | 60 | continue; |
61 | 61 | } |
62 | | - |
| 62 | + |
63 | 63 | // Try to get comment for old versions where it isn't passed, hacky :( |
64 | | - if (!$comment) { |
| 64 | + if ( !$comment ) { |
65 | 65 | global $wgRequest; |
66 | 66 | $comment = $wgRequest->getText( 'wpComment' ); |
67 | 67 | } |
68 | | - |
| 68 | + |
69 | 69 | // TX has not been committed yet, so we must select from the master |
70 | 70 | $dbw = wfGetDB( DB_MASTER ); |
71 | 71 | $res = $dbw->select( 'thread', '*', array( 'thread_root' => $pageid ), __METHOD__ ); |
72 | 72 | $threads = Threads::loadFromResult( $res, $dbw ); |
73 | | - |
74 | | - if ( count($threads) ) { |
75 | | - $thread = array_pop($threads); |
| 73 | + |
| 74 | + if ( count( $threads ) ) { |
| 75 | + $thread = array_pop( $threads ); |
76 | 76 | $thread->setRoot( new Article( $title ) ); |
77 | 77 | $thread->undelete( $comment ); |
78 | 78 | } else { |
79 | | - wfDebug( __METHOD__. ":No thread found with root set to $pageid (??)\n" ); |
| 79 | + wfDebug( __METHOD__ . ":No thread found with root set to $pageid (??)\n" ); |
80 | 80 | } |
81 | 81 | } |
82 | | - |
| 82 | + |
83 | 83 | return true; |
84 | 84 | } |
85 | | - |
| 85 | + |
86 | 86 | static function onArticleConfirmDelete( $article, $out, &$reason ) { |
87 | | - if ($article->getTitle()->getNamespace() != NS_LQT_THREAD) return true; |
88 | | - |
| 87 | + if ( $article->getTitle()->getNamespace() != NS_LQT_THREAD ) return true; |
| 88 | + |
89 | 89 | $thread = Threads::withRoot( $article ); |
90 | | - |
91 | | - if ( $thread->isTopmostThread() && count($thread->replies()) ) { |
| 90 | + |
| 91 | + if ( $thread->isTopmostThread() && count( $thread->replies() ) ) { |
92 | 92 | wfLoadExtensionMessages( 'LiquidThreads' ); |
93 | 93 | $out->wrapWikiMsg( '<strong>$1</strong>', |
94 | 94 | 'lqt-delete-parent-warning' ); |
95 | 95 | } |
96 | | - |
| 96 | + |
97 | 97 | return true; |
98 | 98 | } |
99 | 99 | } |
Index: trunk/extensions/LiquidThreads/classes/Thread.php |
— | — | @@ -31,35 +31,35 @@ |
32 | 32 | protected $subject; |
33 | 33 | protected $authorId; |
34 | 34 | protected $authorName; |
35 | | - |
| 35 | + |
36 | 36 | protected $allDataLoaded; |
37 | | - |
| 37 | + |
38 | 38 | protected $isHistorical = false; |
39 | | - |
| 39 | + |
40 | 40 | protected $rootRevision; |
41 | 41 | |
42 | 42 | /* Flag about who has edited or replied to this thread. */ |
43 | 43 | protected $editedness; |
44 | 44 | |
45 | 45 | protected $replies; |
46 | | - |
| 46 | + |
47 | 47 | static $titleCacheById = array(); |
48 | 48 | static $replyCacheById = array(); |
49 | 49 | static $articleCacheById = array(); |
50 | | - |
| 50 | + |
51 | 51 | static $VALID_TYPES = array( Threads::TYPE_NORMAL, Threads::TYPE_MOVED, Threads::TYPE_DELETED ); |
52 | 52 | |
53 | 53 | function isHistorical() { |
54 | 54 | return $this->isHistorical; |
55 | 55 | } |
56 | | - |
| 56 | + |
57 | 57 | static function create( $root, $article, $superthread = null, |
58 | | - $type = Threads::TYPE_NORMAL, $subject = '' ) { |
| 58 | + $type = Threads::TYPE_NORMAL, $subject = '' ) { |
59 | 59 | |
60 | | - $dbw = wfGetDB( DB_MASTER ); |
61 | | - |
62 | | - $thread = new Thread(null); |
| 60 | + $dbw = wfGetDB( DB_MASTER ); |
63 | 61 | |
| 62 | + $thread = new Thread( null ); |
| 63 | + |
64 | 64 | if ( !in_array( $type, self::$VALID_TYPES ) ) { |
65 | 65 | throw new MWException( __METHOD__ . ": invalid change type $type." ); |
66 | 66 | } |
— | — | @@ -80,50 +80,50 @@ |
81 | 81 | $thread->setArticle( $article ); |
82 | 82 | $thread->setSubject( $subject ); |
83 | 83 | $thread->setType( $type ); |
84 | | - |
| 84 | + |
85 | 85 | $thread->insert(); |
86 | | - |
| 86 | + |
87 | 87 | if ( $superthread ) { |
88 | 88 | $superthread->addReply( $thread ); |
89 | | - |
| 89 | + |
90 | 90 | $superthread->commitRevision( $change_type, $thread ); |
91 | 91 | } else { |
92 | 92 | $hthread = ThreadRevision::create( $thread, $change_type ); |
93 | 93 | } |
94 | | - |
| 94 | + |
95 | 95 | // Create talk page |
96 | 96 | Threads::createTalkpageIfNeeded( $article ); |
97 | 97 | |
98 | 98 | // Notifications |
99 | 99 | NewMessages::writeMessageStateForUpdatedThread( $thread, $change_type, $wgUser ); |
100 | | - |
101 | | - if ($wgUser->getOption( 'lqt-watch-threads', false ) ) { |
| 100 | + |
| 101 | + if ( $wgUser->getOption( 'lqt-watch-threads', false ) ) { |
102 | 102 | $thread->topmostThread()->root()->doWatch(); |
103 | 103 | } |
104 | 104 | |
105 | 105 | return $thread; |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | function insert() { |
109 | 109 | $this->dieIfHistorical(); |
110 | | - |
| 110 | + |
111 | 111 | $dbw = wfGetDB( DB_MASTER ); |
112 | | - |
| 112 | + |
113 | 113 | $row = $this->getRow(); |
114 | 114 | $row['thread_id'] = $dbw->nextSequenceValue( 'thread_thread_id' ); |
115 | | - |
| 115 | + |
116 | 116 | $dbw->insert( 'thread', $row, __METHOD__ ); |
117 | 117 | $this->id = $dbw->insertId(); |
118 | | - |
| 118 | + |
119 | 119 | // Touch the root |
120 | | - if ($this->root()) { |
| 120 | + if ( $this->root() ) { |
121 | 121 | $this->root()->getTitle()->invalidateCache(); |
122 | 122 | } |
123 | | - |
| 123 | + |
124 | 124 | // Touch the talk page, too. |
125 | 125 | $this->article()->getTitle()->invalidateCache(); |
126 | 126 | } |
127 | | - |
| 127 | + |
128 | 128 | function setRoot( $article ) { |
129 | 129 | $this->rootId = $article->getId(); |
130 | 130 | $this->root = $article; |
— | — | @@ -136,27 +136,27 @@ |
137 | 137 | $this->modified = wfTimestampNow(); |
138 | 138 | $this->updateEditedness( $change_type ); |
139 | 139 | $this->save(); |
140 | | - |
| 140 | + |
141 | 141 | $topmost = $this->topmostThread(); |
142 | 142 | $topmost->modified = wfTimestampNow(); |
143 | 143 | $topmost->save(); |
144 | | - |
| 144 | + |
145 | 145 | ThreadRevision::create( $this, $change_type, $change_object, $reason ); |
146 | 146 | |
147 | 147 | if ( $change_type == Threads::CHANGE_EDITED_ROOT ) { |
148 | 148 | NewMessages::writeMessageStateForUpdatedThread( $this, $change_type, $wgUser ); |
149 | 149 | } |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | function updateEditedness( $change_type ) { |
153 | 153 | global $wgUser; |
154 | | - |
| 154 | + |
155 | 155 | if ( $change_type == Threads::CHANGE_REPLY_CREATED |
156 | 156 | && $this->editedness == Threads::EDITED_NEVER ) { |
157 | 157 | $this->editedness = Threads::EDITED_HAS_REPLY; |
158 | 158 | } elseif ( $change_type == Threads::CHANGE_EDITED_ROOT ) { |
159 | 159 | $originalAuthor = $this->author(); |
160 | | - |
| 160 | + |
161 | 161 | if ( ( $wgUser->getId() == 0 && $originalAuthor->getName() != $wgUser->getName() ) |
162 | 162 | || $wgUser->getId() != $originalAuthor->getId() ) { |
163 | 163 | $this->editedness = Threads::EDITED_BY_OTHERS; |
— | — | @@ -165,60 +165,60 @@ |
166 | 166 | } |
167 | 167 | } |
168 | 168 | } |
169 | | - |
| 169 | + |
170 | 170 | /** Unless you know what you're doing, you want commitRevision */ |
171 | | - function save() { |
| 171 | + function save() { |
172 | 172 | $this->dieIfHistorical(); |
173 | 173 | |
174 | 174 | $dbr = wfGetDB( DB_MASTER ); |
175 | | - |
| 175 | + |
176 | 176 | $res = $dbr->update( 'thread', |
177 | 177 | /* SET */ $this->getRow(), |
178 | 178 | /* WHERE */ array( 'thread_id' => $this->id, ), |
179 | 179 | __METHOD__ ); |
180 | | - |
| 180 | + |
181 | 181 | // Touch the root |
182 | | - if ($this->root()) { |
| 182 | + if ( $this->root() ) { |
183 | 183 | $this->root()->getTitle()->invalidateCache(); |
184 | 184 | } |
185 | | - |
| 185 | + |
186 | 186 | // Touch the talk page, too. |
187 | 187 | $this->article()->getTitle()->invalidateCache(); |
188 | 188 | } |
189 | | - |
| 189 | + |
190 | 190 | function getRow() { |
191 | 191 | $id = $this->id(); |
192 | | - |
| 192 | + |
193 | 193 | $dbw = wfGetDB( DB_MASTER ); |
194 | 194 | |
195 | | - if (!$id) { |
| 195 | + if ( !$id ) { |
196 | 196 | $id = $dbw->nextSequenceValue( 'thread_thread_id' ); |
197 | 197 | } |
198 | | - |
| 198 | + |
199 | 199 | // Reflect schema changes here. |
200 | | - |
| 200 | + |
201 | 201 | return array( |
202 | | - 'thread_id' => $id, |
203 | | - 'thread_root' => $this->rootId, |
204 | | - 'thread_parent' => $this->parentId, |
205 | | - 'thread_article_namespace' => $this->articleNamespace, |
206 | | - 'thread_article_title' => $this->articleTitle, |
207 | | - 'thread_modified' => $dbw->timestamp($this->modified), |
208 | | - 'thread_created' => $dbw->timestamp($this->created), |
209 | | - 'thread_ancestor' => $this->ancestorId, |
210 | | - 'thread_type' => $this->type, |
211 | | - 'thread_subject' => $this->subject, |
212 | | - 'thread_author_id' => $this->authorId, |
213 | | - 'thread_author_name' => $this->authorName, |
214 | | - 'thread_summary_page' => $this->summaryId, |
215 | | - 'thread_editedness' => $this->editedness, |
216 | | - ); |
| 202 | + 'thread_id' => $id, |
| 203 | + 'thread_root' => $this->rootId, |
| 204 | + 'thread_parent' => $this->parentId, |
| 205 | + 'thread_article_namespace' => $this->articleNamespace, |
| 206 | + 'thread_article_title' => $this->articleTitle, |
| 207 | + 'thread_modified' => $dbw->timestamp( $this->modified ), |
| 208 | + 'thread_created' => $dbw->timestamp( $this->created ), |
| 209 | + 'thread_ancestor' => $this->ancestorId, |
| 210 | + 'thread_type' => $this->type, |
| 211 | + 'thread_subject' => $this->subject, |
| 212 | + 'thread_author_id' => $this->authorId, |
| 213 | + 'thread_author_name' => $this->authorName, |
| 214 | + 'thread_summary_page' => $this->summaryId, |
| 215 | + 'thread_editedness' => $this->editedness, |
| 216 | + ); |
217 | 217 | } |
218 | | - |
| 218 | + |
219 | 219 | function author() { |
220 | 220 | $this->doLazyUpdates(); |
221 | | - |
222 | | - if ($this->authorId) { |
| 221 | + |
| 222 | + if ( $this->authorId ) { |
223 | 223 | return User::newFromId( $this->authorId ); |
224 | 224 | } else { |
225 | 225 | // Do NOT validate username. If the user did it, they did it. |
— | — | @@ -230,49 +230,51 @@ |
231 | 231 | $this->type = Threads::TYPE_DELETED; |
232 | 232 | $this->commitRevision( Threads::CHANGE_DELETED, $this, $reason ); |
233 | 233 | /* Mark thread as read by all users, or we get blank thingies in New Messages. */ |
234 | | - |
| 234 | + |
235 | 235 | $this->dieIfHistorical(); |
236 | | - |
| 236 | + |
237 | 237 | $dbw = wfGetDB( DB_MASTER ); |
238 | | - |
| 238 | + |
239 | 239 | $dbw->delete( 'user_message_state', array( 'ums_thread' => $this->id() ), |
240 | 240 | __METHOD__ ); |
241 | 241 | } |
242 | | - |
| 242 | + |
243 | 243 | function undelete( $reason ) { |
244 | 244 | $this->type = Threads::TYPE_NORMAL; |
245 | 245 | $this->commitRevision( Threads::CHANGE_UNDELETED, $this, $reason ); |
246 | 246 | } |
247 | 247 | |
248 | 248 | function moveToPage( $title, $reason, $leave_trace ) { |
249 | | - if (!$this->isTopmostThread() ) |
| 249 | + if ( !$this->isTopmostThread() ) |
250 | 250 | throw new MWException( "Attempt to move non-toplevel thread to another page" ); |
251 | | - |
| 251 | + |
252 | 252 | $this->dieIfHistorical(); |
253 | | - |
| 253 | + |
254 | 254 | $dbr = wfGetDB( DB_MASTER ); |
255 | 255 | |
256 | 256 | $oldTitle = $this->article()->getTitle(); |
257 | 257 | $newTitle = $title; |
258 | | - |
| 258 | + |
259 | 259 | $new_articleNamespace = $title->getNamespace(); |
260 | 260 | $new_articleTitle = $title->getDBkey(); |
261 | | - |
| 261 | + |
262 | 262 | // Update on *all* subthreads. |
263 | | - $dbr->update( 'thread', |
264 | | - array( |
265 | | - 'thread_revision=thread_revision+1', |
266 | | - 'thread_article_namespace' => $new_articleNamespace, |
267 | | - 'thread_article_title' => $new_articleTitle, |
268 | | - 'thread_modified' => $dbr->timestamp( wfTimestampNow() ), |
269 | | - ), |
270 | | - array( 'thread_ancestor' => $this->id() ), |
271 | | - __METHOD__ ); |
| 263 | + $dbr->update( |
| 264 | + 'thread', |
| 265 | + array( |
| 266 | + 'thread_revision=thread_revision+1', |
| 267 | + 'thread_article_namespace' => $new_articleNamespace, |
| 268 | + 'thread_article_title' => $new_articleTitle, |
| 269 | + 'thread_modified' => $dbr->timestamp( wfTimestampNow() ), |
| 270 | + ), |
| 271 | + array( 'thread_ancestor' => $this->id() ), |
| 272 | + __METHOD__ |
| 273 | + ); |
272 | 274 | |
273 | 275 | $this->articleNamespace = $new_articleNamespace; |
274 | 276 | $this->articleTitle = $new_articleTitle; |
275 | 277 | $this->commitRevision( Threads::CHANGE_MOVED_TALKPAGE, null, $reason ); |
276 | | - |
| 278 | + |
277 | 279 | # Log the move |
278 | 280 | $log = new LogPage( 'liquidthreads' ); |
279 | 281 | $log->addEntry( 'move', $this->title(), $reason, array( $oldTitle, $newTitle ) ); |
— | — | @@ -286,59 +288,57 @@ |
287 | 289 | // there. |
288 | 290 | function leaveTrace( $reason, $oldTitle, $newTitle ) { |
289 | 291 | $this->dieIfHistorical(); |
290 | | - |
| 292 | + |
291 | 293 | $dbw = wfGetDB( DB_MASTER ); |
292 | 294 | |
293 | 295 | // Create redirect text |
294 | 296 | $mwRedir = MagicWord::get( 'redirect' ); |
295 | 297 | $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $this->title()->getPrefixedText() . "]]\n"; |
296 | | - |
| 298 | + |
297 | 299 | // Make the article edit. |
298 | | - $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat($oldTitle) ); |
| 300 | + $traceTitle = Threads::newThreadTitle( $this->subject(), new Article_LQT_Compat( $oldTitle ) ); |
299 | 301 | $redirectArticle = new Article_LQT_Compat( $traceTitle ); |
300 | 302 | $redirectArticle->doEdit( $redirectText, $reason, EDIT_NEW ); |
301 | 303 | |
302 | 304 | // Add the trace thread to the tracking table. |
303 | | - $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat($oldTitle), null, |
| 305 | + $thread = Threads::newThread( $redirectArticle, new Article_LQT_Compat( $oldTitle ), null, |
304 | 306 | Threads::TYPE_MOVED, $this->subject() ); |
305 | 307 | } |
306 | 308 | |
307 | | - |
308 | | - |
309 | 309 | function __construct( $line, $unused = null ) { |
310 | 310 | /* SCHEMA changes must be reflected here. */ |
311 | | - |
312 | | - if ( is_null($line) ) { // For Thread::create(). |
| 311 | + |
| 312 | + if ( is_null( $line ) ) { // For Thread::create(). |
313 | 313 | $this->modified = wfTimestampNow(); |
314 | 314 | $this->created = wfTimestampNow(); |
315 | 315 | $this->editedness = Threads::EDITED_NEVER; |
316 | 316 | return; |
317 | 317 | } |
318 | | - |
| 318 | + |
319 | 319 | $dataLoads = array( |
320 | | - 'thread_id' => 'id', |
321 | | - 'thread_root' => 'rootId', |
322 | | - 'thread_article_namespace' => 'articleNamespace', |
323 | | - 'thread_article_title' => 'articleTitle', |
324 | | - 'thread_summary_page' => 'summaryId', |
325 | | - 'thread_ancestor' => 'ancestorId', |
326 | | - 'thread_parent' => 'parentId', |
327 | | - 'thread_modified' => 'modified', |
328 | | - 'thread_created' => 'created', |
329 | | - 'thread_type' => 'type', |
330 | | - 'thread_editedness' => 'editedness', |
331 | | - 'thread_subject' => 'subject', |
332 | | - 'thread_author_id' => 'authorId', |
333 | | - 'thread_author_name' => 'authorName', |
334 | | - ); |
335 | | - |
336 | | - foreach( $dataLoads as $db_field => $member_field ) { |
337 | | - if ( isset($line->$db_field) ) { |
| 320 | + 'thread_id' => 'id', |
| 321 | + 'thread_root' => 'rootId', |
| 322 | + 'thread_article_namespace' => 'articleNamespace', |
| 323 | + 'thread_article_title' => 'articleTitle', |
| 324 | + 'thread_summary_page' => 'summaryId', |
| 325 | + 'thread_ancestor' => 'ancestorId', |
| 326 | + 'thread_parent' => 'parentId', |
| 327 | + 'thread_modified' => 'modified', |
| 328 | + 'thread_created' => 'created', |
| 329 | + 'thread_type' => 'type', |
| 330 | + 'thread_editedness' => 'editedness', |
| 331 | + 'thread_subject' => 'subject', |
| 332 | + 'thread_author_id' => 'authorId', |
| 333 | + 'thread_author_name' => 'authorName', |
| 334 | + ); |
| 335 | + |
| 336 | + foreach ( $dataLoads as $db_field => $member_field ) { |
| 337 | + if ( isset( $line->$db_field ) ) { |
338 | 338 | $this->$member_field = $line->$db_field; |
339 | 339 | } |
340 | 340 | } |
341 | | - |
342 | | - if ( isset($line->page_namespace) && isset($line->page_title) ) { |
| 341 | + |
| 342 | + if ( isset( $line->page_namespace ) && isset( $line->page_title ) ) { |
343 | 343 | $root_title = Title::makeTitle( $line->page_namespace, $line->page_title ); |
344 | 344 | $this->root = new Article_LQT_Compat( $root_title ); |
345 | 345 | $this->root->loadPageData( $line ); |
— | — | @@ -348,220 +348,223 @@ |
349 | 349 | } else { |
350 | 350 | $root_title = Title::newFromID( $this->rootId ); |
351 | 351 | } |
352 | | - |
353 | | - if ($root_title) { |
| 352 | + |
| 353 | + if ( $root_title ) { |
354 | 354 | $this->root = new Article_LQT_Compat( $root_title ); |
355 | 355 | } |
356 | 356 | } |
357 | | - |
| 357 | + |
358 | 358 | $this->doLazyUpdates( $line ); |
359 | 359 | } |
360 | | - |
| 360 | + |
361 | 361 | // Load a list of threads in bulk, including all subthreads. |
362 | | - static function bulkLoad( $rows ) { |
| 362 | + static function bulkLoad( $rows ) { |
363 | 363 | // Preload subthreads |
364 | 364 | $thread_ids = array(); |
365 | 365 | $all_thread_rows = $rows; |
366 | 366 | $pageIds = array(); |
367 | 367 | $linkBatch = new LinkBatch(); |
368 | | - |
369 | | - if (!is_array(self::$replyCacheById)) { |
| 368 | + |
| 369 | + if ( !is_array( self::$replyCacheById ) ) { |
370 | 370 | self::$replyCacheById = array(); |
371 | 371 | } |
372 | | - |
| 372 | + |
373 | 373 | // Build a list of threads for which to pull replies, and page IDs to pull data for. |
374 | 374 | // Also, pre-initialise the reply cache. |
375 | | - foreach( $rows as $row ) { |
| 375 | + foreach ( $rows as $row ) { |
376 | 376 | $thread_ids[] = $row->thread_id; |
377 | | - |
| 377 | + |
378 | 378 | // Grab page data while we're here. |
379 | | - if ($row->thread_root) |
| 379 | + if ( $row->thread_root ) |
380 | 380 | $pageIds[] = $row->thread_root; |
381 | | - if ($row->thread_summary_page) |
| 381 | + if ( $row->thread_summary_page ) |
382 | 382 | $pageIds[] = $row->thread_summary_page; |
383 | | - |
| 383 | + |
384 | 384 | if ( !isset( self::$replyCacheById[$row->thread_id] ) ) { |
385 | 385 | self::$replyCacheById[$row->thread_id] = array(); |
386 | 386 | } |
387 | 387 | } |
388 | | - |
| 388 | + |
389 | 389 | // Pull replies to the threads provided, and as above, pull page IDs to pull data for, |
390 | 390 | // pre-initialise the reply cache, and stash the row object for later use. |
391 | | - if ( count($thread_ids) ) { |
| 391 | + if ( count( $thread_ids ) ) { |
392 | 392 | $dbr = wfGetDB( DB_SLAVE ); |
393 | 393 | $res = $dbr->select( 'thread', '*', array( 'thread_ancestor' => $thread_ids ), |
394 | 394 | __METHOD__ ); |
395 | | - |
396 | | - while( $row = $dbr->fetchObject($res) ) { |
| 395 | + |
| 396 | + while ( $row = $dbr->fetchObject( $res ) ) { |
397 | 397 | // Grab page data while we're here. |
398 | | - if ($row->thread_root) |
| 398 | + if ( $row->thread_root ) |
399 | 399 | $pageIds[] = $row->thread_root; |
400 | | - if ($row->thread_summary_page) |
| 400 | + if ( $row->thread_summary_page ) |
401 | 401 | $pageIds[] = $row->thread_summary_page; |
402 | | - |
| 402 | + |
403 | 403 | $all_thread_rows[] = $row; |
404 | | - |
| 404 | + |
405 | 405 | if ( !isset( self::$replyCacheById[$row->thread_id] ) ) { |
406 | 406 | self::$replyCacheById[$row->thread_id] = array(); |
407 | 407 | } |
408 | 408 | } |
409 | 409 | } |
410 | | - |
411 | | - // Preload page data (restrictions, and preload Article object with everything from |
| 410 | + |
| 411 | + // Preload page data (restrictions, and preload Article object with everything from |
412 | 412 | // the page table. Also, precache the title and article objects for pulling later. |
413 | 413 | $articlesById = array(); |
414 | | - if ( count($pageIds) ) { |
| 414 | + if ( count( $pageIds ) ) { |
415 | 415 | // Pull restriction info. Needs to come first because otherwise it's done per |
416 | 416 | // page by loadPageData. |
417 | 417 | $restrictionRows = array_fill_keys( $pageIds, array() ); |
418 | 418 | $res = $dbr->select( 'page_restrictions', '*', array( 'pr_page' => $pageIds ), |
419 | 419 | __METHOD__ ); |
420 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 420 | + while ( $row = $dbr->fetchObject( $res ) ) { |
421 | 421 | $restrictionRows[$row->pr_page][] = $row; |
422 | 422 | } |
423 | | - |
| 423 | + |
424 | 424 | $res = $dbr->select( 'page', '*', array( 'page_id' => $pageIds ), __METHOD__ ); |
425 | | - |
426 | | - while( $row = $dbr->fetchObject( $res ) ) { |
| 425 | + |
| 426 | + while ( $row = $dbr->fetchObject( $res ) ) { |
427 | 427 | $t = Title::newFromRow( $row ); |
428 | | - |
| 428 | + |
429 | 429 | if ( isset( $restrictionRows[$t->getArticleId()] ) ) { |
430 | 430 | $t->loadRestrictionsFromRows( $restrictionRows[$t->getArticleId()], |
431 | 431 | $row->page_restrictions ); |
432 | 432 | } |
433 | | - |
| 433 | + |
434 | 434 | $article = new Article_LQT_Compat( $t ); |
435 | 435 | $article->loadPageData( $row ); |
436 | | - |
| 436 | + |
437 | 437 | self::$titleCacheById[$t->getArticleId()] = $t; |
438 | 438 | $articlesById[$article->getId()] = $article; |
439 | | - |
440 | | - if ( count(self::$titleCacheById) > 10000 ) { |
| 439 | + |
| 440 | + if ( count( self::$titleCacheById ) > 10000 ) { |
441 | 441 | self::$titleCacheById = array(); |
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
445 | | - |
| 445 | + |
446 | 446 | // For every thread we have a row object for, load a Thread object, add the user and |
447 | 447 | // user talk pages to a link batch, cache the relevant user id/name pair, and |
448 | 448 | // populate the reply cache. |
449 | | - foreach( $all_thread_rows as $row ) { |
| 449 | + foreach ( $all_thread_rows as $row ) { |
450 | 450 | $thread = new Thread( $row, null ); |
451 | | - |
452 | | - if ( isset($articlesById[$thread->rootId]) ) |
| 451 | + |
| 452 | + if ( isset( $articlesById[$thread->rootId] ) ) |
453 | 453 | $thread->root = $articlesById[$thread->rootId]; |
454 | | - |
| 454 | + |
455 | 455 | Threads::$cache_by_id[$row->thread_id] = $thread; |
456 | | - |
| 456 | + |
457 | 457 | // User cache data |
458 | 458 | $t = Title::makeTitleSafe( NS_USER, $row->thread_author_name ); |
459 | 459 | $linkBatch->addObj( $t ); |
460 | 460 | $t = Title::makeTitleSafe( NS_USER_TALK, $row->thread_author_name ); |
461 | 461 | $linkBatch->addObj( $t ); |
462 | | - |
| 462 | + |
463 | 463 | User::$idCacheByName[$row->thread_author_name] = $row->thread_author_id; |
464 | | - |
| 464 | + |
465 | 465 | if ( $row->thread_parent ) { |
466 | 466 | self::$replyCacheById[$row->thread_parent][$row->thread_id] = $thread; |
467 | 467 | } |
468 | 468 | } |
469 | | - |
| 469 | + |
470 | 470 | // Pull link batch data. |
471 | 471 | $linkBatch->execute(); |
472 | | - |
| 472 | + |
473 | 473 | $threads = array(); |
474 | | - |
| 474 | + |
475 | 475 | // Fill and return an array with the threads that were actually requested. |
476 | | - foreach( $rows as $row ) { |
| 476 | + foreach ( $rows as $row ) { |
477 | 477 | $threads[$row->thread_id] = Threads::$cache_by_id[$row->thread_id]; |
478 | 478 | } |
479 | | - |
| 479 | + |
480 | 480 | return $threads; |
481 | 481 | } |
482 | | - |
| 482 | + |
483 | 483 | /** |
484 | 484 | * Return the User object representing the author of the first revision |
485 | 485 | * (or null, if the database is screwed up). |
486 | 486 | */ |
487 | 487 | function loadOriginalAuthorFromRevision( ) { |
488 | 488 | $this->dieIfHistorical(); |
489 | | - |
| 489 | + |
490 | 490 | $dbr = wfGetDB( DB_SLAVE ); |
491 | | - |
| 491 | + |
492 | 492 | $article = $this->root(); |
493 | 493 | |
494 | | - $line = $dbr->selectRow( 'revision', |
495 | | - 'rev_user_text', |
496 | | - array( 'rev_page' => $article->getID() ), |
497 | | - __METHOD__, |
498 | | - array( |
499 | | - 'ORDER BY' => 'rev_timestamp', |
500 | | - 'LIMIT' => '1' |
501 | | - ) ); |
| 494 | + $line = $dbr->selectRow( |
| 495 | + 'revision', |
| 496 | + 'rev_user_text', |
| 497 | + array( 'rev_page' => $article->getID() ), |
| 498 | + __METHOD__, |
| 499 | + array( |
| 500 | + 'ORDER BY' => 'rev_timestamp', |
| 501 | + 'LIMIT' => '1' |
| 502 | + ) |
| 503 | + ); |
| 504 | + |
502 | 505 | if ( $line ) |
503 | 506 | return User::newFromName( $line->rev_user_text, false ); |
504 | 507 | else |
505 | 508 | return null; |
506 | 509 | } |
507 | | - |
| 510 | + |
508 | 511 | // Lazy updates done whenever a thread is loaded. |
509 | 512 | // Much easier than running a long-running maintenance script. |
510 | 513 | function doLazyUpdates( ) { |
511 | 514 | if ( $this->isHistorical() ) |
512 | 515 | return; // Don't do lazy updates on stored historical threads. |
513 | | - |
| 516 | + |
514 | 517 | // This is an invocation guard to avoid infinite recursion when fixing a |
515 | 518 | // missing ancestor. |
516 | 519 | static $doingUpdates = false; |
517 | | - if ($doingUpdates) return; |
| 520 | + if ( $doingUpdates ) return; |
518 | 521 | $doingUpdates = true; |
519 | | - |
| 522 | + |
520 | 523 | // Fix missing ancestry information. |
521 | 524 | // (there was a bug where this was not saved properly) |
522 | | - if ($this->parentId &&!$this->ancestorId) { |
| 525 | + if ( $this->parentId && !$this->ancestorId ) { |
523 | 526 | $this->fixMissingAncestor(); |
524 | 527 | } |
525 | | - |
| 528 | + |
526 | 529 | $ancestor = $this->topmostThread(); |
527 | | - |
| 530 | + |
528 | 531 | $set = array(); |
529 | | - |
| 532 | + |
530 | 533 | // Fix missing subject information |
531 | 534 | // (this information only started to be added later) |
532 | 535 | if ( !$this->subject && $this->root() ) { |
533 | 536 | $detectedSubject = $this->root()->getTitle()->getText(); |
534 | 537 | $parts = self::splitIncrementFromSubject( $detectedSubject ); |
535 | | - |
| 538 | + |
536 | 539 | $this->subject = $detectedSubject = $parts[1]; |
537 | | - |
| 540 | + |
538 | 541 | // Update in the DB |
539 | 542 | $set['thread_subject'] = $detectedSubject; |
540 | 543 | } |
541 | | - |
| 544 | + |
542 | 545 | // Fix inconsistent subject information |
543 | 546 | // (in some intermediate versions this was not updated when the subject was changed) |
544 | | - if ($this->subject() != $ancestor->subject()) { |
| 547 | + if ( $this->subject() != $ancestor->subject() ) { |
545 | 548 | $set['thread_subject'] = $ancestor->subject(); |
546 | | - |
| 549 | + |
547 | 550 | $this->subject = $ancestor->subject(); |
548 | 551 | } |
549 | | - |
| 552 | + |
550 | 553 | // Fix missing authorship information |
551 | 554 | // (this information only started to be added later) |
552 | 555 | if ( !$this->authorName ) { |
553 | 556 | $author = $this->loadOriginalAuthorFromRevision(); |
554 | | - |
| 557 | + |
555 | 558 | $this->authorId = $author->getId(); |
556 | 559 | $this->authorName = $author->getName(); |
557 | | - |
| 560 | + |
558 | 561 | $set['thread_author_name'] = $this->authorName; |
559 | 562 | $set['thread_author_id'] = $this->authorId; |
560 | 563 | } |
561 | | - |
562 | | - //Check for article being in subject, not talk namespace. |
563 | | - //If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant |
| 564 | + |
| 565 | + // Check for article being in subject, not talk namespace. |
| 566 | + // If the page is non-LiquidThreads and it's in subject-space, we'll assume it's meant |
564 | 567 | // to be on the corresponding talk page, but only if the talk-page is a LQT page. |
565 | | - //(Previous versions stored the subject page, for some totally bizarre reason) |
| 568 | + // (Previous versions stored the subject page, for some totally bizarre reason) |
566 | 569 | // Old versions also sometimes store the thread page for trace threads as the |
567 | 570 | // article, not as the root. |
568 | 571 | // Trying not to exacerbate this by moving it to be the 'Thread talk' page. |
— | — | @@ -571,99 +574,103 @@ |
572 | 575 | $articleTitle->getNamespace() != NS_LQT_THREAD ) { |
573 | 576 | $newTitle = $articleTitle->getTalkPage(); |
574 | 577 | $newArticle = new Article_LQT_Compat( $newTitle ); |
575 | | - |
| 578 | + |
576 | 579 | $set['thread_article_namespace'] = $newTitle->getNamespace(); |
577 | 580 | $set['thread_article_title'] = $newTitle->getDbKey(); |
578 | | - |
| 581 | + |
579 | 582 | $this->articleNamespace = $newTitle->getNamespace(); |
580 | 583 | $this->articleTitle = $newTitle->getDbKey(); |
581 | | - |
| 584 | + |
582 | 585 | $this->article = $newArticle; |
583 | 586 | } |
584 | | - |
| 587 | + |
585 | 588 | // Check for article corruption from incomplete thread moves. |
586 | 589 | // (thread moves only updated this on immediate replies, not replies to replies etc) |
587 | | - if (! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) { |
| 590 | + if ( ! $ancestor->article()->getTitle()->equals( $this->article()->getTitle() ) ) { |
588 | 591 | $title = $ancestor->article()->getTitle(); |
589 | 592 | $set['thread_article_namespace'] = $title->getNamespace(); |
590 | 593 | $set['thread_article_title'] = $title->getDbKey(); |
591 | | - |
| 594 | + |
592 | 595 | $this->articleNamespace = $title->getNamespace(); |
593 | 596 | $this->articleTitle = $title->getDbKey(); |
594 | | - |
| 597 | + |
595 | 598 | $this->article = $ancestor->article(); |
596 | 599 | } |
597 | | - |
598 | | - if ( count($set) ) { |
| 600 | + |
| 601 | + if ( count( $set ) ) { |
599 | 602 | $dbw = wfGetDB( DB_MASTER ); |
600 | | - |
| 603 | + |
601 | 604 | $dbw->update( 'thread', $set, array( 'thread_id' => $this->id() ), __METHOD__ ); |
602 | 605 | } |
603 | | - |
| 606 | + |
604 | 607 | // Done |
605 | 608 | $doingUpdates = false; |
606 | 609 | } |
607 | 610 | |
608 | 611 | function addReply( $thread ) { |
609 | 612 | $thread->setSuperThread( $this ); |
610 | | - |
611 | | - if ( is_array($this->replies) ) { |
| 613 | + |
| 614 | + if ( is_array( $this->replies ) ) { |
612 | 615 | $this->replies[$thread->id()] = $thread; |
613 | 616 | } else { |
614 | 617 | $this->replies(); |
615 | 618 | $this->replies[$thread->id()] = $thread; |
616 | 619 | } |
617 | 620 | } |
618 | | - |
| 621 | + |
619 | 622 | function removeReply( $thread ) { |
620 | | - if ( is_object($thread) ) { |
| 623 | + if ( is_object( $thread ) ) { |
621 | 624 | $thread = $thread->id(); |
622 | 625 | } |
623 | | - |
| 626 | + |
624 | 627 | $this->replies(); |
625 | | - |
| 628 | + |
626 | 629 | unset( $thread->replies[$thread] ); |
627 | 630 | } |
628 | | - |
| 631 | + |
629 | 632 | function replies() { |
630 | | - if ( !is_null($this->replies) ) { |
| 633 | + if ( !is_null( $this->replies ) ) { |
631 | 634 | return $this->replies; |
632 | 635 | } |
633 | | - |
| 636 | + |
634 | 637 | $this->dieIfHistorical(); |
635 | | - |
| 638 | + |
636 | 639 | // Check cache |
637 | 640 | if ( isset( self::$replyCacheById[$this->id()] ) ) { |
638 | 641 | return $this->replies = self::$replyCacheById[$this->id()]; |
639 | 642 | } |
640 | | - |
| 643 | + |
641 | 644 | $this->replies = array(); |
642 | | - |
| 645 | + |
643 | 646 | $dbr = wfGetDB( DB_SLAVE ); |
644 | | - |
645 | | - $res = $dbr->select( 'thread', '*', |
646 | | - array( 'thread_parent' => $this->id() ), __METHOD__ ); |
647 | | - |
| 647 | + |
| 648 | + $res = $dbr->select( |
| 649 | + 'thread', |
| 650 | + '*', |
| 651 | + array( 'thread_parent' => $this->id() ), |
| 652 | + __METHOD__ |
| 653 | + ); |
| 654 | + |
648 | 655 | $rows = array(); |
649 | | - while ( $row = $dbr->fetchObject($res) ) { |
| 656 | + while ( $row = $dbr->fetchObject( $res ) ) { |
650 | 657 | $rows[] = $row; |
651 | 658 | } |
652 | | - |
| 659 | + |
653 | 660 | $this->replies = Thread::bulkLoad( $rows ); |
654 | | - |
| 661 | + |
655 | 662 | return $this->replies; |
656 | 663 | } |
657 | 664 | |
658 | 665 | function setSuperthread( $thread ) { |
659 | | - if ($thread == null) { |
| 666 | + if ( $thread == null ) { |
660 | 667 | $this->parentId = null; |
661 | 668 | $this->ancestorId = 0; |
662 | 669 | return; |
663 | 670 | } |
664 | | - |
| 671 | + |
665 | 672 | $this->parentId = $thread->id(); |
666 | 673 | $this->superthread = $thread; |
667 | | - |
| 674 | + |
668 | 675 | if ( $thread->isTopmostThread() ) { |
669 | 676 | $this->ancestorId = $thread->id(); |
670 | 677 | $this->ancestor = $thread; |
— | — | @@ -689,23 +696,23 @@ |
690 | 697 | function topmostThread() { |
691 | 698 | if ( $this->isTopmostThread() ) { |
692 | 699 | return $this->ancestor = $this; |
693 | | - } elseif ($this->ancestor) { |
| 700 | + } elseif ( $this->ancestor ) { |
694 | 701 | return $this->ancestor; |
695 | 702 | } else { |
696 | 703 | $this->dieIfHistorical(); |
697 | | - |
| 704 | + |
698 | 705 | $thread = Threads::withId( $this->ancestorId ); |
699 | 706 | |
700 | | - if (!$thread) { |
| 707 | + if ( !$thread ) { |
701 | 708 | $thread = $this->fixMissingAncestor(); |
702 | 709 | } |
703 | | - |
| 710 | + |
704 | 711 | $this->ancestor = $thread; |
705 | | - |
| 712 | + |
706 | 713 | return $thread; |
707 | 714 | } |
708 | 715 | } |
709 | | - |
| 716 | + |
710 | 717 | function setAncestor( $newAncestor ) { |
711 | 718 | if ( is_object( $newAncestor ) ) { |
712 | 719 | $this->ancestorId = $newAncestor->id(); |
— | — | @@ -718,19 +725,23 @@ |
719 | 726 | // Fix the corruption by repeatedly grabbing the parent until we hit the topmost thread. |
720 | 727 | function fixMissingAncestor() { |
721 | 728 | $thread = $this; |
722 | | - |
| 729 | + |
723 | 730 | $this->dieIfHistorical(); |
724 | | - |
| 731 | + |
725 | 732 | while ( !$thread->isTopmostThread() ) { |
726 | 733 | $thread = $thread->superthread(); |
727 | 734 | } |
728 | | - |
| 735 | + |
729 | 736 | $this->ancestorId = $thread->id(); |
730 | | - |
| 737 | + |
731 | 738 | $dbw = wfGetDB( DB_MASTER ); |
732 | | - $dbw->update( 'thread', array( 'thread_ancestor' => $thread->id() ), |
733 | | - array( 'thread_id' => $this->id() ), __METHOD__ ); |
734 | | - |
| 739 | + $dbw->update( |
| 740 | + 'thread', |
| 741 | + array( 'thread_ancestor' => $thread->id() ), |
| 742 | + array( 'thread_id' => $this->id() ), |
| 743 | + __METHOD__ |
| 744 | + ); |
| 745 | + |
735 | 746 | return $thread; |
736 | 747 | } |
737 | 748 | |
— | — | @@ -745,14 +756,14 @@ |
746 | 757 | $this->articleTitle = $a->getTitle()->getDBkey(); |
747 | 758 | $this->touch(); |
748 | 759 | } |
749 | | - |
| 760 | + |
750 | 761 | function touch() { |
751 | 762 | // Nothing here yet |
752 | 763 | } |
753 | 764 | |
754 | 765 | function article() { |
755 | 766 | if ( $this->article ) return $this->article; |
756 | | - |
| 767 | + |
757 | 768 | if ( !is_null( $this->articleId ) ) { |
758 | 769 | $title = Title::newFromID( $this->articleId ); |
759 | 770 | if ( $title ) { |
— | — | @@ -780,19 +791,19 @@ |
781 | 792 | function root( ) { |
782 | 793 | if ( !$this->rootId ) return null; |
783 | 794 | if ( !$this->root ) { |
784 | | - if ( isset(self::$articleCacheById[$this->rootId]) ) { |
| 795 | + if ( isset( self::$articleCacheById[$this->rootId] ) ) { |
785 | 796 | $this->root = self::$articleCacheById[$this->rootId]; |
786 | 797 | return $this->root; |
787 | 798 | } |
788 | | - |
| 799 | + |
789 | 800 | if ( isset( self::$titleCacheById[$this->rootId] ) ) { |
790 | 801 | $title = self::$titleCacheById[$this->rootId]; |
791 | 802 | } else { |
792 | 803 | $title = Title::newFromID( $this->rootId ); |
793 | 804 | } |
794 | | - |
795 | | - if (!$title) return null; |
796 | | - |
| 805 | + |
| 806 | + if ( !$title ) return null; |
| 807 | + |
797 | 808 | $this->root = new Article_LQT_Compat( $title ); |
798 | 809 | } |
799 | 810 | return $this->root; |
— | — | @@ -805,20 +816,19 @@ |
806 | 817 | function summary() { |
807 | 818 | if ( !$this->summaryId ) |
808 | 819 | return null; |
809 | | - |
| 820 | + |
810 | 821 | if ( !$this->summary ) { |
811 | 822 | $title = Title::newFromID( $this->summaryId ); |
812 | | - |
813 | | - if (!$title) { |
814 | | - wfDebug( __METHOD__.": supposed summary doesn't exist" ); |
| 823 | + |
| 824 | + if ( !$title ) { |
| 825 | + wfDebug( __METHOD__ . ": supposed summary doesn't exist" ); |
815 | 826 | $this->summaryId = null; |
816 | 827 | return null; |
817 | 828 | } |
818 | | - |
| 829 | + |
819 | 830 | $this->summary = new Article_LQT_Compat( $title ); |
| 831 | + } |
820 | 832 | |
821 | | - } |
822 | | - |
823 | 833 | return $this->summary; |
824 | 834 | } |
825 | 835 | |
— | — | @@ -848,7 +858,7 @@ |
849 | 859 | function subject() { |
850 | 860 | return $this->subject; |
851 | 861 | } |
852 | | - |
| 862 | + |
853 | 863 | function setSubject( $subject ) { |
854 | 864 | $this->subject = $subject; |
855 | 865 | } |
— | — | @@ -883,8 +893,8 @@ |
884 | 894 | function type() { |
885 | 895 | return $this->type; |
886 | 896 | } |
887 | | - |
888 | | - function setType($t) { |
| 897 | + |
| 898 | + function setType( $t ) { |
889 | 899 | $this->type = $t; |
890 | 900 | } |
891 | 901 | |
— | — | @@ -892,7 +902,7 @@ |
893 | 903 | $rev = Revision::newFromId( $this->root()->getLatest() ); |
894 | 904 | $rtitle = Title::newFromRedirect( $rev->getRawText() ); |
895 | 905 | if ( !$rtitle ) return null; |
896 | | - |
| 906 | + |
897 | 907 | $this->dieIfHistorical(); |
898 | 908 | $rthread = Threads::withRoot( new Article_LQT_Compat( $rtitle ) ); |
899 | 909 | return $rthread; |
— | — | @@ -916,98 +926,102 @@ |
917 | 927 | $result = $parent_restrictions; |
918 | 928 | return false; |
919 | 929 | } |
| 930 | + } |
920 | 931 | |
921 | | - } |
922 | | - |
923 | 932 | function getAnchorName() { |
924 | 933 | return "lqt_thread_{$this->id()}"; |
925 | 934 | } |
926 | | - |
| 935 | + |
927 | 936 | function updateHistory() { |
928 | 937 | // $dbr = wfGetDB( DB_SLAVE ); |
929 | | -// |
930 | | -// $res = $dbr->select( 'historical_thread', '*', |
931 | | -// array( 'hthread_id' => $this->id() ), |
932 | | -// __METHOD__, |
933 | | -// array( 'ORDER BY' => 'hthread_revision ASC' ) ); |
934 | | -// |
| 938 | +// |
| 939 | +// $res = $dbr->select( |
| 940 | +// 'historical_thread', |
| 941 | +// '*', |
| 942 | +// array( 'hthread_id' => $this->id() ), |
| 943 | +// __METHOD__, |
| 944 | +// array( 'ORDER BY' => 'hthread_revision ASC' ) |
| 945 | +// ); |
| 946 | +// |
935 | 947 | // foreach( $row as $res ) { |
936 | 948 | // $historical_thread = HistoricalThread::fromTextRepresentation( $row->hthread_content ); |
937 | | -// |
938 | | -// // Insert a revision into the database. |
939 | | -// $rev = ThreadRevision::create( $historical_thread, |
940 | | -// $historical_thread->changeType(), |
941 | | -// $historical_thread->changeObject(), |
942 | | -// $historical_thread->changeComment(), |
943 | | -// $historical_thread->changeUser(), |
944 | | -// $historical_thread->modified() ); |
| 949 | +// |
| 950 | +// // Insert a revision into the database. |
| 951 | +// $rev = ThreadRevision::create( |
| 952 | +// $historical_thread, |
| 953 | +// $historical_thread->changeType(), |
| 954 | +// $historical_thread->changeObject(), |
| 955 | +// $historical_thread->changeComment(), |
| 956 | +// $historical_thread->changeUser(), |
| 957 | +// $historical_thread->modified() |
| 958 | +// ); |
945 | 959 | // } |
946 | 960 | } |
947 | | - |
| 961 | + |
948 | 962 | function setAuthor( $user ) { |
949 | 963 | $this->authorId = $user->getId(); |
950 | 964 | $this->authorName = $user->getName(); |
951 | 965 | } |
952 | | - |
| 966 | + |
953 | 967 | // Load all lazy-loaded data in prep for (e.g.) serialization. |
954 | 968 | function loadAllData() { |
955 | 969 | // Make sure superthread and topmost thread are loaded. |
956 | 970 | $this->superthread(); |
957 | 971 | $this->topmostThread(); |
958 | | - |
| 972 | + |
959 | 973 | // Make sure replies, and all the data therein, is loaded. |
960 | | - foreach( $this->replies() as $reply ) { |
| 974 | + foreach ( $this->replies() as $reply ) { |
961 | 975 | $reply->loadAllData(); |
962 | 976 | } |
963 | 977 | } |
964 | | - |
| 978 | + |
965 | 979 | // On serialization, load all data because it will be different in the DB when we wake up. |
966 | 980 | function __sleep() { |
967 | | - |
| 981 | + |
968 | 982 | $this->loadAllData(); |
969 | | - |
| 983 | + |
970 | 984 | $fields = array_keys( get_object_vars( $this ) ); |
971 | | - |
| 985 | + |
972 | 986 | // Filter out article objects, there be dragons (or unserialization problems) |
973 | 987 | $fields = array_diff( $fields, array( 'root', 'article', 'summary', 'sleeping' ) ); |
974 | | - |
| 988 | + |
975 | 989 | return $fields; |
976 | 990 | } |
977 | | - |
| 991 | + |
978 | 992 | function __wakeup() { |
979 | 993 | // Mark as historical. |
980 | 994 | $this->isHistorical = true; |
981 | 995 | } |
982 | | - |
| 996 | + |
983 | 997 | // This is a safety valve that makes sure that the DB is NEVER touched by a historical |
984 | 998 | // thread (even for reading, because the data will be out of date). |
985 | 999 | function dieIfHistorical() { |
986 | | - if ($this->isHistorical()) { |
| 1000 | + if ( $this->isHistorical() ) { |
987 | 1001 | throw new MWException( "Attempted write or DB operation on historical thread" ); |
988 | 1002 | } |
989 | 1003 | } |
990 | | - |
| 1004 | + |
991 | 1005 | function rootRevision() { |
992 | | - if ( !$this->isHistorical() || !isset($this->topmostThread()->threadRevision) ) { |
| 1006 | + if ( !$this->isHistorical() || !isset( $this->topmostThread()->threadRevision ) ) { |
993 | 1007 | return null; |
994 | 1008 | } |
995 | | - |
| 1009 | + |
996 | 1010 | $dbr = wfGetDB( DB_SLAVE ); |
997 | | - |
| 1011 | + |
998 | 1012 | $revision = $this->topmostThread()->threadRevision; |
999 | 1013 | $timestamp = $dbr->timestamp( $revision->getTimestamp() ); |
1000 | | - |
| 1014 | + |
1001 | 1015 | $conds = array( |
1002 | | - 'rev_timestamp<='.$dbr->addQuotes( $timestamp ), |
| 1016 | + 'rev_timestamp<=' . $dbr->addQuotes( $timestamp ), |
1003 | 1017 | 'page_namespace' => $this->root()->getTitle()->getNamespace(), |
1004 | 1018 | 'page_title' => $this->root()->getTitle()->getDBKey(), |
1005 | 1019 | ); |
1006 | | - |
| 1020 | + |
1007 | 1021 | $join_conds = array( 'page' => array( 'JOIN', 'rev_page=page_id' ) ); |
1008 | | - |
| 1022 | + |
1009 | 1023 | $row = $dbr->selectRow( array( 'revision', 'page' ), '*', $conds, __METHOD__, |
1010 | 1024 | array( 'ORDER BY' => 'rev_timestamp DESC' ), $join_conds ); |
1011 | | - |
| 1025 | + |
1012 | 1026 | return $row->rev_id; |
1013 | 1027 | } |
1014 | 1028 | } |
Index: trunk/extensions/LiquidThreads/classes/HistoricalThread.php |
— | — | @@ -2,7 +2,6 @@ |
3 | 3 | if ( !defined( 'MEDIAWIKI' ) ) die; |
4 | 4 | |
5 | 5 | class HistoricalThread extends Thread { |
6 | | - |
7 | 6 | /* Information about what changed in this revision. */ |
8 | 7 | protected $changeType; |
9 | 8 | protected $changeObject; |
— | — | @@ -57,12 +56,12 @@ |
58 | 57 | function isHistorical() { |
59 | 58 | return true; |
60 | 59 | } |
61 | | - |
62 | 60 | |
| 61 | + |
63 | 62 | function changeType() { |
64 | 63 | return $this->changeType; |
65 | 64 | } |
66 | | - |
| 65 | + |
67 | 66 | function changeObject() { |
68 | 67 | return $this->replyWithId( $this->changeObject ); |
69 | 68 | } |
— | — | @@ -95,7 +94,7 @@ |
96 | 95 | function changeComment() { |
97 | 96 | return $this->changeComment; |
98 | 97 | } |
99 | | - |
| 98 | + |
100 | 99 | function setChangeUser( $user ) { |
101 | 100 | $this->changeUser = $user->getId(); |
102 | 101 | $this->changeUserText = $user->getName(); |
Index: trunk/extensions/LiquidThreads/classes/Threads.php |
— | — | @@ -3,7 +3,6 @@ |
4 | 4 | |
5 | 5 | /** Module of factory methods. */ |
6 | 6 | class Threads { |
7 | | - |
8 | 7 | const TYPE_NORMAL = 0; |
9 | 8 | const TYPE_MOVED = 1; |
10 | 9 | const TYPE_DELETED = 2; |
— | — | @@ -21,7 +20,7 @@ |
22 | 21 | const CHANGE_MERGED_FROM = 10; |
23 | 22 | const CHANGE_MERGED_TO = 11; |
24 | 23 | const CHANGE_SPLIT_FROM = 12; |
25 | | - |
| 24 | + |
26 | 25 | static $VALID_CHANGE_TYPES = array( self::CHANGE_EDITED_SUMMARY, self::CHANGE_EDITED_ROOT, |
27 | 26 | self::CHANGE_REPLY_CREATED, self::CHANGE_NEW_THREAD, self::CHANGE_DELETED, self::CHANGE_UNDELETED, |
28 | 27 | self::CHANGE_MOVED_TALKPAGE, self::CHANGE_SPLIT, self::CHANGE_EDITED_SUBJECT, |
— | — | @@ -58,26 +57,26 @@ |
59 | 58 | } |
60 | 59 | } |
61 | 60 | } |
62 | | - |
| 61 | + |
63 | 62 | static function loadFromResult( $res, $db ) { |
64 | 63 | $rows = array(); |
65 | | - |
66 | | - while( $row = $db->fetchObject( $res ) ) { |
| 64 | + |
| 65 | + while ( $row = $db->fetchObject( $res ) ) { |
67 | 66 | $rows[] = $row; |
68 | 67 | } |
69 | | - |
| 68 | + |
70 | 69 | return Thread::bulkLoad( $rows ); |
71 | 70 | } |
72 | 71 | |
73 | 72 | static function where( $where, $options = array() ) { |
74 | 73 | global $wgDBprefix; |
75 | 74 | $dbr = wfGetDB( DB_SLAVE ); |
76 | | - |
| 75 | + |
77 | 76 | $res = $dbr->select( 'thread', '*', $where, __METHOD__, $options ); |
78 | 77 | $threads = Threads::loadFromResult( $res, $dbr ); |
79 | 78 | |
80 | 79 | foreach ( $threads as $thread ) { |
81 | | - if ($thread->root()) { |
| 80 | + if ( $thread->root() ) { |
82 | 81 | self::$cache_by_root[$thread->root()->getID()] = $thread; |
83 | 82 | } |
84 | 83 | self::$cache_by_id[$thread->id()] = $thread; |
— | — | @@ -93,7 +92,7 @@ |
94 | 93 | |
95 | 94 | private static function assertSingularity( $threads, $attribute, $value ) { |
96 | 95 | if ( count( $threads ) == 0 ) { return null; } |
97 | | - if ( count( $threads ) == 1 ) { return array_pop($threads); } |
| 96 | + if ( count( $threads ) == 1 ) { return array_pop( $threads ); } |
98 | 97 | if ( count( $threads ) > 1 ) { |
99 | 98 | Threads::databaseError( "More than one thread with $attribute = $value." ); |
100 | 99 | return null; |
— | — | @@ -126,7 +125,7 @@ |
127 | 126 | return self::$cache_by_id[$id]; |
128 | 127 | } |
129 | 128 | $ts = Threads::where( array( 'thread_id' => $id ) ); |
130 | | - |
| 129 | + |
131 | 130 | return self::assertSingularity( $ts, 'thread_id', $id ); |
132 | 131 | } |
133 | 132 | |
— | — | @@ -136,78 +135,78 @@ |
137 | 136 | } |
138 | 137 | |
139 | 138 | /** |
140 | | - * Horrible, horrible! |
141 | | - * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. |
142 | | - * Returned as an array of months in the format yyyymm |
143 | | - */ |
| 139 | + * Horrible, horrible! |
| 140 | + * List of months in which there are >0 threads, suitable for threadsOfArticleInMonth. |
| 141 | + * Returned as an array of months in the format yyyymm |
| 142 | + */ |
144 | 143 | static function monthsWhereArticleHasThreads( $article ) { |
145 | 144 | // FIXME this probably performs absolutely horribly for pages with lots of threads. |
146 | | - |
| 145 | + |
147 | 146 | $threads = Threads::where( Threads::articleClause( $article ) ); |
148 | 147 | $months = array(); |
149 | | - |
| 148 | + |
150 | 149 | foreach ( $threads as $t ) { |
151 | 150 | $month = substr( $t->modified(), 0, 6 ); |
152 | | - |
| 151 | + |
153 | 152 | $months[$month] = true; |
154 | 153 | } |
155 | | - |
| 154 | + |
156 | 155 | // Some code seems to assume that it's sorted by month, make sure it's true. |
157 | 156 | ksort( $months ); |
158 | | - |
159 | | - return array_keys($months); |
| 157 | + |
| 158 | + return array_keys( $months ); |
160 | 159 | } |
161 | 160 | |
162 | 161 | static function articleClause( $article ) { |
163 | 162 | $dbr = wfGetDB( DB_SLAVE ); |
164 | | - |
| 163 | + |
165 | 164 | $arr = array( 'thread_article_title' => $article->getTitle()->getDBKey(), |
166 | 165 | 'thread_article_namespace' => $article->getTitle()->getNamespace() ); |
167 | | - |
| 166 | + |
168 | 167 | return $dbr->makeList( $arr, LIST_AND ); |
169 | 168 | } |
170 | 169 | |
171 | 170 | static function topLevelClause() { |
172 | 171 | $dbr = wfGetDB( DB_SLAVE ); |
173 | | - |
| 172 | + |
174 | 173 | $arr = array( 'thread_ancestor=thread_id', 'thread_parent' => null ); |
175 | | - |
| 174 | + |
176 | 175 | return $dbr->makeList( $arr, LIST_OR ); |
177 | 176 | } |
178 | | - |
| 177 | + |
179 | 178 | static function scratchTitle() { |
180 | 179 | $token = md5( uniqid( rand(), true ) ); |
181 | 180 | return Title::newFromText( "Thread:$token" ); |
182 | 181 | } |
183 | | - |
| 182 | + |
184 | 183 | static function newThreadTitle( $subject, $article ) { |
185 | 184 | wfLoadExtensionMessages( 'LiquidThreads' ); |
186 | 185 | $subject = $subject ? $subject : wfMsg( 'lqt_nosubject' ); |
187 | | - |
| 186 | + |
188 | 187 | $base = $article->getTitle()->getPrefixedText() . "/$subject"; |
189 | | - |
| 188 | + |
190 | 189 | return self::incrementedTitle( $base, NS_LQT_THREAD ); |
191 | 190 | } |
192 | | - |
| 191 | + |
193 | 192 | static function newSummaryTitle( $t ) { |
194 | 193 | return self::incrementedTitle( $t->title()->getText(), NS_LQT_SUMMARY ); |
195 | 194 | } |
196 | | - |
197 | | - static function newReplyTitle( $thread, $user) { |
| 195 | + |
| 196 | + static function newReplyTitle( $thread, $user ) { |
198 | 197 | $topThread = $thread->topmostThread(); |
199 | | - |
| 198 | + |
200 | 199 | $base = $topThread->title()->getText() . '/' . $user->getName(); |
201 | | - |
| 200 | + |
202 | 201 | return self::incrementedTitle( $base, NS_LQT_THREAD ); |
203 | 202 | } |
204 | | - |
| 203 | + |
205 | 204 | /** Keep trying titles starting with $basename until one is unoccupied. */ |
206 | 205 | public static function incrementedTitle( $basename, $namespace ) { |
207 | 206 | $i = 2; |
208 | | - |
| 207 | + |
209 | 208 | $replacements = array_fill_keys( array( '[', ']', '{', '}', '|' ), '_' ); |
210 | 209 | $basename = strtr( $basename, $replacements ); |
211 | | - |
| 210 | + |
212 | 211 | $t = Title::makeTitleSafe( $namespace, $basename ); |
213 | 212 | while ( !$t || $t->exists() || |
214 | 213 | in_array( $t->getPrefixedDBkey(), self::$occupied_titles ) ) { |
— | — | @@ -215,5 +214,5 @@ |
216 | 215 | $i++; |
217 | 216 | } |
218 | 217 | return $t; |
219 | | - } |
| 218 | + } |
220 | 219 | } |
Index: trunk/extensions/LiquidThreads/classes/View.php |
— | — | @@ -1,11 +1,10 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | | -* @package MediaWiki |
6 | | -* @subpackage LiquidThreads |
7 | | -* @author David McCabe <davemccabe@gmail.com> |
8 | | -* @licence GPL2 |
9 | | -*/ |
| 4 | + * @package MediaWiki |
| 5 | + * @subpackage LiquidThreads |
| 6 | + * @author David McCabe <davemccabe@gmail.com> |
| 7 | + * @licence GPL2 |
| 8 | + */ |
10 | 9 | |
11 | 10 | if ( !defined( 'MEDIAWIKI' ) ) { |
12 | 11 | echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" ); |
— | — | @@ -25,7 +24,7 @@ |
26 | 25 | public $threadNestingLevel = 0; |
27 | 26 | |
28 | 27 | protected $sort_order = LQT_NEWEST_CHANGES; |
29 | | - |
| 28 | + |
30 | 29 | static $stylesAndScriptsDone = false; |
31 | 30 | |
32 | 31 | function __construct( &$output, &$article, &$title, &$user, &$request ) { |
— | — | @@ -42,10 +41,10 @@ |
43 | 42 | $this->headerLevel = $int; |
44 | 43 | } |
45 | 44 | |
46 | | - /************************* |
47 | | - * (1) linking to liquidthreads pages and |
48 | | - * (2) figuring out what page you're on and what you need to do. |
49 | | - *************************/ |
| 45 | + /** |
| 46 | + * (1) linking to liquidthreads pages and |
| 47 | + * (2) figuring out what page you're on and what you need to do. |
| 48 | + */ |
50 | 49 | |
51 | 50 | function methodAppliesToThread( $method, $thread ) { |
52 | 51 | return $this->request->getVal( 'lqt_method' ) == $method && |
— | — | @@ -57,64 +56,65 @@ |
58 | 57 | |
59 | 58 | static function permalinkUrl( $thread, $method = null, $operand = null, |
60 | 59 | $uquery = array() ) { |
61 | | - list ($title, $query) = self::permalinkData( $thread, $method, $operand ); |
62 | | - |
| 60 | + list ( $title, $query ) = self::permalinkData( $thread, $method, $operand ); |
| 61 | + |
63 | 62 | $query = array_merge( $query, $uquery ); |
64 | | - |
| 63 | + |
65 | 64 | $queryString = wfArrayToCGI( $query ); |
66 | | - |
| 65 | + |
67 | 66 | return $title->getFullUrl( $queryString ); |
68 | 67 | } |
69 | | - |
| 68 | + |
70 | 69 | /** Gets an array of (title, query-parameters) for a permalink **/ |
71 | 70 | static function permalinkData( $thread, $method = null, $operand = null ) { |
72 | 71 | $query = array(); |
73 | | - |
74 | | - if ($method) { |
| 72 | + |
| 73 | + if ( $method ) { |
75 | 74 | $query['lqt_method'] = $method; |
76 | 75 | } |
77 | | - if ($operand) { |
| 76 | + if ( $operand ) { |
78 | 77 | $query['lqt_operand'] = $operand; |
79 | 78 | } |
80 | | - |
| 79 | + |
81 | 80 | return array( $thread->root()->getTitle(), $query ); |
82 | 81 | } |
83 | 82 | |
84 | 83 | /* This is used for action=history so that the history tab works, which is |
85 | | - why we break the lqt_method paradigm. */ |
| 84 | + * why we break the lqt_method paradigm. |
| 85 | + */ |
86 | 86 | static function permalinkUrlWithQuery( $thread, $query ) { |
87 | | - if ( !is_array($query) ) { |
| 87 | + if ( !is_array( $query ) ) { |
88 | 88 | $query = wfCGIToArray( $query ); |
89 | 89 | } |
90 | | - |
| 90 | + |
91 | 91 | return self::permalinkUrl( $thread, null, null, $query ); |
92 | 92 | } |
93 | | - |
| 93 | + |
94 | 94 | static function permalink( $thread, $text = null, $method = null, $operand = null, |
95 | 95 | $sk = null, $attribs = array(), $uquery = array() ) { |
96 | | - if ( is_null($sk) ) { |
| 96 | + if ( is_null( $sk ) ) { |
97 | 97 | global $wgUser; |
98 | 98 | $sk = $wgUser->getSkin(); |
99 | 99 | } |
100 | | - |
| 100 | + |
101 | 101 | list( $title, $query ) = self::permalinkData( $thread, $method, $operand ); |
102 | | - |
| 102 | + |
103 | 103 | $query = array_merge( $query, $uquery ); |
104 | | - |
| 104 | + |
105 | 105 | return $sk->link( $title, $text, $attribs, $query ); |
106 | 106 | } |
107 | | - |
| 107 | + |
108 | 108 | static function diffQuery( $thread, $revision ) { |
109 | 109 | $changed_thread = $revision->getChangeObject(); |
110 | 110 | $curr_rev_id = $revision->getThreadObj()->rootRevision(); |
111 | 111 | $curr_rev = Revision::newFromId( $curr_rev_id ); |
112 | 112 | $prev_rev = $curr_rev->getPrevious(); |
113 | 113 | $oldid = $prev_rev ? $prev_rev->getId() : ""; |
114 | | - |
| 114 | + |
115 | 115 | $query = array( 'lqt_method' => 'diff', |
116 | 116 | 'diff' => $curr_rev_id, |
117 | 117 | 'oldid' => $oldid ); |
118 | | - |
| 118 | + |
119 | 119 | return $query; |
120 | 120 | } |
121 | 121 | |
— | — | @@ -122,49 +122,49 @@ |
123 | 123 | $query = self::diffQuery( $thread ); |
124 | 124 | return self::permalinkUrl( $thread->changeObject(), null, null, $query ); |
125 | 125 | } |
126 | | - |
| 126 | + |
127 | 127 | static function diffPermalink( $thread, $text, $revision ) { |
128 | 128 | $query = self::diffQuery( $thread, $revision ); |
129 | 129 | return self::permalink( $thread, $text, null, null, null, array(), $query ); |
130 | 130 | } |
131 | | - |
132 | | - static function talkpageLink( $title, $text = null , $method=null, $operand=null, |
133 | | - $includeFragment=true, $attribs = array(), |
| 131 | + |
| 132 | + static function talkpageLink( $title, $text = null , $method = null, $operand = null, |
| 133 | + $includeFragment = true, $attribs = array(), |
134 | 134 | $options = array() ) { |
135 | 135 | list( $title, $query ) = self::talkpageLinkData( $title, $method, $operand, |
136 | 136 | $includeFragment ); |
137 | | - |
| 137 | + |
138 | 138 | global $wgUser; |
139 | 139 | $sk = $wgUser->getSkin(); |
140 | | - |
| 140 | + |
141 | 141 | return $sk->link( $title, $text, $attribs, $query, $options ); |
142 | 142 | } |
143 | | - |
| 143 | + |
144 | 144 | static function talkpageLinkData( $title, $method = null, $operand = null, |
145 | 145 | $includeFragment = true ) { |
146 | 146 | global $wgRequest; |
147 | 147 | $query = array(); |
148 | | - |
149 | | - if ($method) { |
| 148 | + |
| 149 | + if ( $method ) { |
150 | 150 | $query['lqt_method'] = $method; |
151 | 151 | } |
152 | | - |
153 | | - if ($operand) { |
| 152 | + |
| 153 | + if ( $operand ) { |
154 | 154 | $query['lqt_operand'] = $operand->id(); |
155 | 155 | } |
156 | | - |
| 156 | + |
157 | 157 | $oldid = $wgRequest->getVal( 'oldid', null ); |
158 | | - |
| 158 | + |
159 | 159 | if ( $oldid !== null ) { |
160 | 160 | // this is an immensely ugly hack to make editing old revisions work. |
161 | 161 | $query['oldid'] = $oldid; |
162 | 162 | } |
163 | | - |
| 163 | + |
164 | 164 | // Add fragment if appropriate. |
165 | | - if ($operand && $includeFragment) { |
166 | | - $title->mFragment = 'lqt_thread_'.$operand->id(); |
| 165 | + if ( $operand && $includeFragment ) { |
| 166 | + $title->mFragment = 'lqt_thread_' . $operand->id(); |
167 | 167 | } |
168 | | - |
| 168 | + |
169 | 169 | return array( $title, $query ); |
170 | 170 | } |
171 | 171 | |
— | — | @@ -172,40 +172,40 @@ |
173 | 173 | $includeFragment = true ) { |
174 | 174 | global $wgUser; |
175 | 175 | $sk = $wgUser->getSkin(); |
176 | | - |
| 176 | + |
177 | 177 | list( $title, $query ) = |
178 | 178 | self::talkpageLinkData( $title, $method, $operand, $includeFragment ); |
179 | | - |
| 179 | + |
180 | 180 | return $title->getLinkUrl( $query ); |
181 | 181 | } |
182 | 182 | |
183 | 183 | |
184 | 184 | /** |
185 | | - * Return a URL for the current page, including Title and query vars, |
| 185 | + * Return a URL for the current page, including Title and query vars, |
186 | 186 | * with the given replacements made. |
187 | | - * @param $repls array( 'name'=>new_value, ... ) |
188 | | - */ |
| 187 | + * @param $repls array( 'name'=>new_value, ... ) |
| 188 | + */ |
189 | 189 | function queryReplaceLink( $repls ) { |
190 | 190 | $query = $this->getReplacedQuery( $repls ); |
191 | | - |
| 191 | + |
192 | 192 | return $this->title->getFullURL( wfArrayToCGI( $vs ) ); |
193 | 193 | } |
194 | | - |
| 194 | + |
195 | 195 | function getReplacedQuery( $replacements ) { |
196 | 196 | $values = $this->request->getValues(); |
197 | | - |
| 197 | + |
198 | 198 | foreach ( $replacements as $k => $v ) { |
199 | 199 | $values[$k] = $v; |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | return $values; |
203 | 203 | } |
204 | 204 | |
205 | | - /************************************************************* |
206 | | - * Editing methods (here be dragons) * |
207 | | - * Forget dragons: This section distorts the rest of the code * |
208 | | - * like a star bending spacetime around itself. * |
209 | | - *************************************************************/ |
| 205 | + /** |
| 206 | + * Editing methods (here be dragons) |
| 207 | + * Forget dragons: This section distorts the rest of the code |
| 208 | + * like a star bending spacetime around itself. |
| 209 | + */ |
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Return an HTML form element whose value is gotten from the request. |
— | — | @@ -246,37 +246,37 @@ |
247 | 247 | $this->output->addWikiMsg( 'lqt-summarize-intro' ); |
248 | 248 | $this->showEditingFormInGeneral( $thread, 'summarize', $thread ); |
249 | 249 | } |
250 | | - |
| 250 | + |
251 | 251 | function doInlineEditForm() { |
252 | 252 | $method = $this->request->getVal( 'lqt_method' ); |
253 | 253 | $operand = $this->request->getVal( 'lqt_operand' ); |
254 | | - |
255 | | - $thread = Threads::withId( intval($operand) ); |
256 | | - |
257 | | - if ($method == 'reply') { |
| 254 | + |
| 255 | + $thread = Threads::withId( intval( $operand ) ); |
| 256 | + |
| 257 | + if ( $method == 'reply' ) { |
258 | 258 | $this->showReplyForm( $thread ); |
259 | | - } elseif ($method == 'talkpage_new_thread') { |
| 259 | + } elseif ( $method == 'talkpage_new_thread' ) { |
260 | 260 | $this->showNewThreadForm(); |
261 | 261 | } |
262 | | - |
| 262 | + |
263 | 263 | $this->output->setArticleBodyOnly( true ); |
264 | 264 | } |
265 | 265 | |
266 | 266 | private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) { |
267 | 267 | /* |
268 | | - EditPage needs an Article. If there isn't a real one, as for new posts, |
269 | | - replies, and new summaries, we need to generate a title. Auto-generated |
270 | | - titles are based on the subject line. If the subject line is blank, we |
271 | | - can temporarily use a random scratch title. It's fine if the title changes |
272 | | - throughout the edit cycle, since the article doesn't exist yet anyways. |
273 | | - */ |
| 268 | + * EditPage needs an Article. If there isn't a real one, as for new posts, |
| 269 | + * replies, and new summaries, we need to generate a title. Auto-generated |
| 270 | + * titles are based on the subject line. If the subject line is blank, we |
| 271 | + * can temporarily use a random scratch title. It's fine if the title changes |
| 272 | + * throughout the edit cycle, since the article doesn't exist yet anyways. |
| 273 | + */ |
274 | 274 | |
275 | | - // Stuff that might break the save |
| 275 | + // Stuff that might break the save |
276 | 276 | $valid_subject = true; |
277 | 277 | $failed_rename = false; |
278 | | - |
| 278 | + |
279 | 279 | $subject = $this->request->getVal( 'lqt_subject_field', '' ); |
280 | | - |
| 280 | + |
281 | 281 | if ( $edit_type == 'summarize' && $edit_applies_to->summary() ) { |
282 | 282 | $article = $edit_applies_to->summary(); |
283 | 283 | } elseif ( $edit_type == 'summarize' ) { |
— | — | @@ -287,7 +287,7 @@ |
288 | 288 | // Dodgy title |
289 | 289 | $valid_subject = false; |
290 | 290 | $t = $this->scratchTitle(); |
291 | | - } else { |
| 291 | + } else { |
292 | 292 | if ( $edit_type == 'new' ) { |
293 | 293 | $t = $this->newScratchTitle( $subject ); |
294 | 294 | } elseif ( $edit_type == 'reply' ) { |
— | — | @@ -300,16 +300,16 @@ |
301 | 301 | } |
302 | 302 | |
303 | 303 | $e = new EditPage( $article ); |
304 | | - |
305 | | - |
| 304 | + |
| 305 | + |
306 | 306 | // Find errors. |
307 | | - if (!$valid_subject && $subject) { |
308 | | - $e->editFormPageTop .= |
| 307 | + if ( !$valid_subject && $subject ) { |
| 308 | + $e->editFormPageTop .= |
309 | 309 | Xml::tags( 'div', array( 'class' => 'error' ), |
310 | 310 | wfMsgExt( 'lqt_invalid_subject', 'parse' ) ); |
311 | 311 | } |
312 | | - |
313 | | - if ( (!$valid_subject && $subject) || $failed_rename ) { |
| 312 | + |
| 313 | + if ( ( !$valid_subject && $subject ) || $failed_rename ) { |
314 | 314 | // Dirty hack to prevent saving from going ahead |
315 | 315 | global $wgRequest; |
316 | 316 | $wgRequest->setVal( 'wpPreview', true ); |
— | — | @@ -320,20 +320,20 @@ |
321 | 321 | $this->perpetuate( 'lqt_method', 'hidden' ) . |
322 | 322 | $this->perpetuate( 'lqt_operand', 'hidden' ) . |
323 | 323 | Xml::hidden( 'lqt_nonce', wfGenerateToken() ); |
324 | | - |
| 324 | + |
325 | 325 | // Add a one-time random string to a hidden field. Store the random string |
326 | 326 | // in memcached on submit and don't allow the edit to go ahead if it's already |
327 | 327 | // been added. |
328 | 328 | $submitted_nonce = $this->request->getVal( 'lqt_nonce' ); |
329 | | - if ($submitted_nonce) { |
| 329 | + if ( $submitted_nonce ) { |
330 | 330 | global $wgMemc; |
331 | | - |
| 331 | + |
332 | 332 | $key = wfMemcKey( 'lqt-nonce', $submitted_nonce, $this->user->getName() ); |
333 | | - if ( $wgMemc->get($key) ) { |
| 333 | + if ( $wgMemc->get( $key ) ) { |
334 | 334 | $this->output->redirect( $this->article->getTitle()->getFullURL() ); |
335 | 335 | return; |
336 | 336 | } |
337 | | - |
| 337 | + |
338 | 338 | $wgMemc->set( $key, 1, 3600 ); |
339 | 339 | } |
340 | 340 | |
— | — | @@ -343,9 +343,9 @@ |
344 | 344 | $db_subject = $thread ? $thread->subjectWithoutIncrement() : ''; |
345 | 345 | $subject = $this->request->getVal( 'lqt_subject_field', $db_subject ); |
346 | 346 | $subject_label = wfMsg( 'lqt_subject' ); |
347 | | - |
| 347 | + |
348 | 348 | $attr = array( 'tabindex' => 1 ); |
349 | | - |
| 349 | + |
350 | 350 | $e->editFormTextBeforeContent .= |
351 | 351 | Xml::inputLabel( $subject_label, 'lqt_subject_field', 'lqt_subject_field', |
352 | 352 | 60, $subject, $attr ) . Xml::element( 'br' ); |
— | — | @@ -354,9 +354,8 @@ |
355 | 355 | $e->edit(); |
356 | 356 | |
357 | 357 | // Override what happens in EditPage::showEditForm, called from $e->edit(): |
| 358 | + $this->output->setArticleFlag( false ); |
358 | 359 | |
359 | | - $this->output->setArticleFlag( false ); |
360 | | - |
361 | 360 | if ( $e->didSave ) { |
362 | 361 | $thread = self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article, |
363 | 362 | $subject, $e->summary, $thread ); |
— | — | @@ -367,24 +366,24 @@ |
368 | 367 | // so $thread is null. In that case, just allow editpage to redirect back to the talk page. |
369 | 368 | if ( $this->output->getRedirect() != '' && $thread ) { |
370 | 369 | $redirectTitle = clone $thread->article()->getTitle(); |
371 | | - $redirectTitle->setFragment( '#'.$this->anchorName( $thread ) ); |
| 370 | + $redirectTitle->setFragment( '#' . $this->anchorName( $thread ) ); |
372 | 371 | $this->output->redirect( $this->title->getFullURL() ); |
373 | 372 | } else if ( $this->output->getRedirect() != '' && $edit_applies_to ) { |
374 | 373 | // For summaries: |
375 | 374 | $redirectTitle = clone $edit_applies_to->article()->getTitle(); |
376 | | - $redirectTitle->setFragment( '#'.$this->anchorName( $edit_applies_to ) ); |
| 375 | + $redirectTitle->setFragment( '#' . $this->anchorName( $edit_applies_to ) ); |
377 | 376 | $this->output->redirect( $redirectTitle->getFullURL() ); |
378 | 377 | } |
379 | 378 | } |
380 | | - |
381 | | - static function postEditUpdates($edit_type, $edit_applies_to, $edit_page, $article, |
| 379 | + |
| 380 | + static function postEditUpdates( $edit_type, $edit_applies_to, $edit_page, $article, |
382 | 381 | $subject, $edit_summary, $thread ) { |
383 | 382 | // Update metadata - create and update thread and thread revision objects as |
384 | 383 | // appropriate. |
385 | | - |
| 384 | + |
386 | 385 | if ( $edit_type == 'reply' ) { |
387 | 386 | $subject = $edit_applies_to->subject(); |
388 | | - |
| 387 | + |
389 | 388 | $thread = Threads::newThread( $edit_page, $article, $edit_applies_to, |
390 | 389 | Threads::TYPE_NORMAL, $subject ); |
391 | 390 | } elseif ( $edit_type == 'summarize' ) { |
— | — | @@ -395,25 +394,25 @@ |
396 | 395 | // Move the thread and replies if subject changed. |
397 | 396 | if ( $subject && $subject != $thread->subjectWithoutIncrement() ) { |
398 | 397 | $thread->setSubject( $subject ); |
399 | | - |
| 398 | + |
400 | 399 | // Disabled page-moving for now. |
401 | 400 | // $this->renameThread( $thread, $subject, $e->summary ); |
402 | 401 | } |
403 | | - |
| 402 | + |
404 | 403 | // Add the history entry. |
405 | 404 | $thread->commitRevision( Threads::CHANGE_EDITED_ROOT, $thread, $edit_summary ); |
406 | 405 | } else { |
407 | 406 | $thread = Threads::newThread( $edit_page, $article, null, |
408 | 407 | Threads::TYPE_NORMAL, $subject ); |
409 | 408 | } |
410 | | - |
| 409 | + |
411 | 410 | return $thread; |
412 | 411 | } |
413 | 412 | |
414 | 413 | function renameThread( $t, $s, $reason ) { |
415 | 414 | $this->simplePageMove( $t->root()->getTitle(), $s, $reason ); |
416 | 415 | // TODO here create a redirect from old page to new. |
417 | | - |
| 416 | + |
418 | 417 | foreach ( $t->subthreads() as $st ) { |
419 | 418 | $this->renameThread( $st, $s, $reason ); |
420 | 419 | } |
— | — | @@ -422,15 +421,15 @@ |
423 | 422 | function scratchTitle() { |
424 | 423 | return Threads::scratchTitle(); |
425 | 424 | } |
426 | | - |
| 425 | + |
427 | 426 | function newScratchTitle( $subject ) { |
428 | 427 | return Threads::newThreadTitle( $subject, $this->article ); |
429 | 428 | } |
430 | | - |
| 429 | + |
431 | 430 | function newSummaryTitle( $thread ) { |
432 | 431 | return Threads::newSummaryTitle( $thread ); |
433 | 432 | } |
434 | | - |
| 433 | + |
435 | 434 | function newReplyTitle( $unused, $thread ) { |
436 | 435 | return Threads::newReplyTitle( $thread, $this->user ); |
437 | 436 | } |
— | — | @@ -490,77 +489,77 @@ |
491 | 490 | 'enabled' => true ); |
492 | 491 | |
493 | 492 | if ( $this->user->isAllowed( 'delete' ) ) { |
494 | | - $delete_url = $thread->title()->getFullURL( 'action=delete'); |
| 493 | + $delete_url = $thread->title()->getFullURL( 'action=delete' ); |
495 | 494 | $deleteMsg = $thread->type() == Threads::TYPE_DELETED ? 'lqt_undelete' : 'delete'; |
496 | | - |
| 495 | + |
497 | 496 | $commands['delete'] = array( 'label' => wfMsgExt( $deleteMsg, 'parseinline' ), |
498 | 497 | 'href' => $delete_url, |
499 | 498 | 'enabled' => true ); |
500 | 499 | } |
501 | | - |
| 500 | + |
502 | 501 | if ( !$thread->isTopmostThread() && $this->user->isAllowed( 'lqt-split' ) ) { |
503 | 502 | $splitUrl = SpecialPage::getTitleFor( 'SplitThread', |
504 | 503 | $thread->title()->getPrefixedText() )->getFullURL(); |
505 | 504 | $commands['split'] = array( 'label' => wfMsgExt( 'lqt-thread-split', 'parseinline' ), |
506 | 505 | 'href' => $splitUrl, 'enabled' => true ); |
507 | 506 | } |
508 | | - |
| 507 | + |
509 | 508 | if ( $this->user->isAllowed( 'lqt-merge' ) ) { |
510 | 509 | $mergeParams = $_GET; |
511 | 510 | $mergeParams['lqt_merge_from'] = $thread->id(); |
512 | | - |
513 | | - unset($mergeParams['title']); |
514 | | - |
| 511 | + |
| 512 | + unset( $mergeParams['title'] ); |
| 513 | + |
515 | 514 | $mergeUrl = $this->title->getFullURL( wfArrayToCGI( $mergeParams ) ); |
516 | 515 | $label = wfMsgExt( 'lqt-thread-merge', 'parseinline' ); |
517 | | - |
| 516 | + |
518 | 517 | $commands['merge'] = array( 'label' => $label, |
519 | 518 | 'href' => $mergeUrl, 'enabled' => true ); |
520 | 519 | } |
521 | 520 | |
522 | 521 | return $commands; |
523 | 522 | } |
524 | | - |
| 523 | + |
525 | 524 | // Commands for the bottom. |
526 | 525 | function threadMajorCommands( $thread ) { |
527 | 526 | wfLoadExtensionMessages( 'LiquidThreads' ); |
528 | | - |
529 | | - if ($thread->isHistorical() ) { |
| 527 | + |
| 528 | + if ( $thread->isHistorical() ) { |
530 | 529 | // No links for historical threads. |
531 | 530 | return array(); |
532 | 531 | } |
533 | | - |
| 532 | + |
534 | 533 | $commands = array(); |
535 | | - |
| 534 | + |
536 | 535 | if ( $this->user->isAllowed( 'lqt-merge' ) && |
537 | 536 | $this->request->getCheck( 'lqt_merge_from' ) ) { |
538 | 537 | $srcThread = Threads::withId( $this->request->getVal( 'lqt_merge_from' ) ); |
539 | 538 | $par = $srcThread->title()->getPrefixedText(); |
540 | 539 | $mergeTitle = SpecialPage::getTitleFor( 'MergeThread', $par ); |
541 | | - $mergeUrl = $mergeTitle->getFullURL( 'dest='.$thread->id() ); |
| 540 | + $mergeUrl = $mergeTitle->getFullURL( 'dest=' . $thread->id() ); |
542 | 541 | $label = wfMsgExt( 'lqt-thread-merge-to', 'parseinline' ); |
543 | | - |
| 542 | + |
544 | 543 | $commands['merge-to'] = array( 'label' => $label, 'href' => $mergeUrl, |
545 | 544 | 'enabled' => true, 'tooltip' => $label ); |
546 | 545 | } |
547 | | - |
| 546 | + |
548 | 547 | $commands['reply'] = array( 'label' => wfMsgExt( 'lqt_reply', 'parseinline' ), |
549 | 548 | 'href' => $this->talkpageUrl( $this->title, 'reply', $thread ), |
550 | 549 | 'enabled' => true, 'icon' => 'reply.png', 'showlabel' => 1, |
551 | 550 | 'tooltip' => wfMsg( 'lqt_reply' ) ); |
552 | | - |
| 551 | + |
553 | 552 | $commands['link'] = array( 'label' => wfMsgExt( 'lqt_permalink', 'parseinline' ), |
554 | 553 | 'href' => $thread->title()->getFullURL(), |
555 | 554 | 'enabled' => true, 'icon' => 'link.png', |
556 | 555 | 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' ) ); |
557 | | - |
| 556 | + |
558 | 557 | if ( $thread->root()->getTitle()->quickUserCan( 'edit' ) ) { |
559 | 558 | $commands['edit'] = array( 'label' => wfMsgExt( 'edit', 'parseinline' ), |
560 | 559 | 'href' => $this->talkpageUrl( $this->title, 'edit', $thread ), |
561 | 560 | 'enabled' => true, 'icon' => 'edit.png', |
562 | 561 | 'tooltip' => wfMsgExt( 'edit', 'parseinline' ) ); |
563 | 562 | } |
564 | | - |
| 563 | + |
565 | 564 | return $commands; |
566 | 565 | } |
567 | 566 | |
— | — | @@ -568,33 +567,41 @@ |
569 | 568 | wfLoadExtensionMessages( 'LiquidThreads' ); |
570 | 569 | $commands = array(); |
571 | 570 | |
572 | | - $commands['history'] = array( 'label' => wfMsg( 'history_short' ), |
573 | | - 'href' => self::permalinkUrl( $thread, 'thread_history' ), |
574 | | - 'enabled' => true ); |
| 571 | + $commands['history'] = array( |
| 572 | + 'label' => wfMsg( 'history_short' ), |
| 573 | + 'href' => self::permalinkUrl( $thread, 'thread_history' ), |
| 574 | + 'enabled' => true |
| 575 | + ); |
575 | 576 | |
576 | 577 | if ( in_array( 'move', $this->user->getRights() ) ) { |
577 | 578 | $move_href = SpecialPage::getTitleFor( 'MoveThread' )->getFullURL() |
578 | 579 | . '/' . $thread->title()->getPrefixedURL(); |
579 | | - $commands['move'] = array( 'label' => wfMsg( 'move' ), |
580 | | - 'href' => $move_href, |
581 | | - 'enabled' => true ); |
| 580 | + $commands['move'] = array( |
| 581 | + 'label' => wfMsg( 'move' ), |
| 582 | + 'href' => $move_href, |
| 583 | + 'enabled' => true |
| 584 | + ); |
582 | 585 | } |
583 | 586 | if ( !$this->user->isAnon() && !$thread->title()->userIsWatching() ) { |
584 | | - $commands['watch'] = array( 'label' => wfMsg( 'watch' ), |
585 | | - 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ), |
586 | | - 'enabled' => true ); |
| 587 | + $commands['watch'] = array( |
| 588 | + 'label' => wfMsg( 'watch' ), |
| 589 | + 'href' => self::permalinkUrlWithQuery( $thread, 'action=watch' ), |
| 590 | + 'enabled' => true |
| 591 | + ); |
587 | 592 | } else if ( !$this->user->isAnon() ) { |
588 | | - $commands['unwatch'] = array( 'label' => wfMsg( 'unwatch' ), |
589 | | - 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ), |
590 | | - 'enabled' => true ); |
| 593 | + $commands['unwatch'] = array( |
| 594 | + 'label' => wfMsg( 'unwatch' ), |
| 595 | + 'href' => self::permalinkUrlWithQuery( $thread, 'action=unwatch' ), |
| 596 | + 'enabled' => true |
| 597 | + ); |
591 | 598 | } |
592 | | - |
| 599 | + |
593 | 600 | $summarizeUrl = self::permalinkUrl( $thread, 'summarize', $thread->id() ); |
594 | 601 | $commands['summarize'] = array( |
595 | | - 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ), |
596 | | - 'href' => $summarizeUrl, |
597 | | - 'enabled' => true, |
598 | | - ); |
| 602 | + 'label' => wfMsgExt( 'lqt_summarize_link', 'parseinline' ), |
| 603 | + 'href' => $summarizeUrl, |
| 604 | + 'enabled' => true, |
| 605 | + ); |
599 | 606 | |
600 | 607 | return $commands; |
601 | 608 | } |
— | — | @@ -606,38 +613,38 @@ |
607 | 614 | static function addJSandCSS() { |
608 | 615 | // Changed this to be static so that we can call it from |
609 | 616 | // wfLqtBeforeWatchlistHook. |
610 | | - |
| 617 | + |
611 | 618 | if ( self::$stylesAndScriptsDone ) { |
612 | 619 | return; |
613 | 620 | } |
614 | | - |
| 621 | + |
615 | 622 | global $wgOut; |
616 | 623 | global $wgScriptPath, $wgStyleVersion; |
617 | 624 | global $wgEnableJS2system; |
618 | 625 | |
619 | 626 | $wgOut->addInlineScript( 'var wgLqtMessages = ' . self::exportJSLocalisation() . ';' ); |
620 | | - |
621 | | - if (!$wgEnableJS2system) { |
| 627 | + |
| 628 | + if ( !$wgEnableJS2system ) { |
622 | 629 | $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/js2.combined.js" ); |
623 | 630 | } |
624 | | - |
| 631 | + |
625 | 632 | $wgOut->addScriptFile( "{$wgScriptPath}/extensions/LiquidThreads/lqt.js" ); |
626 | 633 | $wgOut->addExtensionStyle( "{$wgScriptPath}/extensions/LiquidThreads/lqt.css?{$wgStyleVersion}" ); |
627 | | - |
| 634 | + |
628 | 635 | self::$stylesAndScriptsDone = true; |
629 | 636 | } |
630 | | - |
| 637 | + |
631 | 638 | static function exportJSLocalisation() { |
632 | 639 | wfLoadExtensionMessages( 'LiquidThreads' ); |
633 | | - |
| 640 | + |
634 | 641 | $messages = array( 'lqt-quote-intro', 'lqt-quote', 'lqt-ajax-updated', |
635 | 642 | 'lqt-ajax-update-link' ); |
636 | 643 | $data = array(); |
637 | | - |
638 | | - foreach( $messages as $msg ) { |
| 644 | + |
| 645 | + foreach ( $messages as $msg ) { |
639 | 646 | $data[$msg] = wfMsgNoTrans( $msg ); |
640 | 647 | } |
641 | | - |
| 648 | + |
642 | 649 | return json_encode( $data ); |
643 | 650 | } |
644 | 651 | |
— | — | @@ -647,65 +654,83 @@ |
648 | 655 | * $post->getParserOutput. */ |
649 | 656 | function showPostBody( $post, $oldid = null ) { |
650 | 657 | global $wgOut; |
651 | | - |
| 658 | + |
652 | 659 | // Load compatibility layer for older versions |
653 | | - if ( !($post instanceof Article_LQT_Compat) ) { |
| 660 | + if ( !( $post instanceof Article_LQT_Compat ) ) { |
654 | 661 | wfWarn( "No article compatibility layer loaded, inefficiently duplicating information." ); |
655 | 662 | $post = new Article_LQT_Compat( $post->getTitle() ); |
656 | 663 | } |
657 | | - |
| 664 | + |
658 | 665 | $parserOutput = $post->getParserOutput( $oldid ); |
659 | 666 | $wgOut->addParserOutputNoText( $parserOutput ); |
660 | | - |
| 667 | + |
661 | 668 | return $parserOutput->getText(); |
662 | 669 | } |
663 | | - |
| 670 | + |
664 | 671 | function showThreadToolbar( $thread ) { |
665 | 672 | global $wgLang; |
666 | | - |
| 673 | + |
667 | 674 | $sk = $this->user->getSkin(); |
668 | 675 | $html = ''; |
669 | 676 | |
670 | 677 | $headerParts = array(); |
671 | | - |
672 | | - foreach( $this->threadMajorCommands( $thread ) as $key => $cmd ) { |
| 678 | + |
| 679 | + foreach ( $this->threadMajorCommands( $thread ) as $key => $cmd ) { |
673 | 680 | $content = $this->contentForCommand( $cmd, false /* No icon divs */ ); |
674 | | - $headerParts[] = Xml::tags( 'li', |
675 | | - array( 'class' => "lqt-command lqt-command-$key" ), |
676 | | - $content ); |
| 681 | + $headerParts[] = Xml::tags( |
| 682 | + 'li', |
| 683 | + array( 'class' => "lqt-command lqt-command-$key" ), |
| 684 | + $content |
| 685 | + ); |
677 | 686 | } |
678 | | - |
| 687 | + |
679 | 688 | // Drop-down menu |
680 | 689 | $commands = $this->threadCommands( $thread ); |
681 | | - $menuHTML = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-command-list'), |
682 | | - $this->listItemsForCommands( $commands ) ); |
683 | | - |
684 | | - $triggerText = Xml::tags( 'span', array('class' => 'lqt-thread-actions-icon'), |
685 | | - ' '); |
686 | | - $dropDownTrigger = Xml::tags( 'div', |
687 | | - array( 'class' => 'lqt-thread-actions-trigger '. |
688 | | - 'lqt-command-icon', 'style' => 'display: none;'), |
689 | | - $triggerText ); |
690 | | - $headerParts[] = Xml::tags( 'li', |
691 | | - array( 'class' => 'lqt-thread-toolbar-menu' ), |
692 | | - $dropDownTrigger ); |
693 | | - |
| 690 | + $menuHTML = Xml::tags( |
| 691 | + 'ul', |
| 692 | + array( 'class' => 'lqt-thread-toolbar-command-list' ), |
| 693 | + $this->listItemsForCommands( $commands ) |
| 694 | + ); |
| 695 | + |
| 696 | + $triggerText = Xml::tags( |
| 697 | + 'span', |
| 698 | + array( 'class' => 'lqt-thread-actions-icon' ), |
| 699 | + ' ' |
| 700 | + ); |
| 701 | + $dropDownTrigger = Xml::tags( |
| 702 | + 'div', |
| 703 | + array( |
| 704 | + 'class' => 'lqt-thread-actions-trigger ' . |
| 705 | + 'lqt-command-icon', 'style' => 'display: none;' |
| 706 | + ), |
| 707 | + $triggerText |
| 708 | + ); |
| 709 | + $headerParts[] = Xml::tags( |
| 710 | + 'li', |
| 711 | + array( 'class' => 'lqt-thread-toolbar-menu' ), |
| 712 | + $dropDownTrigger |
| 713 | + ); |
| 714 | + |
694 | 715 | $html .= implode( ' ', $headerParts ); |
695 | | - |
| 716 | + |
696 | 717 | $html = Xml::tags( 'ul', array( 'class' => 'lqt-thread-toolbar-commands' ), $html ); |
697 | 718 | $html .= Xml::tags( 'div', array( 'style' => 'clear: both; height: 0;' ), ' ' ); |
698 | | - |
| 719 | + |
699 | 720 | // Box stuff |
700 | | - $boxElements = array( 'lqt-thread-toolbar-box-tl', 'lqt-thread-toolbar-box-tr', |
701 | | - 'lqt-thread-toolbar-box-br', 'lqt-thread-toolbar-box-bl' ); |
702 | | - foreach( $boxElements as $class ) { |
| 721 | + $boxElements = array( |
| 722 | + 'lqt-thread-toolbar-box-tl', |
| 723 | + 'lqt-thread-toolbar-box-tr', |
| 724 | + 'lqt-thread-toolbar-box-br', |
| 725 | + 'lqt-thread-toolbar-box-bl' |
| 726 | + ); |
| 727 | + foreach ( $boxElements as $class ) { |
703 | 728 | $html = Xml::openElement( 'div', array( 'class' => $class ) ) . $html . |
704 | 729 | Xml::closeElement( 'div' ); |
705 | 730 | } |
706 | | - |
| 731 | + |
707 | 732 | $html = Xml::tags( 'div', array( 'class' => 'lqt-thread-toolbar' ), $html ) . |
708 | 733 | $menuHTML; |
709 | | - |
| 734 | + |
710 | 735 | return $html; |
711 | 736 | } |
712 | 737 | |
— | — | @@ -713,55 +738,72 @@ |
714 | 739 | $result = array(); |
715 | 740 | foreach ( $commands as $key => $command ) { |
716 | 741 | $thisCommand = $this->contentForCommand( $command ); |
717 | | - |
718 | | - $thisCommand = Xml::tags( 'li', |
719 | | - array( 'class' => 'lqt-command lqt-command-'.$key ), |
720 | | - $thisCommand ); |
721 | | - |
| 742 | + |
| 743 | + $thisCommand = Xml::tags( |
| 744 | + 'li', |
| 745 | + array( 'class' => 'lqt-command lqt-command-' . $key ), |
| 746 | + $thisCommand |
| 747 | + ); |
| 748 | + |
722 | 749 | $result[] = $thisCommand; |
723 | 750 | } |
724 | 751 | return join( ' ', $result ); |
725 | 752 | } |
726 | | - |
| 753 | + |
727 | 754 | function contentForCommand( $command, $icon_divs = true ) { |
728 | 755 | $label = $command['label']; |
729 | 756 | $href = $command['href']; |
730 | 757 | $enabled = $command['enabled']; |
731 | | - $tooltip = isset($command['tooltip']) ? $command['tooltip'] : ''; |
732 | | - |
| 758 | + $tooltip = isset( $command['tooltip'] ) ? $command['tooltip'] : ''; |
| 759 | + |
733 | 760 | if ( isset( $command['icon'] ) ) { |
734 | 761 | global $wgScriptPath; |
735 | | - $icon = Xml::tags( 'div', array( 'title' => $label, |
736 | | - 'class' => 'lqt-command-icon' ), ' ' ); |
737 | | - if ($icon_divs) { |
738 | | - if ( !empty($command['showlabel']) ) { |
739 | | - $label = $icon.' '.$label; |
| 762 | + $icon = Xml::tags( |
| 763 | + 'div', |
| 764 | + array( |
| 765 | + 'title' => $label, |
| 766 | + 'class' => 'lqt-command-icon' |
| 767 | + ), |
| 768 | + ' ' |
| 769 | + ); |
| 770 | + if ( $icon_divs ) { |
| 771 | + if ( !empty( $command['showlabel'] ) ) { |
| 772 | + $label = $icon . ' ' . $label; |
740 | 773 | } else { |
741 | 774 | $label = $icon; |
742 | 775 | } |
743 | 776 | } else { |
744 | | - if ( empty($command['showlabel']) ) { |
| 777 | + if ( empty( $command['showlabel'] ) ) { |
745 | 778 | $label = ''; |
746 | 779 | } |
747 | 780 | } |
748 | 781 | } |
749 | | - |
| 782 | + |
750 | 783 | $thisCommand = ''; |
751 | | - |
| 784 | + |
752 | 785 | if ( $enabled ) { |
753 | | - $thisCommand = Xml::tags( 'a', array( 'href' => $href, 'title' => $tooltip ), |
754 | | - $label ); |
| 786 | + $thisCommand = Xml::tags( |
| 787 | + 'a', |
| 788 | + array( 'href' => $href, 'title' => $tooltip ), |
| 789 | + $label |
| 790 | + ); |
755 | 791 | } else { |
756 | | - $thisCommand = Xml::tags( 'span', array( 'class' => 'lqt_command_disabled', |
757 | | - 'title' => $tooltip), $label ); |
| 792 | + $thisCommand = Xml::tags( |
| 793 | + 'span', |
| 794 | + array( |
| 795 | + 'class' => 'lqt_command_disabled', |
| 796 | + 'title' => $tooltip |
| 797 | + ), |
| 798 | + $label |
| 799 | + ); |
758 | 800 | } |
759 | | - |
| 801 | + |
760 | 802 | return $thisCommand; |
761 | 803 | } |
762 | 804 | |
763 | 805 | /** Shows a normal (i.e. not deleted or moved) thread body */ |
764 | 806 | function showThreadBody( $thread ) { |
765 | | - |
| 807 | + |
766 | 808 | // Remove 'editsection', it won't work. |
767 | 809 | $popts = $this->output->parserOptions(); |
768 | 810 | $previous_editsection = $popts->getEditSection(); |
— | — | @@ -769,7 +811,7 @@ |
770 | 812 | $this->output->parserOptions( $popts ); |
771 | 813 | |
772 | 814 | $post = $thread->root(); |
773 | | - |
| 815 | + |
774 | 816 | $divClass = $this->postDivClass( $thread ); |
775 | 817 | $html = ''; |
776 | 818 | |
— | — | @@ -789,7 +831,7 @@ |
790 | 832 | $html = Xml::openElement( 'div', array( 'class' => $divClass ) ); |
791 | 833 | $this->output->addHTML( $html ); |
792 | 834 | $html = ''; |
793 | | - |
| 835 | + |
794 | 836 | // No way am I refactoring EditForm to send its output as HTML. |
795 | 837 | // so I'm just flushing the HTML and displaying it as-is. |
796 | 838 | $this->showPostEditingForm( $thread ); |
— | — | @@ -800,8 +842,8 @@ |
801 | 843 | $html .= $this->showPostBody( $post, $oldid ); |
802 | 844 | $html .= Xml::closeElement( 'div' ); |
803 | 845 | $html .= $this->threadSignature( $thread ); |
804 | | - } |
805 | | - |
| 846 | + } |
| 847 | + |
806 | 848 | // If we're replying to this thread, show the reply form after it. |
807 | 849 | if ( $this->methodAppliesToThread( 'reply', $thread ) ) { |
808 | 850 | // As with above, flush HTML to avoid refactoring EditPage. |
— | — | @@ -809,60 +851,69 @@ |
810 | 852 | $this->showReplyForm( $thread ); |
811 | 853 | $html = ''; |
812 | 854 | } else { |
813 | | - $html .= Xml::tags( 'div', |
814 | | - array( 'class' => 'lqt-reply-form lqt-edit-form', |
815 | | - 'style' => 'display: none;' ), |
816 | | - '' ); |
| 855 | + $html .= Xml::tags( |
| 856 | + 'div', |
| 857 | + array( |
| 858 | + 'class' => 'lqt-reply-form lqt-edit-form', |
| 859 | + 'style' => 'display: none;' |
| 860 | + ), |
| 861 | + '' |
| 862 | + ); |
817 | 863 | } |
818 | | - |
| 864 | + |
819 | 865 | $this->output->addHTML( $html ); |
820 | 866 | |
821 | 867 | $popts->setEditSection( $previous_editsection ); |
822 | 868 | $this->output->parserOptions( $popts ); |
823 | 869 | } |
824 | | - |
| 870 | + |
825 | 871 | function threadSignature( $thread ) { |
826 | 872 | global $wgUser; |
827 | 873 | $sk = $wgUser->getSkin(); |
828 | | - |
| 874 | + |
829 | 875 | $author = $thread->author(); |
830 | 876 | $signature = $sk->userLink( $author->getId(), $author->getName() ); |
831 | | - $signature = '— '. Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ), |
| 877 | + $signature = '— ' . Xml::tags( 'span', array( 'class' => 'lqt-thread-author' ), |
832 | 878 | $signature ); |
833 | 879 | $signature .= $sk->userToolLinks( $author->getId(), $author->getName() ); |
834 | | - |
| 880 | + |
835 | 881 | $signature = Xml::tags( 'div', array( 'class' => 'lqt-thread-signature' ), |
836 | 882 | $signature ); |
837 | | - |
| 883 | + |
838 | 884 | return $signature; |
839 | 885 | } |
840 | | - |
| 886 | + |
841 | 887 | function threadInfoPanel( $thread ) { |
842 | 888 | global $wgUser, $wgLang; |
843 | | - |
| 889 | + |
844 | 890 | $sk = $wgUser->getSkin(); |
845 | | - |
| 891 | + |
846 | 892 | $infoElements = array(); |
847 | | - |
| 893 | + |
848 | 894 | $timestamp = $wgLang->timeanddate( $thread->created(), true ); |
849 | 895 | $infoElements[] = Xml::element( 'div', array( 'class' => 'lqt-thread-toolbar-timestamp' ), |
850 | 896 | $timestamp ); |
851 | | - |
| 897 | + |
852 | 898 | // Check for edited flag. |
853 | | - $editedFlag = $thread->editedness(); |
| 899 | + $editedFlag = $thread->editedness(); |
854 | 900 | $ebLookup = array( Threads::EDITED_BY_AUTHOR => 'author', |
855 | 901 | Threads::EDITED_BY_OTHERS => 'others' ); |
856 | 902 | if ( isset( $ebLookup[$editedFlag] ) ) { |
857 | 903 | |
858 | 904 | $editedBy = $ebLookup[$editedFlag]; |
859 | | - $editedNotice = wfMsgExt( 'lqt-thread-edited-'.$editedBy, 'parseinline' ); |
860 | | - $infoElements[] = Xml::element( 'div', array( 'class' => |
861 | | - 'lqt-thread-toolbar-edited-'.$editedBy ), |
862 | | - $editedNotice ); |
| 905 | + $editedNotice = wfMsgExt( 'lqt-thread-edited-' . $editedBy, 'parseinline' ); |
| 906 | + $infoElements[] = Xml::element( |
| 907 | + 'div', |
| 908 | + array( 'class' => 'lqt-thread-toolbar-edited-' . $editedBy ), |
| 909 | + $editedNotice |
| 910 | + ); |
863 | 911 | } |
864 | | - |
865 | | - return Xml::tags( 'div', array( 'class' => 'lqt-thread-info-panel' ), |
866 | | - implode( "\n", $infoElements ) ); |
| 912 | + |
| 913 | + return Xml::tags( |
| 914 | + 'div', |
| 915 | + array( 'class' => 'lqt-thread-info-panel' ), |
| 916 | + implode( "\n", $infoElements ) |
| 917 | + ); |
867 | 918 | } |
868 | 919 | |
869 | 920 | /** Shows the headING for a thread (as opposed to the headeER for a post within |
— | — | @@ -873,53 +924,57 @@ |
874 | 925 | $commands_html = ""; |
875 | 926 | } else { |
876 | 927 | $lis = $this->listItemsForCommands( $this->topLevelThreadCommands( $thread ) ); |
877 | | - $commands_html = Xml::tags( 'ul', |
878 | | - array( 'class' => 'lqt_threadlevel_commands' ), |
879 | | - $lis ); |
| 928 | + $commands_html = Xml::tags( |
| 929 | + 'ul', |
| 930 | + array( 'class' => 'lqt_threadlevel_commands' ), |
| 931 | + $lis |
| 932 | + ); |
880 | 933 | } |
881 | | - |
882 | | - $id = 'lqt-header-'.$thread->id(); |
883 | 934 | |
| 935 | + $id = 'lqt-header-' . $thread->id(); |
| 936 | + |
884 | 937 | $html = $this->output->parseInline( $thread->subjectWithoutIncrement() ); |
885 | 938 | $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html ); |
886 | | - $html = Xml::tags( 'h'.$this->headerLevel, |
887 | | - array( 'class' => 'lqt_header', 'id' => $id), |
888 | | - $html ) . $commands_html; |
889 | | - |
| 939 | + $html = Xml::tags( |
| 940 | + 'h' . $this->headerLevel, |
| 941 | + array( 'class' => 'lqt_header', 'id' => $id ), |
| 942 | + $html |
| 943 | + ) . $commands_html; |
| 944 | + |
890 | 945 | return $html; |
891 | 946 | } |
892 | | - |
| 947 | + |
893 | 948 | return ''; |
894 | 949 | } |
895 | 950 | |
896 | 951 | function postDivClass( $thread ) { |
897 | | - $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel; |
898 | | - $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even'; |
| 952 | + $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel; |
| 953 | + $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even'; |
899 | 954 | $alternatingClass = "lqt-thread-$alternatingType"; |
900 | | - |
| 955 | + |
901 | 956 | return "lqt_post $levelClass $alternatingClass"; |
902 | 957 | } |
903 | 958 | |
904 | 959 | static function anchorName( $thread ) { |
905 | 960 | return $thread->getAnchorName(); |
906 | 961 | } |
907 | | - |
| 962 | + |
908 | 963 | // Display a moved thread |
909 | 964 | function showMovedThread( $thread ) { |
910 | 965 | global $wgLang; |
911 | | - |
| 966 | + |
912 | 967 | $sk = $this->user->getSkin(); |
913 | | - |
| 968 | + |
914 | 969 | // Grab target thread |
915 | 970 | $article = new Article( $thread->title() ); |
916 | 971 | $target = Title::newFromRedirect( $article->getContent() ); |
917 | 972 | $t_thread = Threads::withRoot( new Article( $target ) ); |
918 | | - |
| 973 | + |
919 | 974 | // Grab data about the new post. |
920 | 975 | $author = $thread->author(); |
921 | 976 | $sig = $sk->userLink( $author->getID(), $author->getName() ) . |
922 | 977 | $sk->userToolLinks( $author->getID(), $author->getName() ); |
923 | | - |
| 978 | + |
924 | 979 | $html = |
925 | 980 | wfMsgExt( 'lqt_move_placeholder', array( 'parseinline', 'replaceafter' ), |
926 | 981 | $sk->link( $target ), |
— | — | @@ -927,10 +982,10 @@ |
928 | 983 | $wgLang->date( $thread->modified() ), |
929 | 984 | $wgLang->time( $thread->modified() ) |
930 | 985 | ); |
931 | | - |
| 986 | + |
932 | 987 | $this->output->addHTML( $html ); |
933 | 988 | } |
934 | | - |
| 989 | + |
935 | 990 | /** Shows a deleted thread. Returns true to show the thread body */ |
936 | 991 | function showDeletedThread( $thread ) { |
937 | 992 | $sk = $this->user->getSkin(); |
— | — | @@ -946,216 +1001,233 @@ |
947 | 1002 | return false; |
948 | 1003 | } |
949 | 1004 | } |
950 | | - |
| 1005 | + |
951 | 1006 | // Shows a single thread, rather than a thread tree. |
952 | 1007 | function showSingleThread( $thread ) { |
953 | 1008 | wfLoadExtensionMessages( 'LiquidThreads' ); |
954 | | - |
| 1009 | + |
955 | 1010 | $html = ''; |
956 | | - |
| 1011 | + |
957 | 1012 | // If it's a 'moved' thread, show the placeholder |
958 | 1013 | if ( $thread->type() == Threads::TYPE_MOVED ) { |
959 | 1014 | $this->showMovedThread( $thread ); |
960 | 1015 | return; |
961 | 1016 | } elseif ( $thread->type() == Threads::TYPE_DELETED ) { |
962 | 1017 | $res = $this->showDeletedThread( $thread ); |
963 | | - |
964 | | - if (!$res) return; |
| 1018 | + |
| 1019 | + if ( !$res ) return; |
965 | 1020 | } |
966 | | - |
| 1021 | + |
967 | 1022 | $this->output->addHTML( $this->threadInfoPanel( $thread ) ); |
968 | | - |
| 1023 | + |
969 | 1024 | if ( $thread->summary() ) { |
970 | 1025 | $html .= $this->getSummary( $thread ); |
971 | 1026 | } |
972 | | - |
| 1027 | + |
973 | 1028 | // Unfortunately, I can't rewrite showRootPost() to pass back HTML |
974 | 1029 | // as it would involve rewriting EditPage, which I do NOT intend to do. |
975 | 1030 | |
976 | 1031 | $this->output->addHTML( $html ); |
977 | | - |
| 1032 | + |
978 | 1033 | $this->showThreadBody( $thread ); |
979 | | - |
| 1034 | + |
980 | 1035 | } |
981 | 1036 | |
982 | 1037 | function showThread( $thread, $levelNum = 1, $totalInLevel = 1, $options = array() ) { |
983 | 1038 | global $wgLang; |
984 | | - |
| 1039 | + |
985 | 1040 | // Safeguard |
986 | 1041 | if ( $thread->type() == Threads::TYPE_DELETED |
987 | | - && ! ($this->request->getBool( 'lqt_show_deleted_threads' ) |
| 1042 | + && ! ( $this->request->getBool( 'lqt_show_deleted_threads' ) |
988 | 1043 | && $this->user->isAllowed( 'deletedhistory' ) ) ) { |
989 | 1044 | return; |
990 | 1045 | } |
991 | | - |
| 1046 | + |
992 | 1047 | $this->threadNestingLevel++; |
993 | | - |
| 1048 | + |
994 | 1049 | // Figure out which threads *need* to be shown because they're involved in an |
995 | 1050 | // operation |
996 | 1051 | static $mustShowThreads = null; // Array of thread IDs |
997 | | - if ( is_null($mustShowThreads) ) { |
| 1052 | + if ( is_null( $mustShowThreads ) ) { |
998 | 1053 | $mustShowThreads = array(); |
999 | 1054 | if ( $this->request->getVal( 'lqt_operand' ) ) { |
1000 | 1055 | $walk_thread = Threads::withId( $this->request->getVal( 'lqt_operand' ) ); |
1001 | | - |
| 1056 | + |
1002 | 1057 | do { |
1003 | 1058 | $mustShowThreads[$walk_thread->id()] = $walk_thread; |
1004 | 1059 | $walk_thread = $walk_thread->superthread(); |
1005 | 1060 | } while ( $walk_thread ); |
1006 | 1061 | } |
1007 | 1062 | } |
1008 | | - |
| 1063 | + |
1009 | 1064 | $sk = $this->user->getSkin(); |
1010 | | - |
| 1065 | + |
1011 | 1066 | $html = ''; |
1012 | 1067 | |
1013 | | - $html .= Xml::element( 'a', array( 'name' => $this->anchorName($thread) ), ' ' ); |
| 1068 | + $html .= Xml::element( 'a', array( 'name' => $this->anchorName( $thread ) ), ' ' ); |
1014 | 1069 | |
1015 | 1070 | $html .= $this->showThreadHeading( $thread ); |
1016 | | - |
| 1071 | + |
1017 | 1072 | $class = $this->threadDivClass( $thread ); |
1018 | | - if ($levelNum == 1) { |
| 1073 | + if ( $levelNum == 1 ) { |
1019 | 1074 | $class .= ' lqt-thread-first'; |
1020 | | - } elseif ($levelNum == $totalInLevel) { |
| 1075 | + } elseif ( $levelNum == $totalInLevel ) { |
1021 | 1076 | $class .= ' lqt-thread-last'; |
1022 | 1077 | } |
1023 | | - |
1024 | | - $html .= Xml::openElement( 'div', array( 'class' => $class, |
1025 | | - 'id' => 'lqt_thread_id_'. $thread->id() ) ); |
1026 | 1078 | |
| 1079 | + $html .= Xml::openElement( |
| 1080 | + 'div', |
| 1081 | + array( |
| 1082 | + 'class' => $class, |
| 1083 | + 'id' => 'lqt_thread_id_' . $thread->id() |
| 1084 | + ) |
| 1085 | + ); |
| 1086 | + |
1027 | 1087 | // Modified time for topmost threads... |
1028 | 1088 | if ( $thread->isTopmostThread() ) { |
1029 | | - $html .= Xml::hidden( 'lqt-thread-modified-'.$thread->id(), |
1030 | | - wfTimestamp( TS_MW, $thread->modified() ), |
1031 | | - array( 'id' => 'lqt-thread-modified-'.$thread->id(), |
1032 | | - 'class' => 'lqt-thread-modified' ) ); |
1033 | | - } |
| 1089 | + $html .= Xml::hidden('lqt-thre |
| 1090 | + ad-modified-' . $thread->id(), |
| 1091 | + wfTimestamp( TS_MW, $thread->modified() ), |
| 1092 | + array( |
| 1093 | + 'id' => 'lqt-thread-modified-' . $thread->id(), |
| 1094 | + 'class' => 'lqt-thread-modified' |
| 1095 | + ) |
| 1096 | + ); |
| 1097 | + } |
1034 | 1098 | |
1035 | 1099 | // Flush output to display thread |
1036 | 1100 | $this->output->addHTML( $html ); |
1037 | | - $this->output->addHTML( Xml::openElement( 'div', |
1038 | | - array( 'class' => 'lqt-post-wrapper' ) ) ); |
| 1101 | + $this->output->addHTML( Xml::openElement( |
| 1102 | + 'div', |
| 1103 | + array( 'class' => 'lqt-post-wrapper' ) |
| 1104 | + ) ); |
1039 | 1105 | $this->showSingleThread( $thread ); |
1040 | 1106 | $this->output->addHTML( Xml::closeElement( 'div' ) ); |
1041 | 1107 | |
1042 | 1108 | // Check depth and count |
1043 | | - if ( isset($options['maxDepth']) ) { |
| 1109 | + if ( isset( $options['maxDepth'] ) ) { |
1044 | 1110 | $maxDepth = $options['maxDepth']; |
1045 | 1111 | } else { |
1046 | 1112 | $maxDepth = $this->user->getOption( 'lqtdisplaydepth' ); |
1047 | 1113 | } |
1048 | | - |
1049 | | - if ( isset($options['maxCount']) ) { |
| 1114 | + |
| 1115 | + if ( isset( $options['maxCount'] ) ) { |
1050 | 1116 | $maxCount = $options['maxCount']; |
1051 | 1117 | } else { |
1052 | 1118 | $maxCount = $this->user->getOption( 'lqtdisplaycount' ); |
1053 | 1119 | } |
1054 | | - |
| 1120 | + |
1055 | 1121 | if ( isset( $options['startAt'] ) ) { |
1056 | 1122 | $startAt = $options['startAt']; |
1057 | 1123 | } else { |
1058 | 1124 | $startAt = 0; |
1059 | 1125 | } |
1060 | | - |
| 1126 | + |
1061 | 1127 | $cascadeOptions = $options; |
1062 | | - unset($cascadeOptions['startAt']); |
1063 | | - |
1064 | | - $showThreads = ($maxDepth == -1) || ( $this->threadNestingLevel <= $maxDepth ); |
1065 | | - |
| 1128 | + unset( $cascadeOptions['startAt'] ); |
| 1129 | + |
| 1130 | + $showThreads = ( $maxDepth == - 1 ) || ( $this->threadNestingLevel <= $maxDepth ); |
| 1131 | + |
1066 | 1132 | // Show subthreads if one of the subthreads is on the must-show list |
1067 | 1133 | $showThreads = $showThreads || |
1068 | | - count( array_intersect( array_keys($mustShowThreads), array_keys( $thread->replies() ) ) ); |
| 1134 | + count( array_intersect( array_keys( $mustShowThreads ), array_keys( $thread->replies() ) ) ); |
1069 | 1135 | if ( $thread->hasSubthreads() && $showThreads ) { |
1070 | | - $repliesClass = 'lqt-thread-replies lqt-thread-replies-'.$this->threadNestingLevel; |
| 1136 | + $repliesClass = 'lqt-thread-replies lqt-thread-replies-' . $this->threadNestingLevel; |
1071 | 1137 | $div = Xml::openElement( 'div', array( 'class' => $repliesClass ) ); |
1072 | 1138 | $this->output->addHTML( $div ); |
1073 | | - |
| 1139 | + |
1074 | 1140 | $subthreadCount = count( $thread->subthreads() ); |
1075 | 1141 | $i = 0; |
1076 | 1142 | $showCount = 0; |
1077 | 1143 | $showThreads = true; |
1078 | | - |
| 1144 | + |
1079 | 1145 | foreach ( $thread->subthreads() as $st ) { |
1080 | 1146 | ++$i; |
1081 | | - |
| 1147 | + |
1082 | 1148 | // Only show undeleted threads that are above our 'startAt' index. |
1083 | 1149 | $shown = false; |
1084 | | - if ($st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads) { |
1085 | | - if ($showCount > $maxCount && $maxCount > 0) { |
| 1150 | + if ( $st->type() != Threads::TYPE_DELETED && $i >= $startAt && $showThreads ) { |
| 1151 | + if ( $showCount > $maxCount && $maxCount > 0 ) { |
1086 | 1152 | // We've shown too many threads. |
1087 | 1153 | $linkText = wfMsgExt( 'lqt-thread-show-more', 'parseinline' ); |
1088 | 1154 | $linkTitle = clone $thread->topmostThread()->title(); |
1089 | | - $linkTitle->setFragment( '#'.$st->getAnchorName() ); |
1090 | | - |
1091 | | - $link = $sk->link( $linkTitle, $linkText, |
1092 | | - array( 'class' => 'lqt-show-more-posts' ) ); |
1093 | | - $link .= Xml::hidden( 'lqt-thread-start-at', $i, |
1094 | | - array( 'class' => 'lqt-thread-start-at' ) ); |
1095 | | - |
| 1155 | + $linkTitle->setFragment( '#' . $st->getAnchorName() ); |
| 1156 | + |
| 1157 | + $link = $sk->link( |
| 1158 | + $linkTitle, |
| 1159 | + $linkText, |
| 1160 | + array( 'class' => 'lqt-show-more-posts' ) |
| 1161 | + ); |
| 1162 | + $link .= Xml::hidden( |
| 1163 | + 'lqt-thread-start-at', |
| 1164 | + $i, |
| 1165 | + array( 'class' => 'lqt-thread-start-at' ) |
| 1166 | + ); |
| 1167 | + |
1096 | 1168 | $this->output->addHTML( $link ); |
1097 | 1169 | $showThreads = false; |
1098 | 1170 | continue; |
1099 | 1171 | } |
1100 | | - |
| 1172 | + |
1101 | 1173 | ++$showCount; |
1102 | | - if ($showCount == 1 ) { |
| 1174 | + if ( $showCount == 1 ) { |
1103 | 1175 | $this->output->addHTML( |
1104 | 1176 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1105 | 1177 | } |
1106 | | - |
| 1178 | + |
1107 | 1179 | $this->showThread( $st, $i, $subthreadCount, $cascadeOptions ); |
1108 | 1180 | $shown = true; |
1109 | 1181 | } |
1110 | | - |
1111 | | - if ($st->type() != Threads::TYPE_DELETED && !$shown && |
| 1182 | + |
| 1183 | + if ( $st->type() != Threads::TYPE_DELETED && !$shown && |
1112 | 1184 | array_key_exists( $st->id(), $mustShowThreads ) ) { |
1113 | | - |
| 1185 | + |
1114 | 1186 | $this->showThread( $st, $i, $subthreadCount, $cascadeOptions ); |
1115 | 1187 | } |
1116 | 1188 | } |
1117 | | - |
| 1189 | + |
1118 | 1190 | $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
1119 | 1191 | Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
1120 | | - |
| 1192 | + |
1121 | 1193 | $this->output->addHTML( $finishDiv . Xml::CloseElement( 'div' ) ); |
1122 | 1194 | } elseif ( $thread->hasSubthreads() && !$showThreads ) { |
1123 | 1195 | // Add a "show subthreads" link. |
1124 | | - $replies = count($thread->replies()); |
1125 | | - $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum($replies) ); |
| 1196 | + $replies = count( $thread->replies() ); |
| 1197 | + $linkText = wfMsgExt( 'lqt-thread-show-replies', 'parseinline', $wgLang->formatNum( $replies ) ); |
1126 | 1198 | $linkTitle = clone $thread->topmostThread()->title(); |
1127 | | - $linkTitle->setFragment( '#'.$thread->getAnchorName() ); |
1128 | | - |
| 1199 | + $linkTitle->setFragment( '#' . $thread->getAnchorName() ); |
| 1200 | + |
1129 | 1201 | $link = $sk->link( $linkTitle, $linkText, array( 'class' => 'lqt-show-replies' ) ); |
1130 | | - |
| 1202 | + |
1131 | 1203 | $this->output->addHTML( Xml::tags( 'div', array( 'class' => 'lqt-thread-replies' ), $link ) ); |
1132 | | - |
1133 | | - if ($levelNum < $totalInLevel) { |
| 1204 | + |
| 1205 | + if ( $levelNum < $totalInLevel ) { |
1134 | 1206 | $this->output->addHTML( |
1135 | 1207 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1136 | 1208 | } |
1137 | | - } elseif ($levelNum < $totalInLevel) { |
| 1209 | + } elseif ( $levelNum < $totalInLevel ) { |
1138 | 1210 | $this->output->addHTML( |
1139 | 1211 | Xml::tags( 'div', array( 'class' => 'lqt-post-sep' ), ' ' ) ); |
1140 | 1212 | } |
1141 | 1213 | |
1142 | | - if ($this->threadNestingLevel == 1) { |
| 1214 | + if ( $this->threadNestingLevel == 1 ) { |
1143 | 1215 | $finishDiv = Xml::tags( 'div', array( 'class' => 'lqt-replies-finish' ), |
1144 | 1216 | Xml::tags( 'div', array( 'class' => 'lqt-replies-finish-corner' ), ' ' ) ); |
1145 | | - |
| 1217 | + |
1146 | 1218 | $this->output->addHTML( $finishDiv ); |
1147 | 1219 | } |
1148 | 1220 | |
1149 | 1221 | $this->output->addHTML( Xml::closeElement( 'div' ) ); |
1150 | | - |
| 1222 | + |
1151 | 1223 | $this->threadNestingLevel--; |
1152 | 1224 | } |
1153 | | - |
| 1225 | + |
1154 | 1226 | function threadDivClass( $thread ) { |
1155 | | - $levelClass = 'lqt-thread-nest-'.$this->threadNestingLevel; |
1156 | | - $alternatingType = ($this->threadNestingLevel % 2) ? 'odd' : 'even'; |
| 1227 | + $levelClass = 'lqt-thread-nest-' . $this->threadNestingLevel; |
| 1228 | + $alternatingType = ( $this->threadNestingLevel % 2 ) ? 'odd' : 'even'; |
1157 | 1229 | $alternatingClass = "lqt-thread-$alternatingType"; |
1158 | 1230 | $topmostClass = $thread->isTopmostThread() ? ' lqt-thread-topmost' : ''; |
1159 | | - |
| 1231 | + |
1160 | 1232 | return "lqt_thread $levelClass $alternatingClass$topmostClass"; |
1161 | 1233 | } |
1162 | 1234 | |
— | — | @@ -1165,32 +1237,42 @@ |
1166 | 1238 | wfLoadExtensionMessages( 'LiquidThreads' ); |
1167 | 1239 | global $wgUser; |
1168 | 1240 | $sk = $wgUser->getSkin(); |
1169 | | - |
| 1241 | + |
1170 | 1242 | $label = wfMsgExt( 'lqt_summary_label', 'parseinline' ); |
1171 | 1243 | $edit_text = wfMsgExt( 'edit', 'parseinline' ); |
1172 | 1244 | $link_text = wfMsg( 'lqt_permalink', 'parseinline' ); |
1173 | | - |
| 1245 | + |
1174 | 1246 | $html = ''; |
1175 | | - |
| 1247 | + |
1176 | 1248 | $html .= Xml::tags( 'span', |
1177 | 1249 | array( 'class' => 'lqt_thread_permalink_summary_title' ), |
1178 | 1250 | $label ); |
1179 | | - |
| 1251 | + |
1180 | 1252 | $link = $sk->link( $t->summary()->getTitle(), $link_text ); |
1181 | 1253 | $edit_link = self::permalink( $t, $edit_text, 'summarize', $t->id() ); |
1182 | 1254 | $links = "[$link]\n[$edit_link]"; |
1183 | | - $html .= Xml::tags( 'span', array( 'class' => 'lqt_thread_permalink_summary_edit' ), |
1184 | | - $links ); |
1185 | | - |
| 1255 | + $html .= Xml::tags( |
| 1256 | + 'span', |
| 1257 | + array( 'class' => 'lqt_thread_permalink_summary_edit' ), |
| 1258 | + $links |
| 1259 | + ); |
| 1260 | + |
1186 | 1261 | $summary_body = $this->showPostBody( $t->summary() ); |
1187 | | - $html .= Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary_body' ), |
1188 | | - $summary_body ); |
1189 | | - |
1190 | | - $html = Xml::tags( 'div', array( 'class' => 'lqt_thread_permalink_summary' ), $html ); |
1191 | | - |
| 1262 | + $html .= Xml::tags( |
| 1263 | + 'div', |
| 1264 | + array( 'class' => 'lqt_thread_permalink_summary_body' ), |
| 1265 | + $summary_body |
| 1266 | + ); |
| 1267 | + |
| 1268 | + $html = Xml::tags( |
| 1269 | + 'div', |
| 1270 | + array( 'class' => 'lqt_thread_permalink_summary' ), |
| 1271 | + $html |
| 1272 | + ); |
| 1273 | + |
1192 | 1274 | return $html; |
1193 | 1275 | } |
1194 | | - |
| 1276 | + |
1195 | 1277 | function showSummary( $t ) { |
1196 | 1278 | $this->output->addHTML( $this->getSummary( $t ) ); |
1197 | 1279 | } |
Index: trunk/extensions/LiquidThreads/pages/SpecialSplitThread.php |
— | — | @@ -5,23 +5,20 @@ |
6 | 6 | |
7 | 7 | function getFormFields() { |
8 | 8 | $splitForm = array( |
9 | | - 'src' => |
10 | | - array( |
11 | | - 'type' => 'info', |
12 | | - 'label-message' => 'lqt-thread-split-thread', |
13 | | - 'default' => LqtView::permalink( $this->mThread ), |
14 | | - 'raw' => 1, |
15 | | - ), |
16 | | - 'subject' => |
17 | | - array( |
18 | | - 'type' => 'text', |
19 | | - 'label-message' => 'lqt-thread-split-subject', |
20 | | - ), |
21 | | - 'reason' => |
22 | | - array( |
23 | | - 'label-message' => 'movereason', |
24 | | - 'type' => 'text', |
25 | | - ), |
| 9 | + 'src' => array( |
| 10 | + 'type' => 'info', |
| 11 | + 'label-message' => 'lqt-thread-split-thread', |
| 12 | + 'default' => LqtView::permalink( $this->mThread ), |
| 13 | + 'raw' => 1, |
| 14 | + ), |
| 15 | + 'subject' => array( |
| 16 | + 'type' => 'text', |
| 17 | + 'label-message' => 'lqt-thread-split-subject', |
| 18 | + ), |
| 19 | + 'reason' => array( |
| 20 | + 'label-message' => 'movereason', |
| 21 | + 'type' => 'text', |
| 22 | + ) |
26 | 23 | ); |
27 | 24 | |
28 | 25 | return $splitForm; |
— | — | @@ -53,13 +50,16 @@ |
54 | 51 | $this->mThread->commitRevision( Threads::CHANGE_SPLIT, null, $reason ); |
55 | 52 | |
56 | 53 | $title = clone $this->mThread->article()->getTitle(); |
57 | | - $title->setFragment( '#'.$this->mThread->getAnchorName() ); |
| 54 | + $title->setFragment( '#' . $this->mThread->getAnchorName() ); |
58 | 55 | |
59 | 56 | $link = $this->user->getSkin()->link( $title, $this->mThread->subject() ); |
60 | 57 | |
61 | 58 | global $wgOut; |
62 | | - $wgOut->addHTML( wfMsgExt( 'lqt-split-success', array( 'parseinline', 'replaceafter' ), |
63 | | - $link ) ); |
| 59 | + $wgOut->addHTML( wfMsgExt( |
| 60 | + 'lqt-split-success', |
| 61 | + array( 'parseinline', 'replaceafter' ), |
| 62 | + $link ) |
| 63 | + ); |
64 | 64 | |
65 | 65 | return true; |
66 | 66 | } |
— | — | @@ -68,19 +68,19 @@ |
69 | 69 | $thread->setSubject( $subject ); |
70 | 70 | $thread->setAncestor( $ancestor->id() ); |
71 | 71 | |
72 | | - if ($first) { |
| 72 | + if ( $first ) { |
73 | 73 | $thread->setSuperThread( null ); |
74 | 74 | } |
75 | 75 | |
76 | 76 | $thread->save( ); |
77 | 77 | |
78 | | - foreach( $thread->replies() as $subThread ) { |
| 78 | + foreach ( $thread->replies() as $subThread ) { |
79 | 79 | $this->recursiveSet( $subThread, $subject, $ancestor ); |
80 | 80 | } |
81 | 81 | } |
82 | 82 | |
83 | 83 | function validateSubject( $target ) { |
84 | | - if (!$target) { |
| 84 | + if ( !$target ) { |
85 | 85 | return wfMsgExt( 'lqt_split_nosubject', 'parseinline' ); |
86 | 86 | } |
87 | 87 | |
Index: trunk/extensions/LiquidThreads/pages/SummaryPageView.php |
— | — | @@ -8,12 +8,14 @@ |
9 | 9 | $thread = Threads::withSummary( $this->article ); |
10 | 10 | if ( $thread ) { |
11 | 11 | global $wgUser; |
12 | | - |
| 12 | + |
13 | 13 | $t = $thread->root()->getTitle(); |
14 | 14 | $link = $wgUser->getSkin()->link( $t ); |
15 | | - $this->output->setSubtitle( |
16 | | - wfMsgExt( 'lqt_summary_subtitle', array( 'parseinline', 'replaceafter' ), |
17 | | - $link ) ); |
| 15 | + $this->output->setSubtitle( wfMsgExt( |
| 16 | + 'lqt_summary_subtitle', |
| 17 | + array( 'parseinline', 'replaceafter' ), |
| 18 | + $link ) |
| 19 | + ); |
18 | 20 | } |
19 | 21 | return true; |
20 | 22 | } |
Index: trunk/extensions/LiquidThreads/pages/SpecialMergeThread.php |
— | — | @@ -5,70 +5,66 @@ |
6 | 6 | |
7 | 7 | function getFormFields() { |
8 | 8 | $splitForm = array( |
9 | | - 'src' => |
10 | | - array( |
11 | | - 'type' => 'info', |
12 | | - 'label-message' => 'lqt-thread-merge-source', |
13 | | - 'default' => $this->formatThreadField( 'src', $this->mThread->id() ), |
14 | | - 'raw' => 1, |
15 | | - ), |
16 | | - 'dest' => |
17 | | - array( |
18 | | - 'type' => 'info', |
19 | | - 'label-message' => 'lqt-thread-merge-dest', |
20 | | - 'default' => |
21 | | - $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ), |
22 | | - 'raw' => 1, |
23 | | - ), |
24 | | - 'reason' => |
25 | | - array( |
26 | | - 'label-message' => 'movereason', |
27 | | - 'type' => 'text', |
28 | | - ), |
| 9 | + 'src' => array( |
| 10 | + 'type' => 'info', |
| 11 | + 'label-message' => 'lqt-thread-merge-source', |
| 12 | + 'default' => $this->formatThreadField( 'src', $this->mThread->id() ), |
| 13 | + 'raw' => 1, |
| 14 | + ), |
| 15 | + 'dest' => array( |
| 16 | + 'type' => 'info', |
| 17 | + 'label-message' => 'lqt-thread-merge-dest', |
| 18 | + 'default' => $this->formatThreadField( 'dest', $this->request->getVal( 'dest' ) ), |
| 19 | + 'raw' => 1, |
| 20 | + ), |
| 21 | + 'reason' => array( |
| 22 | + 'label-message' => 'movereason', |
| 23 | + 'type' => 'text', |
| 24 | + ) |
29 | 25 | ); |
30 | | - |
| 26 | + |
31 | 27 | return $splitForm; |
32 | 28 | } |
33 | | - |
| 29 | + |
34 | 30 | protected function getRightRequirement() { return 'lqt-merge'; } |
35 | | - |
| 31 | + |
36 | 32 | public function checkParameters( $par ) { |
37 | 33 | global $wgOut; |
38 | | - if ( !parent::checkParameters($par) ) { |
| 34 | + if ( !parent::checkParameters( $par ) ) { |
39 | 35 | return false; |
40 | 36 | } |
41 | | - |
| 37 | + |
42 | 38 | $dest = $this->request->getVal( 'dest' ); |
43 | | - |
44 | | - if (!$dest) { |
| 39 | + |
| 40 | + if ( !$dest ) { |
45 | 41 | $wgOut->addWikiMsg( 'lqt_threadrequired' ); |
46 | 42 | return false; |
47 | 43 | } |
48 | | - |
| 44 | + |
49 | 45 | $thread = Threads::withId( $dest ); |
50 | | - |
51 | | - if (!$thread) { |
| 46 | + |
| 47 | + if ( !$thread ) { |
52 | 48 | $wgOut->addWikiMsg( 'lqt_nosuchthread' ); |
53 | 49 | return false; |
54 | 50 | } |
55 | | - |
| 51 | + |
56 | 52 | $this->mDestThread = $thread; |
57 | | - |
| 53 | + |
58 | 54 | return true; |
59 | 55 | } |
60 | 56 | |
61 | 57 | function formatThreadField( $field, $threadid ) { |
62 | | - |
63 | | - if ( !is_object($threadid) ) { |
| 58 | + |
| 59 | + if ( !is_object( $threadid ) ) { |
64 | 60 | $t = Threads::withId( $threadid ); |
65 | 61 | } else { |
66 | 62 | $t = $threadid; |
67 | 63 | $threadid = $t->id(); |
68 | 64 | } |
69 | | - |
| 65 | + |
70 | 66 | $out = Xml::hidden( $field, $threadid ); |
71 | 67 | $out .= LqtView::permalink( $t ); |
72 | | - |
| 68 | + |
73 | 69 | return $out; |
74 | 70 | } |
75 | 71 | |
— | — | @@ -79,63 +75,63 @@ |
80 | 76 | wfLoadExtensionMessages( 'LiquidThreads' ); |
81 | 77 | return wfMsg( 'lqt_merge_thread' ); |
82 | 78 | } |
83 | | - |
| 79 | + |
84 | 80 | function trySubmit( $data ) { |
85 | 81 | // Load data |
86 | 82 | $srcThread = $this->mThread; |
87 | 83 | $dstThread = $this->mDestThread; |
88 | 84 | $newSubject = $dstThread->subject(); |
89 | 85 | $reason = $data['reason']; |
90 | | - |
| 86 | + |
91 | 87 | $oldTopThread = $srcThread->topmostThread(); |
92 | 88 | $oldParent = $srcThread->superthread(); |
93 | | - |
| 89 | + |
94 | 90 | $this->recursiveSet( $srcThread, $newSubject, $dstThread, $dstThread ); |
95 | 91 | |
96 | 92 | $dstThread->addReply( $srcThread ); |
97 | | - |
98 | | - if ($oldParent) { |
| 93 | + |
| 94 | + if ( $oldParent ) { |
99 | 95 | $oldParent->removeReply( $srcThread ); |
100 | 96 | } |
101 | | - |
| 97 | + |
102 | 98 | $oldTopThread->commitRevision( Threads::CHANGE_MERGED_FROM, $srcThread, $reason ); |
103 | 99 | $dstThread->commitRevision( Threads::CHANGE_MERGED_TO, $srcThread, $reason ); |
104 | | - |
| 100 | + |
105 | 101 | $srcTitle = clone $srcThread->article()->getTitle(); |
106 | | - $srcTitle->setFragment( '#'.$srcThread->getAnchorName() ); |
107 | | - |
| 102 | + $srcTitle->setFragment( '#' . $srcThread->getAnchorName() ); |
| 103 | + |
108 | 104 | $dstTitle = clone $dstThread->article()->getTitle(); |
109 | | - $dstTitle->setFragment( '#'.$dstThread->getAnchorName() ); |
110 | | - |
| 105 | + $dstTitle->setFragment( '#' . $dstThread->getAnchorName() ); |
| 106 | + |
111 | 107 | $srcLink = $this->user->getSkin()->link( $srcTitle, $srcThread->subject() ); |
112 | 108 | $dstLink = $this->user->getSkin()->link( $dstTitle, $dstThread->subject() ); |
113 | | - |
| 109 | + |
114 | 110 | global $wgOut; |
115 | 111 | $wgOut->addHTML( wfMsgExt( 'lqt-merge-success', array( 'parseinline', 'replaceafter' ), |
116 | 112 | $srcLink, $dstLink ) ); |
117 | | - |
| 113 | + |
118 | 114 | return true; |
119 | 115 | } |
120 | | - |
| 116 | + |
121 | 117 | function recursiveSet( $thread, $subject, $ancestor, $superthread = false ) { |
122 | 118 | $thread->setSubject( $subject ); |
123 | 119 | $thread->setAncestor( $ancestor->id() ); |
124 | | - |
125 | | - if ($superthread) { |
| 120 | + |
| 121 | + if ( $superthread ) { |
126 | 122 | $thread->setSuperThread( $superthread ); |
127 | 123 | } |
128 | | - |
| 124 | + |
129 | 125 | $thread->save(); |
130 | | - |
131 | | - foreach( $thread->replies() as $subThread ) { |
| 126 | + |
| 127 | + foreach ( $thread->replies() as $subThread ) { |
132 | 128 | $this->recursiveSet( $subThread, $subject, $ancestor ); |
133 | 129 | } |
134 | 130 | } |
135 | | - |
| 131 | + |
136 | 132 | function getPageName() { |
137 | 133 | return 'MergeThread'; |
138 | 134 | } |
139 | | - |
| 135 | + |
140 | 136 | function getSubmitText() { |
141 | 137 | wfLoadExtensionMessages( 'LiquidThreads' ); |
142 | 138 | return wfMsg( 'lqt-merge-submit' ); |
Index: trunk/extensions/LiquidThreads/pages/TalkpageHeaderView.php |
— | — | @@ -26,30 +26,44 @@ |
27 | 27 | |
28 | 28 | if ( $wgRequest->getVal( 'action' ) === 'edit' ) { |
29 | 29 | wfLoadExtensionMessages( 'LiquidThreads' ); |
30 | | - |
| 30 | + |
31 | 31 | $html = ''; |
32 | | - |
33 | | - $warn_bold = Xml::tags( 'strong', null, |
34 | | - wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) ); |
35 | | - |
36 | | - $warn_link = |
37 | | - $this->talkpageLink( $wgTitle, wfMsgExt( 'lqt_header_warning_new_discussion', |
38 | | - 'parseinline' ), 'talkpage_new_thread' ); |
39 | | - |
40 | | - $html .= wfMsgExt( 'lqt_header_warning_before_big', |
41 | | - array('parseinline', 'replaceafter' ), |
42 | | - array( $warn_bold, $warn_link ) ); |
43 | | - $html .= Xml::tags( 'big', null, |
44 | | - wfMsgExt( 'lqt_header_warning_big', |
45 | | - array( 'parseinline', 'replaceafter' ), |
46 | | - array( $warn_bold, $warn_link ) ) ); |
| 32 | + |
| 33 | + $warn_bold = Xml::tags( |
| 34 | + 'strong', |
| 35 | + null, |
| 36 | + wfMsgExt( 'lqt_header_warning_bold', 'parseinline' ) |
| 37 | + ); |
| 38 | + |
| 39 | + $warn_link = $this->talkpageLink( |
| 40 | + $wgTitle, |
| 41 | + wfMsgExt( 'lqt_header_warning_new_discussion', 'parseinline' ), |
| 42 | + 'talkpage_new_thread' |
| 43 | + ); |
| 44 | + |
| 45 | + $html .= wfMsgExt( |
| 46 | + 'lqt_header_warning_before_big', |
| 47 | + array( 'parseinline', 'replaceafter' ), |
| 48 | + array( $warn_bold, $warn_link ) |
| 49 | + ); |
| 50 | + $html .= Xml::tags( |
| 51 | + 'big', |
| 52 | + null, |
| 53 | + wfMsgExt( |
| 54 | + 'lqt_header_warning_big', |
| 55 | + array( 'parseinline', 'replaceafter' ), |
| 56 | + array( $warn_bold, $warn_link ) |
| 57 | + ) |
| 58 | + ); |
47 | 59 | $html .= wfMsg( 'word-separator' ); |
48 | | - $html .= wfMsgExt( 'lqt_header_warning_after_big', |
49 | | - array( 'parseinline', 'replaceafter' ), |
50 | | - array( $warn_bold, $warn_link ) ); |
51 | | - |
| 60 | + $html .= wfMsgExt( |
| 61 | + 'lqt_header_warning_after_big', |
| 62 | + array( 'parseinline', 'replaceafter' ), |
| 63 | + array( $warn_bold, $warn_link ) |
| 64 | + ); |
| 65 | + |
52 | 66 | $html = Xml::tags( 'p', array( 'class' => 'lqt_header_warning' ), $html ); |
53 | | - |
| 67 | + |
54 | 68 | $wgOut->addHTML( $html ); |
55 | 69 | } |
56 | 70 | |
Index: trunk/extensions/LiquidThreads/pages/IndividualThreadHistoryView.php |
— | — | @@ -16,12 +16,16 @@ |
17 | 17 | function customizeSubtitle() { |
18 | 18 | wfLoadExtensionMessages( 'LiquidThreads' ); |
19 | 19 | $msg = wfMsgExt( 'lqt_hist_view_whole_thread', 'parseinline' ); |
20 | | - $threadhist = $this->permalink( $this->thread->topmostThread(), |
21 | | - $msg, |
22 | | - 'thread_history' ); |
23 | | - $this->output->setSubtitle( parent::getSubtitle() . '<br />' . |
24 | | - $this->output->getSubtitle() . |
25 | | - "<br />$threadhist" ); |
| 20 | + $threadhist = $this->permalink( |
| 21 | + $this->thread->topmostThread(), |
| 22 | + $msg, |
| 23 | + 'thread_history' |
| 24 | + ); |
| 25 | + $this->output->setSubtitle( |
| 26 | + parent::getSubtitle() . '<br />' . |
| 27 | + $this->output->getSubtitle() . |
| 28 | + "<br />$threadhist" |
| 29 | + ); |
26 | 30 | return true; |
27 | 31 | } |
28 | 32 | |
Index: trunk/extensions/LiquidThreads/pages/SpecialMoveThread.php |
— | — | @@ -11,119 +11,125 @@ |
12 | 12 | wfLoadExtensionMessages( 'LiquidThreads' ); |
13 | 13 | return wfMsg( 'lqt_movethread' ); |
14 | 14 | } |
15 | | - |
| 15 | + |
16 | 16 | function getFormFields() { |
17 | | - return |
18 | | - array( |
19 | | - 'dest-title' => |
20 | | - array( |
21 | | - 'label-message' => 'lqt_move_destinationtitle', |
22 | | - 'type' => 'text', |
23 | | - 'validation-callback' => array( $this, 'validateTarget' ), |
24 | | - ), |
25 | | - 'reason' => |
26 | | - array( |
27 | | - 'label-message' => 'movereason', |
28 | | - 'type' => 'text', |
29 | | - ), |
30 | | - ); |
| 17 | + return array( |
| 18 | + 'dest-title' => array( |
| 19 | + 'label-message' => 'lqt_move_destinationtitle', |
| 20 | + 'type' => 'text', |
| 21 | + 'validation-callback' => array( $this, 'validateTarget' ), |
| 22 | + ), |
| 23 | + 'reason' => array( |
| 24 | + 'label-message' => 'movereason', |
| 25 | + 'type' => 'text', |
| 26 | + ), |
| 27 | + ); |
31 | 28 | } |
32 | | - |
| 29 | + |
33 | 30 | function getPageName() { return 'MoveThread'; } |
34 | | - |
| 31 | + |
35 | 32 | function getSubmitText() { |
36 | 33 | wfLoadExtensionMessages( 'LiquidThreads' ); |
37 | 34 | return wfMsg( 'lqt_move_move' ); |
38 | 35 | } |
39 | | - |
| 36 | + |
40 | 37 | function buildForm() { |
41 | 38 | $form = parent::buildForm(); |
42 | | - |
| 39 | + |
43 | 40 | // Generate introduction |
44 | 41 | $intro = ''; |
45 | | - |
| 42 | + |
46 | 43 | global $wgUser; |
47 | 44 | $sk = $wgUser->getSkin(); |
48 | 45 | $page = $article_name = $this->mThread->article()->getTitle()->getPrefixedText(); |
49 | | - |
| 46 | + |
50 | 47 | $edit_text = wfMsgExt( 'lqt_move_torename_edit', 'parseinline' ); |
51 | | - $edit_link = $sk->link( $this->mThread->title(), $edit_text, array(), |
52 | | - array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() ) ); |
53 | | - |
54 | | - $intro .= wfMsgExt( 'lqt_move_movingthread', 'parse', |
55 | | - array('[['.$this->mTarget.']]', '[['.$page.']]') ); |
56 | | - $intro .= wfMsgExt( 'lqt_move_torename', array( 'parse', 'replaceafter' ), |
57 | | - array( $edit_link ) ); |
58 | | - |
| 48 | + $edit_link = $sk->link( |
| 49 | + $this->mThread->title(), |
| 50 | + $edit_text, |
| 51 | + array(), |
| 52 | + array( 'lqt_method' => 'edit', 'lqt_operand' => $this->mThread->id() ) |
| 53 | + ); |
| 54 | + |
| 55 | + $intro .= wfMsgExt( |
| 56 | + 'lqt_move_movingthread', |
| 57 | + 'parse', |
| 58 | + array( '[[' . $this->mTarget . ']]', '[[' . $page . ']]' ) |
| 59 | + ); |
| 60 | + $intro .= wfMsgExt( |
| 61 | + 'lqt_move_torename', |
| 62 | + array( 'parse', 'replaceafter' ), |
| 63 | + array( $edit_link ) |
| 64 | + ); |
| 65 | + |
59 | 66 | $form->setIntro( $intro ); |
60 | | - |
| 67 | + |
61 | 68 | return $form; |
62 | 69 | } |
63 | | - |
| 70 | + |
64 | 71 | function checkUserRights( $oldTitle, $newTitle ) { |
65 | 72 | global $wgUser, $wgOut; |
66 | | - |
| 73 | + |
67 | 74 | $oldErrors = $oldTitle->getUserPermissionsErrors( 'move', $wgUser ); |
68 | 75 | $newErrors = $newTitle->getUserPermissionsErrors( 'move', $wgUser ); |
69 | | - |
| 76 | + |
70 | 77 | // Custom merge/unique function because we don't have the second parameter to |
71 | 78 | // array_unique on Wikimedia. |
72 | 79 | $mergedErrors = array(); |
73 | | - foreach( array_merge( $oldErrors, $newErrors ) as $key => $value ) { |
74 | | - if ( !is_numeric($key) ) { |
| 80 | + foreach ( array_merge( $oldErrors, $newErrors ) as $key => $value ) { |
| 81 | + if ( !is_numeric( $key ) ) { |
75 | 82 | $mergedErrors[$key] = $value; |
76 | 83 | } elseif ( !in_array( $value, $mergedErrors ) ) { |
77 | 84 | $mergedErrors[] = $value; |
78 | 85 | } |
79 | 86 | } |
80 | | - |
81 | | - if ( count($mergedErrors) > 0 ) { |
82 | | - return $wgOut->parse( |
83 | | - $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' ) |
84 | | - ); |
| 87 | + |
| 88 | + if ( count( $mergedErrors ) > 0 ) { |
| 89 | + return $wgOut->parse( |
| 90 | + $wgOut->formatPermissionsErrorMessage( $mergedErrors, 'move' ) |
| 91 | + ); |
85 | 92 | } |
86 | 93 | |
87 | 94 | return true; |
88 | 95 | } |
89 | | - |
| 96 | + |
90 | 97 | function trySubmit( $data ) { |
91 | 98 | // Load data |
92 | 99 | $tmp = $data['dest-title']; |
93 | 100 | $newtitle = Title::newFromText( $tmp ); |
94 | 101 | $reason = $data['reason']; |
95 | | - |
| 102 | + |
96 | 103 | $rightsResult = $this->checkUserRights( $this->mThread->title(), $newtitle ); |
97 | | - |
98 | | - if ($rightsResult !== true) |
| 104 | + |
| 105 | + if ( $rightsResult !== true ) |
99 | 106 | return $rightsResult; |
100 | 107 | |
101 | 108 | // TODO no status code from this method. |
102 | 109 | $this->mThread->moveToPage( $newtitle, $reason, true ); |
103 | | - |
| 110 | + |
104 | 111 | global $wgOut, $wgUser; |
105 | 112 | $sk = $wgUser->getSkin(); |
106 | 113 | $wgOut->addHTML( wfMsgExt( 'lqt_move_success', array( 'parse', 'replaceafter' ), |
107 | 114 | array( $sk->link( $newtitle ) ) ) ); |
108 | | - |
| 115 | + |
109 | 116 | return true; |
110 | 117 | } |
111 | | - |
| 118 | + |
112 | 119 | function validateTarget( $target ) { |
113 | | - if (!$target) { |
| 120 | + if ( !$target ) { |
114 | 121 | return wfMsgExt( 'lqt_move_nodestination', 'parseinline' ); |
115 | 122 | } |
116 | | - |
| 123 | + |
117 | 124 | $title = Title::newFromText( $target ); |
118 | | - |
| 125 | + |
119 | 126 | if ( !$title || !LqtDispatch::isLqtPage( $title ) ) { |
120 | 127 | return wfMsgExt( 'lqt_move_thread_bad_destination', 'parseinline' ); |
121 | 128 | } |
122 | | - |
| 129 | + |
123 | 130 | if ( $title->equals( $this->mThread->article()->getTitle() ) ) { |
124 | 131 | return wfMsgExt( 'lqt_move_samedestination', 'parseinline' ); |
125 | 132 | } |
126 | | - |
| 133 | + |
127 | 134 | return true; |
128 | 135 | } |
129 | | - |
130 | 136 | } |
Index: trunk/extensions/LiquidThreads/pages/ThreadActionPage.php |
— | — | @@ -6,40 +6,40 @@ |
7 | 7 | function __construct() { |
8 | 8 | parent::__construct( $this->getPageName(), $this->getRightRequirement() ); |
9 | 9 | $this->includable( false ); |
10 | | - |
| 10 | + |
11 | 11 | global $wgOut, $wgUser, $wgRequest; |
12 | 12 | $this->output = $wgOut; |
13 | 13 | $this->user = $wgUser; |
14 | 14 | $this->request = $wgRequest; |
15 | 15 | } |
16 | | - |
| 16 | + |
17 | 17 | abstract function getPageName(); |
18 | | - |
| 18 | + |
19 | 19 | abstract function getFormFields(); |
20 | | - |
| 20 | + |
21 | 21 | protected function getRightRequirement() { return ''; } |
22 | 22 | |
23 | 23 | function execute( $par ) { |
24 | 24 | wfLoadExtensionMessages( 'LiquidThreads' ); |
25 | | - |
| 25 | + |
26 | 26 | global $wgOut, $wgUser; |
27 | | - |
| 27 | + |
28 | 28 | if ( !$this->userCanExecute( $wgUser ) ) { |
29 | 29 | $this->displayRestrictionError(); |
30 | 30 | return; |
31 | 31 | } |
32 | | - |
| 32 | + |
33 | 33 | // Page title |
34 | 34 | $wgOut->setPageTitle( $this->getDescription() ); |
35 | | - |
36 | | - if ( !$this->checkParameters($par) ) { |
| 35 | + |
| 36 | + if ( !$this->checkParameters( $par ) ) { |
37 | 37 | return; |
38 | 38 | } |
39 | | - |
| 39 | + |
40 | 40 | $form = $this->buildForm(); |
41 | 41 | $form->show(); |
42 | 42 | } |
43 | | - |
| 43 | + |
44 | 44 | // Loads stuff like the thread and so on |
45 | 45 | function checkParameters( $par ) { |
46 | 46 | // Handle parameter |
— | — | @@ -49,32 +49,31 @@ |
50 | 50 | $this->output->addHTML( wfMsg( 'lqt_threadrequired' ) ); |
51 | 51 | return false; |
52 | 52 | } |
53 | | - |
| 53 | + |
54 | 54 | $thread = Threads::withRoot( new Article( Title::newFromURL( $par ) ) ); |
55 | 55 | if ( !$thread ) { |
56 | 56 | $this->output->addHTML( wfMsg( 'lqt_nosuchthread' ) ); |
57 | 57 | return false; |
58 | 58 | } |
59 | | - |
| 59 | + |
60 | 60 | $this->mThread = $thread; |
61 | | - |
| 61 | + |
62 | 62 | return true; |
63 | 63 | } |
64 | | - |
| 64 | + |
65 | 65 | abstract function getSubmitText(); |
66 | | - |
| 66 | + |
67 | 67 | function buildForm() { |
68 | | - $form = new HTMLForm( $this->getFormFields(), 'lqt-'.$this->getPageName() ); |
69 | | - |
| 68 | + $form = new HTMLForm( $this->getFormFields(), 'lqt-' . $this->getPageName() ); |
| 69 | + |
70 | 70 | $par = $this->mThread->title()->getPrefixedText(); |
71 | | - |
| 71 | + |
72 | 72 | $form->setSubmitText( $this->getSubmitText() ); |
73 | 73 | $form->setTitle( SpecialPage::getTitleFor( $this->getPageName(), $par ) ); |
74 | 74 | $form->setSubmitCallback( array( $this, 'trySubmit' ) ); |
75 | | - |
| 75 | + |
76 | 76 | return $form; |
77 | 77 | } |
78 | | - |
79 | | - abstract function trySubmit( $data ); |
80 | 78 | |
| 79 | + abstract function trySubmit( $data ); |
81 | 80 | } |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoricalRevisionView.php |
— | — | @@ -3,7 +3,6 @@ |
4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die; |
5 | 5 | |
6 | 6 | class ThreadHistoricalRevisionView extends ThreadPermalinkView { |
7 | | - |
8 | 7 | public $mDisplayRevision = null; |
9 | 8 | |
10 | 9 | /* TOOD: customize tabs so that History is highlighted. */ |
— | — | @@ -12,16 +11,16 @@ |
13 | 12 | $changedObject = $this->mDisplayRevision->getChangeObject(); |
14 | 13 | $is_changed_thread = $changedObject && |
15 | 14 | ( $changedObject->id() == $thread->id() ); |
16 | | - |
| 15 | + |
17 | 16 | $class = parent::postDivClass( $thread ); |
18 | | - |
| 17 | + |
19 | 18 | if ( $is_changed_thread ) { |
20 | 19 | return "$class lqt_post_changed_by_history"; |
21 | 20 | } else { |
22 | 21 | return $class; |
23 | 22 | } |
24 | 23 | } |
25 | | - |
| 24 | + |
26 | 25 | function getMessageForChangeType( $ct ) { |
27 | 26 | static $messages = array( |
28 | 27 | Threads::CHANGE_NEW_THREAD => 'lqt_change_new_thread', |
— | — | @@ -36,11 +35,11 @@ |
37 | 36 | Threads::CHANGE_SPLIT_FROM => 'lqt_change_split_from', |
38 | 37 | Threads::CHANGE_EDITED_SUMMARY => 'lqt_change_edited_summary', |
39 | 38 | ); |
40 | | - |
41 | | - if ( isset($messages[$ct]) ) { |
| 39 | + |
| 40 | + if ( isset( $messages[$ct] ) ) { |
42 | 41 | return $messages[$ct]; |
43 | 42 | } |
44 | | - |
| 43 | + |
45 | 44 | return ''; |
46 | 45 | } |
47 | 46 | |
— | — | @@ -49,33 +48,38 @@ |
50 | 49 | wfLoadExtensionMessages( 'LiquidThreads' ); |
51 | 50 | |
52 | 51 | $html = ''; |
53 | | - $html .= wfMsgExt( 'lqt_revision_as_of', 'parseinline', |
54 | | - array( |
55 | | - $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ), |
56 | | - $wgLang->date( $this->mDisplayRevision->getTimestamp() ), |
57 | | - $wgLang->time( $this->mDisplayRevision->getTimestamp() ) |
58 | | - ) |
59 | | - ); |
60 | | - |
| 52 | + $html .= wfMsgExt( |
| 53 | + 'lqt_revision_as_of', 'parseinline', |
| 54 | + array( |
| 55 | + $wgLang->timeanddate( $this->mDisplayRevision->getTimestamp() ), |
| 56 | + $wgLang->date( $this->mDisplayRevision->getTimestamp() ), |
| 57 | + $wgLang->time( $this->mDisplayRevision->getTimestamp() ) |
| 58 | + ) |
| 59 | + ); |
| 60 | + |
61 | 61 | $html .= '<br/>'; |
62 | 62 | |
63 | 63 | $ct = $this->mDisplayRevision->getChangeType(); |
64 | | - |
| 64 | + |
65 | 65 | $msg = ''; |
66 | 66 | if ( $ct == Threads::CHANGE_EDITED_ROOT ) { |
67 | | - $diff_link = $this->diffPermalink( $this->thread, |
68 | | - wfMsgExt( 'diff', 'parseinline' ), |
69 | | - $this->mDisplayRevision ); |
70 | | - $msg = wfMsgExt( 'lqt_change_edited_root', 'parseinline' ) . |
71 | | - " [$diff_link]"; |
| 67 | + $diff_link = $this->diffPermalink( |
| 68 | + $this->thread, |
| 69 | + wfMsgExt( 'diff', 'parseinline' ), |
| 70 | + $this->mDisplayRevision |
| 71 | + ); |
| 72 | + $msg = wfMsgExt( |
| 73 | + 'lqt_change_edited_root', |
| 74 | + 'parseinline' |
| 75 | + ) . " [$diff_link]"; |
72 | 76 | } else { |
73 | | - $msg = wfMsgExt( $this->getMessageForChangeType($ct), 'parseinline' ); |
| 77 | + $msg = wfMsgExt( $this->getMessageForChangeType( $ct ), 'parseinline' ); |
74 | 78 | } |
75 | | - |
| 79 | + |
76 | 80 | $html .= $msg; |
77 | | - |
| 81 | + |
78 | 82 | $html = Xml::tags( 'div', array( 'class' => 'lqt_history_info' ), $html ); |
79 | | - |
| 83 | + |
80 | 84 | $this->output->addHTML( $html ); |
81 | 85 | } |
82 | 86 | |
— | — | @@ -84,12 +88,12 @@ |
85 | 89 | $this->showMissingThreadPage(); |
86 | 90 | return false; |
87 | 91 | } |
88 | | - |
| 92 | + |
89 | 93 | $oldid = $this->request->getInt( 'lqt_oldid' ); |
90 | 94 | $this->mDisplayRevision = ThreadRevision::loadFromId( $oldid ); |
91 | 95 | |
92 | 96 | $this->thread = $this->mDisplayRevision->getThreadObj(); |
93 | | - |
| 97 | + |
94 | 98 | $this->showHistoryInfo(); |
95 | 99 | parent::show(); |
96 | 100 | return false; |
Index: trunk/extensions/LiquidThreads/pages/ThreadPermalinkView.php |
— | — | @@ -10,13 +10,13 @@ |
11 | 11 | // Insert fake 'article' and 'discussion' tabs before the thread tab. |
12 | 12 | // If you call the key 'talk', the url gets re-set later. TODO: |
13 | 13 | // the access key for the talk tab doesn't work. |
14 | | - if ($this->thread) { |
| 14 | + if ( $this->thread ) { |
15 | 15 | $article_t = $this->thread->article()->getTitle(); |
16 | 16 | $talk_t = $this->thread->article()->getTitle(); |
17 | 17 | } else { |
18 | 18 | return true; |
19 | 19 | } |
20 | | - |
| 20 | + |
21 | 21 | $articleTab = |
22 | 22 | array( |
23 | 23 | 'text' => wfMsg( $article_t->getNamespaceKey() ), |
— | — | @@ -24,27 +24,27 @@ |
25 | 25 | 'class' => $article_t->exists() ? '' : 'new' |
26 | 26 | ); |
27 | 27 | efInsertIntoAssoc( 'article', $articleTab, 'nstab-thread', $content_actions ); |
28 | | - |
| 28 | + |
29 | 29 | $talkTab = |
30 | 30 | array( |
31 | 31 | // talkpage certainly exists since this thread is from it. |
32 | 32 | 'text' => wfMsg( 'talk' ), |
33 | 33 | 'href' => $talk_t->getFullURL() |
34 | 34 | ); |
35 | | - |
| 35 | + |
36 | 36 | efInsertIntoAssoc( 'not_talk', $talkTab, 'nstab-thread', $content_actions ); |
37 | 37 | |
38 | 38 | unset( $content_actions['edit'] ); |
39 | 39 | unset( $content_actions['viewsource'] ); |
40 | 40 | unset( $content_actions['talk'] ); |
41 | | - |
| 41 | + |
42 | 42 | $subpage = $this->thread->title()->getPrefixedText(); |
43 | | - |
| 43 | + |
44 | 44 | if ( array_key_exists( 'move', $content_actions ) && $this->thread ) { |
45 | 45 | $content_actions['move']['href'] = |
46 | 46 | SpecialPage::getTitleFor( 'MoveThread', $subpage )->getFullURL(); |
47 | 47 | } |
48 | | - |
| 48 | + |
49 | 49 | if ( array_key_exists( 'delete', $content_actions ) && $this->thread ) { |
50 | 50 | $content_actions['delete']['href'] = |
51 | 51 | $this->thread->title()->getFullURL( 'action=delete' ); |
— | — | @@ -77,33 +77,39 @@ |
78 | 78 | |
79 | 79 | function getSubtitle() { |
80 | 80 | wfLoadExtensionMessages( 'LiquidThreads' ); |
81 | | - |
| 81 | + |
82 | 82 | $sk = $this->user->getSkin(); |
83 | | - $fragment = '#'.$this->anchorName( $this->thread ); |
84 | | - |
| 83 | + $fragment = '#' . $this->anchorName( $this->thread ); |
| 84 | + |
85 | 85 | if ( $this->thread->isHistorical() ) { |
86 | 86 | // TODO: Point to the relevant part of the archive. |
87 | 87 | $query = ''; |
88 | 88 | } else { |
89 | 89 | $query = ''; |
90 | 90 | } |
91 | | - |
| 91 | + |
92 | 92 | $talkpage = $this->thread->article()->getTitle(); |
93 | 93 | $talkpage->setFragment( $fragment ); |
94 | 94 | $talkpage_link = $sk->link( $talkpage ); |
95 | | - |
| 95 | + |
96 | 96 | if ( $this->thread->hasSuperthread() ) { |
97 | 97 | $topmostTitle = $this->thread->topmostThread()->title(); |
98 | 98 | $topmostTitle->setFragment( $fragment ); |
99 | | - |
| 99 | + |
100 | 100 | $linkText = wfMsgExt( 'lqt_discussion_link', 'parseinline' ); |
101 | 101 | $permalink = $sk->link( $topmostTitle, $linkText ); |
102 | | - |
103 | | - return wfMsgExt( 'lqt_fragment', array('parseinline', 'replaceafter'), |
104 | | - array( $permalink, $talkpage_link ) ); |
| 102 | + |
| 103 | + return wfMsgExt( |
| 104 | + 'lqt_fragment', |
| 105 | + array( 'parseinline', 'replaceafter' ), |
| 106 | + array( $permalink, $talkpage_link ) |
| 107 | + ); |
105 | 108 | } else { |
106 | | - return wfMsgExt( 'lqt_from_talk', array('parseinline', 'replaceafter'), |
107 | | - array($talkpage_link) ); |
| 109 | + return wfMsgExt( |
| 110 | + 'lqt_from_talk', |
| 111 | + array( 'parseinline', 'replaceafter' ), |
| 112 | + array( $talkpage_link ) |
| 113 | + ); |
108 | 114 | } |
109 | 115 | } |
110 | 116 | |
— | — | @@ -112,7 +118,7 @@ |
113 | 119 | parent::__construct( $output, $article, $title, $user, $request ); |
114 | 120 | |
115 | 121 | $t = Threads::withRoot( $this->article ); |
116 | | - |
| 122 | + |
117 | 123 | $this->thread = $t; |
118 | 124 | if ( !$t ) { |
119 | 125 | return; // error reporting is handled in show(). this kinda sucks. |
— | — | @@ -132,7 +138,7 @@ |
133 | 139 | $this->showMissingThreadPage(); |
134 | 140 | return false; |
135 | 141 | } |
136 | | - |
| 142 | + |
137 | 143 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
138 | 144 | $this->doInlineEditForm(); |
139 | 145 | return false; |
— | — | @@ -146,8 +152,8 @@ |
147 | 153 | elseif ( $this->methodApplies( 'split' ) ) |
148 | 154 | $this->showSplitForm( $this->thread ); |
149 | 155 | |
150 | | - $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => -1, 'maxCount' => -1 ) ); |
151 | | - |
| 156 | + $this->showThread( $this->thread, 1, 1, array( 'maxDepth' => - 1, 'maxCount' => - 1 ) ); |
| 157 | + |
152 | 158 | $this->output->setPageTitle( $this->thread->subject() ); |
153 | 159 | return false; |
154 | 160 | } |
Index: trunk/extensions/LiquidThreads/pages/NewUserMessagesView.php |
— | — | @@ -13,10 +13,15 @@ |
14 | 14 | $html = ''; |
15 | 15 | $html .= Xml::hidden( 'lqt_method', 'mark_as_read' ); |
16 | 16 | $html .= Xml::hidden( 'lqt_operand', $ids_s ); |
17 | | - $html .= Xml::submitButton( $label, array( 'name' => 'lqt_read_button', |
18 | | - 'title' => $title ) ); |
| 17 | + $html .= Xml::submitButton( |
| 18 | + $label, |
| 19 | + array( |
| 20 | + 'name' => 'lqt_read_button', |
| 21 | + 'title' => $title |
| 22 | + ) |
| 23 | + ); |
19 | 24 | $html = Xml::tags( 'form', array( 'method' => 'post', 'class' => $class ), $html ); |
20 | | - |
| 25 | + |
21 | 26 | return $html; |
22 | 27 | } |
23 | 28 | |
— | — | @@ -24,49 +29,56 @@ |
25 | 30 | wfLoadExtensionMessages( 'LiquidThreads' ); |
26 | 31 | $ids = array_map( create_function( '$t', 'return $t->id();' ), $threads ); // ew |
27 | 32 | return $this->htmlForReadButton( |
28 | | - wfMsg( 'lqt-read-all' ), |
29 | | - wfMsg( 'lqt-read-all-tooltip' ), |
30 | | - "lqt_newmessages_read_all_button", |
31 | | - $ids |
32 | | - ); |
| 33 | + wfMsg( 'lqt-read-all' ), |
| 34 | + wfMsg( 'lqt-read-all-tooltip' ), |
| 35 | + "lqt_newmessages_read_all_button", |
| 36 | + $ids |
| 37 | + ); |
33 | 38 | } |
34 | 39 | |
35 | 40 | function getUndoButton( $ids ) { |
36 | 41 | wfLoadExtensionMessages( 'LiquidThreads' ); |
37 | | - |
| 42 | + |
38 | 43 | if ( count( $ids ) == 1 ) { |
39 | 44 | $t = Threads::withId( $ids[0] ); |
40 | 45 | if ( !$t ) |
41 | 46 | return; // empty or just bogus operand. |
42 | | - $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array($t->subject()) ); |
| 47 | + $msg = wfMsgExt( 'lqt-marked-read', 'parseinline', array( $t->subject() ) ); |
43 | 48 | } else { |
44 | 49 | $count = count( $ids ); |
45 | | - $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array($count) ); |
| 50 | + $msg = wfMsgExt( 'lqt-count-marked-read', 'parseinline', array( $count ) ); |
46 | 51 | } |
47 | 52 | $operand = implode( ',', $ids ); |
48 | | - |
| 53 | + |
49 | 54 | $html = ''; |
50 | 55 | $html .= $msg; |
51 | 56 | $html .= Xml::hidden( 'lqt_method', 'mark_as_unread' ); |
52 | 57 | $html .= Xml::hidden( 'lqt_operand', $operand ); |
53 | | - $html .= Xml::submitButton( wfMsg('lqt-email-undo'), array( 'name' => 'lqt_read_button', |
54 | | - 'title' => wfMsg( 'lqt-email-info-undo' ) ) ); |
55 | | - |
56 | | - $html = Xml::tags( 'form', |
57 | | - array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), |
58 | | - $html ); |
59 | | - |
| 58 | + $html .= Xml::submitButton( |
| 59 | + wfMsg( 'lqt-email-undo' ), |
| 60 | + array( |
| 61 | + 'name' => 'lqt_read_button', |
| 62 | + 'title' => wfMsg( 'lqt-email-info-undo' ) |
| 63 | + ) |
| 64 | + ); |
| 65 | + |
| 66 | + $html = Xml::tags( |
| 67 | + 'form', |
| 68 | + array( 'method' => 'post', 'class' => 'lqt_undo_mark_as_read' ), |
| 69 | + $html |
| 70 | + ); |
| 71 | + |
60 | 72 | return $html; |
61 | 73 | } |
62 | 74 | |
63 | 75 | function postDivClass( $thread ) { |
64 | 76 | $origClass = parent::postDivClass( $thread ); |
65 | | - |
| 77 | + |
66 | 78 | $topid = $thread->topmostThread()->id(); |
67 | | - |
| 79 | + |
68 | 80 | if ( in_array( $thread->id(), $this->targets[$topid] ) ) |
69 | 81 | return "$origClass lqt_post_new_message"; |
70 | | - |
| 82 | + |
71 | 83 | return $origClass; |
72 | 84 | } |
73 | 85 | |
— | — | @@ -82,11 +94,13 @@ |
83 | 95 | |
84 | 96 | if ( $this->request->wasPosted() && $this->methodApplies( 'mark_as_unread' ) ) { |
85 | 97 | $ids = explode( ',', $this->request->getVal( 'lqt_operand', '' ) ); |
86 | | - |
| 98 | + |
87 | 99 | if ( $ids !== false ) { |
88 | 100 | foreach ( $ids as $id ) { |
89 | | - $tmp_thread = Threads::withId( $id ); if ( $tmp_thread ) |
| 101 | + $tmp_thread = Threads::withId( $id ); |
| 102 | + if ( $tmp_thread ) { |
90 | 103 | NewMessages::markThreadAsUnReadByUser( $tmp_thread, $this->user ); |
| 104 | + } |
91 | 105 | } |
92 | 106 | $this->output->redirect( $this->title->getFullURL() ); |
93 | 107 | } |
— | — | @@ -95,8 +109,9 @@ |
96 | 110 | if ( $ids !== false ) { |
97 | 111 | foreach ( $ids as $id ) { |
98 | 112 | $tmp_thread = Threads::withId( $id ); |
99 | | - if ( $tmp_thread ) |
| 113 | + if ( $tmp_thread ) { |
100 | 114 | NewMessages::markThreadAsReadByUser( $tmp_thread, $this->user ); |
| 115 | + } |
101 | 116 | } |
102 | 117 | $query = 'lqt_method=undo_mark_as_read&lqt_operand=' . implode( ',', $ids ); |
103 | 118 | $this->output->redirect( $this->title->getFullURL( $query ) ); |
— | — | @@ -111,7 +126,7 @@ |
112 | 127 | if ( ! is_array( $this->threads ) ) { |
113 | 128 | throw new MWException( 'You must use NewUserMessagesView::setThreads() before calling NewUserMessagesView::show().' ); |
114 | 129 | } |
115 | | - |
| 130 | + |
116 | 131 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
117 | 132 | $this->doInlineEditForm(); |
118 | 133 | return false; |
— | — | @@ -124,10 +139,10 @@ |
125 | 140 | $this->tops = array(); |
126 | 141 | foreach ( $this->threads as $t ) { |
127 | 142 | $top = $t->topmostThread(); |
128 | | - |
| 143 | + |
129 | 144 | // It seems that in some cases $top is zero. |
130 | | - if (!$top) |
131 | | - throw new MWException("{$t->id()} seems to have no topmost thread"); |
| 145 | + if ( !$top ) |
| 146 | + throw new MWException( "{$t->id()} seems to have no topmost thread" ); |
132 | 147 | |
133 | 148 | if ( !array_key_exists( $top->id(), $this->tops ) ) |
134 | 149 | $this->tops[$top->id()] = $top; |
— | — | @@ -135,7 +150,7 @@ |
136 | 151 | $this->targets[$top->id()] = array(); |
137 | 152 | $this->targets[$top->id()][] = $t->id(); |
138 | 153 | } |
139 | | - |
| 154 | + |
140 | 155 | $this->output->addHTML( '<table><tbody>' ); |
141 | 156 | |
142 | 157 | foreach ( $this->tops as $t ) { |
— | — | @@ -145,34 +160,39 @@ |
146 | 161 | |
147 | 162 | $this->showWrappedThread( $t ); |
148 | 163 | } |
149 | | - |
| 164 | + |
150 | 165 | $this->output->addHTML( '</tbody></table>' ); |
151 | | - |
| 166 | + |
152 | 167 | return false; |
153 | 168 | } |
154 | | - |
| 169 | + |
155 | 170 | function showWrappedThread( $t ) { |
156 | 171 | wfLoadExtensionMessages( 'LiquidThreads' ); |
157 | | - |
| 172 | + |
158 | 173 | $read_button = $this->htmlForReadButton( |
159 | 174 | wfMsg( 'lqt-read-message' ), |
160 | 175 | wfMsg( 'lqt-read-message-tooltip' ), |
161 | 176 | 'lqt_newmessages_read_button', |
162 | 177 | $this->targets[$t->id()] ); |
163 | | - |
| 178 | + |
164 | 179 | // Left-hand column � read button and context link to the full thread. |
165 | 180 | $topmostThread = $t->topmostThread(); |
166 | | - $contextLink = self::permalink( $topmostThread, |
167 | | - wfMsgExt( 'lqt-newmessages-context', 'parseinline' ) ); |
| 181 | + $contextLink = self::permalink( |
| 182 | + $topmostThread, |
| 183 | + wfMsgExt( 'lqt-newmessages-context', 'parseinline' ) |
| 184 | + ); |
168 | 185 | $leftColumn = Xml::tags( 'p', null, $read_button ) . |
169 | 186 | Xml::tags( 'p', null, $contextLink ); |
170 | | - $leftColumn = Xml::tags( 'td', array( 'class' => 'mw-lqt-newmessages-left' ), |
171 | | - $leftColumn ); |
| 187 | + $leftColumn = Xml::tags( |
| 188 | + 'td', |
| 189 | + array( 'class' => 'mw-lqt-newmessages-left' ), |
| 190 | + $leftColumn |
| 191 | + ); |
172 | 192 | $html = "<tr>$leftColumn<td>"; |
173 | 193 | $this->output->addHTML( $html ); |
174 | 194 | |
175 | 195 | $this->showThread( $t ); |
176 | | - |
| 196 | + |
177 | 197 | $this->output->addHTML( "</td></tr>" ); |
178 | 198 | } |
179 | 199 | |
Index: trunk/extensions/LiquidThreads/pages/ThreadHistoryListingView.php |
— | — | @@ -13,92 +13,90 @@ |
14 | 14 | } |
15 | 15 | self::addJSandCSS(); |
16 | 16 | wfLoadExtensionMessages( 'LiquidThreads' ); |
17 | | - |
| 17 | + |
18 | 18 | $this->thread->updateHistory(); |
19 | 19 | |
20 | 20 | $this->output->setPageTitle( wfMsg( 'lqt-history-title' ) ); |
21 | 21 | $this->output->setSubtitle( $this->getSubtitle() . '<br />' . |
22 | 22 | wfMsg( 'lqt_hist_listing_subtitle' ) ); |
23 | 23 | $this->showThreadHeading( $this->thread ); |
24 | | - |
| 24 | + |
25 | 25 | $pager = new ThreadHistoryPager( $this, $this->thread ); |
26 | | - |
| 26 | + |
27 | 27 | $html = $pager->getNavigationBar() . |
28 | 28 | $pager->getBody() . |
29 | 29 | $pager->getNavigationBar(); |
30 | | - |
| 30 | + |
31 | 31 | $this->output->addHTML( $html ); |
32 | | - |
| 32 | + |
33 | 33 | $this->showThread( $this->thread ); |
34 | | - |
| 34 | + |
35 | 35 | return false; |
36 | 36 | } |
37 | 37 | } |
38 | 38 | |
39 | 39 | class ThreadHistoryPager extends TablePager { |
40 | 40 | static $change_names; |
41 | | - |
42 | 41 | |
| 42 | + |
43 | 43 | function __construct( $view, $thread ) { |
44 | 44 | parent::__construct(); |
45 | | - |
| 45 | + |
46 | 46 | $this->thread = $thread; |
47 | 47 | $this->view = $view; |
48 | | - |
49 | | - self::$change_names = |
50 | | - array( |
51 | | - Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ), |
52 | | - Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ), |
53 | | - Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ), |
54 | | - Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ), |
55 | | - Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ), |
56 | | - Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ), |
57 | | - Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ), |
58 | | - Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ), |
59 | | - Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ), |
60 | | - Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ), |
61 | | - Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ), |
62 | | - Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ), |
63 | | - ); |
| 48 | + |
| 49 | + self::$change_names = array( |
| 50 | + Threads::CHANGE_EDITED_ROOT => wfMsgNoTrans( 'lqt_hist_comment_edited' ), |
| 51 | + Threads::CHANGE_EDITED_SUMMARY => wfMsgNoTrans( 'lqt_hist_summary_changed' ), |
| 52 | + Threads::CHANGE_REPLY_CREATED => wfMsgNoTrans( 'lqt_hist_reply_created' ), |
| 53 | + Threads::CHANGE_NEW_THREAD => wfMsgNoTrans( 'lqt_hist_thread_created' ), |
| 54 | + Threads::CHANGE_DELETED => wfMsgNoTrans( 'lqt_hist_deleted' ), |
| 55 | + Threads::CHANGE_UNDELETED => wfMsgNoTrans( 'lqt_hist_undeleted' ), |
| 56 | + Threads::CHANGE_MOVED_TALKPAGE => wfMsgNoTrans( 'lqt_hist_moved_talkpage' ), |
| 57 | + Threads::CHANGE_EDITED_SUBJECT => wfMsgNoTrans( 'lqt_hist_edited_subject' ), |
| 58 | + Threads::CHANGE_SPLIT => wfMsgNoTrans( 'lqt_hist_split' ), |
| 59 | + Threads::CHANGE_MERGED_FROM => wfMsgNoTrans( 'lqt_hist_merged_from' ), |
| 60 | + Threads::CHANGE_MERGED_TO => wfMsgNoTrans( 'lqt_hist_merged_to' ), |
| 61 | + Threads::CHANGE_SPLIT_FROM => wfMsgNoTrans( 'lqt_hist_split_from' ), |
| 62 | + ); |
64 | 63 | } |
65 | | - |
| 64 | + |
66 | 65 | function getQueryInfo() { |
67 | | - $queryInfo = |
68 | | - array( |
69 | | - 'tables' => array( 'thread_history' ), |
70 | | - 'fields' => '*', |
71 | | - 'conds' => array( 'th_thread' => $this->thread->id() ), |
72 | | - 'options' => array( 'order by' => 'th_timestamp desc' ), |
73 | | - ); |
74 | | - |
| 66 | + $queryInfo = array( |
| 67 | + 'tables' => array( 'thread_history' ), |
| 68 | + 'fields' => '*', |
| 69 | + 'conds' => array( 'th_thread' => $this->thread->id() ), |
| 70 | + 'options' => array( 'order by' => 'th_timestamp desc' ), |
| 71 | + ); |
| 72 | + |
75 | 73 | return $queryInfo; |
76 | 74 | } |
77 | | - |
| 75 | + |
78 | 76 | function getFieldNames() { |
79 | 77 | static $headers = null; |
80 | 78 | |
81 | | - if (!empty($headers)) { |
| 79 | + if ( !empty( $headers ) ) { |
82 | 80 | return $headers; |
83 | 81 | } |
84 | 82 | |
85 | | - $headers = array( |
86 | | - 'th_timestamp' => 'lqt-history-time', |
87 | | - 'th_user_text' => 'lqt-history-user', |
| 83 | + $headers = array( |
| 84 | + 'th_timestamp' => 'lqt-history-time', |
| 85 | + 'th_user_text' => 'lqt-history-user', |
88 | 86 | 'th_change_type' => 'lqt-history-action', |
89 | | - 'th_change_comment' => 'lqt-history-comment', |
90 | | - ); |
| 87 | + 'th_change_comment' => 'lqt-history-comment', |
| 88 | + ); |
91 | 89 | |
92 | 90 | $headers = array_map( 'wfMsg', $headers ); |
93 | 91 | |
94 | 92 | return $headers; |
95 | 93 | } |
96 | | - |
| 94 | + |
97 | 95 | function formatValue( $name, $value ) { |
98 | | - global $wgOut,$wgLang, $wgTitle; |
| 96 | + global $wgOut, $wgLang, $wgTitle; |
99 | 97 | |
100 | | - static $sk=null; |
| 98 | + static $sk = null; |
101 | 99 | |
102 | | - if (empty($sk)) { |
| 100 | + if ( empty( $sk ) ) { |
103 | 101 | global $wgUser; |
104 | 102 | $sk = $wgUser->getSkin(); |
105 | 103 | } |
— | — | @@ -107,7 +105,7 @@ |
108 | 106 | |
109 | 107 | $formatted = ''; |
110 | 108 | |
111 | | - switch($name) { |
| 109 | + switch( $name ) { |
112 | 110 | case 'th_timestamp': |
113 | 111 | $formatted = $wgLang->timeanddate( $value ); |
114 | 112 | return $sk->link( $wgTitle, $formatted, array(), |
— | — | @@ -124,20 +122,19 @@ |
125 | 123 | break; |
126 | 124 | } |
127 | 125 | } |
128 | | - |
| 126 | + |
129 | 127 | function getIndexField() { |
130 | 128 | return 'th_timestamp'; |
131 | 129 | } |
132 | | - |
| 130 | + |
133 | 131 | function getDefaultSort() { |
134 | 132 | return 'th_timestamp'; |
135 | 133 | } |
136 | 134 | |
137 | | - function isFieldSortable($name) { |
| 135 | + function isFieldSortable( $name ) { |
138 | 136 | $sortable_fields = array( 'th_timestamp', 'th_user_text', 'th_change_type' ); |
139 | 137 | return in_array( $name, $sortable_fields ); |
140 | 138 | } |
141 | | - |
| 139 | + |
142 | 140 | function getDefaultDirections() { return true; /* descending */ } |
143 | 141 | } |
144 | | - |
Index: trunk/extensions/LiquidThreads/pages/SpecialNewMessages.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | $this->request = $wgRequest; |
28 | 28 | |
29 | 29 | $this->setHeaders(); |
30 | | - |
| 30 | + |
31 | 31 | $article = new Article( $this->getTitle() ); |
32 | 32 | $title = $this->getTitle(); |
33 | 33 | |
— | — | @@ -42,21 +42,27 @@ |
43 | 43 | $wgOut->addWikitext( wfMsg( 'lqt-no-new-messages' ) ); |
44 | 44 | return; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | $html = ''; |
48 | | - |
| 48 | + |
49 | 49 | $html .= $view->getReadAllButton( $both_sets ); |
50 | 50 | |
51 | 51 | $view->setHeaderLevel( 3 ); |
52 | 52 | |
53 | | - $html .= Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ), |
54 | | - wfMsgExt( 'lqt-messages-sent', 'parseinline' ) ); |
| 53 | + $html .= Xml::tags( |
| 54 | + 'h2', |
| 55 | + array( 'class' => 'lqt_newmessages_section' ), |
| 56 | + wfMsgExt( 'lqt-messages-sent', 'parseinline' ) |
| 57 | + ); |
55 | 58 | $wgOut->addHTML( $html ); |
56 | 59 | $view->setThreads( $first_set ); |
57 | 60 | $view->show(); |
58 | 61 | |
59 | | - $wgOut->addHTML( Xml::tags( 'h2', array( 'class' => 'lqt_newmessages_section' ), |
60 | | - wfMsgExt( 'lqt-other-messages', 'parseinline' ) ) ); |
| 62 | + $wgOut->addHTML( Xml::tags( |
| 63 | + 'h2', |
| 64 | + array( 'class' => 'lqt_newmessages_section' ), |
| 65 | + wfMsgExt( 'lqt-other-messages', 'parseinline' ) |
| 66 | + ) ); |
61 | 67 | $view->setThreads( $second_set ); |
62 | 68 | $view->show(); |
63 | 69 | } |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | |
21 | 21 | function showHeader() { |
22 | 22 | /* Show the contents of the actual talkpage article if it exists. */ |
23 | | - |
| 23 | + |
24 | 24 | global $wgUser; |
25 | 25 | $sk = $wgUser->getSkin(); |
26 | 26 | |
— | — | @@ -32,107 +32,124 @@ |
33 | 33 | // when the first thread was posted to make the links blue. |
34 | 34 | if ( $article->exists() && $article->getContent() ) { |
35 | 35 | $html = ''; |
36 | | - |
| 36 | + |
37 | 37 | $article->view(); |
38 | | - |
| 38 | + |
39 | 39 | $actionLinks = array(); |
40 | | - $actionLinks[] = $sk->link( $this->title, |
41 | | - wfMsgExt( 'edit', 'parseinline' ) . "↑", |
42 | | - array(), array( 'action' => 'edit' ) ); |
43 | | - $actionLinks[] = $sk->link( $this->title, |
44 | | - wfMsgExt( 'history_short', 'parseinline' ) . "↑", |
45 | | - array(), array( 'action' => 'history' ) ); |
46 | | - |
| 40 | + $actionLinks[] = $sk->link( |
| 41 | + $this->title, |
| 42 | + wfMsgExt( 'edit', 'parseinline' ) . "↑", |
| 43 | + array(), |
| 44 | + array( 'action' => 'edit' ) |
| 45 | + ); |
| 46 | + $actionLinks[] = $sk->link( |
| 47 | + $this->title, |
| 48 | + wfMsgExt( 'history_short', 'parseinline' ) . "↑", |
| 49 | + array(), |
| 50 | + array( 'action' => 'history' ) |
| 51 | + ); |
| 52 | + |
47 | 53 | if ( $wgUser->isAllowed( 'delete' ) ) { |
48 | | - $actionLinks[] = $sk->link( $this->title, |
49 | | - wfMsgExt( 'delete', 'parseinline' ) . '↑', |
50 | | - array(), array( 'action' => 'delete' ) ); |
| 54 | + $actionLinks[] = $sk->link( |
| 55 | + $this->title, |
| 56 | + wfMsgExt( 'delete', 'parseinline' ) . '↑', |
| 57 | + array(), |
| 58 | + array( 'action' => 'delete' ) |
| 59 | + ); |
51 | 60 | } |
52 | | - |
| 61 | + |
53 | 62 | $actions = ''; |
54 | | - foreach( $actionLinks as $link ) { |
| 63 | + foreach ( $actionLinks as $link ) { |
55 | 64 | $actions .= Xml::tags( 'li', null, "[$link]" ) . "\n"; |
56 | 65 | } |
57 | 66 | $actions = Xml::tags( 'ul', array( 'class' => 'lqt_header_commands' ), $actions ); |
58 | 67 | $html .= $actions; |
59 | 68 | |
60 | 69 | $html = Xml::tags( 'div', array( 'class' => 'lqt_header_content' ), $html ); |
61 | | - |
| 70 | + |
62 | 71 | $this->output->addHTML( $html ); |
63 | 72 | } else { |
64 | | - |
65 | | - $editLink = $sk->link( $this->title, wfMsgExt( 'lqt_add_header', 'parseinline' ), |
66 | | - array(), array( 'action' => 'edit' ) ); |
67 | | - |
| 73 | + |
| 74 | + $editLink = $sk->link( |
| 75 | + $this->title, |
| 76 | + wfMsgExt( 'lqt_add_header', 'parseinline' ), |
| 77 | + array(), |
| 78 | + array( 'action' => 'edit' ) |
| 79 | + ); |
| 80 | + |
68 | 81 | $html = Xml::tags( 'p', array( 'class' => 'lqt_header_notice' ), "[$editLink]" ); |
69 | | - |
| 82 | + |
70 | 83 | $this->output->addHTML( $html ); |
71 | 84 | } |
72 | 85 | } |
73 | | - |
| 86 | + |
74 | 87 | function getTOC( $threads ) { |
75 | 88 | global $wgLang; |
76 | | - |
| 89 | + |
77 | 90 | wfLoadExtensionMessages( 'LiquidThreads' ); |
78 | 91 | |
79 | 92 | $sk = $this->user->getSkin(); |
80 | | - |
| 93 | + |
81 | 94 | $html = ''; |
82 | | - |
| 95 | + |
83 | 96 | $h2_header = Xml::tags( 'h2', null, wfMsgExt( 'lqt_contents_title', 'parseinline' ) ); |
84 | | - |
| 97 | + |
85 | 98 | // Header row |
86 | 99 | $headerRow = ''; |
87 | | - $headers = array( 'lqt_toc_thread_title', 'lqt_toc_thread_author', |
88 | | - 'lqt_toc_thread_replycount', 'lqt_toc_thread_modified' ); |
89 | | - foreach( $headers as $msg ) { |
| 100 | + $headers = array( |
| 101 | + 'lqt_toc_thread_title', |
| 102 | + 'lqt_toc_thread_author', |
| 103 | + 'lqt_toc_thread_replycount', |
| 104 | + 'lqt_toc_thread_modified' |
| 105 | + ); |
| 106 | + foreach ( $headers as $msg ) { |
90 | 107 | $headerRow .= Xml::tags( 'th', null, wfMsgExt( $msg, 'parseinline' ) ); |
91 | 108 | } |
92 | 109 | $headerRow = Xml::tags( 'tr', null, $headerRow ); |
93 | 110 | $headerRow = Xml::tags( 'thead', null, $headerRow ); |
94 | | - |
| 111 | + |
95 | 112 | // Table body |
96 | 113 | $rows = array(); |
97 | | - foreach( $threads as $thread ) { |
| 114 | + foreach ( $threads as $thread ) { |
98 | 115 | $row = ''; |
99 | | - $anchor = '#'.$this->anchorName( $thread ); |
| 116 | + $anchor = '#' . $this->anchorName( $thread ); |
100 | 117 | $subject = $this->output->parseInline( $thread->subjectWithoutIncrement() ); |
101 | 118 | $subject = Xml::tags( 'a', array( 'href' => $anchor ), $subject ); |
102 | 119 | $row .= Xml::tags( 'td', null, $subject ); |
103 | | - |
| 120 | + |
104 | 121 | $author = $thread->author(); |
105 | 122 | $authorLink = $sk->userLink( $author->getId(), $author->getName() ); |
106 | 123 | $row .= Xml::tags( 'td', null, $authorLink ); |
107 | | - |
| 124 | + |
108 | 125 | $row .= Xml::element( 'td', null, count( $thread->replies() ) ); |
109 | | - |
| 126 | + |
110 | 127 | $timestamp = $wgLang->timeanddate( $thread->modified(), true ); |
111 | 128 | $row .= Xml::element( 'td', null, $timestamp ); |
112 | | - |
| 129 | + |
113 | 130 | $row = Xml::tags( 'tr', null, $row ); |
114 | 131 | $rows[] = $row; |
115 | 132 | } |
116 | | - |
| 133 | + |
117 | 134 | $html .= $headerRow . "\n" . Xml::tags( 'tbody', null, implode( "\n", $rows ) ); |
118 | 135 | $html = $h2_header . Xml::tags( 'table', array( 'class' => 'lqt_toc' ), $html ); |
119 | | - |
| 136 | + |
120 | 137 | return $html; |
121 | 138 | } |
122 | | - |
| 139 | + |
123 | 140 | function getList( $kind, $class, $id, $contents ) { |
124 | 141 | $html = ''; |
125 | 142 | foreach ( $contents as $li ) { |
126 | 143 | $html .= Xml::tags( 'li', null, $li ); |
127 | 144 | } |
128 | 145 | $html = Xml::tags( $kind, array( 'class' => $class, 'id' => $id ), $html ); |
129 | | - |
| 146 | + |
130 | 147 | return $html; |
131 | 148 | } |
132 | 149 | |
133 | 150 | function getArchiveWidget( ) { |
134 | 151 | wfLoadExtensionMessages( 'LiquidThreads' ); |
135 | 152 | $url = $this->talkpageUrl( $this->title, 'talkpage_archive' ); |
136 | | - |
| 153 | + |
137 | 154 | $html = ''; |
138 | 155 | $html = Xml::tags( 'div', array( 'class' => 'lqt_archive_teaser' ), $html ); |
139 | 156 | return $html; |
— | — | @@ -144,32 +161,44 @@ |
145 | 162 | if ( $article->exists() ) { |
146 | 163 | $form_action_url = $this->talkpageUrl( $this->title, 'talkpage_sort_order' ); |
147 | 164 | $go = wfMsg( 'go' ); |
148 | | - |
| 165 | + |
149 | 166 | $html = ''; |
150 | | - |
| 167 | + |
151 | 168 | $html .= Xml::label( wfMsg( 'lqt_sorting_order' ), 'lqt_sort_select' ) . ' '; |
152 | 169 | |
153 | 170 | $sortOrderSelect = |
154 | 171 | new XmlSelect( 'lqt_order', 'lqt_sort_select', $this->getSortType() ); |
155 | | - |
| 172 | + |
156 | 173 | $sortOrderSelect->setAttribute( 'class', 'lqt_sort_select' ); |
157 | | - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_changes' ), |
158 | | - LQT_NEWEST_CHANGES ); |
159 | | - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_newest_threads' ), |
160 | | - LQT_NEWEST_THREADS ); |
161 | | - $sortOrderSelect->addOption( wfMsg( 'lqt_sort_oldest_threads' ), |
162 | | - LQT_OLDEST_THREADS ); |
| 174 | + $sortOrderSelect->addOption( |
| 175 | + wfMsg( 'lqt_sort_newest_changes' ), |
| 176 | + LQT_NEWEST_CHANGES |
| 177 | + ); |
| 178 | + $sortOrderSelect->addOption( |
| 179 | + wfMsg( 'lqt_sort_newest_threads' ), |
| 180 | + LQT_NEWEST_THREADS |
| 181 | + ); |
| 182 | + $sortOrderSelect->addOption( |
| 183 | + wfMsg( 'lqt_sort_oldest_threads' ), |
| 184 | + LQT_OLDEST_THREADS |
| 185 | + ); |
163 | 186 | $html .= $sortOrderSelect->getHTML(); |
164 | | - |
| 187 | + |
165 | 188 | $html .= Xml::submitButton( wfMsg( 'go' ), array( 'class' => 'lqt_go_sort' ) ); |
166 | 189 | $html .= Xml::hidden( 'title', $this->title->getPrefixedText() ); |
167 | | - |
168 | | - |
169 | | - $html = Xml::tags( 'form', array( 'action' => $form_action_url, |
170 | | - 'method' => 'get', |
171 | | - 'name' => 'lqt_sort' ), $html ); |
| 190 | + |
| 191 | + |
| 192 | + $html = Xml::tags( |
| 193 | + 'form', |
| 194 | + array( |
| 195 | + 'action' => $form_action_url, |
| 196 | + 'method' => 'get', |
| 197 | + 'name' => 'lqt_sort' |
| 198 | + ), |
| 199 | + $html |
| 200 | + ); |
172 | 201 | $html = Xml::tags( 'div', array( 'class' => 'lqt_view_options' ), $html ); |
173 | | - |
| 202 | + |
174 | 203 | return $html; |
175 | 204 | } |
176 | 205 | } |
— | — | @@ -182,54 +211,62 @@ |
183 | 212 | |
184 | 213 | $this->output->setPageTitle( $this->title->getPrefixedText() ); |
185 | 214 | self::addJSandCSS(); |
186 | | - |
| 215 | + |
187 | 216 | $sk = $this->user->getSkin(); |
188 | | - |
| 217 | + |
189 | 218 | $article = new Article( $this->title ); |
190 | | - |
| 219 | + |
191 | 220 | if ( $this->request->getBool( 'lqt_inline' ) ) { |
192 | 221 | $this->doInlineEditForm(); |
193 | 222 | return false; |
194 | 223 | } |
195 | | - |
| 224 | + |
196 | 225 | // Search! |
197 | 226 | if ( $this->request->getCheck( 'lqt_search' ) ) { |
198 | 227 | $q = $this->request->getText( 'lqt_search' ); |
199 | | - $q .= ' ondiscussionpage:'.$article->getTitle()->getPrefixedText(); |
200 | | - |
201 | | - $params = array( 'search' => $q, |
202 | | - 'fulltext' => 1, |
203 | | - 'ns'.NS_LQT_THREAD => 1, |
204 | | - ); |
205 | | - |
| 228 | + $q .= ' ondiscussionpage:' . $article->getTitle()->getPrefixedText(); |
| 229 | + |
| 230 | + $params = array( |
| 231 | + 'search' => $q, |
| 232 | + 'fulltext' => 1, |
| 233 | + 'ns' . NS_LQT_THREAD => 1, |
| 234 | + ); |
| 235 | + |
206 | 236 | $t = SpecialPage::getTitleFor( 'Search' ); |
207 | 237 | $url = $t->getLocalURL( wfArrayToCGI( $params ) ); |
208 | | - |
| 238 | + |
209 | 239 | $this->output->redirect( $url ); |
210 | | - |
211 | 240 | } |
212 | 241 | |
213 | 242 | $this->showHeader(); |
214 | | - |
| 243 | + |
215 | 244 | $html = ''; |
216 | | - |
| 245 | + |
217 | 246 | // Set up a per-page header for new threads, search box, and sorting stuff. |
218 | | - |
| 247 | + |
219 | 248 | $talkpageHeader = ''; |
220 | | - |
| 249 | + |
221 | 250 | $newThreadText = wfMsgExt( 'lqt_new_thread', 'parseinline' ); |
222 | | - $newThreadLink = $sk->link( $this->title, $newThreadText, |
223 | | - array( ), |
224 | | - array( 'lqt_method' => 'talkpage_new_thread' ), |
225 | | - array( 'known' ) ); |
226 | | - |
227 | | - $talkpageHeader .= Xml::tags( 'strong', array( 'class' => 'lqt_start_discussion' ), |
228 | | - $newThreadLink ); |
| 251 | + $newThreadLink = $sk->link( |
| 252 | + $this->title, $newThreadText, |
| 253 | + array(), |
| 254 | + array( 'lqt_method' => 'talkpage_new_thread' ), |
| 255 | + array( 'known' ) |
| 256 | + ); |
| 257 | + |
| 258 | + $talkpageHeader .= Xml::tags( |
| 259 | + 'strong', |
| 260 | + array( 'class' => 'lqt_start_discussion' ), |
| 261 | + $newThreadLink |
| 262 | + ); |
229 | 263 | $talkpageHeader .= $this->getSearchBox(); |
230 | 264 | $talkpageHeader .= $this->showTalkpageViewOptions( $article ); |
231 | | - $talkpageHeader = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-header' ), |
232 | | - $talkpageHeader ); |
233 | | - |
| 265 | + $talkpageHeader = Xml::tags( |
| 266 | + 'div', |
| 267 | + array( 'class' => 'lqt-talkpage-header' ), |
| 268 | + $talkpageHeader |
| 269 | + ); |
| 270 | + |
234 | 271 | $this->output->addHTML( $talkpageHeader ); |
235 | 272 | |
236 | 273 | global $wgRequest; |
— | — | @@ -242,63 +279,71 @@ |
243 | 280 | $this->output->addHTML( Xml::tags( 'div', |
244 | 281 | array( 'class' => 'lqt-new-thread lqt-edit-form' ), '' ) ); |
245 | 282 | } |
246 | | - |
| 283 | + |
247 | 284 | $pager = $this->getPager(); |
248 | | - |
| 285 | + |
249 | 286 | $threads = $this->getPageThreads( $pager ); |
250 | 287 | |
251 | | - if ( count($threads) > 0 ) { |
| 288 | + if ( count( $threads ) > 0 ) { |
252 | 289 | $html .= Xml::element( 'br', array( 'style' => 'clear: both;' ) ); |
253 | 290 | $html .= $this->getTOC( $threads ); |
254 | 291 | } else { |
255 | 292 | $html .= wfMsgExt( 'lqt-no-threads', 'parseinline' ); |
256 | 293 | } |
257 | | - |
| 294 | + |
258 | 295 | $html .= $pager->getNavigationBar(); |
259 | | - |
| 296 | + |
260 | 297 | $this->output->addHTML( $html ); |
261 | 298 | |
262 | 299 | foreach ( $threads as $t ) { |
263 | 300 | $this->showThread( $t ); |
264 | 301 | } |
265 | | - |
| 302 | + |
266 | 303 | $this->output->addHTML( $pager->getNavigationBar() ); |
267 | | - |
| 304 | + |
268 | 305 | return false; |
269 | 306 | } |
270 | | - |
| 307 | + |
271 | 308 | function getSearchBox() { |
272 | 309 | $html = ''; |
273 | | - $html .= Xml::inputLabel( wfMsg('lqt-search-label'), 'lqt_search', 'lqt-search-box', |
274 | | - 45 ); |
275 | | - |
| 310 | + $html .= Xml::inputLabel( |
| 311 | + wfMsg( 'lqt-search-label' ), |
| 312 | + 'lqt_search', |
| 313 | + 'lqt-search-box', |
| 314 | + 45 |
| 315 | + ); |
| 316 | + |
276 | 317 | $html .= ' ' . Xml::submitButton( wfMsg( 'lqt-search-button' ) ); |
277 | 318 | $html .= Xml::hidden( 'title', $this->title->getPrefixedText() ); |
278 | | - $html = Xml::tags( 'form', |
279 | | - array( 'action' => $this->title->getLocalURL(), |
280 | | - 'method' => 'get' ), |
281 | | - $html ); |
282 | | - |
| 319 | + $html = Xml::tags( |
| 320 | + 'form', |
| 321 | + array( |
| 322 | + 'action' => $this->title->getLocalURL(), |
| 323 | + 'method' => 'get' |
| 324 | + ), |
| 325 | + $html |
| 326 | + ); |
| 327 | + |
283 | 328 | # $html = Xml::fieldset( wfMsg('lqt-search-legend' ), $html, |
284 | 329 | # array( 'class' => 'lqt-talkpage-search' ) ); |
285 | 330 | |
286 | 331 | $html = Xml::tags( 'div', array( 'class' => 'lqt-talkpage-search' ), $html ); |
287 | | - |
| 332 | + |
288 | 333 | return $html; |
289 | 334 | } |
290 | | - |
| 335 | + |
291 | 336 | function getPager() { |
292 | | - |
| 337 | + |
293 | 338 | $sortType = $this->getSortType(); |
294 | 339 | return new LqtDiscussionPager( $this->article, $sortType ); |
295 | 340 | } |
296 | | - |
| 341 | + |
297 | 342 | function getPageThreads( $pager ) { |
298 | 343 | $rows = $pager->getRows(); |
299 | | - |
| 344 | + |
300 | 345 | return Thread::bulkLoad( $rows ); |
301 | 346 | } |
302 | | - |
| 347 | + |
303 | 348 | function getSortType() { |
304 | 349 | // Determine sort order |
305 | 350 | if ( $this->request->getCheck( 'lqt_order' ) ) { |
— | — | @@ -313,7 +358,7 @@ |
314 | 359 | return LQT_OLDEST_THREADS; |
315 | 360 | } |
316 | 361 | } |
317 | | - |
| 362 | + |
318 | 363 | // Default |
319 | 364 | return LQT_NEWEST_CHANGES; |
320 | 365 | } |
— | — | @@ -324,39 +369,37 @@ |
325 | 370 | function __construct( $article, $orderType ) { |
326 | 371 | $this->article = $article; |
327 | 372 | $this->orderType = $orderType; |
328 | | - |
| 373 | + |
329 | 374 | parent::__construct(); |
330 | | - |
| 375 | + |
331 | 376 | $this->mLimit = 20; |
332 | 377 | } |
333 | | - |
| 378 | + |
334 | 379 | function getQueryInfo() { |
335 | | - $queryInfo = |
336 | | - array( |
337 | | - 'tables' => array( 'thread' ), |
338 | | - 'fields' => '*', |
339 | | - 'conds' => |
340 | | - array( |
341 | | - Threads::articleClause( $this->article ), |
342 | | - Threads::topLevelClause(), |
343 | | - 'thread_type != '. $this->mDb->addQuotes( Threads::TYPE_DELETED ), |
344 | | - ), |
345 | | - ); |
346 | | - |
| 380 | + $queryInfo = array( |
| 381 | + 'tables' => array( 'thread' ), |
| 382 | + 'fields' => '*', |
| 383 | + 'conds' => array( |
| 384 | + Threads::articleClause( $this->article ), |
| 385 | + Threads::topLevelClause(), |
| 386 | + 'thread_type != ' . $this->mDb->addQuotes( Threads::TYPE_DELETED ), |
| 387 | + ), |
| 388 | + ); |
| 389 | + |
347 | 390 | return $queryInfo; |
348 | 391 | } |
349 | | - |
| 392 | + |
350 | 393 | // Adapted from getBody(). |
351 | 394 | function getRows() { |
352 | 395 | if ( !$this->mQueryDone ) { |
353 | 396 | $this->doQuery(); |
354 | 397 | } |
355 | | - |
| 398 | + |
356 | 399 | # Don't use any extra rows returned by the query |
357 | 400 | $numRows = min( $this->mResult->numRows(), $this->mLimit ); |
358 | 401 | |
359 | 402 | $rows = array(); |
360 | | - |
| 403 | + |
361 | 404 | if ( $numRows ) { |
362 | 405 | if ( $this->mIsBackwards ) { |
363 | 406 | for ( $i = $numRows - 1; $i >= 0; $i-- ) { |
— | — | @@ -372,14 +415,14 @@ |
373 | 416 | } |
374 | 417 | } |
375 | 418 | } |
376 | | - |
| 419 | + |
377 | 420 | return $rows; |
378 | 421 | } |
379 | | - |
| 422 | + |
380 | 423 | function formatRow( $row ) { |
381 | 424 | // No-op, we get the list of rows from getRows() |
382 | 425 | } |
383 | | - |
| 426 | + |
384 | 427 | function getIndexField() { |
385 | 428 | switch( $this->orderType ) { |
386 | 429 | case LQT_NEWEST_CHANGES: |
— | — | @@ -388,10 +431,10 @@ |
389 | 432 | case LQT_NEWEST_THREADS: |
390 | 433 | return 'thread_created'; |
391 | 434 | default: |
392 | | - throw new MWException( "Unknown sort order ".$this->orderType ); |
| 435 | + throw new MWException( "Unknown sort order " . $this->orderType ); |
393 | 436 | } |
394 | 437 | } |
395 | | - |
| 438 | + |
396 | 439 | function getDefaultDirections() { |
397 | 440 | switch( $this->orderType ) { |
398 | 441 | case LQT_NEWEST_CHANGES: |
— | — | @@ -400,10 +443,10 @@ |
401 | 444 | case LQT_OLDEST_THREADS: |
402 | 445 | return false; // Ascending |
403 | 446 | default: |
404 | | - throw new MWException( "Unknown sort order ".$this->orderType ); |
| 447 | + throw new MWException( "Unknown sort order " . $this->orderType ); |
405 | 448 | } |
406 | 449 | } |
407 | | - |
| 450 | + |
408 | 451 | /** |
409 | 452 | * A navigation bar with images |
410 | 453 | * Stolen from TablePager because it's pretty. |
— | — | @@ -453,7 +496,7 @@ |
454 | 497 | $s .= "</tr></table>\n"; |
455 | 498 | return $s; |
456 | 499 | } |
457 | | - |
| 500 | + |
458 | 501 | function getNavClass() { |
459 | 502 | return 'TalkpagePager_nav'; |
460 | 503 | } |
Index: trunk/extensions/LiquidThreads/migrateDatabase.php |
— | — | @@ -3,71 +3,73 @@ |
4 | 4 | // Utility script to update your LiquidThreads installation by batch-running lazy updates |
5 | 5 | // normally done on-demand when a thread is loaded. Also runs any necessary database updates. |
6 | 6 | |
7 | | -require_once ( getenv('MW_INSTALL_PATH') !== false |
8 | | - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
| 7 | +require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
| 8 | + ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
9 | 9 | : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
10 | | - |
| 10 | + |
11 | 11 | $db = wfGetDB( DB_MASTER ); |
12 | 12 | |
13 | 13 | // Do database updates |
14 | | -$threadFieldUpdates = array('thread_article_namespace' => 'split-thread_article.sql', |
15 | | - 'thread_article_title' => 'split-thread_article.sql', |
16 | | - 'thread_ancestor' => 'normalise-ancestry.sql', |
17 | | - 'thread_parent' => 'normalise-ancestry.sql', |
18 | | - 'thread_modified' => 'split-timestamps.sql', |
19 | | - 'thread_created' => 'split-timestamps.sql', |
20 | | - 'thread_editedness' => 'store-editedness.sql', |
21 | | - 'thread_subject' => 'store_subject-author.sql', |
22 | | - 'thread_author_id' => 'store_subject-author.sql', |
23 | | - 'thread_author_name' => 'store_subject-author.sql', |
24 | | - ); |
25 | | -$threadIndexUpdates = array('thread_summary_page' => 'index-summary_page.sql'); |
| 14 | +$threadFieldUpdates = array( |
| 15 | + 'thread_article_namespace' => 'split-thread_article.sql', |
| 16 | + 'thread_article_title' => 'split-thread_article.sql', |
| 17 | + 'thread_ancestor' => 'normalise-ancestry.sql', |
| 18 | + 'thread_parent' => 'normalise-ancestry.sql', |
| 19 | + 'thread_modified' => 'split-timestamps.sql', |
| 20 | + 'thread_created' => 'split-timestamps.sql', |
| 21 | + 'thread_editedness' => 'store-editedness.sql', |
| 22 | + 'thread_subject' => 'store_subject-author.sql', |
| 23 | + 'thread_author_id' => 'store_subject-author.sql', |
| 24 | + 'thread_author_name' => 'store_subject-author.sql', |
| 25 | +); |
| 26 | +$threadIndexUpdates = array( 'thread_summary_page' => 'index-summary_page.sql' ); |
26 | 27 | |
27 | 28 | $newTableUpdates = array( 'thread_history' => 'thread_history_table.sql' ); |
28 | 29 | |
29 | | -foreach( $threadFieldUpdates as $field => $patch ) { |
30 | | - if (!$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) { |
31 | | - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
| 30 | +foreach ( $threadFieldUpdates as $field => $patch ) { |
| 31 | + if ( !$db->fieldExists( 'thread', $field, 'lqt-update-script' ) ) { |
| 32 | + dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
32 | 33 | } |
33 | 34 | } |
34 | 35 | |
35 | | -foreach( $threadIndexUpdates as $index => $patch ) { |
36 | | - if (!$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) { |
37 | | - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
| 36 | +foreach ( $threadIndexUpdates as $index => $patch ) { |
| 37 | + if ( !$db->indexExists( 'thread', $index, 'lqt-update-script' ) ) { |
| 38 | + dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
38 | 39 | } |
39 | 40 | } |
40 | 41 | |
41 | | -foreach( $newTableUpdates as $table => $patch ) { |
42 | | - if (!$db->tableExists( $table, 'lqt-update-script' ) ) { |
43 | | - dbsource( dirname( __FILE__ ).'/schema-changes/'.$patch ); |
| 42 | +foreach ( $newTableUpdates as $table => $patch ) { |
| 43 | + if ( !$db->tableExists( $table, 'lqt-update-script' ) ) { |
| 44 | + dbsource( dirname( __FILE__ ) . '/schema-changes/' . $patch ); |
44 | 45 | } |
45 | 46 | } |
46 | 47 | |
47 | | - |
48 | 48 | // Batch lazy updates |
49 | 49 | $upTo = $lastUpTo = 0; |
50 | 50 | |
51 | 51 | do { |
52 | 52 | $lastUpTo = $upTo; |
53 | | - |
| 53 | + |
54 | 54 | $db->begin(); |
55 | | - |
| 55 | + |
56 | 56 | // Read 500 rows |
57 | | - $res = $db->select( 'thread', '*', array( 'thread_id>'.$db->addQuotes($upTo ) ), |
58 | | - 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE', |
59 | | - 'ORDER BY' => 'thread_id asc' ) ); |
60 | | - |
| 57 | + $res = $db->select( |
| 58 | + 'thread', '*', array( 'thread_id>' . $db->addQuotes( $upTo ) ), |
| 59 | + 'lqt-update-script', array( 'LIMIT' => 500, 'FOR UPDATE', |
| 60 | + 'ORDER BY' => 'thread_id asc' ) |
| 61 | + ); |
| 62 | + |
61 | 63 | $threads = Threads::loadFromResult( $res, $db ); |
62 | | - |
63 | | - foreach( $threads as $thread ) { |
| 64 | + |
| 65 | + foreach ( $threads as $thread ) { |
64 | 66 | $thread->doLazyUpdates(); |
65 | 67 | $thread->updateHistory(); |
66 | | - |
| 68 | + |
67 | 69 | if ( $thread->id() > $upTo ) { |
68 | 70 | $upTo = $thread->id(); |
69 | 71 | } |
70 | 72 | } |
71 | | - |
| 73 | + |
72 | 74 | $db->commit(); |
73 | | - |
| 75 | + |
74 | 76 | } while ( $lastUpTo != $upTo ); |
Index: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php |
— | — | @@ -17,9 +17,9 @@ |
18 | 18 | * http://www.gnu.org/copyleft/gpl.html |
19 | 19 | */ |
20 | 20 | |
21 | | -if (!defined('MEDIAWIKI')) { |
| 21 | +if ( !defined( 'MEDIAWIKI' ) ) { |
22 | 22 | // Eclipse helper - will be ignored in production |
23 | | - require_once ("ApiBase.php"); |
| 23 | + require_once ( "ApiBase.php" ); |
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
— | — | @@ -29,15 +29,15 @@ |
30 | 30 | */ |
31 | 31 | class ApiFeedLQTThreads extends ApiBase { |
32 | 32 | |
33 | | - public function __construct($main, $action) { |
34 | | - parent :: __construct($main, $action); |
| 33 | + public function __construct( $main, $action ) { |
| 34 | + parent :: __construct( $main, $action ); |
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
38 | 38 | * This module uses a custom feed wrapper printer. |
39 | 39 | */ |
40 | 40 | public function getCustomPrinter() { |
41 | | - return new ApiFormatFeedWrapper($this->getMain()); |
| 41 | + return new ApiFormatFeedWrapper( $this->getMain() ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
— | — | @@ -46,98 +46,102 @@ |
47 | 47 | */ |
48 | 48 | public function execute() { |
49 | 49 | global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgContLanguageCode; |
50 | | - |
| 50 | + |
51 | 51 | $params = $this->extractRequestParams(); |
52 | | - |
| 52 | + |
53 | 53 | $db = wfGetDB( DB_SLAVE ); |
54 | | - |
| 54 | + |
55 | 55 | $feedTitle = self::createFeedTitle( $params ); |
56 | 56 | $feedClass = $wgFeedClasses[$params['feedformat']]; |
57 | 57 | // TODO need a better URL :) |
58 | 58 | $feedUrl = 'http://www.mediawiki.org/wiki/Extension:LiquidThreads'; |
59 | 59 | $feedItems = array(); |
60 | | - |
| 60 | + |
61 | 61 | $tables = array( 'thread' ); |
62 | 62 | $fields = array( 'thread.*' ); |
63 | 63 | $conds = $this->getConditions( $params, $db ); |
64 | 64 | $options = array( 'LIMIT' => 200, 'ORDER BY' => 'thread_created DESC' ); |
65 | | - |
| 65 | + |
66 | 66 | $res = $db->select( $tables, $fields, $conds, __METHOD__, $options ); |
67 | | - |
68 | | - foreach( $res as $row ) { |
| 67 | + |
| 68 | + foreach ( $res as $row ) { |
69 | 69 | $feedItems[] = $this->createFeedItem( $row ); |
70 | 70 | } |
71 | | - |
72 | | - $feed = new $feedClass($feedTitle, '', $feedUrl); |
73 | 71 | |
74 | | - ApiFormatFeedWrapper :: setResult($this->getResult(), $feed, $feedItems); |
| 72 | + $feed = new $feedClass( $feedTitle, '', $feedUrl ); |
| 73 | + |
| 74 | + ApiFormatFeedWrapper :: setResult( $this->getResult(), $feed, $feedItems ); |
75 | 75 | } |
76 | | - |
77 | | - private function createFeedItem($row) { |
| 76 | + |
| 77 | + private function createFeedItem( $row ) { |
78 | 78 | global $wgOut; |
79 | 79 | $thread = new Thread( $row ); |
80 | 80 | $linker = new Linker; |
81 | | - |
| 81 | + |
82 | 82 | $titleStr = $thread->subject(); |
83 | 83 | $completeText = $thread->root()->getContent(); |
84 | 84 | $completeText = $wgOut->parse( $completeText ); |
85 | 85 | $threadTitle = clone $thread->topmostThread()->title(); |
86 | | - $threadTitle->setFragment( '#'.$thread->getAnchorName() ); |
| 86 | + $threadTitle->setFragment( '#' . $thread->getAnchorName() ); |
87 | 87 | $titleUrl = $threadTitle->getFullURL(); |
88 | 88 | $timestamp = $thread->created(); |
89 | 89 | $user = $thread->author()->getName(); |
90 | | - |
| 90 | + |
91 | 91 | // Grab the title for the superthread, if one exists. |
92 | 92 | $stTitle = null; |
93 | 93 | if ( $thread->hasSuperThread() ) { |
94 | 94 | $stTitle = clone $thread->topmostThread()->title(); |
95 | | - $stTitle->setFragment( '#'.$thread->superthread()->getAnchorName() ); |
| 95 | + $stTitle->setFragment( '#' . $thread->superthread()->getAnchorName() ); |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | // Prefix content with a quick description |
99 | 99 | $userLink = $linker->userLink( $thread->author()->getId(), $user ); |
100 | 100 | $talkpageLink = $linker->link( $thread->article()->getTitle() ); |
101 | 101 | $superthreadLink = $linker->link( $stTitle ); |
102 | | - |
| 102 | + |
103 | 103 | $description = ''; |
104 | 104 | if ( $thread->hasSuperThread() ) { |
105 | | - $description = wfMsgExt( 'lqt-feed-reply-intro', |
106 | | - array( 'parse', 'replaceafter' ), |
107 | | - array( $talkpageLink, $userLink, $superthreadLink ) ); |
| 105 | + $description = wfMsgExt( |
| 106 | + 'lqt-feed-reply-intro', |
| 107 | + array( 'parse', 'replaceafter' ), |
| 108 | + array( $talkpageLink, $userLink, $superthreadLink ) |
| 109 | + ); |
108 | 110 | } else { |
109 | | - $description = wfMsgExt( 'lqt-feed-new-thread-intro', |
110 | | - array( 'parse', 'replaceafter' ), |
111 | | - array( $talkpageLink, $userLink ) ); |
| 111 | + $description = wfMsgExt( |
| 112 | + 'lqt-feed-new-thread-intro', |
| 113 | + array( 'parse', 'replaceafter' ), |
| 114 | + array( $talkpageLink, $userLink ) |
| 115 | + ); |
112 | 116 | } |
113 | | - |
| 117 | + |
114 | 118 | $completeText = $description . $completeText; |
115 | 119 | |
116 | | - return new FeedItem($titleStr, $completeText, $titleUrl, $timestamp, $user); |
| 120 | + return new FeedItem( $titleStr, $completeText, $titleUrl, $timestamp, $user ); |
117 | 121 | } |
118 | | - |
| 122 | + |
119 | 123 | public static function createFeedTitle( $params ) { |
120 | 124 | wfLoadExtensionMessages( 'LiquidThreads' ); |
121 | 125 | $fromPlaces = array(); |
122 | | - |
123 | | - foreach( (array)$params['thread'] as $thread ) { |
| 126 | + |
| 127 | + foreach ( (array)$params['thread'] as $thread ) { |
124 | 128 | $t = Title::newFromText( $thread ); |
125 | 129 | $fromPlaces[] = $t->getPrefixedText(); |
126 | 130 | } |
127 | | - |
128 | | - foreach( (array)$params['talkpage'] as $talkpage ) { |
| 131 | + |
| 132 | + foreach ( (array)$params['talkpage'] as $talkpage ) { |
129 | 133 | $t = Title::newFromText( $talkpage ); |
130 | 134 | $fromPlaces[] = $t->getPrefixedText(); |
131 | 135 | } |
132 | | - |
| 136 | + |
133 | 137 | global $wgLang; |
134 | | - $fromCount = count($fromPlaces); |
| 138 | + $fromCount = count( $fromPlaces ); |
135 | 139 | $fromPlaces = $wgLang->commaList( $fromPlaces ); |
136 | | - |
| 140 | + |
137 | 141 | // What's included? |
138 | 142 | $types = (array)$params['type']; |
139 | | - |
| 143 | + |
140 | 144 | $msg = ''; |
141 | | - |
| 145 | + |
142 | 146 | if ( !count( array_diff( array( 'replies', 'newthreads' ), $types ) ) ) { |
143 | 147 | $msg = 'lqt-feed-title-all'; |
144 | 148 | } elseif ( in_array( 'replies', $types ) ) { |
— | — | @@ -145,67 +149,71 @@ |
146 | 150 | } elseif ( in_array( 'newthreads', $types ) ) { |
147 | 151 | $msg = 'lqt-feed-title-new-threads'; |
148 | 152 | } else { |
149 | | - throw new MWException( "Unable to determine appropriate display type"); |
| 153 | + throw new MWException( "Unable to determine appropriate display type" ); |
150 | 154 | } |
151 | | - |
| 155 | + |
152 | 156 | if ( $fromCount ) { |
153 | 157 | $msg .= '-from'; |
154 | 158 | } |
155 | | - |
| 159 | + |
156 | 160 | return wfMsg( $msg, $fromPlaces, $fromCount ); |
157 | 161 | } |
158 | | - |
| 162 | + |
159 | 163 | function getConditions( $params, $db ) { |
160 | 164 | $conds = array(); |
161 | | - |
| 165 | + |
162 | 166 | // Types |
163 | 167 | $conds['thread_type'] = Threads::TYPE_NORMAL; |
164 | | - |
| 168 | + |
165 | 169 | // Limit |
166 | | - $cutoff = time() - intval($params['days'] * 24 * 3600); |
| 170 | + $cutoff = time() - intval( $params['days'] * 24 * 3600 ); |
167 | 171 | $cutoff = $db->timestamp( $cutoff ); |
168 | 172 | $conds[] = 'thread_created > ' . $db->addQuotes( $cutoff ); |
169 | | - |
| 173 | + |
170 | 174 | // Talkpage conditions |
171 | 175 | $pageConds = array(); |
172 | | - |
| 176 | + |
173 | 177 | $talkpages = (array)$params['talkpage']; |
174 | | - foreach( $talkpages as $page ) { |
| 178 | + foreach ( $talkpages as $page ) { |
175 | 179 | $title = Title::newFromText( $page ); |
176 | | - $pageCond = array( 'thread_article_namespace' => $title->getNamespace(), |
177 | | - 'thread_article_title' => $title->getDBkey() ); |
| 180 | + $pageCond = array( |
| 181 | + 'thread_article_namespace' => $title->getNamespace(), |
| 182 | + 'thread_article_title' => $title->getDBkey() |
| 183 | + ); |
178 | 184 | $pageConds[] = $db->makeList( $pageCond, LIST_AND ); |
179 | 185 | } |
180 | | - |
| 186 | + |
181 | 187 | // Thread conditions |
182 | 188 | $threadConds = array(); |
183 | 189 | $threads = (array)$params['thread']; |
184 | | - foreach( $threads as $thread ) { |
| 190 | + foreach ( $threads as $thread ) { |
185 | 191 | $root = new Article( Title::newFromText( $thread ) ); |
186 | 192 | $thread = Threads::withRoot( $root ); |
187 | | - |
188 | | - $threadCond = array( 'thread_ancestor' => $thread->id(), |
189 | | - 'thread_id' => $thread->id() ); |
| 193 | + |
| 194 | + $threadCond = array( |
| 195 | + 'thread_ancestor' => $thread->id(), |
| 196 | + 'thread_id' => $thread->id() |
| 197 | + ); |
190 | 198 | $pageConds[] = $db->makeList( $threadCond, LIST_OR ); |
191 | 199 | } |
192 | | - if ( count($pageConds) ) { |
| 200 | + if ( count( $pageConds ) ) { |
193 | 201 | $conds[] = $db->makeList( $pageConds, LIST_OR ); |
194 | 202 | } |
195 | | - |
| 203 | + |
196 | 204 | // New thread v. Reply |
197 | 205 | $types = (array)$params['type']; |
198 | 206 | if ( !in_array( 'replies', $types ) ) { |
199 | 207 | $conds[] = Threads::topLevelClause(); |
200 | 208 | } elseif ( !in_array( 'newthreads', $types ) ) { |
201 | | - $conds[] = '!'.Threads::topLevelClause(); |
| 209 | + $conds[] = '!' . Threads::topLevelClause(); |
202 | 210 | } |
203 | | - |
| 211 | + |
204 | 212 | return $conds; |
205 | 213 | } |
206 | 214 | |
207 | 215 | public function getAllowedParams() { |
208 | 216 | global $wgFeedClasses; |
209 | | - $feedFormatNames = array_keys($wgFeedClasses); |
| 217 | + $feedFormatNames = array_keys( $wgFeedClasses ); |
210 | 218 | return array ( |
211 | 219 | 'feedformat' => array ( |
212 | 220 | ApiBase :: PARAM_DFLT => 'rss', |
Property changes on: trunk/extensions/LiquidThreads/api/ApiFeedLQTThreads.php |
___________________________________________________________________ |
Added: svn:eol-style |
213 | 221 | + native |
Index: trunk/extensions/LiquidThreads/api/ApiQueryLQTThreads.php |
— | — | @@ -15,20 +15,25 @@ |
16 | 16 | * - "root" page ID |
17 | 17 | * - type |
18 | 18 | */ |
| 19 | + |
19 | 20 | class ApiQueryLQTThreads extends ApiQueryBase { |
20 | 21 | |
21 | 22 | // Property definitions |
22 | 23 | static $propRelations = array( |
23 | 24 | 'id' => 'thread_id', |
24 | 25 | 'subject' => 'thread_subject', |
25 | | - 'page' => array( 'namespace' => 'thread_article_namespace', |
26 | | - 'title' => 'thread_article_title' ), |
| 26 | + 'page' => array( |
| 27 | + 'namespace' => 'thread_article_namespace', |
| 28 | + 'title' => 'thread_article_title' |
| 29 | + ), |
27 | 30 | 'parent' => 'thread_parent', |
28 | 31 | 'ancestor' => 'thread_ancestor', |
29 | 32 | 'created' => 'thread_created', |
30 | 33 | 'modified' => 'thread_modified', |
31 | | - 'author' => array( 'id' => 'thread_author_id', |
32 | | - 'name' => 'thread_author_name'), |
| 34 | + 'author' => array( |
| 35 | + 'id' => 'thread_author_id', |
| 36 | + 'name' => 'thread_author_name' |
| 37 | + ), |
33 | 38 | 'summaryid' => 'thread_summary_page', |
34 | 39 | 'rootid' => 'thread_root', |
35 | 40 | 'type' => 'thread_type', |
— | — | @@ -40,20 +45,20 @@ |
41 | 46 | |
42 | 47 | public function execute() { |
43 | 48 | global $wgUser; |
44 | | - |
| 49 | + |
45 | 50 | $params = $this->extractRequestParams(); |
46 | 51 | $prop = array_flip( $params['prop'] ); |
47 | 52 | $result = $this->getResult(); |
48 | 53 | $this->addTables( 'thread' ); |
49 | 54 | $this->addFields( 'thread_id' ); |
50 | | - |
| 55 | + |
51 | 56 | foreach ( self::$propRelations as $name => $fields ) { |
52 | 57 | // Pass a straight array rather than one with string |
53 | 58 | // keys, to be sure that merging it into other added |
54 | 59 | // arrays doesn't mess stuff up |
55 | 60 | $this->addFieldsIf( array_values( (array)$fields ), isset( $prop[$name] ) ); |
56 | 61 | } |
57 | | - |
| 62 | + |
58 | 63 | // Check for conditions |
59 | 64 | $conditionFields = array( 'page', 'root', 'summary', 'author', 'id' ); |
60 | 65 | foreach ( $conditionFields as $field ) { |
— | — | @@ -65,23 +70,25 @@ |
66 | 71 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
67 | 72 | $this->addWhereRange( 'thread_id', $params['dir'], |
68 | 73 | $params['startid'], $params['endid'] ); |
69 | | - |
| 74 | + |
70 | 75 | if ( !$params['showdeleted'] ) { |
71 | | - $delType = $this->getDB()->addQuotes( Threads::TYPE_DELETED ); |
| 76 | + $delType = $this->getDB()->addQuotes( Threads::TYPE_DELETED ); |
72 | 77 | $this->addWhere( "thread_type != $delType" ); |
73 | 78 | } |
74 | | - |
| 79 | + |
75 | 80 | if ( $params['render'] ) { |
76 | 81 | // All fields |
77 | | - $allFields = array( 'thread_id', 'thread_root', 'thread_article_namespace', |
| 82 | + $allFields = array( |
| 83 | + 'thread_id', 'thread_root', 'thread_article_namespace', |
78 | 84 | 'thread_article_title', 'thread_summary_page', 'thread_ancestor', |
79 | 85 | 'thread_parent', 'thread_modified', 'thread_created', 'thread_type', |
80 | | - 'thread_editedness', 'thread_subject', 'thread_author_id', |
81 | | - 'thread_author_name' ); |
82 | | - |
| 86 | + 'thread_editedness', 'thread_subject', 'thread_author_id', |
| 87 | + 'thread_author_name' |
| 88 | + ); |
| 89 | + |
83 | 90 | $this->addFields( $allFields ); |
84 | 91 | } |
85 | | - |
| 92 | + |
86 | 93 | $res = $this->select( __METHOD__ ); |
87 | 94 | $count = 0; |
88 | 95 | foreach ( $res as $row ) |
— | — | @@ -91,22 +98,22 @@ |
92 | 99 | $this->setContinueEnumParameter( 'startid', $row->thread_id ); |
93 | 100 | break; |
94 | 101 | } |
95 | | - |
| 102 | + |
96 | 103 | $entry = array(); |
97 | 104 | foreach ( $prop as $name => $nothing ) { |
98 | 105 | $fields = self::$propRelations[$name]; |
99 | 106 | self::formatProperty( $name, $fields, $row, $entry ); |
100 | 107 | } |
101 | | - |
| 108 | + |
102 | 109 | // Render if requested |
103 | 110 | if ( $params['render'] ) { |
104 | 111 | self::renderThread( $row, $params, $entry ); |
105 | 112 | } |
106 | | - |
| 113 | + |
107 | 114 | if ( $entry ) { |
108 | 115 | $fit = $result->addValue( array( 'query', |
109 | 116 | $this->getModuleName() ), |
110 | | - null, $entry); |
| 117 | + null, $entry ); |
111 | 118 | if ( !$fit ) { |
112 | 119 | $this->setContinueEnumParameter( 'startid', $row->thread_id ); |
113 | 120 | break; |
— | — | @@ -115,42 +122,42 @@ |
116 | 123 | } |
117 | 124 | $result->setIndexedTagName_internal( array( 'query', $this->getModuleName() ), 'thread' ); |
118 | 125 | } |
119 | | - |
| 126 | + |
120 | 127 | static function renderThread( $row, $params, &$entry ) { |
121 | 128 | // Set up OutputPage |
122 | 129 | global $wgOut, $wgUser, $wgRequest; |
123 | 130 | $oldOutputText = $wgOut->getHTML(); |
124 | 131 | $wgOut->clearHTML(); |
125 | | - |
| 132 | + |
126 | 133 | // Setup |
127 | 134 | $thread = new Thread( $row ); |
128 | 135 | $article = $thread->root(); |
129 | 136 | $title = $article->getTitle(); |
130 | 137 | $view = new LqtView( $wgOut, $article, $title, $wgUser, $wgRequest ); |
131 | | - |
| 138 | + |
132 | 139 | // Parameters |
133 | 140 | $view->threadNestingLevel = $params['renderlevel']; |
134 | | - |
| 141 | + |
135 | 142 | $renderpos = $params['renderthreadpos']; |
136 | 143 | $rendercount = $params['renderthreadcount']; |
137 | | - |
| 144 | + |
138 | 145 | $options = array(); |
139 | | - if ( isset($params['rendermaxthreadcount']) ) |
| 146 | + if ( isset( $params['rendermaxthreadcount'] ) ) |
140 | 147 | $options['maxCount'] = $params['rendermaxthreadcount']; |
141 | | - if ( isset($params['rendermaxdepth']) ) |
| 148 | + if ( isset( $params['rendermaxdepth'] ) ) |
142 | 149 | $options['maxDepth'] = $params['rendermaxdepth']; |
143 | | - if ( isset($params['renderstartrepliesat']) ) |
| 150 | + if ( isset( $params['renderstartrepliesat'] ) ) |
144 | 151 | $options['startAt' ] = $params['renderstartrepliesat']; |
145 | | - |
| 152 | + |
146 | 153 | $view->showThread( $thread, $renderpos, $rendercount, $options ); |
147 | | - |
| 154 | + |
148 | 155 | $result = $wgOut->getHTML(); |
149 | 156 | $wgOut->clearHTML(); |
150 | 157 | $wgOut->addHTML( $oldOutputText ); |
151 | | - |
| 158 | + |
152 | 159 | $entry['content'] = $result; |
153 | 160 | } |
154 | | - |
| 161 | + |
155 | 162 | static function formatProperty( $name, $fields, $row, &$entry ) { |
156 | 163 | if ( !is_array( $fields ) ) { |
157 | 164 | // Common case. |
— | — | @@ -170,7 +177,7 @@ |
171 | 178 | } |
172 | 179 | } |
173 | 180 | } |
174 | | - |
| 181 | + |
175 | 182 | function addPageCond( $prop, $value ) { |
176 | 183 | if ( count( $value ) === 1 ) { |
177 | 184 | $cond = $this->getPageCond( $prop, $value[0] ); |
— | — | @@ -181,12 +188,12 @@ |
182 | 189 | $cond = $this->getPageCond( $prop, $page ); |
183 | 190 | $conds[] = $this->getDB()->makeList( $cond, LIST_AND ); |
184 | 191 | } |
185 | | - |
| 192 | + |
186 | 193 | $cond = $this->getDB()->makeList( $conds, LIST_OR ); |
187 | 194 | $this->addWhere( $cond ); |
188 | 195 | } |
189 | 196 | } |
190 | | - |
| 197 | + |
191 | 198 | function getPageCond( $prop, $value ) { |
192 | 199 | $fieldMappings = array( |
193 | 200 | 'page' => array( |
— | — | @@ -196,7 +203,7 @@ |
197 | 204 | 'root' => array( 'id' => 'thread_root' ), |
198 | 205 | 'summary' => array( 'id' => 'thread_summary_id' ), |
199 | 206 | ); |
200 | | - |
| 207 | + |
201 | 208 | // Split. |
202 | 209 | $t = Title::newFromText( $value ); |
203 | 210 | $cond = array(); |
— | — | @@ -217,11 +224,11 @@ |
218 | 225 | } |
219 | 226 | return $cond; |
220 | 227 | } |
221 | | - |
| 228 | + |
222 | 229 | function handleCondition( $prop, $value ) { |
223 | 230 | $titleParams = array( 'page', 'root', 'summary' ); |
224 | 231 | $fields = self::$propRelations[$prop]; |
225 | | - |
| 232 | + |
226 | 233 | if ( in_array( $prop, $titleParams ) ) { |
227 | 234 | // Special cases |
228 | 235 | $this->addPageCond( $prop, $value ); |
— | — | @@ -261,7 +268,7 @@ |
262 | 269 | ApiBase :: PARAM_TYPE => array_keys( self::$propRelations ), |
263 | 270 | ApiBase :: PARAM_ISMULTI => true |
264 | 271 | ), |
265 | | - |
| 272 | + |
266 | 273 | 'page' => array( |
267 | 274 | ApiBase :: PARAM_ISMULTI => true |
268 | 275 | ), |
— | — | @@ -297,8 +304,8 @@ |
298 | 305 | ApiBase :: PARAM_DFLT => null, |
299 | 306 | ), |
300 | 307 | ); |
301 | | - } |
302 | | - |
| 308 | + } |
| 309 | + |
303 | 310 | public function getParamDescription() { |
304 | 311 | return array ( |
305 | 312 | 'startid' => 'The thread id to start enumerating from', |
Index: trunk/extensions/LiquidThreads/import/import-parsed-discussions.php |
— | — | @@ -1,12 +1,12 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -require_once ( getenv('MW_INSTALL_PATH') !== false |
5 | | - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
| 4 | +require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
| 5 | + ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
6 | 6 | : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
7 | 7 | |
8 | | -## Imports JSON-encoded discussions from parse-wikitext-discussions.pl |
| 8 | +# # Imports JSON-encoded discussions from parse-wikitext-discussions.pl |
9 | 9 | |
10 | | -$structure = json_decode(file_get_contents( $argv[1] ), true); |
| 10 | +$structure = json_decode( file_get_contents( $argv[1] ), true ); |
11 | 11 | |
12 | 12 | $article = new Article( Title::newFromText( $argv[2] ) ); |
13 | 13 | |
— | — | @@ -17,35 +17,35 @@ |
18 | 18 | |
19 | 19 | function recursiveParseArray( $array ) { |
20 | 20 | static $recurseLevel = 0; |
21 | | - |
| 21 | + |
22 | 22 | $recurseLevel++; |
23 | | - |
24 | | - if ($recurseLevel > 90) { |
| 23 | + |
| 24 | + if ( $recurseLevel > 90 ) { |
25 | 25 | print var_dump( $array ); |
26 | 26 | die( wfBacktrace() ); |
27 | 27 | } |
28 | | - |
| 28 | + |
29 | 29 | global $subject, $rootPost; |
30 | | - if ( is_array( $array ) && isset($array['title']) ) { |
| 30 | + if ( is_array( $array ) && isset( $array['title'] ) ) { |
31 | 31 | $subject = $array['title']; |
32 | 32 | recursiveParseArray( $array['content'] ); |
33 | | - |
| 33 | + |
34 | 34 | $rootPost = null; |
35 | | - } elseif ( is_array( $array ) && isset($array['user']) ) { |
| 35 | + } elseif ( is_array( $array ) && isset( $array['user'] ) ) { |
36 | 36 | // We have a post. |
37 | 37 | $t = createPost( $array, $subject, $rootPost ); |
38 | | - |
39 | | - if (!$rootPost) { |
| 38 | + |
| 39 | + if ( !$rootPost ) { |
40 | 40 | $rootPost = $t; |
41 | 41 | } |
42 | | - } elseif (is_array($array)) { |
43 | | - foreach( $array as $info ) { |
| 42 | + } elseif ( is_array( $array ) ) { |
| 43 | + foreach ( $array as $info ) { |
44 | 44 | recursiveParseArray( $info ); |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | $rootPost = null; |
48 | 48 | } |
49 | | - |
| 49 | + |
50 | 50 | $recurseLevel--; |
51 | 51 | } |
52 | 52 | |
— | — | @@ -53,33 +53,33 @@ |
54 | 54 | $userName = $info['user']; |
55 | 55 | if ( strpos( $userName, '#' ) !== false ) { |
56 | 56 | $pos = strpos( $userName, '#' ); |
57 | | - |
| 57 | + |
58 | 58 | $userName = substr( $userName, 0, $pos ); |
59 | 59 | } |
60 | | - |
| 60 | + |
61 | 61 | $user = User::newFromName( $userName, /* no validation */ false ); |
62 | | - |
63 | | - if (!$user) { |
64 | | - throw new MWException( "Username ".$info['user']." is invalid." ); |
| 62 | + |
| 63 | + if ( !$user ) { |
| 64 | + throw new MWException( "Username " . $info['user'] . " is invalid." ); |
65 | 65 | } |
66 | | - |
| 66 | + |
67 | 67 | global $article; |
68 | | - |
69 | | - if ($super) { |
| 68 | + |
| 69 | + if ( $super ) { |
70 | 70 | $title = Threads::newReplyTitle( $super, $user ); |
71 | 71 | } else { |
72 | 72 | $title = Threads::newThreadTitle( $subject, $article ); |
73 | 73 | } |
74 | | - |
75 | | - print "Creating thread $title as a subthread of ".($super ? $super->title() : 'none')."\n"; |
76 | | - |
| 74 | + |
| 75 | + print "Creating thread $title as a subthread of " . ( $super ? $super->title() : 'none' ) . "\n"; |
| 76 | + |
77 | 77 | $root = new Article( $title ); |
78 | 78 | $root->doEdit( $info['content'], 'Imported from JSON', EDIT_NEW, false, $user ); |
79 | | - |
80 | | - $t = LqtView::postEditUpdates($super ? 'reply' : 'new', $super, $root, $article, |
| 79 | + |
| 80 | + $t = LqtView::postEditUpdates( $super ? 'reply' : 'new', $super, $root, $article, |
81 | 81 | $subject, 'Imported from JSON', null ); |
82 | | - |
| 82 | + |
83 | 83 | $t = Threads::withId( $t->id() ); // Some weirdness. |
84 | | - |
| 84 | + |
85 | 85 | return $t; |
86 | 86 | } |
Index: trunk/extensions/LiquidThreads/LqtFunctions.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | * Recreate the original associative array so that a new pair with the given key |
21 | 21 | * and value is inserted before the given existing key. $original_array gets |
22 | 22 | * modified in-place. |
23 | | -*/ |
| 23 | + */ |
24 | 24 | function efInsertIntoAssoc( $new_key, $new_value, $before, &$original_array ) { |
25 | 25 | $ordered = array(); |
26 | 26 | $i = 0; |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | function lqtSetupParserFunctions() { |
47 | 47 | global $wgParser; |
48 | | - |
| 48 | + |
49 | 49 | $wgParser->setFunctionHook( 'useliquidthreads', |
50 | 50 | array( 'LqtParserFunctions', 'useLiquidThreads' ) ); |
51 | 51 | return true; |
Index: trunk/extensions/LiquidThreads/i18n/Lqt.i18n.php |
— | — | @@ -183,7 +183,7 @@ |
184 | 184 | 'lqt-thread-split' => 'Split to new thread', |
185 | 185 | 'lqt-split-success' => 'You have successfully split off the thread $1.', |
186 | 186 | 'lqt_split_thread' => 'Split a thread', |
187 | | - 'lqt-thread-split-subject'=> 'New thread subject:', |
| 187 | + 'lqt-thread-split-subject' => 'New thread subject:', |
188 | 188 | 'lqt-thread-split-thread' => 'Thread:', |
189 | 189 | 'lqt-split-submit' => 'Split', |
190 | 190 | 'lqt_split_badsubject' => 'The subject you entered is invalid.', |
— | — | @@ -249,7 +249,7 @@ |
250 | 250 | 'lqt-ajax-update-link' => 'Update', |
251 | 251 | 'lqt-thread-show-replies' => 'Show $1 replies', |
252 | 252 | 'lqt-thread-show-more' => 'Show more replies', |
253 | | - |
| 253 | + |
254 | 254 | // Feeds |
255 | 255 | 'lqt-feed-title-all' => '{{SITENAME}} — New posts', |
256 | 256 | 'lqt-feed-title-all-from' => '{{SITENAME}} — New posts from $1', |
— | — | @@ -999,12 +999,12 @@ |
1000 | 1000 | 'lqt-enotif-subject-reply' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Адказ: $1', |
1001 | 1001 | 'lqt-enotif-subject-newthread' => 'Абмеркаваньне {{GRAMMAR:родны|{{SITENAME}}}} — Новая галіна: $1', |
1002 | 1002 | 'lqt-enotif-newthread' => "Вітаем $1, |
1003 | | -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2', |
| 1003 | +Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новую галіну $5, '$2', |
1004 | 1004 | створаную $3 $4. |
1005 | 1005 | |
1006 | 1006 | Вы можаце паглядзець яе на <$6>", |
1007 | 1007 | 'lqt-enotif-reply' => "Вітаем $1, |
1008 | | -Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2', |
| 1008 | +Гэта паведамленьне з {{GRAMMAR:родны|{{SITENAME}}}} пра новы адказ $5, '$2', |
1009 | 1009 | створаны $3 $4. |
1010 | 1010 | |
1011 | 1011 | Вы можаце паглядзець яго на <$6>", |
— | — | @@ -1338,7 +1338,7 @@ |
1339 | 1339 | 'lqt_invalid_subject' => 'El tema que heu introduït no és vàlid. |
1340 | 1340 | Pot: |
1341 | 1341 | * contenir caràcters no vàlids, com []{}<>, |
1342 | | -* ser massa llarg, o |
| 1342 | +* ser massa llarg, o |
1343 | 1343 | * entrar en conflicte amb prefixos interwiki o altres espai de noms.', |
1344 | 1344 | 'lqt_subject_change_forbidden' => "No podeu canviar el tema d'aquest fil perquè no teniu el permís de moure les pàgines.", |
1345 | 1345 | 'lqt_in_response_to' => 'En resposta a $1 per $2, amunt:', |
Index: trunk/extensions/LiquidThreads/compat/Lqt-compat.i18n.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | 3 | // This file is generated automatically by generateCompatibilityLocalisation.php |
4 | 4 | $messages = array ( |
5 | | - 'ar' => |
| 5 | + 'ar' => |
6 | 6 | array ( |
7 | 7 | 'htmlform-reset' => 'الرجوع عن التغييرات', |
8 | 8 | 'htmlform-submit' => 'تنفيذ', |
— | — | @@ -12,13 +12,13 @@ |
13 | 13 | 'htmlform-selectorother-other' => 'أخرى', |
14 | 14 | 'htmlform-invalid-input' => 'توجد مشكلات ضمن بعض من مدخلاتك', |
15 | 15 | ), |
16 | | - 'arc' => |
| 16 | + 'arc' => |
17 | 17 | array ( |
18 | 18 | 'htmlform-reset' => 'ܠܐ ܥܒܘܕ ܫܘܚܠܦ̈ܐ', |
19 | 19 | 'htmlform-submit' => 'ܫܕܪ', |
20 | 20 | 'htmlform-selectorother-other' => 'ܐܚܪܢܐ', |
21 | 21 | ), |
22 | | - 'arz' => |
| 22 | + 'arz' => |
23 | 23 | array ( |
24 | 24 | 'htmlform-reset' => 'الرجوع فى التغييرات', |
25 | 25 | 'htmlform-submit' => 'تقديم', |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | 'htmlform-selectorother-other' => 'تانيين', |
31 | 31 | 'htmlform-invalid-input' => 'فى مشاكل فى المدخلات بتاعتك', |
32 | 32 | ), |
33 | | - 'bcc' => |
| 33 | + 'bcc' => |
34 | 34 | array ( |
35 | 35 | 'htmlform-reset' => 'ترینگ تغییرات', |
36 | 36 | 'htmlform-submit' => 'دیم دی', |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | 'htmlform-selectorother-other' => 'دگه', |
42 | 42 | 'htmlform-invalid-input' => 'لهتی چه ورودی شما مشکل هست', |
43 | 43 | ), |
44 | | - 'be-tarask' => |
| 44 | + 'be-tarask' => |
45 | 45 | array ( |
46 | 46 | 'htmlform-reset' => 'Адмяніць зьмены', |
47 | 47 | 'htmlform-submit' => 'Захаваць', |
— | — | @@ -51,13 +51,13 @@ |
52 | 52 | 'htmlform-selectorother-other' => 'Іншае', |
53 | 53 | 'htmlform-invalid-input' => 'Узьніклі праблемы з некаторымі з Вашых уваходных зьвестак', |
54 | 54 | ), |
55 | | - 'bg' => |
| 55 | + 'bg' => |
56 | 56 | array ( |
57 | 57 | 'htmlform-reset' => 'Отказване на промените', |
58 | 58 | 'htmlform-submit' => 'Изпращане', |
59 | 59 | 'htmlform-selectorother-other' => 'Друга', |
60 | 60 | ), |
61 | | - 'br' => |
| 61 | + 'br' => |
62 | 62 | array ( |
63 | 63 | 'htmlform-reset' => 'Dizober ar c\'hemmoù', |
64 | 64 | 'htmlform-submit' => 'Kas', |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | 'htmlform-selectorother-other' => 'Unan all', |
70 | 70 | 'htmlform-invalid-input' => 'Kudennoù zo gant talvoudennoù zo merket ganeoc\'h.', |
71 | 71 | ), |
72 | | - 'bs' => |
| 72 | + 'bs' => |
73 | 73 | array ( |
74 | 74 | 'htmlform-reset' => 'Vrati izmjene', |
75 | 75 | 'htmlform-submit' => 'Pošalji', |
— | — | @@ -79,7 +79,7 @@ |
80 | 80 | 'htmlform-selectorother-other' => 'Ostalo', |
81 | 81 | 'htmlform-invalid-input' => 'Postoje određeni problemi s Vašim unosom', |
82 | 82 | ), |
83 | | - 'ca' => |
| 83 | + 'ca' => |
84 | 84 | array ( |
85 | 85 | 'htmlform-reset' => 'Desfés els canvis', |
86 | 86 | 'htmlform-submit' => 'Tramet', |
— | — | @@ -90,11 +90,11 @@ |
91 | 91 | 'htmlform-selectorother-other' => 'Altres', |
92 | 92 | 'htmlform-invalid-input' => 'Hi ha problemes amb alguna de les seves entrades', |
93 | 93 | ), |
94 | | - 'ckb-arab' => |
| 94 | + 'ckb-arab' => |
95 | 95 | array ( |
96 | 96 | 'htmlform-reset' => 'گەڕانەوەی گۆڕانکاری', |
97 | 97 | ), |
98 | | - 'cs' => |
| 98 | + 'cs' => |
99 | 99 | array ( |
100 | 100 | 'htmlform-reset' => 'Vrátit změny', |
101 | 101 | 'htmlform-submit' => 'Odeslat', |
— | — | @@ -105,12 +105,12 @@ |
106 | 106 | 'htmlform-selectorother-other' => 'Jiná hodnota', |
107 | 107 | 'htmlform-invalid-input' => 'Některé vámi zadané údaje jsou chybné', |
108 | 108 | ), |
109 | | - 'cy' => |
| 109 | + 'cy' => |
110 | 110 | array ( |
111 | 111 | 'htmlform-reset' => 'Datod y newidiadau', |
112 | 112 | 'htmlform-selectorother-other' => 'Arall', |
113 | 113 | ), |
114 | | - 'da' => |
| 114 | + 'da' => |
115 | 115 | array ( |
116 | 116 | 'htmlform-reset' => 'Annuller ændringer', |
117 | 117 | 'htmlform-submit' => 'Gem', |
— | — | @@ -121,7 +121,7 @@ |
122 | 122 | 'htmlform-selectorother-other' => 'Anden', |
123 | 123 | 'htmlform-invalid-input' => 'Det er problemer med dine angivelser', |
124 | 124 | ), |
125 | | - 'de' => |
| 125 | + 'de' => |
126 | 126 | array ( |
127 | 127 | 'htmlform-reset' => 'Änderungen rückgängig machen', |
128 | 128 | 'htmlform-submit' => 'Übertragen', |
— | — | @@ -132,7 +132,7 @@ |
133 | 133 | 'htmlform-selectorother-other' => 'Andere', |
134 | 134 | 'htmlform-invalid-input' => 'Mit einigen Eingaben gibt es Probleme', |
135 | 135 | ), |
136 | | - 'dsb' => |
| 136 | + 'dsb' => |
137 | 137 | array ( |
138 | 138 | 'htmlform-reset' => 'Změny anulěrowaś', |
139 | 139 | 'htmlform-submit' => 'Wótpósłaś', |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | 'htmlform-selectorother-other' => 'Druge', |
145 | 145 | 'htmlform-invalid-input' => 'Su někotare problemy z twójim zapodaśim', |
146 | 146 | ), |
147 | | - 'el' => |
| 147 | + 'el' => |
148 | 148 | array ( |
149 | 149 | 'htmlform-reset' => 'Αναστροφή αλλαγών', |
150 | 150 | 'htmlform-submit' => 'Υποβολή', |
— | — | @@ -154,7 +154,7 @@ |
155 | 155 | 'htmlform-selectorother-other' => 'Άλλο', |
156 | 156 | 'htmlform-invalid-input' => 'Υπάρχουν κάποια προβλήματα με μερικές από τις εισροές σας', |
157 | 157 | ), |
158 | | - 'en' => |
| 158 | + 'en' => |
159 | 159 | array ( |
160 | 160 | 'htmlform-reset' => 'Undo changes', |
161 | 161 | 'htmlform-submit' => 'Submit', |
— | — | @@ -165,7 +165,7 @@ |
166 | 166 | 'htmlform-selectorother-other' => 'Other', |
167 | 167 | 'htmlform-invalid-input' => 'There are problems with some of your input', |
168 | 168 | ), |
169 | | - 'eo' => |
| 169 | + 'eo' => |
170 | 170 | array ( |
171 | 171 | 'htmlform-reset' => 'Malfari ŝanĝojn', |
172 | 172 | 'htmlform-submit' => 'Ek!', |
— | — | @@ -176,7 +176,7 @@ |
177 | 177 | 'htmlform-selectorother-other' => 'Alia', |
178 | 178 | 'htmlform-invalid-input' => 'Estas problemoj kun iom da via enigo', |
179 | 179 | ), |
180 | | - 'es' => |
| 180 | + 'es' => |
181 | 181 | array ( |
182 | 182 | 'htmlform-reset' => 'Deshacer cambios', |
183 | 183 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -187,13 +187,13 @@ |
188 | 188 | 'htmlform-selectorother-other' => 'Otro', |
189 | 189 | 'htmlform-invalid-input' => 'Hay problemas con alguno de tus ingresos', |
190 | 190 | ), |
191 | | - 'eu' => |
| 191 | + 'eu' => |
192 | 192 | array ( |
193 | 193 | 'htmlform-reset' => 'Aldaketak desegin', |
194 | 194 | 'htmlform-submit' => 'Bidali', |
195 | 195 | 'htmlform-selectorother-other' => 'Beste bat', |
196 | 196 | ), |
197 | | - 'fa' => |
| 197 | + 'fa' => |
198 | 198 | array ( |
199 | 199 | 'htmlform-reset' => 'خنثی کردن تغییرات', |
200 | 200 | 'htmlform-submit' => 'ارسال', |
— | — | @@ -204,7 +204,7 @@ |
205 | 205 | 'htmlform-selectorother-other' => 'دیگر', |
206 | 206 | 'htmlform-invalid-input' => 'بخشی از ورودی شما مشکل دارد', |
207 | 207 | ), |
208 | | - 'fi' => |
| 208 | + 'fi' => |
209 | 209 | array ( |
210 | 210 | 'htmlform-reset' => 'Kumoa muutokset', |
211 | 211 | 'htmlform-submit' => 'Lähetä', |
— | — | @@ -215,7 +215,7 @@ |
216 | 216 | 'htmlform-selectorother-other' => 'Muu', |
217 | 217 | 'htmlform-invalid-input' => 'Antamassasi syötteessä on ongelmia', |
218 | 218 | ), |
219 | | - 'fr' => |
| 219 | + 'fr' => |
220 | 220 | array ( |
221 | 221 | 'htmlform-reset' => 'Défaire les modifications', |
222 | 222 | 'htmlform-submit' => 'Soumettre', |
— | — | @@ -226,7 +226,7 @@ |
227 | 227 | 'htmlform-selectorother-other' => 'Autre', |
228 | 228 | 'htmlform-invalid-input' => 'Des problèmes sont survenus avec certaines valeurs', |
229 | 229 | ), |
230 | | - 'frp' => |
| 230 | + 'frp' => |
231 | 231 | array ( |
232 | 232 | 'htmlform-reset' => 'Dèfâre los changements', |
233 | 233 | 'htmlform-submit' => 'Sometre', |
— | — | @@ -237,7 +237,7 @@ |
238 | 238 | 'htmlform-selectorother-other' => 'Ôtro', |
239 | 239 | 'htmlform-invalid-input' => 'Des problèmos sont arrevâs avouéc quârques valors', |
240 | 240 | ), |
241 | | - 'gl' => |
| 241 | + 'gl' => |
242 | 242 | array ( |
243 | 243 | 'htmlform-reset' => 'Desfacer os cambios', |
244 | 244 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -248,7 +248,7 @@ |
249 | 249 | 'htmlform-selectorother-other' => 'Outra', |
250 | 250 | 'htmlform-invalid-input' => 'Hai algún problema con partes do texto que inseriu', |
251 | 251 | ), |
252 | | - 'grc' => |
| 252 | + 'grc' => |
253 | 253 | array ( |
254 | 254 | 'htmlform-reset' => 'Ἀναστρέφειν μεταβολάς', |
255 | 255 | 'htmlform-submit' => 'Ὑποβάλλειν', |
— | — | @@ -259,7 +259,7 @@ |
260 | 260 | 'htmlform-selectorother-other' => 'Ἄλλον', |
261 | 261 | 'htmlform-invalid-input' => 'Μέρος τῶν εἰσαγομένων δεδομένων σου προβληματικὸν ἐστίν', |
262 | 262 | ), |
263 | | - 'gsw' => |
| 263 | + 'gsw' => |
264 | 264 | array ( |
265 | 265 | 'htmlform-reset' => 'Änderige ruckgängig mache', |
266 | 266 | 'htmlform-submit' => 'Ibertrage', |
— | — | @@ -270,7 +270,7 @@ |
271 | 271 | 'htmlform-selectorother-other' => 'Anderi', |
272 | 272 | 'htmlform-invalid-input' => 'Mit e Teil Yygabe git s Probläm', |
273 | 273 | ), |
274 | | - 'he' => |
| 274 | + 'he' => |
275 | 275 | array ( |
276 | 276 | 'htmlform-reset' => 'ביטול השינויים', |
277 | 277 | 'htmlform-submit' => 'שליחה', |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | 'htmlform-selectorother-other' => 'אחר', |
283 | 283 | 'htmlform-invalid-input' => 'יש בעיות עם חלק מהקלט שהכנסתם', |
284 | 284 | ), |
285 | | - 'hr' => |
| 285 | + 'hr' => |
286 | 286 | array ( |
287 | 287 | 'htmlform-reset' => 'Poništi izmjene', |
288 | 288 | 'htmlform-submit' => 'Pošalji', |
— | — | @@ -292,7 +292,7 @@ |
293 | 293 | 'htmlform-selectorother-other' => 'Drugi', |
294 | 294 | 'htmlform-invalid-input' => 'Postoje problemi s nekim od vaših unosa', |
295 | 295 | ), |
296 | | - 'hsb' => |
| 296 | + 'hsb' => |
297 | 297 | array ( |
298 | 298 | 'htmlform-reset' => 'Změny cofnyć', |
299 | 299 | 'htmlform-submit' => 'Wotpósłać', |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | 'htmlform-selectorother-other' => 'Druhe', |
305 | 305 | 'htmlform-invalid-input' => 'Su problemy z twojim zapodaćom', |
306 | 306 | ), |
307 | | - 'hu' => |
| 307 | + 'hu' => |
308 | 308 | array ( |
309 | 309 | 'htmlform-reset' => 'Változtatások visszavonása', |
310 | 310 | 'htmlform-submit' => 'Elküldés', |
— | — | @@ -314,7 +314,7 @@ |
315 | 315 | 'htmlform-selectorother-other' => 'egyéb', |
316 | 316 | 'htmlform-invalid-input' => 'Probléma van az általad megadott értékkel', |
317 | 317 | ), |
318 | | - 'ia' => |
| 318 | + 'ia' => |
319 | 319 | array ( |
320 | 320 | 'htmlform-reset' => 'Disfacer modificationes', |
321 | 321 | 'htmlform-submit' => 'Submitter', |
— | — | @@ -325,7 +325,7 @@ |
326 | 326 | 'htmlform-selectorother-other' => 'Altere', |
327 | 327 | 'htmlform-invalid-input' => 'Il ha problemas con alique que tu entrava', |
328 | 328 | ), |
329 | | - 'id' => |
| 329 | + 'id' => |
330 | 330 | array ( |
331 | 331 | 'htmlform-reset' => 'Batalkan perubahan', |
332 | 332 | 'htmlform-submit' => 'Kirim', |
— | — | @@ -336,7 +336,7 @@ |
337 | 337 | 'htmlform-selectorother-other' => 'Lain-lain', |
338 | 338 | 'htmlform-invalid-input' => 'Ada kesalahan dalam beberapa input Anda', |
339 | 339 | ), |
340 | | - 'it' => |
| 340 | + 'it' => |
341 | 341 | array ( |
342 | 342 | 'htmlform-reset' => 'Annulla modifiche', |
343 | 343 | 'htmlform-submit' => 'Invia', |
— | — | @@ -347,7 +347,7 @@ |
348 | 348 | 'htmlform-selectorother-other' => 'Altro', |
349 | 349 | 'htmlform-invalid-input' => 'Ci sono problemi con l\'input inserito', |
350 | 350 | ), |
351 | | - 'ja' => |
| 351 | + 'ja' => |
352 | 352 | array ( |
353 | 353 | 'htmlform-reset' => '変更を取り消す', |
354 | 354 | 'htmlform-submit' => '送信', |
— | — | @@ -358,7 +358,7 @@ |
359 | 359 | 'htmlform-selectorother-other' => 'その他', |
360 | 360 | 'htmlform-invalid-input' => '入力になんらかの問題があります', |
361 | 361 | ), |
362 | | - 'jv' => |
| 362 | + 'jv' => |
363 | 363 | array ( |
364 | 364 | 'htmlform-reset' => 'Batalna pangowahan', |
365 | 365 | 'htmlform-int-invalid' => 'Aji sing panjenengan lebokaké dudu angka wutuh (integer).', |
— | — | @@ -368,7 +368,7 @@ |
369 | 369 | 'htmlform-selectorother-other' => 'Liya', |
370 | 370 | 'htmlform-invalid-input' => 'Ana masalah jroning sawetara input panjenengan', |
371 | 371 | ), |
372 | | - 'ka' => |
| 372 | + 'ka' => |
373 | 373 | array ( |
374 | 374 | 'htmlform-reset' => 'ცვლილებების გაუქმება', |
375 | 375 | 'htmlform-submit' => 'შენახვა', |
— | — | @@ -379,7 +379,7 @@ |
380 | 380 | 'htmlform-selectorother-other' => 'სხვა', |
381 | 381 | 'htmlform-invalid-input' => 'თქვენს მიერ შეყვანილი ინფორმაციის ნაწილმა გამოიწვია პრობლემები', |
382 | 382 | ), |
383 | | - 'ko' => |
| 383 | + 'ko' => |
384 | 384 | array ( |
385 | 385 | 'htmlform-reset' => '변경한 것을 되돌리기', |
386 | 386 | 'htmlform-submit' => '저장', |
— | — | @@ -390,7 +390,7 @@ |
391 | 391 | 'htmlform-selectorother-other' => '기타', |
392 | 392 | 'htmlform-invalid-input' => '당신이 입력한 값에 문제가 있습니다.', |
393 | 393 | ), |
394 | | - 'ksh' => |
| 394 | + 'ksh' => |
395 | 395 | array ( |
396 | 396 | 'htmlform-reset' => 'Änderunge retuur nämme', |
397 | 397 | 'htmlform-submit' => 'Loß Jonn!', |
— | — | @@ -401,11 +401,11 @@ |
402 | 402 | 'htmlform-selectorother-other' => 'Annder', |
403 | 403 | 'htmlform-invalid-input' => 'Mer han e Problem met jet wat De enjejovve häß', |
404 | 404 | ), |
405 | | - 'la' => |
| 405 | + 'la' => |
406 | 406 | array ( |
407 | 407 | 'htmlform-selectorother-other' => 'Aliud', |
408 | 408 | ), |
409 | | - 'lb' => |
| 409 | + 'lb' => |
410 | 410 | array ( |
411 | 411 | 'htmlform-reset' => 'Ännerungen zrécksetzen', |
412 | 412 | 'htmlform-submit' => 'Späicheren', |
— | — | @@ -416,7 +416,7 @@ |
417 | 417 | 'htmlform-selectorother-other' => 'Anerer', |
418 | 418 | 'htmlform-invalid-input' => 'Et gëtt Problemer mat de Werter déi dir aginn hutt.', |
419 | 419 | ), |
420 | | - 'lt' => |
| 420 | + 'lt' => |
421 | 421 | array ( |
422 | 422 | 'htmlform-reset' => 'Atšaukti pakeitimus', |
423 | 423 | 'htmlform-submit' => 'Siųsti', |
— | — | @@ -427,7 +427,7 @@ |
428 | 428 | 'htmlform-selectorother-other' => 'Kita', |
429 | 429 | 'htmlform-invalid-input' => 'Yra problemų su jūsų įvestimi', |
430 | 430 | ), |
431 | | - 'lzh' => |
| 431 | + 'lzh' => |
432 | 432 | array ( |
433 | 433 | 'htmlform-reset' => '復', |
434 | 434 | 'htmlform-submit' => '呈', |
— | — | @@ -438,7 +438,7 @@ |
439 | 439 | 'htmlform-selectorother-other' => '他', |
440 | 440 | 'htmlform-invalid-input' => '爾之輸問也', |
441 | 441 | ), |
442 | | - 'mk' => |
| 442 | + 'mk' => |
443 | 443 | array ( |
444 | 444 | 'htmlform-reset' => 'Откажи промени', |
445 | 445 | 'htmlform-submit' => 'Зачувај', |
— | — | @@ -449,11 +449,11 @@ |
450 | 450 | 'htmlform-selectorother-other' => 'Друго', |
451 | 451 | 'htmlform-invalid-input' => 'Има проблеми со дел од вашиот внес', |
452 | 452 | ), |
453 | | - 'ml' => |
| 453 | + 'ml' => |
454 | 454 | array ( |
455 | 455 | 'htmlform-reset' => 'മാറ്റങ്ങള് വേണ്ട', |
456 | 456 | ), |
457 | | - 'ms' => |
| 457 | + 'ms' => |
458 | 458 | array ( |
459 | 459 | 'htmlform-reset' => 'Undur perubahan', |
460 | 460 | 'htmlform-submit' => 'Hantar', |
— | — | @@ -462,7 +462,7 @@ |
463 | 463 | 'htmlform-selectorother-other' => 'Lain-lain', |
464 | 464 | 'htmlform-invalid-input' => 'Terdapat beberapa masalah dengan input anda', |
465 | 465 | ), |
466 | | - 'mt' => |
| 466 | + 'mt' => |
467 | 467 | array ( |
468 | 468 | 'htmlform-reset' => 'Annulla l-modifiki', |
469 | 469 | 'htmlform-submit' => 'Ibgħat', |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | 'htmlform-selectorother-other' => 'Oħrajn', |
475 | 475 | 'htmlform-invalid-input' => 'Hemm xi problemi f\'dak li daħħalt', |
476 | 476 | ), |
477 | | - 'nds' => |
| 477 | + 'nds' => |
478 | 478 | array ( |
479 | 479 | 'htmlform-reset' => 'Ännern trüchsetten', |
480 | 480 | 'htmlform-submit' => 'Afspiekern', |
— | — | @@ -484,7 +484,7 @@ |
485 | 485 | 'htmlform-selectorother-other' => 'Annere', |
486 | 486 | 'htmlform-invalid-input' => 'Mit welk vun de angeven Weerten gifft dat Problemen', |
487 | 487 | ), |
488 | | - 'nds-nl' => |
| 488 | + 'nds-nl' => |
489 | 489 | array ( |
490 | 490 | 'htmlform-reset' => 'Wiezigingen ongedaonmaken', |
491 | 491 | 'htmlform-submit' => 'Opslaon', |
— | — | @@ -495,7 +495,7 @@ |
496 | 496 | 'htmlform-selectorother-other' => 'Aanders', |
497 | 497 | 'htmlform-invalid-input' => 'Der bin preblemen mit een paor in-egeven weerden', |
498 | 498 | ), |
499 | | - 'nl' => |
| 499 | + 'nl' => |
500 | 500 | array ( |
501 | 501 | 'htmlform-reset' => 'Wijzigingen ongedaan maken', |
502 | 502 | 'htmlform-submit' => 'Opslaan', |
— | — | @@ -506,7 +506,7 @@ |
507 | 507 | 'htmlform-selectorother-other' => 'Anders', |
508 | 508 | 'htmlform-invalid-input' => 'Er zijn problemen met enkele ingegeven waarden', |
509 | 509 | ), |
510 | | - 'nn' => |
| 510 | + 'nn' => |
511 | 511 | array ( |
512 | 512 | 'htmlform-reset' => 'Gjer om endringar', |
513 | 513 | 'htmlform-submit' => 'Lagre', |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | 'htmlform-selectorother-other' => 'Andre', |
519 | 519 | 'htmlform-invalid-input' => 'Det finst problem med innskrivinga di', |
520 | 520 | ), |
521 | | - 'no' => |
| 521 | + 'no' => |
522 | 522 | array ( |
523 | 523 | 'htmlform-reset' => 'Omgjør endringer', |
524 | 524 | 'htmlform-submit' => 'Lagre', |
— | — | @@ -528,7 +528,7 @@ |
529 | 529 | 'htmlform-selectorother-other' => 'Andre', |
530 | 530 | 'htmlform-invalid-input' => 'Det er problemer med noen av inndatene dine', |
531 | 531 | ), |
532 | | - 'oc' => |
| 532 | + 'oc' => |
533 | 533 | array ( |
534 | 534 | 'htmlform-reset' => 'Desfar las modificacions', |
535 | 535 | 'htmlform-submit' => 'Sometre', |
— | — | @@ -539,11 +539,11 @@ |
540 | 540 | 'htmlform-selectorother-other' => 'Autre', |
541 | 541 | 'htmlform-invalid-input' => 'De problèmas son arribats amb d\'unas valors', |
542 | 542 | ), |
543 | | - 'pdc' => |
| 543 | + 'pdc' => |
544 | 544 | array ( |
545 | 545 | 'htmlform-selectorother-other' => 'Annere', |
546 | 546 | ), |
547 | | - 'pl' => |
| 547 | + 'pl' => |
548 | 548 | array ( |
549 | 549 | 'htmlform-reset' => 'Cofnij zmiany', |
550 | 550 | 'htmlform-submit' => 'Zapisz', |
— | — | @@ -554,11 +554,11 @@ |
555 | 555 | 'htmlform-selectorother-other' => 'Inne', |
556 | 556 | 'htmlform-invalid-input' => 'Wystąpił problem z wprowadzonymi danymi', |
557 | 557 | ), |
558 | | - 'pnt' => |
| 558 | + 'pnt' => |
559 | 559 | array ( |
560 | 560 | 'htmlform-selectorother-other' => 'Άλλον', |
561 | 561 | ), |
562 | | - 'pt' => |
| 562 | + 'pt' => |
563 | 563 | array ( |
564 | 564 | 'htmlform-reset' => 'Desfazer alterações', |
565 | 565 | 'htmlform-submit' => 'Enviar', |
— | — | @@ -569,7 +569,7 @@ |
570 | 570 | 'htmlform-selectorother-other' => 'Outros', |
571 | 571 | 'htmlform-invalid-input' => 'Existem problemas com alguns dos dados introduzidos', |
572 | 572 | ), |
573 | | - 'qu' => |
| 573 | + 'qu' => |
574 | 574 | array ( |
575 | 575 | 'htmlform-reset' => 'Hukchasqakunata kutichiy', |
576 | 576 | 'htmlform-submit' => 'Kachay', |
— | — | @@ -580,7 +580,7 @@ |
581 | 581 | 'htmlform-selectorother-other' => 'Wakin', |
582 | 582 | 'htmlform-invalid-input' => 'Yaykuchisqaykiwanqa sasachakuykunam kachkan', |
583 | 583 | ), |
584 | | - 'ro' => |
| 584 | + 'ro' => |
585 | 585 | array ( |
586 | 586 | 'htmlform-reset' => 'Anulează modificările', |
587 | 587 | 'htmlform-submit' => 'Trimite', |
— | — | @@ -591,7 +591,7 @@ |
592 | 592 | 'htmlform-selectorother-other' => 'Altul', |
593 | 593 | 'htmlform-invalid-input' => 'Există probleme la valorile introduse', |
594 | 594 | ), |
595 | | - 'roa-tara' => |
| 595 | + 'roa-tara' => |
596 | 596 | array ( |
597 | 597 | 'htmlform-reset' => 'Annulle le cangiaminde', |
598 | 598 | 'htmlform-submit' => 'Conferme', |
— | — | @@ -602,7 +602,7 @@ |
603 | 603 | 'htmlform-selectorother-other' => 'Otre', |
604 | 604 | 'htmlform-invalid-input' => 'Stonne probbleme cu certe input ca tu è mise', |
605 | 605 | ), |
606 | | - 'ru' => |
| 606 | + 'ru' => |
607 | 607 | array ( |
608 | 608 | 'htmlform-reset' => 'Отменить изменения', |
609 | 609 | 'htmlform-submit' => 'Отправить', |
— | — | @@ -613,7 +613,7 @@ |
614 | 614 | 'htmlform-selectorother-other' => 'Иное', |
615 | 615 | 'htmlform-invalid-input' => 'Часть введённых вами данных вызвала проблемы', |
616 | 616 | ), |
617 | | - 'sah' => |
| 617 | + 'sah' => |
618 | 618 | array ( |
619 | 619 | 'htmlform-reset' => 'Уларытыыны төннөр', |
620 | 620 | 'htmlform-submit' => 'Ыыт', |
— | — | @@ -624,11 +624,11 @@ |
625 | 625 | 'htmlform-selectorother-other' => 'Атын', |
626 | 626 | 'htmlform-invalid-input' => 'Киллэрбит сибидиэнньэҥ сорҕото алҕаһы таһаарда', |
627 | 627 | ), |
628 | | - 'sc' => |
| 628 | + 'sc' => |
629 | 629 | array ( |
630 | 630 | 'htmlform-selectorother-other' => 'Àteru', |
631 | 631 | ), |
632 | | - 'sh' => |
| 632 | + 'sh' => |
633 | 633 | array ( |
634 | 634 | 'htmlform-reset' => 'Vrati izmjene', |
635 | 635 | 'htmlform-submit' => 'Unesi', |
— | — | @@ -639,7 +639,7 @@ |
640 | 640 | 'htmlform-selectorother-other' => 'Ostalo', |
641 | 641 | 'htmlform-invalid-input' => 'Postoje određeni problemi sa Vašim unosom', |
642 | 642 | ), |
643 | | - 'si' => |
| 643 | + 'si' => |
644 | 644 | array ( |
645 | 645 | 'htmlform-reset' => 'වෙනස්කිරීම් අහෝසිකරන්න', |
646 | 646 | 'htmlform-submit' => 'යොමුකරන්න', |
— | — | @@ -650,7 +650,7 @@ |
651 | 651 | 'htmlform-selectorother-other' => 'වෙනත්', |
652 | 652 | 'htmlform-invalid-input' => 'ඔබගේ සමහරක් ප්රදානයන් විෂයයෙහි ගැටළු ඇත', |
653 | 653 | ), |
654 | | - 'sk' => |
| 654 | + 'sk' => |
655 | 655 | array ( |
656 | 656 | 'htmlform-reset' => 'Vrátiť zmeny', |
657 | 657 | 'htmlform-submit' => 'Odoslať', |
— | — | @@ -661,7 +661,7 @@ |
662 | 662 | 'htmlform-selectorother-other' => 'Iné', |
663 | 663 | 'htmlform-invalid-input' => 'Niekotrý z údajov, ktoré ste zadali je problematický', |
664 | 664 | ), |
665 | | - 'sr-ec' => |
| 665 | + 'sr-ec' => |
666 | 666 | array ( |
667 | 667 | 'htmlform-reset' => 'Врати измене', |
668 | 668 | 'htmlform-submit' => 'Пошаљи', |
— | — | @@ -672,7 +672,7 @@ |
673 | 673 | 'htmlform-selectorother-other' => 'Друго', |
674 | 674 | 'htmlform-invalid-input' => 'Има проблема са делом Вашег уноса', |
675 | 675 | ), |
676 | | - 'sv' => |
| 676 | + 'sv' => |
677 | 677 | array ( |
678 | 678 | 'htmlform-reset' => 'Ogör ändringar', |
679 | 679 | 'htmlform-submit' => 'Spara', |
— | — | @@ -683,15 +683,15 @@ |
684 | 684 | 'htmlform-selectorother-other' => 'Andra', |
685 | 685 | 'htmlform-invalid-input' => 'Det finns problem med din inmatning', |
686 | 686 | ), |
687 | | - 'sw' => |
| 687 | + 'sw' => |
688 | 688 | array ( |
689 | 689 | 'htmlform-selectorother-other' => 'Nyingine', |
690 | 690 | ), |
691 | | - 'te' => |
| 691 | + 'te' => |
692 | 692 | array ( |
693 | 693 | 'htmlform-selectorother-other' => 'ఇతర', |
694 | 694 | ), |
695 | | - 'tr' => |
| 695 | + 'tr' => |
696 | 696 | array ( |
697 | 697 | 'htmlform-reset' => 'Değişiklikleri geri al', |
698 | 698 | 'htmlform-submit' => 'Gönder', |
— | — | @@ -702,7 +702,7 @@ |
703 | 703 | 'htmlform-selectorother-other' => 'Diğer', |
704 | 704 | 'htmlform-invalid-input' => 'Girdinizin bir kısmıyla ilgili sorunlar var', |
705 | 705 | ), |
706 | | - 'uk' => |
| 706 | + 'uk' => |
707 | 707 | array ( |
708 | 708 | 'htmlform-reset' => 'Відкотити зміни', |
709 | 709 | 'htmlform-submit' => 'Відправити', |
— | — | @@ -713,7 +713,7 @@ |
714 | 714 | 'htmlform-selectorother-other' => 'Інше', |
715 | 715 | 'htmlform-invalid-input' => 'Частина введених вами даних викликала проблеми', |
716 | 716 | ), |
717 | | - 'vec' => |
| 717 | + 'vec' => |
718 | 718 | array ( |
719 | 719 | 'htmlform-reset' => 'Scancèla modifiche', |
720 | 720 | 'htmlform-submit' => 'Manda', |
— | — | @@ -723,7 +723,7 @@ |
724 | 724 | 'htmlform-select-badoption' => 'El valor che te ghè indicà no\'l xe mia valido.', |
725 | 725 | 'htmlform-invalid-input' => 'Ghe xe problemi con l\'input che te ghè inserìo', |
726 | 726 | ), |
727 | | - 'vi' => |
| 727 | + 'vi' => |
728 | 728 | array ( |
729 | 729 | 'htmlform-reset' => 'Hủy các thay đổi', |
730 | 730 | 'htmlform-submit' => 'Đăng', |
— | — | @@ -734,15 +734,15 @@ |
735 | 735 | 'htmlform-selectorother-other' => 'Khác', |
736 | 736 | 'htmlform-invalid-input' => 'Có vấn đề trong dữ liệu bạn vừa đưa vào', |
737 | 737 | ), |
738 | | - 'vo' => |
| 738 | + 'vo' => |
739 | 739 | array ( |
740 | 740 | 'htmlform-selectorother-other' => 'Votik', |
741 | 741 | ), |
742 | | - 'xal' => |
| 742 | + 'xal' => |
743 | 743 | array ( |
744 | 744 | 'htmlform-reset' => 'Сольлһдудиг уга кех', |
745 | 745 | ), |
746 | | - 'yue' => |
| 746 | + 'yue' => |
747 | 747 | array ( |
748 | 748 | 'htmlform-reset' => '復原更改', |
749 | 749 | 'htmlform-submit' => '遞交', |
— | — | @@ -753,7 +753,7 @@ |
754 | 754 | 'htmlform-selectorother-other' => '其它', |
755 | 755 | 'htmlform-invalid-input' => '響你嘅輸入度有一啲問題', |
756 | 756 | ), |
757 | | - 'zh-hans' => |
| 757 | + 'zh-hans' => |
758 | 758 | array ( |
759 | 759 | 'htmlform-reset' => '撤销更改', |
760 | 760 | 'htmlform-submit' => '提交', |
— | — | @@ -764,7 +764,7 @@ |
765 | 765 | 'htmlform-selectorother-other' => '其他', |
766 | 766 | 'htmlform-invalid-input' => '您输入的内容存在问题', |
767 | 767 | ), |
768 | | - 'zh-hant' => |
| 768 | + 'zh-hant' => |
769 | 769 | array ( |
770 | 770 | 'htmlform-reset' => '復原更改', |
771 | 771 | 'htmlform-submit' => '遞交', |
Index: trunk/extensions/LiquidThreads/compat/generateCompatibilityLocalisation.php |
— | — | @@ -2,27 +2,27 @@ |
3 | 3 | |
4 | 4 | // Utility script to generate an extension messages file for backwards-compatibility. |
5 | 5 | |
6 | | -require_once ( getenv('MW_INSTALL_PATH') !== false |
7 | | - ? getenv('MW_INSTALL_PATH')."/maintenance/commandLine.inc" |
| 6 | +require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
| 7 | + ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
8 | 8 | : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
9 | 9 | |
10 | | -$messages = array( |
11 | | - 'htmlform-reset', |
12 | | - 'htmlform-submit', |
13 | | - 'htmlform-int-invalid', |
14 | | - 'htmlform-int-toolow', |
15 | | - 'htmlform-int-toohigh', |
16 | | - 'htmlform-select-badoption', |
17 | | - 'htmlform-selectorother-other', |
18 | | - 'htmlform-invalid-input', |
19 | | - ); |
| 10 | +$messages = array( |
| 11 | + 'htmlform-reset', |
| 12 | + 'htmlform-submit', |
| 13 | + 'htmlform-int-invalid', |
| 14 | + 'htmlform-int-toolow', |
| 15 | + 'htmlform-int-toohigh', |
| 16 | + 'htmlform-select-badoption', |
| 17 | + 'htmlform-selectorother-other', |
| 18 | + 'htmlform-invalid-input', |
| 19 | +); |
20 | 20 | |
21 | | -$languages = array_keys(Language::getLanguageNames( false )); |
| 21 | +$languages = array_keys( Language::getLanguageNames( false ) ); |
22 | 22 | $data = array_fill_keys( $languages, array() ); |
23 | 23 | |
24 | | -foreach( $messages as $msg ) { |
| 24 | +foreach ( $messages as $msg ) { |
25 | 25 | print "\nGetting localisation for $msg..."; |
26 | | - foreach( $languages as $lang ) { |
| 26 | + foreach ( $languages as $lang ) { |
27 | 27 | $data[$lang][$msg] = $wgMessageCache->get( $msg, false, $lang ); |
28 | 28 | print " $lang "; |
29 | 29 | } |
— | — | @@ -33,24 +33,24 @@ |
34 | 34 | |
35 | 35 | print "Eliminating redundant data... "; |
36 | 36 | |
37 | | -foreach( $languages as $lang ) { |
| 37 | +foreach ( $languages as $lang ) { |
38 | 38 | $fallback = Language::getFallbackFor( $lang ); |
39 | | - |
| 39 | + |
40 | 40 | print " [$lang from $fallback] "; |
41 | 41 | $lastFallback = $lang; |
42 | | - |
43 | | - while ($fallback && !isset($originalData[$fallback]) && $fallback != $lastFallback) { |
| 42 | + |
| 43 | + while ( $fallback && !isset( $originalData[$fallback] ) && $fallback != $lastFallback ) { |
44 | 44 | $lastFallback = $fallback; |
45 | 45 | $fallback = Language::getFallbackFor( $lang ); |
46 | 46 | } |
47 | | - |
48 | | - if ( $fallback && isset($originalData[$fallback]) ) { |
| 47 | + |
| 48 | + if ( $fallback && isset( $originalData[$fallback] ) ) { |
49 | 49 | $fallbackData = $originalData[$fallback]; |
50 | | - |
| 50 | + |
51 | 51 | $data[$lang] = array_diff_assoc( $originalData[$lang], $fallbackData ); |
52 | | - |
53 | | - if (!count($data[$lang])) |
54 | | - unset($data[$lang]); |
| 52 | + |
| 53 | + if ( !count( $data[$lang] ) ) |
| 54 | + unset( $data[$lang] ); |
55 | 55 | } |
56 | 56 | } |
57 | 57 | |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | |
60 | 60 | $export = "<?php\n" . |
61 | 61 | "// This file is generated automatically by generateCompatibilityLocalisation.php\n" . |
62 | | - '$messages = '.var_export($data, true).";\n"; |
| 62 | + '$messages = ' . var_export( $data, true ) . ";\n"; |
63 | 63 | |
64 | 64 | file_put_contents( 'Lqt-compat.i18n.php', $export ); |
65 | 65 | |
Index: trunk/extensions/LiquidThreads/compat/HTMLForm.php |
— | — | @@ -1,7 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | class HTMLForm { |
5 | | - |
6 | 5 | static $jsAdded = false; |
7 | 6 | |
8 | 7 | /* The descriptor is an array of arrays. |
— | — | @@ -26,14 +25,14 @@ |
27 | 26 | |
28 | 27 | function __construct( $descriptor, $messagePrefix ) { |
29 | 28 | wfLoadExtensionMessages( 'Lqt-Compat' ); |
30 | | - |
| 29 | + |
31 | 30 | $this->mMessagePrefix = $messagePrefix; |
32 | 31 | |
33 | 32 | // Expand out into a tree. |
34 | 33 | $loadedDescriptor = array(); |
35 | 34 | $this->mFlatFields = array(); |
36 | 35 | |
37 | | - foreach( $descriptor as $fieldname => $info ) { |
| 36 | + foreach ( $descriptor as $fieldname => $info ) { |
38 | 37 | $section = ''; |
39 | 38 | if ( isset( $info['section'] ) ) |
40 | 39 | $section = $info['section']; |
— | — | @@ -44,10 +43,10 @@ |
45 | 44 | $field->mParent = $this; |
46 | 45 | |
47 | 46 | $setSection =& $loadedDescriptor; |
48 | | - if( $section ) { |
| 47 | + if ( $section ) { |
49 | 48 | $sectionParts = explode( '/', $section ); |
50 | 49 | |
51 | | - while( count( $sectionParts ) ) { |
| 50 | + while ( count( $sectionParts ) ) { |
52 | 51 | $newName = array_shift( $sectionParts ); |
53 | 52 | |
54 | 53 | if ( !isset( $setSection[$newName] ) ) { |
— | — | @@ -79,7 +78,7 @@ |
80 | 79 | $descriptor['class'] = $class; |
81 | 80 | } |
82 | 81 | |
83 | | - if( !$class ) { |
| 82 | + if ( !$class ) { |
84 | 83 | throw new MWException( "Descriptor with no class: " . print_r( $descriptor, true ) ); |
85 | 84 | } |
86 | 85 | |
— | — | @@ -104,7 +103,7 @@ |
105 | 104 | if ( $wgUser->matchEditToken( $editToken ) ) |
106 | 105 | $result = $this->trySubmit(); |
107 | 106 | |
108 | | - if( $result === true ) |
| 107 | + if ( $result === true ) |
109 | 108 | return $result; |
110 | 109 | |
111 | 110 | // Display form. |
— | — | @@ -118,7 +117,7 @@ |
119 | 118 | */ |
120 | 119 | function trySubmit() { |
121 | 120 | // Check for validation |
122 | | - foreach( $this->mFlatFields as $fieldname => $field ) { |
| 121 | + foreach ( $this->mFlatFields as $fieldname => $field ) { |
123 | 122 | if ( !empty( $field->mParams['nodata'] ) ) continue; |
124 | 123 | if ( $field->validate( $this->mFieldData[$fieldname], |
125 | 124 | $this->mFieldData ) !== true ) { |
— | — | @@ -205,7 +204,7 @@ |
206 | 205 | |
207 | 206 | $html .= Xml::submitButton( $this->getSubmitText(), $attribs ) . "\n"; |
208 | 207 | |
209 | | - if( $this->mShowReset ) { |
| 208 | + if ( $this->mShowReset ) { |
210 | 209 | $html .= Xml::element( |
211 | 210 | 'input', |
212 | 211 | array( |
— | — | @@ -214,7 +213,7 @@ |
215 | 214 | ) |
216 | 215 | ) . "\n"; |
217 | 216 | } |
218 | | - |
| 217 | + |
219 | 218 | return $html; |
220 | 219 | } |
221 | 220 | |
— | — | @@ -228,7 +227,7 @@ |
229 | 228 | } else { |
230 | 229 | $errorstr = $errors; |
231 | 230 | } |
232 | | - |
| 231 | + |
233 | 232 | $errorstr = Xml::tags( 'div', array( 'class' => 'error' ), $errorstr ); |
234 | 233 | |
235 | 234 | global $wgOut; |
— | — | @@ -238,7 +237,7 @@ |
239 | 238 | static function formatErrors( $errors ) { |
240 | 239 | $errorstr = ''; |
241 | 240 | foreach ( $errors as $error ) { |
242 | | - if( is_array( $error ) ) { |
| 241 | + if ( is_array( $error ) ) { |
243 | 242 | $msg = array_shift( $error ); |
244 | 243 | } else { |
245 | 244 | $msg = $error; |
— | — | @@ -285,14 +284,14 @@ |
286 | 285 | $subsectionHtml = ''; |
287 | 286 | $hasLeftColumn = false; |
288 | 287 | |
289 | | - foreach( $fields as $key => $value ) { |
| 288 | + foreach ( $fields as $key => $value ) { |
290 | 289 | if ( is_object( $value ) ) { |
291 | 290 | $v = empty( $value->mParams['nodata'] ) |
292 | 291 | ? $this->mFieldData[$key] |
293 | 292 | : $value->getDefault(); |
294 | 293 | $tableHtml .= $value->getTableRow( $v ); |
295 | 294 | |
296 | | - if( $value->getLabel() != ' ' ) |
| 295 | + if ( $value->getLabel() != ' ' ) |
297 | 296 | $hasLeftColumn = true; |
298 | 297 | } elseif ( is_array( $value ) ) { |
299 | 298 | $section = $this->displaySection( $value ); |
— | — | @@ -302,7 +301,7 @@ |
303 | 302 | } |
304 | 303 | |
305 | 304 | $classes = array(); |
306 | | - if( !$hasLeftColumn ) // Avoid strange spacing when no labels exist |
| 305 | + if ( !$hasLeftColumn ) // Avoid strange spacing when no labels exist |
307 | 306 | $classes[] = 'mw-htmlform-nolabel'; |
308 | 307 | $classes = implode( ' ', $classes ); |
309 | 308 | |
— | — | @@ -316,7 +315,7 @@ |
317 | 316 | |
318 | 317 | $fieldData = array(); |
319 | 318 | |
320 | | - foreach( $this->mFlatFields as $fieldname => $field ) { |
| 319 | + foreach ( $this->mFlatFields as $fieldname => $field ) { |
321 | 320 | if ( !empty( $field->mParams['nodata'] ) ) continue; |
322 | 321 | if ( !empty( $field->mParams['disabled'] ) ) { |
323 | 322 | $fieldData[$fieldname] = $field->getDefault(); |
— | — | @@ -326,7 +325,7 @@ |
327 | 326 | } |
328 | 327 | |
329 | 328 | // Filter data. |
330 | | - foreach( $fieldData as $name => &$value ) { |
| 329 | + foreach ( $fieldData as $name => &$value ) { |
331 | 330 | $field = $this->mFlatFields[$name]; |
332 | 331 | $value = $field->filter( $value, $this->mFlatFields ); |
333 | 332 | } |
— | — | @@ -336,12 +335,12 @@ |
337 | 336 | |
338 | 337 | function importData( $fieldData ) { |
339 | 338 | // Filter data. |
340 | | - foreach( $fieldData as $name => &$value ) { |
| 339 | + foreach ( $fieldData as $name => &$value ) { |
341 | 340 | $field = $this->mFlatFields[$name]; |
342 | 341 | $value = $field->filter( $value, $this->mFlatFields ); |
343 | 342 | } |
344 | 343 | |
345 | | - foreach( $this->mFlatFields as $fieldname => $field ) { |
| 344 | + foreach ( $this->mFlatFields as $fieldname => $field ) { |
346 | 345 | if ( !isset( $fieldData[$fieldname] ) ) |
347 | 346 | $fieldData[$fieldname] = $field->getDefault(); |
348 | 347 | } |
— | — | @@ -370,7 +369,7 @@ |
371 | 370 | } |
372 | 371 | |
373 | 372 | function filter( $value, $alldata ) { |
374 | | - if( isset( $this->mFilterCallback ) ) { |
| 373 | + if ( isset( $this->mFilterCallback ) ) { |
375 | 374 | $value = call_user_func( $this->mFilterCallback, $value, $alldata ); |
376 | 375 | } |
377 | 376 | |
— | — | @@ -378,7 +377,7 @@ |
379 | 378 | } |
380 | 379 | |
381 | 380 | function loadDataFromRequest( $request ) { |
382 | | - if( $request->getCheck( $this->mName ) ) { |
| 381 | + if ( $request->getCheck( $this->mName ) ) { |
383 | 382 | return $request->getText( $this->mName ); |
384 | 383 | } else { |
385 | 384 | return $this->getDefault(); |
— | — | @@ -388,7 +387,7 @@ |
389 | 388 | function __construct( $params ) { |
390 | 389 | $this->mParams = $params; |
391 | 390 | |
392 | | - if( isset( $params['label-message'] ) ) { |
| 391 | + if ( isset( $params['label-message'] ) ) { |
393 | 392 | $msgInfo = $params['label-message']; |
394 | 393 | |
395 | 394 | if ( is_array( $msgInfo ) ) { |
— | — | @@ -404,8 +403,8 @@ |
405 | 404 | } |
406 | 405 | |
407 | 406 | if ( isset( $params['name'] ) ) { |
408 | | - $this->mName = 'wp'.$params['name']; |
409 | | - $this->mID = 'mw-input-'.$params['name']; |
| 407 | + $this->mName = 'wp' . $params['name']; |
| 408 | + $this->mID = 'mw-input-' . $params['name']; |
410 | 409 | } |
411 | 410 | |
412 | 411 | if ( isset( $params['default'] ) ) { |
— | — | @@ -442,7 +441,7 @@ |
443 | 442 | Xml::tags( 'label', array( 'for' => $this->mID ), $this->getLabel() ) |
444 | 443 | ); |
445 | 444 | $html .= Xml::tags( 'td', array( 'class' => 'mw-input' ), |
446 | | - $this->getInputHTML( $value ) ."\n$errors" ); |
| 445 | + $this->getInputHTML( $value ) . "\n$errors" ); |
447 | 446 | |
448 | 447 | $fieldType = get_class( $this ); |
449 | 448 | |
— | — | @@ -455,7 +454,7 @@ |
456 | 455 | |
457 | 456 | $text = wfMsgExt( $msg, 'parseinline' ); |
458 | 457 | |
459 | | - if( !wfEmptyMsg( $msg, $text ) ) { |
| 458 | + if ( !wfEmptyMsg( $msg, $text ) ) { |
460 | 459 | $row = Xml::tags( 'td', array( 'colspan' => 2, 'class' => 'htmlform-tip' ), |
461 | 460 | $text ); |
462 | 461 | |
— | — | @@ -483,7 +482,7 @@ |
484 | 483 | static function flattenOptions( $options ) { |
485 | 484 | $flatOpts = array(); |
486 | 485 | |
487 | | - foreach( $options as $key => $value ) { |
| 486 | + foreach ( $options as $key => $value ) { |
488 | 487 | if ( is_array( $value ) ) { |
489 | 488 | $flatOpts = array_merge( $flatOpts, self::flattenOptions( $value ) ); |
490 | 489 | } else { |
— | — | @@ -507,8 +506,8 @@ |
508 | 507 | if ( isset( $this->mParams['maxlength'] ) ) { |
509 | 508 | $attribs['maxlength'] = $this->mParams['maxlength']; |
510 | 509 | } |
511 | | - |
512 | | - if( !empty( $this->mParams['disabled'] ) ) { |
| 510 | + |
| 511 | + if ( !empty( $this->mParams['disabled'] ) ) { |
513 | 512 | $attribs['disabled'] = 'disabled'; |
514 | 513 | } |
515 | 514 | |
— | — | @@ -530,7 +529,7 @@ |
531 | 530 | function validate( $value, $alldata ) { |
532 | 531 | $p = parent::validate( $value, $alldata ); |
533 | 532 | |
534 | | - if( $p !== true ) return $p; |
| 533 | + if ( $p !== true ) return $p; |
535 | 534 | |
536 | 535 | if ( intval( $value ) != $value ) { |
537 | 536 | return wfMsgExt( 'htmlform-int-invalid', 'parse' ); |
— | — | @@ -546,7 +545,7 @@ |
547 | 546 | |
548 | 547 | if ( isset( $this->mParams['max'] ) ) { |
549 | 548 | $max = $this->mParams['max']; |
550 | | - if( $max < $value ) |
| 549 | + if ( $max < $value ) |
551 | 550 | return wfMsgExt( 'htmlform-int-toohigh', 'parse', array( $max ) ); |
552 | 551 | } |
553 | 552 | |
— | — | @@ -560,7 +559,7 @@ |
561 | 560 | $value = !$value; |
562 | 561 | |
563 | 562 | $attr = array( 'id' => $this->mID ); |
564 | | - if( !empty( $this->mParams['disabled'] ) ) { |
| 563 | + if ( !empty( $this->mParams['disabled'] ) ) { |
565 | 564 | $attr['disabled'] = 'disabled'; |
566 | 565 | } |
567 | 566 | |
— | — | @@ -579,7 +578,7 @@ |
580 | 579 | } |
581 | 580 | |
582 | 581 | // GetCheck won't work like we want for checks. |
583 | | - if( $request->getCheck( 'wpEditToken' ) ) { |
| 582 | + if ( $request->getCheck( 'wpEditToken' ) ) { |
584 | 583 | // XOR has the following truth table, which is what we want |
585 | 584 | // INVERT VALUE | OUTPUT |
586 | 585 | // true true | false |
— | — | @@ -597,7 +596,7 @@ |
598 | 597 | |
599 | 598 | function validate( $value, $alldata ) { |
600 | 599 | $p = parent::validate( $value, $alldata ); |
601 | | - if( $p !== true ) return $p; |
| 600 | + if ( $p !== true ) return $p; |
602 | 601 | |
603 | 602 | $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
604 | 603 | if ( in_array( $value, $validOptions ) ) |
— | — | @@ -614,7 +613,7 @@ |
615 | 614 | // Working around this by forcing all of them to strings. |
616 | 615 | $options = array_map( 'strval', $this->mParams['options'] ); |
617 | 616 | |
618 | | - if( !empty( $this->mParams['disabled'] ) ) { |
| 617 | + if ( !empty( $this->mParams['disabled'] ) ) { |
619 | 618 | $select->setAttribute( 'disabled', 'disabled' ); |
620 | 619 | } |
621 | 620 | |
— | — | @@ -628,7 +627,7 @@ |
629 | 628 | static $jsAdded = false; |
630 | 629 | |
631 | 630 | function __construct( $params ) { |
632 | | - if( !in_array( 'other', $params['options'] ) ) { |
| 631 | + if ( !in_array( 'other', $params['options'] ) ) { |
633 | 632 | $params['options'][wfMsg( 'htmlform-selectorother-other' )] = 'other'; |
634 | 633 | } |
635 | 634 | |
— | — | @@ -638,9 +637,12 @@ |
639 | 638 | function getInputHTML( $value ) { |
640 | 639 | $valInSelect = false; |
641 | 640 | |
642 | | - if( $value !== false ) |
643 | | - $valInSelect = in_array( $value, |
644 | | - HTMLFormField::flattenOptions( $this->mParams['options'] ) ); |
| 641 | + if ( $value !== false ) { |
| 642 | + $valInSelect = in_array( |
| 643 | + $value, |
| 644 | + HTMLFormField::flattenOptions( $this->mParams['options'] ) |
| 645 | + ); |
| 646 | + } |
645 | 647 | |
646 | 648 | $selected = $valInSelect ? $value : 'other'; |
647 | 649 | |
— | — | @@ -650,7 +652,7 @@ |
651 | 653 | $select->setAttribute( 'class', 'mw-htmlform-select-or-other' ); |
652 | 654 | |
653 | 655 | $tbAttribs = array( 'id' => $this->mID . '-other' ); |
654 | | - if( !empty( $this->mParams['disabled'] ) ) { |
| 656 | + if ( !empty( $this->mParams['disabled'] ) ) { |
655 | 657 | $select->setAttribute( 'disabled', 'disabled' ); |
656 | 658 | $tbAttribs['disabled'] = 'disabled'; |
657 | 659 | } |
— | — | @@ -661,19 +663,21 @@ |
662 | 664 | $tbAttribs['maxlength'] = $this->mParams['maxlength']; |
663 | 665 | } |
664 | 666 | |
665 | | - $textbox = Xml::input( $this->mName . '-other', |
666 | | - $this->getSize(), |
667 | | - $valInSelect ? '' : $value, |
668 | | - $tbAttribs ); |
| 667 | + $textbox = Xml::input( |
| 668 | + $this->mName . '-other', |
| 669 | + $this->getSize(), |
| 670 | + $valInSelect ? '' : $value, |
| 671 | + $tbAttribs |
| 672 | + ); |
669 | 673 | |
670 | 674 | return "$select<br/>\n$textbox"; |
671 | 675 | } |
672 | 676 | |
673 | 677 | function loadDataFromRequest( $request ) { |
674 | | - if( $request->getCheck( $this->mName ) ) { |
| 678 | + if ( $request->getCheck( $this->mName ) ) { |
675 | 679 | $val = $request->getText( $this->mName ); |
676 | 680 | |
677 | | - if( $val == 'other' ) { |
| 681 | + if ( $val == 'other' ) { |
678 | 682 | $val = $request->getText( $this->mName . '-other' ); |
679 | 683 | } |
680 | 684 | |
— | — | @@ -687,9 +691,9 @@ |
688 | 692 | class HTMLMultiSelectField extends HTMLFormField { |
689 | 693 | function validate( $value, $alldata ) { |
690 | 694 | $p = parent::validate( $value, $alldata ); |
691 | | - if( $p !== true ) return $p; |
| 695 | + if ( $p !== true ) return $p; |
692 | 696 | |
693 | | - if( !is_array( $value ) ) return false; |
| 697 | + if ( !is_array( $value ) ) return false; |
694 | 698 | |
695 | 699 | // If all options are valid, array_intersect of the valid options and the provided |
696 | 700 | // options will return the provided options. |
— | — | @@ -716,17 +720,24 @@ |
717 | 721 | $attribs['disabled'] = 'disabled'; |
718 | 722 | } |
719 | 723 | |
720 | | - foreach( $options as $label => $info ) { |
721 | | - if( is_array( $info ) ) { |
| 724 | + foreach ( $options as $label => $info ) { |
| 725 | + if ( is_array( $info ) ) { |
722 | 726 | $html .= Xml::tags( 'h1', null, $label ) . "\n"; |
723 | 727 | $html .= $this->formatOptions( $info, $value ); |
724 | 728 | } else { |
725 | 729 | $thisAttribs = array( 'id' => $this->mID . "-$info", 'value' => $info ); |
726 | | - |
727 | | - $checkbox = Xml::check( $this->mName . '[]', in_array( $info, $value ), |
728 | | - $attribs + $thisAttribs ); |
729 | | - $checkbox .= ' ' . Xml::tags( 'label', array( 'for' => $this->mID . "-$info" ), $label ); |
730 | 730 | |
| 731 | + $checkbox = Xml::check( |
| 732 | + $this->mName . '[]', |
| 733 | + in_array( $info, $value ), |
| 734 | + $attribs + $thisAttribs |
| 735 | + ); |
| 736 | + $checkbox .= ' ' . Xml::tags( |
| 737 | + 'label', |
| 738 | + array( 'for' => $this->mID . "-$info" ), |
| 739 | + $label |
| 740 | + ); |
| 741 | + |
731 | 742 | $html .= $checkbox . '<br />'; |
732 | 743 | } |
733 | 744 | } |
— | — | @@ -736,10 +747,10 @@ |
737 | 748 | |
738 | 749 | function loadDataFromRequest( $request ) { |
739 | 750 | // won't work with getCheck |
740 | | - if( $request->getCheck( 'wpEditToken' ) ) { |
| 751 | + if ( $request->getCheck( 'wpEditToken' ) ) { |
741 | 752 | $arr = $request->getArray( $this->mName ); |
742 | 753 | |
743 | | - if( !$arr ) |
| 754 | + if ( !$arr ) |
744 | 755 | $arr = array(); |
745 | 756 | |
746 | 757 | return $arr; |
— | — | @@ -760,9 +771,9 @@ |
761 | 772 | class HTMLRadioField extends HTMLFormField { |
762 | 773 | function validate( $value, $alldata ) { |
763 | 774 | $p = parent::validate( $value, $alldata ); |
764 | | - if( $p !== true ) return $p; |
| 775 | + if ( $p !== true ) return $p; |
765 | 776 | |
766 | | - if( !is_string( $value ) && !is_int( $value ) ) |
| 777 | + if ( !is_string( $value ) && !is_int( $value ) ) |
767 | 778 | return false; |
768 | 779 | |
769 | 780 | $validOptions = HTMLFormField::flattenOptions( $this->mParams['options'] ); |
— | — | @@ -778,7 +789,7 @@ |
779 | 790 | |
780 | 791 | return $html; |
781 | 792 | } |
782 | | - |
| 793 | + |
783 | 794 | function formatOptions( $options, $value ) { |
784 | 795 | $html = ''; |
785 | 796 | |
— | — | @@ -787,8 +798,8 @@ |
788 | 799 | $attribs['disabled'] = 'disabled'; |
789 | 800 | } |
790 | 801 | |
791 | | - foreach( $options as $label => $info ) { |
792 | | - if( is_array( $info ) ) { |
| 802 | + foreach ( $options as $label => $info ) { |
| 803 | + if ( is_array( $info ) ) { |
793 | 804 | $html .= Xml::tags( 'h1', null, $label ) . "\n"; |
794 | 805 | $html .= $this->formatOptions( $info, $value ); |
795 | 806 | } else { |
Index: trunk/extensions/LiquidThreads/compat/LqtCompatArticle.php |
— | — | @@ -3,68 +3,67 @@ |
4 | 4 | |
5 | 5 | global $wgVersion; |
6 | 6 | if ( version_compare( $wgVersion, '1.16', '<' ) ) { |
7 | | - |
8 | 7 | // LiquidThreads compatibility wrapper around the Article object. |
9 | 8 | class Article_LQT_Compat extends Article { |
10 | | - |
| 9 | + |
11 | 10 | public function getOutputFromWikitext( $text, $cache = true, $parserOptions = false ) { |
12 | 11 | global $wgParser, $wgOut, $wgEnableParserCache, $wgUseFileCache; |
13 | | - |
| 12 | + |
14 | 13 | if ( !$parserOptions ) { |
15 | 14 | $parserOptions = $wgOut->parserOptions(); |
16 | 15 | } |
17 | | - |
18 | | - $time = -wfTime(); |
| 16 | + |
| 17 | + $time = - wfTime(); |
19 | 18 | $parserOutput = $wgParser->parse( $text, $this->mTitle, |
20 | 19 | $parserOptions, true, true, $this->getRevIdFetched() ); |
21 | 20 | $time += wfTime(); |
22 | | - |
| 21 | + |
23 | 22 | # Timing hack |
24 | | - if( $time > 3 ) { |
| 23 | + if ( $time > 3 ) { |
25 | 24 | wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time, |
26 | | - $this->mTitle->getPrefixedDBkey())); |
| 25 | + $this->mTitle->getPrefixedDBkey() ) ); |
27 | 26 | } |
28 | | - |
29 | | - if( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != -1 ) { |
| 27 | + |
| 28 | + if ( $wgEnableParserCache && $cache && $this && $parserOutput->getCacheTime() != - 1 ) { |
30 | 29 | $parserCache = ParserCache::singleton(); |
31 | 30 | $parserCache->save( $parserOutput, $this, $parserOptions ); |
32 | 31 | } |
33 | 32 | // Make sure file cache is not used on uncacheable content. |
34 | 33 | // Output that has magic words in it can still use the parser cache |
35 | 34 | // (if enabled), though it will generally expire sooner. |
36 | | - if( $parserOutput->getCacheTime() == -1 || $parserOutput->containsOldMagic() ) { |
| 35 | + if ( $parserOutput->getCacheTime() == - 1 || $parserOutput->containsOldMagic() ) { |
37 | 36 | $wgUseFileCache = false; |
38 | 37 | } |
39 | 38 | return $parserOutput; |
40 | 39 | } |
41 | | - |
| 40 | + |
42 | 41 | /** Stolen from 1.16-alpha, for compatibility with 1.15 */ |
43 | 42 | /** Lightweight method to get the parser output for a page, checking the parser cache |
44 | 43 | * and so on. Doesn't consider most of the stuff that Article::view is forced to |
45 | 44 | * consider, so it's not appropriate to use there. */ |
46 | 45 | function getParserOutput( $oldid = null ) { |
47 | 46 | global $wgEnableParserCache, $wgUser, $wgOut; |
48 | | - |
| 47 | + |
49 | 48 | // Should the parser cache be used? |
50 | 49 | $useParserCache = $wgEnableParserCache && |
51 | 50 | intval( $wgUser->getOption( 'stubthreshold' ) ) == 0 && |
52 | 51 | $this->exists() && |
53 | 52 | $oldid === null; |
54 | | - |
55 | | - wfDebug( __METHOD__.': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
| 53 | + |
| 54 | + wfDebug( __METHOD__ . ': using parser cache: ' . ( $useParserCache ? 'yes' : 'no' ) . "\n" ); |
56 | 55 | if ( $wgUser->getOption( 'stubthreshold' ) ) { |
57 | 56 | wfIncrStats( 'pcache_miss_stub' ); |
58 | 57 | } |
59 | | - |
| 58 | + |
60 | 59 | $parserOutput = false; |
61 | 60 | if ( $useParserCache ) { |
62 | 61 | $parserOutput = ParserCache::singleton()->get( $this, $wgOut->parserOptions() ); |
63 | 62 | } |
64 | | - |
| 63 | + |
65 | 64 | if ( $parserOutput === false ) { |
66 | 65 | // Cache miss; parse and output it. |
67 | 66 | $rev = Revision::newFromTitle( $this->getTitle(), $oldid ); |
68 | | - |
| 67 | + |
69 | 68 | return $this->getOutputFromWikitext( $rev->getText(), $useParserCache ); |
70 | 69 | } else { |
71 | 70 | return $parserOutput; |
— | — | @@ -72,5 +71,5 @@ |
73 | 72 | } |
74 | 73 | } |
75 | 74 | } else { |
76 | | - class Article_LQT_Compat extends Article {} |
| 75 | + class Article_LQT_Compat extends Article { } |
77 | 76 | } |