Index: trunk/phase3/includes/Skin.php |
— | — | @@ -290,7 +290,36 @@ |
291 | 291 | public function getTitle() { |
292 | 292 | return $this->mTitle; |
293 | 293 | } |
| 294 | + |
| 295 | + function outputUnwrappedText( $out ) { |
| 296 | + global $wgDebugComments; |
| 297 | + wfProfileIn( __METHOD__ ); |
294 | 298 | |
| 299 | + $this->setMembers(); |
| 300 | + $this->initPage( $out ); |
| 301 | + |
| 302 | + $out->out( $out->headElement( $this ) ); |
| 303 | + |
| 304 | + $out->out( "\n<body" ); |
| 305 | + $ops = $this->getBodyOptions(); |
| 306 | + foreach ( $ops as $name => $val ) { |
| 307 | + $out->out( " $name='$val'" ); |
| 308 | + } |
| 309 | + $out->out( ">\n" ); |
| 310 | + if ( $wgDebugComments ) { |
| 311 | + $out->out( "<!-- Wiki debugging output:\n" . |
| 312 | + $out->mDebugtext . "-->\n" ); |
| 313 | + } |
| 314 | + |
| 315 | + $out->out( $out->mBodytext . "\n" ); |
| 316 | + $out->out( $this->bottomScripts() ); |
| 317 | + |
| 318 | + $out->out( wfReportTime() ); |
| 319 | + |
| 320 | + $out->out( "\n</body></html>" ); |
| 321 | + wfProfileOut( __METHOD__ ); |
| 322 | + } |
| 323 | + |
295 | 324 | function outputPage( OutputPage $out ) { |
296 | 325 | global $wgDebugComments; |
297 | 326 | wfProfileIn( __METHOD__ ); |
Index: trunk/phase3/includes/Exception.php |
— | — | @@ -26,7 +26,8 @@ |
27 | 27 | function useMessageCache() { |
28 | 28 | global $wgLang; |
29 | 29 | foreach ( $this->getTrace() as $frame ) { |
30 | | - if ( $frame['class'] == 'LocalisationCache' ) { |
| 30 | + if ( isset( $frame['class'] ) && |
| 31 | + $frame['class'] == 'LocalisationCache' ) { |
31 | 32 | return false; |
32 | 33 | } |
33 | 34 | } |
Index: trunk/extensions/LiquidThreads/LqtFunctions.php |
— | — | @@ -132,3 +132,4 @@ |
133 | 133 | $wgParser->setFunctionHook( 'archivestartdays', |
134 | 134 | array( 'LqtParserFunctions', 'archivestartdays' ) ); |
135 | 135 | } |
| 136 | + |
Index: trunk/extensions/LiquidThreads/pages/TalkpageView.php |
— | — | @@ -226,6 +226,11 @@ |
227 | 227 | $this->output->setPageTitle( $this->title->getPrefixedText() ); |
228 | 228 | self::addJSandCSS(); |
229 | 229 | $article = new Article( $this->title ); |
| 230 | + |
| 231 | + if ( $this->request->getBool( 'lqt_inline' ) ) { |
| 232 | + $this->doInlineEditForm(); |
| 233 | + return false; |
| 234 | + } |
230 | 235 | |
231 | 236 | $this->showHeader(); |
232 | 237 | |
Index: trunk/extensions/LiquidThreads/lqt.js |
— | — | @@ -1,67 +1,93 @@ |
2 | | -// http://onlinetools.org/articles/unobtrusivejavascript/chapter4.html |
3 | | -function lqt_add_event(obj, evType, fn){ |
4 | | - if (obj.addEventListener){ |
5 | | - obj.addEventListener(evType, fn, false); |
6 | | - return true; |
7 | | - } else if (obj.attachEvent){ |
8 | | - var r = obj.attachEvent("on"+evType, fn); |
9 | | - return r; |
10 | | - } else { |
| 2 | +var liquidThreads = { |
| 3 | + 'handleReplyLink' : function(e) { |
| 4 | + var link; |
| 5 | + if (!e) e = window.event; |
| 6 | + if (e.target) link = e.target; |
| 7 | + else if (e.srcElement) link = e.srcElement; |
| 8 | + if (link.nodeType == 3) // defeat Safari bug |
| 9 | + link = link.parentNode; |
| 10 | + link = link.parentNode; // Get the enclosing li. |
| 11 | + |
| 12 | + var prefixLength = "lqt-reply-id-".length; |
| 13 | + var thread_id = link.id.substring( prefixLength ); |
| 14 | + var container = document.getElementById( 'lqt_thread_id_'+thread_id ); |
| 15 | + var footer_cmds = getElementsByClassName( container, '*', 'lqt_post' )[0]; |
| 16 | + var query = '&lqt_method=reply&lqt_operand='+thread_id; |
| 17 | + |
| 18 | + liquidThreads.injectEditForm( query, container, footer_cmds.nextSibling ); |
| 19 | + |
| 20 | + e.preventDefault(); |
| 21 | + |
11 | 22 | return false; |
| 23 | + }, |
| 24 | + |
| 25 | + 'handleNewLink' : function(e) { |
| 26 | + var link; |
| 27 | + if (!e) e = window.event; |
| 28 | + if (e.target) link = e.target; |
| 29 | + else if (e.srcElement) link = e.srcElement; |
| 30 | + if (link.nodeType == 3) // defeat Safari bug |
| 31 | + link = link.parentNode; |
| 32 | + |
| 33 | + var query = '&lqt_method=talkpage_new_thread'; |
| 34 | + var container = document.getElementById( 'bodyContent' ); |
| 35 | + |
| 36 | + liquidThreads.injectEditForm( query, container, link.parentNode.nextSibling ); |
| 37 | + |
| 38 | + e.preventDefault(); |
| 39 | + return false; |
| 40 | + }, |
| 41 | + |
| 42 | + 'injectEditForm' : function(query, container, before) { |
| 43 | + var x = sajax_init_object(); |
| 44 | + var url = wgServer+wgScript+'?title='+encodeURIComponent(wgPageName)+ |
| 45 | + query+'&lqt_inline=1' |
| 46 | + x.open( 'get', url, true ); |
| 47 | + |
| 48 | + x.onreadystatechange = |
| 49 | + function() { |
| 50 | + if (x.readyState != 4) |
| 51 | + return; |
| 52 | + |
| 53 | + var result = x.responseText; |
| 54 | + var replyDiv = document.createElement( 'div' ); |
| 55 | + replyDiv.className = 'lqt_ajax_reply_form' |
| 56 | + replyDiv.innerHTML = result; |
| 57 | + |
| 58 | + if (before) { |
| 59 | + container.insertBefore( replyDiv, before ); |
| 60 | + } else { |
| 61 | + container.appendChild( replyDiv ); |
| 62 | + } |
| 63 | + }; |
| 64 | + |
| 65 | + x.send( null ); |
12 | 66 | } |
13 | 67 | } |
14 | 68 | |
15 | | -var LqtDateRangeRectifier = function( startsel, endsel ) { |
16 | | - this.startsel = startsel; |
17 | | - this.endsel = endsel; |
18 | | - |
19 | | - this.oldstart = this.startsel.selectedIndex; |
20 | | - this.oldend = this.endsel.selectedIndex; |
21 | | - |
22 | | - this.handle_start_changed = function(e) { |
23 | | - newi = this.startsel.selectedIndex; |
24 | | - oldi = this.oldstart; |
25 | | - endi = this.endsel.selectedIndex; |
26 | | - goal = newi - (oldi - endi); // seem backwards? it's because |
27 | | - this.endsel.selectedIndex = Math.max(goal, 0); |
28 | | - this.oldend = endi; // later months have smaller |
29 | | - this.oldstart = newi; // indexes. |
30 | | - } |
31 | | - |
32 | | - this.handle_end_changed = function(e){ |
33 | | - this.startsel.selectedIndex = Math.max(this.endsel.selectedIndex, |
34 | | - this.startsel.selectedIndex) |
35 | | - this.oldend = this.endsel.selectedIndex; |
36 | | - this.oldstart = this.startsel.selectedIndex; |
37 | | - } |
38 | | - |
39 | | - // In order for this instance to recieve the events, we need to capture the |
40 | | - // current value of 'this' with a closure, because this = the target object |
41 | | - // in event handlers. |
42 | | - var me = this; |
43 | | - lqt_add_event( this.startsel, 'change', function(e) { me.handle_start_changed(e) }); |
44 | | - lqt_add_event( this.endsel, 'change', function(e) { me.handle_end_changed(e) }); |
45 | | -} |
46 | | - |
47 | | -function lqt_on_load() { |
48 | | - if(!document.getElementById) return; |
49 | | - |
50 | | - var searchform = document.getElementById("lqt_archive_search_form"); |
51 | | - if ( searchform ) { |
52 | | - var start = document.getElementById("lqt_archive_start"); |
53 | | - var end = document.getElementById("lqt_archive_end"); |
54 | | - |
55 | | - new LqtDateRangeRectifier( start, end ); |
56 | | - |
57 | | - var filter = document.getElementById("lqt_archive_filter_by_date_yes"); |
58 | | - function set_date_filter_radio(e) { filter.checked = true; } |
59 | | - lqt_add_event(start, 'change', set_date_filter_radio); |
60 | | - lqt_add_event(end, 'change', set_date_filter_radio); |
61 | | - if ( !filter.checked ) { |
62 | | - start.selectedIndex = end.selectedIndex = 0; |
| 69 | +addOnloadHook( function() { |
| 70 | + // Find all the reply links |
| 71 | + var threadContainers = getElementsByClassName( document, 'div', 'lqt_thread' ); |
| 72 | + var prefixLength = "lqt_thread_id_".length; |
| 73 | + |
| 74 | + for( var i = 0; i < threadContainers.length; ++i ) { |
| 75 | + var container = threadContainers[i]; |
| 76 | + var replyLI = getElementsByClassName( container, '*', 'lqt-command-reply' )[0]; |
| 77 | + var threadId = container.id.substring( prefixLength ); |
| 78 | + |
| 79 | + if (!replyLI) { |
| 80 | + continue; |
63 | 81 | } |
64 | | - |
| 82 | + |
| 83 | + replyLI.id = "lqt-reply-id-"+threadId; |
| 84 | + var replyLink = replyLI.firstChild; |
| 85 | + |
| 86 | + addHandler( replyLink, 'click', liquidThreads.handleReplyLink ); |
65 | 87 | } |
66 | | -} |
| 88 | + |
| 89 | + // Update the new thread link |
| 90 | + var newThreadLink = getElementsByClassName( document, 'a', 'lqt_start_discussion' )[0]; |
| 91 | + |
| 92 | + addHandler( newThreadLink, 'click', liquidThreads.handleNewLink ); |
| 93 | +} ); |
67 | 94 | |
68 | | -addOnloadHook(lqt_on_load); |
Index: trunk/extensions/LiquidThreads/classes/LqtView.php |
— | — | @@ -249,6 +249,21 @@ |
250 | 250 | $this->output->addWikiMsg( 'lqt-summarize-intro' ); |
251 | 251 | $this->showEditingFormInGeneral( null, 'summarize', $thread ); |
252 | 252 | } |
| 253 | + |
| 254 | + function doInlineEditForm() { |
| 255 | + $method = $this->request->getVal( 'lqt_method' ); |
| 256 | + $operand = $this->request->getVal( 'lqt_operand' ); |
| 257 | + |
| 258 | + $thread = Threads::withId( $operand ); |
| 259 | + |
| 260 | + if ($method == 'reply') { |
| 261 | + $this->showReplyForm( $thread ); |
| 262 | + } elseif ($method == 'talkpage_new_thread') { |
| 263 | + $this->showNewThreadForm(); |
| 264 | + } |
| 265 | + |
| 266 | + $this->output->setArticleBodyOnly( true ); |
| 267 | + } |
253 | 268 | |
254 | 269 | private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) { |
255 | 270 | /* |
— | — | @@ -379,7 +394,7 @@ |
380 | 395 | $this->output->setArticleFlag( false ); |
381 | 396 | |
382 | 397 | if ( $e->didSave ) { |
383 | | - self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article, |
| 398 | + $thread = self::postEditUpdates( $edit_type, $edit_applies_to, $article, $this->article, |
384 | 399 | $subject, $e->summary, $thread ); |
385 | 400 | } |
386 | 401 | |
— | — | @@ -387,7 +402,7 @@ |
388 | 403 | // This results in a new Thread object not being created for replies and new discussions, |
389 | 404 | // so $thread is null. In that case, just allow editpage to redirect back to the talk page. |
390 | 405 | if ( $this->output->getRedirect() != '' && $thread ) { |
391 | | - $redirectTitle = clone $this->title; |
| 406 | + $redirectTitle = clone $thread->article()->getTitle(); |
392 | 407 | $redirectTitle->setFragment( '#'.$this->anchorName( $thread ) ); |
393 | 408 | $this->output->redirect( $this->title->getFullURL() ); |
394 | 409 | } else if ( $this->output->getRedirect() != '' && $edit_applies_to ) { |