Exemple #1
0
 function getTOC($threads)
 {
     global $wgLang, $wgContLang;
     $html = '';
     $h2_header = Xml::tags('h2', null, wfMessage('lqt_contents_title')->parse());
     // Header row
     $headerRow = '';
     $headers = array('lqt_toc_thread_title', 'lqt_toc_thread_replycount', 'lqt_toc_thread_modified');
     foreach ($headers as $msg) {
         $headerRow .= Xml::tags('th', null, wfMessage($msg)->parse());
     }
     $headerRow = Xml::tags('tr', null, $headerRow);
     $headerRow = Xml::tags('thead', null, $headerRow);
     // Table body
     $rows = array();
     foreach ($threads as $thread) {
         if ($thread->root() && !$thread->root()->getContent() && !LqtView::threadContainsRepliesWithContent($thread)) {
             continue;
         }
         $row = '';
         $anchor = '#' . $this->anchorName($thread);
         $subject = Xml::tags('a', array('href' => $anchor), Threads::stripHTML($thread->formattedSubject()));
         $row .= Xml::tags('td', array('dir' => $wgContLang->getDir()), $subject);
         $row .= Xml::element('td', null, $wgLang->formatNum($thread->replyCount()));
         $timestamp = $wgLang->timeanddate($thread->modified(), true);
         $row .= Xml::element('td', null, $timestamp);
         $row = Xml::tags('tr', null, $row);
         $rows[] = $row;
     }
     $html .= $headerRow . "\n" . Xml::tags('tbody', null, implode("\n", $rows));
     $html = $h2_header . Xml::tags('table', array('class' => 'lqt_toc'), $html);
     // wrap our output in a div for containment
     $html = Xml::tags('div', array('class' => 'lqt-contents-wrapper'), $html);
     return $html;
 }