r25334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25333‎ | r25334 | r25335 >
Date:02:30, 31 August 2007
Author:david
Status:old
Tags:
Comment:
subject increments in parens. urls horrible.
Modified paths:
  • /branches/liquidthreads/extensions/LqtBaseView.php (modified) (history)
  • /branches/liquidthreads/extensions/LqtModel.php (modified) (history)

Diff [purge]

Index: branches/liquidthreads/extensions/LqtModel.php
@@ -216,7 +216,6 @@
217217 protected $superthread;
218218
219219 /* Simple strings: */
220 - protected $subject;
221220 protected $timestamp;
222221 protected $path;
223222
@@ -603,17 +602,35 @@
604603 function title() {
605604 return $this->root()->getTitle();
606605 }
 606+
 607+ private function splitIncrementFromSubject($subject_string) {
 608+ preg_match('/^(.*) \((\d+)\)$/', $subject_string, $matches);
 609+ if( count($matches) != 3 )
 610+ throw new MWException( __METHOD__ . ": thread subject has no increment: " . $this->subject() );
 611+ else
 612+ return $matches;
 613+ }
607614
608615 function wikilink() {
609616 return $this->root()->getTitle()->getPrefixedText();
610617 }
611618
 619+ function subject() {
 620+ return $this->root()->getTitle()->getText();
 621+ }
 622+
612623 function wikilinkWithoutIncrement() {
613 - $foo = explode( ' ', $this->wikilink() );
614 - array_pop($foo);
615 - return implode( ' ', $foo );
 624+ $tmp = $this->splitIncrementFromSubject($this->wikilink()); return $tmp[1];
616625 }
 626+
 627+ function subjectWithoutIncrement() {
 628+ $tmp = $this->splitIncrementFromSubject($this->subject()); return $tmp[1];
 629+ }
617630
 631+ function increment() {
 632+ $tmp = $this->splitIncrementFromSubject($this->subject()); return $tmp[2];
 633+ }
 634+
618635 function hasDistinctSubject() {
619636 if( $this->hasSuperthread() ) {
620637 return $this->superthread()->subjectWithoutIncrement()
@@ -622,22 +639,7 @@
623640 return true;
624641 }
625642 }
626 -
627 - function subject() {
628 - return $this->root()->getTitle()->getText();
629 - return $this->subject;
630 - }
631643
632 - function subjectWithoutIncrement() {
633 - $foo = explode( ' ', $this->subject() );
634 - array_pop($foo);
635 - return implode( ' ', $foo );
636 - }
637 -
638 - function increment() {
639 - return array_pop( explode(' ', $this->subject()) );
640 - }
641 -
642644 function hasSubthreads() {
643645 return count($replies) != 0;
644646 }
Index: branches/liquidthreads/extensions/LqtBaseView.php
@@ -371,7 +371,7 @@
372372 /** Keep trying titles starting with $basename until one is unoccupied. */
373373 function incrementedTitle($basename, $namespace) {
374374 $i = 1; do {
375 - $t = Title::newFromText( $basename.'_'.$i, $namespace );
 375+ $t = Title::newFromText( $basename.'_('.$i.')', $namespace );
376376 $i++;
377377 } while ( $t->exists() || in_array($t->getPrefixedDBkey(), self::$occupied_titles) );
378378 return $t;
@@ -534,8 +534,8 @@
535535 function showThreadHeading( $thread ) {
536536 if ( $thread->hasDistinctSubject() ) {
537537 $html = $thread->subjectWithoutIncrement() .
538 - ' <span class="lqt_subject_increment">' .
539 - $thread->increment() . '</span>';
 538+ ' <span class="lqt_subject_increment">(' .
 539+ $thread->increment() . ')</span>';
540540 $this->output->addHTML( wfOpenElement( "h{$this->headerLevel}", array('class'=>'lqt_header') ) .
541541 $html . wfCloseElement("h{$this->headerLevel}") );
542542 }

Status & tagging log