r24292 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24291‎ | r24292 | r24293 >
Date:00:10, 21 July 2007
Author:david
Status:old
Tags:
Comment:
Talkpage headers are now feature-complete.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)
  • /branches/liquidthreads/includes/Defines.php (modified) (history)
  • /branches/liquidthreads/includes/Namespace.php (modified) (history)
  • /branches/liquidthreads/includes/Title.php (modified) (history)
  • /branches/liquidthreads/languages/messages/MessagesEn.php (modified) (history)
  • /branches/liquidthreads/maintenance/lqt.sql (modified) (history)

Diff [purge]

Index: branches/liquidthreads/maintenance/lqt.sql
@@ -26,18 +26,11 @@
2727 hthread_id int(8) unsigned NOT NULL,
2828 hthread_revision int(8) unsigned NOT NULL,
2929 hthread_contents BLOB NOT NULL,
 30+ hthread_affected_id int(8) unsigned NOT NULL,
 31+ hthread_action int(1) unsigned NOT NULL,
3032 PRIMARY KEY hthread_id_revision (hthread_id, hthread_revision)
3133 ) TYPE=InnoDB;
3234
33 -CREATE TABLE /*$wgDBprefix*/hthread_contents (
34 - htcontents_child int(8) unsigned NOT NULL,
35 - htcontents_hthread int(8) unsigned NOT NULL,
36 - htcontents_rev_start int(8) unsigned NOT NULL,
37 - htcontents_rev_end int(8) unsigned NULL
38 -) TYPE=InnoDB;
39 -
4035 /*
4136 old_superthread and old_article are mutually exclusive.
4237 New position is recorded either in the text movement or in the
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -64,10 +64,45 @@
6565 }
6666 return true;
6767 }
 68+
 69+ static function onPageMove( $movepage, $ot, $nt ) {
 70+ /* If the user moved a subject page, we are responsible for moving the articles
 71+ associated with the talkpage directly; we will not be invoked a second time when
 72+ MW attempts to move the talk page, because it doesn't actually exist. */
 73+ if( $movepage->moveTalk && !$ot->isTalkPage() && !$nt->isTalkPage() ) {
 74+ $ntt = $nt->getTalkPage();
 75+ $ott = $ot->getTalkPage();
 76+ return self::onPageMove($movepage, $ott, $ntt);
 77+ }
 78+
 79+ if( $ot->getNamespace() == NS_LQT_HEADER ||
 80+ $nt->getNamespace() == NS_LQT_HEADER ) return true;
 81+
 82+ # TODO look up namespace name
 83+ $oht = Title::newFromText( 'Header:' . $ot->getPrefixedText() );
 84+
 85+
 86+ if( $oht->exists() ) {
 87+ $nht = Title::newFromText( 'Header:' . $nt->getPrefixedText() );
 88+
 89+ $error = $oht->moveTo( $nht, true, $movepage->reason );
 90+ if ( $error === true ) {
 91+ wfRunHooks( 'SpecialMovepageAfterMove', array( &$movepage, &$oht, &$nht ) ) ;
 92+ } else {
 93+ $talkmoved = $error;
 94+ }
 95+ } else {
 96+ $talkmoved = 'notalkpage';
 97+ }
 98+ # TODO we have no apparent way to report any error or success that goes on here.
 99+
 100+ return true;
 101+ }
68102 }
69103
70104
71105 $wgHooks['MediaWikiPerformAction'][] = array('LqtDispatch::tryPage');
 106+$wgHooks['SpecialMovepageAfterMove'][] = array('LqtDispatch::onPageMove');
72107
73108
74109 class LqtView {
@@ -172,6 +207,11 @@
173208 return $title->getFullURL( $query );
174209 }
175210
 211+ function headerTitle() {
 212+ # TODO
 213+ return Title::newFromText( 'Header:' . $this->title->getPrefixedText() );
 214+ }
 215+
