r63994 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63993‎ | r63994 | r63995 >
Date:07:36, 21 March 2010
Author:werdna
Status:deferred
Tags:
Comment:
Add several hooks
Modified paths:
  • /trunk/extensions/LiquidThreads/classes/View.php (modified) (history)

Diff [purge]

Index: trunk/extensions/LiquidThreads/classes/View.php
@@ -346,6 +346,8 @@
347347 LqtHooks::$editType = 'new';
348348 LqtHooks::$editAppliesTo = null;
349349
 350+ wfRunHooks( 'LiquidThreadsShowNewThreadForm', array( &$e, $talkpage ) );
 351+
350352 $e = new EditPage( $article );
351353
352354 global $wgRequest;
@@ -392,7 +394,7 @@
393395 if ( $e->didSave ) {
394396 $signature = $this->request->getVal( 'wpLqtSignature', null );
395397
396 - $thread = LqtView::newPostMetadataUpdates(
 398+ $info =
397399 array(
398400 'talkpage' => $talkpage,
399401 'text' => $e->textbox1,
@@ -400,9 +402,13 @@
401403 'signature' => $signature,
402404 'root' => $article,
403405 'subject' => $subject,
404 - )
405 - );
 406+ );
406407
 408+ wfRunHooks( 'LiquidThreadsSaveNewThread',
 409+ array( &$info, &$e, &$talkpage ) );
 410+
 411+ $thread = LqtView::newPostMetadataUpdates( $info );
 412+
407413 if ( $submitted_nonce && $nonce_key ) {
408414 global $wgMemc;
409415 $wgMemc->set( $nonce_key, 1, 3600 );
@@ -485,6 +491,8 @@
486492 Xml::tags( 'p', null, $signatureHTML );
487493
488494 $wgRequest->setVal( 'wpWatchThis', false );
 495+
 496+ wfRunHooks( 'LiquidThreadsShowReplyForm', array( &$e, $thread ) );
489497
490498 $e->edit();
491499
@@ -492,17 +500,20 @@
493501 $bump = $this->request->getBool( 'wpBumpThread' );
494502 $signature = $this->request->getVal( 'wpLqtSignature', null );
495503
496 - $newThread = LqtView::replyMetadataUpdates(
497 - array(
 504+ $info = array(
498505 'replyTo' => $thread,
499506 'text' => $e->textbox1,
500507 'summary' => $e->summary,
501508 'bump' => $bump,
502509 'signature' => $signature,
503510 'root' => $article,
504 - )
505 - );
 511+ );
506512
 513+ wfRunHooks( 'LiquidThreadsSaveReply',
 514+ array( &$info, &$e, &$thread ) );
 515+
 516+ $newThread = LqtView::replyMetadataUpdates( $info );
 517+
507518 if ( $submitted_nonce && $nonce_key ) {
508519 global $wgMemc;
509520 $wgMemc->set( $nonce_key, 1, 3600 );
@@ -1002,6 +1013,8 @@
10031014 'showlabel' => true,
10041015 'tooltip' => wfMsgExt( 'lqt_permalink', 'parseinline' )
10051016 );
 1017+
 1018+ wfRunHooks( 'LiquidThreadsThreadCommands', array( $thread, &$commands ) );
10061019
10071020 return $commands;
10081021 }
@@ -1065,6 +1078,9 @@
10661079 'showlabel' => 1,
10671080 );
10681081 }
 1082+
 1083+ wfRunHooks( 'LiquidThreadsThreadMajorCommands',
 1084+ array( $thread, &$commands ) );
10691085
10701086 return $commands;
10711087 }
@@ -1126,6 +1142,8 @@
11271143 'href' => $summarizeUrl,
11281144 'enabled' => true,
11291145 );
 1146+
 1147+ wfRunHooks( 'LiquidThreadsTopLevelCommands', array( $thread, &$commands ) );
11301148
11311149 return $commands;
11321150 }
@@ -1358,7 +1376,9 @@
13591377 }
13601378
13611379 // If we're editing the thread, show the editing form.
1362 - if ( $this->methodAppliesToThread( 'edit', $thread ) ) {
 1380+ $showAnything = wfRunHooks( 'LiquidThreadsShowThreadBody',
 1381+ array( $thread ) );
 1382+ if ( $this->methodAppliesToThread( 'edit', $thread ) && $showAnything ) {
13631383 $html = Xml::openElement( 'div', array( 'class' => $divClass ) );
13641384 $this->output->addHTML( $html );
13651385 $html = '';
@@ -1367,10 +1387,11 @@
13681388 // so I'm just flushing the HTML and displaying it as-is.
13691389 $this->showPostEditingForm( $thread );
13701390 $html .= Xml::closeElement( 'div' );
1371 - } else {
 1391+ } elseif ($showAnything) {
13721392 $html .= Xml::openElement( 'div', array( 'class' => $divClass ) );
13731393
1374 - $show = wfRunHooks( 'LiquidThreadsShowThreadBody', array( $thread, &$post ) );
 1394+ $show = wfRunHooks( 'LiquidThreadsShowPostContent',
 1395+ array( $thread, &$post ) );
13751396 if ($show) {
13761397 $html .= $this->showPostBody( $post, $oldid );
13771398 }
@@ -1481,11 +1502,17 @@
14821503 $id = 'lqt-header-' . $thread->id();
14831504
14841505 $html = $thread->formattedSubject();
1485 - $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html );
1486 - $html .= Xml::hidden( 'raw-header', $thread->subject() );
1487 - $html = Xml::tags( 'h' . $this->headerLevel,
1488 - array( 'class' => 'lqt_header', 'id' => $id ),
1489 - $html ) . $commands_html;
 1506+
 1507+ $show = wfRunHooks( 'LiquidThreadsShowThreadHeading',
 1508+ array( $thread, &$html ) );
 1509+
 1510+ if ($show) {
 1511+ $html = Xml::tags( 'span', array( 'class' => 'mw-headline' ), $html );
 1512+ $html .= Xml::hidden( 'raw-header', $thread->subject() );
 1513+ $html = Xml::tags( 'h' . $this->headerLevel,
 1514+ array( 'class' => 'lqt_header', 'id' => $id ),
 1515+ $html ) . $commands_html;
 1516+ }
14901517
14911518 return $html;
14921519 }

Status & tagging log