Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -216,7 +216,6 @@ |
217 | 217 | protected $superthread; |
218 | 218 | |
219 | 219 | /* Simple strings: */ |
220 | | - protected $subject; |
221 | 220 | protected $timestamp; |
222 | 221 | protected $path; |
223 | 222 | |
— | — | @@ -603,17 +602,35 @@ |
604 | 603 | function title() { |
605 | 604 | return $this->root()->getTitle(); |
606 | 605 | } |
| 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 | + } |
607 | 614 | |
608 | 615 | function wikilink() { |
609 | 616 | return $this->root()->getTitle()->getPrefixedText(); |
610 | 617 | } |
611 | 618 | |
| 619 | + function subject() { |
| 620 | + return $this->root()->getTitle()->getText(); |
| 621 | + } |
| 622 | + |
612 | 623 | function wikilinkWithoutIncrement() { |
613 | | - $foo = explode( ' ', $this->wikilink() ); |
614 | | - array_pop($foo); |
615 | | - return implode( ' ', $foo ); |
| 624 | + $tmp = $this->splitIncrementFromSubject($this->wikilink()); return $tmp[1]; |
616 | 625 | } |
| 626 | + |
| 627 | + function subjectWithoutIncrement() { |
| 628 | + $tmp = $this->splitIncrementFromSubject($this->subject()); return $tmp[1]; |
| 629 | + } |
617 | 630 | |
| 631 | + function increment() { |
| 632 | + $tmp = $this->splitIncrementFromSubject($this->subject()); return $tmp[2]; |
| 633 | + } |
| 634 | + |
618 | 635 | function hasDistinctSubject() { |
619 | 636 | if( $this->hasSuperthread() ) { |
620 | 637 | return $this->superthread()->subjectWithoutIncrement() |
— | — | @@ -622,22 +639,7 @@ |
623 | 640 | return true; |
624 | 641 | } |
625 | 642 | } |
626 | | - |
627 | | - function subject() { |
628 | | - return $this->root()->getTitle()->getText(); |
629 | | - return $this->subject; |
630 | | - } |
631 | 643 | |
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 | | - |
642 | 644 | function hasSubthreads() { |
643 | 645 | return count($replies) != 0; |
644 | 646 | } |
Index: branches/liquidthreads/extensions/LqtBaseView.php |
— | — | @@ -371,7 +371,7 @@ |
372 | 372 | /** Keep trying titles starting with $basename until one is unoccupied. */ |
373 | 373 | function incrementedTitle($basename, $namespace) { |
374 | 374 | $i = 1; do { |
375 | | - $t = Title::newFromText( $basename.'_'.$i, $namespace ); |
| 375 | + $t = Title::newFromText( $basename.'_('.$i.')', $namespace ); |
376 | 376 | $i++; |
377 | 377 | } while ( $t->exists() || in_array($t->getPrefixedDBkey(), self::$occupied_titles) ); |
378 | 378 | return $t; |
— | — | @@ -534,8 +534,8 @@ |
535 | 535 | function showThreadHeading( $thread ) { |
536 | 536 | if ( $thread->hasDistinctSubject() ) { |
537 | 537 | $html = $thread->subjectWithoutIncrement() . |
538 | | - ' <span class="lqt_subject_increment">' . |
539 | | - $thread->increment() . '</span>'; |
| 538 | + ' <span class="lqt_subject_increment">(' . |
| 539 | + $thread->increment() . ')</span>'; |
540 | 540 | $this->output->addHTML( wfOpenElement( "h{$this->headerLevel}", array('class'=>'lqt_header') ) . |
541 | 541 | $html . wfCloseElement("h{$this->headerLevel}") ); |
542 | 542 | } |