176216 /*************************************************************
177217 * Editing methods (here be dragons) *
178218 * Forget dragons: This section distorts the rest of the code *
@@ -594,6 +634,10 @@
595635 $action = $this->request->getVal('lqt_header_action');
596636
597637 $article = new Article( $this->title );
 638+
 639+ $headert = $this->headerTitle();
 640+ $headera = new Article($headert);
 641+
598642 if( $action == 'edit' || $action=='submit' ) {
599643 // TODO this is scary and horrible.
600644 $e = new EditPage($article);
@@ -605,18 +649,18 @@
606650 $this->output->addHTML("Disclaimer: history doesn't really work yet.");
607651 $history = new PageHistory( $article );
608652 $history->history();
609 - } else if ( $article->exists() ) {
610 - $edit = $this->title->getFullURL( 'lqt_header_action=edit' );
611 - $history = $this->title->getFullURL( 'lqt_header_action=history' );
 653+ } else if ( $headera->exists() ) {
 654+ $edit = $headert->getFullURL( 'action=edit' );
 655+ $history = $headert->getFullURL( 'action=history' );
612656 $this->openDiv('lqt_header_content');
613 - $this->showPostBody($article);
 657+ $this->showPostBody($headera);
614658 $this->outputList('ul', 'lqt_header_commands', null, array(
615659 "[<a href=\"$edit\">edit</a>]",
616660 "[<a href=\"$history\">history</a>]"
617661 ));
618662 $this->closeDiv();
619663 } else {
620 - $this->output->addHTML("<p class=\"lqt_header_notice\">[<a href=\"{$this->title->getFullURL('lqt_header_action=edit')}\">add header</a>]</p>");
 664+ $this->output->addHTML("<p class=\"lqt_header_notice\">[<a href=\"{$headert->getFullURL('action=edit')}\">add header</a>]</p>");
621665 }
622666 }
623667
Index: branches/liquidthreads/extensions/LqtModel.php
@@ -216,6 +216,8 @@
217217 }
218218
219219 function commitRevision() {
 220+ global $wgUser; // TODO global.
 221+
220222 // TODO open a transaction.
221223 HistoricalThread::create( $this->double );
222224
@@ -233,6 +235,10 @@
234236 'thread_article_title' => $this->articleTitle),
235237 /* WHERE */ array( 'thread_id' => $this->id, ),
236238 __METHOD__);
 239+
 240+ /* RecentChange::notifyEdit( wfTimestampNow(), $this->root(), /*minor*/false, $wgUser, $summary,
 241+ $lastRevision, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
 242+ $revisionId );*/
237243 }
238244
239245 function __construct($line, $children) {
Index: branches/liquidthreads/includes/Defines.php
@@ -65,6 +65,8 @@
6666 define('NS_LQT_THREAD_TALK', 17);
6767 define('NS_LQT_SUMMARY', 18);
6868 define('NS_LQT_SUMMARY_TALK', 19);
 69+define('NS_LQT_HEADER', 20);
 70+define('NS_LQT_HEADER_TALK', 21);
6971 /**#@-*/
7072
7173 /**
Index: branches/liquidthreads/includes/Title.php
@@ -2466,11 +2466,11 @@
24672467 }
24682468
24692469 /**
2470 - * Check if page exists
 2470+ * Check if page exists LQT HACK
24712471 * @return bool
24722472 */
24732473 public function exists() {
2474 - return $this->getArticleId() != 0;
 2474+ return $this->getArticleId() != 0 || $this->isTalkPage();
24752475 }
24762476
24772477 /**
Index: branches/liquidthreads/includes/Namespace.php
@@ -28,7 +28,9 @@
2929 NS_LQT_THREAD => 'Thread',
3030 NS_LQT_THREAD_TALK => 'Thread_talk',
3131 NS_LQT_SUMMARY => 'Summary',
32 - NS_LQT_SUMMARY_TALK => 'Summary_talk'
 32+ NS_LQT_SUMMARY_TALK => 'Summary_talk',
 33+ NS_LQT_HEADER => 'Header',
 34+ NS_LQT_HEADER_TALK => 'Header_talk'
3335 );
3436
3537 if( is_array( $wgExtraNamespaces ) ) {
Index: branches/liquidthreads/languages/messages/MessagesEn.php
@@ -106,7 +106,9 @@
107107 NS_LQT_THREAD => 'Thread',
108108 NS_LQT_THREAD_TALK => 'Thread_talk',
109109 NS_LQT_SUMMARY => 'Summary',
110 - NS_LQT_SUMMARY_TALK => 'Summary_talk'
 110+ NS_LQT_SUMMARY_TALK => 'Summary_talk',
 111+ NS_LQT_HEADER => 'Header',
 112+ NS_LQT_HEADER_TALK => 'Header_talk'
111113 );
112114
113115 /**

Status & tagging log