Example #1
0
 function execute($par)
 {
     global $wgOut;
     $langNames = Language::getLanguageNames();
     $this->setHeaders();
     $this->outputHeader();
     $matrix = new SiteMatrix();
     $localLanguageNames = self::getLocalLanguageNames();
     # Construct the HTML
     # Header row
     $s = Xml::openElement('table', array('class' => 'wikitable', 'id' => 'mw-sitematrix-table')) . "<tr>" . Xml::element('th', array('rowspan' => 2), wfMsg('sitematrix-language')) . Xml::element('th', array('colspan' => count($matrix->getSites())), wfMsg('sitematrix-project')) . "</tr>\n\t\t\t<tr>";
     foreach ($matrix->getNames() as $id => $name) {
         $url = $matrix->getSiteUrl($id);
         $s .= Xml::tags('th', null, "<a href=\"{$url}\">{$name}</a>");
     }
     $s .= "</tr>\n";
     # Bulk of table
     foreach ($matrix->getLangList() as $lang) {
         $anchor = strtolower('<a id="' . htmlspecialchars($lang) . '" name="' . htmlspecialchars($lang) . '"></a>');
         $s .= '<tr>';
         $attribs = array();
         if (isset($localLanguageNames[$lang])) {
             $attribs['title'] = $localLanguageNames[$lang];
         }
         $langDisplay = isset($langNames[$lang]) ? $langNames[$lang] : '';
         if (isset($localLanguageNames[$lang]) && strlen($localLanguageNames[$lang]) && $langDisplay != $localLanguageNames[$lang]) {
             $langDisplay .= ' (' . $localLanguageNames[$lang] . ')';
         }
         $s .= '<td>' . $anchor . Xml::element('strong', $attribs, $langDisplay) . '</td>';
         foreach ($matrix->getNames() as $site => $name) {
             $url = $matrix->getUrl($lang, $site);
             if ($matrix->exist($lang, $site)) {
                 # Wiki exists
                 $closed = $matrix->isClosed($lang, $site);
                 $s .= "<td>" . ($closed ? "<del>" : '') . "<a href=\"{$url}\">{$lang}</a>" . ($closed ? "</del>" : '') . '</td>';
             } else {
                 # Non-existent wiki
                 $s .= "<td><a href=\"{$url}\" class=\"new\">{$lang}</a></td>";
             }
         }
         $s .= "</tr>\n";
     }
     $language = $this->getLanguage();
     # Total
     $totalCount = 0;
     $s .= '<tr><th rowspan="2"><a id="total" name="total"></a>' . wfMsgHtml('sitematrix-sitetotal') . '</th>';
     foreach ($matrix->getNames() as $site => $name) {
         $url = $matrix->getSiteUrl($site);
         $count = $matrix->getCountPerSite($site);
         $totalCount += $count;
         $count = $language->formatNum($count);
         $s .= "<th><a href=\"{$url}\">{$count}</a></th>";
     }
     $s .= '</tr>';
     $s .= '<tr>';
     $noProjects = count($matrix->getNames());
     $totalCount = $language->formatNum($totalCount);
     $s .= "<th colspan=\"{$noProjects}\">{$totalCount}</th>";
     $s .= '</tr>';
     $s .= Xml::closeElement('table') . "\n";
     # Specials
     $s .= '<h2 id="mw-sitematrix-others">' . wfMsg('sitematrix-others') . '</h2>';
     $s .= Xml::openElement('table', array('class' => 'wikitable', 'id' => 'mw-sitematrix-other-table')) . "<tr>" . Xml::element('th', null, wfMsg('sitematrix-other-projects')) . "</tr>";
     foreach ($matrix->getSpecials() as $special) {
         list($lang, $site) = $special;
         $langhost = str_replace('_', '-', $lang);
         $url = $matrix->getUrl($lang, $site);
         # Handle options
         $flags = array();
         if ($matrix->isPrivate($lang . $site)) {
             $flags[] = wfMsgHtml('sitematrix-private');
         }
         if ($matrix->isFishbowl($lang . $site)) {
             $flags[] = wfMsgHtml('sitematrix-fishbowl');
         }
         $flagsStr = implode(', ', $flags);
         if ($site != 'wiki') {
             $langhost .= $site;
         }
         $closed = $matrix->isClosed($lang, $site);
         $s .= '<tr><td>' . ($closed ? '<del>' : '') . $language->specialList('<a href="' . $url . '/">' . $langhost . "</a>", $flagsStr) . ($closed ? '</del>' : '') . "</td></tr>\n";
     }
     $s .= Xml::closeElement('table') . "\n";
     $wgOut->addHTML($s);
     $wgOut->addWikiMsg('sitematrix-total', $language->formatNum($matrix->getCount()));
 }