r25803 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25802‎ | r25803 | r25804 >
Date:02:20, 12 September 2007
Author:david
Status:old
Tags:
Comment:
Completely incomplete new-user-messages, including specialwatchlist hook and one instance of mTitle in EditPage that had previously been missed.
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtPages.php (modified) (history)
  • /branches/liquidthreads/includes/EditPage.php (modified) (history)
  • /branches/liquidthreads/includes/SpecialWatchlist.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtPages.php
@@ -15,6 +15,11 @@
1616 require_once('LqtBaseView.php');
1717 require_once('LqtI18N.php');
1818
 19+$wgExtensionFunctions[] = 'wfLqtSpecialDeleteThread';
 20+$wgExtensionFunctions[] = 'wfLqtSpecialMoveThreadToAnotherPage';
 21+$wgExtensionFunctions[] = 'wfLqtSpecialNewMessages';
 22+$wgHooks['BeforeWatchlist'][] = 'wfLqtBeforeWatchlistHook';
 23+
1924 class TalkpageView extends LqtView {
2025 /* Added to SkinTemplateTabs hook in TalkpageView::show(). */
2126 function customizeTabs( $skintemplate, $content_actions ) {
@@ -630,12 +635,6 @@
631636 }
632637
633638
634 -/* We have to do this goofy wgExtensionFunctions run-around because
635 - the files required by SpecialPage aren't required_onced() yet by
636 - the time this file is. Don't ask me why. */
637 -
638 -$wgExtensionFunctions[] = 'wfLqtSpecialMoveThreadToAnotherPage';
639 -
640639 function wfLqtSpecialMoveThreadToAnotherPage() {
641640 global $wgMessageCache;
642641
@@ -767,9 +766,6 @@
768767 }
769768
770769
771 -
772 -$wgExtensionFunctions[] = 'wfLqtSpecialDeleteThread';
773 -
774770 function wfLqtSpecialDeleteThread() {
775771 global $wgMessageCache;
776772
@@ -900,4 +896,78 @@
901897 }
902898
903899
 900+
 901+class NewUserMessagesView extends LqtView {
 902+
 903+ function addJSandCSS() {
 904+ global $wgJsMimeType, $wgStylePath; // TODO globals.
 905+ $s = "<script type=\"{$wgJsMimeType}\" src=\"{$wgStylePath}/common/lqt.js\"><!-- lqt js --></script>\n";
 906+ $this->output->addScript($s);
 907+ }
 908+
 909+ function postDivClass($thread) {
 910+
 911+ }
 912+
 913+ function show() {
 914+ $this->addJSandCSS();
 915+
 916+ $threads = NewMessages::newUserMessages($this->user);
 917+ foreach($threads as $t) {
 918+ $this->showThread($t);
 919+ }
 920+ return false;
 921+ }
 922+}
 923+
 924+function wfLqtSpecialNewMessages() {
 925+ global $wgMessageCache;
 926+
 927+ require_once('SpecialPage.php');
 928+
 929+ $wgMessageCache->addMessage( 'newmessages', 'New Messages' );
 930+
 931+ class SpecialNewMessages extends SpecialPage {
 932+
 933+ function __construct() {
 934+ SpecialPage::SpecialPage( 'Newmessages' );
 935+ SpecialPage::$mStripSubpages = false;
 936+ $this->includable( true );
 937+ }
 938+
 939+
 940+ function execute( $par = null ) {
 941+ global $wgOut, $wgRequest, $wgUser;
 942+
 943+ $this->setHeaders();
 944+
 945+ $title = $this->getTitle();
 946+ $view = new NewUserMessagesView( $wgOut, new Article($title), $title, $wgUser, $wgRequest );
 947+ return $view->show();
 948+
 949+ // and then the same for the other talkpage messagess.
 950+ }
 951+ }
 952+
 953+ SpecialPage::addPage( new SpecialNewMessages() );
 954+}
 955+
 956+
 957+function wfLqtBeforeWatchlistHook( $options, $user ) {
 958+ global $wgOut;
 959+
 960+ $user_messages = NewMessages::newUserMessages($user);
 961+ $n = count($user_messages);
 962+
 963+ $wgOut->addHTML(<<< HTML
 964+ <div class="lqt_watchlist_messages_notice">
 965+ There are $n messages for you.
 966+ </div>
 967+HTML
 968+ );
 969+
 970+ return true;
 971+}
 972+
 973+
904974 ?>
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -986,4 +986,30 @@
987987 }
988988 }
989989
 990+
 991+class NewMessages {
 992+
 993+ static function newUserMessages($user) {
 994+/* $article_clause = Threads::articleClause(new Article($user->getUserPage()))
 995+ $sql = <<< SQL
 996+ select * from thread, page, recentchanges
 997+ where thread_root = rc_cur_id
 998+ and $article_clause
 999+SQL;
 1000+ $dbr = wfGetDB( DB_SLAVE );
 1001+ res = $dbr->query($sql);
 1002+ while ( $line = $dbr->fetchObject($res) ) {
 1003+
 1004+ }*/
 1005+
 1006+ $ts = Threads::where( array('thread.thread_root = rc_cur_id',
 1007+ Threads::articleClause(new Article($user->getUserPage()))),
 1008+ array(), array('recentchanges') );
 1009+ return $ts;
 1010+ }
 1011+
 1012+
 1013+
 1014+}
 1015+
9901016 ?>
Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -21,7 +21,7 @@
2222 var_dump($value);
2323 $tmp=ob_get_contents();
2424 ob_end_clean();
25 - $output->addHTML('<pre>' . htmlspecialchars($tmp,ENT_QUOTES) . '</pre>');
 25+ $output->addHTML(/*'<pre>' . htmlspecialchars($tmp,ENT_QUOTES) . '</pre>'*/ $tmp);
2626 }
2727
2828
Index: branches/liquidthreads/includes/EditPage.php
@@ -325,8 +325,8 @@
326326 }
327327
328328 $permErrors = $this->mArticle->getTitle()->getUserPermissionsErrors( 'edit', $wgUser);
329 - if( !$this->mTitle->exists() )
330 - $permErrors += $this->mTitle->getUserPermissionsErrors( 'create', $wgUser);
 329+ if( !$this->mArticle->getTitle()->exists() )
 330+ $permErrors += $this->mArticle->getTitle()->getUserPermissionsErrors( 'create', $wgUser);
331331
332332 # Ignore some permissions errors.
333333 $remove = array();
Index: branches/liquidthreads/includes/SpecialWatchlist.php
@@ -122,6 +122,10 @@
123123 wfAppendToArrayIfNotDefault( 'hideMinor', (int)$hideMinor, $defaults, $nondefaults );
124124 wfAppendToArrayIfNotDefault('namespace', $nameSpace , $defaults, $nondefaults);
125125
 126+ if( ! wfRunHooks('BeforeWatchlist', array($nondefaults, $wgUser)) ) {
 127+ return;
 128+ }
 129+
126130 if ( $days <= 0 ) {
127131 $andcutoff = '';
128132 } else {

Status & tagging log