Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -207,7 +207,7 @@ |
208 | 208 | $this->perpetuate('lqt_method', 'hidden') . |
209 | 209 | $this->perpetuate('lqt_operand', 'hidden'); |
210 | 210 | |
211 | | - if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) { |
| 211 | + if ( /*$thread == null*/ $edit_type=='new' || ($thread && !$thread->hasSuperthread()) ) { |
212 | 212 | // This is a top-level post; show the subject line. |
213 | 213 | $sbjtxt = $thread ? $thread->subjectWithoutIncrement() : ''; |
214 | 214 | $subject = $this->request->getVal('lqt_subject_field', $sbjtxt); |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | /* $subject = $this->request->getVal('lqt_subject_field', ''); |
257 | 257 | if ( $e->didSave && $subject != '' ) { |
258 | 258 | $thread->setSubject( Sanitizer::stripAllTags($subject) ); |
259 | | - } else if ( $e->didSave && $edit_type !='summarize' && $subject == '' && !$thread->superthread() ) { |
| 259 | + } else if ( $e->didSave && $edit_type !='summarize' && $subject == '' && !$thread->hasSuperthread() ) { |
260 | 260 | $thread->setSubject( '«no subject»' ); |
261 | 261 | } */ |
262 | 262 | } |
— | — | @@ -433,7 +433,7 @@ |
434 | 434 | if( $thread->summary() ) { |
435 | 435 | $this->showSummary($thread); |
436 | 436 | } else if ( $timestamp->isBefore(Date::now()->nDaysAgo($this->archive_start_days)) |
437 | | - && !$thread->summary() && !$thread->superthread() ) { |
| 437 | + && !$thread->summary() && !$thread->hasSuperthread() ) { |
438 | 438 | $this->output->addHTML("<p class=\"lqt_summary_notice\">If this discussion seems to be concluded, you are encouraged to <a href=\"{$this->permalinkUrl($thread, 'summarize')}\">write a summary</a>. There have been no changes here for at least $this->archive_start_days days.</p>"); |
439 | 439 | } |
440 | 440 | |
— | — | @@ -855,7 +855,7 @@ |
856 | 856 | $talkpage = $t->article()->getTitle()->getTalkpage(); |
857 | 857 | $talkpage_link = $this->user->getSkin()->makeKnownLinkObj($talkpage, '', $query); |
858 | 858 | |
859 | | - if ( $t->superthread() ) { |
| 859 | + if ( $t->hasSuperthread() ) { |
860 | 860 | $this->output->setSubtitle( "a fragment of <a href=\"{$this->permalinkUrl($t->topmostThread())}\">a discussion</a> from " . $talkpage_link ); |
861 | 861 | } else { |
862 | 862 | |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -106,7 +106,6 @@ |
107 | 107 | protected $rootId; |
108 | 108 | protected $articleId; |
109 | 109 | protected $summaryId; |
110 | | - protected $superthreadId; |
111 | 110 | |
112 | 111 | /* Actual objects loaded on demand from the above when accessors are called: */ |
113 | 112 | protected $root; |
— | — | @@ -117,6 +116,7 @@ |
118 | 117 | /* Simple strings: */ |
119 | 118 | protected $subject; |
120 | 119 | protected $timestamp; |
| 120 | + protected $path; |
121 | 121 | |
122 | 122 | /* Identity */ |
123 | 123 | protected $id; |
— | — | @@ -132,15 +132,24 @@ |
133 | 133 | } |
134 | 134 | |
135 | 135 | function setSuperthread($thread) { |
136 | | - $this->superthreadId = $thread->id(); |
137 | | - $this->touch(); |
| 136 | + var_dump("warning setSuperthread unimplemented"); |
138 | 137 | } |
139 | 138 | |
140 | 139 | function superthread() { |
141 | | - if ( !$this->superthreadId ) return null; |
142 | | - if ( !$this->superthread ) $this->superthread = Thread::newFromId($this->superthreadId); |
143 | | - return $this->superthread; |
| 140 | + var_dump("warning superthread unimplemented"); return; |
| 141 | + // TODO we have to find threads that may not be looked up yet |
| 142 | + // and look them up if needed. |
| 143 | + if( false === strpos($this->path,'.') ) { |
| 144 | + return null; |
| 145 | + } else { |
| 146 | + return array_slice( $this->path, strpos($this->path, '.') ); |
| 147 | + } |
144 | 148 | } |
| 149 | + |
| 150 | + function hasSuperthread() { |
| 151 | + if( false === strpos($this->path,'.') ) return false; |
| 152 | + else return true; |
| 153 | + } |
145 | 154 | |
146 | 155 | function topmostThread() { |
147 | 156 | if ( !$this->superthread() ) return $this; |
— | — | @@ -274,8 +283,9 @@ |
275 | 284 | $lines[] = $line; |
276 | 285 | } |
277 | 286 | |
278 | | - foreach( $lines as $l ) { |
| 287 | + foreach( $lines as $key => $l ) { |
279 | 288 | if( $l->is_root ) { |
| 289 | + unset($lines[$key]); |
280 | 290 | $threads[] = Threads::buildLiveThread( &$lines, $l ); |
281 | 291 | } |
282 | 292 | } |
— | — | @@ -285,10 +295,11 @@ |
286 | 296 | |
287 | 297 | private static function buildLiveThread( $lines, $l ) { |
288 | 298 | $children = array(); |
289 | | - foreach( $lines as $m ) { |
| 299 | + foreach( $lines as $key => $m ) { |
290 | 300 | if ( $m->thread_path != $l->thread_path && |
291 | 301 | strpos( $m->thread_path, $l->thread_path ) === 0 ) { |
292 | 302 | // $m->path begins with $l->path; this is a child. |
| 303 | + unset($lines[$key]); |
293 | 304 | $children[] = Threads::buildLiveThread( &$lines, $m ); |
294 | 305 | } |
295 | 306 | } |